aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS6
-rw-r--r--Documentation/DMA-mapping.txt4
-rw-r--r--Documentation/DocBook/libata.tmpl2
-rw-r--r--Documentation/feature-removal-schedule.txt8
-rw-r--r--Documentation/filesystems/vfs.txt12
-rw-r--r--Documentation/isdn/README.gigaset286
-rw-r--r--Documentation/kbuild/modules.txt2
-rw-r--r--Documentation/laptop-mode.txt10
-rw-r--r--Documentation/memory-barriers.txt68
-rw-r--r--Documentation/mtrr.txt23
-rw-r--r--Documentation/scsi/scsi_eh.txt14
-rw-r--r--Documentation/scsi/scsi_mid_low_api.txt19
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl16
-rw-r--r--Documentation/vm/hugetlbpage.txt20
-rw-r--r--Documentation/x86_64/boot-options.txt5
-rw-r--r--Kbuild2
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile58
-rw-r--r--arch/alpha/Kconfig5
-rw-r--r--arch/alpha/kernel/alpha_ksyms.c1
-rw-r--r--arch/alpha/kernel/setup.c17
-rw-r--r--arch/alpha/kernel/smp.c8
-rw-r--r--arch/arm/Kconfig6
-rw-r--r--arch/arm/boot/compressed/vmlinux.lds.in1
-rw-r--r--arch/arm/configs/at91rm9200dk_defconfig2
-rw-r--r--arch/arm/configs/at91rm9200ek_defconfig2
-rw-r--r--arch/arm/kernel/armksyms.c14
-rw-r--r--arch/arm/kernel/setup.c9
-rw-r--r--arch/arm/mach-at91rm9200/Makefile9
-rw-r--r--arch/arm/mach-at91rm9200/board-csb337.c3
-rw-r--r--arch/arm/mach-at91rm9200/board-csb637.c3
-rw-r--r--arch/arm/mach-at91rm9200/board-dk.c10
-rw-r--r--arch/arm/mach-at91rm9200/board-ek.c10
-rw-r--r--arch/arm/mach-at91rm9200/devices.c154
-rw-r--r--arch/arm/mach-at91rm9200/leds.c100
-rw-r--r--arch/arm/mach-ep93xx/core.c10
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c39
-rw-r--r--arch/arm/mach-imx/dma.c511
-rw-r--r--arch/arm/mach-imx/generic.c13
-rw-r--r--arch/arm/mach-imx/mx1ads.c18
-rw-r--r--arch/arm/mach-ixp23xx/espresso.c9
-rw-r--r--arch/arm/mach-ixp23xx/pci.c18
-rw-r--r--arch/arm/mach-omap1/Kconfig20
-rw-r--r--arch/arm/mach-omap1/Makefile11
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c116
-rw-r--r--arch/arm/mach-omap1/board-generic.c2
-rw-r--r--arch/arm/mach-omap1/board-h2.c200
-rw-r--r--arch/arm/mach-omap1/board-h3.c277
-rw-r--r--arch/arm/mach-omap1/board-innovator.c56
-rw-r--r--arch/arm/mach-omap1/board-netstar.c160
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c268
-rw-r--r--arch/arm/mach-omap1/board-osk.c95
-rw-r--r--arch/arm/mach-omap1/board-palmte.c12
-rw-r--r--arch/arm/mach-omap1/board-perseus2.c123
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c8
-rw-r--r--arch/arm/mach-omap1/clock.c9
-rw-r--r--arch/arm/mach-omap1/clock.h91
-rw-r--r--arch/arm/mach-omap1/devices.c45
-rw-r--r--arch/arm/mach-omap1/io.c4
-rw-r--r--arch/arm/mach-omap1/irq.c18
-rw-r--r--arch/arm/mach-omap1/mux.c30
-rw-r--r--arch/arm/mach-omap1/pm.c770
-rw-r--r--arch/arm/mach-omap1/serial.c6
-rw-r--r--arch/arm/mach-omap1/sleep.S (renamed from arch/arm/plat-omap/sleep.S)111
-rw-r--r--arch/arm/mach-omap1/time.c197
-rw-r--r--arch/arm/mach-omap2/Kconfig3
-rw-r--r--arch/arm/mach-omap2/Makefile6
-rw-r--r--arch/arm/mach-omap2/board-apollon.c285
-rw-r--r--arch/arm/mach-omap2/board-h4.c174
-rw-r--r--arch/arm/mach-omap2/clock.c79
-rw-r--r--arch/arm/mach-omap2/clock.h37
-rw-r--r--arch/arm/mach-omap2/devices.c46
-rw-r--r--arch/arm/mach-omap2/io.c21
-rw-r--r--arch/arm/mach-omap2/memory.c102
-rw-r--r--arch/arm/mach-omap2/memory.h34
-rw-r--r--arch/arm/mach-omap2/mux.c45
-rw-r--r--arch/arm/mach-omap2/pm.c149
-rw-r--r--arch/arm/mach-omap2/prcm-regs.h (renamed from arch/arm/mach-omap2/prcm.h)188
-rw-r--r--arch/arm/mach-omap2/prcm.c40
-rw-r--r--arch/arm/mach-omap2/sleep.S144
-rw-r--r--arch/arm/mach-omap2/sram-fn.S4
-rw-r--r--arch/arm/mach-pxa/poodle.c4
-rw-r--r--arch/arm/mach-s3c2410/Kconfig7
-rw-r--r--arch/arm/mach-s3c2410/Makefile2
-rw-r--r--arch/arm/mach-s3c2410/clock.c6
-rw-r--r--arch/arm/mach-s3c2410/common-smdk.c135
-rw-r--r--arch/arm/mach-s3c2410/common-smdk.h15
-rw-r--r--arch/arm/mach-s3c2410/mach-anubis.c4
-rw-r--r--arch/arm/mach-s3c2410/mach-rx3715.c35
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2410.c13
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2440.c17
-rw-r--r--arch/arm/mach-sa1100/collie.c72
-rw-r--r--arch/arm/mm/cache-v4wb.S26
-rw-r--r--arch/arm/mm/consistent.c17
-rw-r--r--arch/arm/mm/init.c7
-rw-r--r--arch/arm/mm/mm-armv.c11
-rw-r--r--arch/arm/mm/proc-sa110.S25
-rw-r--r--arch/arm/mm/proc-sa1100.S37
-rw-r--r--arch/arm/mm/proc-xsc3.S2
-rw-r--r--arch/arm/plat-omap/Kconfig4
-rw-r--r--arch/arm/plat-omap/Makefile6
-rw-r--r--arch/arm/plat-omap/clock.c68
-rw-r--r--arch/arm/plat-omap/devices.c159
-rw-r--r--arch/arm/plat-omap/dma.c6
-rw-r--r--arch/arm/plat-omap/dmtimer.c26
-rw-r--r--arch/arm/plat-omap/fb.c80
-rw-r--r--arch/arm/plat-omap/gpio.c86
-rw-r--r--arch/arm/plat-omap/mcbsp.c345
-rw-r--r--arch/arm/plat-omap/ocpi.c3
-rw-r--r--arch/arm/plat-omap/pm.c1
-rw-r--r--arch/arm/plat-omap/sram.c143
-rw-r--r--arch/arm/plat-omap/timer32k.c325
-rw-r--r--arch/arm/vfp/vfpdouble.c29
-rw-r--r--arch/arm/vfp/vfphw.S6
-rw-r--r--arch/arm/vfp/vfpsingle.c9
-rw-r--r--arch/arm26/kernel/armksyms.c1
-rw-r--r--arch/cris/kernel/crisksyms.c1
-rw-r--r--arch/frv/kernel/entry.S26
-rw-r--r--arch/frv/kernel/frv_ksyms.c1
-rw-r--r--arch/h8300/kernel/h8300_ksyms.c1
-rw-r--r--arch/i386/Kconfig73
-rw-r--r--arch/i386/Kconfig.cpu2
-rw-r--r--arch/i386/boot/video.S5
-rw-r--r--arch/i386/kernel/acpi/boot.c10
-rw-r--r--arch/i386/kernel/apic.c23
-rw-r--r--arch/i386/kernel/cpu/amd.c2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c18
-rw-r--r--arch/i386/kernel/i386_ksyms.c1
-rw-r--r--arch/i386/kernel/mpparse.c43
-rw-r--r--arch/i386/kernel/reboot_fixups.c2
-rw-r--r--arch/i386/kernel/setup.c36
-rw-r--r--arch/i386/kernel/traps.c16
-rw-r--r--arch/i386/mach-voyager/voyager_cat.c10
-rw-r--r--arch/i386/mm/init.c2
-rw-r--r--arch/i386/pci/direct.c13
-rw-r--r--arch/i386/pci/mmconfig.c67
-rw-r--r--arch/ia64/Kconfig19
-rw-r--r--arch/ia64/kernel/acpi-ext.c143
-rw-r--r--arch/ia64/kernel/entry.S3
-rw-r--r--arch/ia64/kernel/mca.c33
-rw-r--r--arch/ia64/kernel/mca_asm.S10
-rw-r--r--arch/ia64/kernel/module.c2
-rw-r--r--arch/ia64/mm/fault.c3
-rw-r--r--arch/ia64/sn/kernel/xpc_channel.c2
-rw-r--r--arch/m32r/Kconfig5
-rw-r--r--arch/m32r/kernel/m32r_ksyms.c29
-rw-r--r--arch/m32r/kernel/setup.c12
-rw-r--r--arch/m32r/kernel/smpboot.c19
-rw-r--r--arch/m32r/lib/Makefile4
-rw-r--r--arch/m32r/lib/getuser.S88
-rw-r--r--arch/m32r/lib/putuser.S84
-rw-r--r--arch/m68k/kernel/m68k_ksyms.c1
-rw-r--r--arch/m68knommu/kernel/m68k_ksyms.c1
-rw-r--r--arch/mips/Kconfig5
-rw-r--r--arch/mips/kernel/mips_ksyms.c1
-rw-r--r--arch/parisc/Kconfig5
-rw-r--r--arch/parisc/kernel/parisc_ksyms.c1
-rw-r--r--arch/powerpc/Kconfig5
-rw-r--r--arch/ppc/boot/lib/Makefile2
-rw-r--r--arch/s390/Makefile1
-rw-r--r--arch/s390/defconfig48
-rw-r--r--arch/sh/Kconfig5
-rw-r--r--arch/sh/kernel/sh_ksyms.c1
-rw-r--r--arch/sh64/kernel/sh_ksyms.c1
-rw-r--r--arch/sparc/kernel/smp.c2
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c1
-rw-r--r--arch/sparc/math-emu/Makefile2
-rw-r--r--arch/sparc64/Kconfig3
-rw-r--r--arch/sparc64/defconfig10
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c2
-rw-r--r--arch/sparc64/kernel/ptrace.c23
-rw-r--r--arch/sparc64/kernel/setup.c2
-rw-r--r--arch/sparc64/kernel/smp.c41
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c1
-rw-r--r--arch/sparc64/kernel/traps.c4
-rw-r--r--arch/um/Makefile3
-rw-r--r--arch/um/drivers/cow.h2
-rw-r--r--arch/um/drivers/cow_sys.h2
-rw-r--r--arch/um/drivers/cow_user.c94
-rw-r--r--arch/um/drivers/mconsole_kern.c8
-rw-r--r--arch/um/drivers/net_user.c4
-rw-r--r--arch/um/drivers/slirp_user.c2
-rw-r--r--arch/um/include/kern_util.h4
-rw-r--r--arch/um/include/tt/tt.h3
-rw-r--r--arch/um/include/user.h6
-rw-r--r--arch/um/include/user_util.h3
-rw-r--r--arch/um/kernel/ksyms.c5
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c2
-rw-r--r--arch/um/os-Linux/helper.c10
-rw-r--r--arch/um/os-Linux/mem.c23
-rw-r--r--arch/um/os-Linux/sigio.c2
-rw-r--r--arch/um/os-Linux/skas/mem.c4
-rw-r--r--arch/um/os-Linux/skas/process.c4
-rw-r--r--arch/um/os-Linux/sys-i386/tls.c1
-rw-r--r--arch/um/os-Linux/umid.c15
-rw-r--r--arch/um/os-Linux/user_syms.c9
-rw-r--r--arch/um/scripts/Makefile.rules6
-rw-r--r--arch/um/sys-i386/ksyms.c4
-rw-r--r--arch/um/sys-i386/ptrace_user.c2
-rw-r--r--arch/um/sys-i386/signal.c2
-rw-r--r--arch/um/sys-i386/tls.c2
-rw-r--r--arch/um/sys-x86_64/signal.c2
-rw-r--r--arch/v850/kernel/v850_ksyms.c1
-rw-r--r--arch/x86_64/Kconfig10
-rw-r--r--arch/x86_64/Makefile24
-rw-r--r--arch/x86_64/boot/video.S5
-rw-r--r--arch/x86_64/defconfig42
-rw-r--r--arch/x86_64/ia32/ia32entry.S23
-rw-r--r--arch/x86_64/kernel/aperture.c2
-rw-r--r--arch/x86_64/kernel/e820.c36
-rw-r--r--arch/x86_64/kernel/entry.S28
-rw-r--r--arch/x86_64/kernel/mce.c8
-rw-r--r--arch/x86_64/kernel/nmi.c7
-rw-r--r--arch/x86_64/kernel/pci-dma.c2
-rw-r--r--arch/x86_64/kernel/process.c10
-rw-r--r--arch/x86_64/kernel/ptrace.c5
-rw-r--r--arch/x86_64/kernel/setup.c4
-rw-r--r--arch/x86_64/kernel/time.c4
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S2
-rw-r--r--arch/x86_64/kernel/x8664_ksyms.c3
-rw-r--r--arch/x86_64/mm/init.c37
-rw-r--r--arch/x86_64/mm/numa.c46
-rw-r--r--arch/x86_64/mm/srat.c170
-rw-r--r--arch/x86_64/pci/mmconfig.c53
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c1
-rw-r--r--drivers/acpi/Kconfig2
-rw-r--r--drivers/base/node.c2
-rw-r--r--drivers/cdrom/aztcd.c2
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/applicom.c2
-rw-r--r--drivers/char/dtlk.c2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c2
-rw-r--r--drivers/char/random.c1
-rw-r--r--drivers/char/tlclk.c36
-rw-r--r--drivers/char/tty_io.c26
-rw-r--r--drivers/hwmon/hdaps.c14
-rw-r--r--drivers/isdn/gigaset/Kconfig4
-rw-r--r--drivers/isdn/gigaset/asyncdata.c132
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c870
-rw-r--r--drivers/isdn/gigaset/common.c505
-rw-r--r--drivers/isdn/gigaset/ev-layer.c667
-rw-r--r--drivers/isdn/gigaset/gigaset.h600
-rw-r--r--drivers/isdn/gigaset/i4l.c231
-rw-r--r--drivers/isdn/gigaset/interface.c235
-rw-r--r--drivers/isdn/gigaset/isocdata.c139
-rw-r--r--drivers/isdn/gigaset/proc.c51
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c455
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c20
-rw-r--r--drivers/leds/Kconfig27
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-s3c24xx.c163
-rw-r--r--drivers/md/Kconfig11
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/bt8xx/Makefile2
-rw-r--r--drivers/media/video/cx25840/Makefile2
-rw-r--r--drivers/media/video/cx88/Makefile6
-rw-r--r--drivers/media/video/em28xx/Makefile2
-rw-r--r--drivers/media/video/saa7134/Makefile6
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c3
-rw-r--r--drivers/mmc/Kconfig18
-rw-r--r--drivers/mmc/Makefile2
-rw-r--r--drivers/mmc/at91_mci.c988
-rw-r--r--drivers/mmc/imxmmc.c1096
-rw-r--r--drivers/mmc/imxmmc.h67
-rw-r--r--drivers/mtd/devices/Kconfig13
-rw-r--r--drivers/mtd/devices/Makefile1
-rw-r--r--drivers/mtd/devices/blkmtd.c819
-rw-r--r--drivers/net/b44.c64
-rw-r--r--drivers/net/bnx2.c2
-rw-r--r--drivers/net/chelsio/Makefile2
-rw-r--r--drivers/net/hydra.h177
-rw-r--r--drivers/net/irda/irda-usb.c363
-rw-r--r--drivers/net/irda/irda-usb.h43
-rw-r--r--drivers/net/irda/smsc-ircc2.c311
-rw-r--r--drivers/net/ixgb/ixgb_main.c13
-rw-r--r--drivers/net/mv643xx_eth.c19
-rw-r--r--drivers/net/natsemi.c2
-rw-r--r--drivers/net/netconsole.c1
-rw-r--r--drivers/net/pcmcia/axnet_cs.c2
-rw-r--r--drivers/net/skge.c2
-rw-r--r--drivers/net/sky2.c6
-rw-r--r--drivers/net/sky2.h2
-rw-r--r--drivers/net/starfire.c2
-rw-r--r--drivers/net/tg3.c100
-rw-r--r--drivers/net/tg3.h3
-rw-r--r--drivers/net/typhoon.c2
-rw-r--r--drivers/net/via-rhine.c7
-rw-r--r--drivers/net/wan/Kconfig97
-rw-r--r--drivers/net/wan/Makefile13
-rw-r--r--drivers/net/wan/sdla_chdlc.c4428
-rw-r--r--drivers/net/wan/sdla_fr.c5061
-rw-r--r--drivers/net/wan/sdla_ft1.c345
-rw-r--r--drivers/net/wan/sdla_ppp.c3430
-rw-r--r--drivers/net/wan/sdla_x25.c5497
-rw-r--r--drivers/net/wan/sdladrv.c2314
-rw-r--r--drivers/net/wan/sdlamain.c1346
-rw-r--r--drivers/net/wan/wanpipe_multppp.c2358
-rw-r--r--drivers/parport/parport_serial.c2
-rw-r--r--drivers/rtc/Kconfig10
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/class.c2
-rw-r--r--drivers/rtc/rtc-ds1672.c72
-rw-r--r--drivers/rtc/rtc-ep93xx.c2
-rw-r--r--drivers/rtc/rtc-m48t86.c9
-rw-r--r--drivers/rtc/rtc-pcf8563.c11
-rw-r--r--drivers/rtc/rtc-proc.c2
-rw-r--r--drivers/rtc/rtc-rs5c372.c28
-rw-r--r--drivers/rtc/rtc-sa1100.c14
-rw-r--r--drivers/rtc/rtc-test.c3
-rw-r--r--drivers/rtc/rtc-vr41xx.c (renamed from drivers/char/vr41xx_rtc.c)404
-rw-r--r--drivers/rtc/rtc-x1205.c29
-rw-r--r--drivers/s390/block/dasd.c45
-rw-r--r--drivers/s390/block/dasd_proc.c17
-rw-r--r--drivers/s390/char/keyboard.c2
-rw-r--r--drivers/s390/char/tape_block.c4
-rw-r--r--drivers/s390/char/tape_core.c10
-rw-r--r--drivers/s390/cio/blacklist.c4
-rw-r--r--drivers/s390/cio/cio.c2
-rw-r--r--drivers/s390/cio/cio_debug.h22
-rw-r--r--drivers/scsi/3w-xxxx.c3
-rw-r--r--drivers/scsi/ahci.c1
-rw-r--r--drivers/scsi/ata_piix.c1
-rw-r--r--drivers/scsi/hosts.c12
-rw-r--r--drivers/scsi/libata-core.c1
-rw-r--r--drivers/scsi/libata-scsi.c8
-rw-r--r--drivers/scsi/libata.h1
-rw-r--r--drivers/scsi/pdc_adma.c1
-rw-r--r--drivers/scsi/sata_mv.c3
-rw-r--r--drivers/scsi/sata_nv.c1
-rw-r--r--drivers/scsi/sata_promise.c1
-rw-r--r--drivers/scsi/sata_qstor.c1
-rw-r--r--drivers/scsi/sata_sil.c1
-rw-r--r--drivers/scsi/sata_sil24.c1
-rw-r--r--drivers/scsi/sata_sis.c1
-rw-r--r--drivers/scsi/sata_svw.c1
-rw-r--r--drivers/scsi/sata_sx4.c1
-rw-r--r--drivers/scsi/sata_uli.c1
-rw-r--r--drivers/scsi/sata_via.c1
-rw-r--r--drivers/scsi/sata_vsc.c1
-rw-r--r--drivers/scsi/scsi_error.c4
-rw-r--r--drivers/sn/ioc3.c5
-rw-r--r--drivers/usb/serial/option.c5
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/aty/atyfb_base.c2
-rw-r--r--drivers/video/fbmem.c5
-rw-r--r--drivers/video/vesafb.c27
-rw-r--r--fs/9p/vfs_super.c13
-rw-r--r--fs/Kconfig3
-rw-r--r--fs/configfs/dir.c2
-rw-r--r--fs/eventpoll.c4
-rw-r--r--fs/exec.c19
-rw-r--r--fs/ext3/resize.c1
-rw-r--r--fs/fifo.c65
-rw-r--r--fs/fuse/dev.c256
-rw-r--r--fs/fuse/dir.c118
-rw-r--r--fs/fuse/file.c56
-rw-r--r--fs/fuse/fuse_i.h61
-rw-r--r--fs/fuse/inode.c135
-rw-r--r--fs/inotify.c2
-rw-r--r--fs/namespace.c7
-rw-r--r--fs/nfsd/auth.c46
-rw-r--r--fs/nfsd/export.c3
-rw-r--r--fs/nfsd/nfs3proc.c2
-rw-r--r--fs/nfsd/nfs4acl.c8
-rw-r--r--fs/nfsd/nfs4callback.c6
-rw-r--r--fs/nfsd/nfs4proc.c4
-rw-r--r--fs/nfsd/nfs4state.c150
-rw-r--r--fs/nfsd/nfs4xdr.c62
-rw-r--r--fs/nfsd/nfsproc.c2
-rw-r--r--fs/nfsd/vfs.c6
-rw-r--r--fs/ocfs2/cluster/heartbeat.c40
-rw-r--r--fs/ocfs2/dlm/userdlm.c74
-rw-r--r--fs/ocfs2/file.c19
-rw-r--r--fs/pipe.c314
-rw-r--r--fs/proc/vmcore.c4
-rw-r--r--fs/read_write.c2
-rw-r--r--fs/select.c30
-rw-r--r--fs/splice.c649
-rw-r--r--fs/sync.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c18
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c113
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h1
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c120
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.h11
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c11
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h12
-rw-r--r--fs/xfs/quota/xfs_qm.c17
-rw-r--r--fs/xfs/quota/xfs_trans_dquot.c68
-rw-r--r--fs/xfs/xfs_bmap.c11
-rw-r--r--fs/xfs/xfs_bmap.h9
-rw-r--r--fs/xfs/xfs_clnt.h1
-rw-r--r--fs/xfs/xfs_error.h3
-rw-r--r--fs/xfs/xfs_ialloc.c15
-rw-r--r--fs/xfs/xfs_iget.c29
-rw-r--r--fs/xfs/xfs_inode.c27
-rw-r--r--fs/xfs/xfs_inode.h1
-rw-r--r--fs/xfs/xfs_mount.c73
-rw-r--r--fs/xfs/xfs_mount.h5
-rw-r--r--fs/xfs/xfs_quota.h5
-rw-r--r--fs/xfs/xfs_vfsops.c10
-rw-r--r--fs/xfs/xfs_vnodeops.c4
-rw-r--r--include/asm-alpha/numnodes.h7
-rw-r--r--include/asm-arm/arch-at91rm9200/at91rm9200_mci.h104
-rw-r--r--include/asm-arm/arch-at91rm9200/board.h24
-rw-r--r--include/asm-arm/arch-cl7500/hardware.h4
-rw-r--r--include/asm-arm/arch-cl7500/memory.h6
-rw-r--r--include/asm-arm/arch-ebsa110/debug-macro.S2
-rw-r--r--include/asm-arm/arch-ebsa110/hardware.h3
-rw-r--r--include/asm-arm/arch-ebsa110/memory.h6
-rw-r--r--include/asm-arm/arch-ebsa110/uncompress.h2
-rw-r--r--include/asm-arm/arch-ebsa285/hardware.h7
-rw-r--r--include/asm-arm/arch-ebsa285/memory.h12
-rw-r--r--include/asm-arm/arch-ep93xx/ts72xx.h11
-rw-r--r--include/asm-arm/arch-imx/dma.h17
-rw-r--r--include/asm-arm/arch-imx/imx-dma.h90
-rw-r--r--include/asm-arm/arch-imx/mmc.h12
-rw-r--r--include/asm-arm/arch-ixp23xx/debug-macro.S3
-rw-r--r--include/asm-arm/arch-ixp23xx/memory.h17
-rw-r--r--include/asm-arm/arch-ixp23xx/platform.h1
-rw-r--r--include/asm-arm/arch-l7200/hardware.h3
-rw-r--r--include/asm-arm/arch-l7200/memory.h6
-rw-r--r--include/asm-arm/arch-lh7a40x/memory.h2
-rw-r--r--include/asm-arm/arch-omap/aic23.h4
-rw-r--r--include/asm-arm/arch-omap/board-ams-delta.h65
-rw-r--r--include/asm-arm/arch-omap/board-apollon.h45
-rw-r--r--include/asm-arm/arch-omap/board-h2.h4
-rw-r--r--include/asm-arm/arch-omap/board-h3.h4
-rw-r--r--include/asm-arm/arch-omap/board-h4.h8
-rw-r--r--include/asm-arm/arch-omap/board-netstar.h19
-rw-r--r--include/asm-arm/arch-omap/board-nokia.h54
-rw-r--r--include/asm-arm/arch-omap/board-perseus2.h4
-rw-r--r--include/asm-arm/arch-omap/board.h30
-rw-r--r--include/asm-arm/arch-omap/clock.h13
-rw-r--r--include/asm-arm/arch-omap/dma.h1
-rw-r--r--include/asm-arm/arch-omap/dmtimer.h1
-rw-r--r--include/asm-arm/arch-omap/dsp.h6
-rw-r--r--include/asm-arm/arch-omap/dsp_common.h13
-rw-r--r--include/asm-arm/arch-omap/gpioexpander.h24
-rw-r--r--include/asm-arm/arch-omap/hardware.h8
-rw-r--r--include/asm-arm/arch-omap/irda.h36
-rw-r--r--include/asm-arm/arch-omap/irqs.h5
-rw-r--r--include/asm-arm/arch-omap/keypad.h36
-rw-r--r--include/asm-arm/arch-omap/lcd_lph8923.h14
-rw-r--r--include/asm-arm/arch-omap/mcbsp.h65
-rw-r--r--include/asm-arm/arch-omap/mcspi.h16
-rw-r--r--include/asm-arm/arch-omap/menelaus.h2
-rw-r--r--include/asm-arm/arch-omap/mux.h54
-rw-r--r--include/asm-arm/arch-omap/omap-alsa.h124
-rw-r--r--include/asm-arm/arch-omap/omapfb.h98
-rw-r--r--include/asm-arm/arch-omap/param.h8
-rw-r--r--include/asm-arm/arch-omap/pm.h81
-rw-r--r--include/asm-arm/arch-omap/prcm.h404
-rw-r--r--include/asm-arm/arch-omap/sram.h2
-rw-r--r--include/asm-arm/arch-omap/system.h17
-rw-r--r--include/asm-arm/arch-rpc/hardware.h3
-rw-r--r--include/asm-arm/arch-rpc/memory.h6
-rw-r--r--include/asm-arm/arch-s3c2410/entry-macro.S167
-rw-r--r--include/asm-arm/arch-s3c2410/leds-gpio.h28
-rw-r--r--include/asm-arm/arch-sa1100/hardware.h4
-rw-r--r--include/asm-arm/arch-sa1100/memory.h7
-rw-r--r--include/asm-arm/arch-shark/hardware.h6
-rw-r--r--include/asm-arm/arch-shark/memory.h6
-rw-r--r--include/asm-arm/dma-mapping.h22
-rw-r--r--include/asm-arm/fpstate.h2
-rw-r--r--include/asm-arm/memory.h16
-rw-r--r--include/asm-arm/numnodes.h26
-rw-r--r--include/asm-arm/pgtable-hwdef.h1
-rw-r--r--include/asm-arm/pgtable.h1
-rw-r--r--include/asm-arm/vfpmacros.h8
-rw-r--r--include/asm-cris/system.h1
-rw-r--r--include/asm-cris/unistd.h2
-rw-r--r--include/asm-frv/system.h2
-rw-r--r--include/asm-frv/unistd.h2
-rw-r--r--include/asm-h8300/system.h2
-rw-r--r--include/asm-h8300/unistd.h2
-rw-r--r--include/asm-i386/apic.h2
-rw-r--r--include/asm-i386/e820.h4
-rw-r--r--include/asm-i386/hpet.h1
-rw-r--r--include/asm-i386/mpspec.h1
-rw-r--r--include/asm-i386/numnodes.h18
-rw-r--r--include/asm-i386/unistd.h6
-rw-r--r--include/asm-ia64/acpi-ext.h11
-rw-r--r--include/asm-ia64/kdebug.h2
-rw-r--r--include/asm-ia64/mca.h5
-rw-r--r--include/asm-ia64/mutex.h2
-rw-r--r--include/asm-ia64/numnodes.h20
-rw-r--r--include/asm-ia64/unistd.h5
-rw-r--r--include/asm-ia64/vga.h2
-rw-r--r--include/asm-m32r/numnodes.h15
-rw-r--r--include/asm-m32r/smp.h3
-rw-r--r--include/asm-m32r/system.h4
-rw-r--r--include/asm-m32r/uaccess.h266
-rw-r--r--include/asm-m32r/unistd.h2
-rw-r--r--include/asm-mips/numnodes.h7
-rw-r--r--include/asm-parisc/numnodes.h7
-rw-r--r--include/asm-powerpc/numnodes.h9
-rw-r--r--include/asm-s390/atomic.h2
-rw-r--r--include/asm-s390/ebcdic.h12
-rw-r--r--include/asm-sh/numnodes.h7
-rw-r--r--include/asm-sh/unistd.h2
-rw-r--r--include/asm-sh64/unistd.h2
-rw-r--r--include/asm-sparc/vga.h33
-rw-r--r--include/asm-sparc64/percpu.h2
-rw-r--r--include/asm-um/ptrace-i386.h3
-rw-r--r--include/asm-v850/system.h2
-rw-r--r--include/asm-x86_64/e820.h3
-rw-r--r--include/asm-x86_64/hpet.h2
-rw-r--r--include/asm-x86_64/ia32_unistd.h2
-rw-r--r--include/asm-x86_64/io.h2
-rw-r--r--include/asm-x86_64/mce.h7
-rw-r--r--include/asm-x86_64/numa.h3
-rw-r--r--include/asm-x86_64/numnodes.h12
-rw-r--r--include/asm-x86_64/timex.h2
-rw-r--r--include/asm-xtensa/system.h2
-rw-r--r--include/linux/bootmem.h1
-rw-r--r--include/linux/dma-mapping.h2
-rw-r--r--include/linux/fs.h19
-rw-r--r--include/linux/gfp.h2
-rw-r--r--include/linux/init.h3
-rw-r--r--include/linux/jiffies.h6
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/leds.h51
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/memory_hotplug.h14
-rw-r--r--include/linux/mm.h5
-rw-r--r--include/linux/netfilter.h42
-rw-r--r--include/linux/netfilter_ipv4.h2
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_h323.h52
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h (renamed from net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.h)0
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h (renamed from net/ipv4/netfilter/ip_conntrack_helper_h323_types.h)0
-rw-r--r--include/linux/netfilter_ipv6.h3
-rw-r--r--include/linux/numa.h8
-rw-r--r--include/linux/page-flags.h24
-rw-r--r--include/linux/pipe_fs_i.h24
-rw-r--r--include/linux/proc_fs.h2
-rw-r--r--include/linux/raid/md_p.h2
-rw-r--r--include/linux/sched.h11
-rw-r--r--include/linux/screen_info.h3
-rw-r--r--include/linux/sdla_asy.h226
-rw-r--r--include/linux/sdla_chdlc.h813
-rw-r--r--include/linux/sdla_ppp.h575
-rw-r--r--include/linux/sdla_x25.h772
-rw-r--r--include/linux/sdladrv.h66
-rw-r--r--include/linux/sdlapci.h72
-rw-r--r--include/linux/sdlasfm.h104
-rw-r--r--include/linux/seqlock.h4
-rw-r--r--include/linux/string.h17
-rw-r--r--include/linux/sunrpc/svc.h9
-rw-r--r--include/linux/swap.h1
-rw-r--r--include/linux/syscalls.h9
-rw-r--r--include/linux/tty_flip.h25
-rw-r--r--include/linux/vermagic.h7
-rw-r--r--include/linux/wanpipe.h483
-rw-r--r--include/net/inet6_hashtables.h70
-rw-r--r--include/net/ip.h1
-rw-r--r--include/net/x25device.h1
-rw-r--r--include/scsi/scsi_host.h1
-rw-r--r--include/scsi/scsi_transport.h5
-rw-r--r--include/sound/core.h2
-rw-r--r--include/sound/pcm.h3
-rw-r--r--init/Kconfig9
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/hrtimer.c1
-rw-r--r--kernel/irq/Makefile3
-rw-r--r--kernel/irq/migration.c5
-rw-r--r--kernel/panic.c1
-rw-r--r--kernel/sched.c62
-rw-r--r--kernel/signal.c1
-rw-r--r--kernel/sys_ni.c12
-rw-r--r--kernel/timer.c31
-rw-r--r--lib/string.c5
-rw-r--r--mm/bootmem.c9
-rw-r--r--mm/migrate.c8
-rw-r--r--mm/mmap.c34
-rw-r--r--mm/nommu.c18
-rw-r--r--mm/page-writeback.c5
-rw-r--r--mm/page_alloc.c70
-rw-r--r--mm/slab.c30
-rw-r--r--net/bluetooth/sco.c2
-rw-r--r--net/bridge/br_input.c3
-rw-r--r--net/bridge/br_netfilter.c13
-rw-r--r--net/bridge/netfilter/ebtables.c18
-rw-r--r--net/core/dev.c7
-rw-r--r--net/core/dv.c5
-rw-r--r--net/core/flow.c8
-rw-r--r--net/core/gen_estimator.c3
-rw-r--r--net/core/neighbour.c16
-rw-r--r--net/core/net-sysfs.c2
-rw-r--r--net/core/request_sock.c4
-rw-r--r--net/core/utils.c4
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/ipv4/fib_trie.c14
-rw-r--r--net/ipv4/icmp.c2
-rw-r--r--net/ipv4/ip_fragment.c15
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/ipcomp.c8
-rw-r--r--net/ipv4/ipip.c4
-rw-r--r--net/ipv4/netfilter.c50
-rw-r--r--net/ipv4/netfilter/Kconfig1
-rw-r--r--net/ipv4/netfilter/arp_tables.c4
-rw-r--r--net/ipv4/netfilter/arptable_filter.c19
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c66
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_icmp.c23
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c7
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_udp.c7
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c268
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_h323.c71
-rw-r--r--net/ipv4/netfilter/ip_nat_rule.c2
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c159
-rw-r--r--net/ipv4/netfilter/ip_queue.c31
-rw-r--r--net/ipv4/netfilter/ip_tables.c4
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c40
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c9
-rw-r--r--net/ipv4/netfilter/iptable_filter.c21
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c33
-rw-r--r--net/ipv4/netfilter/iptable_raw.c35
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c223
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c20
-rw-r--r--net/ipv4/proc.c4
-rw-r--r--net/ipv4/route.c2
-rw-r--r--net/ipv4/tunnel4.c8
-rw-r--r--net/ipv4/xfrm4_input.c4
-rw-r--r--net/ipv6/icmp.c4
-rw-r--r--net/ipv6/inet6_hashtables.c80
-rw-r--r--net/ipv6/ip6_tunnel.c12
-rw-r--r--net/ipv6/ipcomp6.c8
-rw-r--r--net/ipv6/netfilter.c52
-rw-r--r--net/ipv6/netfilter/ip6_queue.c31
-rw-r--r--net/ipv6/netfilter/ip6_tables.c4
-rw-r--r--net/ipv6/netfilter/ip6table_filter.c21
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c33
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c15
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c179
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c12
-rw-r--r--net/ipv6/proc.c4
-rw-r--r--net/ipv6/reassembly.c18
-rw-r--r--net/ipv6/sit.c2
-rw-r--r--net/ipv6/tunnel6.c8
-rw-r--r--net/netfilter/core.c51
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c50
-rw-r--r--net/netfilter/nf_conntrack_proto_udp.c50
-rw-r--r--net/netfilter/nf_conntrack_standalone.c115
-rw-r--r--net/netfilter/nf_queue.c49
-rw-r--r--net/netfilter/nfnetlink_log.c25
-rw-r--r--net/netfilter/nfnetlink_queue.c27
-rw-r--r--net/netfilter/x_tables.c4
-rw-r--r--net/sched/act_police.c8
-rw-r--r--net/sctp/proc.c2
-rw-r--r--net/socket.c6
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c14
-rw-r--r--net/wanrouter/af_wanpipe.c2
-rw-r--r--scripts/Kbuild.include5
-rw-r--r--scripts/Makefile.lib5
-rwxr-xr-x[-rw-r--r--]scripts/bloat-o-meter0
-rwxr-xr-x[-rw-r--r--]scripts/checkstack.pl0
-rw-r--r--scripts/gen_initramfs_list.sh225
-rw-r--r--scripts/kconfig/conf.c21
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/lxdialog/menubox.c19
-rw-r--r--scripts/mod/modpost.c2
-rwxr-xr-x[-rw-r--r--]scripts/namespace.pl0
-rwxr-xr-x[-rw-r--r--]scripts/show_delta0
-rwxr-xr-xscripts/ver_linux4
-rw-r--r--security/keys/key.c4
-rw-r--r--security/keys/keyring.c1
-rw-r--r--security/keys/process_keys.c41
-rw-r--r--security/selinux/xfrm.c4
-rw-r--r--sound/core/oss/pcm_oss.c7
-rw-r--r--sound/core/pcm.c2
-rw-r--r--sound/core/pcm_native.c6
-rw-r--r--sound/isa/ad1848/ad1848.c16
-rw-r--r--sound/isa/adlib.c11
-rw-r--r--sound/isa/cmi8330.c16
-rw-r--r--sound/isa/cs423x/cs4231.c16
-rw-r--r--sound/isa/cs423x/cs4236.c16
-rw-r--r--sound/isa/es1688/es1688.c16
-rw-r--r--sound/isa/es18xx.c16
-rw-r--r--sound/isa/gus/gusclassic.c16
-rw-r--r--sound/isa/gus/gusextreme.c16
-rw-r--r--sound/isa/gus/gusmax.c16
-rw-r--r--sound/isa/gus/interwave.c16
-rw-r--r--sound/isa/opl3sa2.c16
-rw-r--r--sound/isa/opti9xx/miro.c7
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c7
-rw-r--r--sound/isa/sb/sb16.c16
-rw-r--r--sound/isa/sb/sb8.c16
-rw-r--r--sound/isa/sgalaxy.c16
-rw-r--r--sound/isa/sscape.c16
-rw-r--r--sound/isa/wavefront/wavefront.c16
-rw-r--r--sound/oss/emu10k1/main.c3
-rw-r--r--sound/pci/ac97/ac97_codec.c1
-rw-r--r--sound/pci/als300.c5
-rw-r--r--sound/pci/au88x0/au88x0.h13
-rw-r--r--sound/pci/au88x0/au88x0_core.c2
-rw-r--r--sound/pci/au88x0/au88x0_eq.c2
-rw-r--r--sound/pci/au88x0/au88x0_pcm.c2
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c5
-rw-r--r--sound/pci/hda/patch_analog.c6
-rw-r--r--sound/pci/hda/patch_sigmatel.c3
-rw-r--r--sound/pci/via82xx.c1
-rw-r--r--usr/Makefile91
708 files changed, 17340 insertions, 37571 deletions
diff --git a/CREDITS b/CREDITS
index 0bf31eac6dc22..787564bc248b1 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3382,7 +3382,7 @@ S: Germany
N: Geert Uytterhoeven
E: geert@linux-m68k.org
-W: http://home.tvd.be/cr26864/
+W: http://users.telenet.be/geertu/
P: 1024/862678A6 C51D 361C 0BD1 4C90 B275 C553 6EEA 11BA 8626 78A6
D: m68k/Amiga and PPC/CHRP Longtrail coordinator
D: Frame buffer device and XF68_FBDev maintainer
@@ -3392,8 +3392,8 @@ D: Amiga Buddha and Catweasel chipset IDE
D: Atari Falcon chipset IDE
D: Amiga Gayle chipset IDE
D: mipsel NEC DDB Vrc-5074
-S: Emiel Vlieberghlaan 2A/21
-S: B-3010 Kessel-Lo
+S: Haterbeekstraat 55B
+S: B-3200 Aarschot
S: Belgium
N: Chris Vance
diff --git a/Documentation/DMA-mapping.txt b/Documentation/DMA-mapping.txt
index ee4bb73683cd4..10bf4deb96aab 100644
--- a/Documentation/DMA-mapping.txt
+++ b/Documentation/DMA-mapping.txt
@@ -194,7 +194,7 @@ document for how to handle this case.
Finally, if your device can only drive the low 24-bits of
address during PCI bus mastering you might do something like:
- if (pci_set_dma_mask(pdev, 0x00ffffff)) {
+ if (pci_set_dma_mask(pdev, DMA_24BIT_MASK)) {
printk(KERN_WARNING
"mydev: 24-bit DMA addressing not available.\n");
goto ignore_this_device;
@@ -212,7 +212,7 @@ functions (for example a sound card provides playback and record
functions) and the various different functions have _different_
DMA addressing limitations, you may wish to probe each mask and
only provide the functionality which the machine can handle. It
-is important that the last call to pci_set_dma_mask() be for the
+is important that the last call to pci_set_dma_mask() be for the
most specific mask.
Here is pseudo-code showing how this might be done:
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index 5bcbb6ee3bc03..f869b03929db4 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -705,7 +705,7 @@ and other resources, etc.
<sect1><title>ata_scsi_error()</title>
<para>
- ata_scsi_error() is the current hostt->eh_strategy_handler()
+ ata_scsi_error() is the current transportt->eh_strategy_handler()
for libata. As discussed above, this will be entered in two
cases - timeout and ATAPI error completion. This function
calls low level libata driver's eng_timeout() callback, the
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 59d0c74c79c95..293fed113dff3 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -71,14 +71,6 @@ Who: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
---------------------------
-What: remove EXPORT_SYMBOL(panic_timeout)
-When: April 2006
-Files: kernel/panic.c
-Why: No modular usage in the kernel.
-Who: Adrian Bunk <bunk@stusta.de>
-
----------------------------
-
What: remove EXPORT_SYMBOL(insert_resource)
When: April 2006
Files: kernel/resource.c
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index adaa899e5c903..3a2e5520c1e3a 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -694,7 +694,7 @@ struct file_operations
----------------------
This describes how the VFS can manipulate an open file. As of kernel
-2.6.13, the following members are defined:
+2.6.17, the following members are defined:
struct file_operations {
loff_t (*llseek) (struct file *, loff_t, int);
@@ -723,6 +723,10 @@ struct file_operations {
int (*check_flags)(int);
int (*dir_notify)(struct file *filp, unsigned long arg);
int (*flock) (struct file *, int, struct file_lock *);
+ ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned
+int);
+ ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned
+int);
};
Again, all methods are called without any locks being held, unless
@@ -790,6 +794,12 @@ otherwise noted.
flock: called by the flock(2) system call
+ splice_write: called by the VFS to splice data from a pipe to a file. This
+ method is used by the splice(2) system call
+
+ splice_read: called by the VFS to splice data from file to a pipe. This
+ method is used by the splice(2) system call
+
Note that the file operations are implemented by the specific
filesystem in which the inode resides. When opening a device node
(character or block special) most filesystems will call special
diff --git a/Documentation/isdn/README.gigaset b/Documentation/isdn/README.gigaset
new file mode 100644
index 0000000000000..85a64defd3856
--- /dev/null
+++ b/Documentation/isdn/README.gigaset
@@ -0,0 +1,286 @@
+GigaSet 307x Device Driver
+==========================
+
+1. Requirements
+ ------------
+1.1. Hardware
+ --------
+ This release supports the connection of the Gigaset 307x/417x family of
+ ISDN DECT bases via Gigaset M101 Data, Gigaset M105 Data or direct USB
+ connection. The following devices are reported to be compatible:
+ 307x/417x:
+ Gigaset SX255isdn
+ Gigaset SX353isdn
+ Sinus 45 [AB] isdn (Deutsche Telekom)
+ Sinus 721X/XA
+ Vox Chicago 390 ISDN (KPN Telecom)
+ M101:
+ Sinus 45 Data 1 (Telekom)
+ M105:
+ Gigaset USB Adapter DECT
+ Sinus 45 Data 2 (Telekom)
+ Sinus 721 data
+ Chicago 390 USB (KPN)
+ See also http://www.erbze.info/sinus_gigaset.htm and
+ http://gigaset307x.sourceforge.net/
+
+ We had also reports from users of Gigaset M105 who could use the drivers
+ with SX 100 and CX 100 ISDN bases (only in unimodem mode, see section 2.4.)
+ If you have another device that works with our driver, please let us know.
+ For example, Gigaset SX205isdn/Sinus 721 X SE and Gigaset SX303isdn bases
+ are just versions without answering machine of models known to work, so
+ they should work just as well; but so far we are lacking positive reports
+ on these.
+
+ Chances of getting an USB device to work are good if the output of
+ lsusb
+ at the command line contains one of the following:
+ ID 0681:0001
+ ID 0681:0002
+ ID 0681:0009
+ ID 0681:0021
+ ID 0681:0022
+
+1.2. Software
+ --------
+ The driver works with ISDN4linux and so can be used with any software
+ which is able to use ISDN4linux for ISDN connections (voice or data).
+ CAPI4Linux support is planned but not yet available.
+
+ There are some user space tools available at
+ http://sourceforge.net/projects/gigaset307x/
+ which provide access to additional device specific functions like SMS,
+ phonebook or call journal.
+
+
+2. How to use the driver
+ ---------------------
+2.1. Modules
+ -------
+ To get the device working, you have to load the proper kernel module. You
+ can do this using
+ modprobe modulename
+ where modulename is usb_gigaset (M105) or bas_gigaset (direct USB
+ connection to the base).
+
+2.2. Device nodes for user space programs
+ ------------------------------------
+ The device can be accessed from user space (eg. by the user space tools
+ mentioned in 1.2.) through the device nodes:
+
+ - /dev/ttyGU0 for M105 (USB data boxes)
+ - /dev/ttyGB0 for the base driver (direct USB connection)
+
+ You can also select a "default device" which is used by the frontends when
+ no device node is given as parameter, by creating a symlink /dev/ttyG to
+ one of them, eg.:
+
+ ln -s /dev/ttyGB0 /dev/ttyG
+
+2.3. ISDN4linux
+ ----------
+ This is the "normal" mode of operation. After loading the module you can
+ set up the ISDN system just as you'd do with any ISDN card.
+ Your distribution should provide some configuration utility.
+ If not, you can use some HOWTOs like
+ http://www.linuxhaven.de/dlhp/HOWTO/DE-ISDN-HOWTO-5.html
+ If this doesn't work, because you have some recent device like SX100 where
+ debug output (see section 3.2.) shows something like this when dialing
+ CMD Received: ERROR
+ Available Params: 0
+ Connection State: 0, Response: -1
+ gigaset_process_response: resp_code -1 in ConState 0 !
+ Timeout occurred
+ you might need to use unimodem mode:
+
+2.4. Unimodem mode
+ -------------
+ This is needed for some devices [e.g. SX100] as they have problems with
+ the "normal" commands.
+
+ If you have installed the command line tool gigacontr, you can enter
+ unimodem mode using
+ gigacontr --mode unimodem
+ You can switch back using
+ gigacontr --mode isdn
+
+ You can also load the driver using e.g.
+ modprobe usb_gigaset startmode=0
+ to prevent the driver from starting in "isdn4linux mode".
+
+ In this mode the device works like a modem connected to a serial port
+ (the /dev/ttyGU0, ... mentioned above) which understands the commands
+ ATZ init, reset
+ => OK or ERROR
+ ATD
+ ATDT dial
+ => OK, CONNECT,
+ BUSY,
+ NO DIAL TONE,
+ NO CARRIER,
+ NO ANSWER
+ <pause>+++<pause> change to command mode when connected
+ ATH hangup
+
+ You can use some configuration tool of your distribution to configure this
+ "modem" or configure pppd/wvdial manually. There are some example ppp
+ configuration files and chat scripts in the gigaset-VERSION/ppp directory.
+ Please note that the USB drivers are not able to change the state of the
+ control lines (the M105 driver can be configured to use some undocumented
+ control requests, if you really need the control lines, though). This means
+ you must use "Stupid Mode" if you are using wvdial or you should use the
+ nocrtscts option of pppd.
+ You must also assure that the ppp_async module is loaded with the parameter
+ flag_time=0. You can do this e.g. by adding a line like
+
+ options ppp_async flag_time=0
+
+ to /etc/modprobe.conf. If your distribution has some local module
+ configuration file like /etc/modprobe.conf.local,
+ using that should be preferred.
+
+2.5. Call-ID (CID) mode
+ ------------------
+ Call-IDs are numbers used to tag commands to, and responses from, the
+ Gigaset base in order to support the simultaneous handling of multiple
+ ISDN calls. Their use can be enabled ("CID mode") or disabled ("Unimodem
+ mode"). Without Call-IDs (in Unimodem mode), only a very limited set of
+ functions is available. It allows outgoing data connections only, but
+ does not signal incoming calls or other base events.
+
+ DECT cordless data devices (M10x) permanently occupy the cordless
+ connection to the base while Call-IDs are activated. As the Gigaset
+ bases only support one DECT data connection at a time, this prevents
+ other DECT cordless data devices from accessing the base.
+
+ During active operation, the driver switches to the necessary mode
+ automatically. However, for the reasons above, the mode chosen when
+ the device is not in use (idle) can be selected by the user.
+ - If you want to receive incoming calls, you can use the default
+ settings (CID mode).
+ - If you have several DECT data devices (M10x) which you want to use
+ in turn, select Unimodem mode by passing the parameter "cidmode=0" to
+ the driver ("modprobe usb_gigaset cidmode=0" or modprobe.conf).
+
+ If you want both of these at once, you are out of luck.
+
+ You can also use /sys/module/<name>/parameters/cidmode for changing
+ the CID mode setting (<name> is usb_gigaset or bas_gigaset).
+
+
+3. Troubleshooting
+ ---------------
+3.1. Solutions to frequently reported problems
+ -----------------------------------------
+ Problem:
+ You have a slow provider and isdn4linux gives up dialing too early.
+ Solution:
+ Load the isdn module using the dialtimeout option. You can do this e.g.
+ by adding a line like
+
+ options isdn dialtimeout=15
+
+ to /etc/modprobe.conf. If your distribution has some local module
+ configuration file like /etc/modprobe.conf.local,
+ using that should be preferred.
+
+ Problem:
+ Your isdn script aborts with a message about isdnlog.
+ Solution:
+ Try deactivating (or commenting out) isdnlog. This driver does not
+ support it.
+
+ Problem:
+ You have two or more DECT data adapters (M101/M105) and only the
+ first one you turn on works.
+ Solution:
+ Select Unimodem mode for all DECT data adapters. (see section 2.4.)
+
+3.2. Telling the driver to provide more information
+ ----------------------------------------------
+ Building the driver with the "Gigaset debugging" kernel configuration
+ option (CONFIG_GIGASET_DEBUG) gives it the ability to produce additional
+ information useful for debugging.
+
+ You can control the amount of debugging information the driver produces by
+ writing an appropriate value to /sys/module/gigaset/parameters/debug, e.g.
+ echo 0 > /sys/module/gigaset/parameters/debug
+ switches off debugging output completely,
+ echo 0x10a020 > /sys/module/gigaset/parameters/debug
+ enables the standard set of debugging output messages. These values are
+ bit patterns where every bit controls a certain type of debugging output.
+ See the constants DEBUG_* in the source file gigaset.h for details.
+
+ The initial value can be set using the debug parameter when loading the
+ module "gigaset", e.g. by adding a line
+ options gigaset debug=0
+ to /etc/modprobe.conf, ...
+
+ Generated debugging information can be found
+ - as output of the command
+ dmesg
+ - in system log files written by your syslog daemon, usually
+ in /var/log/, e.g. /var/log/messages.
+
+3.3. Reporting problems and bugs
+ ---------------------------
+ If you can't solve problems with the driver on your own, feel free to
+ use one of the forums, bug trackers, or mailing lists on
+ http://sourceforge.net/projects/gigaset307x
+ or write an electronic mail to the maintainers.
+
+ Try to provide as much information as possible, such as
+ - distribution
+ - kernel version (uname -r)
+ - gcc version (gcc --version)
+ - hardware architecture (uname -m, ...)
+ - type and firmware version of your device (base and wireless module,
+ if any)
+ - output of "lsusb -v" (if using an USB device)
+ - error messages
+ - relevant system log messages (it would help if you activate debug
+ output as described in 3.2.)
+
+ For help with general configuration problems not specific to our driver,
+ such as isdn4linux and network configuration issues, please refer to the
+ appropriate forums and newsgroups.
+
+3.4. Reporting problem solutions
+ ---------------------------
+ If you solved a problem with our drivers, wrote startup scripts for your
+ distribution, ... feel free to contact us (using one of the places
+ mentioned in 3.3.). We'd like to add scripts, hints, documentation
+ to the driver and/or the project web page.
+
+
+4. Links, other software
+ ---------------------
+ - Sourceforge project developing this driver and associated tools
+ http://sourceforge.net/projects/gigaset307x
+ - Yahoo! Group on the Siemens Gigaset family of devices
+ http://de.groups.yahoo.com/group/Siemens-Gigaset
+ - Siemens Gigaset/T-Sinus compatibility table
+ http://www.erbze.info/sinus_gigaset.htm
+
+
+5. Credits
+ -------
+ Thanks to
+
+ Karsten Keil
+ for his help with isdn4linux
+ Deti Fliegl
+ for his base driver code
+ Dennis Dietrich
+ for his kernel 2.6 patches
+ Andreas Rummel
+ for his work and logs to get unimodem mode working
+ Andreas Degert
+ for his logs and patches to get cx 100 working
+ Dietrich Feist
+ for his generous donation of one M105 and two M101 cordless adapters
+ Christoph Schweers
+ for his generous donation of a M34 device
+
+ and all the other people who sent logs and other information.
+
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index fcccf2432f98f..61fc079eb9661 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -44,7 +44,7 @@ What is covered within this file is mainly information to authors
of modules. The author of an external modules should supply
a makefile that hides most of the complexity so one only has to type
'make' to build the module. A complete example will be present in
-chapter ¤. Creating a kbuild file for an external module".
+chapter 4, "Creating a kbuild file for an external module".
=== 2. How to build external modules
diff --git a/Documentation/laptop-mode.txt b/Documentation/laptop-mode.txt
index b18e216759060..5696e879449bc 100644
--- a/Documentation/laptop-mode.txt
+++ b/Documentation/laptop-mode.txt
@@ -919,11 +919,11 @@ int main(int argc, char **argv)
int settle_time = 60;
/* Parse the simple command-line */
- if (ac == 2)
- disk = av[1];
- else if (ac == 4) {
- settle_time = atoi(av[2]);
- disk = av[3];
+ if (argc == 2)
+ disk = argv[1];
+ else if (argc == 4) {
+ settle_time = atoi(argv[2]);
+ disk = argv[3];
} else
usage();
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index f8550310a6d5d..92f0056d928c1 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -610,6 +610,7 @@ loads. Consider the following sequence of events:
CPU 1 CPU 2
======================= =======================
+ { B = 7; X = 9; Y = 8; C = &Y }
STORE A = 1
STORE B = 2
<write barrier>
@@ -651,7 +652,20 @@ In the above example, CPU 2 perceives that B is 7, despite the load of *C
(which would be B) coming after the the LOAD of C.
If, however, a data dependency barrier were to be placed between the load of C
-and the load of *C (ie: B) on CPU 2, then the following will occur:
+and the load of *C (ie: B) on CPU 2:
+
+ CPU 1 CPU 2
+ ======================= =======================
+ { B = 7; X = 9; Y = 8; C = &Y }
+ STORE A = 1
+ STORE B = 2
+ <write barrier>
+ STORE C = &B LOAD X
+ STORE D = 4 LOAD C (gets &B)
+ <data dependency barrier>
+ LOAD *C (reads B)
+
+then the following will occur:
+-------+ : : : :
| | +------+ +-------+
@@ -829,8 +843,8 @@ There are some more advanced barrier functions:
(*) smp_mb__after_atomic_inc();
These are for use with atomic add, subtract, increment and decrement
- functions, especially when used for reference counting. These functions
- do not imply memory barriers.
+ functions that don't return a value, especially when used for reference
+ counting. These functions do not imply memory barriers.
As an example, consider a piece of code that marks an object as being dead
and then decrements the object's reference count:
@@ -1263,15 +1277,17 @@ else.
ATOMIC OPERATIONS
-----------------
-Though they are technically interprocessor interaction considerations, atomic
-operations are noted specially as they do _not_ generally imply memory
-barriers. The possible offenders include:
+Whilst they are technically interprocessor interaction considerations, atomic
+operations are noted specially as some of them imply full memory barriers and
+some don't, but they're very heavily relied on as a group throughout the
+kernel.
+
+Any atomic operation that modifies some state in memory and returns information
+about the state (old or new) implies an SMP-conditional general memory barrier
+(smp_mb()) on each side of the actual operation. These include:
xchg();
cmpxchg();
- test_and_set_bit();
- test_and_clear_bit();
- test_and_change_bit();
atomic_cmpxchg();
atomic_inc_return();
atomic_dec_return();
@@ -1282,21 +1298,31 @@ barriers. The possible offenders include:
atomic_sub_and_test();
atomic_add_negative();
atomic_add_unless();
+ test_and_set_bit();
+ test_and_clear_bit();
+ test_and_change_bit();
-These may be used for such things as implementing LOCK operations or controlling
-the lifetime of objects by decreasing their reference counts. In such cases
-they need preceding memory barriers.
+These are used for such things as implementing LOCK-class and UNLOCK-class
+operations and adjusting reference counters towards object destruction, and as
+such the implicit memory barrier effects are necessary.
-The following may also be possible offenders as they may be used as UNLOCK
-operations.
+The following operation are potential problems as they do _not_ imply memory
+barriers, but might be used for implementing such things as UNLOCK-class
+operations:
+
+ atomic_set();
set_bit();
clear_bit();
change_bit();
- atomic_set();
+With these the appropriate explicit memory barrier should be used if necessary
+(smp_mb__before_clear_bit() for instance).
-The following are a little tricky:
+
+The following also do _not_ imply memory barriers, and so may require explicit
+memory barriers under some circumstances (smp_mb__before_atomic_dec() for
+instance)):
atomic_add();
atomic_sub();
@@ -1317,10 +1343,12 @@ specific order.
Basically, each usage case has to be carefully considered as to whether memory
-barriers are needed or not. The simplest rule is probably: if the atomic
-operation is protected by a lock, then it does not require a barrier unless
-there's another operation within the critical section with respect to which an
-ordering must be maintained.
+barriers are needed or not.
+
+[!] Note that special memory barrier primitives are available for these
+situations because on some CPUs the atomic instructions used imply full memory
+barriers, and so barrier instructions are superfluous in conjunction with them,
+and in such cases the special barrier primitives will be no-ops.
See Documentation/atomic_ops.txt for more information.
diff --git a/Documentation/mtrr.txt b/Documentation/mtrr.txt
index b78af1c329967..c39ac395970ec 100644
--- a/Documentation/mtrr.txt
+++ b/Documentation/mtrr.txt
@@ -138,19 +138,29 @@ Reading MTRRs from a C program using ioctl()'s:
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
-#define MTRR_NEED_STRINGS
#include <asm/mtrr.h>
#define TRUE 1
#define FALSE 0
#define ERRSTRING strerror (errno)
+static char *mtrr_strings[MTRR_NUM_TYPES] =
+{
+ "uncachable", /* 0 */
+ "write-combining", /* 1 */
+ "?", /* 2 */
+ "?", /* 3 */
+ "write-through", /* 4 */
+ "write-protect", /* 5 */
+ "write-back", /* 6 */
+};
int main ()
{
@@ -232,13 +242,22 @@ Creating MTRRs from a C programme using ioctl()'s:
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
-#define MTRR_NEED_STRINGS
#include <asm/mtrr.h>
#define TRUE 1
#define FALSE 0
#define ERRSTRING strerror (errno)
+static char *mtrr_strings[MTRR_NUM_TYPES] =
+{
+ "uncachable", /* 0 */
+ "write-combining", /* 1 */
+ "?", /* 2 */
+ "?", /* 3 */
+ "write-through", /* 4 */
+ "write-protect", /* 5 */
+ "write-back", /* 6 */
+};
int main (int argc, char **argv)
{
diff --git a/Documentation/scsi/scsi_eh.txt b/Documentation/scsi/scsi_eh.txt
index 331afd791cbb4..ce767b90bb0dd 100644
--- a/Documentation/scsi/scsi_eh.txt
+++ b/Documentation/scsi/scsi_eh.txt
@@ -19,9 +19,9 @@ TABLE OF CONTENTS
[2-1-1] Overview
[2-1-2] Flow of scmds through EH
[2-1-3] Flow of control
- [2-2] EH through hostt->eh_strategy_handler()
- [2-2-1] Pre hostt->eh_strategy_handler() SCSI midlayer conditions
- [2-2-2] Post hostt->eh_strategy_handler() SCSI midlayer conditions
+ [2-2] EH through transportt->eh_strategy_handler()
+ [2-2-1] Pre transportt->eh_strategy_handler() SCSI midlayer conditions
+ [2-2-2] Post transportt->eh_strategy_handler() SCSI midlayer conditions
[2-2-3] Things to consider
@@ -413,9 +413,9 @@ scmd->allowed.
layer of failure of the scmds.
-[2-2] EH through hostt->eh_strategy_handler()
+[2-2] EH through transportt->eh_strategy_handler()
- hostt->eh_strategy_handler() is invoked in the place of
+ transportt->eh_strategy_handler() is invoked in the place of
scsi_unjam_host() and it is responsible for whole recovery process.
On completion, the handler should have made lower layers forget about
all failed scmds and either ready for new commands or offline. Also,
@@ -424,7 +424,7 @@ SCSI midlayer. IOW, of the steps described in [2-1-2], all steps
except for #1 must be implemented by eh_strategy_handler().
-[2-2-1] Pre hostt->eh_strategy_handler() SCSI midlayer conditions
+[2-2-1] Pre transportt->eh_strategy_handler() SCSI midlayer conditions
The following conditions are true on entry to the handler.
@@ -437,7 +437,7 @@ except for #1 must be implemented by eh_strategy_handler().
- shost->host_failed == shost->host_busy
-[2-2-2] Post hostt->eh_strategy_handler() SCSI midlayer conditions
+[2-2-2] Post transportt->eh_strategy_handler() SCSI midlayer conditions
The following conditions must be true on exit from the handler.
diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt
index 8bbae3e1abdfa..75a535a975c36 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -804,7 +804,6 @@ Summary:
eh_bus_reset_handler - issue SCSI bus reset
eh_device_reset_handler - issue SCSI device reset
eh_host_reset_handler - reset host (host bus adapter)
- eh_strategy_handler - driver supplied alternate to scsi_unjam_host()
info - supply information about given host
ioctl - driver can respond to ioctls
proc_info - supports /proc/scsi/{driver_name}/{host_no}
@@ -970,24 +969,6 @@ Details:
/**
- * eh_strategy_handler - driver supplied alternate to scsi_unjam_host()
- * @shp: host on which error has occurred
- *
- * Returns TRUE if host unjammed, else FALSE.
- *
- * Locks: none
- *
- * Calling context: kernel thread
- *
- * Notes: Invoked from scsi_eh thread. LLD supplied alternate to
- * scsi_unjam_host() found in scsi_error.c
- *
- * Optionally defined in: LLD
- **/
- int eh_strategy_handler(struct Scsi_Host * shp)
-
-
-/**
* info - supply information about given host: driver name plus data
* to distinguish given host
* @shp: host to supply information about
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index 6feef9e82b63f..68eeebc17ff43 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -1123,8 +1123,8 @@
if ((err = pci_enable_device(pci)) < 0)
return err;
/* check PCI availability (28bit DMA) */
- if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
- pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
+ if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
+ pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
printk(KERN_ERR "error to set 28bit mask DMA\n");
pci_disable_device(pci);
return -ENXIO;
@@ -1216,7 +1216,7 @@
The allocation of PCI resources is done in the
<function>probe()</function> function, and usually an extra
<function>xxx_create()</function> function is written for this
- purpose.
+ purpose.
</para>
<para>
@@ -1225,7 +1225,7 @@
allocating resources. Also, you need to set the proper PCI DMA
mask to limit the accessed i/o range. In some cases, you might
need to call <function>pci_set_master()</function> function,
- too.
+ too.
</para>
<para>
@@ -1236,8 +1236,8 @@
<![CDATA[
if ((err = pci_enable_device(pci)) < 0)
return err;
- if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
- pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
+ if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
+ pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
printk(KERN_ERR "error to set 28bit mask DMA\n");
pci_disable_device(pci);
return -ENXIO;
@@ -1256,13 +1256,13 @@
functions. Unlike ALSA ver.0.5.x., there are no helpers for
that. And these resources must be released in the destructor
function (see below). Also, on ALSA 0.9.x, you don't need to
- allocate (pseudo-)DMA for PCI like ALSA 0.5.x.
+ allocate (pseudo-)DMA for PCI like ALSA 0.5.x.
</para>
<para>
Now assume that this PCI device has an I/O port with 8 bytes
and an interrupt. Then struct <structname>mychip</structname> will have the
- following fields:
+ following fields:
<informalexample>
<programlisting>
diff --git a/Documentation/vm/hugetlbpage.txt b/Documentation/vm/hugetlbpage.txt
index 1ad9af1ca4d0b..2803f63c1a276 100644
--- a/Documentation/vm/hugetlbpage.txt
+++ b/Documentation/vm/hugetlbpage.txt
@@ -27,7 +27,7 @@ number of free hugetlb pages at any time. It also displays information about
the configured hugepage size - this is needed for generating the proper
alignment and size of the arguments to the above system calls.
-The output of "cat /proc/meminfo" will have output like:
+The output of "cat /proc/meminfo" will have lines like:
.....
HugePages_Total: xxx
@@ -42,11 +42,11 @@ pages in the kernel. Super user can dynamically request more (or free some
pre-configured) hugepages.
The allocation (or deallocation) of hugetlb pages is possible only if there are
enough physically contiguous free pages in system (freeing of hugepages is
-possible only if there are enough hugetlb pages free that can be transfered
+possible only if there are enough hugetlb pages free that can be transferred
back to regular memory pool).
-Pages that are used as hugetlb pages are reserved inside the kernel and can
-not be used for other purposes.
+Pages that are used as hugetlb pages are reserved inside the kernel and cannot
+be used for other purposes.
Once the kernel with Hugetlb page support is built and running, a user can
use either the mmap system call or shared memory system calls to start using
@@ -60,7 +60,7 @@ Use the following command to dynamically allocate/deallocate hugepages:
This command will try to configure 20 hugepages in the system. The success
or failure of allocation depends on the amount of physically contiguous
memory that is preset in system at this time. System administrators may want
-to put this command in one of the local rc init file. This will enable the
+to put this command in one of the local rc init files. This will enable the
kernel to request huge pages early in the boot process (when the possibility
of getting physical contiguous pages is still very high).
@@ -78,8 +78,8 @@ the uid and gid of the current process are taken. The mode option sets the
mode of root of file system to value & 0777. This value is given in octal.
By default the value 0755 is picked. The size option sets the maximum value of
memory (huge pages) allowed for that filesystem (/mnt/huge). The size is
-rounded down to HPAGE_SIZE. The option nr_inode sets the maximum number of
-inodes that /mnt/huge can use. If the size or nr_inode options are not
+rounded down to HPAGE_SIZE. The option nr_inodes sets the maximum number of
+inodes that /mnt/huge can use. If the size or nr_inodes options are not
provided on command line then no limits are set. For size and nr_inodes
options, you can use [G|g]/[M|m]/[K|k] to represent giga/mega/kilo. For
example, size=2K has the same meaning as size=2048. An example is given at
@@ -88,7 +88,7 @@ the end of this document.
read and write system calls are not supported on files that reside on hugetlb
file systems.
-A regular chown, chgrp and chmod commands (with right permissions) could be
+Regular chown, chgrp, and chmod commands (with right permissions) could be
used to change the file attributes on hugetlbfs.
Also, it is important to note that no such mount command is required if the
@@ -96,8 +96,8 @@ applications are going to use only shmat/shmget system calls. Users who
wish to use hugetlb page via shared memory segment should be a member of
a supplementary group and system admin needs to configure that gid into
/proc/sys/vm/hugetlb_shm_group. It is possible for same or different
-applications to use any combination of mmaps and shm* calls. Though the
-mount of filesystem will be required for using mmaps.
+applications to use any combination of mmaps and shm* calls, though the
+mount of filesystem will be required for using mmap calls.
*******************************************************************
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 1921353259aee..f2cd6ef53ff33 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -151,6 +151,11 @@ NUMA
numa=fake=X Fake X nodes and ignore NUMA setup of the actual machine.
+ numa=hotadd=percent
+ Only allow hotadd memory to preallocate page structures upto
+ percent of already available memory.
+ numa=hotadd=0 will disable hotadd memory.
+
ACPI
acpi=off Don't enable ACPI
diff --git a/Kbuild b/Kbuild
index 95d6a00bace08..2d4f95e4b89f7 100644
--- a/Kbuild
+++ b/Kbuild
@@ -18,7 +18,7 @@ define sed-y
"/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
endef
# Override default regexp for specific architectures
-sed-$(CONFIG_MIPS) := "/^@@@/s///p"
+sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
quiet_cmd_offsets = GEN $@
define cmd_offsets
diff --git a/MAINTAINERS b/MAINTAINERS
index f97657b7e2c71..6d3c401ccdb6c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1556,9 +1556,7 @@ S: Maintained
KEXEC
P: Eric Biederman
-P: Randy Dunlap
M: ebiederm@xmission.com
-M: rdunlap@xenotime.net
W: http://www.xmission.com/~ebiederm/files/kexec/
L: linux-kernel@vger.kernel.org
L: fastboot@osdl.org
@@ -3060,13 +3058,6 @@ M: khali@linux-fr.org
L: lm-sensors@lm-sensors.org
S: Odd Fixes
-WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC)
-P: Nenad Corbic
-M: ncorbic@sangoma.com
-M: dm@sangoma.com
-W: http://www.sangoma.com
-S: Supported
-
WATCHDOG DEVICE DRIVERS
P: Wim Van Sebroeck
M: wim@iguana.be
diff --git a/Makefile b/Makefile
index af6210d488368..fc8e08c419f09 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
-SUBLEVEL = 16
-EXTRAVERSION =
+SUBLEVEL = 17
+EXTRAVERSION =-rc1
NAME=Sliding Snow Leopard
# *DOCUMENTATION*
@@ -1112,7 +1112,6 @@ modules_install: _emodinst_ _emodinst_post
install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
PHONY += _emodinst_
_emodinst_:
- $(Q)rm -rf $(MODLIB)/$(install-dir)
$(Q)mkdir -p $(MODLIB)/$(install-dir)
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
@@ -1275,40 +1274,43 @@ kernelversion:
# Single targets
# ---------------------------------------------------------------------------
-# The directory part is taken from first prerequisite, so this
-# works even with external modules
+# Single targets are compatible with:
+# - build whith mixed source and output
+# - build with separate output dir 'make O=...'
+# - external modules
+#
+# target-dir => where to store outputfile
+# build-dir => directory in kernel source tree to use
+
+ifeq ($(KBUILD_EXTMOD),)
+ build-dir = $(patsubst %/,%,$(dir $@))
+ target-dir = $(dir $@)
+else
+ zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
+ build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
+ target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
+endif
+
%.s: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.i: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.lst: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.s: %.S prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.S prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
-
-# For external modules we shall include any directory of the target,
-# but usual case there is no directory part.
-# make M=`pwd` module.o => $(dir $@)=./
-# make M=`pwd` foo/module.o => $(dir $@)=foo/
-# make M=`pwd` / => $(dir $@)=/
-
-ifeq ($(KBUILD_EXTMOD),)
- target-dir = $(@D)
-else
- zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
- target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
-endif
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
-/ %/: scripts prepare FORCE
+# Modules
+/ %/: prepare scripts FORCE
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
- $(build)=$(target-dir)
-%.ko: scripts FORCE
+ $(build)=$(build-dir)
+%.ko: prepare scripts FORCE
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
- $(build)=$(target-dir) $(@:.ko=.o)
+ $(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
# FIXME Should go into a make.lib or something
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 9bef61b303674..8290b69da2021 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -549,6 +549,11 @@ config NUMA
Access). This option is for configuring high-end multiprocessor
server machines. If in doubt, say N.
+config NODES_SHIFT
+ int
+ default "7"
+ depends on NEED_MULTIPLE_NODES
+
# LARGE_VMALLOC is racy, if you *really* need it then fix it first
config ALPHA_LARGE_VMALLOC
bool
diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
index 9d6186d50245c..c645c5e14786f 100644
--- a/arch/alpha/kernel/alpha_ksyms.c
+++ b/arch/alpha/kernel/alpha_ksyms.c
@@ -76,7 +76,6 @@ EXPORT_SYMBOL(strncpy);
EXPORT_SYMBOL(strnlen);
EXPORT_SYMBOL(strncat);
EXPORT_SYMBOL(strstr);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strchr);
EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(memcmp);
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index a15e18a00258e..558b833685593 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -24,6 +24,7 @@
#include <linux/config.h> /* CONFIG_ALPHA_LCA etc */
#include <linux/mc146818rtc.h>
#include <linux/console.h>
+#include <linux/cpu.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/string.h>
@@ -471,6 +472,22 @@ page_is_ram(unsigned long pfn)
return 0;
}
+static int __init
+register_cpus(void)
+{
+ int i;
+
+ for_each_possible_cpu(i) {
+ struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+ register_cpu(p, i, NULL);
+ }
+ return 0;
+}
+
+arch_initcall(register_cpus);
+
void __init
setup_arch(char **cmdline_p)
{
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 02c2db08114ad..185255416e853 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -439,7 +439,7 @@ setup_smp(void)
if ((cpu->flags & 0x1cc) == 0x1cc) {
smp_num_probed++;
/* Assume here that "whami" == index */
- cpu_set(i, cpu_possible_map);
+ cpu_set(i, cpu_present_mask);
cpu->pal_revision = boot_cpu_palrev;
}
@@ -450,9 +450,8 @@ setup_smp(void)
}
} else {
smp_num_probed = 1;
- cpu_set(boot_cpuid, cpu_possible_map);
+ cpu_set(boot_cpuid, cpu_present_mask);
}
- cpu_present_mask = cpumask_of_cpu(boot_cpuid);
printk(KERN_INFO "SMP: %d CPUs probed -- cpu_present_mask = %lx\n",
smp_num_probed, cpu_possible_map.bits[0]);
@@ -488,9 +487,8 @@ void __devinit
smp_prepare_boot_cpu(void)
{
/*
- * Mark the boot cpu (current cpu) as both present and online
+ * Mark the boot cpu (current cpu) as online
*/
- cpu_set(smp_processor_id(), cpu_present_mask);
cpu_set(smp_processor_id(), cpu_online_map);
}
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dc5a9332c9159..1dbf6ddb300d2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -512,6 +512,12 @@ config ARCH_DISCONTIGMEM_ENABLE
or have huge holes in the physical address space for other reasons.
See <file:Documentation/vm/numa> for more.
+config NODES_SHIFT
+ int
+ default "4" if ARCH_LH7A40X
+ default "2"
+ depends on NEED_MULTIPLE_NODES
+
source "mm/Kconfig"
config LEDS
diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in
index eed616113e473..153a07e7222bd 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.in
+++ b/arch/arm/boot/compressed/vmlinux.lds.in
@@ -18,6 +18,7 @@ SECTIONS
_start = .;
*(.start)
*(.text)
+ *(.text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata)
diff --git a/arch/arm/configs/at91rm9200dk_defconfig b/arch/arm/configs/at91rm9200dk_defconfig
index 1fe73d1988880..9e1c1cceb735c 100644
--- a/arch/arm/configs/at91rm9200dk_defconfig
+++ b/arch/arm/configs/at91rm9200dk_defconfig
@@ -379,7 +379,7 @@ CONFIG_MTD_PHYSMAP_BANKWIDTH=2
# CONFIG_MTD_DOC2001 is not set
# CONFIG_MTD_DOC2001PLUS is not set
CONFIG_MTD_AT91_DATAFLASH=y
-CONFIG_MTD_AT91_DATAFLASH_CARD=y
+# CONFIG_MTD_AT91_DATAFLASH_CARD is not set
#
# NAND Flash Device Drivers
diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
index b7d934cdb1b73..6e0805a971d78 100644
--- a/arch/arm/configs/at91rm9200ek_defconfig
+++ b/arch/arm/configs/at91rm9200ek_defconfig
@@ -370,7 +370,7 @@ CONFIG_MTD_PHYSMAP_BANKWIDTH=2
# CONFIG_MTD_DOC2001 is not set
# CONFIG_MTD_DOC2001PLUS is not set
CONFIG_MTD_AT91_DATAFLASH=y
-CONFIG_MTD_AT91_DATAFLASH_CARD=y
+# CONFIG_MTD_AT91_DATAFLASH_CARD is not set
#
# NAND Flash Device Drivers
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index 1574941ebfe18..c49b5d4d7fca2 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -100,23 +100,11 @@ EXPORT_SYMBOL(__raw_writesl);
#endif
/* string / mem functions */
-EXPORT_SYMBOL(strcpy);
-EXPORT_SYMBOL(strncpy);
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strncmp);
EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strrchr);
-EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memscan);
EXPORT_SYMBOL(memchr);
EXPORT_SYMBOL(__memzero);
@@ -190,8 +178,6 @@ EXPORT_SYMBOL(_find_next_bit_be);
/* syscalls */
EXPORT_SYMBOL(sys_write);
-EXPORT_SYMBOL(sys_read);
EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_open);
EXPORT_SYMBOL(sys_exit);
EXPORT_SYMBOL(sys_wait4);
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index b7cd280bfd638..8cff73e668b38 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -252,6 +252,9 @@ static void __init dump_cpu_info(int cpu)
dump_cache("cache", cpu, CACHE_ISIZE(info));
}
}
+
+ if (arch_is_coherent())
+ printk("Cache coherency enabled\n");
}
int cpu_architecture(void)
@@ -319,6 +322,12 @@ static void __init setup_processor(void)
sprintf(system_utsname.machine, "%s%c", list->arch_name, ENDIANNESS);
sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
elf_hwcap = list->elf_hwcap;
+#ifndef CONFIG_ARM_THUMB
+ elf_hwcap &= ~HWCAP_THUMB;
+#endif
+#ifndef CONFIG_VFP
+ elf_hwcap &= ~HWCAP_VFP;
+#endif
cpu_proc_init();
}
diff --git a/arch/arm/mach-at91rm9200/Makefile b/arch/arm/mach-at91rm9200/Makefile
index 75e6ee318dedc..ef88c4128edc3 100644
--- a/arch/arm/mach-at91rm9200/Makefile
+++ b/arch/arm/mach-at91rm9200/Makefile
@@ -16,11 +16,12 @@ obj-$(CONFIG_MACH_CSB637) += board-csb637.o
#obj-$(CONFIG_MACH_KB9200) += board-kb9202.o
# LEDs support
-#led-$(CONFIG_ARCH_AT91RM9200DK) += leds.o
-#led-$(CONFIG_MACH_AT91RM9200EK) += leds.o
-#led-$(CONFIG_MACH_CSB337) += leds.o
-#led-$(CONFIG_MACH_CSB637) += leds.o
+led-$(CONFIG_ARCH_AT91RM9200DK) += leds.o
+led-$(CONFIG_MACH_AT91RM9200EK) += leds.o
+led-$(CONFIG_MACH_CSB337) += leds.o
+led-$(CONFIG_MACH_CSB637) += leds.o
#led-$(CONFIG_MACH_KB9200) += leds.o
+#led-$(CONFIG_MACH_KAFA) += leds.o
obj-$(CONFIG_LEDS) += $(led-y)
# VGA support
diff --git a/arch/arm/mach-at91rm9200/board-csb337.c b/arch/arm/mach-at91rm9200/board-csb337.c
index 54022e58d50dc..f45104ceea8fc 100644
--- a/arch/arm/mach-at91rm9200/board-csb337.c
+++ b/arch/arm/mach-at91rm9200/board-csb337.c
@@ -67,6 +67,9 @@ static void __init csb337_map_io(void)
/* Initialize clocks: 3.6864 MHz crystal */
at91_clock_init(3686400);
+ /* Setup the LEDs */
+ at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
+
#ifdef CONFIG_SERIAL_AT91
at91_console_port = CSB337_SERIAL_CONSOLE;
memcpy(at91_serial_map, serial, sizeof(serial));
diff --git a/arch/arm/mach-at91rm9200/board-csb637.c b/arch/arm/mach-at91rm9200/board-csb637.c
index 8195f9d919ea5..f2c2d6e79bc6e 100644
--- a/arch/arm/mach-at91rm9200/board-csb637.c
+++ b/arch/arm/mach-at91rm9200/board-csb637.c
@@ -67,6 +67,9 @@ static void __init csb637_map_io(void)
/* Initialize clocks: 3.6864 MHz crystal */
at91_clock_init(3686400);
+ /* Setup the LEDs */
+ at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
+
#ifdef CONFIG_SERIAL_AT91
at91_console_port = CSB637_SERIAL_CONSOLE;
memcpy(at91_serial_map, serial, sizeof(serial));
diff --git a/arch/arm/mach-at91rm9200/board-dk.c b/arch/arm/mach-at91rm9200/board-dk.c
index 8a783368366ed..2d7200ed66ed7 100644
--- a/arch/arm/mach-at91rm9200/board-dk.c
+++ b/arch/arm/mach-at91rm9200/board-dk.c
@@ -70,6 +70,9 @@ static void __init dk_map_io(void)
/* Initialize clocks: 18.432 MHz crystal */
at91_clock_init(18432000);
+ /* Setup the LEDs */
+ at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
+
#ifdef CONFIG_SERIAL_AT91
at91_console_port = DK_SERIAL_CONSOLE;
memcpy(at91_serial_map, serial, sizeof(serial));
@@ -118,9 +121,14 @@ static void __init dk_board_init(void)
at91_add_device_udc(&dk_udc_data);
/* Compact Flash */
at91_add_device_cf(&dk_cf_data);
+#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
+ /* DataFlash card */
+ at91_set_gpio_output(AT91_PIN_PB7, 0);
+#else
/* MMC */
- at91_set_gpio_output(AT91_PIN_PB7, 1); /* this MMC card slot can optionally use SPI signaling (CS3). default: MMC */
+ at91_set_gpio_output(AT91_PIN_PB7, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
at91_add_device_mmc(&dk_mmc_data);
+#endif
/* VGA */
// dk_add_device_video();
}
diff --git a/arch/arm/mach-at91rm9200/board-ek.c b/arch/arm/mach-at91rm9200/board-ek.c
index fd0752eba897e..80d90f5135a13 100644
--- a/arch/arm/mach-at91rm9200/board-ek.c
+++ b/arch/arm/mach-at91rm9200/board-ek.c
@@ -70,6 +70,9 @@ static void __init ek_map_io(void)
/* Initialize clocks: 18.432 MHz crystal */
at91_clock_init(18432000);
+ /* Setup the LEDs */
+ at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
+
#ifdef CONFIG_SERIAL_AT91
at91_console_port = EK_SERIAL_CONSOLE;
memcpy(at91_serial_map, serial, sizeof(serial));
@@ -111,9 +114,14 @@ static void __init ek_board_init(void)
at91_add_device_usbh(&ek_usbh_data);
/* USB Device */
at91_add_device_udc(&ek_udc_data);
+#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
+ /* DataFlash card */
+ at91_set_gpio_output(AT91_PIN_PB22, 0);
+#else
/* MMC */
- at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). default: MMC */
+ at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
at91_add_device_mmc(&ek_mmc_data);
+#endif
/* VGA */
// ek_add_device_video();
}
diff --git a/arch/arm/mach-at91rm9200/devices.c b/arch/arm/mach-at91rm9200/devices.c
index 57eedd5beaf64..1781b8f342c4d 100644
--- a/arch/arm/mach-at91rm9200/devices.c
+++ b/arch/arm/mach-at91rm9200/devices.c
@@ -28,10 +28,10 @@
static u64 ohci_dmamask = 0xffffffffUL;
static struct at91_usbh_data usbh_data;
-static struct resource at91rm9200_usbh_resource[] = {
+static struct resource at91_usbh_resource[] = {
[0] = {
.start = AT91_UHP_BASE,
- .end = AT91_UHP_BASE + SZ_1M -1,
+ .end = AT91_UHP_BASE + SZ_1M - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
@@ -49,8 +49,8 @@ static struct platform_device at91rm9200_usbh_device = {
.coherent_dma_mask = 0xffffffff,
.platform_data = &usbh_data,
},
- .resource = at91rm9200_usbh_resource,
- .num_resources = ARRAY_SIZE(at91rm9200_usbh_resource),
+ .resource = at91_usbh_resource,
+ .num_resources = ARRAY_SIZE(at91_usbh_resource),
};
void __init at91_add_device_usbh(struct at91_usbh_data *data)
@@ -121,6 +121,19 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
static u64 eth_dmamask = 0xffffffffUL;
static struct at91_eth_data eth_data;
+static struct resource at91_eth_resources[] = {
+ [0] = {
+ .start = AT91_BASE_EMAC,
+ .end = AT91_BASE_EMAC + SZ_16K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = AT91_ID_EMAC,
+ .end = AT91_ID_EMAC,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
static struct platform_device at91rm9200_eth_device = {
.name = "at91_ether",
.id = -1,
@@ -129,7 +142,8 @@ static struct platform_device at91rm9200_eth_device = {
.coherent_dma_mask = 0xffffffff,
.platform_data = &eth_data,
},
- .num_resources = 0,
+ .resource = at91_eth_resources,
+ .num_resources = ARRAY_SIZE(at91_eth_resources),
};
void __init at91_add_device_eth(struct at91_eth_data *data)
@@ -224,15 +238,20 @@ static u64 mmc_dmamask = 0xffffffffUL;
static struct at91_mmc_data mmc_data;
static struct resource at91_mmc_resources[] = {
- {
+ [0] = {
.start = AT91_BASE_MCI,
.end = AT91_BASE_MCI + SZ_16K - 1,
.flags = IORESOURCE_MEM,
- }
+ },
+ [1] = {
+ .start = AT91_ID_MCI,
+ .end = AT91_ID_MCI,
+ .flags = IORESOURCE_IRQ,
+ },
};
static struct platform_device at91rm9200_mmc_device = {
- .name = "at91rm9200_mci",
+ .name = "at91_mci",
.id = -1,
.dev = {
.dma_mask = &mmc_dmamask,
@@ -290,4 +309,123 @@ void __init at91_add_device_mmc(struct at91_mmc_data *data)
void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
#endif
+/* --------------------------------------------------------------------
+ * NAND / SmartMedia
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
+static struct at91_nand_data nand_data;
+
+static struct resource at91_nand_resources[] = {
+ {
+ .start = AT91_SMARTMEDIA_BASE,
+ .end = AT91_SMARTMEDIA_BASE + SZ_8M - 1,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
+static struct platform_device at91_nand_device = {
+ .name = "at91_nand",
+ .id = -1,
+ .dev = {
+ .platform_data = &nand_data,
+ },
+ .resource = at91_nand_resources,
+ .num_resources = ARRAY_SIZE(at91_nand_resources),
+};
+
+void __init at91_add_device_nand(struct at91_nand_data *data)
+{
+ if (!data)
+ return;
+
+ /* enable pin */
+ if (data->enable_pin)
+ at91_set_gpio_output(data->enable_pin, 1);
+
+ /* ready/busy pin */
+ if (data->rdy_pin)
+ at91_set_gpio_input(data->rdy_pin, 1);
+
+ /* card detect pin */
+ if (data->det_pin)
+ at91_set_gpio_input(data->det_pin, 1);
+
+ at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
+ at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
+
+ nand_data = *data;
+ platform_device_register(&at91_nand_device);
+}
+#else
+void __init at91_add_device_nand(struct at91_nand_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ * TWI (i2c)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
+static struct platform_device at91rm9200_twi_device = {
+ .name = "at91_i2c",
+ .id = -1,
+ .num_resources = 0,
+};
+
+void __init at91_add_device_i2c(void)
+{
+ /* pins used for TWI interface */
+ at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
+ at91_set_multi_drive(AT91_PIN_PA25, 1);
+
+ at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
+ at91_set_multi_drive(AT91_PIN_PA26, 1);
+
+ platform_device_register(&at91rm9200_twi_device);
+}
+#else
+void __init at91_add_device_i2c(void) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ * RTC
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_AT91_RTC) || defined(CONFIG_AT91_RTC_MODULE)
+static struct platform_device at91rm9200_rtc_device = {
+ .name = "at91_rtc",
+ .id = -1,
+ .num_resources = 0,
+};
+
+void __init at91_add_device_rtc(void)
+{
+ platform_device_register(&at91rm9200_rtc_device);
+}
+#else
+void __init at91_add_device_rtc(void) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ * LEDs
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_LEDS)
+u8 at91_leds_cpu;
+u8 at91_leds_timer;
+
+void __init at91_init_leds(u8 cpu_led, u8 timer_led)
+{
+ at91_leds_cpu = cpu_led;
+ at91_leds_timer = timer_led;
+}
+
+#else
+void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
+#endif
+
+
/* -------------------------------------------------------------------- */
diff --git a/arch/arm/mach-at91rm9200/leds.c b/arch/arm/mach-at91rm9200/leds.c
new file mode 100644
index 0000000000000..28150e8905ba4
--- /dev/null
+++ b/arch/arm/mach-at91rm9200/leds.c
@@ -0,0 +1,100 @@
+/*
+ * LED driver for Atmel AT91-based boards.
+ *
+ * Copyright (C) SAN People (Pty) Ltd
+ *
+ * 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 <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <asm/mach-types.h>
+#include <asm/leds.h>
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+
+
+static inline void at91_led_on(unsigned int led)
+{
+ at91_set_gpio_value(led, 0);
+}
+
+static inline void at91_led_off(unsigned int led)
+{
+ at91_set_gpio_value(led, 1);
+}
+
+static inline void at91_led_toggle(unsigned int led)
+{
+ unsigned long is_off = at91_get_gpio_value(led);
+ if (is_off)
+ at91_led_on(led);
+ else
+ at91_led_off(led);
+}
+
+
+/*
+ * Handle LED events.
+ */
+static void at91_leds_event(led_event_t evt)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ switch(evt) {
+ case led_start: /* System startup */
+ at91_led_on(at91_leds_cpu);
+ break;
+
+ case led_stop: /* System stop / suspend */
+ at91_led_off(at91_leds_cpu);
+ break;
+
+#ifdef CONFIG_LEDS_TIMER
+ case led_timer: /* Every 50 timer ticks */
+ at91_led_toggle(at91_leds_timer);
+ break;
+#endif
+
+#ifdef CONFIG_LEDS_CPU
+ case led_idle_start: /* Entering idle state */
+ at91_led_off(at91_leds_cpu);
+ break;
+
+ case led_idle_end: /* Exit idle state */
+ at91_led_on(at91_leds_cpu);
+ break;
+#endif
+
+ default:
+ break;
+ }
+
+ local_irq_restore(flags);
+}
+
+
+static int __init leds_init(void)
+{
+ if (!at91_leds_timer || !at91_leds_cpu)
+ return -ENODEV;
+
+ /* Enable PIO to access the LEDs */
+ at91_set_gpio_output(at91_leds_timer, 1);
+ at91_set_gpio_output(at91_leds_cpu, 1);
+
+ leds_event = at91_leds_event;
+
+ leds_event(led_start);
+ return 0;
+}
+
+__initcall(leds_init);
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 2d892e4daa071..dcd4176253894 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -424,6 +424,14 @@ static struct amba_device uart3_device = {
.periphid = 0x00041010,
};
+
+static struct platform_device ep93xx_rtc_device = {
+ .name = "ep93xx-rtc",
+ .id = -1,
+ .num_resources = 0,
+};
+
+
void __init ep93xx_init_devices(void)
{
unsigned int v;
@@ -439,4 +447,6 @@ void __init ep93xx_init_devices(void)
amba_device_register(&uart1_device, &iomem_resource);
amba_device_register(&uart2_device, &iomem_resource);
amba_device_register(&uart3_device, &iomem_resource);
+
+ platform_device_register(&ep93xx_rtc_device);
}
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index 777e75daa8a54..9be01b0c3f487 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -17,6 +17,8 @@
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/mtd/physmap.h>
+#include <linux/platform_device.h>
+#include <linux/m48t86.h>
#include <asm/io.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -39,6 +41,16 @@ static struct map_desc ts72xx_io_desc[] __initdata = {
.pfn = __phys_to_pfn(TS72XX_OPTIONS2_PHYS_BASE),
.length = TS72XX_OPTIONS2_SIZE,
.type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_RTC_INDEX_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_RTC_INDEX_PHYS_BASE),
+ .length = TS72XX_RTC_INDEX_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_RTC_DATA_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_RTC_DATA_PHYS_BASE),
+ .length = TS72XX_RTC_DATA_SIZE,
+ .type = MT_DEVICE,
}
};
@@ -99,11 +111,38 @@ static void __init ts72xx_map_io(void)
}
}
+static unsigned char ts72xx_rtc_readb(unsigned long addr)
+{
+ __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
+ return __raw_readb(TS72XX_RTC_DATA_VIRT_BASE);
+}
+
+static void ts72xx_rtc_writeb(unsigned char value, unsigned long addr)
+{
+ __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
+ __raw_writeb(value, TS72XX_RTC_DATA_VIRT_BASE);
+}
+
+static struct m48t86_ops ts72xx_rtc_ops = {
+ .readb = ts72xx_rtc_readb,
+ .writeb = ts72xx_rtc_writeb,
+};
+
+static struct platform_device ts72xx_rtc_device = {
+ .name = "rtc-m48t86",
+ .id = -1,
+ .dev = {
+ .platform_data = &ts72xx_rtc_ops,
+ },
+ .num_resources = 0,
+};
+
static void __init ts72xx_init_machine(void)
{
ep93xx_init_devices();
if (board_is_ts7200())
physmap_configure(TS72XX_NOR_PHYS_BASE, 0x01000000, 1, NULL);
+ platform_device_register(&ts72xx_rtc_device);
}
MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
diff --git a/arch/arm/mach-imx/dma.c b/arch/arm/mach-imx/dma.c
index 71a59e196166c..4ca51dcf13ac6 100644
--- a/arch/arm/mach-imx/dma.c
+++ b/arch/arm/mach-imx/dma.c
@@ -7,11 +7,18 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
- * 03/03/2004 Sascha Hauer <sascha@saschahauer.de>
+ * 2004-03-03 Sascha Hauer <sascha@saschahauer.de>
* initial version heavily inspired by
* linux/arch/arm/mach-pxa/dma.c
+ *
+ * 2005-04-17 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * Changed to support scatter gather DMA
+ * by taking Russell's code from RiscPC
+ *
*/
+#undef DEBUG
+
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
@@ -22,69 +29,368 @@
#include <asm/irq.h>
#include <asm/hardware.h>
#include <asm/dma.h>
+#include <asm/arch/imx-dma.h>
+
+struct imx_dma_channel imx_dma_channels[IMX_DMA_CHANNELS];
+
+/*
+ * imx_dma_sg_next - prepare next chunk for scatter-gather DMA emulation
+ * @dma_ch: i.MX DMA channel number
+ * @lastcount: number of bytes transferred during last transfer
+ *
+ * Functions prepares DMA controller for next sg data chunk transfer.
+ * The @lastcount argument informs function about number of bytes transferred
+ * during last block. Zero value can be used for @lastcount to setup DMA
+ * for the first chunk.
+ */
+static inline int imx_dma_sg_next(imx_dmach_t dma_ch, unsigned int lastcount)
+{
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
+ unsigned int nextcount;
+ unsigned int nextaddr;
+
+ if (!imxdma->name) {
+ printk(KERN_CRIT "%s: called for not allocated channel %d\n",
+ __FUNCTION__, dma_ch);
+ return 0;
+ }
+
+ imxdma->resbytes -= lastcount;
+
+ if (!imxdma->sg) {
+ pr_debug("imxdma%d: no sg data\n", dma_ch);
+ return 0;
+ }
+
+ imxdma->sgbc += lastcount;
+ if ((imxdma->sgbc >= imxdma->sg->length) || !imxdma->resbytes) {
+ if ((imxdma->sgcount <= 1) || !imxdma->resbytes) {
+ pr_debug("imxdma%d: sg transfer limit reached\n",
+ dma_ch);
+ imxdma->sgcount=0;
+ imxdma->sg = NULL;
+ return 0;
+ } else {
+ imxdma->sgcount--;
+ imxdma->sg++;
+ imxdma->sgbc = 0;
+ }
+ }
+ nextcount = imxdma->sg->length - imxdma->sgbc;
+ nextaddr = imxdma->sg->dma_address + imxdma->sgbc;
-static struct dma_channel {
- char *name;
- void (*irq_handler) (int, void *, struct pt_regs *);
- void (*err_handler) (int, void *, struct pt_regs *);
- void *data;
-} dma_channels[11];
+ if(imxdma->resbytes < nextcount)
+ nextcount = imxdma->resbytes;
-/* set err_handler to NULL to have the standard info-only error handler */
+ if ((imxdma->dma_mode & DMA_MODE_MASK) == DMA_MODE_READ)
+ DAR(dma_ch) = nextaddr;
+ else
+ SAR(dma_ch) = nextaddr;
+
+ CNTR(dma_ch) = nextcount;
+ pr_debug("imxdma%d: next sg chunk dst 0x%08x, src 0x%08x, size 0x%08x\n",
+ dma_ch, DAR(dma_ch), SAR(dma_ch), CNTR(dma_ch));
+
+ return nextcount;
+}
+
+/*
+ * imx_dma_setup_sg_base - scatter-gather DMA emulation
+ * @dma_ch: i.MX DMA channel number
+ * @sg: pointer to the scatter-gather list/vector
+ * @sgcount: scatter-gather list hungs count
+ *
+ * Functions sets up i.MX DMA state for emulated scatter-gather transfer
+ * and sets up channel registers to be ready for the first chunk
+ */
+static int
+imx_dma_setup_sg_base(imx_dmach_t dma_ch,
+ struct scatterlist *sg, unsigned int sgcount)
+{
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
+
+ imxdma->sg = sg;
+ imxdma->sgcount = sgcount;
+ imxdma->sgbc = 0;
+ return imx_dma_sg_next(dma_ch, 0);
+}
+
+/**
+ * imx_dma_setup_single - setup i.MX DMA channel for linear memory to/from device transfer
+ * @dma_ch: i.MX DMA channel number
+ * @dma_address: the DMA/physical memory address of the linear data block
+ * to transfer
+ * @dma_length: length of the data block in bytes
+ * @dev_addr: physical device port address
+ * @dmamode: DMA transfer mode, %DMA_MODE_READ from the device to the memory
+ * or %DMA_MODE_WRITE from memory to the device
+ *
+ * The function setups DMA channel source and destination addresses for transfer
+ * specified by provided parameters. The scatter-gather emulation is disabled,
+ * because linear data block
+ * form the physical address range is transfered.
+ * Return value: if incorrect parameters are provided -%EINVAL.
+ * Zero indicates success.
+ */
int
-imx_request_dma(char *name, imx_dma_prio prio,
- void (*irq_handler) (int, void *, struct pt_regs *),
- void (*err_handler) (int, void *, struct pt_regs *), void *data)
+imx_dma_setup_single(imx_dmach_t dma_ch, dma_addr_t dma_address,
+ unsigned int dma_length, unsigned int dev_addr,
+ dmamode_t dmamode)
{
- unsigned long flags;
- int i, found = 0;
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
- /* basic sanity checks */
- if (!name || !irq_handler)
+ imxdma->sg = NULL;
+ imxdma->sgcount = 0;
+ imxdma->dma_mode = dmamode;
+ imxdma->resbytes = dma_length;
+
+ if (!dma_address) {
+ printk(KERN_ERR "imxdma%d: imx_dma_setup_single null address\n",
+ dma_ch);
return -EINVAL;
+ }
- local_irq_save(flags);
+ if (!dma_length) {
+ printk(KERN_ERR "imxdma%d: imx_dma_setup_single zero length\n",
+ dma_ch);
+ return -EINVAL;
+ }
- /* try grabbing a DMA channel with the requested priority */
- for (i = prio; i < prio + (prio == DMA_PRIO_LOW) ? 8 : 4; i++) {
- if (!dma_channels[i].name) {
- found = 1;
- break;
- }
+ if ((dmamode & DMA_MODE_MASK) == DMA_MODE_READ) {
+ pr_debug("imxdma%d: mx_dma_setup_single2dev dma_addressg=0x%08x dma_length=%d dev_addr=0x%08x for read\n",
+ dma_ch, (unsigned int)dma_address, dma_length,
+ dev_addr);
+ SAR(dma_ch) = dev_addr;
+ DAR(dma_ch) = (unsigned int)dma_address;
+ } else if ((dmamode & DMA_MODE_MASK) == DMA_MODE_WRITE) {
+ pr_debug("imxdma%d: mx_dma_setup_single2dev dma_addressg=0x%08x dma_length=%d dev_addr=0x%08x for write\n",
+ dma_ch, (unsigned int)dma_address, dma_length,
+ dev_addr);
+ SAR(dma_ch) = (unsigned int)dma_address;
+ DAR(dma_ch) = dev_addr;
+ } else {
+ printk(KERN_ERR "imxdma%d: imx_dma_setup_single bad dmamode\n",
+ dma_ch);
+ return -EINVAL;
}
- if (!found) {
- /* requested prio group is full, try hier priorities */
- for (i = prio - 1; i >= 0; i--) {
- if (!dma_channels[i].name) {
- found = 1;
- break;
- }
- }
+ CNTR(dma_ch) = dma_length;
+
+ return 0;
+}
+
+/**
+ * imx_dma_setup_sg - setup i.MX DMA channel SG list to/from device transfer
+ * @dma_ch: i.MX DMA channel number
+ * @sg: pointer to the scatter-gather list/vector
+ * @sgcount: scatter-gather list hungs count
+ * @dma_length: total length of the transfer request in bytes
+ * @dev_addr: physical device port address
+ * @dmamode: DMA transfer mode, %DMA_MODE_READ from the device to the memory
+ * or %DMA_MODE_WRITE from memory to the device
+ *
+ * The function setups DMA channel state and registers to be ready for transfer
+ * specified by provided parameters. The scatter-gather emulation is set up
+ * according to the parameters.
+ *
+ * The full preparation of the transfer requires setup of more register
+ * by the caller before imx_dma_enable() can be called.
+ *
+ * %BLR(dma_ch) holds transfer burst length in bytes, 0 means 64 bytes
+ *
+ * %RSSR(dma_ch) has to be set to the DMA request line source %DMA_REQ_xxx
+ *
+ * %CCR(dma_ch) has to specify transfer parameters, the next settings is typical
+ * for linear or simple scatter-gather transfers if %DMA_MODE_READ is specified
+ *
+ * %CCR_DMOD_LINEAR | %CCR_DSIZ_32 | %CCR_SMOD_FIFO | %CCR_SSIZ_x
+ *
+ * The typical setup for %DMA_MODE_WRITE is specified by next options combination
+ *
+ * %CCR_SMOD_LINEAR | %CCR_SSIZ_32 | %CCR_DMOD_FIFO | %CCR_DSIZ_x
+ *
+ * Be carefull there and do not mistakenly mix source and target device
+ * port sizes constants, they are really different:
+ * %CCR_SSIZ_8, %CCR_SSIZ_16, %CCR_SSIZ_32,
+ * %CCR_DSIZ_8, %CCR_DSIZ_16, %CCR_DSIZ_32
+ *
+ * Return value: if incorrect parameters are provided -%EINVAL.
+ * Zero indicates success.
+ */
+int
+imx_dma_setup_sg(imx_dmach_t dma_ch,
+ struct scatterlist *sg, unsigned int sgcount, unsigned int dma_length,
+ unsigned int dev_addr, dmamode_t dmamode)
+{
+ int res;
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
+
+ imxdma->sg = NULL;
+ imxdma->sgcount = 0;
+ imxdma->dma_mode = dmamode;
+ imxdma->resbytes = dma_length;
+
+ if (!sg || !sgcount) {
+ printk(KERN_ERR "imxdma%d: imx_dma_setup_sg epty sg list\n",
+ dma_ch);
+ return -EINVAL;
+ }
+
+ if (!sg->length) {
+ printk(KERN_ERR "imxdma%d: imx_dma_setup_sg zero length\n",
+ dma_ch);
+ return -EINVAL;
}
- if (found) {
- DIMR &= ~(1 << i);
- dma_channels[i].name = name;
- dma_channels[i].irq_handler = irq_handler;
- dma_channels[i].err_handler = err_handler;
- dma_channels[i].data = data;
+ if ((dmamode & DMA_MODE_MASK) == DMA_MODE_READ) {
+ pr_debug("imxdma%d: mx_dma_setup_sg2dev sg=%p sgcount=%d total length=%d dev_addr=0x%08x for read\n",
+ dma_ch, sg, sgcount, dma_length, dev_addr);
+ SAR(dma_ch) = dev_addr;
+ } else if ((dmamode & DMA_MODE_MASK) == DMA_MODE_WRITE) {
+ pr_debug("imxdma%d: mx_dma_setup_sg2dev sg=%p sgcount=%d total length=%d dev_addr=0x%08x for write\n",
+ dma_ch, sg, sgcount, dma_length, dev_addr);
+ DAR(dma_ch) = dev_addr;
} else {
- printk(KERN_WARNING "No more available DMA channels for %s\n",
- name);
- i = -ENODEV;
+ printk(KERN_ERR "imxdma%d: imx_dma_setup_sg bad dmamode\n",
+ dma_ch);
+ return -EINVAL;
+ }
+
+ res = imx_dma_setup_sg_base(dma_ch, sg, sgcount);
+ if (res <= 0) {
+ printk(KERN_ERR "imxdma%d: no sg chunk ready\n", dma_ch);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/**
+ * imx_dma_setup_handlers - setup i.MX DMA channel end and error notification handlers
+ * @dma_ch: i.MX DMA channel number
+ * @irq_handler: the pointer to the function called if the transfer
+ * ends successfully
+ * @err_handler: the pointer to the function called if the premature
+ * end caused by error occurs
+ * @data: user specified value to be passed to the handlers
+ */
+int
+imx_dma_setup_handlers(imx_dmach_t dma_ch,
+ void (*irq_handler) (int, void *, struct pt_regs *),
+ void (*err_handler) (int, void *, struct pt_regs *),
+ void *data)
+{
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
+ unsigned long flags;
+
+ if (!imxdma->name) {
+ printk(KERN_CRIT "%s: called for not allocated channel %d\n",
+ __FUNCTION__, dma_ch);
+ return -ENODEV;
+ }
+
+ local_irq_save(flags);
+ DISR = (1 << dma_ch);
+ imxdma->irq_handler = irq_handler;
+ imxdma->err_handler = err_handler;
+ imxdma->data = data;
+ local_irq_restore(flags);
+ return 0;
+}
+
+/**
+ * imx_dma_enable - function to start i.MX DMA channel operation
+ * @dma_ch: i.MX DMA channel number
+ *
+ * The channel has to be allocated by driver through imx_dma_request()
+ * or imx_dma_request_by_prio() function.
+ * The transfer parameters has to be set to the channel registers through
+ * call of the imx_dma_setup_single() or imx_dma_setup_sg() function
+ * and registers %BLR(dma_ch), %RSSR(dma_ch) and %CCR(dma_ch) has to
+ * be set prior this function call by the channel user.
+ */
+void imx_dma_enable(imx_dmach_t dma_ch)
+{
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
+ unsigned long flags;
+
+ pr_debug("imxdma%d: imx_dma_enable\n", dma_ch);
+
+ if (!imxdma->name) {
+ printk(KERN_CRIT "%s: called for not allocated channel %d\n",
+ __FUNCTION__, dma_ch);
+ return;
+ }
+
+ local_irq_save(flags);
+ DISR = (1 << dma_ch);
+ DIMR &= ~(1 << dma_ch);
+ CCR(dma_ch) |= CCR_CEN;
+ local_irq_restore(flags);
+}
+
+/**
+ * imx_dma_disable - stop, finish i.MX DMA channel operatin
+ * @dma_ch: i.MX DMA channel number
+ */
+void imx_dma_disable(imx_dmach_t dma_ch)
+{
+ unsigned long flags;
+
+ pr_debug("imxdma%d: imx_dma_disable\n", dma_ch);
+
+ local_irq_save(flags);
+ DIMR |= (1 << dma_ch);
+ CCR(dma_ch) &= ~CCR_CEN;
+ DISR = (1 << dma_ch);
+ local_irq_restore(flags);
+}
+
+/**
+ * imx_dma_request - request/allocate specified channel number
+ * @dma_ch: i.MX DMA channel number
+ * @name: the driver/caller own non-%NULL identification
+ */
+int imx_dma_request(imx_dmach_t dma_ch, const char *name)
+{
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
+ unsigned long flags;
+
+ /* basic sanity checks */
+ if (!name)
+ return -EINVAL;
+
+ if (dma_ch >= IMX_DMA_CHANNELS) {
+ printk(KERN_CRIT "%s: called for non-existed channel %d\n",
+ __FUNCTION__, dma_ch);
+ return -EINVAL;
}
+ local_irq_save(flags);
+ if (imxdma->name) {
+ local_irq_restore(flags);
+ return -ENODEV;
+ }
+
+ imxdma->name = name;
+ imxdma->irq_handler = NULL;
+ imxdma->err_handler = NULL;
+ imxdma->data = NULL;
+ imxdma->sg = NULL;
local_irq_restore(flags);
- return i;
+ return 0;
}
-void
-imx_free_dma(int dma_ch)
+/**
+ * imx_dma_free - release previously acquired channel
+ * @dma_ch: i.MX DMA channel number
+ */
+void imx_dma_free(imx_dmach_t dma_ch)
{
unsigned long flags;
+ struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
- if (!dma_channels[dma_ch].name) {
+ if (!imxdma->name) {
printk(KERN_CRIT
"%s: trying to free channel %d which is already freed\n",
__FUNCTION__, dma_ch);
@@ -92,27 +398,84 @@ imx_free_dma(int dma_ch)
}
local_irq_save(flags);
- DIMR &= ~(1 << dma_ch);
- dma_channels[dma_ch].name = NULL;
+ /* Disable interrupts */
+ DIMR |= (1 << dma_ch);
+ CCR(dma_ch) &= ~CCR_CEN;
+ imxdma->name = NULL;
local_irq_restore(flags);
}
-static irqreturn_t
-dma_err_handler(int irq, void *dev_id, struct pt_regs *regs)
+/**
+ * imx_dma_request_by_prio - find and request some of free channels best suiting requested priority
+ * @dma_ch: i.MX DMA channel number
+ * @name: the driver/caller own non-%NULL identification
+ * @prio: one of the hardware distinguished priority level:
+ * %DMA_PRIO_HIGH, %DMA_PRIO_MEDIUM, %DMA_PRIO_LOW
+ *
+ * This function tries to find free channel in the specified priority group
+ * if the priority cannot be achieved it tries to look for free channel
+ * in the higher and then even lower priority groups.
+ *
+ * Return value: If there is no free channel to allocate, -%ENODEV is returned.
+ * Zero value indicates successful channel allocation.
+ */
+int
+imx_dma_request_by_prio(imx_dmach_t * pdma_ch, const char *name,
+ imx_dma_prio prio)
+{
+ int i;
+ int best;
+
+ switch (prio) {
+ case (DMA_PRIO_HIGH):
+ best = 8;
+ break;
+ case (DMA_PRIO_MEDIUM):
+ best = 4;
+ break;
+ case (DMA_PRIO_LOW):
+ default:
+ best = 0;
+ break;
+ }
+
+ for (i = best; i < IMX_DMA_CHANNELS; i++) {
+ if (!imx_dma_request(i, name)) {
+ *pdma_ch = i;
+ return 0;
+ }
+ }
+
+ for (i = best - 1; i >= 0; i--) {
+ if (!imx_dma_request(i, name)) {
+ *pdma_ch = i;
+ return 0;
+ }
+ }
+
+ printk(KERN_ERR "%s: no free DMA channel found\n", __FUNCTION__);
+
+ return -ENODEV;
+}
+
+static irqreturn_t dma_err_handler(int irq, void *dev_id, struct pt_regs *regs)
{
int i, disr = DISR;
- struct dma_channel *channel;
+ struct imx_dma_channel *channel;
unsigned int err_mask = DBTOSR | DRTOSR | DSESR | DBOSR;
DISR = disr;
- for (i = 0; i < 11; i++) {
- channel = &dma_channels[i];
+ for (i = 0; i < IMX_DMA_CHANNELS; i++) {
+ channel = &imx_dma_channels[i];
- if ( (err_mask & 1<<i) && channel->name && channel->err_handler) {
+ if ((err_mask & 1 << i) && channel->name
+ && channel->err_handler) {
channel->err_handler(i, channel->data, regs);
continue;
}
+ imx_dma_channels[i].sg = NULL;
+
if (DBTOSR & (1 << i)) {
printk(KERN_WARNING
"Burst timeout on channel %d (%s)\n",
@@ -141,17 +504,27 @@ dma_err_handler(int irq, void *dev_id, struct pt_regs *regs)
return IRQ_HANDLED;
}
-static irqreturn_t
-dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
{
int i, disr = DISR;
+ pr_debug("imxdma: dma_irq_handler called, disr=0x%08x\n",
+ disr);
+
DISR = disr;
- for (i = 0; i < 11; i++) {
+ for (i = 0; i < IMX_DMA_CHANNELS; i++) {
if (disr & (1 << i)) {
- struct dma_channel *channel = &dma_channels[i];
- if (channel->name && channel->irq_handler) {
- channel->irq_handler(i, channel->data, regs);
+ struct imx_dma_channel *channel = &imx_dma_channels[i];
+ if (channel->name) {
+ if (imx_dma_sg_next(i, CNTR(i))) {
+ CCR(i) &= ~CCR_CEN;
+ mb();
+ CCR(i) |= CCR_CEN;
+ } else {
+ if (channel->irq_handler)
+ channel->irq_handler(i,
+ channel->data, regs);
+ }
} else {
/*
* IRQ for an unregistered DMA channel:
@@ -165,10 +538,10 @@ dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
return IRQ_HANDLED;
}
-static int __init
-imx_dma_init(void)
+static int __init imx_dma_init(void)
{
int ret;
+ int i;
/* reset DMA module */
DCR = DCR_DRST;
@@ -189,15 +562,27 @@ imx_dma_init(void)
DCR = DCR_DEN;
/* clear all interrupts */
- DISR = 0x3ff;
+ DISR = (1 << IMX_DMA_CHANNELS) - 1;
/* enable interrupts */
- DIMR = 0;
+ DIMR = (1 << IMX_DMA_CHANNELS) - 1;
+
+ for (i = 0; i < IMX_DMA_CHANNELS; i++) {
+ imx_dma_channels[i].sg = NULL;
+ imx_dma_channels[i].dma_num = i;
+ }
return ret;
}
arch_initcall(imx_dma_init);
-EXPORT_SYMBOL(imx_request_dma);
-EXPORT_SYMBOL(imx_free_dma);
+EXPORT_SYMBOL(imx_dma_setup_single);
+EXPORT_SYMBOL(imx_dma_setup_sg);
+EXPORT_SYMBOL(imx_dma_setup_handlers);
+EXPORT_SYMBOL(imx_dma_enable);
+EXPORT_SYMBOL(imx_dma_disable);
+EXPORT_SYMBOL(imx_dma_request);
+EXPORT_SYMBOL(imx_dma_free);
+EXPORT_SYMBOL(imx_dma_request_by_prio);
+EXPORT_SYMBOL(imx_dma_channels);
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index 37613ad68366e..9d8331be2b58e 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -33,6 +33,7 @@
#include <asm/arch/imx-regs.h>
#include <asm/mach/map.h>
+#include <asm/arch/mmc.h>
void imx_gpio_mode(int gpio_mode)
{
@@ -175,13 +176,25 @@ static struct resource imx_mmc_resources[] = {
},
};
+static u64 imxmmmc_dmamask = 0xffffffffUL;
+
static struct platform_device imx_mmc_device = {
.name = "imx-mmc",
.id = 0,
+ .dev = {
+ .dma_mask = &imxmmmc_dmamask,
+ .coherent_dma_mask = 0xffffffff,
+ },
.num_resources = ARRAY_SIZE(imx_mmc_resources),
.resource = imx_mmc_resources,
};
+void __init imx_set_mmc_info(struct imxmmc_platform_data *info)
+{
+ imx_mmc_device.dev.platform_data = info;
+}
+EXPORT_SYMBOL(imx_set_mmc_info);
+
static struct resource imx_uart1_resources[] = {
[0] = {
.start = 0x00206000,
diff --git a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c
index 8ab1b040288c0..e34d0df90aed8 100644
--- a/arch/arm/mach-imx/mx1ads.c
+++ b/arch/arm/mach-imx/mx1ads.c
@@ -25,6 +25,7 @@
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
+#include <asm/arch/mmc.h>
#include <linux/interrupt.h>
#include "generic.h"
@@ -51,12 +52,29 @@ static struct platform_device *devices[] __initdata = {
&cs89x0_device,
};
+#ifdef CONFIG_MMC_IMX
+static int mx1ads_mmc_card_present(void)
+{
+ /* MMC/SD Card Detect is PB 20 on MX1ADS V1.0.7 */
+ return (SSR(1) & (1 << 20) ? 0 : 1);
+}
+
+static struct imxmmc_platform_data mx1ads_mmc_info = {
+ .card_present = mx1ads_mmc_card_present,
+};
+#endif
+
static void __init
mx1ads_init(void)
{
#ifdef CONFIG_LEDS
imx_gpio_mode(GPIO_PORTA | GPIO_OUT | 2);
#endif
+#ifdef CONFIG_MMC_IMX
+ /* SD/MMC card detect */
+ imx_gpio_mode(GPIO_PORTB | GPIO_GIUS | GPIO_IN | 20);
+ imx_set_mmc_info(&mx1ads_mmc_info);
+#endif
platform_add_devices(devices, ARRAY_SIZE(devices));
}
diff --git a/arch/arm/mach-ixp23xx/espresso.c b/arch/arm/mach-ixp23xx/espresso.c
index 2327c97904162..bf688c1286301 100644
--- a/arch/arm/mach-ixp23xx/espresso.c
+++ b/arch/arm/mach-ixp23xx/espresso.c
@@ -44,6 +44,15 @@
#include <asm/mach/irq.h>
#include <asm/mach/pci.h>
+static int __init espresso_pci_init(void)
+{
+ if (machine_is_espresso())
+ ixp23xx_pci_slave_init();
+
+ return 0;
+};
+subsys_initcall(espresso_pci_init);
+
static void __init espresso_init(void)
{
physmap_configure(0x90000000, 0x02000000, 2, NULL);
diff --git a/arch/arm/mach-ixp23xx/pci.c b/arch/arm/mach-ixp23xx/pci.c
index 5330ad78c1bb2..ac72f94c5b4d5 100644
--- a/arch/arm/mach-ixp23xx/pci.c
+++ b/arch/arm/mach-ixp23xx/pci.c
@@ -201,7 +201,7 @@ int clear_master_aborts(void)
return 0;
}
-void __init ixp23xx_pci_preinit(void)
+static void __init ixp23xx_pci_common_init(void)
{
#ifdef __ARMEB__
*IXP23XX_PCI_CONTROL |= 0x20000; /* set I/O swapping */
@@ -219,7 +219,18 @@ void __init ixp23xx_pci_preinit(void)
*IXP23XX_PCI_CPP_ADDR_BITS &= ~(1 << 1);
} else {
*IXP23XX_PCI_CPP_ADDR_BITS |= (1 << 1);
+
+ /*
+ * Enable coherency on A2 silicon.
+ */
+ if (arch_is_coherent())
+ *IXP23XX_CPP2XSI_CURR_XFER_REG3 &= ~IXP23XX_CPP2XSI_COH_OFF;
}
+}
+
+void __init ixp23xx_pci_preinit(void)
+{
+ ixp23xx_pci_common_init();
hook_fault_code(16+6, ixp23xx_pci_abort_handler, SIGBUS,
"PCI config cycle to non-existent device");
@@ -273,3 +284,8 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
return 1;
}
+
+void ixp23xx_pci_slave_init(void)
+{
+ ixp23xx_pci_common_init();
+}
diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 86a0f0d14345c..f8d716ccc1dfb 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -69,12 +69,6 @@ config MACH_VOICEBLUE
Support for Voiceblue GSM/VoIP gateway. Say Y here if you have
such a board.
-config MACH_NETSTAR
- bool "NetStar"
- depends on ARCH_OMAP1 && ARCH_OMAP15XX
- help
- Support for NetStar PBX. Say Y here if you have such a board.
-
config MACH_OMAP_PALMTE
bool "Palm Tungsten E"
depends on ARCH_OMAP1 && ARCH_OMAP15XX
@@ -85,6 +79,20 @@ config MACH_OMAP_PALMTE
informations.
Say Y here if you have such a PDA, say NO otherwise.
+config MACH_NOKIA770
+ bool "Nokia 770"
+ depends on ARCH_OMAP1 && ARCH_OMAP16XX
+ help
+ Support for the Nokia 770 Internet Tablet. Say Y here if you
+ have such a device.
+
+config MACH_AMS_DELTA
+ bool "Amstrad E3 (Delta)"
+ depends on ARCH_OMAP1 && ARCH_OMAP15XX
+ help
+ Support for the Amstrad E3 (codename Delta) videophone. Say Y here
+ if you have such a device.
+
config MACH_OMAP_GENERIC
bool "Generic OMAP board"
depends on ARCH_OMAP1 && (ARCH_OMAP15XX || ARCH_OMAP16XX)
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index b0b00156faaef..9ea719550ad37 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -3,7 +3,13 @@
#
# Common support
-obj-y := io.o id.o clock.o irq.o time.o mux.o serial.o devices.o
+obj-y := io.o id.o clock.o irq.o mux.o serial.o devices.o
+
+obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
+
+# Power Management
+obj-$(CONFIG_PM) += pm.o sleep.o
+
led-y := leds.o
# Specific board support
@@ -14,8 +20,9 @@ obj-$(CONFIG_MACH_OMAP_PERSEUS2) += board-perseus2.o
obj-$(CONFIG_MACH_OMAP_OSK) += board-osk.o
obj-$(CONFIG_MACH_OMAP_H3) += board-h3.o
obj-$(CONFIG_MACH_VOICEBLUE) += board-voiceblue.o
-obj-$(CONFIG_MACH_NETSTAR) += board-netstar.o
obj-$(CONFIG_MACH_OMAP_PALMTE) += board-palmte.o
+obj-$(CONFIG_MACH_NOKIA770) += board-nokia770.o
+obj-$(CONFIG_MACH_AMS_DELTA) += board-ams-delta.o
ifeq ($(CONFIG_ARCH_OMAP15XX),y)
# Innovator-1510 FPGA
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
new file mode 100644
index 0000000000000..6178f046f128c
--- /dev/null
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -0,0 +1,116 @@
+/*
+ * linux/arch/arm/mach-omap1/board-ams-delta.c
+ *
+ * Modified from board-generic.c
+ *
+ * Board specific inits for the Amstrad E3 (codename Delta) videophone
+ *
+ * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <asm/arch/board-ams-delta.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/usb.h>
+#include <asm/arch/board.h>
+#include <asm/arch/common.h>
+
+static u8 ams_delta_latch1_reg;
+static u16 ams_delta_latch2_reg;
+
+void ams_delta_latch1_write(u8 mask, u8 value)
+{
+ ams_delta_latch1_reg &= ~mask;
+ ams_delta_latch1_reg |= value;
+ *(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg;
+}
+
+void ams_delta_latch2_write(u16 mask, u16 value)
+{
+ ams_delta_latch2_reg &= ~mask;
+ ams_delta_latch2_reg |= value;
+ *(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
+}
+
+static void __init ams_delta_init_irq(void)
+{
+ omap1_init_common_hw();
+ omap_init_irq();
+ omap_gpio_init();
+}
+
+static struct map_desc ams_delta_io_desc[] __initdata = {
+ // AMS_DELTA_LATCH1
+ {
+ .virtual = AMS_DELTA_LATCH1_VIRT,
+ .pfn = __phys_to_pfn(AMS_DELTA_LATCH1_PHYS),
+ .length = 0x01000000,
+ .type = MT_DEVICE
+ },
+ // AMS_DELTA_LATCH2
+ {
+ .virtual = AMS_DELTA_LATCH2_VIRT,
+ .pfn = __phys_to_pfn(AMS_DELTA_LATCH2_PHYS),
+ .length = 0x01000000,
+ .type = MT_DEVICE
+ },
+ // AMS_DELTA_MODEM
+ {
+ .virtual = AMS_DELTA_MODEM_VIRT,
+ .pfn = __phys_to_pfn(AMS_DELTA_MODEM_PHYS),
+ .length = 0x01000000,
+ .type = MT_DEVICE
+ }
+};
+
+static struct omap_uart_config ams_delta_uart_config __initdata = {
+ .enabled_uarts = 1,
+};
+
+static struct omap_board_config_kernel ams_delta_config[] = {
+ { OMAP_TAG_UART, &ams_delta_uart_config },
+};
+
+static void __init ams_delta_init(void)
+{
+ iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));
+
+ omap_board_config = ams_delta_config;
+ omap_board_config_size = ARRAY_SIZE(ams_delta_config);
+ omap_serial_init();
+
+ /* Clear latch2 (NAND, LCD, modem enable) */
+ ams_delta_latch2_write(~0, 0);
+}
+
+static void __init ams_delta_map_io(void)
+{
+ omap1_map_common_io();
+}
+
+MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
+ /* Maintainer: Jonathan McDowell <noodles@earth.li> */
+ .phys_io = 0xfff00000,
+ .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
+ .boot_params = 0x10000100,
+ .map_io = ams_delta_map_io,
+ .init_irq = ams_delta_init_irq,
+ .init_machine = ams_delta_init,
+ .timer = &omap_timer,
+MACHINE_END
+
+EXPORT_SYMBOL(ams_delta_latch1_write);
+EXPORT_SYMBOL(ams_delta_latch2_write);
diff --git a/arch/arm/mach-omap1/board-generic.c b/arch/arm/mach-omap1/board-generic.c
index a177e78b2b878..33d01adab1ed6 100644
--- a/arch/arm/mach-omap1/board-generic.c
+++ b/arch/arm/mach-omap1/board-generic.c
@@ -88,7 +88,7 @@ static struct omap_board_config_kernel generic_config[] = {
static void __init omap_generic_init(void)
{
#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap1510()) {
+ if (cpu_is_omap15xx()) {
generic_config[0].data = &generic1510_usb_config;
}
#endif
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 89f0cc74a5197..cd3a06dfc0a83 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -24,7 +24,9 @@
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
+#include <linux/input.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -35,12 +37,55 @@
#include <asm/arch/gpio.h>
#include <asm/arch/mux.h>
#include <asm/arch/tc.h>
+#include <asm/arch/irda.h>
#include <asm/arch/usb.h>
+#include <asm/arch/keypad.h>
#include <asm/arch/common.h>
+#include <asm/arch/mcbsp.h>
+#include <asm/arch/omap-alsa.h>
extern int omap_gpio_init(void);
-static struct mtd_partition h2_partitions[] = {
+static int h2_keymap[] = {
+ KEY(0, 0, KEY_LEFT),
+ KEY(0, 1, KEY_RIGHT),
+ KEY(0, 2, KEY_3),
+ KEY(0, 3, KEY_F10),
+ KEY(0, 4, KEY_F5),
+ KEY(0, 5, KEY_9),
+ KEY(1, 0, KEY_DOWN),
+ KEY(1, 1, KEY_UP),
+ KEY(1, 2, KEY_2),
+ KEY(1, 3, KEY_F9),
+ KEY(1, 4, KEY_F7),
+ KEY(1, 5, KEY_0),
+ KEY(2, 0, KEY_ENTER),
+ KEY(2, 1, KEY_6),
+ KEY(2, 2, KEY_1),
+ KEY(2, 3, KEY_F2),
+ KEY(2, 4, KEY_F6),
+ KEY(2, 5, KEY_HOME),
+ KEY(3, 0, KEY_8),
+ KEY(3, 1, KEY_5),
+ KEY(3, 2, KEY_F12),
+ KEY(3, 3, KEY_F3),
+ KEY(3, 4, KEY_F8),
+ KEY(3, 5, KEY_END),
+ KEY(4, 0, KEY_7),
+ KEY(4, 1, KEY_4),
+ KEY(4, 2, KEY_F11),
+ KEY(4, 3, KEY_F1),
+ KEY(4, 4, KEY_F4),
+ KEY(4, 5, KEY_ESC),
+ KEY(5, 0, KEY_F13),
+ KEY(5, 1, KEY_F14),
+ KEY(5, 2, KEY_F15),
+ KEY(5, 3, KEY_F16),
+ KEY(5, 4, KEY_SLEEP),
+ 0
+};
+
+static struct mtd_partition h2_nor_partitions[] = {
/* bootloader (U-Boot, etc) in first sector */
{
.name = "bootloader",
@@ -71,26 +116,26 @@ static struct mtd_partition h2_partitions[] = {
}
};
-static struct flash_platform_data h2_flash_data = {
+static struct flash_platform_data h2_nor_data = {
.map_name = "cfi_probe",
.width = 2,
- .parts = h2_partitions,
- .nr_parts = ARRAY_SIZE(h2_partitions),
+ .parts = h2_nor_partitions,
+ .nr_parts = ARRAY_SIZE(h2_nor_partitions),
};
-static struct resource h2_flash_resource = {
+static struct resource h2_nor_resource = {
/* This is on CS3, wherever it's mapped */
.flags = IORESOURCE_MEM,
};
-static struct platform_device h2_flash_device = {
+static struct platform_device h2_nor_device = {
.name = "omapflash",
.id = 0,
.dev = {
- .platform_data = &h2_flash_data,
+ .platform_data = &h2_nor_data,
},
.num_resources = 1,
- .resource = &h2_flash_resource,
+ .resource = &h2_nor_resource,
};
static struct resource h2_smc91x_resources[] = {
@@ -113,9 +158,119 @@ static struct platform_device h2_smc91x_device = {
.resource = h2_smc91x_resources,
};
+static struct resource h2_kp_resources[] = {
+ [0] = {
+ .start = INT_KEYBOARD,
+ .end = INT_KEYBOARD,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct omap_kp_platform_data h2_kp_data = {
+ .rows = 8,
+ .cols = 8,
+ .keymap = h2_keymap,
+ .rep = 1,
+};
+
+static struct platform_device h2_kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &h2_kp_data,
+ },
+ .num_resources = ARRAY_SIZE(h2_kp_resources),
+ .resource = h2_kp_resources,
+};
+
+#define H2_IRDA_FIRSEL_GPIO_PIN 17
+
+#if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
+static int h2_transceiver_mode(struct device *dev, int state)
+{
+ if (state & IR_SIRMODE)
+ omap_set_gpio_dataout(H2_IRDA_FIRSEL_GPIO_PIN, 0);
+ else /* MIR/FIR */
+ omap_set_gpio_dataout(H2_IRDA_FIRSEL_GPIO_PIN, 1);
+
+ return 0;
+}
+#endif
+
+static struct omap_irda_config h2_irda_data = {
+ .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
+ .rx_channel = OMAP_DMA_UART3_RX,
+ .tx_channel = OMAP_DMA_UART3_TX,
+ .dest_start = UART3_THR,
+ .src_start = UART3_RHR,
+ .tx_trigger = 0,
+ .rx_trigger = 0,
+};
+
+static struct resource h2_irda_resources[] = {
+ [0] = {
+ .start = INT_UART3,
+ .end = INT_UART3,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device h2_irda_device = {
+ .name = "omapirda",
+ .id = 0,
+ .dev = {
+ .platform_data = &h2_irda_data,
+ },
+ .num_resources = ARRAY_SIZE(h2_irda_resources),
+ .resource = h2_irda_resources,
+};
+
+static struct platform_device h2_lcd_device = {
+ .name = "lcd_h2",
+ .id = -1,
+};
+
+static struct omap_mcbsp_reg_cfg mcbsp_regs = {
+ .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
+ .spcr1 = RINTM(3) | RRST,
+ .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
+ RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
+ .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
+ .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
+ XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
+ .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
+ .srgr1 = FWID(15),
+ .srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
+
+ .pcr0 = CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
+ //.pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
+};
+
+static struct omap_alsa_codec_config alsa_config = {
+ .name = "H2 TSC2101",
+ .mcbsp_regs_alsa = &mcbsp_regs,
+ .codec_configure_dev = NULL, // tsc2101_configure,
+ .codec_set_samplerate = NULL, // tsc2101_set_samplerate,
+ .codec_clock_setup = NULL, // tsc2101_clock_setup,
+ .codec_clock_on = NULL, // tsc2101_clock_on,
+ .codec_clock_off = NULL, // tsc2101_clock_off,
+ .get_default_samplerate = NULL, // tsc2101_get_default_samplerate,
+};
+
+static struct platform_device h2_mcbsp1_device = {
+ .name = "omap_alsa_mcbsp",
+ .id = 1,
+ .dev = {
+ .platform_data = &alsa_config,
+ },
+};
+
static struct platform_device *h2_devices[] __initdata = {
- &h2_flash_device,
+ &h2_nor_device,
&h2_smc91x_device,
+ &h2_irda_device,
+ &h2_kp_device,
+ &h2_lcd_device,
+ &h2_mcbsp1_device,
};
static void __init h2_init_smc91x(void)
@@ -164,7 +319,6 @@ static struct omap_uart_config h2_uart_config __initdata = {
};
static struct omap_lcd_config h2_lcd_config __initdata = {
- .panel_name = "h2",
.ctrl_name = "internal",
};
@@ -177,16 +331,34 @@ static struct omap_board_config_kernel h2_config[] = {
static void __init h2_init(void)
{
- /* NOTE: revC boards support NAND-boot, which can put NOR on CS2B
- * and NAND (either 16bit or 8bit) on CS3.
+ /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
+ * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
+ * notice whether a NAND chip is enabled at probe time.
+ *
+ * FIXME revC boards (and H3) support NAND-boot, with a dip switch to
+ * put NOR on CS2B and NAND (which on H2 may be 16bit) on CS3. Try
+ * detecting that in code here, to avoid probing every possible flash
+ * configuration...
*/
- h2_flash_resource.end = h2_flash_resource.start = omap_cs3_phys();
- h2_flash_resource.end += SZ_32M - 1;
+ h2_nor_resource.end = h2_nor_resource.start = omap_cs3_phys();
+ h2_nor_resource.end += SZ_32M - 1;
+
+ omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
+ omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
/* MMC: card detect and WP */
// omap_cfg_reg(U19_ARMIO1); /* CD */
omap_cfg_reg(BALLOUT_V8_ARMIO3); /* WP */
+ /* Irda */
+#if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
+ omap_writel(omap_readl(FUNC_MUX_CTRL_A) | 7, FUNC_MUX_CTRL_A);
+ if (!(omap_request_gpio(H2_IRDA_FIRSEL_GPIO_PIN))) {
+ omap_set_gpio_direction(H2_IRDA_FIRSEL_GPIO_PIN, 0);
+ h2_irda_data.transceiver_mode = h2_transceiver_mode;
+ }
+#endif
+
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_board_config = h2_config;
omap_board_config_size = ARRAY_SIZE(h2_config);
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index d9f3862659967..4b8d0ec73cb76 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -21,8 +21,11 @@
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/errno.h>
+#include <linux/workqueue.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
+#include <linux/input.h>
#include <asm/setup.h>
#include <asm/page.h>
@@ -33,15 +36,59 @@
#include <asm/mach/map.h>
#include <asm/arch/gpio.h>
+#include <asm/arch/gpioexpander.h>
#include <asm/arch/irqs.h>
#include <asm/arch/mux.h>
#include <asm/arch/tc.h>
+#include <asm/arch/irda.h>
#include <asm/arch/usb.h>
+#include <asm/arch/keypad.h>
+#include <asm/arch/dma.h>
#include <asm/arch/common.h>
extern int omap_gpio_init(void);
-static struct mtd_partition h3_partitions[] = {
+static int h3_keymap[] = {
+ KEY(0, 0, KEY_LEFT),
+ KEY(0, 1, KEY_RIGHT),
+ KEY(0, 2, KEY_3),
+ KEY(0, 3, KEY_F10),
+ KEY(0, 4, KEY_F5),
+ KEY(0, 5, KEY_9),
+ KEY(1, 0, KEY_DOWN),
+ KEY(1, 1, KEY_UP),
+ KEY(1, 2, KEY_2),
+ KEY(1, 3, KEY_F9),
+ KEY(1, 4, KEY_F7),
+ KEY(1, 5, KEY_0),
+ KEY(2, 0, KEY_ENTER),
+ KEY(2, 1, KEY_6),
+ KEY(2, 2, KEY_1),
+ KEY(2, 3, KEY_F2),
+ KEY(2, 4, KEY_F6),
+ KEY(2, 5, KEY_HOME),
+ KEY(3, 0, KEY_8),
+ KEY(3, 1, KEY_5),
+ KEY(3, 2, KEY_F12),
+ KEY(3, 3, KEY_F3),
+ KEY(3, 4, KEY_F8),
+ KEY(3, 5, KEY_END),
+ KEY(4, 0, KEY_7),
+ KEY(4, 1, KEY_4),
+ KEY(4, 2, KEY_F11),
+ KEY(4, 3, KEY_F1),
+ KEY(4, 4, KEY_F4),
+ KEY(4, 5, KEY_ESC),
+ KEY(5, 0, KEY_F13),
+ KEY(5, 1, KEY_F14),
+ KEY(5, 2, KEY_F15),
+ KEY(5, 3, KEY_F16),
+ KEY(5, 4, KEY_SLEEP),
+ 0
+};
+
+
+static struct mtd_partition nor_partitions[] = {
/* bootloader (U-Boot, etc) in first sector */
{
.name = "bootloader",
@@ -72,26 +119,80 @@ static struct mtd_partition h3_partitions[] = {
}
};
-static struct flash_platform_data h3_flash_data = {
+static struct flash_platform_data nor_data = {
.map_name = "cfi_probe",
.width = 2,
- .parts = h3_partitions,
- .nr_parts = ARRAY_SIZE(h3_partitions),
+ .parts = nor_partitions,
+ .nr_parts = ARRAY_SIZE(nor_partitions),
};
-static struct resource h3_flash_resource = {
+static struct resource nor_resource = {
/* This is on CS3, wherever it's mapped */
.flags = IORESOURCE_MEM,
};
-static struct platform_device flash_device = {
+static struct platform_device nor_device = {
.name = "omapflash",
.id = 0,
.dev = {
- .platform_data = &h3_flash_data,
+ .platform_data = &nor_data,
+ },
+ .num_resources = 1,
+ .resource = &nor_resource,
+};
+
+static struct mtd_partition nand_partitions[] = {
+#if 0
+ /* REVISIT: enable these partitions if you make NAND BOOT work */
+ {
+ .name = "xloader",
+ .offset = 0,
+ .size = 64 * 1024,
+ .mask_flags = MTD_WRITEABLE, /* force read-only */
+ },
+ {
+ .name = "bootloader",
+ .offset = MTDPART_OFS_APPEND,
+ .size = 256 * 1024,
+ .mask_flags = MTD_WRITEABLE, /* force read-only */
+ },
+ {
+ .name = "params",
+ .offset = MTDPART_OFS_APPEND,
+ .size = 192 * 1024,
+ },
+ {
+ .name = "kernel",
+ .offset = MTDPART_OFS_APPEND,
+ .size = 2 * SZ_1M,
+ },
+#endif
+ {
+ .name = "filesystem",
+ .size = MTDPART_SIZ_FULL,
+ .offset = MTDPART_OFS_APPEND,
+ },
+};
+
+/* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
+static struct nand_platform_data nand_data = {
+ .options = NAND_SAMSUNG_LP_OPTIONS,
+ .parts = nand_partitions,
+ .nr_parts = ARRAY_SIZE(nand_partitions),
+};
+
+static struct resource nand_resource = {
+ .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device nand_device = {
+ .name = "omapnand",
+ .id = 0,
+ .dev = {
+ .platform_data = &nand_data,
},
.num_resources = 1,
- .resource = &h3_flash_resource,
+ .resource = &nand_resource,
};
static struct resource smc91x_resources[] = {
@@ -138,10 +239,136 @@ static struct platform_device intlat_device = {
.resource = intlat_resources,
};
+static struct resource h3_kp_resources[] = {
+ [0] = {
+ .start = INT_KEYBOARD,
+ .end = INT_KEYBOARD,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct omap_kp_platform_data h3_kp_data = {
+ .rows = 8,
+ .cols = 8,
+ .keymap = h3_keymap,
+ .rep = 1,
+};
+
+static struct platform_device h3_kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &h3_kp_data,
+ },
+ .num_resources = ARRAY_SIZE(h3_kp_resources),
+ .resource = h3_kp_resources,
+};
+
+
+/* Select between the IrDA and aGPS module
+ */
+static int h3_select_irda(struct device *dev, int state)
+{
+ unsigned char expa;
+ int err = 0;
+
+ if ((err = read_gpio_expa(&expa, 0x26))) {
+ printk(KERN_ERR "Error reading from I/O EXPANDER \n");
+ return err;
+ }
+
+ /* 'P6' enable/disable IRDA_TX and IRDA_RX */
+ if (state & IR_SEL) { /* IrDA */
+ if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
+ printk(KERN_ERR "Error writing to I/O EXPANDER \n");
+ return err;
+ }
+ } else {
+ if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
+ printk(KERN_ERR "Error writing to I/O EXPANDER \n");
+ return err;
+ }
+ }
+ return err;
+}
+
+static void set_trans_mode(void *data)
+{
+ int *mode = data;
+ unsigned char expa;
+ int err = 0;
+
+ if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
+ printk(KERN_ERR "Error reading from I/O expander\n");
+ }
+
+ expa &= ~0x03;
+
+ if (*mode & IR_SIRMODE) {
+ expa |= 0x01;
+ } else { /* MIR/FIR */
+ expa |= 0x03;
+ }
+
+ if ((err = write_gpio_expa(expa, 0x27)) != 0) {
+ printk(KERN_ERR "Error writing to I/O expander\n");
+ }
+}
+
+static int h3_transceiver_mode(struct device *dev, int mode)
+{
+ struct omap_irda_config *irda_config = dev->platform_data;
+
+ cancel_delayed_work(&irda_config->gpio_expa);
+ PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
+ schedule_work(&irda_config->gpio_expa);
+
+ return 0;
+}
+
+static struct omap_irda_config h3_irda_data = {
+ .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
+ .transceiver_mode = h3_transceiver_mode,
+ .select_irda = h3_select_irda,
+ .rx_channel = OMAP_DMA_UART3_RX,
+ .tx_channel = OMAP_DMA_UART3_TX,
+ .dest_start = UART3_THR,
+ .src_start = UART3_RHR,
+ .tx_trigger = 0,
+ .rx_trigger = 0,
+};
+
+static struct resource h3_irda_resources[] = {
+ [0] = {
+ .start = INT_UART3,
+ .end = INT_UART3,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device h3_irda_device = {
+ .name = "omapirda",
+ .id = 0,
+ .dev = {
+ .platform_data = &h3_irda_data,
+ },
+ .num_resources = ARRAY_SIZE(h3_irda_resources),
+ .resource = h3_irda_resources,
+};
+
+static struct platform_device h3_lcd_device = {
+ .name = "lcd_h3",
+ .id = -1,
+};
+
static struct platform_device *devices[] __initdata = {
- &flash_device,
+ &nor_device,
+ &nand_device,
&smc91x_device,
&intlat_device,
+ &h3_irda_device,
+ &h3_kp_device,
+ &h3_lcd_device,
};
static struct omap_usb_config h3_usb_config __initdata = {
@@ -171,7 +398,6 @@ static struct omap_uart_config h3_uart_config __initdata = {
};
static struct omap_lcd_config h3_lcd_config __initdata = {
- .panel_name = "h3",
.ctrl_name = "internal",
};
@@ -182,11 +408,36 @@ static struct omap_board_config_kernel h3_config[] = {
{ OMAP_TAG_LCD, &h3_lcd_config },
};
+#define H3_NAND_RB_GPIO_PIN 10
+
+static int nand_dev_ready(struct nand_platform_data *data)
+{
+ return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
+}
+
static void __init h3_init(void)
{
- h3_flash_resource.end = h3_flash_resource.start = omap_cs3_phys();
- h3_flash_resource.end += OMAP_CS3_SIZE - 1;
- (void) platform_add_devices(devices, ARRAY_SIZE(devices));
+ /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
+ * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
+ * notice whether a NAND chip is enabled at probe time.
+ *
+ * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
+ * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
+ * to avoid probing every possible flash configuration...
+ */
+ nor_resource.end = nor_resource.start = omap_cs3_phys();
+ nor_resource.end += SZ_32M - 1;
+
+ nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
+ nand_resource.end += SZ_4K - 1;
+ if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
+ nand_data.dev_ready = nand_dev_ready;
+
+ /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
+ /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
+ omap_cfg_reg(V2_1710_GPIO10);
+
+ platform_add_devices(devices, ARRAY_SIZE(devices));
omap_board_config = h3_config;
omap_board_config_size = ARRAY_SIZE(h3_config);
omap_serial_init();
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index a04e4332915e6..e90c137a4cf31 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -22,6 +22,7 @@
#include <linux/delay.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/input.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -34,8 +35,22 @@
#include <asm/arch/gpio.h>
#include <asm/arch/tc.h>
#include <asm/arch/usb.h>
+#include <asm/arch/keypad.h>
#include <asm/arch/common.h>
+static int innovator_keymap[] = {
+ KEY(0, 0, KEY_F1),
+ KEY(0, 3, KEY_DOWN),
+ KEY(1, 1, KEY_F2),
+ KEY(1, 2, KEY_RIGHT),
+ KEY(2, 0, KEY_F3),
+ KEY(2, 1, KEY_F4),
+ KEY(2, 2, KEY_UP),
+ KEY(3, 2, KEY_ENTER),
+ KEY(3, 3, KEY_LEFT),
+ 0
+};
+
static struct mtd_partition innovator_partitions[] = {
/* bootloader (U-Boot, etc) in first sector */
{
@@ -97,6 +112,31 @@ static struct platform_device innovator_flash_device = {
.resource = &innovator_flash_resource,
};
+static struct resource innovator_kp_resources[] = {
+ [0] = {
+ .start = INT_KEYBOARD,
+ .end = INT_KEYBOARD,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct omap_kp_platform_data innovator_kp_data = {
+ .rows = 8,
+ .cols = 8,
+ .keymap = innovator_keymap,
+};
+
+static struct platform_device innovator_kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &innovator_kp_data,
+ },
+ .num_resources = ARRAY_SIZE(innovator_kp_resources),
+ .resource = innovator_kp_resources,
+};
+
+
#ifdef CONFIG_ARCH_OMAP15XX
/* Only FPGA needs to be mapped here. All others are done with ioremap */
@@ -129,9 +169,16 @@ static struct platform_device innovator1510_smc91x_device = {
.resource = innovator1510_smc91x_resources,
};
+static struct platform_device innovator1510_lcd_device = {
+ .name = "lcd_inn1510",
+ .id = -1,
+};
+
static struct platform_device *innovator1510_devices[] __initdata = {
&innovator_flash_device,
&innovator1510_smc91x_device,
+ &innovator_kp_device,
+ &innovator1510_lcd_device,
};
#endif /* CONFIG_ARCH_OMAP15XX */
@@ -158,9 +205,16 @@ static struct platform_device innovator1610_smc91x_device = {
.resource = innovator1610_smc91x_resources,
};
+static struct platform_device innovator1610_lcd_device = {
+ .name = "inn1610_lcd",
+ .id = -1,
+};
+
static struct platform_device *innovator1610_devices[] __initdata = {
&innovator_flash_device,
&innovator1610_smc91x_device,
+ &innovator_kp_device,
+ &innovator1610_lcd_device,
};
#endif /* CONFIG_ARCH_OMAP16XX */
@@ -206,7 +260,6 @@ static struct omap_usb_config innovator1510_usb_config __initdata = {
};
static struct omap_lcd_config innovator1510_lcd_config __initdata = {
- .panel_name = "inn1510",
.ctrl_name = "internal",
};
#endif
@@ -228,7 +281,6 @@ static struct omap_usb_config h2_usb_config __initdata = {
};
static struct omap_lcd_config innovator1610_lcd_config __initdata = {
- .panel_name = "inn1610",
.ctrl_name = "internal",
};
#endif
diff --git a/arch/arm/mach-omap1/board-netstar.c b/arch/arm/mach-omap1/board-netstar.c
deleted file mode 100644
index 7520e602d7a23..0000000000000
--- a/arch/arm/mach-omap1/board-netstar.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Modified from board-generic.c
- *
- * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz>
- *
- * Code for Netstar OMAP board.
- *
- * 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.
- */
-
-#include <linux/delay.h>
-#include <linux/platform_device.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/gpio.h>
-#include <asm/arch/mux.h>
-#include <asm/arch/usb.h>
-#include <asm/arch/common.h>
-
-extern void __init omap_init_time(void);
-extern int omap_gpio_init(void);
-
-static struct resource netstar_smc91x_resources[] = {
- [0] = {
- .start = OMAP_CS1_PHYS + 0x300,
- .end = OMAP_CS1_PHYS + 0x300 + 16,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = OMAP_GPIO_IRQ(8),
- .end = OMAP_GPIO_IRQ(8),
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device netstar_smc91x_device = {
- .name = "smc91x",
- .id = 0,
- .num_resources = ARRAY_SIZE(netstar_smc91x_resources),
- .resource = netstar_smc91x_resources,
-};
-
-static struct platform_device *netstar_devices[] __initdata = {
- &netstar_smc91x_device,
-};
-
-static struct omap_uart_config netstar_uart_config __initdata = {
- .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
-};
-
-static struct omap_board_config_kernel netstar_config[] = {
- { OMAP_TAG_UART, &netstar_uart_config },
-};
-
-static void __init netstar_init_irq(void)
-{
- omap1_init_common_hw();
- omap_init_irq();
- omap_gpio_init();
-}
-
-static void __init netstar_init(void)
-{
- /* green LED */
- omap_request_gpio(4);
- omap_set_gpio_direction(4, 0);
- /* smc91x reset */
- omap_request_gpio(7);
- omap_set_gpio_direction(7, 0);
- omap_set_gpio_dataout(7, 1);
- udelay(2); /* wait at least 100ns */
- omap_set_gpio_dataout(7, 0);
- mdelay(50); /* 50ms until PHY ready */
- /* smc91x interrupt pin */
- omap_request_gpio(8);
-
- omap_request_gpio(12);
- omap_request_gpio(13);
- omap_request_gpio(14);
- omap_request_gpio(15);
- set_irq_type(OMAP_GPIO_IRQ(12), IRQT_FALLING);
- set_irq_type(OMAP_GPIO_IRQ(13), IRQT_FALLING);
- set_irq_type(OMAP_GPIO_IRQ(14), IRQT_FALLING);
- set_irq_type(OMAP_GPIO_IRQ(15), IRQT_FALLING);
-
- platform_add_devices(netstar_devices, ARRAY_SIZE(netstar_devices));
-
- /* Switch on green LED */
- omap_set_gpio_dataout(4, 0);
- /* Switch off red LED */
- omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */
- omap_writeb(0x80, OMAP_LPG1_LCR);
-
- omap_board_config = netstar_config;
- omap_board_config_size = ARRAY_SIZE(netstar_config);
- omap_serial_init();
-}
-
-static void __init netstar_map_io(void)
-{
- omap1_map_common_io();
-}
-
-#define MACHINE_PANICED 1
-#define MACHINE_REBOOTING 2
-#define MACHINE_REBOOT 4
-static unsigned long machine_state;
-
-static int panic_event(struct notifier_block *this, unsigned long event,
- void *ptr)
-{
- if (test_and_set_bit(MACHINE_PANICED, &machine_state))
- return NOTIFY_DONE;
-
- /* Switch off green LED */
- omap_set_gpio_dataout(4, 1);
- /* Flash red LED */
- omap_writeb(0x78, OMAP_LPG1_LCR);
- omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */
-
- return NOTIFY_DONE;
-}
-
-static struct notifier_block panic_block = {
- .notifier_call = panic_event,
-};
-
-static int __init netstar_late_init(void)
-{
- /* TODO: Setup front panel switch here */
-
- /* Setup panic notifier */
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
-
- return 0;
-}
-
-postcore_initcall(netstar_late_init);
-
-MACHINE_START(NETSTAR, "NetStar OMAP5910")
- /* Maintainer: Ladislav Michl <michl@2n.cz> */
- .phys_io = 0xfff00000,
- .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
- .boot_params = 0x10000100,
- .map_io = netstar_map_io,
- .init_irq = netstar_init_irq,
- .init_machine = netstar_init,
- .timer = &omap_timer,
-MACHINE_END
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
new file mode 100644
index 0000000000000..02b980d77b12d
--- /dev/null
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -0,0 +1,268 @@
+/*
+ * linux/arch/arm/mach-omap1/board-nokia770.c
+ *
+ * Modified from board-generic.c
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/clk.h>
+
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/usb.h>
+#include <asm/arch/board.h>
+#include <asm/arch/keypad.h>
+#include <asm/arch/common.h>
+#include <asm/arch/dsp_common.h>
+#include <asm/arch/aic23.h>
+#include <asm/arch/gpio.h>
+
+static void __init omap_nokia770_init_irq(void)
+{
+ /* On Nokia 770, the SleepX signal is masked with an
+ * MPUIO line by default. It has to be unmasked for it
+ * to become functional */
+
+ /* SleepX mask direction */
+ omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
+ /* Unmask SleepX signal */
+ omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
+
+ omap1_init_common_hw();
+ omap_init_irq();
+}
+
+static int nokia770_keymap[] = {
+ KEY(0, 1, GROUP_0 | KEY_UP),
+ KEY(0, 2, GROUP_1 | KEY_F5),
+ KEY(1, 0, GROUP_0 | KEY_LEFT),
+ KEY(1, 1, GROUP_0 | KEY_ENTER),
+ KEY(1, 2, GROUP_0 | KEY_RIGHT),
+ KEY(2, 0, GROUP_1 | KEY_ESC),
+ KEY(2, 1, GROUP_0 | KEY_DOWN),
+ KEY(2, 2, GROUP_1 | KEY_F4),
+ KEY(3, 0, GROUP_2 | KEY_F7),
+ KEY(3, 1, GROUP_2 | KEY_F8),
+ KEY(3, 2, GROUP_2 | KEY_F6),
+ 0
+};
+
+static struct resource nokia770_kp_resources[] = {
+ [0] = {
+ .start = INT_KEYBOARD,
+ .end = INT_KEYBOARD,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct omap_kp_platform_data nokia770_kp_data = {
+ .rows = 8,
+ .cols = 8,
+ .keymap = nokia770_keymap
+};
+
+static struct platform_device nokia770_kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &nokia770_kp_data,
+ },
+ .num_resources = ARRAY_SIZE(nokia770_kp_resources),
+ .resource = nokia770_kp_resources,
+};
+
+static struct platform_device *nokia770_devices[] __initdata = {
+ &nokia770_kp_device,
+};
+
+static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
+ .x_max = 0x0fff,
+ .y_max = 0x0fff,
+ .x_plate_ohms = 180,
+ .pressure_max = 255,
+ .debounce_max = 10,
+ .debounce_tol = 3,
+};
+
+static struct spi_board_info nokia770_spi_board_info[] __initdata = {
+ [0] = {
+ .modalias = "lcd_lph8923",
+ .bus_num = 2,
+ .chip_select = 3,
+ .max_speed_hz = 12000000,
+ },
+ [1] = {
+ .modalias = "ads7846",
+ .bus_num = 2,
+ .chip_select = 0,
+ .max_speed_hz = 2500000,
+ .irq = OMAP_GPIO_IRQ(15),
+ .platform_data = &nokia770_ads7846_platform_data,
+ },
+};
+
+
+/* assume no Mini-AB port */
+
+static struct omap_usb_config nokia770_usb_config __initdata = {
+ .otg = 1,
+ .register_host = 1,
+ .register_dev = 1,
+ .hmc_mode = 16,
+ .pins[0] = 6,
+};
+
+static struct omap_mmc_config nokia770_mmc_config __initdata = {
+ .mmc[0] = {
+ .enabled = 0,
+ .wire4 = 0,
+ .wp_pin = -1,
+ .power_pin = -1,
+ .switch_pin = -1,
+ },
+ .mmc[1] = {
+ .enabled = 0,
+ .wire4 = 0,
+ .wp_pin = -1,
+ .power_pin = -1,
+ .switch_pin = -1,
+ },
+};
+
+static struct omap_board_config_kernel nokia770_config[] = {
+ { OMAP_TAG_USB, NULL },
+ { OMAP_TAG_MMC, &nokia770_mmc_config },
+};
+
+/*
+ * audio power control
+ */
+#define HEADPHONE_GPIO 14
+#define AMPLIFIER_CTRL_GPIO 58
+
+static struct clk *dspxor_ck;
+static DECLARE_MUTEX(audio_pwr_sem);
+/*
+ * audio_pwr_state
+ * +--+-------------------------+---------------------------------------+
+ * |-1|down |power-up request -> 0 |
+ * +--+-------------------------+---------------------------------------+
+ * | 0|up |power-down(1) request -> 1 |
+ * | | |power-down(2) request -> (ignore) |
+ * +--+-------------------------+---------------------------------------+
+ * | 1|up, |power-up request -> 0 |
+ * | |received down(1) request |power-down(2) request -> -1 |
+ * +--+-------------------------+---------------------------------------+
+ */
+static int audio_pwr_state = -1;
+
+/*
+ * audio_pwr_up / down should be called under audio_pwr_sem
+ */
+static void nokia770_audio_pwr_up(void)
+{
+ clk_enable(dspxor_ck);
+
+ /* Turn on codec */
+ tlv320aic23_power_up();
+
+ if (omap_get_gpio_datain(HEADPHONE_GPIO))
+ /* HP not connected, turn on amplifier */
+ omap_set_gpio_dataout(AMPLIFIER_CTRL_GPIO, 1);
+ else
+ /* HP connected, do not turn on amplifier */
+ printk("HP connected\n");
+}
+
+static void codec_delayed_power_down(void *arg)
+{
+ down(&audio_pwr_sem);
+ if (audio_pwr_state == -1)
+ tlv320aic23_power_down();
+ clk_disable(dspxor_ck);
+ up(&audio_pwr_sem);
+}
+
+static DECLARE_WORK(codec_power_down_work, codec_delayed_power_down, NULL);
+
+static void nokia770_audio_pwr_down(void)
+{
+ /* Turn off amplifier */
+ omap_set_gpio_dataout(AMPLIFIER_CTRL_GPIO, 0);
+
+ /* Turn off codec: schedule delayed work */
+ schedule_delayed_work(&codec_power_down_work, HZ / 20); /* 50ms */
+}
+
+void nokia770_audio_pwr_up_request(int stage)
+{
+ down(&audio_pwr_sem);
+ if (audio_pwr_state == -1)
+ nokia770_audio_pwr_up();
+ /* force audio_pwr_state = 0, even if it was 1. */
+ audio_pwr_state = 0;
+ up(&audio_pwr_sem);
+}
+
+void nokia770_audio_pwr_down_request(int stage)
+{
+ down(&audio_pwr_sem);
+ switch (stage) {
+ case 1:
+ if (audio_pwr_state == 0)
+ audio_pwr_state = 1;
+ break;
+ case 2:
+ if (audio_pwr_state == 1) {
+ nokia770_audio_pwr_down();
+ audio_pwr_state = -1;
+ }
+ break;
+ }
+ up(&audio_pwr_sem);
+}
+
+static void __init omap_nokia770_init(void)
+{
+ nokia770_config[0].data = &nokia770_usb_config;
+
+ platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
+ spi_register_board_info(nokia770_spi_board_info,
+ ARRAY_SIZE(nokia770_spi_board_info));
+ omap_board_config = nokia770_config;
+ omap_board_config_size = ARRAY_SIZE(nokia770_config);
+ omap_serial_init();
+ omap_dsp_audio_pwr_up_request = nokia770_audio_pwr_up_request;
+ omap_dsp_audio_pwr_down_request = nokia770_audio_pwr_down_request;
+ dspxor_ck = clk_get(0, "dspxor_ck");
+}
+
+static void __init omap_nokia770_map_io(void)
+{
+ omap1_map_common_io();
+}
+
+MACHINE_START(NOKIA770, "Nokia 770")
+ .phys_io = 0xfff00000,
+ .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
+ .boot_params = 0x10000100,
+ .map_io = omap_nokia770_map_io,
+ .init_irq = omap_nokia770_init_irq,
+ .init_machine = omap_nokia770_init,
+ .timer = &omap_timer,
+MACHINE_END
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 543fa136106d8..1160093e8ef67 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -33,6 +33,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/input.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -44,7 +45,24 @@
#include <asm/arch/usb.h>
#include <asm/arch/mux.h>
#include <asm/arch/tc.h>
+#include <asm/arch/keypad.h>
#include <asm/arch/common.h>
+#include <asm/arch/mcbsp.h>
+#include <asm/arch/omap-alsa.h>
+
+static int osk_keymap[] = {
+ KEY(0, 0, KEY_F1),
+ KEY(0, 3, KEY_UP),
+ KEY(1, 1, KEY_LEFTCTRL),
+ KEY(1, 2, KEY_LEFT),
+ KEY(2, 0, KEY_SPACE),
+ KEY(2, 1, KEY_ESC),
+ KEY(2, 2, KEY_DOWN),
+ KEY(3, 2, KEY_ENTER),
+ KEY(3, 3, KEY_RIGHT),
+ 0
+};
+
static struct mtd_partition osk_partitions[] = {
/* bootloader (U-Boot, etc) in first sector */
@@ -133,9 +151,69 @@ static struct platform_device osk5912_cf_device = {
.resource = osk5912_cf_resources,
};
+#define DEFAULT_BITPERSAMPLE 16
+
+static struct omap_mcbsp_reg_cfg mcbsp_regs = {
+ .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
+ .spcr1 = RINTM(3) | RRST,
+ .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
+ RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
+ .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
+ .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
+ XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
+ .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
+ .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
+ .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
+ /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
+ .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
+};
+
+static struct omap_alsa_codec_config alsa_config = {
+ .name = "OSK AIC23",
+ .mcbsp_regs_alsa = &mcbsp_regs,
+ .codec_configure_dev = NULL, // aic23_configure,
+ .codec_set_samplerate = NULL, // aic23_set_samplerate,
+ .codec_clock_setup = NULL, // aic23_clock_setup,
+ .codec_clock_on = NULL, // aic23_clock_on,
+ .codec_clock_off = NULL, // aic23_clock_off,
+ .get_default_samplerate = NULL, // aic23_get_default_samplerate,
+};
+
static struct platform_device osk5912_mcbsp1_device = {
- .name = "omap_mcbsp",
- .id = 1,
+ .name = "omap_alsa_mcbsp",
+ .id = 1,
+ .dev = {
+ .platform_data = &alsa_config,
+ },
+};
+
+static struct resource osk5912_kp_resources[] = {
+ [0] = {
+ .start = INT_KEYBOARD,
+ .end = INT_KEYBOARD,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct omap_kp_platform_data osk_kp_data = {
+ .rows = 8,
+ .cols = 8,
+ .keymap = osk_keymap,
+};
+
+static struct platform_device osk5912_kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &osk_kp_data,
+ },
+ .num_resources = ARRAY_SIZE(osk5912_kp_resources),
+ .resource = osk5912_kp_resources,
+};
+
+static struct platform_device osk5912_lcd_device = {
+ .name = "lcd_osk",
+ .id = -1,
};
static struct platform_device *osk5912_devices[] __initdata = {
@@ -143,6 +221,8 @@ static struct platform_device *osk5912_devices[] __initdata = {
&osk5912_smc91x_device,
&osk5912_cf_device,
&osk5912_mcbsp1_device,
+ &osk5912_kp_device,
+ &osk5912_lcd_device,
};
static void __init osk_init_smc91x(void)
@@ -197,7 +277,6 @@ static struct omap_uart_config osk_uart_config __initdata = {
};
static struct omap_lcd_config osk_lcd_config __initdata = {
- .panel_name = "osk",
.ctrl_name = "internal",
};
@@ -255,8 +334,18 @@ static void __init osk_mistral_init(void)
static void __init osk_mistral_init(void) { }
#endif
+#define EMIFS_CS3_VAL (0x88013141)
+
static void __init osk_init(void)
{
+ /* Workaround for wrong CS3 (NOR flash) timing
+ * There are some U-Boot versions out there which configure
+ * wrong CS3 memory timings. This mainly leads to CRC
+ * or similiar errors if you use NOR flash (e.g. with JFFS2)
+ */
+ if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
+ EMIFS_CCS(3) = EMIFS_CS3_VAL;
+
osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
osk_flash_resource.end += SZ_32M - 1;
platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index e488f72367754..4bc8a62909b9a 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -38,6 +38,15 @@ static void __init omap_generic_init_irq(void)
omap_init_irq();
}
+static struct platform_device palmte_lcd_device = {
+ .name = "lcd_palmte",
+ .id = -1,
+};
+
+static struct platform_device *devices[] __initdata = {
+ &palmte_lcd_device,
+};
+
static struct omap_usb_config palmte_usb_config __initdata = {
.register_dev = 1,
.hmc_mode = 0,
@@ -55,7 +64,6 @@ static struct omap_mmc_config palmte_mmc_config __initdata = {
};
static struct omap_lcd_config palmte_lcd_config __initdata = {
- .panel_name = "palmte",
.ctrl_name = "internal",
};
@@ -69,6 +77,8 @@ static void __init omap_generic_init(void)
{
omap_board_config = palmte_config;
omap_board_config_size = ARRAY_SIZE(palmte_config);
+
+ platform_add_devices(devices, ARRAY_SIZE(devices));
}
static void __init omap_generic_map_io(void)
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index 3913a3cc0ce6c..64b45d8ae357e 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -16,7 +16,9 @@
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
+#include <linux/input.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -28,9 +30,44 @@
#include <asm/arch/gpio.h>
#include <asm/arch/mux.h>
#include <asm/arch/fpga.h>
+#include <asm/arch/keypad.h>
#include <asm/arch/common.h>
#include <asm/arch/board.h>
+static int p2_keymap[] = {
+ KEY(0,0,KEY_UP),
+ KEY(0,1,KEY_RIGHT),
+ KEY(0,2,KEY_LEFT),
+ KEY(0,3,KEY_DOWN),
+ KEY(0,4,KEY_CENTER),
+ KEY(0,5,KEY_0_5),
+ KEY(1,0,KEY_SOFT2),
+ KEY(1,1,KEY_SEND),
+ KEY(1,2,KEY_END),
+ KEY(1,3,KEY_VOLUMEDOWN),
+ KEY(1,4,KEY_VOLUMEUP),
+ KEY(1,5,KEY_RECORD),
+ KEY(2,0,KEY_SOFT1),
+ KEY(2,1,KEY_3),
+ KEY(2,2,KEY_6),
+ KEY(2,3,KEY_9),
+ KEY(2,4,KEY_SHARP),
+ KEY(2,5,KEY_2_5),
+ KEY(3,0,KEY_BACK),
+ KEY(3,1,KEY_2),
+ KEY(3,2,KEY_5),
+ KEY(3,3,KEY_8),
+ KEY(3,4,KEY_0),
+ KEY(3,5,KEY_HEADSETHOOK),
+ KEY(4,0,KEY_HOME),
+ KEY(4,1,KEY_1),
+ KEY(4,2,KEY_4),
+ KEY(4,3,KEY_7),
+ KEY(4,4,KEY_STAR),
+ KEY(4,5,KEY_POWER),
+ 0
+};
+
static struct resource smc91x_resources[] = {
[0] = {
.start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
@@ -44,7 +81,7 @@ static struct resource smc91x_resources[] = {
},
};
-static struct mtd_partition p2_partitions[] = {
+static struct mtd_partition nor_partitions[] = {
/* bootloader (U-Boot, etc) in first sector */
{
.name = "bootloader",
@@ -75,27 +112,47 @@ static struct mtd_partition p2_partitions[] = {
},
};
-static struct flash_platform_data p2_flash_data = {
+static struct flash_platform_data nor_data = {
.map_name = "cfi_probe",
.width = 2,
- .parts = p2_partitions,
- .nr_parts = ARRAY_SIZE(p2_partitions),
+ .parts = nor_partitions,
+ .nr_parts = ARRAY_SIZE(nor_partitions),
};
-static struct resource p2_flash_resource = {
+static struct resource nor_resource = {
.start = OMAP_CS0_PHYS,
.end = OMAP_CS0_PHYS + SZ_32M - 1,
.flags = IORESOURCE_MEM,
};
-static struct platform_device p2_flash_device = {
+static struct platform_device nor_device = {
.name = "omapflash",
.id = 0,
.dev = {
- .platform_data = &p2_flash_data,
+ .platform_data = &nor_data,
+ },
+ .num_resources = 1,
+ .resource = &nor_resource,
+};
+
+static struct nand_platform_data nand_data = {
+ .options = NAND_SAMSUNG_LP_OPTIONS,
+};
+
+static struct resource nand_resource = {
+ .start = OMAP_CS3_PHYS,
+ .end = OMAP_CS3_PHYS + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device nand_device = {
+ .name = "omapnand",
+ .id = 0,
+ .dev = {
+ .platform_data = &nand_data,
},
.num_resources = 1,
- .resource = &p2_flash_resource,
+ .resource = &nand_resource,
};
static struct platform_device smc91x_device = {
@@ -105,17 +162,55 @@ static struct platform_device smc91x_device = {
.resource = smc91x_resources,
};
+static struct resource kp_resources[] = {
+ [0] = {
+ .start = INT_730_MPUIO_KEYPAD,
+ .end = INT_730_MPUIO_KEYPAD,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct omap_kp_platform_data kp_data = {
+ .rows = 8,
+ .cols = 8,
+ .keymap = p2_keymap,
+};
+
+static struct platform_device kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &kp_data,
+ },
+ .num_resources = ARRAY_SIZE(kp_resources),
+ .resource = kp_resources,
+};
+
+static struct platform_device lcd_device = {
+ .name = "lcd_p2",
+ .id = -1,
+};
+
static struct platform_device *devices[] __initdata = {
- &p2_flash_device,
+ &nor_device,
+ &nand_device,
&smc91x_device,
+ &kp_device,
+ &lcd_device,
};
+#define P2_NAND_RB_GPIO_PIN 62
+
+static int nand_dev_ready(struct nand_platform_data *data)
+{
+ return omap_get_gpio_datain(P2_NAND_RB_GPIO_PIN);
+}
+
static struct omap_uart_config perseus2_uart_config __initdata = {
.enabled_uarts = ((1 << 0) | (1 << 1)),
};
static struct omap_lcd_config perseus2_lcd_config __initdata = {
- .panel_name = "p2",
.ctrl_name = "internal",
};
@@ -126,7 +221,13 @@ static struct omap_board_config_kernel perseus2_config[] = {
static void __init omap_perseus2_init(void)
{
- (void) platform_add_devices(devices, ARRAY_SIZE(devices));
+ if (!(omap_request_gpio(P2_NAND_RB_GPIO_PIN)))
+ nand_data.dev_ready = nand_dev_ready;
+
+ omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
+ omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
+
+ platform_add_devices(devices, ARRAY_SIZE(devices));
omap_board_config = perseus2_config;
omap_board_config_size = ARRAY_SIZE(perseus2_config);
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index 52e4a9d69642b..447a586eb3345 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -155,9 +155,9 @@ static struct omap_uart_config voiceblue_uart_config __initdata = {
};
static struct omap_board_config_kernel voiceblue_config[] = {
- { OMAP_TAG_USB, &voiceblue_usb_config },
- { OMAP_TAG_MMC, &voiceblue_mmc_config },
- { OMAP_TAG_UART, &voiceblue_uart_config },
+ { OMAP_TAG_USB, &voiceblue_usb_config },
+ { OMAP_TAG_MMC, &voiceblue_mmc_config },
+ { OMAP_TAG_UART, &voiceblue_uart_config },
};
static void __init voiceblue_init_irq(void)
@@ -235,7 +235,7 @@ static struct notifier_block panic_block = {
static int __init voiceblue_setup(void)
{
/* Setup panic notifier */
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ notifier_chain_register(&panic_notifier_list, &panic_block);
return 0;
}
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 75110ba104246..619db18144ead 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -345,7 +345,7 @@ static unsigned calc_ext_dsor(unsigned long rate)
*/
for (dsor = 2; dsor < 96; ++dsor) {
if ((dsor & 1) && dsor > 8)
- continue;
+ continue;
if (rate >= 96000000 / dsor)
break;
}
@@ -687,6 +687,11 @@ int __init omap1_clk_init(void)
clk_register(*clkp);
continue;
}
+
+ if (((*clkp)->flags &CLOCK_IN_OMAP310) && cpu_is_omap310()) {
+ clk_register(*clkp);
+ continue;
+ }
}
info = omap_get_config(OMAP_TAG_CLOCK, struct omap_clock_config);
@@ -784,7 +789,7 @@ int __init omap1_clk_init(void)
clk_enable(&armxor_ck.clk);
clk_enable(&armtim_ck.clk); /* This should be done by timer code */
- if (cpu_is_omap1510())
+ if (cpu_is_omap15xx())
clk_enable(&arm_gpio_ck);
return 0;
diff --git a/arch/arm/mach-omap1/clock.h b/arch/arm/mach-omap1/clock.h
index 4f18d1b94449b..b7c68819c4e7e 100644
--- a/arch/arm/mach-omap1/clock.h
+++ b/arch/arm/mach-omap1/clock.h
@@ -151,7 +151,7 @@ static struct clk ck_ref = {
.name = "ck_ref",
.rate = 12000000,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- ALWAYS_ENABLED,
+ CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
.enable = &omap1_clk_enable_generic,
.disable = &omap1_clk_disable_generic,
};
@@ -160,7 +160,7 @@ static struct clk ck_dpll1 = {
.name = "ck_dpll1",
.parent = &ck_ref,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- RATE_PROPAGATES | ALWAYS_ENABLED,
+ CLOCK_IN_OMAP310 | RATE_PROPAGATES | ALWAYS_ENABLED,
.enable = &omap1_clk_enable_generic,
.disable = &omap1_clk_disable_generic,
};
@@ -183,7 +183,8 @@ static struct clk arm_ck = {
.name = "arm_ck",
.parent = &ck_dpll1,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- RATE_CKCTL | RATE_PROPAGATES | ALWAYS_ENABLED,
+ CLOCK_IN_OMAP310 | RATE_CKCTL | RATE_PROPAGATES |
+ ALWAYS_ENABLED,
.rate_offset = CKCTL_ARMDIV_OFFSET,
.recalc = &omap1_ckctl_recalc,
.enable = &omap1_clk_enable_generic,
@@ -195,7 +196,8 @@ static struct arm_idlect1_clk armper_ck = {
.name = "armper_ck",
.parent = &ck_dpll1,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- RATE_CKCTL | CLOCK_IDLE_CONTROL,
+ CLOCK_IN_OMAP310 | RATE_CKCTL |
+ CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_PERCK,
.rate_offset = CKCTL_PERDIV_OFFSET,
@@ -209,7 +211,7 @@ static struct arm_idlect1_clk armper_ck = {
static struct clk arm_gpio_ck = {
.name = "arm_gpio_ck",
.parent = &ck_dpll1,
- .flags = CLOCK_IN_OMAP1510,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_GPIOCK,
.recalc = &followparent_recalc,
@@ -222,7 +224,7 @@ static struct arm_idlect1_clk armxor_ck = {
.name = "armxor_ck",
.parent = &ck_ref,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- CLOCK_IDLE_CONTROL,
+ CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_XORPCK,
.recalc = &followparent_recalc,
@@ -237,7 +239,7 @@ static struct arm_idlect1_clk armtim_ck = {
.name = "armtim_ck",
.parent = &ck_ref,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- CLOCK_IDLE_CONTROL,
+ CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_TIMCK,
.recalc = &followparent_recalc,
@@ -252,7 +254,7 @@ static struct arm_idlect1_clk armwdt_ck = {
.name = "armwdt_ck",
.parent = &ck_ref,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- CLOCK_IDLE_CONTROL,
+ CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_WDTCK,
.recalc = &omap1_watchdog_recalc,
@@ -344,9 +346,9 @@ static struct arm_idlect1_clk tc_ck = {
.name = "tc_ck",
.parent = &ck_dpll1,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- CLOCK_IN_OMAP730 | RATE_CKCTL |
- RATE_PROPAGATES | ALWAYS_ENABLED |
- CLOCK_IDLE_CONTROL,
+ CLOCK_IN_OMAP730 | CLOCK_IN_OMAP310 |
+ RATE_CKCTL | RATE_PROPAGATES |
+ ALWAYS_ENABLED | CLOCK_IDLE_CONTROL,
.rate_offset = CKCTL_TCDIV_OFFSET,
.recalc = &omap1_ckctl_recalc,
.enable = &omap1_clk_enable_generic,
@@ -358,7 +360,8 @@ static struct arm_idlect1_clk tc_ck = {
static struct clk arminth_ck1510 = {
.name = "arminth_ck",
.parent = &tc_ck.clk,
- .flags = CLOCK_IN_OMAP1510 | ALWAYS_ENABLED,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
+ ALWAYS_ENABLED,
.recalc = &followparent_recalc,
/* Note: On 1510 the frequency follows TC_CK
*
@@ -372,7 +375,8 @@ static struct clk tipb_ck = {
/* No-idle controlled by "tc_ck" */
.name = "tibp_ck",
.parent = &tc_ck.clk,
- .flags = CLOCK_IN_OMAP1510 | ALWAYS_ENABLED,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
+ ALWAYS_ENABLED,
.recalc = &followparent_recalc,
.enable = &omap1_clk_enable_generic,
.disable = &omap1_clk_disable_generic,
@@ -417,7 +421,7 @@ static struct clk dma_ck = {
.name = "dma_ck",
.parent = &tc_ck.clk,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- ALWAYS_ENABLED,
+ CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
.recalc = &followparent_recalc,
.enable = &omap1_clk_enable_generic,
.disable = &omap1_clk_disable_generic,
@@ -437,7 +441,7 @@ static struct arm_idlect1_clk api_ck = {
.name = "api_ck",
.parent = &tc_ck.clk,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- CLOCK_IDLE_CONTROL,
+ CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_APICK,
.recalc = &followparent_recalc,
@@ -451,7 +455,8 @@ static struct arm_idlect1_clk lb_ck = {
.clk = {
.name = "lb_ck",
.parent = &tc_ck.clk,
- .flags = CLOCK_IN_OMAP1510 | CLOCK_IDLE_CONTROL,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
+ CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_LBCK,
.recalc = &followparent_recalc,
@@ -495,8 +500,8 @@ static struct arm_idlect1_clk lcd_ck_1510 = {
.clk = {
.name = "lcd_ck",
.parent = &ck_dpll1,
- .flags = CLOCK_IN_OMAP1510 | RATE_CKCTL |
- CLOCK_IDLE_CONTROL,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
+ RATE_CKCTL | CLOCK_IDLE_CONTROL,
.enable_reg = (void __iomem *)ARM_IDLECT2,
.enable_bit = EN_LCDCK,
.rate_offset = CKCTL_LCDDIV_OFFSET,
@@ -512,8 +517,9 @@ static struct clk uart1_1510 = {
/* Direct from ULPD, no real parent */
.parent = &armper_ck.clk,
.rate = 12000000,
- .flags = CLOCK_IN_OMAP1510 | ENABLE_REG_32BIT |
- ALWAYS_ENABLED | CLOCK_NO_IDLE_PARENT,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
+ ENABLE_REG_32BIT | ALWAYS_ENABLED |
+ CLOCK_NO_IDLE_PARENT,
.enable_reg = (void __iomem *)MOD_CONF_CTRL_0,
.enable_bit = 29, /* Chooses between 12MHz and 48MHz */
.set_rate = &omap1_set_uart_rate,
@@ -544,8 +550,8 @@ static struct clk uart2_ck = {
.parent = &armper_ck.clk,
.rate = 12000000,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- ENABLE_REG_32BIT | ALWAYS_ENABLED |
- CLOCK_NO_IDLE_PARENT,
+ CLOCK_IN_OMAP310 | ENABLE_REG_32BIT |
+ ALWAYS_ENABLED | CLOCK_NO_IDLE_PARENT,
.enable_reg = (void __iomem *)MOD_CONF_CTRL_0,
.enable_bit = 30, /* Chooses between 12MHz and 48MHz */
.set_rate = &omap1_set_uart_rate,
@@ -559,8 +565,9 @@ static struct clk uart3_1510 = {
/* Direct from ULPD, no real parent */
.parent = &armper_ck.clk,
.rate = 12000000,
- .flags = CLOCK_IN_OMAP1510 | ENABLE_REG_32BIT |
- ALWAYS_ENABLED | CLOCK_NO_IDLE_PARENT,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
+ ENABLE_REG_32BIT | ALWAYS_ENABLED |
+ CLOCK_NO_IDLE_PARENT,
.enable_reg = (void __iomem *)MOD_CONF_CTRL_0,
.enable_bit = 31, /* Chooses between 12MHz and 48MHz */
.set_rate = &omap1_set_uart_rate,
@@ -590,7 +597,7 @@ static struct clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
/* Direct from ULPD, no parent */
.rate = 6000000,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- RATE_FIXED | ENABLE_REG_32BIT,
+ CLOCK_IN_OMAP310 | RATE_FIXED | ENABLE_REG_32BIT,
.enable_reg = (void __iomem *)ULPD_CLOCK_CTRL,
.enable_bit = USB_MCLK_EN_BIT,
.enable = &omap1_clk_enable_generic,
@@ -601,7 +608,7 @@ static struct clk usb_hhc_ck1510 = {
.name = "usb_hhc_ck",
/* Direct from ULPD, no parent */
.rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
- .flags = CLOCK_IN_OMAP1510 |
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
RATE_FIXED | ENABLE_REG_32BIT,
.enable_reg = (void __iomem *)MOD_CONF_CTRL_0,
.enable_bit = USB_HOST_HHC_UHOST_EN,
@@ -637,7 +644,9 @@ static struct clk mclk_1510 = {
.name = "mclk",
/* Direct from ULPD, no parent. May be enabled by ext hardware. */
.rate = 12000000,
- .flags = CLOCK_IN_OMAP1510 | RATE_FIXED,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | RATE_FIXED,
+ .enable_reg = (void __iomem *)SOFT_REQ_REG,
+ .enable_bit = 6,
.enable = &omap1_clk_enable_generic,
.disable = &omap1_clk_disable_generic,
};
@@ -659,7 +668,7 @@ static struct clk bclk_1510 = {
.name = "bclk",
/* Direct from ULPD, no parent. May be enabled by ext hardware. */
.rate = 12000000,
- .flags = CLOCK_IN_OMAP1510 | RATE_FIXED,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | RATE_FIXED,
.enable = &omap1_clk_enable_generic,
.disable = &omap1_clk_disable_generic,
};
@@ -678,12 +687,14 @@ static struct clk bclk_16xx = {
};
static struct clk mmc1_ck = {
- .name = "mmc1_ck",
+ .name = "mmc_ck",
+ .id = 1,
/* Functional clock is direct from ULPD, interface clock is ARMPER */
.parent = &armper_ck.clk,
.rate = 48000000,
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- RATE_FIXED | ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
+ CLOCK_IN_OMAP310 | RATE_FIXED | ENABLE_REG_32BIT |
+ CLOCK_NO_IDLE_PARENT,
.enable_reg = (void __iomem *)MOD_CONF_CTRL_0,
.enable_bit = 23,
.enable = &omap1_clk_enable_generic,
@@ -691,7 +702,8 @@ static struct clk mmc1_ck = {
};
static struct clk mmc2_ck = {
- .name = "mmc2_ck",
+ .name = "mmc_ck",
+ .id = 2,
/* Functional clock is direct from ULPD, interface clock is ARMPER */
.parent = &armper_ck.clk,
.rate = 48000000,
@@ -706,7 +718,7 @@ static struct clk mmc2_ck = {
static struct clk virtual_ck_mpu = {
.name = "mpu",
.flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
- VIRTUAL_CLOCK | ALWAYS_ENABLED,
+ CLOCK_IN_OMAP310 | VIRTUAL_CLOCK | ALWAYS_ENABLED,
.parent = &arm_ck, /* Is smarter alias for */
.recalc = &followparent_recalc,
.set_rate = &omap1_select_table_rate,
@@ -715,6 +727,20 @@ static struct clk virtual_ck_mpu = {
.disable = &omap1_clk_disable_generic,
};
+/* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
+remains active during MPU idle whenever this is enabled */
+static struct clk i2c_fck = {
+ .name = "i2c_fck",
+ .id = 1,
+ .flags = CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+ VIRTUAL_CLOCK | CLOCK_NO_IDLE_PARENT |
+ ALWAYS_ENABLED,
+ .parent = &armxor_ck.clk,
+ .recalc = &followparent_recalc,
+ .enable = &omap1_clk_enable_generic,
+ .disable = &omap1_clk_disable_generic,
+};
+
static struct clk * onchip_clks[] = {
/* non-ULPD clocks */
&ck_ref,
@@ -763,6 +789,7 @@ static struct clk * onchip_clks[] = {
&mmc2_ck,
/* Virtual clocks */
&virtual_ck_mpu,
+ &i2c_fck,
};
#endif
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index ecbc47514adc6..847329cafc5c0 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -25,10 +25,6 @@
#include <asm/arch/mux.h>
#include <asm/arch/gpio.h>
-extern void omap_nop_release(struct device *dev);
-
-/*-------------------------------------------------------------------------*/
-
#if defined(CONFIG_OMAP1610_IR) || defined(CONFIG_OMAP161O_IR_MODULE)
static u64 irda_dmamask = 0xffffffff;
@@ -37,7 +33,6 @@ static struct platform_device omap1610ir_device = {
.name = "omap1610-ir",
.id = -1,
.dev = {
- .release = omap_nop_release,
.dma_mask = &irda_dmamask,
},
};
@@ -84,9 +79,6 @@ static struct resource rtc_resources[] = {
static struct platform_device omap_rtc_device = {
.name = "omap_rtc",
.id = -1,
- .dev = {
- .release = omap_nop_release,
- },
.num_resources = ARRAY_SIZE(rtc_resources),
.resource = rtc_resources,
};
@@ -99,6 +91,42 @@ static void omap_init_rtc(void)
static inline void omap_init_rtc(void) {}
#endif
+#if defined(CONFIG_OMAP_STI)
+
+#define OMAP1_STI_BASE IO_ADDRESS(0xfffea000)
+#define OMAP1_STI_CHANNEL_BASE (OMAP1_STI_BASE + 0x400)
+
+static struct resource sti_resources[] = {
+ {
+ .start = OMAP1_STI_BASE,
+ .end = OMAP1_STI_BASE + SZ_1K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = OMAP1_STI_CHANNEL_BASE,
+ .end = OMAP1_STI_CHANNEL_BASE + SZ_1K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = INT_1610_STI,
+ .flags = IORESOURCE_IRQ,
+ }
+};
+
+static struct platform_device sti_device = {
+ .name = "sti",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(sti_resources),
+ .resource = sti_resources,
+};
+
+static inline void omap_init_sti(void)
+{
+ platform_device_register(&sti_device);
+}
+#else
+static inline void omap_init_sti(void) {}
+#endif
/*-------------------------------------------------------------------------*/
@@ -129,6 +157,7 @@ static int __init omap1_init_devices(void)
*/
omap_init_irda();
omap_init_rtc();
+ omap_init_sti();
return 0;
}
diff --git a/arch/arm/mach-omap1/io.c b/arch/arm/mach-omap1/io.c
index 82d556be79c51..be3a2a4ee2b8c 100644
--- a/arch/arm/mach-omap1/io.c
+++ b/arch/arm/mach-omap1/io.c
@@ -18,6 +18,7 @@
#include <asm/io.h>
#include <asm/arch/mux.h>
#include <asm/arch/tc.h>
+#include <asm/arch/omapfb.h>
extern int omap1_clk_init(void);
extern void omap_check_revision(void);
@@ -110,7 +111,7 @@ void __init omap1_map_common_io(void)
}
#endif
#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap1510()) {
+ if (cpu_is_omap15xx()) {
iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc));
}
#endif
@@ -121,6 +122,7 @@ void __init omap1_map_common_io(void)
#endif
omap_sram_init();
+ omapfb_reserve_mem();
}
/*
diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c
index ed65a7d2e941c..a0431c00fa813 100644
--- a/arch/arm/mach-omap1/irq.c
+++ b/arch/arm/mach-omap1/irq.c
@@ -60,7 +60,7 @@ struct omap_irq_bank {
unsigned long wake_enable;
};
-static unsigned int irq_bank_count = 0;
+static unsigned int irq_bank_count;
static struct omap_irq_bank *irq_banks;
static inline unsigned int irq_bank_readl(int bank, int offset)
@@ -142,28 +142,28 @@ static void omap_irq_set_cfg(int irq, int fiq, int priority, int trigger)
#ifdef CONFIG_ARCH_OMAP730
static struct omap_irq_bank omap730_irq_banks[] = {
- { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3f8e22f },
- { .base_reg = OMAP_IH2_BASE, .trigger_map = 0xfdb9c1f2 },
+ { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3f8e22f },
+ { .base_reg = OMAP_IH2_BASE, .trigger_map = 0xfdb9c1f2 },
{ .base_reg = OMAP_IH2_BASE + 0x100, .trigger_map = 0x800040f3 },
};
#endif
#ifdef CONFIG_ARCH_OMAP15XX
static struct omap_irq_bank omap1510_irq_banks[] = {
- { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3febfff },
- { .base_reg = OMAP_IH2_BASE, .trigger_map = 0xffbfffed },
+ { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3febfff },
+ { .base_reg = OMAP_IH2_BASE, .trigger_map = 0xffbfffed },
};
static struct omap_irq_bank omap310_irq_banks[] = {
- { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3faefc3 },
- { .base_reg = OMAP_IH2_BASE, .trigger_map = 0x65b3c061 },
+ { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3faefc3 },
+ { .base_reg = OMAP_IH2_BASE, .trigger_map = 0x65b3c061 },
};
#endif
#if defined(CONFIG_ARCH_OMAP16XX)
static struct omap_irq_bank omap1610_irq_banks[] = {
- { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3fefe8f },
- { .base_reg = OMAP_IH2_BASE, .trigger_map = 0xfdb7c1fd },
+ { .base_reg = OMAP_IH1_BASE, .trigger_map = 0xb3fefe8f },
+ { .base_reg = OMAP_IH2_BASE, .trigger_map = 0xfdb7c1fd },
{ .base_reg = OMAP_IH2_BASE + 0x100, .trigger_map = 0xffffb7ff },
{ .base_reg = OMAP_IH2_BASE + 0x200, .trigger_map = 0xffffffff },
};
diff --git a/arch/arm/mach-omap1/mux.c b/arch/arm/mach-omap1/mux.c
index d4b8d624e7424..10fe0b3efcace 100644
--- a/arch/arm/mach-omap1/mux.c
+++ b/arch/arm/mach-omap1/mux.c
@@ -35,16 +35,20 @@
#ifdef CONFIG_ARCH_OMAP730
struct pin_config __initdata_or_module omap730_pins[] = {
-MUX_CFG_730("E2_730_KBR0", 12, 21, 0, 0, 20, 1, NA, 0, 0)
-MUX_CFG_730("J7_730_KBR1", 12, 25, 0, 0, 24, 1, NA, 0, 0)
-MUX_CFG_730("E1_730_KBR2", 12, 29, 0, 0, 28, 1, NA, 0, 0)
-MUX_CFG_730("F3_730_KBR3", 13, 1, 0, 0, 0, 1, NA, 0, 0)
-MUX_CFG_730("D2_730_KBR4", 13, 5, 0, 0, 4, 1, NA, 0, 0)
-MUX_CFG_730("C2_730_KBC0", 13, 9, 0, 0, 8, 1, NA, 0, 0)
-MUX_CFG_730("D3_730_KBC1", 13, 13, 0, 0, 12, 1, NA, 0, 0)
-MUX_CFG_730("E4_730_KBC2", 13, 17, 0, 0, 16, 1, NA, 0, 0)
-MUX_CFG_730("F4_730_KBC3", 13, 21, 0, 0, 20, 1, NA, 0, 0)
-MUX_CFG_730("E3_730_KBC4", 13, 25, 0, 0, 24, 1, NA, 0, 0)
+MUX_CFG_730("E2_730_KBR0", 12, 21, 0, 20, 1, 0)
+MUX_CFG_730("J7_730_KBR1", 12, 25, 0, 24, 1, 0)
+MUX_CFG_730("E1_730_KBR2", 12, 29, 0, 28, 1, 0)
+MUX_CFG_730("F3_730_KBR3", 13, 1, 0, 0, 1, 0)
+MUX_CFG_730("D2_730_KBR4", 13, 5, 0, 4, 1, 0)
+MUX_CFG_730("C2_730_KBC0", 13, 9, 0, 8, 1, 0)
+MUX_CFG_730("D3_730_KBC1", 13, 13, 0, 12, 1, 0)
+MUX_CFG_730("E4_730_KBC2", 13, 17, 0, 16, 1, 0)
+MUX_CFG_730("F4_730_KBC3", 13, 21, 0, 20, 1, 0)
+MUX_CFG_730("E3_730_KBC4", 13, 25, 0, 24, 1, 0)
+
+MUX_CFG_730("AA17_730_USB_DM", 2, 21, 0, 20, 0, 0)
+MUX_CFG_730("W16_730_USB_PU_EN", 2, 25, 0, 24, 0, 0)
+MUX_CFG_730("W17_730_USB_VBUSI", 2, 29, 0, 28, 0, 0)
};
#endif
@@ -73,8 +77,8 @@ MUX_CFG("UART3_BCLK", A, 0, 0, 2, 6, 0, NA, 0, 0)
MUX_CFG("Y15_1610_UART3_RTS", A, 0, 1, 2, 6, 0, NA, 0, 0)
/* PWT & PWL, conflicts with UART3 */
-MUX_CFG("PWT", 6, 0, 2, 0, 30, 0, NA, 0, 0)
-MUX_CFG("PWL", 6, 3, 1, 0, 31, 1, NA, 0, 0)
+MUX_CFG("PWT", 6, 0, 2, 0, 30, 0, NA, 0, 0)
+MUX_CFG("PWL", 6, 3, 1, 0, 31, 1, NA, 0, 0)
/* USB internal master generic */
MUX_CFG("R18_USB_VBUS", 7, 9, 2, 1, 11, 0, NA, 0, 1)
@@ -151,7 +155,7 @@ MUX_CFG("MCBSP3_CLKX", 9, 3, 1, 1, 29, 0, NA, 0, 1)
/* Misc ballouts */
MUX_CFG("BALLOUT_V8_ARMIO3", B, 18, 0, 2, 25, 1, NA, 0, 1)
-MUX_CFG("N20_HDQ", 6, 18, 1, 1, 4, 0, 1, 4, 0)
+MUX_CFG("N20_HDQ", 6, 18, 1, 1, 4, 0, 1, 4, 0)
/* OMAP-1610 MMC2 */
MUX_CFG("W8_1610_MMC2_DAT0", B, 21, 6, 2, 23, 1, 2, 1, 1)
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
new file mode 100644
index 0000000000000..ddf6b07dc9c78
--- /dev/null
+++ b/arch/arm/mach-omap1/pm.c
@@ -0,0 +1,770 @@
+/*
+ * linux/arch/arm/mach-omap1/pm.c
+ *
+ * OMAP Power Management Routines
+ *
+ * Original code for the SA11x0:
+ * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
+ *
+ * Modified for the PXA250 by Nicolas Pitre:
+ * Copyright (c) 2002 Monta Vista Software, Inc.
+ *
+ * Modified for the OMAP1510 by David Singleton:
+ * Copyright (c) 2002 Monta Vista Software, Inc.
+ *
+ * Cleanup 2004 for OMAP1510/1610 by Dirk Behme <dirk.behme@de.bosch.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.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * 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 <linux/pm.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+#include <linux/pm.h>
+#include <linux/interrupt.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/atomic.h>
+#include <asm/mach/time.h>
+#include <asm/mach/irq.h>
+#include <asm/mach-types.h>
+
+#include <asm/arch/irqs.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/sram.h>
+#include <asm/arch/tc.h>
+#include <asm/arch/pm.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/tps65010.h>
+#include <asm/arch/dma.h>
+#include <asm/arch/dsp_common.h>
+#include <asm/arch/dmtimer.h>
+
+static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE];
+static unsigned short dsp_sleep_save[DSP_SLEEP_SAVE_SIZE];
+static unsigned short ulpd_sleep_save[ULPD_SLEEP_SAVE_SIZE];
+static unsigned int mpui730_sleep_save[MPUI730_SLEEP_SAVE_SIZE];
+static unsigned int mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_SIZE];
+static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
+
+static unsigned short enable_dyn_sleep = 1;
+
+static ssize_t omap_pm_sleep_while_idle_show(struct subsystem * subsys, char *buf)
+{
+ return sprintf(buf, "%hu\n", enable_dyn_sleep);
+}
+
+static ssize_t omap_pm_sleep_while_idle_store(struct subsystem * subsys,
+ const char * buf,
+ size_t n)
+{
+ unsigned short value;
+ if (sscanf(buf, "%hu", &value) != 1 ||
+ (value != 0 && value != 1)) {
+ printk(KERN_ERR "idle_sleep_store: Invalid value\n");
+ return -EINVAL;
+ }
+ enable_dyn_sleep = value;
+ return n;
+}
+
+static struct subsys_attribute sleep_while_idle_attr = {
+ .attr = {
+ .name = __stringify(sleep_while_idle),
+ .mode = 0644,
+ },
+ .show = omap_pm_sleep_while_idle_show,
+ .store = omap_pm_sleep_while_idle_store,
+};
+
+extern struct subsystem power_subsys;
+static void (*omap_sram_idle)(void) = NULL;
+static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
+
+/*
+ * Let's power down on idle, but only if we are really
+ * idle, because once we start down the path of
+ * going idle we continue to do idle even if we get
+ * a clock tick interrupt . .
+ */
+void omap_pm_idle(void)
+{
+ extern __u32 arm_idlect1_mask;
+ __u32 use_idlect1 = arm_idlect1_mask;
+#ifndef CONFIG_OMAP_MPU_TIMER
+ int do_sleep;
+#endif
+
+ local_irq_disable();
+ local_fiq_disable();
+ if (need_resched()) {
+ local_fiq_enable();
+ local_irq_enable();
+ return;
+ }
+
+ /*
+ * Since an interrupt may set up a timer, we don't want to
+ * reprogram the hardware timer with interrupts enabled.
+ * Re-enable interrupts only after returning from idle.
+ */
+ timer_dyn_reprogram();
+
+#ifdef CONFIG_OMAP_MPU_TIMER
+#warning Enable 32kHz OS timer in order to allow sleep states in idle
+ use_idlect1 = use_idlect1 & ~(1 << 9);
+#else
+
+ do_sleep = 0;
+ while (enable_dyn_sleep) {
+
+#ifdef CONFIG_CBUS_TAHVO_USB
+ extern int vbus_active;
+ /* Clock requirements? */
+ if (vbus_active)
+ break;
+#endif
+ do_sleep = 1;
+ break;
+ }
+
+#ifdef CONFIG_OMAP_DM_TIMER
+ use_idlect1 = omap_dm_timer_modify_idlect_mask(use_idlect1);
+#endif
+
+ if (omap_dma_running()) {
+ use_idlect1 &= ~(1 << 6);
+ if (omap_lcd_dma_ext_running())
+ use_idlect1 &= ~(1 << 12);
+ }
+
+ /* We should be able to remove the do_sleep variable and multiple
+ * tests above as soon as drivers, timer and DMA code have been fixed.
+ * Even the sleep block count should become obsolete. */
+ if ((use_idlect1 != ~0) || !do_sleep) {
+
+ __u32 saved_idlect1 = omap_readl(ARM_IDLECT1);
+ if (cpu_is_omap15xx())
+ use_idlect1 &= OMAP1510_BIG_SLEEP_REQUEST;
+ else
+ use_idlect1 &= OMAP1610_IDLECT1_SLEEP_VAL;
+ omap_writel(use_idlect1, ARM_IDLECT1);
+ __asm__ volatile ("mcr p15, 0, r0, c7, c0, 4");
+ omap_writel(saved_idlect1, ARM_IDLECT1);
+
+ local_fiq_enable();
+ local_irq_enable();
+ return;
+ }
+ omap_sram_suspend(omap_readl(ARM_IDLECT1),
+ omap_readl(ARM_IDLECT2));
+#endif
+
+ local_fiq_enable();
+ local_irq_enable();
+}
+
+/*
+ * Configuration of the wakeup event is board specific. For the
+ * moment we put it into this helper function. Later it may move
+ * to board specific files.
+ */
+static void omap_pm_wakeup_setup(void)
+{
+ u32 level1_wake = 0;
+ u32 level2_wake = OMAP_IRQ_BIT(INT_UART2);
+
+ /*
+ * Turn off all interrupts except GPIO bank 1, L1-2nd level cascade,
+ * and the L2 wakeup interrupts: keypad and UART2. Note that the
+ * drivers must still separately call omap_set_gpio_wakeup() to
+ * wake up to a GPIO interrupt.
+ */
+ if (cpu_is_omap730())
+ level1_wake = OMAP_IRQ_BIT(INT_730_GPIO_BANK1) |
+ OMAP_IRQ_BIT(INT_730_IH2_IRQ);
+ else if (cpu_is_omap15xx())
+ level1_wake = OMAP_IRQ_BIT(INT_GPIO_BANK1) |
+ OMAP_IRQ_BIT(INT_1510_IH2_IRQ);
+ else if (cpu_is_omap16xx())
+ level1_wake = OMAP_IRQ_BIT(INT_GPIO_BANK1) |
+ OMAP_IRQ_BIT(INT_1610_IH2_IRQ);
+
+ omap_writel(~level1_wake, OMAP_IH1_MIR);
+
+ if (cpu_is_omap730()) {
+ omap_writel(~level2_wake, OMAP_IH2_0_MIR);
+ omap_writel(~(OMAP_IRQ_BIT(INT_730_WAKE_UP_REQ) |
+ OMAP_IRQ_BIT(INT_730_MPUIO_KEYPAD)),
+ OMAP_IH2_1_MIR);
+ } else if (cpu_is_omap15xx()) {
+ level2_wake |= OMAP_IRQ_BIT(INT_KEYBOARD);
+ omap_writel(~level2_wake, OMAP_IH2_MIR);
+ } else if (cpu_is_omap16xx()) {
+ level2_wake |= OMAP_IRQ_BIT(INT_KEYBOARD);
+ omap_writel(~level2_wake, OMAP_IH2_0_MIR);
+
+ /* INT_1610_WAKE_UP_REQ is needed for GPIO wakeup... */
+ omap_writel(~OMAP_IRQ_BIT(INT_1610_WAKE_UP_REQ),
+ OMAP_IH2_1_MIR);
+ omap_writel(~0x0, OMAP_IH2_2_MIR);
+ omap_writel(~0x0, OMAP_IH2_3_MIR);
+ }
+
+ /* New IRQ agreement, recalculate in cascade order */
+ omap_writel(1, OMAP_IH2_CONTROL);
+ omap_writel(1, OMAP_IH1_CONTROL);
+}
+
+#define EN_DSPCK 13 /* ARM_CKCTL */
+#define EN_APICK 6 /* ARM_IDLECT2 */
+#define DSP_EN 1 /* ARM_RSTCT1 */
+
+void omap_pm_suspend(void)
+{
+ unsigned long arg0 = 0, arg1 = 0;
+
+ printk("PM: OMAP%x is trying to enter deep sleep...\n", system_rev);
+
+ omap_serial_wake_trigger(1);
+
+ if (machine_is_omap_osk()) {
+ /* Stop LED1 (D9) blink */
+ tps65010_set_led(LED1, OFF);
+ }
+
+ omap_writew(0xffff, ULPD_SOFT_DISABLE_REQ_REG);
+
+ /*
+ * Step 1: turn off interrupts (FIXME: NOTE: already disabled)
+ */
+
+ local_irq_disable();
+ local_fiq_disable();
+
+ /*
+ * Step 2: save registers
+ *
+ * The omap is a strange/beautiful device. The caches, memory
+ * and register state are preserved across power saves.
+ * We have to save and restore very little register state to
+ * idle the omap.
+ *
+ * Save interrupt, MPUI, ARM and UPLD control registers.
+ */
+
+ if (cpu_is_omap730()) {
+ MPUI730_SAVE(OMAP_IH1_MIR);
+ MPUI730_SAVE(OMAP_IH2_0_MIR);
+ MPUI730_SAVE(OMAP_IH2_1_MIR);
+ MPUI730_SAVE(MPUI_CTRL);
+ MPUI730_SAVE(MPUI_DSP_BOOT_CONFIG);
+ MPUI730_SAVE(MPUI_DSP_API_CONFIG);
+ MPUI730_SAVE(EMIFS_CONFIG);
+ MPUI730_SAVE(EMIFF_SDRAM_CONFIG);
+
+ } else if (cpu_is_omap15xx()) {
+ MPUI1510_SAVE(OMAP_IH1_MIR);
+ MPUI1510_SAVE(OMAP_IH2_MIR);
+ MPUI1510_SAVE(MPUI_CTRL);
+ MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
+ MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
+ MPUI1510_SAVE(EMIFS_CONFIG);
+ MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
+ } else if (cpu_is_omap16xx()) {
+ MPUI1610_SAVE(OMAP_IH1_MIR);
+ MPUI1610_SAVE(OMAP_IH2_0_MIR);
+ MPUI1610_SAVE(OMAP_IH2_1_MIR);
+ MPUI1610_SAVE(OMAP_IH2_2_MIR);
+ MPUI1610_SAVE(OMAP_IH2_3_MIR);
+ MPUI1610_SAVE(MPUI_CTRL);
+ MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
+ MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
+ MPUI1610_SAVE(EMIFS_CONFIG);
+ MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
+ }
+
+ ARM_SAVE(ARM_CKCTL);
+ ARM_SAVE(ARM_IDLECT1);
+ ARM_SAVE(ARM_IDLECT2);
+ if (!(cpu_is_omap15xx()))
+ ARM_SAVE(ARM_IDLECT3);
+ ARM_SAVE(ARM_EWUPCT);
+ ARM_SAVE(ARM_RSTCT1);
+ ARM_SAVE(ARM_RSTCT2);
+ ARM_SAVE(ARM_SYSST);
+ ULPD_SAVE(ULPD_CLOCK_CTRL);
+ ULPD_SAVE(ULPD_STATUS_REQ);
+
+ /* (Step 3 removed - we now allow deep sleep by default) */
+
+ /*
+ * Step 4: OMAP DSP Shutdown
+ */
+
+ /* stop DSP */
+ omap_writew(omap_readw(ARM_RSTCT1) & ~(1 << DSP_EN), ARM_RSTCT1);
+
+ /* shut down dsp_ck */
+ omap_writew(omap_readw(ARM_CKCTL) & ~(1 << EN_DSPCK), ARM_CKCTL);
+
+ /* temporarily enabling api_ck to access DSP registers */
+ omap_writew(omap_readw(ARM_IDLECT2) | 1 << EN_APICK, ARM_IDLECT2);
+
+ /* save DSP registers */
+ DSP_SAVE(DSP_IDLECT2);
+
+ /* Stop all DSP domain clocks */
+ __raw_writew(0, DSP_IDLECT2);
+
+ /*
+ * Step 5: Wakeup Event Setup
+ */
+
+ omap_pm_wakeup_setup();
+
+ /*
+ * Step 6: ARM and Traffic controller shutdown
+ */
+
+ /* disable ARM watchdog */
+ omap_writel(0x00F5, OMAP_WDT_TIMER_MODE);
+ omap_writel(0x00A0, OMAP_WDT_TIMER_MODE);
+
+ /*
+ * Step 6b: ARM and Traffic controller shutdown
+ *
+ * Step 6 continues here. Prepare jump to power management
+ * assembly code in internal SRAM.
+ *
+ * Since the omap_cpu_suspend routine has been copied to
+ * SRAM, we'll do an indirect procedure call to it and pass the
+ * contents of arm_idlect1 and arm_idlect2 so it can restore
+ * them when it wakes up and it will return.
+ */
+
+ arg0 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT1];
+ arg1 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT2];
+
+ /*
+ * Step 6c: ARM and Traffic controller shutdown
+ *
+ * Jump to assembly code. The processor will stay there
+ * until wake up.
+ */
+ omap_sram_suspend(arg0, arg1);
+
+ /*
+ * If we are here, processor is woken up!
+ */
+
+ /*
+ * Restore DSP clocks
+ */
+
+ /* again temporarily enabling api_ck to access DSP registers */
+ omap_writew(omap_readw(ARM_IDLECT2) | 1 << EN_APICK, ARM_IDLECT2);
+
+ /* Restore DSP domain clocks */
+ DSP_RESTORE(DSP_IDLECT2);
+
+ /*
+ * Restore ARM state, except ARM_IDLECT1/2 which omap_cpu_suspend did
+ */
+
+ if (!(cpu_is_omap15xx()))
+ ARM_RESTORE(ARM_IDLECT3);
+ ARM_RESTORE(ARM_CKCTL);
+ ARM_RESTORE(ARM_EWUPCT);
+ ARM_RESTORE(ARM_RSTCT1);
+ ARM_RESTORE(ARM_RSTCT2);
+ ARM_RESTORE(ARM_SYSST);
+ ULPD_RESTORE(ULPD_CLOCK_CTRL);
+ ULPD_RESTORE(ULPD_STATUS_REQ);
+
+ if (cpu_is_omap730()) {
+ MPUI730_RESTORE(EMIFS_CONFIG);
+ MPUI730_RESTORE(EMIFF_SDRAM_CONFIG);
+ MPUI730_RESTORE(OMAP_IH1_MIR);
+ MPUI730_RESTORE(OMAP_IH2_0_MIR);
+ MPUI730_RESTORE(OMAP_IH2_1_MIR);
+ } else if (cpu_is_omap15xx()) {
+ MPUI1510_RESTORE(MPUI_CTRL);
+ MPUI1510_RESTORE(MPUI_DSP_BOOT_CONFIG);
+ MPUI1510_RESTORE(MPUI_DSP_API_CONFIG);
+ MPUI1510_RESTORE(EMIFS_CONFIG);
+ MPUI1510_RESTORE(EMIFF_SDRAM_CONFIG);
+ MPUI1510_RESTORE(OMAP_IH1_MIR);
+ MPUI1510_RESTORE(OMAP_IH2_MIR);
+ } else if (cpu_is_omap16xx()) {
+ MPUI1610_RESTORE(MPUI_CTRL);
+ MPUI1610_RESTORE(MPUI_DSP_BOOT_CONFIG);
+ MPUI1610_RESTORE(MPUI_DSP_API_CONFIG);
+ MPUI1610_RESTORE(EMIFS_CONFIG);
+ MPUI1610_RESTORE(EMIFF_SDRAM_CONFIG);
+
+ MPUI1610_RESTORE(OMAP_IH1_MIR);
+ MPUI1610_RESTORE(OMAP_IH2_0_MIR);
+ MPUI1610_RESTORE(OMAP_IH2_1_MIR);
+ MPUI1610_RESTORE(OMAP_IH2_2_MIR);
+ MPUI1610_RESTORE(OMAP_IH2_3_MIR);
+ }
+
+ omap_writew(0, ULPD_SOFT_DISABLE_REQ_REG);
+
+ /*
+ * Reenable interrupts
+ */
+
+ local_irq_enable();
+ local_fiq_enable();
+
+ omap_serial_wake_trigger(0);
+
+ printk("PM: OMAP%x is re-starting from deep sleep...\n", system_rev);
+
+ if (machine_is_omap_osk()) {
+ /* Let LED1 (D9) blink again */
+ tps65010_set_led(LED1, BLINK);
+ }
+}
+
+#if defined(DEBUG) && defined(CONFIG_PROC_FS)
+static int g_read_completed;
+
+/*
+ * Read system PM registers for debugging
+ */
+static int omap_pm_read_proc(
+ char *page_buffer,
+ char **my_first_byte,
+ off_t virtual_start,
+ int length,
+ int *eof,
+ void *data)
+{
+ int my_buffer_offset = 0;
+ char * const my_base = page_buffer;
+
+ ARM_SAVE(ARM_CKCTL);
+ ARM_SAVE(ARM_IDLECT1);
+ ARM_SAVE(ARM_IDLECT2);
+ if (!(cpu_is_omap15xx()))
+ ARM_SAVE(ARM_IDLECT3);
+ ARM_SAVE(ARM_EWUPCT);
+ ARM_SAVE(ARM_RSTCT1);
+ ARM_SAVE(ARM_RSTCT2);
+ ARM_SAVE(ARM_SYSST);
+
+ ULPD_SAVE(ULPD_IT_STATUS);
+ ULPD_SAVE(ULPD_CLOCK_CTRL);
+ ULPD_SAVE(ULPD_SOFT_REQ);
+ ULPD_SAVE(ULPD_STATUS_REQ);
+ ULPD_SAVE(ULPD_DPLL_CTRL);
+ ULPD_SAVE(ULPD_POWER_CTRL);
+
+ if (cpu_is_omap730()) {
+ MPUI730_SAVE(MPUI_CTRL);
+ MPUI730_SAVE(MPUI_DSP_STATUS);
+ MPUI730_SAVE(MPUI_DSP_BOOT_CONFIG);
+ MPUI730_SAVE(MPUI_DSP_API_CONFIG);
+ MPUI730_SAVE(EMIFF_SDRAM_CONFIG);
+ MPUI730_SAVE(EMIFS_CONFIG);
+ } else if (cpu_is_omap15xx()) {
+ MPUI1510_SAVE(MPUI_CTRL);
+ MPUI1510_SAVE(MPUI_DSP_STATUS);
+ MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
+ MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
+ MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
+ MPUI1510_SAVE(EMIFS_CONFIG);
+ } else if (cpu_is_omap16xx()) {
+ MPUI1610_SAVE(MPUI_CTRL);
+ MPUI1610_SAVE(MPUI_DSP_STATUS);
+ MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
+ MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
+ MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
+ MPUI1610_SAVE(EMIFS_CONFIG);
+ }
+
+ if (virtual_start == 0) {
+ g_read_completed = 0;
+
+ my_buffer_offset += sprintf(my_base + my_buffer_offset,
+ "ARM_CKCTL_REG: 0x%-8x \n"
+ "ARM_IDLECT1_REG: 0x%-8x \n"
+ "ARM_IDLECT2_REG: 0x%-8x \n"
+ "ARM_IDLECT3_REG: 0x%-8x \n"
+ "ARM_EWUPCT_REG: 0x%-8x \n"
+ "ARM_RSTCT1_REG: 0x%-8x \n"
+ "ARM_RSTCT2_REG: 0x%-8x \n"
+ "ARM_SYSST_REG: 0x%-8x \n"
+ "ULPD_IT_STATUS_REG: 0x%-4x \n"
+ "ULPD_CLOCK_CTRL_REG: 0x%-4x \n"
+ "ULPD_SOFT_REQ_REG: 0x%-4x \n"
+ "ULPD_DPLL_CTRL_REG: 0x%-4x \n"
+ "ULPD_STATUS_REQ_REG: 0x%-4x \n"
+ "ULPD_POWER_CTRL_REG: 0x%-4x \n",
+ ARM_SHOW(ARM_CKCTL),
+ ARM_SHOW(ARM_IDLECT1),
+ ARM_SHOW(ARM_IDLECT2),
+ ARM_SHOW(ARM_IDLECT3),
+ ARM_SHOW(ARM_EWUPCT),
+ ARM_SHOW(ARM_RSTCT1),
+ ARM_SHOW(ARM_RSTCT2),
+ ARM_SHOW(ARM_SYSST),
+ ULPD_SHOW(ULPD_IT_STATUS),
+ ULPD_SHOW(ULPD_CLOCK_CTRL),
+ ULPD_SHOW(ULPD_SOFT_REQ),
+ ULPD_SHOW(ULPD_DPLL_CTRL),
+ ULPD_SHOW(ULPD_STATUS_REQ),
+ ULPD_SHOW(ULPD_POWER_CTRL));
+
+ if (cpu_is_omap730()) {
+ my_buffer_offset += sprintf(my_base + my_buffer_offset,
+ "MPUI730_CTRL_REG 0x%-8x \n"
+ "MPUI730_DSP_STATUS_REG: 0x%-8x \n"
+ "MPUI730_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
+ "MPUI730_DSP_API_CONFIG_REG: 0x%-8x \n"
+ "MPUI730_SDRAM_CONFIG_REG: 0x%-8x \n"
+ "MPUI730_EMIFS_CONFIG_REG: 0x%-8x \n",
+ MPUI730_SHOW(MPUI_CTRL),
+ MPUI730_SHOW(MPUI_DSP_STATUS),
+ MPUI730_SHOW(MPUI_DSP_BOOT_CONFIG),
+ MPUI730_SHOW(MPUI_DSP_API_CONFIG),
+ MPUI730_SHOW(EMIFF_SDRAM_CONFIG),
+ MPUI730_SHOW(EMIFS_CONFIG));
+ } else if (cpu_is_omap15xx()) {
+ my_buffer_offset += sprintf(my_base + my_buffer_offset,
+ "MPUI1510_CTRL_REG 0x%-8x \n"
+ "MPUI1510_DSP_STATUS_REG: 0x%-8x \n"
+ "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
+ "MPUI1510_DSP_API_CONFIG_REG: 0x%-8x \n"
+ "MPUI1510_SDRAM_CONFIG_REG: 0x%-8x \n"
+ "MPUI1510_EMIFS_CONFIG_REG: 0x%-8x \n",
+ MPUI1510_SHOW(MPUI_CTRL),
+ MPUI1510_SHOW(MPUI_DSP_STATUS),
+ MPUI1510_SHOW(MPUI_DSP_BOOT_CONFIG),
+ MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
+ MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
+ MPUI1510_SHOW(EMIFS_CONFIG));
+ } else if (cpu_is_omap16xx()) {
+ my_buffer_offset += sprintf(my_base + my_buffer_offset,
+ "MPUI1610_CTRL_REG 0x%-8x \n"
+ "MPUI1610_DSP_STATUS_REG: 0x%-8x \n"
+ "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
+ "MPUI1610_DSP_API_CONFIG_REG: 0x%-8x \n"
+ "MPUI1610_SDRAM_CONFIG_REG: 0x%-8x \n"
+ "MPUI1610_EMIFS_CONFIG_REG: 0x%-8x \n",
+ MPUI1610_SHOW(MPUI_CTRL),
+ MPUI1610_SHOW(MPUI_DSP_STATUS),
+ MPUI1610_SHOW(MPUI_DSP_BOOT_CONFIG),
+ MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
+ MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
+ MPUI1610_SHOW(EMIFS_CONFIG));
+ }
+
+ g_read_completed++;
+ } else if (g_read_completed >= 1) {
+ *eof = 1;
+ return 0;
+ }
+ g_read_completed++;
+
+ *my_first_byte = page_buffer;
+ return my_buffer_offset;
+}
+
+static void omap_pm_init_proc(void)
+{
+ struct proc_dir_entry *entry;
+
+ entry = create_proc_read_entry("driver/omap_pm",
+ S_IWUSR | S_IRUGO, NULL,
+ omap_pm_read_proc, NULL);
+}
+
+#endif /* DEBUG && CONFIG_PROC_FS */
+
+static void (*saved_idle)(void) = NULL;
+
+/*
+ * omap_pm_prepare - Do preliminary suspend work.
+ * @state: suspend state we're entering.
+ *
+ */
+static int omap_pm_prepare(suspend_state_t state)
+{
+ int error = 0;
+
+ /* We cannot sleep in idle until we have resumed */
+ saved_idle = pm_idle;
+ pm_idle = NULL;
+
+ switch (state)
+ {
+ case PM_SUSPEND_STANDBY:
+ case PM_SUSPEND_MEM:
+ break;
+
+ case PM_SUSPEND_DISK:
+ return -ENOTSUPP;
+
+ default:
+ return -EINVAL;
+ }
+
+ return error;
+}
+
+
+/*
+ * omap_pm_enter - Actually enter a sleep state.
+ * @state: State we're entering.
+ *
+ */
+
+static int omap_pm_enter(suspend_state_t state)
+{
+ switch (state)
+ {
+ case PM_SUSPEND_STANDBY:
+ case PM_SUSPEND_MEM:
+ omap_pm_suspend();
+ break;
+
+ case PM_SUSPEND_DISK:
+ return -ENOTSUPP;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+/**
+ * omap_pm_finish - Finish up suspend sequence.
+ * @state: State we're coming out of.
+ *
+ * This is called after we wake back up (or if entering the sleep state
+ * failed).
+ */
+
+static int omap_pm_finish(suspend_state_t state)
+{
+ pm_idle = saved_idle;
+ return 0;
+}
+
+
+static irqreturn_t omap_wakeup_interrupt(int irq, void * dev,
+ struct pt_regs * regs)
+{
+ return IRQ_HANDLED;
+}
+
+static struct irqaction omap_wakeup_irq = {
+ .name = "peripheral wakeup",
+ .flags = SA_INTERRUPT,
+ .handler = omap_wakeup_interrupt
+};
+
+
+
+static struct pm_ops omap_pm_ops ={
+ .pm_disk_mode = 0,
+ .prepare = omap_pm_prepare,
+ .enter = omap_pm_enter,
+ .finish = omap_pm_finish,
+};
+
+static int __init omap_pm_init(void)
+{
+ printk("Power Management for TI OMAP.\n");
+
+ /*
+ * We copy the assembler sleep/wakeup routines to SRAM.
+ * These routines need to be in SRAM as that's the only
+ * memory the MPU can see when it wakes up.
+ */
+ if (cpu_is_omap730()) {
+ omap_sram_idle = omap_sram_push(omap730_idle_loop_suspend,
+ omap730_idle_loop_suspend_sz);
+ omap_sram_suspend = omap_sram_push(omap730_cpu_suspend,
+ omap730_cpu_suspend_sz);
+ } else if (cpu_is_omap15xx()) {
+ omap_sram_idle = omap_sram_push(omap1510_idle_loop_suspend,
+ omap1510_idle_loop_suspend_sz);
+ omap_sram_suspend = omap_sram_push(omap1510_cpu_suspend,
+ omap1510_cpu_suspend_sz);
+ } else if (cpu_is_omap16xx()) {
+ omap_sram_idle = omap_sram_push(omap1610_idle_loop_suspend,
+ omap1610_idle_loop_suspend_sz);
+ omap_sram_suspend = omap_sram_push(omap1610_cpu_suspend,
+ omap1610_cpu_suspend_sz);
+ }
+
+ if (omap_sram_idle == NULL || omap_sram_suspend == NULL) {
+ printk(KERN_ERR "PM not initialized: Missing SRAM support\n");
+ return -ENODEV;
+ }
+
+ pm_idle = omap_pm_idle;
+
+ if (cpu_is_omap730())
+ setup_irq(INT_730_WAKE_UP_REQ, &omap_wakeup_irq);
+ else if (cpu_is_omap16xx())
+ setup_irq(INT_1610_WAKE_UP_REQ, &omap_wakeup_irq);
+
+ /* Program new power ramp-up time
+ * (0 for most boards since we don't lower voltage when in deep sleep)
+ */
+ omap_writew(ULPD_SETUP_ANALOG_CELL_3_VAL, ULPD_SETUP_ANALOG_CELL_3);
+
+ /* Setup ULPD POWER_CTRL_REG - enter deep sleep whenever possible */
+ omap_writew(ULPD_POWER_CTRL_REG_VAL, ULPD_POWER_CTRL);
+
+ /* Configure IDLECT3 */
+ if (cpu_is_omap730())
+ omap_writel(OMAP730_IDLECT3_VAL, OMAP730_IDLECT3);
+ else if (cpu_is_omap16xx())
+ omap_writel(OMAP1610_IDLECT3_VAL, OMAP1610_IDLECT3);
+
+ pm_set_ops(&omap_pm_ops);
+
+#if defined(DEBUG) && defined(CONFIG_PROC_FS)
+ omap_pm_init_proc();
+#endif
+
+ subsys_create_file(&power_subsys, &sleep_while_idle_attr);
+
+ if (cpu_is_omap16xx()) {
+ /* configure LOW_PWR pin */
+ omap_cfg_reg(T20_1610_LOW_PWR);
+ }
+
+ return 0;
+}
+__initcall(omap_pm_init);
diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c
index e924e0c6a4ce9..9b4cd698bec85 100644
--- a/arch/arm/mach-omap1/serial.c
+++ b/arch/arm/mach-omap1/serial.c
@@ -30,9 +30,9 @@
#include <asm/arch/pm.h>
#endif
-static struct clk * uart1_ck = NULL;
-static struct clk * uart2_ck = NULL;
-static struct clk * uart3_ck = NULL;
+static struct clk * uart1_ck;
+static struct clk * uart2_ck;
+static struct clk * uart3_ck;
static inline unsigned int omap_serial_in(struct plat_serial8250_port *up,
int offset)
diff --git a/arch/arm/plat-omap/sleep.S b/arch/arm/mach-omap1/sleep.S
index 4cd7d292f854b..e58295e2d3b24 100644
--- a/arch/arm/plat-omap/sleep.S
+++ b/arch/arm/mach-omap1/sleep.S
@@ -1,5 +1,5 @@
/*
- * linux/arch/arm/plat-omap/sleep.S
+ * linux/arch/arm/mach-omap1/sleep.S
*
* Low-level OMAP730/1510/1610 sleep/wakeUp support
*
@@ -383,60 +383,133 @@ ENTRY(omap1610_cpu_suspend)
mcr p15, 0, r0, c7, c10, 4
nop
- @ load base address of Traffic Controller
+ @ Load base address of Traffic Controller
mov r6, #TCMIF_ASM_BASE & 0xff000000
orr r6, r6, #TCMIF_ASM_BASE & 0x00ff0000
orr r6, r6, #TCMIF_ASM_BASE & 0x0000ff00
- @ prepare to put SDRAM into self-refresh manually
+ @ Prepare to put SDRAM into self-refresh manually
ldr r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
orr r9, r7, #SELF_REFRESH_MODE & 0xff000000
orr r9, r9, #SELF_REFRESH_MODE & 0x000000ff
str r9, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
- @ prepare to put EMIFS to Sleep
+ @ Prepare to put EMIFS to Sleep
ldr r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
orr r9, r8, #IDLE_EMIFS_REQUEST & 0xff
str r9, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
- @ load base address of ARM_IDLECT1 and ARM_IDLECT2
+ @ Load base address of ARM_IDLECT1 and ARM_IDLECT2
mov r4, #CLKGEN_REG_ASM_BASE & 0xff000000
orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
orr r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
- @ turn off clock domains
- @ do not disable PERCK (0x04)
+ @ Turn off clock domains
+ @ Do not disable PERCK (0x04)
mov r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff
orr r5, r5, #OMAP1610_IDLECT2_SLEEP_VAL & 0xff00
strh r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
- @ request ARM idle
+ @ Request ARM idle
mov r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff
orr r3, r3, #OMAP1610_IDLECT1_SLEEP_VAL & 0xff00
strh r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
- @ disable instruction cache
- mrc p15, 0, r9, c1, c0, 0
- bic r2, r9, #0x1000
- mcr p15, 0, r2, c1, c0, 0
- nop
-
/*
* Let's wait for the next wake up event to wake us up. r0 can't be
* used here because r0 holds ARM_IDLECT1
*/
mov r2, #0
mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
+
+ @ Errata (HEL3SU467, section 1.4.4) specifies nop-instructions
+ @ according to this formula:
+ @ 2 + (4*DPLL_MULT)/DPLL_DIV/ARMDIV
+ @ Max DPLL_MULT = 18
+ @ DPLL_DIV = 1
+ @ ARMDIV = 1
+ @ => 74 nop-instructions
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @10
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @20
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @30
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @40
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @50
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @60
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop @70
+ nop
+ nop
+ nop
+ nop @74
/*
* omap1610_cpu_suspend()'s resume point.
*
* It will just start executing here, so we'll restore stuff from the
* stack.
*/
- @ re-enable Icache
- mcr p15, 0, r9, c1, c0, 0
-
- @ reset the ARM_IDLECT1 and ARM_IDLECT2.
+ @ Restore the ARM_IDLECT1 and ARM_IDLECT2.
strh r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
strh r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
@@ -444,7 +517,7 @@ ENTRY(omap1610_cpu_suspend)
str r7, [r6, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
str r8, [r6, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
- @ restore regs and return
+ @ Restore regs and return
ldmfd sp!, {r0 - r12, pc}
ENTRY(omap1610_cpu_suspend_sz)
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index cdbf4d7620c6c..a85fe6066bc47 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -51,8 +51,6 @@
struct sys_timer omap_timer;
-#ifdef CONFIG_OMAP_MPU_TIMER
-
/*
* ---------------------------------------------------------------------------
* MPU timer
@@ -222,195 +220,6 @@ unsigned long long sched_clock(void)
return cycles_2_ns(ticks64);
}
-#endif /* CONFIG_OMAP_MPU_TIMER */
-
-#ifdef CONFIG_OMAP_32K_TIMER
-
-#ifdef CONFIG_ARCH_OMAP15XX
-#error OMAP 32KHz timer does not currently work on 15XX!
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- * 32KHz OS timer
- *
- * This currently works only on 16xx, as 1510 does not have the continuous
- * 32KHz synchronous timer. The 32KHz synchronous timer is used to keep track
- * of time in addition to the 32KHz OS timer. Using only the 32KHz OS timer
- * on 1510 would be possible, but the timer would not be as accurate as
- * with the 32KHz synchronized timer.
- * ---------------------------------------------------------------------------
- */
-#define OMAP_32K_TIMER_BASE 0xfffb9000
-#define OMAP_32K_TIMER_CR 0x08
-#define OMAP_32K_TIMER_TVR 0x00
-#define OMAP_32K_TIMER_TCR 0x04
-
-#define OMAP_32K_TICKS_PER_HZ (32768 / HZ)
-
-/*
- * TRM says 1 / HZ = ( TVR + 1) / 32768, so TRV = (32768 / HZ) - 1
- * so with HZ = 100, TVR = 327.68.
- */
-#define OMAP_32K_TIMER_TICK_PERIOD ((32768 / HZ) - 1)
-#define TIMER_32K_SYNCHRONIZED 0xfffbc410
-
-#define JIFFIES_TO_HW_TICKS(nr_jiffies, clock_rate) \
- (((nr_jiffies) * (clock_rate)) / HZ)
-
-static inline void omap_32k_timer_write(int val, int reg)
-{
- omap_writew(val, reg + OMAP_32K_TIMER_BASE);
-}
-
-static inline unsigned long omap_32k_timer_read(int reg)
-{
- return omap_readl(reg + OMAP_32K_TIMER_BASE) & 0xffffff;
-}
-
-/*
- * The 32KHz synchronized timer is an additional timer on 16xx.
- * It is always running.
- */
-static inline unsigned long omap_32k_sync_timer_read(void)
-{
- return omap_readl(TIMER_32K_SYNCHRONIZED);
-}
-
-static inline void omap_32k_timer_start(unsigned long load_val)
-{
- omap_32k_timer_write(load_val, OMAP_32K_TIMER_TVR);
- omap_32k_timer_write(0x0f, OMAP_32K_TIMER_CR);
-}
-
-static inline void omap_32k_timer_stop(void)
-{
- omap_32k_timer_write(0x0, OMAP_32K_TIMER_CR);
-}
-
-/*
- * Rounds down to nearest usec. Note that this will overflow for larger values.
- */
-static inline unsigned long omap_32k_ticks_to_usecs(unsigned long ticks_32k)
-{
- return (ticks_32k * 5*5*5*5*5*5) >> 9;
-}
-
-/*
- * Rounds down to nearest nsec.
- */
-static inline unsigned long long
-omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
-{
- return (unsigned long long) ticks_32k * 1000 * 5*5*5*5*5*5 >> 9;
-}
-
-static unsigned long omap_32k_last_tick = 0;
-
-/*
- * Returns elapsed usecs since last 32k timer interrupt
- */
-static unsigned long omap_32k_timer_gettimeoffset(void)
-{
- unsigned long now = omap_32k_sync_timer_read();
- return omap_32k_ticks_to_usecs(now - omap_32k_last_tick);
-}
-
-/*
- * Returns current time from boot in nsecs. It's OK for this to wrap
- * around for now, as it's just a relative time stamp.
- */
-unsigned long long sched_clock(void)
-{
- return omap_32k_ticks_to_nsecs(omap_32k_sync_timer_read());
-}
-
-/*
- * Timer interrupt for 32KHz timer. When dynamic tick is enabled, this
- * function is also called from other interrupts to remove latency
- * issues with dynamic tick. In the dynamic tick case, we need to lock
- * with irqsave.
- */
-static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id,
- struct pt_regs *regs)
-{
- unsigned long flags;
- unsigned long now;
-
- write_seqlock_irqsave(&xtime_lock, flags);
- now = omap_32k_sync_timer_read();
-
- while (now - omap_32k_last_tick >= OMAP_32K_TICKS_PER_HZ) {
- omap_32k_last_tick += OMAP_32K_TICKS_PER_HZ;
- timer_tick(regs);
- }
-
- /* Restart timer so we don't drift off due to modulo or dynamic tick.
- * By default we program the next timer to be continuous to avoid
- * latencies during high system load. During dynamic tick operation the
- * continuous timer can be overridden from pm_idle to be longer.
- */
- omap_32k_timer_start(omap_32k_last_tick + OMAP_32K_TICKS_PER_HZ - now);
- write_sequnlock_irqrestore(&xtime_lock, flags);
-
- return IRQ_HANDLED;
-}
-
-#ifdef CONFIG_NO_IDLE_HZ
-/*
- * Programs the next timer interrupt needed. Called when dynamic tick is
- * enabled, and to reprogram the ticks to skip from pm_idle. Note that
- * we can keep the timer continuous, and don't need to set it to run in
- * one-shot mode. This is because the timer will get reprogrammed again
- * after next interrupt.
- */
-void omap_32k_timer_reprogram(unsigned long next_tick)
-{
- omap_32k_timer_start(JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1);
-}
-
-static struct irqaction omap_32k_timer_irq;
-extern struct timer_update_handler timer_update;
-
-static int omap_32k_timer_enable_dyn_tick(void)
-{
- /* No need to reprogram timer, just use the next interrupt */
- return 0;
-}
-
-static int omap_32k_timer_disable_dyn_tick(void)
-{
- omap_32k_timer_start(OMAP_32K_TIMER_TICK_PERIOD);
- return 0;
-}
-
-static struct dyn_tick_timer omap_dyn_tick_timer = {
- .enable = omap_32k_timer_enable_dyn_tick,
- .disable = omap_32k_timer_disable_dyn_tick,
- .reprogram = omap_32k_timer_reprogram,
- .handler = omap_32k_timer_interrupt,
-};
-#endif /* CONFIG_NO_IDLE_HZ */
-
-static struct irqaction omap_32k_timer_irq = {
- .name = "32KHz timer",
- .flags = SA_INTERRUPT | SA_TIMER,
- .handler = omap_32k_timer_interrupt,
-};
-
-static __init void omap_init_32k_timer(void)
-{
-
-#ifdef CONFIG_NO_IDLE_HZ
- omap_timer.dyn_tick = &omap_dyn_tick_timer;
-#endif
-
- setup_irq(INT_OS_TIMER, &omap_32k_timer_irq);
- omap_timer.offset = omap_32k_timer_gettimeoffset;
- omap_32k_last_tick = omap_32k_sync_timer_read();
- omap_32k_timer_start(OMAP_32K_TIMER_TICK_PERIOD);
-}
-#endif /* CONFIG_OMAP_32K_TIMER */
/*
* ---------------------------------------------------------------------------
@@ -419,13 +228,7 @@ static __init void omap_init_32k_timer(void)
*/
static void __init omap_timer_init(void)
{
-#if defined(CONFIG_OMAP_MPU_TIMER)
omap_init_mpu_timer();
-#elif defined(CONFIG_OMAP_32K_TIMER)
- omap_init_32k_timer();
-#else
-#error No system timer selected in Kconfig!
-#endif
}
struct sys_timer omap_timer = {
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 578880943cf24..537dd2e6d3801 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -20,3 +20,6 @@ config MACH_OMAP_H4
bool "OMAP 2420 H4 board"
depends on ARCH_OMAP2 && ARCH_OMAP24XX
+config MACH_OMAP_APOLLON
+ bool "OMAP 2420 Apollon board"
+ depends on ARCH_OMAP2 && ARCH_OMAP24XX
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 42041166435c4..111eaa64258f2 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -3,11 +3,15 @@
#
# Common support
-obj-y := irq.o id.o io.o sram-fn.o clock.o mux.o devices.o serial.o
+obj-y := irq.o id.o io.o sram-fn.o memory.o prcm.o clock.o mux.o devices.o serial.o
obj-$(CONFIG_OMAP_MPU_TIMER) += timer-gp.o
+# Power Management
+obj-$(CONFIG_PM) += pm.o sleep.o
+
# Specific board support
obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o
obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o
+obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
new file mode 100644
index 0000000000000..6c6ba172cdf6d
--- /dev/null
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -0,0 +1,285 @@
+/*
+ * linux/arch/arm/mach-omap/omap2/board-apollon.c
+ *
+ * Copyright (C) 2005,2006 Samsung Electronics
+ * Author: Kyungmin Park <kyungmin.park@samsung.com>
+ *
+ * Modified from mach-omap/omap2/board-h4.c
+ *
+ * Code for apollon OMAP2 board. Should work on many OMAP2 systems where
+ * the bootloader passes the board-specific data to the kernel.
+ * Do not put any board specific code to this file; create a new machine
+ * type if you need custom low-level initializations.
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/onenand.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/usb.h>
+#include <asm/arch/board.h>
+#include <asm/arch/common.h>
+#include "prcm-regs.h"
+
+/* LED & Switch macros */
+#define LED0_GPIO13 13
+#define LED1_GPIO14 14
+#define LED2_GPIO15 15
+#define SW_ENTER_GPIO16 16
+#define SW_UP_GPIO17 17
+#define SW_DOWN_GPIO58 58
+
+static struct mtd_partition apollon_partitions[] = {
+ {
+ .name = "X-Loader + U-Boot",
+ .offset = 0,
+ .size = SZ_128K,
+ .mask_flags = MTD_WRITEABLE,
+ },
+ {
+ .name = "params",
+ .offset = MTDPART_OFS_APPEND,
+ .size = SZ_128K,
+ },
+ {
+ .name = "kernel",
+ .offset = MTDPART_OFS_APPEND,
+ .size = SZ_2M,
+ },
+ {
+ .name = "rootfs",
+ .offset = MTDPART_OFS_APPEND,
+ .size = SZ_16M,
+ },
+ {
+ .name = "filesystem00",
+ .offset = MTDPART_OFS_APPEND,
+ .size = SZ_32M,
+ },
+ {
+ .name = "filesystem01",
+ .offset = MTDPART_OFS_APPEND,
+ .size = MTDPART_SIZ_FULL,
+ },
+};
+
+static struct flash_platform_data apollon_flash_data = {
+ .parts = apollon_partitions,
+ .nr_parts = ARRAY_SIZE(apollon_partitions),
+};
+
+static struct resource apollon_flash_resource = {
+ .start = APOLLON_CS0_BASE,
+ .end = APOLLON_CS0_BASE + SZ_128K,
+ .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device apollon_onenand_device = {
+ .name = "onenand",
+ .id = -1,
+ .dev = {
+ .platform_data = &apollon_flash_data,
+ },
+ .num_resources = ARRAY_SIZE(&apollon_flash_resource),
+ .resource = &apollon_flash_resource,
+};
+
+static struct resource apollon_smc91x_resources[] = {
+ [0] = {
+ .start = APOLLON_ETHR_START, /* Physical */
+ .end = APOLLON_ETHR_START + 0xf,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
+ .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device apollon_smc91x_device = {
+ .name = "smc91x",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
+ .resource = apollon_smc91x_resources,
+};
+
+static struct platform_device apollon_lcd_device = {
+ .name = "apollon_lcd",
+ .id = -1,
+};
+
+static struct platform_device *apollon_devices[] __initdata = {
+ &apollon_onenand_device,
+ &apollon_smc91x_device,
+ &apollon_lcd_device,
+};
+
+static inline void __init apollon_init_smc91x(void)
+{
+ /* Make sure CS1 timings are correct */
+ GPMC_CONFIG1_1 = 0x00011203;
+ GPMC_CONFIG2_1 = 0x001f1f01;
+ GPMC_CONFIG3_1 = 0x00080803;
+ GPMC_CONFIG4_1 = 0x1c091c09;
+ GPMC_CONFIG5_1 = 0x041f1f1f;
+ GPMC_CONFIG6_1 = 0x000004c4;
+ GPMC_CONFIG7_1 = 0x00000f40 | (APOLLON_CS1_BASE >> 24);
+ udelay(100);
+
+ omap_cfg_reg(W4__24XX_GPIO74);
+ if (omap_request_gpio(APOLLON_ETHR_GPIO_IRQ) < 0) {
+ printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
+ APOLLON_ETHR_GPIO_IRQ);
+ return;
+ }
+ omap_set_gpio_direction(APOLLON_ETHR_GPIO_IRQ, 1);
+}
+
+static void __init omap_apollon_init_irq(void)
+{
+ omap2_init_common_hw();
+ omap_init_irq();
+ omap_gpio_init();
+ apollon_init_smc91x();
+}
+
+static struct omap_uart_config apollon_uart_config __initdata = {
+ .enabled_uarts = (1 << 0) | (0 << 1) | (0 << 2),
+};
+
+static struct omap_mmc_config apollon_mmc_config __initdata = {
+ .mmc [0] = {
+ .enabled = 0,
+ .wire4 = 0,
+ .wp_pin = -1,
+ .power_pin = -1,
+ .switch_pin = -1,
+ },
+};
+
+static struct omap_lcd_config apollon_lcd_config __initdata = {
+ .ctrl_name = "internal",
+};
+
+static struct omap_board_config_kernel apollon_config[] = {
+ { OMAP_TAG_UART, &apollon_uart_config },
+ { OMAP_TAG_MMC, &apollon_mmc_config },
+ { OMAP_TAG_LCD, &apollon_lcd_config },
+};
+
+static void __init apollon_led_init(void)
+{
+ /* LED0 - AA10 */
+ omap_cfg_reg(AA10_242X_GPIO13);
+ omap_request_gpio(LED0_GPIO13);
+ omap_set_gpio_direction(LED0_GPIO13, 0);
+ omap_set_gpio_dataout(LED0_GPIO13, 0);
+ /* LED1 - AA6 */
+ omap_cfg_reg(AA6_242X_GPIO14);
+ omap_request_gpio(LED1_GPIO14);
+ omap_set_gpio_direction(LED1_GPIO14, 0);
+ omap_set_gpio_dataout(LED1_GPIO14, 0);
+ /* LED2 - AA4 */
+ omap_cfg_reg(AA4_242X_GPIO15);
+ omap_request_gpio(LED2_GPIO15);
+ omap_set_gpio_direction(LED2_GPIO15, 0);
+ omap_set_gpio_dataout(LED2_GPIO15, 0);
+}
+
+static irqreturn_t apollon_sw_interrupt(int irq, void *ignored, struct pt_regs *regs)
+{
+ static unsigned int led0, led1, led2;
+
+ if (irq == OMAP_GPIO_IRQ(SW_ENTER_GPIO16))
+ omap_set_gpio_dataout(LED0_GPIO13, led0 ^= 1);
+ else if (irq == OMAP_GPIO_IRQ(SW_UP_GPIO17))
+ omap_set_gpio_dataout(LED1_GPIO14, led1 ^= 1);
+ else if (irq == OMAP_GPIO_IRQ(SW_DOWN_GPIO58))
+ omap_set_gpio_dataout(LED2_GPIO15, led2 ^= 1);
+
+ return IRQ_HANDLED;
+}
+
+static void __init apollon_sw_init(void)
+{
+ /* Enter SW - Y11 */
+ omap_cfg_reg(Y11_242X_GPIO16);
+ omap_request_gpio(SW_ENTER_GPIO16);
+ omap_set_gpio_direction(SW_ENTER_GPIO16, 1);
+ /* Up SW - AA12 */
+ omap_cfg_reg(AA12_242X_GPIO17);
+ omap_request_gpio(SW_UP_GPIO17);
+ omap_set_gpio_direction(SW_UP_GPIO17, 1);
+ /* Down SW - AA8 */
+ omap_cfg_reg(AA8_242X_GPIO58);
+ omap_request_gpio(SW_DOWN_GPIO58);
+ omap_set_gpio_direction(SW_DOWN_GPIO58, 1);
+
+ set_irq_type(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), IRQT_RISING);
+ if (request_irq(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), &apollon_sw_interrupt,
+ SA_SHIRQ, "enter sw",
+ &apollon_sw_interrupt))
+ return;
+ set_irq_type(OMAP_GPIO_IRQ(SW_UP_GPIO17), IRQT_RISING);
+ if (request_irq(OMAP_GPIO_IRQ(SW_UP_GPIO17), &apollon_sw_interrupt,
+ SA_SHIRQ, "up sw",
+ &apollon_sw_interrupt))
+ return;
+ set_irq_type(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), IRQT_RISING);
+ if (request_irq(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), &apollon_sw_interrupt,
+ SA_SHIRQ, "down sw",
+ &apollon_sw_interrupt))
+ return;
+}
+
+static void __init omap_apollon_init(void)
+{
+ apollon_led_init();
+ apollon_sw_init();
+
+ /* REVISIT: where's the correct place */
+ omap_cfg_reg(W19_24XX_SYS_NIRQ);
+
+ /*
+ * Make sure the serial ports are muxed on at this point.
+ * You have to mux them off in device drivers later on
+ * if not needed.
+ */
+ platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
+ omap_board_config = apollon_config;
+ omap_board_config_size = ARRAY_SIZE(apollon_config);
+ omap_serial_init();
+}
+
+static void __init omap_apollon_map_io(void)
+{
+ omap2_map_common_io();
+}
+
+MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
+ /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
+ .phys_io = 0x48000000,
+ .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
+ .boot_params = 0x80000100,
+ .map_io = omap_apollon_map_io,
+ .init_irq = omap_apollon_init_irq,
+ .init_machine = omap_apollon_init,
+ .timer = &omap_timer,
+MACHINE_END
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index a300d634d8a59..4933fce766c82 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -17,6 +17,8 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/input.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -25,15 +27,57 @@
#include <asm/mach/flash.h>
#include <asm/arch/gpio.h>
+#include <asm/arch/gpioexpander.h>
#include <asm/arch/mux.h>
#include <asm/arch/usb.h>
+#include <asm/arch/irda.h>
#include <asm/arch/board.h>
#include <asm/arch/common.h>
-#include <asm/arch/prcm.h>
+#include <asm/arch/keypad.h>
+#include <asm/arch/menelaus.h>
+#include <asm/arch/dma.h>
+#include "prcm-regs.h"
#include <asm/io.h>
#include <asm/delay.h>
+static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
+static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
+
+static int h4_keymap[] = {
+ KEY(0, 0, KEY_LEFT),
+ KEY(0, 1, KEY_RIGHT),
+ KEY(0, 2, KEY_A),
+ KEY(0, 3, KEY_B),
+ KEY(0, 4, KEY_C),
+ KEY(1, 0, KEY_DOWN),
+ KEY(1, 1, KEY_UP),
+ KEY(1, 2, KEY_E),
+ KEY(1, 3, KEY_F),
+ KEY(1, 4, KEY_G),
+ KEY(2, 0, KEY_ENTER),
+ KEY(2, 1, KEY_I),
+ KEY(2, 2, KEY_J),
+ KEY(2, 3, KEY_K),
+ KEY(2, 4, KEY_3),
+ KEY(3, 0, KEY_M),
+ KEY(3, 1, KEY_N),
+ KEY(3, 2, KEY_O),
+ KEY(3, 3, KEY_P),
+ KEY(3, 4, KEY_Q),
+ KEY(4, 0, KEY_R),
+ KEY(4, 1, KEY_4),
+ KEY(4, 2, KEY_T),
+ KEY(4, 3, KEY_U),
+ KEY(4, 4, KEY_ENTER),
+ KEY(5, 0, KEY_V),
+ KEY(5, 1, KEY_W),
+ KEY(5, 2, KEY_L),
+ KEY(5, 3, KEY_S),
+ KEY(5, 4, KEY_ENTER),
+ 0
+};
+
static struct mtd_partition h4_partitions[] = {
/* bootloader (U-Boot, etc) in first sector */
{
@@ -108,9 +152,123 @@ static struct platform_device h4_smc91x_device = {
.resource = h4_smc91x_resources,
};
+/* Select between the IrDA and aGPS module
+ */
+static int h4_select_irda(struct device *dev, int state)
+{
+ unsigned char expa;
+ int err = 0;
+
+ if ((err = read_gpio_expa(&expa, 0x21))) {
+ printk(KERN_ERR "Error reading from I/O expander\n");
+ return err;
+ }
+
+ /* 'P6' enable/disable IRDA_TX and IRDA_RX */
+ if (state & IR_SEL) { /* IrDa */
+ if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
+ printk(KERN_ERR "Error writing to I/O expander\n");
+ return err;
+ }
+ } else {
+ if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
+ printk(KERN_ERR "Error writing to I/O expander\n");
+ return err;
+ }
+ }
+ return err;
+}
+
+static void set_trans_mode(void *data)
+{
+ int *mode = data;
+ unsigned char expa;
+ int err = 0;
+
+ if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
+ printk(KERN_ERR "Error reading from I/O expander\n");
+ }
+
+ expa &= ~0x01;
+
+ if (!(*mode & IR_SIRMODE)) { /* MIR/FIR */
+ expa |= 0x01;
+ }
+
+ if ((err = write_gpio_expa(expa, 0x20)) != 0) {
+ printk(KERN_ERR "Error writing to I/O expander\n");
+ }
+}
+
+static int h4_transceiver_mode(struct device *dev, int mode)
+{
+ struct omap_irda_config *irda_config = dev->platform_data;
+
+ cancel_delayed_work(&irda_config->gpio_expa);
+ PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
+ schedule_work(&irda_config->gpio_expa);
+
+ return 0;
+}
+
+static struct omap_irda_config h4_irda_data = {
+ .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
+ .transceiver_mode = h4_transceiver_mode,
+ .select_irda = h4_select_irda,
+ .rx_channel = OMAP24XX_DMA_UART3_RX,
+ .tx_channel = OMAP24XX_DMA_UART3_TX,
+ .dest_start = OMAP_UART3_BASE,
+ .src_start = OMAP_UART3_BASE,
+ .tx_trigger = OMAP24XX_DMA_UART3_TX,
+ .rx_trigger = OMAP24XX_DMA_UART3_RX,
+};
+
+static struct resource h4_irda_resources[] = {
+ [0] = {
+ .start = INT_24XX_UART3_IRQ,
+ .end = INT_24XX_UART3_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device h4_irda_device = {
+ .name = "omapirda",
+ .id = -1,
+ .dev = {
+ .platform_data = &h4_irda_data,
+ },
+ .num_resources = 1,
+ .resource = h4_irda_resources,
+};
+
+static struct omap_kp_platform_data h4_kp_data = {
+ .rows = 6,
+ .cols = 7,
+ .keymap = h4_keymap,
+ .rep = 1,
+ .row_gpios = row_gpios,
+ .col_gpios = col_gpios,
+};
+
+static struct platform_device h4_kp_device = {
+ .name = "omap-keypad",
+ .id = -1,
+ .dev = {
+ .platform_data = &h4_kp_data,
+ },
+};
+
+static struct platform_device h4_lcd_device = {
+ .name = "lcd_h4",
+ .id = -1,
+};
+
static struct platform_device *h4_devices[] __initdata = {
&h4_smc91x_device,
&h4_flash_device,
+ &h4_irda_device,
+ &h4_kp_device,
+ &h4_lcd_device,
};
static inline void __init h4_init_smc91x(void)
@@ -157,7 +315,6 @@ static struct omap_mmc_config h4_mmc_config __initdata = {
};
static struct omap_lcd_config h4_lcd_config __initdata = {
- .panel_name = "h4",
.ctrl_name = "internal",
};
@@ -174,6 +331,19 @@ static void __init omap_h4_init(void)
* You have to mux them off in device drivers later on
* if not needed.
*/
+#if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
+ omap_cfg_reg(K15_24XX_UART3_TX);
+ omap_cfg_reg(K14_24XX_UART3_RX);
+#endif
+
+#if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
+ if (omap_has_menelaus()) {
+ row_gpios[5] = 0;
+ col_gpios[2] = 15;
+ col_gpios[6] = 18;
+ }
+#endif
+
platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
omap_board_config = h4_config;
omap_board_config_size = ARRAY_SIZE(h4_config);
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 180f675c90640..72eb4bf571acf 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -28,14 +28,14 @@
#include <asm/arch/clock.h>
#include <asm/arch/sram.h>
-#include <asm/arch/prcm.h>
+#include "prcm-regs.h"
+#include "memory.h"
#include "clock.h"
//#define DOWN_VARIABLE_DPLL 1 /* Experimental */
static struct prcm_config *curr_prcm_set;
-static struct memory_timings mem_timings;
static u32 curr_perf_level = PRCM_FULL_SPEED;
/*-------------------------------------------------------------------------
@@ -54,11 +54,13 @@ static void omap2_sys_clk_recalc(struct clk * clk)
static u32 omap2_get_dpll_rate(struct clk * tclk)
{
- int dpll_clk, dpll_mult, dpll_div, amult;
+ long long dpll_clk;
+ int dpll_mult, dpll_div, amult;
dpll_mult = (CM_CLKSEL1_PLL >> 12) & 0x03ff; /* 10 bits */
dpll_div = (CM_CLKSEL1_PLL >> 8) & 0x0f; /* 4 bits */
- dpll_clk = (tclk->parent->rate * dpll_mult) / (dpll_div + 1);
+ dpll_clk = (long long)tclk->parent->rate * dpll_mult;
+ do_div(dpll_clk, dpll_div + 1);
amult = CM_CLKSEL2_PLL & 0x3;
dpll_clk *= amult;
@@ -385,75 +387,23 @@ static u32 omap2_dll_force_needed(void)
return 0;
}
-static void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
-{
- unsigned long dll_cnt;
- u32 fast_dll = 0;
-
- mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */
-
- /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others.
- * In the case of 2422, its ok to use CS1 instead of CS0.
- */
-
-#if 0 /* FIXME: Enable after 24xx cpu detection works */
- ctype = get_cpu_type();
- if (cpu_is_omap2422())
- mem_timings.base_cs = 1;
- else
-#endif
- mem_timings.base_cs = 0;
-
- if (mem_timings.m_type != M_DDR)
- return;
-
- /* With DDR we need to determine the low frequency DLL value */
- if (((mem_timings.fast_dll_ctrl & (1 << 2)) == M_LOCK_CTRL))
- mem_timings.dll_mode = M_UNLOCK;
- else
- mem_timings.dll_mode = M_LOCK;
-
- if (mem_timings.base_cs == 0) {
- fast_dll = SDRC_DLLA_CTRL;
- dll_cnt = SDRC_DLLA_STATUS & 0xff00;
- } else {
- fast_dll = SDRC_DLLB_CTRL;
- dll_cnt = SDRC_DLLB_STATUS & 0xff00;
- }
- if (force_lock_to_unlock_mode) {
- fast_dll &= ~0xff00;
- fast_dll |= dll_cnt; /* Current lock mode */
- }
- mem_timings.fast_dll_ctrl = fast_dll;
-
- /* No disruptions, DDR will be offline & C-ABI not followed */
- omap2_sram_ddr_init(&mem_timings.slow_dll_ctrl,
- mem_timings.fast_dll_ctrl,
- mem_timings.base_cs,
- force_lock_to_unlock_mode);
- mem_timings.slow_dll_ctrl &= 0xff00; /* Keep lock value */
-
- /* Turn status into unlock ctrl */
- mem_timings.slow_dll_ctrl |=
- ((mem_timings.fast_dll_ctrl & 0xF) | (1 << 2));
-
- /* 90 degree phase for anything below 133Mhz */
- mem_timings.slow_dll_ctrl |= (1 << 1);
-}
-
static u32 omap2_reprogram_sdrc(u32 level, u32 force)
{
+ u32 slow_dll_ctrl, fast_dll_ctrl, m_type;
u32 prev = curr_perf_level, flags;
if ((curr_perf_level == level) && !force)
return prev;
+ m_type = omap2_memory_get_type();
+ slow_dll_ctrl = omap2_memory_get_slow_dll_ctrl();
+ fast_dll_ctrl = omap2_memory_get_fast_dll_ctrl();
+
if (level == PRCM_HALF_SPEED) {
local_irq_save(flags);
PRCM_VOLTSETUP = 0xffff;
omap2_sram_reprogram_sdrc(PRCM_HALF_SPEED,
- mem_timings.slow_dll_ctrl,
- mem_timings.m_type);
+ slow_dll_ctrl, m_type);
curr_perf_level = PRCM_HALF_SPEED;
local_irq_restore(flags);
}
@@ -461,8 +411,7 @@ static u32 omap2_reprogram_sdrc(u32 level, u32 force)
local_irq_save(flags);
PRCM_VOLTSETUP = 0xffff;
omap2_sram_reprogram_sdrc(PRCM_FULL_SPEED,
- mem_timings.fast_dll_ctrl,
- mem_timings.m_type);
+ fast_dll_ctrl, m_type);
curr_perf_level = PRCM_FULL_SPEED;
local_irq_restore(flags);
}
@@ -650,7 +599,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask,
case 13: /* dss2 */
mask = 0x1; break;
case 25: /* usb */
- mask = 0xf; break;
+ mask = 0x7; break;
}
}
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 6cab20b1d3c1d..6c78d471fab70 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -33,20 +33,6 @@ static u32 omap2_clksel_get_divisor(struct clk *clk);
#define RATE_IN_242X (1 << 0)
#define RATE_IN_243X (1 << 1)
-/* Memory timings */
-#define M_DDR 1
-#define M_LOCK_CTRL (1 << 2)
-#define M_UNLOCK 0
-#define M_LOCK 1
-
-struct memory_timings {
- u32 m_type; /* ddr = 1, sdr = 0 */
- u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */
- u32 slow_dll_ctrl; /* unlock mode, dll value for slow speed */
- u32 fast_dll_ctrl; /* unlock mode, dll value for fast speed */
- u32 base_cs; /* base chip select to use for calculations */
-};
-
/* Key dividers which make up a PRCM set. Ratio's for a PRCM are mandated.
* xtal_speed, dpll_speed, mpu_speed, CM_CLKSEL_MPU,CM_CLKSEL_DSP
* CM_CLKSEL_GFX, CM_CLKSEL1_CORE, CM_CLKSEL1_PLL CM_CLKSEL2_PLL, CM_CLKSEL_MDM
@@ -731,6 +717,16 @@ static struct clk sys_clkout2 = {
.recalc = &omap2_clksel_recalc,
};
+static struct clk emul_ck = {
+ .name = "emul_ck",
+ .parent = &func_54m_ck,
+ .flags = CLOCK_IN_OMAP242X,
+ .enable_reg = (void __iomem *)&PRCM_CLKEMUL_CTRL,
+ .enable_bit = 0,
+ .recalc = &omap2_propagate_rate,
+
+};
+
/*
* MPU clock domain
* Clocks:
@@ -1702,7 +1698,8 @@ static struct clk hdq_fck = {
};
static struct clk i2c2_ick = {
- .name = "i2c2_ick",
+ .name = "i2c_ick",
+ .id = 2,
.parent = &l4_ck,
.flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
.enable_reg = (void __iomem *)&CM_ICLKEN1_CORE,
@@ -1711,7 +1708,8 @@ static struct clk i2c2_ick = {
};
static struct clk i2c2_fck = {
- .name = "i2c2_fck",
+ .name = "i2c_fck",
+ .id = 2,
.parent = &func_12m_ck,
.flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
.enable_reg = (void __iomem *)&CM_FCLKEN1_CORE,
@@ -1729,7 +1727,8 @@ static struct clk i2chs2_fck = {
};
static struct clk i2c1_ick = {
- .name = "i2c1_ick",
+ .name = "i2c_ick",
+ .id = 1,
.parent = &l4_ck,
.flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
.enable_reg = (void __iomem *)&CM_ICLKEN1_CORE,
@@ -1738,7 +1737,8 @@ static struct clk i2c1_ick = {
};
static struct clk i2c1_fck = {
- .name = "i2c1_fck",
+ .name = "i2c_fck",
+ .id = 1,
.parent = &func_12m_ck,
.flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
.enable_reg = (void __iomem *)&CM_FCLKEN1_CORE,
@@ -1971,6 +1971,7 @@ static struct clk *onchip_clks[] = {
&wdt1_osc_ck,
&sys_clkout,
&sys_clkout2,
+ &emul_ck,
/* mpu domain clocks */
&mpu_ck,
/* dsp domain clocks */
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 7181edb89352f..fb7f91da1aad1 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -25,10 +25,6 @@
#include <asm/arch/mux.h>
#include <asm/arch/gpio.h>
-extern void omap_nop_release(struct device *dev);
-
-/*-------------------------------------------------------------------------*/
-
#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
#define OMAP2_I2C_BASE2 0x48072000
@@ -49,9 +45,6 @@ static struct resource i2c_resources2[] = {
static struct platform_device omap_i2c_device2 = {
.name = "i2c_omap",
.id = 2,
- .dev = {
- .release = omap_nop_release,
- },
.num_resources = ARRAY_SIZE(i2c_resources2),
.resource = i2c_resources2,
};
@@ -74,6 +67,44 @@ static void omap_init_i2c(void) {}
#endif
+#if defined(CONFIG_OMAP_STI)
+
+#define OMAP2_STI_BASE IO_ADDRESS(0x48068000)
+#define OMAP2_STI_CHANNEL_BASE 0x54000000
+#define OMAP2_STI_IRQ 4
+
+static struct resource sti_resources[] = {
+ {
+ .start = OMAP2_STI_BASE,
+ .end = OMAP2_STI_BASE + 0x7ff,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = OMAP2_STI_CHANNEL_BASE,
+ .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = OMAP2_STI_IRQ,
+ .flags = IORESOURCE_IRQ,
+ }
+};
+
+static struct platform_device sti_device = {
+ .name = "sti",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(sti_resources),
+ .resource = sti_resources,
+};
+
+static inline void omap_init_sti(void)
+{
+ platform_device_register(&sti_device);
+}
+#else
+static inline void omap_init_sti(void) {}
+#endif
+
/*-------------------------------------------------------------------------*/
static int __init omap2_init_devices(void)
@@ -82,6 +113,7 @@ static int __init omap2_init_devices(void)
* in alphabetical order so they're easier to sort through.
*/
omap_init_i2c();
+ omap_init_sti();
return 0;
}
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 8ea67bf196a5e..7d5711611f2f4 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -16,9 +16,13 @@
#include <linux/kernel.h>
#include <linux/init.h>
-#include <asm/mach/map.h>
+#include <asm/tlb.h>
#include <asm/io.h>
+
+#include <asm/mach/map.h>
+
#include <asm/arch/mux.h>
+#include <asm/arch/omapfb.h>
extern void omap_sram_init(void);
extern int omap2_clk_init(void);
@@ -43,11 +47,24 @@ static struct map_desc omap2_io_desc[] __initdata = {
}
};
-void __init omap_map_common_io(void)
+void __init omap2_map_common_io(void)
{
iotable_init(omap2_io_desc, ARRAY_SIZE(omap2_io_desc));
+
+ /* Normally devicemaps_init() would flush caches and tlb after
+ * mdesc->map_io(), but we must also do it here because of the CPU
+ * revision check below.
+ */
+ local_flush_tlb_all();
+ flush_cache_all();
+
omap2_check_revision();
omap_sram_init();
+ omapfb_reserve_mem();
+}
+
+void __init omap2_init_common_hw(void)
+{
omap2_mux_init();
omap2_clk_init();
}
diff --git a/arch/arm/mach-omap2/memory.c b/arch/arm/mach-omap2/memory.c
new file mode 100644
index 0000000000000..1d925d69fc358
--- /dev/null
+++ b/arch/arm/mach-omap2/memory.c
@@ -0,0 +1,102 @@
+/*
+ * linux/arch/arm/mach-omap2/memory.c
+ *
+ * Memory timing related functions for OMAP24XX
+ *
+ * Copyright (C) 2005 Texas Instruments Inc.
+ * Richard Woodruff <r-woodruff2@ti.com>
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ * Tony Lindgren <tony@atomide.com>
+ *
+ * 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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+
+#include <asm/io.h>
+
+#include <asm/arch/clock.h>
+#include <asm/arch/sram.h>
+
+#include "prcm-regs.h"
+#include "memory.h"
+
+static struct memory_timings mem_timings;
+
+u32 omap2_memory_get_slow_dll_ctrl(void)
+{
+ return mem_timings.slow_dll_ctrl;
+}
+
+u32 omap2_memory_get_fast_dll_ctrl(void)
+{
+ return mem_timings.fast_dll_ctrl;
+}
+
+u32 omap2_memory_get_type(void)
+{
+ return mem_timings.m_type;
+}
+
+void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
+{
+ unsigned long dll_cnt;
+ u32 fast_dll = 0;
+
+ mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */
+
+ /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others.
+ * In the case of 2422, its ok to use CS1 instead of CS0.
+ */
+ if (cpu_is_omap2422())
+ mem_timings.base_cs = 1;
+ else
+ mem_timings.base_cs = 0;
+
+ if (mem_timings.m_type != M_DDR)
+ return;
+
+ /* With DDR we need to determine the low frequency DLL value */
+ if (((mem_timings.fast_dll_ctrl & (1 << 2)) == M_LOCK_CTRL))
+ mem_timings.dll_mode = M_UNLOCK;
+ else
+ mem_timings.dll_mode = M_LOCK;
+
+ if (mem_timings.base_cs == 0) {
+ fast_dll = SDRC_DLLA_CTRL;
+ dll_cnt = SDRC_DLLA_STATUS & 0xff00;
+ } else {
+ fast_dll = SDRC_DLLB_CTRL;
+ dll_cnt = SDRC_DLLB_STATUS & 0xff00;
+ }
+ if (force_lock_to_unlock_mode) {
+ fast_dll &= ~0xff00;
+ fast_dll |= dll_cnt; /* Current lock mode */
+ }
+ /* set fast timings with DLL filter disabled */
+ mem_timings.fast_dll_ctrl = (fast_dll | (3 << 8));
+
+ /* No disruptions, DDR will be offline & C-ABI not followed */
+ omap2_sram_ddr_init(&mem_timings.slow_dll_ctrl,
+ mem_timings.fast_dll_ctrl,
+ mem_timings.base_cs,
+ force_lock_to_unlock_mode);
+ mem_timings.slow_dll_ctrl &= 0xff00; /* Keep lock value */
+
+ /* Turn status into unlock ctrl */
+ mem_timings.slow_dll_ctrl |=
+ ((mem_timings.fast_dll_ctrl & 0xF) | (1 << 2));
+
+ /* 90 degree phase for anything below 133Mhz + disable DLL filter */
+ mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8));
+}
diff --git a/arch/arm/mach-omap2/memory.h b/arch/arm/mach-omap2/memory.h
new file mode 100644
index 0000000000000..d212eea83a051
--- /dev/null
+++ b/arch/arm/mach-omap2/memory.h
@@ -0,0 +1,34 @@
+/*
+ * linux/arch/arm/mach-omap2/memory.h
+ *
+ * Interface for memory timing related functions for OMAP24XX
+ *
+ * Copyright (C) 2005 Texas Instruments Inc.
+ * Richard Woodruff <r-woodruff2@ti.com>
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ * Tony Lindgren <tony@atomide.com>
+ *
+ * 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.
+ */
+
+/* Memory timings */
+#define M_DDR 1
+#define M_LOCK_CTRL (1 << 2)
+#define M_UNLOCK 0
+#define M_LOCK 1
+
+struct memory_timings {
+ u32 m_type; /* ddr = 1, sdr = 0 */
+ u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */
+ u32 slow_dll_ctrl; /* unlock mode, dll value for slow speed */
+ u32 fast_dll_ctrl; /* unlock mode, dll value for fast speed */
+ u32 base_cs; /* base chip select to use for calculations */
+};
+
+extern void omap2_init_memory_params(u32 force_lock_to_unlock_mode);
+extern u32 omap2_memory_get_slow_dll_ctrl(void);
+extern u32 omap2_memory_get_fast_dll_ctrl(void);
+extern u32 omap2_memory_get_type(void);
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index ea4654815dd1a..1197dc38c20af 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -50,9 +50,54 @@ MUX_CFG_24XX("H19_24XX_I2C2_SDA", 0x114, 0, 0, 0, 1)
/* Menelaus interrupt */
MUX_CFG_24XX("W19_24XX_SYS_NIRQ", 0x12c, 0, 1, 1, 1)
+/* 24xx clocks */
+MUX_CFG_24XX("W14_24XX_SYS_CLKOUT", 0x137, 0, 1, 1, 1)
+
+/* 24xx McBSP */
+MUX_CFG_24XX("Y15_24XX_MCBSP2_CLKX", 0x124, 1, 1, 0, 1)
+MUX_CFG_24XX("R14_24XX_MCBSP2_FSX", 0x125, 1, 1, 0, 1)
+MUX_CFG_24XX("W15_24XX_MCBSP2_DR", 0x126, 1, 1, 0, 1)
+MUX_CFG_24XX("V15_24XX_MCBSP2_DX", 0x127, 1, 1, 0, 1)
+
/* 24xx GPIO */
+MUX_CFG_24XX("M21_242X_GPIO11", 0x0c9, 3, 1, 1, 1)
+MUX_CFG_24XX("AA10_242X_GPIO13", 0x0e5, 3, 0, 0, 1)
+MUX_CFG_24XX("AA6_242X_GPIO14", 0x0e6, 3, 0, 0, 1)
+MUX_CFG_24XX("AA4_242X_GPIO15", 0x0e7, 3, 0, 0, 1)
+MUX_CFG_24XX("Y11_242X_GPIO16", 0x0e8, 3, 0, 0, 1)
+MUX_CFG_24XX("AA12_242X_GPIO17", 0x0e9, 3, 0, 0, 1)
+MUX_CFG_24XX("AA8_242X_GPIO58", 0x0ea, 3, 0, 0, 1)
MUX_CFG_24XX("Y20_24XX_GPIO60", 0x12c, 3, 0, 0, 1)
+MUX_CFG_24XX("W4__24XX_GPIO74", 0x0f2, 3, 0, 0, 1)
MUX_CFG_24XX("M15_24XX_GPIO92", 0x10a, 3, 0, 0, 1)
+MUX_CFG_24XX("V14_24XX_GPIO117", 0x128, 3, 1, 0, 1)
+
+/* TSC IRQ */
+MUX_CFG_24XX("P20_24XX_TSC_IRQ", 0x108, 0, 0, 0, 1)
+
+/* UART3 */
+MUX_CFG_24XX("K15_24XX_UART3_TX", 0x118, 0, 0, 0, 1)
+MUX_CFG_24XX("K14_24XX_UART3_RX", 0x119, 0, 0, 0, 1)
+
+/* Keypad GPIO*/
+MUX_CFG_24XX("T19_24XX_KBR0", 0x106, 3, 1, 1, 1)
+MUX_CFG_24XX("R19_24XX_KBR1", 0x107, 3, 1, 1, 1)
+MUX_CFG_24XX("V18_24XX_KBR2", 0x139, 3, 1, 1, 1)
+MUX_CFG_24XX("M21_24XX_KBR3", 0xc9, 3, 1, 1, 1)
+MUX_CFG_24XX("E5__24XX_KBR4", 0x138, 3, 1, 1, 1)
+MUX_CFG_24XX("M18_24XX_KBR5", 0x10e, 3, 1, 1, 1)
+MUX_CFG_24XX("R20_24XX_KBC0", 0x108, 3, 0, 0, 1)
+MUX_CFG_24XX("M14_24XX_KBC1", 0x109, 3, 0, 0, 1)
+MUX_CFG_24XX("H19_24XX_KBC2", 0x114, 3, 0, 0, 1)
+MUX_CFG_24XX("V17_24XX_KBC3", 0x135, 3, 0, 0, 1)
+MUX_CFG_24XX("P21_24XX_KBC4", 0xca, 3, 0, 0, 1)
+MUX_CFG_24XX("L14_24XX_KBC5", 0x10f, 3, 0, 0, 1)
+MUX_CFG_24XX("N19_24XX_KBC6", 0x110, 3, 0, 0, 1)
+
+/* 24xx Menelaus Keypad GPIO */
+MUX_CFG_24XX("B3__24XX_KBR5", 0x30, 3, 1, 1, 1)
+MUX_CFG_24XX("AA4_24XX_KBC2", 0xe7, 3, 0, 0, 1)
+MUX_CFG_24XX("B13_24XX_KBC6", 0x110, 3, 0, 0, 1)
};
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
new file mode 100644
index 0000000000000..562168fa2b163
--- /dev/null
+++ b/arch/arm/mach-omap2/pm.c
@@ -0,0 +1,149 @@
+/*
+ * linux/arch/arm/mach-omap2/pm.c
+ *
+ * OMAP2 Power Management Routines
+ *
+ * Copyright (C) 2006 Nokia Corporation
+ * Tony Lindgren <tony@atomide.com>
+ *
+ * Copyright (C) 2005 Texas Instruments, Inc.
+ * Richard Woodruff <r-woodruff2@ti.com>
+ *
+ * Based on pm.c for omap1
+ *
+ * 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.
+ */
+
+#include <linux/pm.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+#include <linux/pm.h>
+#include <linux/interrupt.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/atomic.h>
+#include <asm/mach/time.h>
+#include <asm/mach/irq.h>
+#include <asm/mach-types.h>
+
+#include <asm/arch/irqs.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/sram.h>
+#include <asm/arch/pm.h>
+
+static struct clk *vclk;
+static void (*omap2_sram_idle)(void);
+static void (*omap2_sram_suspend)(int dllctrl, int cpu_rev);
+static void (*saved_idle)(void);
+
+void omap2_pm_idle(void)
+{
+ local_irq_disable();
+ local_fiq_disable();
+ if (need_resched()) {
+ local_fiq_enable();
+ local_irq_enable();
+ return;
+ }
+
+ /*
+ * Since an interrupt may set up a timer, we don't want to
+ * reprogram the hardware timer with interrupts enabled.
+ * Re-enable interrupts only after returning from idle.
+ */
+ timer_dyn_reprogram();
+
+ omap2_sram_idle();
+ local_fiq_enable();
+ local_irq_enable();
+}
+
+static int omap2_pm_prepare(suspend_state_t state)
+{
+ int error = 0;
+
+ /* We cannot sleep in idle until we have resumed */
+ saved_idle = pm_idle;
+ pm_idle = NULL;
+
+ switch (state)
+ {
+ case PM_SUSPEND_STANDBY:
+ case PM_SUSPEND_MEM:
+ break;
+
+ case PM_SUSPEND_DISK:
+ return -ENOTSUPP;
+
+ default:
+ return -EINVAL;
+ }
+
+ return error;
+}
+
+static int omap2_pm_enter(suspend_state_t state)
+{
+ switch (state)
+ {
+ case PM_SUSPEND_STANDBY:
+ case PM_SUSPEND_MEM:
+ /* FIXME: Add suspend */
+ break;
+
+ case PM_SUSPEND_DISK:
+ return -ENOTSUPP;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int omap2_pm_finish(suspend_state_t state)
+{
+ pm_idle = saved_idle;
+ return 0;
+}
+
+static struct pm_ops omap_pm_ops = {
+ .pm_disk_mode = 0,
+ .prepare = omap2_pm_prepare,
+ .enter = omap2_pm_enter,
+ .finish = omap2_pm_finish,
+};
+
+int __init omap2_pm_init(void)
+{
+ printk("Power Management for TI OMAP.\n");
+
+ vclk = clk_get(NULL, "virt_prcm_set");
+ if (IS_ERR(vclk)) {
+ printk(KERN_ERR "Could not get PM vclk\n");
+ return -ENODEV;
+ }
+
+ /*
+ * We copy the assembler sleep/wakeup routines to SRAM.
+ * These routines need to be in SRAM as that's the only
+ * memory the MPU can see when it wakes up.
+ */
+ omap2_sram_idle = omap_sram_push(omap24xx_idle_loop_suspend,
+ omap24xx_idle_loop_suspend_sz);
+
+ omap2_sram_suspend = omap_sram_push(omap24xx_cpu_suspend,
+ omap24xx_cpu_suspend_sz);
+
+ pm_set_ops(&omap_pm_ops);
+ pm_idle = omap2_pm_idle;
+
+ return 0;
+}
+
+__initcall(omap2_pm_init);
diff --git a/arch/arm/mach-omap2/prcm.h b/arch/arm/mach-omap2/prcm-regs.h
index 2eb89b936c83f..22ac7be4f7828 100644
--- a/arch/arm/mach-omap2/prcm.h
+++ b/arch/arm/mach-omap2/prcm-regs.h
@@ -1,5 +1,7 @@
/*
- * prcm.h - Access definations for use in OMAP24XX clock and power management
+ * linux/arch/arm/mach-omap2/prcm-reg.h
+ *
+ * OMAP24XX Power Reset and Clock Management (PRCM) registers
*
* Copyright (C) 2005 Texas Instruments, Inc.
*
@@ -18,8 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef __ASM_ARM_ARCH_DPM_PRCM_H
-#define __ASM_ARM_ARCH_DPM_PRCM_H
+#ifndef __ARCH_ARM_MACH_OMAP2_PRCM_H
+#define __ARCH_ARM_MACH_OMAP2_PRCM_H
/* SET_PERFORMANCE_LEVEL PARAMETERS */
#define PRCM_HALF_SPEED 1
@@ -159,54 +161,63 @@
#define CM_FCLKEN_MDM PRCM_REG32(0xC00)
#define CM_ICLKEN_MDM PRCM_REG32(0xC10)
#define CM_IDLEST_MDM PRCM_REG32(0xC20)
+#define CM_AUTOIDLE_MDM PRCM_REG32(0xC30)
#define CM_CLKSEL_MDM PRCM_REG32(0xC40)
-
-/* FIXME: Move to header for 2430 */
-#define DISP_BASE (OMAP24XX_L4_IO_BASE+0x50000)
+#define CM_CLKSTCTRL_MDM PRCM_REG32(0xC48)
+#define RM_RSTCTRL_MDM PRCM_REG32(0xC50)
+#define RM_RSTST_MDM PRCM_REG32(0xC58)
+#define PM_WKEN_MDM PRCM_REG32(0xCA0)
+#define PM_WKST_MDM PRCM_REG32(0xCB0)
+#define PM_WKDEP_MDM PRCM_REG32(0xCC8)
+#define PM_PWSTCTRL_MDM PRCM_REG32(0xCE0)
+#define PM_PWSTST_MDM PRCM_REG32(0xCE4)
+
+#define OMAP24XX_L4_IO_BASE 0x48000000
+
+#define DISP_BASE (OMAP24XX_L4_IO_BASE + 0x50000)
#define DISP_REG32(offset) __REG32(DISP_BASE + (offset))
-#define GPMC_BASE (OMAP24XX_GPMC_BASE)
-#define GPMC_REG32(offset) __REG32(GPMC_BASE + (offset))
+#define OMAP24XX_GPMC_BASE (L3_24XX_BASE + 0xa000)
+#define GPMC_REG32(offset) __REG32(OMAP24XX_GPMC_BASE + (offset))
-#define GPT1_BASE (OMAP24XX_GPT1)
+/* FIXME: Move these to timer code */
+#define GPT1_BASE (0x48028000)
#define GPT1_REG32(offset) __REG32(GPT1_BASE + (offset))
/* Misc sysconfig */
#define DISPC_SYSCONFIG DISP_REG32(0x410)
-#define SPI_BASE (OMAP24XX_L4_IO_BASE+0x98000)
+#define SPI_BASE (OMAP24XX_L4_IO_BASE + 0x98000)
#define MCSPI1_SYSCONFIG __REG32(SPI_BASE + 0x10)
-#define MCSPI2_SYSCONFIG __REG32(SPI_BASE+0x2000 + 0x10)
-
-//#define DSP_MMU_SYSCONFIG 0x5A000010
-#define CAMERA_MMU_SYSCONFIG __REG32(DISP_BASE+0x2C10)
-//#define IVA_MMU_SYSCONFIG 0x5D000010
-//#define DSP_DMA_SYSCONFIG 0x00FCC02C
-#define CAMERA_DMA_SYSCONFIG __REG32(DISP_BASE+0x282C)
-#define SYSTEM_DMA_SYSCONFIG __REG32(DISP_BASE+0x602C)
+#define MCSPI2_SYSCONFIG __REG32(SPI_BASE + 0x2000 + 0x10)
+#define MCSPI3_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE + 0xb8010)
+
+#define CAMERA_MMU_SYSCONFIG __REG32(DISP_BASE + 0x2C10)
+#define CAMERA_DMA_SYSCONFIG __REG32(DISP_BASE + 0x282C)
+#define SYSTEM_DMA_SYSCONFIG __REG32(DISP_BASE + 0x602C)
#define GPMC_SYSCONFIG GPMC_REG32(0x010)
-#define MAILBOXES_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x94010)
-#define UART1_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x6A054)
-#define UART2_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x6C054)
-#define UART3_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x6E054)
-//#define IVA_SYSCONFIG 0x5C060010
-#define SDRC_SYSCONFIG __REG32(OMAP24XX_SDRC_BASE+0x10)
-#define SMS_SYSCONFIG __REG32(OMAP24XX_SMS_BASE+0x10)
-#define SSI_SYSCONFIG __REG32(DISP_BASE+0x8010)
-//#define VLYNQ_SYSCONFIG 0x67FFFE10
+#define MAILBOXES_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE + 0x94010)
+#define UART1_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE + 0x6A054)
+#define UART2_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE + 0x6C054)
+#define UART3_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE + 0x6E054)
+#define SDRC_SYSCONFIG __REG32(OMAP24XX_SDRC_BASE + 0x10)
+#define OMAP24XX_SMS_BASE (L3_24XX_BASE + 0x8000)
+#define SMS_SYSCONFIG __REG32(OMAP24XX_SMS_BASE + 0x10)
+#define SSI_SYSCONFIG __REG32(DISP_BASE + 0x8010)
/* rkw - good cannidates for PM_ to start what nm was trying */
-#define OMAP24XX_GPT2 (OMAP24XX_L4_IO_BASE+0x2A000)
-#define OMAP24XX_GPT3 (OMAP24XX_L4_IO_BASE+0x78000)
-#define OMAP24XX_GPT4 (OMAP24XX_L4_IO_BASE+0x7A000)
-#define OMAP24XX_GPT5 (OMAP24XX_L4_IO_BASE+0x7C000)
-#define OMAP24XX_GPT6 (OMAP24XX_L4_IO_BASE+0x7E000)
-#define OMAP24XX_GPT7 (OMAP24XX_L4_IO_BASE+0x80000)
-#define OMAP24XX_GPT8 (OMAP24XX_L4_IO_BASE+0x82000)
-#define OMAP24XX_GPT9 (OMAP24XX_L4_IO_BASE+0x84000)
-#define OMAP24XX_GPT10 (OMAP24XX_L4_IO_BASE+0x86000)
-#define OMAP24XX_GPT11 (OMAP24XX_L4_IO_BASE+0x88000)
-#define OMAP24XX_GPT12 (OMAP24XX_L4_IO_BASE+0x8A000)
-
+#define OMAP24XX_GPT2 (OMAP24XX_L4_IO_BASE + 0x2A000)
+#define OMAP24XX_GPT3 (OMAP24XX_L4_IO_BASE + 0x78000)
+#define OMAP24XX_GPT4 (OMAP24XX_L4_IO_BASE + 0x7A000)
+#define OMAP24XX_GPT5 (OMAP24XX_L4_IO_BASE + 0x7C000)
+#define OMAP24XX_GPT6 (OMAP24XX_L4_IO_BASE + 0x7E000)
+#define OMAP24XX_GPT7 (OMAP24XX_L4_IO_BASE + 0x80000)
+#define OMAP24XX_GPT8 (OMAP24XX_L4_IO_BASE + 0x82000)
+#define OMAP24XX_GPT9 (OMAP24XX_L4_IO_BASE + 0x84000)
+#define OMAP24XX_GPT10 (OMAP24XX_L4_IO_BASE + 0x86000)
+#define OMAP24XX_GPT11 (OMAP24XX_L4_IO_BASE + 0x88000)
+#define OMAP24XX_GPT12 (OMAP24XX_L4_IO_BASE + 0x8A000)
+
+/* FIXME: Move these to timer code */
#define GPTIMER1_SYSCONFIG GPT1_REG32(0x010)
#define GPTIMER2_SYSCONFIG __REG32(OMAP24XX_GPT2 + 0x10)
#define GPTIMER3_SYSCONFIG __REG32(OMAP24XX_GPT3 + 0x10)
@@ -220,12 +231,18 @@
#define GPTIMER11_SYSCONFIG __REG32(OMAP24XX_GPT11 + 0x10)
#define GPTIMER12_SYSCONFIG __REG32(OMAP24XX_GPT12 + 0x10)
-#define GPIOX_BASE(X) (OMAP24XX_GPIO_BASE+(0x2000*((X)-1)))
+/* FIXME: Move these to gpio code */
+#define OMAP24XX_GPIO_BASE 0x48018000
+#define GPIOX_BASE(X) (OMAP24XX_GPIO_BASE + (0x2000 * ((X) - 1)))
+
+#define GPIO1_SYSCONFIG __REG32((GPIOX_BASE(1) + 0x10))
+#define GPIO2_SYSCONFIG __REG32((GPIOX_BASE(2) + 0x10))
+#define GPIO3_SYSCONFIG __REG32((GPIOX_BASE(3) + 0x10))
+#define GPIO4_SYSCONFIG __REG32((GPIOX_BASE(4) + 0x10))
-#define GPIO1_SYSCONFIG __REG32((GPIOX_BASE(1)+0x10))
-#define GPIO2_SYSCONFIG __REG32((GPIOX_BASE(2)+0x10))
-#define GPIO3_SYSCONFIG __REG32((GPIOX_BASE(3)+0x10))
-#define GPIO4_SYSCONFIG __REG32((GPIOX_BASE(4)+0x10))
+#if defined(CONFIG_ARCH_OMAP243X)
+#define GPIO5_SYSCONFIG __REG32((OMAP24XX_GPIO5_BASE + 0x10))
+#endif
/* GP TIMER 1 */
#define GPTIMER1_TISTAT GPT1_REG32(0x014)
@@ -243,15 +260,15 @@
#define GPTIMER1_TCAR2 GPT1_REG32(0x044)
/* rkw -- base fix up please... */
-#define GPTIMER3_TISR __REG32(OMAP24XX_L4_IO_BASE+0x78018)
+#define GPTIMER3_TISR __REG32(OMAP24XX_L4_IO_BASE + 0x78018)
/* SDRC */
-#define SDRC_DLLA_CTRL __REG32(OMAP24XX_SDRC_BASE+0x060)
-#define SDRC_DLLA_STATUS __REG32(OMAP24XX_SDRC_BASE+0x064)
-#define SDRC_DLLB_CTRL __REG32(OMAP24XX_SDRC_BASE+0x068)
-#define SDRC_DLLB_STATUS __REG32(OMAP24XX_SDRC_BASE+0x06C)
-#define SDRC_POWER __REG32(OMAP24XX_SDRC_BASE+0x070)
-#define SDRC_MR_0 __REG32(OMAP24XX_SDRC_BASE+0x084)
+#define SDRC_DLLA_CTRL __REG32(OMAP24XX_SDRC_BASE + 0x060)
+#define SDRC_DLLA_STATUS __REG32(OMAP24XX_SDRC_BASE + 0x064)
+#define SDRC_DLLB_CTRL __REG32(OMAP24XX_SDRC_BASE + 0x068)
+#define SDRC_DLLB_STATUS __REG32(OMAP24XX_SDRC_BASE + 0x06C)
+#define SDRC_POWER __REG32(OMAP24XX_SDRC_BASE + 0x070)
+#define SDRC_MR_0 __REG32(OMAP24XX_SDRC_BASE + 0x084)
/* GPIO 1 */
#define GPIO1_BASE GPIOX_BASE(1)
@@ -278,6 +295,8 @@
#define GPIO2_DATAIN GPIO2_REG32(0x038)
#define GPIO2_OE GPIO2_REG32(0x034)
#define GPIO2_DATAOUT GPIO2_REG32(0x03C)
+#define GPIO2_DEBOUNCENABLE GPIO2_REG32(0x050)
+#define GPIO2_DEBOUNCINGTIME GPIO2_REG32(0x054)
/* GPIO 3 */
#define GPIO3_BASE GPIOX_BASE(3)
@@ -294,6 +313,8 @@
#define GPIO3_DATAOUT GPIO3_REG32(0x03C)
#define GPIO3_DEBOUNCENABLE GPIO3_REG32(0x050)
#define GPIO3_DEBOUNCINGTIME GPIO3_REG32(0x054)
+#define GPIO3_DEBOUNCENABLE GPIO3_REG32(0x050)
+#define GPIO3_DEBOUNCINGTIME GPIO3_REG32(0x054)
/* GPIO 4 */
#define GPIO4_BASE GPIOX_BASE(4)
@@ -311,10 +332,26 @@
#define GPIO4_DEBOUNCENABLE GPIO4_REG32(0x050)
#define GPIO4_DEBOUNCINGTIME GPIO4_REG32(0x054)
+#if defined(CONFIG_ARCH_OMAP243X)
+/* GPIO 5 */
+#define GPIO5_REG32(offset) __REG32((OMAP24XX_GPIO5_BASE + (offset)))
+#define GPIO5_IRQENABLE1 GPIO5_REG32(0x01C)
+#define GPIO5_IRQSTATUS1 GPIO5_REG32(0x018)
+#define GPIO5_IRQENABLE2 GPIO5_REG32(0x02C)
+#define GPIO5_IRQSTATUS2 GPIO5_REG32(0x028)
+#define GPIO5_WAKEUPENABLE GPIO5_REG32(0x020)
+#define GPIO5_RISINGDETECT GPIO5_REG32(0x048)
+#define GPIO5_FALLINGDETECT GPIO5_REG32(0x04C)
+#define GPIO5_DATAIN GPIO5_REG32(0x038)
+#define GPIO5_OE GPIO5_REG32(0x034)
+#define GPIO5_DATAOUT GPIO5_REG32(0x03C)
+#define GPIO5_DEBOUNCENABLE GPIO5_REG32(0x050)
+#define GPIO5_DEBOUNCINGTIME GPIO5_REG32(0x054)
+#endif
/* IO CONFIG */
-#define CONTROL_BASE (OMAP24XX_CTRL_BASE)
-#define CONTROL_REG32(offset) __REG32(CONTROL_BASE + (offset))
+#define OMAP24XX_CTRL_BASE (L4_24XX_BASE)
+#define CONTROL_REG32(offset) __REG32(OMAP24XX_CTRL_BASE + (offset))
#define CONTROL_PADCONF_SPI1_NCS2 CONTROL_REG32(0x104)
#define CONTROL_PADCONF_SYS_XTALOUT CONTROL_REG32(0x134)
@@ -322,15 +359,18 @@
#define CONTROL_PADCONF_MCBSP1_DX CONTROL_REG32(0x10C)
#define CONTROL_PADCONF_GPMC_NCS4 CONTROL_REG32(0x090)
#define CONTROL_PADCONF_DSS_D5 CONTROL_REG32(0x0B8)
-#define CONTROL_PADCONF_DSS_D9 CONTROL_REG32(0x0BC)
+#define CONTROL_PADCONF_DSS_D9 CONTROL_REG32(0x0BC) /* 2420 */
#define CONTROL_PADCONF_DSS_D13 CONTROL_REG32(0x0C0)
#define CONTROL_PADCONF_DSS_VSYNC CONTROL_REG32(0x0CC)
+#define CONTROL_PADCONF_SYS_NIRQW0 CONTROL_REG32(0x0BC) /* 2430 */
+#define CONTROL_PADCONF_SSI1_FLAG_TX CONTROL_REG32(0x108) /* 2430 */
/* CONTROL */
#define CONTROL_DEVCONF CONTROL_REG32(0x274)
+#define CONTROL_DEVCONF1 CONTROL_REG32(0x2E8)
/* INTERRUPT CONTROLLER */
-#define INTC_BASE (OMAP24XX_L4_IO_BASE+0xfe000)
+#define INTC_BASE ((L4_24XX_BASE) + 0xfe000)
#define INTC_REG32(offset) __REG32(INTC_BASE + (offset))
#define INTC1_U_BASE INTC_REG32(0x000)
@@ -348,10 +388,12 @@
#define INTC_ISR_CLEAR2 INTC_REG32(0x0D4)
#define INTC_SIR_IRQ INTC_REG32(0x040)
#define INTC_CONTROL INTC_REG32(0x048)
-#define INTC_ILR11 INTC_REG32(0x12C)
+#define INTC_ILR11 INTC_REG32(0x12C) /* PRCM on MPU PIC */
+#define INTC_ILR30 INTC_REG32(0x178)
+#define INTC_ILR31 INTC_REG32(0x17C)
#define INTC_ILR32 INTC_REG32(0x180)
-#define INTC_ILR37 INTC_REG32(0x194)
-#define INTC_SYSCONFIG INTC_REG32(0x010)
+#define INTC_ILR37 INTC_REG32(0x194) /* GPIO4 on MPU PIC */
+#define INTC_SYSCONFIG INTC_REG32(0x010) /* GPT1 on MPU PIC */
/* RAM FIREWALL */
#define RAMFW_BASE (0x68005000)
@@ -373,6 +415,24 @@
#define GPMC_CONFIG6_0 GPMC_REG32(0x074)
#define GPMC_CONFIG7_0 GPMC_REG32(0x078)
+/* GPMC CS1 */
+#define GPMC_CONFIG1_1 GPMC_REG32(0x090)
+#define GPMC_CONFIG2_1 GPMC_REG32(0x094)
+#define GPMC_CONFIG3_1 GPMC_REG32(0x098)
+#define GPMC_CONFIG4_1 GPMC_REG32(0x09C)
+#define GPMC_CONFIG5_1 GPMC_REG32(0x0a0)
+#define GPMC_CONFIG6_1 GPMC_REG32(0x0a4)
+#define GPMC_CONFIG7_1 GPMC_REG32(0x0a8)
+
+/* GPMC CS3 */
+#define GPMC_CONFIG1_3 GPMC_REG32(0x0F0)
+#define GPMC_CONFIG2_3 GPMC_REG32(0x0F4)
+#define GPMC_CONFIG3_3 GPMC_REG32(0x0F8)
+#define GPMC_CONFIG4_3 GPMC_REG32(0x0FC)
+#define GPMC_CONFIG5_3 GPMC_REG32(0x100)
+#define GPMC_CONFIG6_3 GPMC_REG32(0x104)
+#define GPMC_CONFIG7_3 GPMC_REG32(0x108)
+
/* DSS */
#define DSS_CONTROL DISP_REG32(0x040)
#define DISPC_CONTROL DISP_REG32(0x440)
@@ -405,11 +465,15 @@
#define DISPC_DATA_CYCLE2 DISP_REG32(0x5D8)
#define DISPC_DATA_CYCLE3 DISP_REG32(0x5DC)
-/* Wake up define for board */
-#define GPIO97 (1 << 1)
-#define GPIO88 (1 << 24)
+/* HSUSB Suspend */
+#define HSUSB_CTRL __REG8(0x480AC001)
+#define USBOTG_POWER __REG32(0x480AC000)
+
+/* HS MMC */
+#define MMCHS1_SYSCONFIG __REG32(0x4809C010)
+#define MMCHS2_SYSCONFIG __REG32(0x480b4010)
-#endif /* __ASSEMBLER__ */
+#endif /* __ASSEMBLER__ */
#endif
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c
new file mode 100644
index 0000000000000..8893479dc7e02
--- /dev/null
+++ b/arch/arm/mach-omap2/prcm.c
@@ -0,0 +1,40 @@
+/*
+ * linux/arch/arm/mach-omap2/prcm.c
+ *
+ * OMAP 24xx Power Reset and Clock Management (PRCM) functions
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ *
+ * Written by Tony Lindgren <tony.lindgren@nokia.com>
+ *
+ * Some pieces of code Copyright (C) 2005 Texas Instruments, Inc.
+ *
+ * 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.
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+
+#include "prcm-regs.h"
+
+u32 omap_prcm_get_reset_sources(void)
+{
+ return RM_RSTST_WKUP & 0x7f;
+}
+EXPORT_SYMBOL(omap_prcm_get_reset_sources);
+
+/* Resets clock rates and reboots the system. Only called from system.h */
+void omap_prcm_arch_reset(char mode)
+{
+ u32 rate;
+ struct clk *vclk, *sclk;
+
+ vclk = clk_get(NULL, "virt_prcm_set");
+ sclk = clk_get(NULL, "sys_ck");
+ rate = clk_get_rate(sclk);
+ clk_set_rate(vclk, rate); /* go to bypass for OMAP limitation */
+ RM_RSTCTRL_WKUP |= 2;
+}
diff --git a/arch/arm/mach-omap2/sleep.S b/arch/arm/mach-omap2/sleep.S
new file mode 100644
index 0000000000000..00299cbeb9111
--- /dev/null
+++ b/arch/arm/mach-omap2/sleep.S
@@ -0,0 +1,144 @@
+/*
+ * linux/arch/arm/mach-omap2/sleep.S
+ *
+ * (C) Copyright 2004
+ * Texas Instruments, <www.ti.com>
+ * Richard Woodruff <r-woodruff2@ti.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.
+ *
+ * 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 <linux/config.h>
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/arch/io.h>
+#include <asm/arch/pm.h>
+
+#define A_32KSYNC_CR_V IO_ADDRESS(OMAP_TIMER32K_BASE+0x10)
+#define A_PRCM_VOLTCTRL_V IO_ADDRESS(OMAP24XX_PRCM_BASE+0x50)
+#define A_PRCM_CLKCFG_CTRL_V IO_ADDRESS(OMAP24XX_PRCM_BASE+0x80)
+#define A_CM_CLKEN_PLL_V IO_ADDRESS(OMAP24XX_PRCM_BASE+0x500)
+#define A_CM_IDLEST_CKGEN_V IO_ADDRESS(OMAP24XX_PRCM_BASE+0x520)
+#define A_CM_CLKSEL1_PLL_V IO_ADDRESS(OMAP24XX_PRCM_BASE+0x540)
+#define A_CM_CLKSEL2_PLL_V IO_ADDRESS(OMAP24XX_PRCM_BASE+0x544)
+
+#define A_SDRC_DLLA_CTRL_V IO_ADDRESS(OMAP24XX_SDRC_BASE+0x60)
+#define A_SDRC_POWER_V IO_ADDRESS(OMAP24XX_SDRC_BASE+0x70)
+#define A_SDRC_RFR_CTRL_V IO_ADDRESS(OMAP24XX_SDRC_BASE+0xA4)
+#define A_SDRC0_V (0xC0000000)
+#define A_SDRC_MANUAL_V IO_ADDRESS(OMAP24XX_SDRC_BASE+0xA8)
+
+ .text
+
+/*
+ * Forces OMAP into idle state
+ *
+ * omap24xx_idle_loop_suspend() - This bit of code just executes the WFI
+ * for normal idles.
+ *
+ * Note: This code get's copied to internal SRAM at boot. When the OMAP
+ * wakes up it continues execution at the point it went to sleep.
+ */
+ENTRY(omap24xx_idle_loop_suspend)
+ stmfd sp!, {r0, lr} @ save registers on stack
+ mov r0, #0 @ clear for mcr setup
+ mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
+ ldmfd sp!, {r0, pc} @ restore regs and return
+
+ENTRY(omap24xx_idle_loop_suspend_sz)
+ .word . - omap24xx_idle_loop_suspend
+
+/*
+ * omap242x_cpu_suspend() - Forces OMAP into deep sleep state by completing
+ * SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore
+ * SDRC.
+ *
+ * Input:
+ * R0 : DLL ctrl value pre-Sleep
+ * R1 : Processor+Revision
+ * 2420: 0x21 = 242xES1, 0x26 = 242xES2.2
+ * 2430: 0x31 = 2430ES1, 0x32 = 2430ES2
+ *
+ * The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on
+ * when we get called, but the DLL probably isn't. We will wait a bit more in
+ * case the DPLL isn't quite there yet. The code will wait on DLL for DDR even
+ * if in unlocked mode.
+ *
+ * For less than 242x-ES2.2 upon wake from a sleep mode where the external
+ * oscillator was stopped, a timing bug exists where a non-stabilized 12MHz
+ * clock can pass into the PRCM can cause problems at DSP and IVA.
+ * To work around this the code will switch to the 32kHz source prior to sleep.
+ * Post sleep we will shift back to using the DPLL. Apparently,
+ * CM_IDLEST_CLKGEN does not reflect the full clock change so you need to wait
+ * 3x12MHz + 3x32kHz clocks for a full switch.
+ *
+ * The DLL load value is not kept in RETENTION or OFF. It needs to be restored
+ * at wake
+ */
+ENTRY(omap24xx_cpu_suspend)
+ stmfd sp!, {r0 - r12, lr} @ save registers on stack
+ mov r3, #0x0 @ clear for mrc call
+ mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished
+ nop
+ nop
+ ldr r3, A_SDRC_POWER @ addr of sdrc power
+ ldr r4, [r3] @ value of sdrc power
+ orr r4, r4, #0x40 @ enable self refresh on idle req
+ mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
+ str r4, [r3] @ make it so
+ mov r2, #0
+ nop
+ mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
+ nop
+loop:
+ subs r5, r5, #0x1 @ awake, wait just a bit
+ bne loop
+
+ /* The DPLL has on before we take the DDR out of self refresh */
+ bic r4, r4, #0x40 @ now clear self refresh bit.
+ str r4, [r3] @ put vlaue back.
+ ldr r4, A_SDRC0 @ make a clock happen
+ ldr r4, [r4]
+ nop @ start auto refresh only after clk ok
+ movs r0, r0 @ see if DDR or SDR
+ ldrne r1, A_SDRC_DLLA_CTRL_S @ get addr of DLL ctrl
+ strne r0, [r1] @ rewrite DLLA to force DLL reload
+ addne r1, r1, #0x8 @ move to DLLB
+ strne r0, [r1] @ rewrite DLLB to force DLL reload
+
+ mov r5, #0x1000
+loop2:
+ subs r5, r5, #0x1
+ bne loop2
+ /* resume*/
+ ldmfd sp!, {r0 - r12, pc} @ restore regs and return
+
+A_SDRC_POWER:
+ .word A_SDRC_POWER_V
+A_SDRC0:
+ .word A_SDRC0_V
+A_CM_CLKSEL2_PLL_S:
+ .word A_CM_CLKSEL2_PLL_V
+A_CM_CLKEN_PLL:
+ .word A_CM_CLKEN_PLL_V
+A_SDRC_DLLA_CTRL_S:
+ .word A_SDRC_DLLA_CTRL_V
+A_SDRC_MANUAL_S:
+ .word A_SDRC_MANUAL_V
+
+ENTRY(omap24xx_cpu_suspend_sz)
+ .word . - omap24xx_cpu_suspend
+
diff --git a/arch/arm/mach-omap2/sram-fn.S b/arch/arm/mach-omap2/sram-fn.S
index 2a869e203342b..d261e4ff4d9b3 100644
--- a/arch/arm/mach-omap2/sram-fn.S
+++ b/arch/arm/mach-omap2/sram-fn.S
@@ -1,5 +1,5 @@
/*
- * linux/arch/arm/mach-omap1/sram.S
+ * linux/arch/arm/mach-omap2/sram.S
*
* Omap2 specific functions that need to be run in internal SRAM
*
@@ -28,7 +28,7 @@
#include <asm/arch/io.h>
#include <asm/hardware.h>
-#include <asm/arch/prcm.h>
+#include "prcm-regs.h"
#define TIMER_32KSYNCT_CR_V IO_ADDRESS(OMAP24XX_32KSYNCT_BASE + 0x010)
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index b45560a8f6c4d..a042473deeddf 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -307,6 +307,10 @@ static void __init fixup_poodle(struct machine_desc *desc,
struct tag *tags, char **cmdline, struct meminfo *mi)
{
sharpsl_save_param();
+ mi->nr_banks=1;
+ mi->bank[0].start = 0xa0000000;
+ mi->bank[0].node = 0;
+ mi->bank[0].size = (32*1024*1024);
}
MACHINE_START(POODLE, "SHARP Poodle")
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index ed07c4149d823..ce7d81000695e 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -50,9 +50,15 @@ config MACH_N30
<http://zoo.weinigel.se/n30>.
+config MACH_SMDK
+ bool
+ help
+ Common machine code for SMDK2410 and SMDK2440
+
config ARCH_SMDK2410
bool "SMDK2410/A9M2410"
select CPU_S3C2410
+ select MACH_SMDK
help
Say Y here if you are using the SMDK2410 or the derived module A9M2410
<http://www.fsforth.de>
@@ -60,6 +66,7 @@ config ARCH_SMDK2410
config ARCH_S3C2440
bool "SMDK2440"
select CPU_S3C2440
+ select MACH_SMDK
help
Say Y here if you are using the SMDK2440.
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index 1b3b476e56370..3e5712db6b52a 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -48,3 +48,5 @@ obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o usb-simtec.o
obj-$(CONFIG_MACH_RX3715) += mach-rx3715.o
obj-$(CONFIG_MACH_OTOM) += mach-otom.o
obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o
+
+obj-$(CONFIG_MACH_SMDK) += common-smdk.o \ No newline at end of file
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index fec02c92f95f4..6de713ad319a1 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -249,7 +249,7 @@ static int s3c24xx_upll_enable(struct clk *clk, int enable)
/* if we started the UPLL, then allow to settle */
- if (enable && !(orig & S3C2410_CLKSLOW_UCLK_OFF))
+ if (enable && (orig & S3C2410_CLKSLOW_UCLK_OFF))
udelay(200);
return 0;
@@ -367,6 +367,8 @@ static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
source = S3C2410_MISCCR_CLK0_UPLL;
else if (parent == &clk_f)
source = S3C2410_MISCCR_CLK0_FCLK;
+ else if (parent == &clk_h)
+ source = S3C2410_MISCCR_CLK0_HCLK;
else if (parent == &clk_p)
source = S3C2410_MISCCR_CLK0_PCLK;
else if (clk == &s3c24xx_clkout0 && parent == &s3c24xx_dclk0)
@@ -376,6 +378,8 @@ static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
else
return -EINVAL;
+ clk->parent = parent;
+
if (clk == &s3c24xx_dclk0)
mask = S3C2410_MISCCR_CLK0_MASK;
else {
diff --git a/arch/arm/mach-s3c2410/common-smdk.c b/arch/arm/mach-s3c2410/common-smdk.c
new file mode 100644
index 0000000000000..f372fbda124e1
--- /dev/null
+++ b/arch/arm/mach-s3c2410/common-smdk.c
@@ -0,0 +1,135 @@
+/* linux/arch/arm/mach-s3c2410/common-smdk.c
+ *
+ * Copyright (c) 2006 Simtec Electronics
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * Common code for SMDK2410 and SMDK2440 boards
+ *
+ * http://www.fluff.org/ben/smdk2440/
+ *
+ * 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.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand_ecc.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#include <asm/arch/regs-gpio.h>
+
+#include <asm/arch/nand.h>
+
+#include "common-smdk.h"
+#include "devs.h"
+#include "pm.h"
+
+/* NAND parititon from 2.4.18-swl5 */
+
+static struct mtd_partition smdk_default_nand_part[] = {
+ [0] = {
+ .name = "Boot Agent",
+ .size = SZ_16K,
+ .offset = 0,
+ },
+ [1] = {
+ .name = "S3C2410 flash parition 1",
+ .offset = 0,
+ .size = SZ_2M,
+ },
+ [2] = {
+ .name = "S3C2410 flash partition 2",
+ .offset = SZ_4M,
+ .size = SZ_4M,
+ },
+ [3] = {
+ .name = "S3C2410 flash partition 3",
+ .offset = SZ_8M,
+ .size = SZ_2M,
+ },
+ [4] = {
+ .name = "S3C2410 flash partition 4",
+ .offset = SZ_1M * 10,
+ .size = SZ_4M,
+ },
+ [5] = {
+ .name = "S3C2410 flash partition 5",
+ .offset = SZ_1M * 14,
+ .size = SZ_1M * 10,
+ },
+ [6] = {
+ .name = "S3C2410 flash partition 6",
+ .offset = SZ_1M * 24,
+ .size = SZ_1M * 24,
+ },
+ [7] = {
+ .name = "S3C2410 flash partition 7",
+ .offset = SZ_1M * 48,
+ .size = SZ_16M,
+ }
+};
+
+static struct s3c2410_nand_set smdk_nand_sets[] = {
+ [0] = {
+ .name = "NAND",
+ .nr_chips = 1,
+ .nr_partitions = ARRAY_SIZE(smdk_default_nand_part),
+ .partitions = smdk_default_nand_part,
+ },
+};
+
+/* choose a set of timings which should suit most 512Mbit
+ * chips and beyond.
+*/
+
+static struct s3c2410_platform_nand smdk_nand_info = {
+ .tacls = 20,
+ .twrph0 = 60,
+ .twrph1 = 20,
+ .nr_sets = ARRAY_SIZE(smdk_nand_sets),
+ .sets = smdk_nand_sets,
+};
+
+/* devices we initialise */
+
+static struct platform_device __initdata *smdk_devs[] = {
+ &s3c_device_nand,
+};
+
+void __init smdk_machine_init(void)
+{
+ /* Configure the LEDs (even if we have no LED support)*/
+
+ s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_OUTP);
+ s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);
+ s3c2410_gpio_cfgpin(S3C2410_GPF6, S3C2410_GPF6_OUTP);
+ s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_OUTP);
+
+ s3c2410_gpio_setpin(S3C2410_GPF4, 1);
+ s3c2410_gpio_setpin(S3C2410_GPF5, 1);
+ s3c2410_gpio_setpin(S3C2410_GPF6, 1);
+ s3c2410_gpio_setpin(S3C2410_GPF7, 1);
+
+ s3c_device_nand.dev.platform_data = &smdk_nand_info;
+
+ platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
+
+ s3c2410_pm_init();
+}
diff --git a/arch/arm/mach-s3c2410/common-smdk.h b/arch/arm/mach-s3c2410/common-smdk.h
new file mode 100644
index 0000000000000..0e3a3be330a34
--- /dev/null
+++ b/arch/arm/mach-s3c2410/common-smdk.h
@@ -0,0 +1,15 @@
+/* linux/arch/arm/mach-s3c2410/common-smdk.h
+ *
+ * Copyright (c) 2006 Simtec Electronics
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * Common code for SMDK2410 and SMDK2440 boards
+ *
+ * http://www.fluff.org/ben/smdk2440/
+ *
+ * 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.
+*/
+
+extern void smdk_machine_init(void);
diff --git a/arch/arm/mach-s3c2410/mach-anubis.c b/arch/arm/mach-s3c2410/mach-anubis.c
index 3e327b8e46bed..cc97fbf66291e 100644
--- a/arch/arm/mach-s3c2410/mach-anubis.c
+++ b/arch/arm/mach-s3c2410/mach-anubis.c
@@ -232,8 +232,8 @@ static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
static struct s3c2410_platform_nand anubis_nand_info = {
.tacls = 25,
- .twrph0 = 80,
- .twrph1 = 80,
+ .twrph0 = 55,
+ .twrph1 = 40,
.nr_sets = ARRAY_SIZE(anubis_nand_sets),
.sets = anubis_nand_sets,
.select_chip = anubis_nand_select,
diff --git a/arch/arm/mach-s3c2410/mach-rx3715.c b/arch/arm/mach-s3c2410/mach-rx3715.c
index 0260ed5ab946c..306afc1d7cd33 100644
--- a/arch/arm/mach-s3c2410/mach-rx3715.c
+++ b/arch/arm/mach-s3c2410/mach-rx3715.c
@@ -32,6 +32,11 @@
#include <linux/serial_core.h>
#include <linux/serial.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand_ecc.h>
+#include <linux/mtd/partitions.h>
+
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
@@ -46,6 +51,7 @@
#include <asm/arch/regs-gpio.h>
#include <asm/arch/regs-lcd.h>
+#include <asm/arch/nand.h>
#include <asm/arch/fb.h>
#include "clock.h"
@@ -170,12 +176,39 @@ static struct s3c2410fb_mach_info rx3715_lcdcfg __initdata = {
},
};
+static struct mtd_partition rx3715_nand_part[] = {
+ [0] = {
+ .name = "Whole Flash",
+ .offset = 0,
+ .size = MTDPART_SIZ_FULL,
+ .mask_flags = MTD_WRITEABLE,
+ }
+};
+
+static struct s3c2410_nand_set rx3715_nand_sets[] = {
+ [0] = {
+ .name = "Internal",
+ .nr_chips = 1,
+ .nr_partitions = ARRAY_SIZE(rx3715_nand_part),
+ .partitions = rx3715_nand_part,
+ },
+};
+
+static struct s3c2410_platform_nand rx3715_nand_info = {
+ .tacls = 25,
+ .twrph0 = 50,
+ .twrph1 = 15,
+ .nr_sets = ARRAY_SIZE(rx3715_nand_sets),
+ .sets = rx3715_nand_sets,
+};
+
static struct platform_device *rx3715_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
+ &s3c_device_nand,
};
static struct s3c24xx_board rx3715_board __initdata = {
@@ -185,6 +218,8 @@ static struct s3c24xx_board rx3715_board __initdata = {
static void __init rx3715_map_io(void)
{
+ s3c_device_nand.dev.platform_data = &rx3715_nand_info;
+
s3c24xx_init_io(rx3715_iodesc, ARRAY_SIZE(rx3715_iodesc));
s3c24xx_init_clocks(16934000);
s3c24xx_init_uarts(rx3715_uartcfgs, ARRAY_SIZE(rx3715_uartcfgs));
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
index 1e76e1fdfcea9..2db932d72c5ae 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c
@@ -28,7 +28,8 @@
* Ben Dooks <ben@simtec.co.uk>
*
* 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
- * 20-Sep-2005 BJD Added static to non-exported items
+ * 20-Sep-2005 BJD Added static to non-exported items
+ * 01-Apr-2006 BJD Moved init code to common smdk
*
***********************************************************************/
@@ -54,6 +55,8 @@
#include "devs.h"
#include "cpu.h"
+#include "common-smdk.h"
+
static struct map_desc smdk2410_iodesc[] __initdata = {
/* nothing here yet */
};
@@ -107,11 +110,6 @@ static void __init smdk2410_map_io(void)
s3c24xx_set_board(&smdk2410_board);
}
-static void __init smdk2410_init_irq(void)
-{
- s3c24xx_init_irq();
-}
-
MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
* to SMDK2410 */
/* Maintainer: Jonas Dietsche */
@@ -119,7 +117,8 @@ MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switc
.io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
.boot_params = S3C2410_SDRAM_PA + 0x100,
.map_io = smdk2410_map_io,
- .init_irq = smdk2410_init_irq,
+ .init_irq = s3c24xx_init_irq,
+ .init_machine = smdk_machine_init,
.timer = &s3c24xx_timer,
MACHINE_END
diff --git a/arch/arm/mach-s3c2410/mach-smdk2440.c b/arch/arm/mach-s3c2410/mach-smdk2440.c
index f4315721c3b8b..5fffd1d51047b 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2440.c
@@ -53,7 +53,8 @@
#include "clock.h"
#include "devs.h"
#include "cpu.h"
-#include "pm.h"
+
+#include "common-smdk.h"
static struct map_desc smdk2440_iodesc[] __initdata = {
/* ISA IO Space map (memory space selected by A24) */
@@ -197,21 +198,9 @@ static void __init smdk2440_map_io(void)
static void __init smdk2440_machine_init(void)
{
- /* Configure the LEDs (even if we have no LED support)*/
-
- s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_OUTP);
- s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);
- s3c2410_gpio_cfgpin(S3C2410_GPF6, S3C2410_GPF6_OUTP);
- s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_OUTP);
-
- s3c2410_gpio_setpin(S3C2410_GPF4, 0);
- s3c2410_gpio_setpin(S3C2410_GPF5, 0);
- s3c2410_gpio_setpin(S3C2410_GPF6, 0);
- s3c2410_gpio_setpin(S3C2410_GPF7, 0);
-
s3c24xx_fb_set_platdata(&smdk2440_lcd_cfg);
- s3c2410_pm_init();
+ smdk_machine_init();
}
MACHINE_START(S3C2440, "SMDK2440")
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 1024540824744..676b5c5b75bb2 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -11,7 +11,8 @@
* published by the Free Software Foundation.
*
* ChangeLog:
- * 03-06-2004 John Lenz <jelenz@wisc.edu>
+ * 2006 Pavel Machek <pavel@suse.cz>
+ * 03-06-2004 John Lenz <lenz@cs.wisc.edu>
* 06-04-2002 Chris Larson <kergoth@digitalnemesis.net>
* 04-16-2001 Lineo Japan,Inc. ...
*/
@@ -87,12 +88,75 @@ static struct mcp_plat_data collie_mcp_data = {
.sclk_rate = 11981000,
};
+#ifdef CONFIG_SHARP_LOCOMO
+/*
+ * low-level UART features.
+ */
+static struct locomo_dev *uart_dev = NULL;
+
+static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+ if (!uart_dev) return;
+
+ if (mctrl & TIOCM_RTS)
+ locomo_gpio_write(uart_dev, LOCOMO_GPIO_RTS, 0);
+ else
+ locomo_gpio_write(uart_dev, LOCOMO_GPIO_RTS, 1);
+
+ if (mctrl & TIOCM_DTR)
+ locomo_gpio_write(uart_dev, LOCOMO_GPIO_DTR, 0);
+ else
+ locomo_gpio_write(uart_dev, LOCOMO_GPIO_DTR, 1);
+}
+
+static u_int collie_uart_get_mctrl(struct uart_port *port)
+{
+ int ret = TIOCM_CD;
+ unsigned int r;
+ if (!uart_dev) return ret;
+
+ r = locomo_gpio_read_output(uart_dev, LOCOMO_GPIO_CTS & LOCOMO_GPIO_DSR);
+ if (r & LOCOMO_GPIO_CTS)
+ ret |= TIOCM_CTS;
+ if (r & LOCOMO_GPIO_DSR)
+ ret |= TIOCM_DSR;
+
+ return ret;
+}
static struct sa1100_port_fns collie_port_fns __initdata = {
.set_mctrl = collie_uart_set_mctrl,
.get_mctrl = collie_uart_get_mctrl,
};
+static int collie_uart_probe(struct locomo_dev *dev)
+{
+ uart_dev = dev;
+ return 0;
+}
+
+static int collie_uart_remove(struct locomo_dev *dev)
+{
+ uart_dev = NULL;
+ return 0;
+}
+
+static struct locomo_driver collie_uart_driver = {
+ .drv = {
+ .name = "collie_uart",
+ },
+ .devid = LOCOMO_DEVID_UART,
+ .probe = collie_uart_probe,
+ .remove = collie_uart_remove,
+};
+
+static int __init collie_uart_init(void) {
+ return locomo_driver_register(&collie_uart_driver);
+}
+device_initcall(collie_uart_init);
+
+#endif
+
static struct resource locomo_resources[] = {
[0] = {
@@ -218,6 +282,12 @@ static void __init collie_map_io(void)
{
sa1100_map_io();
iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
+
+#ifdef CONFIG_SHARP_LOCOMO
+ sa1100_register_uart_fns(&collie_port_fns);
+#endif
+ sa1100_register_uart(0, 3);
+ sa1100_register_uart(1, 1);
}
MACHINE_START(COLLIE, "Sharp-Collie")
diff --git a/arch/arm/mm/cache-v4wb.S b/arch/arm/mm/cache-v4wb.S
index 5c4055b62d976..54e3c5bb5186a 100644
--- a/arch/arm/mm/cache-v4wb.S
+++ b/arch/arm/mm/cache-v4wb.S
@@ -10,7 +10,7 @@
#include <linux/config.h>
#include <linux/linkage.h>
#include <linux/init.h>
-#include <asm/hardware.h>
+#include <asm/memory.h>
#include <asm/page.h>
#include "proc-macros.S"
@@ -46,6 +46,11 @@
*/
#define CACHE_DLIMIT (CACHE_DSIZE * 4)
+ .data
+flush_base:
+ .long FLUSH_BASE
+ .text
+
/*
* flush_user_cache_all()
*
@@ -63,11 +68,21 @@ ENTRY(v4wb_flush_kern_cache_all)
mov ip, #0
mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
__flush_whole_cache:
- mov r0, #FLUSH_BASE
- add r1, r0, #CACHE_DSIZE
-1: ldr r2, [r0], #32
- cmp r0, r1
+ ldr r3, =flush_base
+ ldr r1, [r3, #0]
+ eor r1, r1, #CACHE_DSIZE
+ str r1, [r3, #0]
+ add r2, r1, #CACHE_DSIZE
+1: ldr r3, [r1], #32
+ cmp r1, r2
+ blo 1b
+#ifdef FLUSH_BASE_MINICACHE
+ add r2, r2, #FLUSH_BASE_MINICACHE - FLUSH_BASE
+ sub r1, r2, #512 @ only 512 bytes
+1: ldr r3, [r1], #32
+ cmp r1, r2
blo 1b
+#endif
mcr p15, 0, ip, c7, c10, 4 @ drain write buffer
mov pc, lr
@@ -82,6 +97,7 @@ __flush_whole_cache:
* - flags - vma_area_struct flags describing address space
*/
ENTRY(v4wb_flush_user_cache_range)
+ mov ip, #0
sub r3, r1, r0 @ calculate total size
tst r2, #VM_EXEC @ executable region?
mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
index 8a1bfcd500871..50e6b6bfb2e23 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/consistent.c
@@ -18,6 +18,7 @@
#include <linux/device.h>
#include <linux/dma-mapping.h>
+#include <asm/memory.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
#include <asm/sizes.h>
@@ -272,6 +273,17 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
{
+ if (arch_is_coherent()) {
+ void *virt;
+
+ virt = kmalloc(size, gfp);
+ if (!virt)
+ return NULL;
+ *handle = virt_to_dma(dev, virt);
+
+ return virt;
+ }
+
return __dma_alloc(dev, size, handle, gfp,
pgprot_noncached(pgprot_kernel));
}
@@ -350,6 +362,11 @@ void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr
WARN_ON(irqs_disabled());
+ if (arch_is_coherent()) {
+ kfree(cpu_addr);
+ return;
+ }
+
size = PAGE_ALIGN(size);
spin_lock_irqsave(&consistent_lock, flags);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 88279124317a6..9ea1f87a7079b 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -20,6 +20,7 @@
#include <asm/mach-types.h>
#include <asm/setup.h>
+#include <asm/sizes.h>
#include <asm/tlb.h>
#include <asm/mach/arch.h>
@@ -455,14 +456,14 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
#ifdef FLUSH_BASE
map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
map.virtual = FLUSH_BASE;
- map.length = PGDIR_SIZE;
+ map.length = SZ_1M;
map.type = MT_CACHECLEAN;
create_mapping(&map);
#endif
#ifdef FLUSH_BASE_MINICACHE
- map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + PGDIR_SIZE);
+ map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
map.virtual = FLUSH_BASE_MINICACHE;
- map.length = PGDIR_SIZE;
+ map.length = SZ_1M;
map.type = MT_MINICLEAN;
create_mapping(&map);
#endif
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index 5e5d05bcad500..f14b2d0f3690a 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -389,6 +389,17 @@ void __init build_mem_type_table(void)
kern_pgprot = user_pgprot = cp->pte;
/*
+ * Enable CPU-specific coherency if supported.
+ * (Only available on XSC3 at the moment.)
+ */
+ if (arch_is_coherent()) {
+ if (cpu_is_xsc3()) {
+ mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
+ mem_types[MT_MEMORY].prot_pte |= L_PTE_COHERENT;
+ }
+ }
+
+ /*
* ARMv6 and above have extended page tables.
*/
if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index c916a6cae4042..a2dd5ae1077dd 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -26,22 +26,7 @@
* the cache line size of the I and D cache
*/
#define DCACHELINESIZE 32
-#define FLUSH_OFFSET 32768
- .macro flush_110_dcache rd, ra, re
- ldr \rd, =flush_base
- ldr \ra, [\rd]
- eor \ra, \ra, #FLUSH_OFFSET
- str \ra, [\rd]
- add \re, \ra, #16384 @ only necessary for 16k
-1001: ldr \rd, [\ra], #DCACHELINESIZE
- teq \re, \ra
- bne 1001b
- .endm
-
- .data
-flush_base:
- .long FLUSH_BASE
.text
/*
@@ -145,13 +130,11 @@ ENTRY(cpu_sa110_dcache_clean_area)
*/
.align 5
ENTRY(cpu_sa110_switch_mm)
- flush_110_dcache r3, ip, r1
- mov r1, #0
- mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
- mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ str lr, [sp, #-4]!
+ bl v4wb_flush_kern_cache_all @ clears IP
mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
- mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
- mov pc, lr
+ mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
+ ldr pc, [sp], #4
/*
* cpu_sa110_set_pte(ptep, pte)
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index 41f21f2dd8ffa..777ad99c14395 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -30,30 +30,6 @@
* the cache line size of the I and D cache
*/
#define DCACHELINESIZE 32
-#define FLUSH_OFFSET 32768
-
- .macro flush_1100_dcache rd, ra, re
- ldr \rd, =flush_base
- ldr \ra, [\rd]
- eor \ra, \ra, #FLUSH_OFFSET
- str \ra, [\rd]
- add \re, \ra, #8192 @ only necessary for 8k
-1001: ldr \rd, [\ra], #DCACHELINESIZE
- teq \re, \ra
- bne 1001b
-#ifdef FLUSH_BASE_MINICACHE
- add \ra, \ra, #FLUSH_BASE_MINICACHE - FLUSH_BASE
- add \re, \ra, #512 @ only 512 bytes
-1002: ldr \rd, [\ra], #DCACHELINESIZE
- teq \re, \ra
- bne 1002b
-#endif
- .endm
-
- .data
-flush_base:
- .long FLUSH_BASE
- .text
__INIT
@@ -79,9 +55,8 @@ ENTRY(cpu_sa1100_proc_fin)
stmfd sp!, {lr}
mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
msr cpsr_c, ip
- flush_1100_dcache r0, r1, r2 @ clean caches
- mov r0, #0
- mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
+ bl v4wb_flush_kern_cache_all
+ mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
mrc p15, 0, r0, c1, c0, 0 @ ctrl register
bic r0, r0, #0x1000 @ ...i............
bic r0, r0, #0x000e @ ............wca.
@@ -167,14 +142,12 @@ ENTRY(cpu_sa1100_dcache_clean_area)
*/
.align 5
ENTRY(cpu_sa1100_switch_mm)
- flush_1100_dcache r3, ip, r1
- mov ip, #0
- mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
+ str lr, [sp, #-4]!
+ bl v4wb_flush_kern_cache_all @ clears IP
mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
- mcr p15, 0, ip, c7, c10, 4 @ drain WB
mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
- mov pc, lr
+ ldr pc, [sp], #4
/*
* cpu_sa1100_set_pte(ptep, pte)
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index b9dfce57c272c..80873b36c3f7a 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -371,7 +371,7 @@ ENTRY(cpu_xsc3_switch_mm)
ENTRY(cpu_xsc3_set_pte)
str r1, [r0], #-2048 @ linux version
- bic r2, r1, #0xff0
+ bic r2, r1, #0xdf0 @ Keep C, B, coherency bits
orr r2, r2, #PTE_TYPE_EXT @ extended page
eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 0887bb2a25518..ec49495e651eb 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -70,13 +70,13 @@ config OMAP_MPU_TIMER
config OMAP_32K_TIMER
bool "Use 32KHz timer"
- depends on ARCH_OMAP16XX
+ depends on ARCH_OMAP16XX || ARCH_OMAP24XX
help
Select this option if you want to enable the OMAP 32KHz timer.
This timer saves power compared to the OMAP_MPU_TIMER, and has
support for no tick during idle. The 32KHz timer provides less
intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is
- currently only available for OMAP-16xx.
+ currently only available for OMAP16XX and 24XX.
endchoice
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 9ccf1943fc946..2896b4546411c 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -3,16 +3,16 @@
#
# Common support
-obj-y := common.o sram.o sram-fn.o clock.o devices.o dma.o mux.o gpio.o mcbsp.o usb.o
+obj-y := common.o sram.o sram-fn.o clock.o devices.o dma.o mux.o gpio.o mcbsp.o usb.o fb.o
obj-m :=
obj-n :=
obj- :=
+obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
+
# OCPI interconnect support for 1710, 1610 and 5912
obj-$(CONFIG_ARCH_OMAP16XX) += ocpi.o
-# Power Management
-obj-$(CONFIG_PM) += pm.o sleep.o
obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 3c2bfc0efdaf6..32ec04c58bcd4 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -21,6 +21,7 @@
#include <linux/string.h>
#include <linux/clk.h>
#include <linux/mutex.h>
+#include <linux/platform_device.h>
#include <asm/io.h>
#include <asm/semaphore.h>
@@ -37,17 +38,38 @@ static struct clk_functions *arch_clock;
* Standard clock functions defined in include/linux/clk.h
*-------------------------------------------------------------------------*/
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
struct clk * clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);
+ int idno;
+
+ if (dev == NULL || dev->bus != &platform_bus_type)
+ idno = -1;
+ else
+ idno = to_platform_device(dev)->id;
mutex_lock(&clocks_mutex);
+
+ list_for_each_entry(p, &clocks, node) {
+ if (p->id == idno &&
+ strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+ clk = p;
+ goto found;
+ }
+ }
+
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
clk = p;
break;
}
}
+
+found:
mutex_unlock(&clocks_mutex);
return clk;
@@ -59,6 +81,9 @@ int clk_enable(struct clk *clk)
unsigned long flags;
int ret = 0;
+ if (clk == NULL || IS_ERR(clk))
+ return -EINVAL;
+
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_enable)
ret = arch_clock->clk_enable(clk);
@@ -72,6 +97,9 @@ void clk_disable(struct clk *clk)
{
unsigned long flags;
+ if (clk == NULL || IS_ERR(clk))
+ return;
+
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_disable)
arch_clock->clk_disable(clk);
@@ -84,6 +112,9 @@ int clk_get_usecount(struct clk *clk)
unsigned long flags;
int ret = 0;
+ if (clk == NULL || IS_ERR(clk))
+ return 0;
+
spin_lock_irqsave(&clockfw_lock, flags);
ret = clk->usecount;
spin_unlock_irqrestore(&clockfw_lock, flags);
@@ -97,6 +128,9 @@ unsigned long clk_get_rate(struct clk *clk)
unsigned long flags;
unsigned long ret = 0;
+ if (clk == NULL || IS_ERR(clk))
+ return 0;
+
spin_lock_irqsave(&clockfw_lock, flags);
ret = clk->rate;
spin_unlock_irqrestore(&clockfw_lock, flags);
@@ -121,6 +155,9 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
unsigned long flags;
long ret = 0;
+ if (clk == NULL || IS_ERR(clk))
+ return ret;
+
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_round_rate)
ret = arch_clock->clk_round_rate(clk, rate);
@@ -133,7 +170,10 @@ EXPORT_SYMBOL(clk_round_rate);
int clk_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long flags;
- int ret = 0;
+ int ret = -EINVAL;
+
+ if (clk == NULL || IS_ERR(clk))
+ return ret;
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_set_rate)
@@ -147,7 +187,10 @@ EXPORT_SYMBOL(clk_set_rate);
int clk_set_parent(struct clk *clk, struct clk *parent)
{
unsigned long flags;
- int ret = 0;
+ int ret = -EINVAL;
+
+ if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent))
+ return ret;
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_set_parent)
@@ -163,6 +206,9 @@ struct clk *clk_get_parent(struct clk *clk)
unsigned long flags;
struct clk * ret = NULL;
+ if (clk == NULL || IS_ERR(clk))
+ return ret;
+
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_get_parent)
ret = arch_clock->clk_get_parent(clk);
@@ -199,6 +245,9 @@ __setup("mpurate=", omap_clk_setup);
/* Used for clocks that always have same value as the parent clock */
void followparent_recalc(struct clk *clk)
{
+ if (clk == NULL || IS_ERR(clk))
+ return;
+
clk->rate = clk->parent->rate;
}
@@ -207,6 +256,9 @@ void propagate_rate(struct clk * tclk)
{
struct clk *clkp;
+ if (tclk == NULL || IS_ERR(tclk))
+ return;
+
list_for_each_entry(clkp, &clocks, node) {
if (likely(clkp->parent != tclk))
continue;
@@ -217,6 +269,9 @@ void propagate_rate(struct clk * tclk)
int clk_register(struct clk *clk)
{
+ if (clk == NULL || IS_ERR(clk))
+ return -EINVAL;
+
mutex_lock(&clocks_mutex);
list_add(&clk->node, &clocks);
if (clk->init)
@@ -229,6 +284,9 @@ EXPORT_SYMBOL(clk_register);
void clk_unregister(struct clk *clk)
{
+ if (clk == NULL || IS_ERR(clk))
+ return;
+
mutex_lock(&clocks_mutex);
list_del(&clk->node);
mutex_unlock(&clocks_mutex);
@@ -239,6 +297,9 @@ void clk_deny_idle(struct clk *clk)
{
unsigned long flags;
+ if (clk == NULL || IS_ERR(clk))
+ return;
+
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_deny_idle)
arch_clock->clk_deny_idle(clk);
@@ -250,6 +311,9 @@ void clk_allow_idle(struct clk *clk)
{
unsigned long flags;
+ if (clk == NULL || IS_ERR(clk))
+ return;
+
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_allow_idle)
arch_clock->clk_allow_idle(clk);
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index 9dcce904b6082..5d5d6eb222dd7 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -24,14 +24,7 @@
#include <asm/arch/board.h>
#include <asm/arch/mux.h>
#include <asm/arch/gpio.h>
-
-
-void omap_nop_release(struct device *dev)
-{
- /* Nothing */
-}
-
-/*-------------------------------------------------------------------------*/
+#include <asm/arch/menelaus.h>
#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
@@ -58,9 +51,6 @@ static struct resource i2c_resources1[] = {
static struct platform_device omap_i2c_device1 = {
.name = "i2c_omap",
.id = 1,
- .dev = {
- .release = omap_nop_release,
- },
.num_resources = ARRAY_SIZE(i2c_resources1),
.resource = i2c_resources1,
};
@@ -98,6 +88,62 @@ static inline void omap_init_i2c(void) {}
#endif
/*-------------------------------------------------------------------------*/
+#if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
+
+static void omap_init_kp(void)
+{
+ if (machine_is_omap_h2() || machine_is_omap_h3()) {
+ omap_cfg_reg(F18_1610_KBC0);
+ omap_cfg_reg(D20_1610_KBC1);
+ omap_cfg_reg(D19_1610_KBC2);
+ omap_cfg_reg(E18_1610_KBC3);
+ omap_cfg_reg(C21_1610_KBC4);
+
+ omap_cfg_reg(G18_1610_KBR0);
+ omap_cfg_reg(F19_1610_KBR1);
+ omap_cfg_reg(H14_1610_KBR2);
+ omap_cfg_reg(E20_1610_KBR3);
+ omap_cfg_reg(E19_1610_KBR4);
+ omap_cfg_reg(N19_1610_KBR5);
+ } else if (machine_is_omap_perseus2()) {
+ omap_cfg_reg(E2_730_KBR0);
+ omap_cfg_reg(J7_730_KBR1);
+ omap_cfg_reg(E1_730_KBR2);
+ omap_cfg_reg(F3_730_KBR3);
+ omap_cfg_reg(D2_730_KBR4);
+
+ omap_cfg_reg(C2_730_KBC0);
+ omap_cfg_reg(D3_730_KBC1);
+ omap_cfg_reg(E4_730_KBC2);
+ omap_cfg_reg(F4_730_KBC3);
+ omap_cfg_reg(E3_730_KBC4);
+ } else if (machine_is_omap_h4()) {
+ omap_cfg_reg(T19_24XX_KBR0);
+ omap_cfg_reg(R19_24XX_KBR1);
+ omap_cfg_reg(V18_24XX_KBR2);
+ omap_cfg_reg(M21_24XX_KBR3);
+ omap_cfg_reg(E5__24XX_KBR4);
+ if (omap_has_menelaus()) {
+ omap_cfg_reg(B3__24XX_KBR5);
+ omap_cfg_reg(AA4_24XX_KBC2);
+ omap_cfg_reg(B13_24XX_KBC6);
+ } else {
+ omap_cfg_reg(M18_24XX_KBR5);
+ omap_cfg_reg(H19_24XX_KBC2);
+ omap_cfg_reg(N19_24XX_KBC6);
+ }
+ omap_cfg_reg(R20_24XX_KBC0);
+ omap_cfg_reg(M14_24XX_KBC1);
+ omap_cfg_reg(V17_24XX_KBC3);
+ omap_cfg_reg(P21_24XX_KBC4);
+ omap_cfg_reg(L14_24XX_KBC5);
+ }
+}
+#else
+static inline void omap_init_kp(void) {}
+#endif
+
+/*-------------------------------------------------------------------------*/
#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
@@ -130,7 +176,6 @@ static struct platform_device mmc_omap_device1 = {
.name = "mmci-omap",
.id = 1,
.dev = {
- .release = omap_nop_release,
.dma_mask = &mmc1_dmamask,
.platform_data = &mmc1_conf,
},
@@ -160,7 +205,6 @@ static struct platform_device mmc_omap_device2 = {
.name = "mmci-omap",
.id = 2,
.dev = {
- .release = omap_nop_release,
.dma_mask = &mmc2_dmamask,
.platform_data = &mmc2_conf,
},
@@ -240,6 +284,52 @@ static void __init omap_init_mmc(void)
static inline void omap_init_mmc(void) {}
#endif
+/*-------------------------------------------------------------------------*/
+
+/* Numbering for the SPI-capable controllers when used for SPI:
+ * spi = 1
+ * uwire = 2
+ * mmc1..2 = 3..4
+ * mcbsp1..3 = 5..7
+ */
+
+#if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
+
+#define OMAP_UWIRE_BASE 0xfffb3000
+
+static struct resource uwire_resources[] = {
+ {
+ .start = OMAP_UWIRE_BASE,
+ .end = OMAP_UWIRE_BASE + 0x20,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct platform_device omap_uwire_device = {
+ .name = "omap_uwire",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(uwire_resources),
+ .resource = uwire_resources,
+};
+
+static void omap_init_uwire(void)
+{
+ /* FIXME define and use a boot tag; not all boards will be hooking
+ * up devices to the microwire controller, and multi-board configs
+ * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
+ */
+
+ /* board-specific code must configure chipselects (only a few
+ * are normally used) and SCLK/SDI/SDO (each has two choices).
+ */
+ (void) platform_device_register(&omap_uwire_device);
+}
+#else
+static inline void omap_init_uwire(void) {}
+#endif
+
+/*-------------------------------------------------------------------------*/
+
#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
#ifdef CONFIG_ARCH_OMAP24XX
@@ -259,9 +349,6 @@ static struct resource wdt_resources[] = {
static struct platform_device omap_wdt_device = {
.name = "omap_wdt",
.id = -1,
- .dev = {
- .release = omap_nop_release,
- },
.num_resources = ARRAY_SIZE(wdt_resources),
.resource = wdt_resources,
};
@@ -295,9 +382,6 @@ static struct resource rng_resources[] = {
static struct platform_device omap_rng_device = {
.name = "omap_rng",
.id = -1,
- .dev = {
- .release = omap_nop_release,
- },
.num_resources = ARRAY_SIZE(rng_resources),
.resource = rng_resources,
};
@@ -310,40 +394,6 @@ static void omap_init_rng(void)
static inline void omap_init_rng(void) {}
#endif
-#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
-
-static struct omap_lcd_config omap_fb_conf;
-
-static u64 omap_fb_dma_mask = ~(u32)0;
-
-static struct platform_device omap_fb_device = {
- .name = "omapfb",
- .id = -1,
- .dev = {
- .release = omap_nop_release,
- .dma_mask = &omap_fb_dma_mask,
- .coherent_dma_mask = ~(u32)0,
- .platform_data = &omap_fb_conf,
- },
- .num_resources = 0,
-};
-
-static inline void omap_init_fb(void)
-{
- const struct omap_lcd_config *conf;
-
- conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
- if (conf != NULL)
- omap_fb_conf = *conf;
- platform_device_register(&omap_fb_device);
-}
-
-#else
-
-static inline void omap_init_fb(void) {}
-
-#endif
-
/*
* This gets called after board-specific INIT_MACHINE, and initializes most
* on-chip peripherals accessible on this board (except for few like USB):
@@ -369,9 +419,10 @@ static int __init omap_init_devices(void)
/* please keep these calls, and their implementations above,
* in alphabetical order so they're easier to sort through.
*/
- omap_init_fb();
omap_init_i2c();
+ omap_init_kp();
omap_init_mmc();
+ omap_init_uwire();
omap_init_wdt();
omap_init_rng();
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index a4e5ac77f6dfc..5dac4230360d8 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -1258,6 +1258,11 @@ void omap_stop_lcd_dma(void)
omap_writew(w, OMAP1610_DMA_LCD_CTRL);
}
+int omap_lcd_dma_ext_running(void)
+{
+ return lcd_dma.ext_ctrl && lcd_dma.active;
+}
+
/*----------------------------------------------------------------------------*/
static int __init omap_init_dma(void)
@@ -1389,6 +1394,7 @@ EXPORT_SYMBOL(omap_free_lcd_dma);
EXPORT_SYMBOL(omap_enable_lcd_dma);
EXPORT_SYMBOL(omap_setup_lcd_dma);
EXPORT_SYMBOL(omap_stop_lcd_dma);
+EXPORT_SYMBOL(omap_lcd_dma_ext_running);
EXPORT_SYMBOL(omap_set_lcd_dma_b1);
EXPORT_SYMBOL(omap_set_lcd_dma_single_transfer);
EXPORT_SYMBOL(omap_set_lcd_dma_ext_controller);
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 38d7ebf879207..eba3cb52ad878 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -97,6 +97,32 @@ int omap_dm_timers_active(void)
}
+/**
+ * omap_dm_timer_modify_idlect_mask - Check if any running timers use ARMXOR
+ * @inputmask: current value of idlect mask
+ */
+__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
+{
+ int n;
+
+ /* If ARMXOR cannot be idled this function call is unnecessary */
+ if (!(inputmask & (1 << 1)))
+ return inputmask;
+
+ /* If any active timer is using ARMXOR return modified mask */
+ for (n = 0; dm_timers[n].base; ++n)
+ if (omap_dm_timer_read_reg(&dm_timers[n], OMAP_TIMER_CTRL_REG)&
+ OMAP_TIMER_CTRL_ST) {
+ if (((omap_readl(MOD_CONF_CTRL_1)>>(n*2)) & 0x03) == 0)
+ inputmask &= ~(1 << 1);
+ else
+ inputmask &= ~(1 << 2);
+ }
+
+ return inputmask;
+}
+
+
void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
{
int n = (timer - dm_timers) << 1;
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
new file mode 100644
index 0000000000000..305e9b990b710
--- /dev/null
+++ b/arch/arm/plat-omap/fb.c
@@ -0,0 +1,80 @@
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/bootmem.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/mach/map.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/sram.h>
+#include <asm/arch/omapfb.h>
+
+#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
+
+static struct omapfb_platform_data omapfb_config;
+
+static u64 omap_fb_dma_mask = ~(u32)0;
+
+static struct platform_device omap_fb_device = {
+ .name = "omapfb",
+ .id = -1,
+ .dev = {
+ .dma_mask = &omap_fb_dma_mask,
+ .coherent_dma_mask = ~(u32)0,
+ .platform_data = &omapfb_config,
+ },
+ .num_resources = 0,
+};
+
+/* called from map_io */
+void omapfb_reserve_mem(void)
+{
+ const struct omap_fbmem_config *fbmem_conf;
+
+ omapfb_config.fbmem.fb_sram_start = omap_fb_sram_start;
+ omapfb_config.fbmem.fb_sram_size = omap_fb_sram_size;
+
+ fbmem_conf = omap_get_config(OMAP_TAG_FBMEM, struct omap_fbmem_config);
+
+ if (fbmem_conf != NULL) {
+ /* indicate that the bootloader already initialized the
+ * fb device, so we'll skip that part in the fb driver
+ */
+ omapfb_config.fbmem.fb_sdram_start = fbmem_conf->fb_sdram_start;
+ omapfb_config.fbmem.fb_sdram_size = fbmem_conf->fb_sdram_size;
+ if (fbmem_conf->fb_sdram_size) {
+ pr_info("Reserving %u bytes SDRAM for frame buffer\n",
+ fbmem_conf->fb_sdram_size);
+ reserve_bootmem(fbmem_conf->fb_sdram_start,
+ fbmem_conf->fb_sdram_size);
+ }
+ }
+}
+
+static inline int omap_init_fb(void)
+{
+ const struct omap_lcd_config *conf;
+
+ conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
+ if (conf == NULL)
+ return 0;
+
+ omapfb_config.lcd = *conf;
+
+ return platform_device_register(&omap_fb_device);
+}
+
+arch_initcall(omap_init_fb);
+
+#else
+
+void omapfb_reserve_mem(void) {}
+
+#endif
+
+
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index b4d5b9e4bfce6..d3c8ea7eecfd2 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -174,7 +174,7 @@ static int gpio_bank_count;
static inline struct gpio_bank *get_gpio_bank(int gpio)
{
#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap1510()) {
+ if (cpu_is_omap15xx()) {
if (OMAP_GPIO_IS_MPUIO(gpio))
return &gpio_bank[0];
return &gpio_bank[1];
@@ -223,7 +223,7 @@ static inline int gpio_valid(int gpio)
return 0;
}
#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap1510() && gpio < 16)
+ if (cpu_is_omap15xx() && gpio < 16)
return 0;
#endif
#if defined(CONFIG_ARCH_OMAP16XX)
@@ -402,13 +402,13 @@ static inline void set_24xx_gpio_triggering(void __iomem *base, int gpio, int tr
u32 gpio_bit = 1 << gpio;
MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT0, gpio_bit,
- trigger & IRQT_LOW);
+ trigger & __IRQT_LOWLVL);
MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT1, gpio_bit,
- trigger & IRQT_HIGH);
+ trigger & __IRQT_HIGHLVL);
MOD_REG_BIT(OMAP24XX_GPIO_RISINGDETECT, gpio_bit,
- trigger & IRQT_RISING);
+ trigger & __IRQT_RISEDGE);
MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
- trigger & IRQT_FALLING);
+ trigger & __IRQT_FALEDGE);
/* FIXME: Possibly do 'set_irq_handler(j, do_level_IRQ)' if only level
* triggering requested. */
}
@@ -422,9 +422,9 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
case METHOD_MPUIO:
reg += OMAP_MPUIO_GPIO_INT_EDGE;
l = __raw_readl(reg);
- if (trigger == IRQT_RISING)
+ if (trigger & __IRQT_RISEDGE)
l |= 1 << gpio;
- else if (trigger == IRQT_FALLING)
+ else if (trigger & __IRQT_FALEDGE)
l &= ~(1 << gpio);
else
goto bad;
@@ -432,9 +432,9 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
case METHOD_GPIO_1510:
reg += OMAP1510_GPIO_INT_CONTROL;
l = __raw_readl(reg);
- if (trigger == IRQT_RISING)
+ if (trigger & __IRQT_RISEDGE)
l |= 1 << gpio;
- else if (trigger == IRQT_FALLING)
+ else if (trigger & __IRQT_FALEDGE)
l &= ~(1 << gpio);
else
goto bad;
@@ -446,20 +446,21 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
reg += OMAP1610_GPIO_EDGE_CTRL1;
gpio &= 0x07;
/* We allow only edge triggering, i.e. two lowest bits */
- if (trigger & ~IRQT_BOTHEDGE)
+ if (trigger & (__IRQT_LOWLVL | __IRQT_HIGHLVL))
BUG();
- /* NOTE: knows __IRQT_{FAL,RIS}EDGE match OMAP hardware */
- trigger &= 0x03;
l = __raw_readl(reg);
l &= ~(3 << (gpio << 1));
- l |= trigger << (gpio << 1);
+ if (trigger & __IRQT_RISEDGE)
+ l |= 2 << (gpio << 1);
+ if (trigger & __IRQT_FALEDGE)
+ l |= 1 << (gpio << 1);
break;
case METHOD_GPIO_730:
reg += OMAP730_GPIO_INT_CONTROL;
l = __raw_readl(reg);
- if (trigger == IRQT_RISING)
+ if (trigger & __IRQT_RISEDGE)
l |= 1 << gpio;
- else if (trigger == IRQT_FALLING)
+ else if (trigger & __IRQT_FALEDGE)
l &= ~(1 << gpio);
else
goto bad;
@@ -491,7 +492,9 @@ static int gpio_irq_type(unsigned irq, unsigned type)
if (check_gpio(gpio) < 0)
return -EINVAL;
- if (type & (__IRQT_LOWLVL|__IRQT_HIGHLVL|IRQT_PROBE))
+ if (type & IRQT_PROBE)
+ return -EINVAL;
+ if (!cpu_is_omap24xx() && (type & (__IRQT_LOWLVL|__IRQT_HIGHLVL)))
return -EINVAL;
bank = get_gpio_bank(gpio);
@@ -755,13 +758,32 @@ static void gpio_irq_handler(unsigned int irq, struct irqdesc *desc,
if (bank->method == METHOD_GPIO_24XX)
isr_reg = bank->base + OMAP24XX_GPIO_IRQSTATUS1;
#endif
-
while(1) {
- isr = __raw_readl(isr_reg);
- _enable_gpio_irqbank(bank, isr, 0);
- _clear_gpio_irqbank(bank, isr);
- _enable_gpio_irqbank(bank, isr, 1);
- desc->chip->unmask(irq);
+ u32 isr_saved, level_mask = 0;
+
+ isr_saved = isr = __raw_readl(isr_reg);
+
+ if (cpu_is_omap15xx() && (bank->method == METHOD_MPUIO))
+ isr &= 0x0000ffff;
+
+ if (cpu_is_omap24xx())
+ level_mask =
+ __raw_readl(bank->base +
+ OMAP24XX_GPIO_LEVELDETECT0) |
+ __raw_readl(bank->base +
+ OMAP24XX_GPIO_LEVELDETECT1);
+
+ /* clear edge sensitive interrupts before handler(s) are
+ called so that we don't miss any interrupt occurred while
+ executing them */
+ _enable_gpio_irqbank(bank, isr_saved & ~level_mask, 0);
+ _clear_gpio_irqbank(bank, isr_saved & ~level_mask);
+ _enable_gpio_irqbank(bank, isr_saved & ~level_mask, 1);
+
+ /* if there is only edge sensitive GPIO pin interrupts
+ configured, we could unmask GPIO bank interrupt immediately */
+ if (!level_mask)
+ desc->chip->unmask(irq);
if (!isr)
break;
@@ -774,6 +796,20 @@ static void gpio_irq_handler(unsigned int irq, struct irqdesc *desc,
d = irq_desc + gpio_irq;
desc_handle_irq(gpio_irq, d, regs);
}
+
+ if (cpu_is_omap24xx()) {
+ /* clear level sensitive interrupts after handler(s) */
+ _enable_gpio_irqbank(bank, isr_saved & level_mask, 0);
+ _clear_gpio_irqbank(bank, isr_saved & level_mask);
+ _enable_gpio_irqbank(bank, isr_saved & level_mask, 1);
+ }
+
+ /* if bank has any level sensitive GPIO pin interrupt
+ configured, we must unmask the bank interrupt only after
+ handler(s) are executed in order to avoid spurious bank
+ interrupt */
+ if (level_mask)
+ desc->chip->unmask(irq);
}
}
@@ -848,7 +884,7 @@ static int __init _omap_gpio_init(void)
initialized = 1;
- if (cpu_is_omap1510()) {
+ if (cpu_is_omap15xx()) {
gpio_ick = clk_get(NULL, "arm_gpio_ck");
if (IS_ERR(gpio_ick))
printk("Could not get arm_gpio_ck\n");
@@ -869,7 +905,7 @@ static int __init _omap_gpio_init(void)
}
#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap1510()) {
+ if (cpu_is_omap15xx()) {
printk(KERN_INFO "OMAP1510 GPIO hardware\n");
gpio_bank_count = 2;
gpio_bank = gpio_bank_1510;
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 1cd2cace7e1b5..196aac3ac329a 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -34,7 +34,7 @@
#ifdef CONFIG_MCBSP_DEBUG
#define DBG(x...) printk(x)
#else
-#define DBG(x...) do { } while (0)
+#define DBG(x...) do { } while (0)
#endif
struct omap_mcbsp {
@@ -44,6 +44,7 @@ struct omap_mcbsp {
omap_mcbsp_word_length rx_word_length;
omap_mcbsp_word_length tx_word_length;
+ omap_mcbsp_io_type_t io_type; /* IRQ or poll */
/* IRQ based TX/RX */
int rx_irq;
int tx_irq;
@@ -64,10 +65,19 @@ struct omap_mcbsp {
};
static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
+#ifdef CONFIG_ARCH_OMAP1
static struct clk *mcbsp_dsp_ck = 0;
static struct clk *mcbsp_api_ck = 0;
static struct clk *mcbsp_dspxor_ck = 0;
-
+#endif
+#ifdef CONFIG_ARCH_OMAP2
+static struct clk *mcbsp1_ick = 0;
+static struct clk *mcbsp1_fck = 0;
+static struct clk *mcbsp2_ick = 0;
+static struct clk *mcbsp2_fck = 0;
+static struct clk *sys_ck = 0;
+static struct clk *sys_clkout = 0;
+#endif
static void omap_mcbsp_dump_reg(u8 id)
{
@@ -88,7 +98,6 @@ static void omap_mcbsp_dump_reg(u8 id)
DBG("***********************\n");
}
-
static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
{
struct omap_mcbsp * mcbsp_tx = (struct omap_mcbsp *)(dev_id);
@@ -109,7 +118,6 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id, struct pt_re
return IRQ_HANDLED;
}
-
static void omap_mcbsp_tx_dma_callback(int lch, u16 ch_status, void *data)
{
struct omap_mcbsp * mcbsp_dma_tx = (struct omap_mcbsp *)(data);
@@ -176,7 +184,7 @@ static int omap_mcbsp_check(unsigned int id)
return 0;
}
- if (cpu_is_omap1510() || cpu_is_omap16xx()) {
+ if (cpu_is_omap15xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) {
if (id > OMAP_MAX_MCBSP_COUNT) {
printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1);
return -1;
@@ -187,9 +195,10 @@ static int omap_mcbsp_check(unsigned int id)
return -1;
}
+#ifdef CONFIG_ARCH_OMAP1
static void omap_mcbsp_dsp_request(void)
{
- if (cpu_is_omap1510() || cpu_is_omap16xx()) {
+ if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
clk_enable(mcbsp_dsp_ck);
clk_enable(mcbsp_api_ck);
@@ -207,12 +216,49 @@ static void omap_mcbsp_dsp_request(void)
static void omap_mcbsp_dsp_free(void)
{
- if (cpu_is_omap1510() || cpu_is_omap16xx()) {
+ if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
clk_disable(mcbsp_dspxor_ck);
clk_disable(mcbsp_dsp_ck);
clk_disable(mcbsp_api_ck);
}
}
+#endif
+
+#ifdef CONFIG_ARCH_OMAP2
+static void omap2_mcbsp2_mux_setup(void)
+{
+ omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
+ omap_cfg_reg(R14_24XX_MCBSP2_FSX);
+ omap_cfg_reg(W15_24XX_MCBSP2_DR);
+ omap_cfg_reg(V15_24XX_MCBSP2_DX);
+ omap_cfg_reg(V14_24XX_GPIO117);
+ omap_cfg_reg(W14_24XX_SYS_CLKOUT);
+}
+#endif
+
+/*
+ * We can choose between IRQ based or polled IO.
+ * This needs to be called before omap_mcbsp_request().
+ */
+int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
+{
+ if (omap_mcbsp_check(id) < 0)
+ return -EINVAL;
+
+ spin_lock(&mcbsp[id].lock);
+
+ if (!mcbsp[id].free) {
+ printk (KERN_ERR "OMAP-McBSP: McBSP%d is currently in use\n", id + 1);
+ spin_unlock(&mcbsp[id].lock);
+ return -EINVAL;
+ }
+
+ mcbsp[id].io_type = io_type;
+
+ spin_unlock(&mcbsp[id].lock);
+
+ return 0;
+}
int omap_mcbsp_request(unsigned int id)
{
@@ -221,12 +267,26 @@ int omap_mcbsp_request(unsigned int id)
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
+#ifdef CONFIG_ARCH_OMAP1
/*
* On 1510, 1610 and 1710, McBSP1 and McBSP3
* are DSP public peripherals.
*/
if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
omap_mcbsp_dsp_request();
+#endif
+
+#ifdef CONFIG_ARCH_OMAP2
+ if (cpu_is_omap24xx()) {
+ if (id == OMAP_MCBSP1) {
+ clk_enable(mcbsp1_ick);
+ clk_enable(mcbsp1_fck);
+ } else {
+ clk_enable(mcbsp2_ick);
+ clk_enable(mcbsp2_fck);
+ }
+ }
+#endif
spin_lock(&mcbsp[id].lock);
if (!mcbsp[id].free) {
@@ -238,30 +298,33 @@ int omap_mcbsp_request(unsigned int id)
mcbsp[id].free = 0;
spin_unlock(&mcbsp[id].lock);
- /* We need to get IRQs here */
- err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 0,
- "McBSP",
- (void *) (&mcbsp[id]));
- if (err != 0) {
- printk(KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n",
- mcbsp[id].tx_irq, mcbsp[id].id);
- return err;
- }
+ if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) {
+ /* We need to get IRQs here */
+ err = request_irq(mcbsp[id].tx_irq, omap_mcbsp_tx_irq_handler, 0,
+ "McBSP",
+ (void *) (&mcbsp[id]));
+ if (err != 0) {
+ printk(KERN_ERR "OMAP-McBSP: Unable to request TX IRQ %d for McBSP%d\n",
+ mcbsp[id].tx_irq, mcbsp[id].id);
+ return err;
+ }
- init_completion(&(mcbsp[id].tx_irq_completion));
+ init_completion(&(mcbsp[id].tx_irq_completion));
- err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 0,
- "McBSP",
- (void *) (&mcbsp[id]));
- if (err != 0) {
- printk(KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n",
- mcbsp[id].rx_irq, mcbsp[id].id);
- free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
- return err;
+ err = request_irq(mcbsp[id].rx_irq, omap_mcbsp_rx_irq_handler, 0,
+ "McBSP",
+ (void *) (&mcbsp[id]));
+ if (err != 0) {
+ printk(KERN_ERR "OMAP-McBSP: Unable to request RX IRQ %d for McBSP%d\n",
+ mcbsp[id].rx_irq, mcbsp[id].id);
+ free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
+ return err;
+ }
+
+ init_completion(&(mcbsp[id].rx_irq_completion));
}
- init_completion(&(mcbsp[id].rx_irq_completion));
return 0;
}
@@ -271,8 +334,24 @@ void omap_mcbsp_free(unsigned int id)
if (omap_mcbsp_check(id) < 0)
return;
- if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
- omap_mcbsp_dsp_free();
+#ifdef CONFIG_ARCH_OMAP1
+ if (cpu_class_is_omap1()) {
+ if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
+ omap_mcbsp_dsp_free();
+ }
+#endif
+
+#ifdef CONFIG_ARCH_OMAP2
+ if (cpu_is_omap24xx()) {
+ if (id == OMAP_MCBSP1) {
+ clk_disable(mcbsp1_ick);
+ clk_disable(mcbsp1_fck);
+ } else {
+ clk_disable(mcbsp2_ick);
+ clk_disable(mcbsp2_fck);
+ }
+ }
+#endif
spin_lock(&mcbsp[id].lock);
if (mcbsp[id].free) {
@@ -284,9 +363,11 @@ void omap_mcbsp_free(unsigned int id)
mcbsp[id].free = 1;
spin_unlock(&mcbsp[id].lock);
- /* Free IRQs */
- free_irq(mcbsp[id].rx_irq, (void *) (&mcbsp[id]));
- free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
+ if (mcbsp[id].io_type == OMAP_MCBSP_IRQ_IO) {
+ /* Free IRQs */
+ free_irq(mcbsp[id].rx_irq, (void *) (&mcbsp[id]));
+ free_irq(mcbsp[id].tx_irq, (void *) (&mcbsp[id]));
+ }
}
/*
@@ -461,6 +542,115 @@ u32 omap_mcbsp_recv_word(unsigned int id)
}
+int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
+{
+ u32 io_base = mcbsp[id].io_base;
+ omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
+ omap_mcbsp_word_length rx_word_length = mcbsp[id].rx_word_length;
+ u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
+
+ if (tx_word_length != rx_word_length)
+ return -EINVAL;
+
+ /* First we wait for the transmitter to be ready */
+ spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
+ while (!(spcr2 & XRDY)) {
+ spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
+ if (attempts++ > 1000) {
+ /* We must reset the transmitter */
+ OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST));
+ udelay(10);
+ OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
+ udelay(10);
+ printk("McBSP transmitter not ready\n");
+ return -EAGAIN;
+ }
+ }
+
+ /* Now we can push the data */
+ if (tx_word_length > OMAP_MCBSP_WORD_16)
+ OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
+ OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
+
+ /* We wait for the receiver to be ready */
+ spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
+ while (!(spcr1 & RRDY)) {
+ spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
+ if (attempts++ > 1000) {
+ /* We must reset the receiver */
+ OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST));
+ udelay(10);
+ OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
+ udelay(10);
+ printk("McBSP receiver not ready\n");
+ return -EAGAIN;
+ }
+ }
+
+ /* Receiver is ready, let's read the dummy data */
+ if (rx_word_length > OMAP_MCBSP_WORD_16)
+ word_msb = OMAP_MCBSP_READ(io_base, DRR2);
+ word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
+
+ return 0;
+}
+
+int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word)
+{
+ u32 io_base = mcbsp[id].io_base, clock_word = 0;
+ omap_mcbsp_word_length tx_word_length = mcbsp[id].tx_word_length;
+ omap_mcbsp_word_length rx_word_length = mcbsp[id].rx_word_length;
+ u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
+
+ if (tx_word_length != rx_word_length)
+ return -EINVAL;
+
+ /* First we wait for the transmitter to be ready */
+ spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
+ while (!(spcr2 & XRDY)) {
+ spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
+ if (attempts++ > 1000) {
+ /* We must reset the transmitter */
+ OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST));
+ udelay(10);
+ OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
+ udelay(10);
+ printk("McBSP transmitter not ready\n");
+ return -EAGAIN;
+ }
+ }
+
+ /* We first need to enable the bus clock */
+ if (tx_word_length > OMAP_MCBSP_WORD_16)
+ OMAP_MCBSP_WRITE(io_base, DXR2, clock_word >> 16);
+ OMAP_MCBSP_WRITE(io_base, DXR1, clock_word & 0xffff);
+
+ /* We wait for the receiver to be ready */
+ spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
+ while (!(spcr1 & RRDY)) {
+ spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
+ if (attempts++ > 1000) {
+ /* We must reset the receiver */
+ OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST));
+ udelay(10);
+ OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
+ udelay(10);
+ printk("McBSP receiver not ready\n");
+ return -EAGAIN;
+ }
+ }
+
+ /* Receiver is ready, there is something for us */
+ if (rx_word_length > OMAP_MCBSP_WORD_16)
+ word_msb = OMAP_MCBSP_READ(io_base, DRR2);
+ word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
+
+ word[0] = (word_lsb | (word_msb << 16));
+
+ return 0;
+}
+
+
/*
* Simple DMA based buffer rx/tx routines.
* Nothing fancy, just a single buffer tx/rx through DMA.
@@ -471,6 +661,9 @@ u32 omap_mcbsp_recv_word(unsigned int id)
int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
{
int dma_tx_ch;
+ int src_port = 0;
+ int dest_port = 0;
+ int sync_dev = 0;
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
@@ -487,20 +680,27 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
init_completion(&(mcbsp[id].tx_dma_completion));
+ if (cpu_class_is_omap1()) {
+ src_port = OMAP_DMA_PORT_TIPB;
+ dest_port = OMAP_DMA_PORT_EMIFF;
+ }
+ if (cpu_is_omap24xx())
+ sync_dev = mcbsp[id].dma_tx_sync;
+
omap_set_dma_transfer_params(mcbsp[id].dma_tx_lch,
OMAP_DMA_DATA_TYPE_S16,
length >> 1, 1,
OMAP_DMA_SYNC_ELEMENT,
- 0, 0);
+ sync_dev, 0);
omap_set_dma_dest_params(mcbsp[id].dma_tx_lch,
- OMAP_DMA_PORT_TIPB,
+ src_port,
OMAP_DMA_AMODE_CONSTANT,
mcbsp[id].io_base + OMAP_MCBSP_REG_DXR1,
0, 0);
omap_set_dma_src_params(mcbsp[id].dma_tx_lch,
- OMAP_DMA_PORT_EMIFF,
+ dest_port,
OMAP_DMA_AMODE_POST_INC,
buffer,
0, 0);
@@ -514,6 +714,9 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length)
{
int dma_rx_ch;
+ int src_port = 0;
+ int dest_port = 0;
+ int sync_dev = 0;
if (omap_mcbsp_check(id) < 0)
return -EINVAL;
@@ -530,20 +733,27 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int leng
init_completion(&(mcbsp[id].rx_dma_completion));
+ if (cpu_class_is_omap1()) {
+ src_port = OMAP_DMA_PORT_TIPB;
+ dest_port = OMAP_DMA_PORT_EMIFF;
+ }
+ if (cpu_is_omap24xx())
+ sync_dev = mcbsp[id].dma_rx_sync;
+
omap_set_dma_transfer_params(mcbsp[id].dma_rx_lch,
OMAP_DMA_DATA_TYPE_S16,
length >> 1, 1,
OMAP_DMA_SYNC_ELEMENT,
- 0, 0);
+ sync_dev, 0);
omap_set_dma_src_params(mcbsp[id].dma_rx_lch,
- OMAP_DMA_PORT_TIPB,
+ src_port,
OMAP_DMA_AMODE_CONSTANT,
mcbsp[id].io_base + OMAP_MCBSP_REG_DRR1,
0, 0);
omap_set_dma_dest_params(mcbsp[id].dma_rx_lch,
- OMAP_DMA_PORT_EMIFF,
+ dest_port,
OMAP_DMA_AMODE_POST_INC,
buffer,
0, 0);
@@ -688,6 +898,23 @@ static const struct omap_mcbsp_info mcbsp_1610[] = {
};
#endif
+#if defined(CONFIG_ARCH_OMAP24XX)
+static const struct omap_mcbsp_info mcbsp_24xx[] = {
+ [0] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP1_BASE),
+ .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
+ .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
+ .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
+ .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
+ },
+ [1] = { .virt_base = IO_ADDRESS(OMAP24XX_MCBSP2_BASE),
+ .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
+ .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
+ .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
+ .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
+ },
+};
+#endif
+
static int __init omap_mcbsp_init(void)
{
int mcbsp_count = 0, i;
@@ -695,6 +922,7 @@ static int __init omap_mcbsp_init(void)
printk("Initializing OMAP McBSP system\n");
+#ifdef CONFIG_ARCH_OMAP1
mcbsp_dsp_ck = clk_get(0, "dsp_ck");
if (IS_ERR(mcbsp_dsp_ck)) {
printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
@@ -710,6 +938,29 @@ static int __init omap_mcbsp_init(void)
printk(KERN_ERR "mcbsp: could not acquire dspxor_ck handle.\n");
return PTR_ERR(mcbsp_dspxor_ck);
}
+#endif
+#ifdef CONFIG_ARCH_OMAP2
+ mcbsp1_ick = clk_get(0, "mcbsp1_ick");
+ if (IS_ERR(mcbsp1_ick)) {
+ printk(KERN_ERR "mcbsp: could not acquire mcbsp1_ick handle.\n");
+ return PTR_ERR(mcbsp1_ick);
+ }
+ mcbsp1_fck = clk_get(0, "mcbsp1_fck");
+ if (IS_ERR(mcbsp1_fck)) {
+ printk(KERN_ERR "mcbsp: could not acquire mcbsp1_fck handle.\n");
+ return PTR_ERR(mcbsp1_fck);
+ }
+ mcbsp2_ick = clk_get(0, "mcbsp2_ick");
+ if (IS_ERR(mcbsp2_ick)) {
+ printk(KERN_ERR "mcbsp: could not acquire mcbsp2_ick handle.\n");
+ return PTR_ERR(mcbsp2_ick);
+ }
+ mcbsp2_fck = clk_get(0, "mcbsp2_fck");
+ if (IS_ERR(mcbsp2_fck)) {
+ printk(KERN_ERR "mcbsp: could not acquire mcbsp2_fck handle.\n");
+ return PTR_ERR(mcbsp2_fck);
+ }
+#endif
#ifdef CONFIG_ARCH_OMAP730
if (cpu_is_omap730()) {
@@ -718,7 +969,7 @@ static int __init omap_mcbsp_init(void)
}
#endif
#ifdef CONFIG_ARCH_OMAP15XX
- if (cpu_is_omap1510()) {
+ if (cpu_is_omap15xx()) {
mcbsp_info = mcbsp_1510;
mcbsp_count = ARRAY_SIZE(mcbsp_1510);
}
@@ -729,6 +980,19 @@ static int __init omap_mcbsp_init(void)
mcbsp_count = ARRAY_SIZE(mcbsp_1610);
}
#endif
+#if defined(CONFIG_ARCH_OMAP24XX)
+ if (cpu_is_omap24xx()) {
+ mcbsp_info = mcbsp_24xx;
+ mcbsp_count = ARRAY_SIZE(mcbsp_24xx);
+
+ /* REVISIT: where's the right place? */
+ omap2_mcbsp2_mux_setup();
+ sys_ck = clk_get(0, "sys_ck");
+ sys_clkout = clk_get(0, "sys_clkout");
+ clk_set_parent(sys_clkout, sys_ck);
+ clk_enable(sys_clkout);
+ }
+#endif
for (i = 0; i < OMAP_MAX_MCBSP_COUNT ; i++) {
if (i >= mcbsp_count) {
mcbsp[i].io_base = 0;
@@ -741,6 +1005,7 @@ static int __init omap_mcbsp_init(void)
mcbsp[i].dma_rx_lch = -1;
mcbsp[i].io_base = mcbsp_info[i].virt_base;
+ mcbsp[i].io_type = OMAP_MCBSP_IRQ_IO; /* Default I/O is IRQ based */
mcbsp[i].tx_irq = mcbsp_info[i].tx_irq;
mcbsp[i].rx_irq = mcbsp_info[i].rx_irq;
mcbsp[i].dma_rx_sync = mcbsp_info[i].dma_rx_sync;
@@ -751,11 +1016,11 @@ static int __init omap_mcbsp_init(void)
return 0;
}
-
arch_initcall(omap_mcbsp_init);
EXPORT_SYMBOL(omap_mcbsp_config);
EXPORT_SYMBOL(omap_mcbsp_request);
+EXPORT_SYMBOL(omap_mcbsp_set_io_type);
EXPORT_SYMBOL(omap_mcbsp_free);
EXPORT_SYMBOL(omap_mcbsp_start);
EXPORT_SYMBOL(omap_mcbsp_stop);
@@ -763,4 +1028,6 @@ EXPORT_SYMBOL(omap_mcbsp_xmit_word);
EXPORT_SYMBOL(omap_mcbsp_recv_word);
EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
+EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
+EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
diff --git a/arch/arm/plat-omap/ocpi.c b/arch/arm/plat-omap/ocpi.c
index 5cc6775c789c9..37792d43738b1 100644
--- a/arch/arm/plat-omap/ocpi.c
+++ b/arch/arm/plat-omap/ocpi.c
@@ -62,9 +62,6 @@ int ocpi_enable(void)
if (!cpu_is_omap16xx())
return -ENODEV;
- /* Make sure there's clock for OCPI */
- clk_enable(ocpi_ck);
-
/* Enable access for OHCI in OCPI */
val = omap_readl(OCPI_PROT);
val &= ~0xff;
diff --git a/arch/arm/plat-omap/pm.c b/arch/arm/plat-omap/pm.c
index 093efd786f211..1a24e2c10714e 100644
--- a/arch/arm/plat-omap/pm.c
+++ b/arch/arm/plat-omap/pm.c
@@ -38,6 +38,7 @@
#include <linux/pm.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
+#include <linux/pm.h>
#include <linux/interrupt.h>
#include <asm/io.h>
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index ee82763b02b8f..b7bf09b1b412c 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -16,24 +16,94 @@
#include <linux/kernel.h>
#include <linux/init.h>
-#include <asm/mach/map.h>
#include <asm/tlb.h>
#include <asm/io.h>
#include <asm/cacheflush.h>
+#include <asm/mach/map.h>
+
#include <asm/arch/sram.h>
+#include <asm/arch/board.h>
#define OMAP1_SRAM_PA 0x20000000
#define OMAP1_SRAM_VA 0xd0000000
#define OMAP2_SRAM_PA 0x40200000
+#define OMAP2_SRAM_PUB_PA 0x4020f800
#define OMAP2_SRAM_VA 0xd0000000
+#define OMAP2_SRAM_PUB_VA 0xd0000800
+#if defined(CONFIG_ARCH_OMAP24XX)
+#define SRAM_BOOTLOADER_SZ 0x00
+#else
#define SRAM_BOOTLOADER_SZ 0x80
+#endif
+
+#define VA_REQINFOPERM0 IO_ADDRESS(0x68005048)
+#define VA_READPERM0 IO_ADDRESS(0x68005050)
+#define VA_WRITEPERM0 IO_ADDRESS(0x68005058)
+#define VA_CONTROL_STAT IO_ADDRESS(0x480002F8)
+#define GP_DEVICE 0x300
+#define TYPE_MASK 0x700
+
+#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
static unsigned long omap_sram_base;
static unsigned long omap_sram_size;
static unsigned long omap_sram_ceil;
+unsigned long omap_fb_sram_start;
+unsigned long omap_fb_sram_size;
+
+/* Depending on the target RAMFS firewall setup, the public usable amount of
+ * SRAM varies. The default accessable size for all device types is 2k. A GP
+ * device allows ARM11 but not other initators for full size. This
+ * functionality seems ok until some nice security API happens.
+ */
+static int is_sram_locked(void)
+{
+ int type = 0;
+
+ if (cpu_is_omap242x())
+ type = __raw_readl(VA_CONTROL_STAT) & TYPE_MASK;
+
+ if (type == GP_DEVICE) {
+ /* RAMFW: R/W access to all initators for all qualifier sets */
+ if (cpu_is_omap242x()) {
+ __raw_writel(0xFF, VA_REQINFOPERM0); /* all q-vects */
+ __raw_writel(0xCFDE, VA_READPERM0); /* all i-read */
+ __raw_writel(0xCFDE, VA_WRITEPERM0); /* all i-write */
+ }
+ return 0;
+ } else
+ return 1; /* assume locked with no PPA or security driver */
+}
+
+void get_fb_sram_conf(unsigned long start_avail, unsigned size_avail,
+ unsigned long *start, unsigned long *size)
+{
+ const struct omap_fbmem_config *fbmem_conf;
+
+ fbmem_conf = omap_get_config(OMAP_TAG_FBMEM, struct omap_fbmem_config);
+ if (fbmem_conf != NULL) {
+ *start = fbmem_conf->fb_sram_start;
+ *size = fbmem_conf->fb_sram_size;
+ } else {
+ *size = 0;
+ *start = 0;
+ }
+
+ if (*size && (
+ *start < start_avail ||
+ *start + *size > start_avail + size_avail)) {
+ printk(KERN_ERR "invalid FB SRAM configuration\n");
+ *start = start_avail;
+ *size = size_avail;
+ }
+
+ if (*size)
+ pr_info("Reserving %lu bytes SRAM for frame buffer\n", *size);
+}
+
/*
* The amount of SRAM depends on the core type.
* Note that we cannot try to test for SRAM here because writes
@@ -42,26 +112,45 @@ static unsigned long omap_sram_ceil;
*/
void __init omap_detect_sram(void)
{
- if (!cpu_is_omap24xx())
+ unsigned long sram_start;
+
+ if (cpu_is_omap24xx()) {
+ if (is_sram_locked()) {
+ omap_sram_base = OMAP2_SRAM_PUB_VA;
+ sram_start = OMAP2_SRAM_PUB_PA;
+ omap_sram_size = 0x800; /* 2K */
+ } else {
+ omap_sram_base = OMAP2_SRAM_VA;
+ sram_start = OMAP2_SRAM_PA;
+ if (cpu_is_omap242x())
+ omap_sram_size = 0xa0000; /* 640K */
+ else if (cpu_is_omap243x())
+ omap_sram_size = 0x10000; /* 64K */
+ }
+ } else {
omap_sram_base = OMAP1_SRAM_VA;
- else
- omap_sram_base = OMAP2_SRAM_VA;
-
- if (cpu_is_omap730())
- omap_sram_size = 0x32000; /* 200K */
- else if (cpu_is_omap15xx())
- omap_sram_size = 0x30000; /* 192K */
- else if (cpu_is_omap1610() || cpu_is_omap1621() || cpu_is_omap1710())
- omap_sram_size = 0x4000; /* 16K */
- else if (cpu_is_omap1611())
- omap_sram_size = 0x3e800; /* 250K */
- else if (cpu_is_omap2420())
- omap_sram_size = 0xa0014; /* 640K */
- else {
- printk(KERN_ERR "Could not detect SRAM size\n");
- omap_sram_size = 0x4000;
+ sram_start = OMAP1_SRAM_PA;
+
+ if (cpu_is_omap730())
+ omap_sram_size = 0x32000; /* 200K */
+ else if (cpu_is_omap15xx())
+ omap_sram_size = 0x30000; /* 192K */
+ else if (cpu_is_omap1610() || cpu_is_omap1621() ||
+ cpu_is_omap1710())
+ omap_sram_size = 0x4000; /* 16K */
+ else if (cpu_is_omap1611())
+ omap_sram_size = 0x3e800; /* 250K */
+ else {
+ printk(KERN_ERR "Could not detect SRAM size\n");
+ omap_sram_size = 0x4000;
+ }
}
-
+ get_fb_sram_conf(sram_start + SRAM_BOOTLOADER_SZ,
+ omap_sram_size - SRAM_BOOTLOADER_SZ,
+ &omap_fb_sram_start, &omap_fb_sram_size);
+ if (omap_fb_sram_size)
+ omap_sram_size -= sram_start + omap_sram_size -
+ omap_fb_sram_start;
omap_sram_ceil = omap_sram_base + omap_sram_size;
}
@@ -80,12 +169,20 @@ static struct map_desc omap_sram_io_desc[] __initdata = {
*/
void __init omap_map_sram(void)
{
+ unsigned long base;
+
if (omap_sram_size == 0)
return;
if (cpu_is_omap24xx()) {
omap_sram_io_desc[0].virtual = OMAP2_SRAM_VA;
- omap_sram_io_desc[0].pfn = __phys_to_pfn(OMAP2_SRAM_PA);
+
+ if (is_sram_locked())
+ base = OMAP2_SRAM_PUB_PA;
+ else
+ base = OMAP2_SRAM_PA;
+ base = ROUND_DOWN(base, PAGE_SIZE);
+ omap_sram_io_desc[0].pfn = __phys_to_pfn(base);
}
omap_sram_io_desc[0].length = (omap_sram_size + PAGE_SIZE-1)/PAGE_SIZE;
@@ -93,7 +190,8 @@ void __init omap_map_sram(void)
iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc));
printk(KERN_INFO "SRAM: Mapped pa 0x%08lx to va 0x%08lx size: 0x%lx\n",
- omap_sram_io_desc[0].pfn, omap_sram_io_desc[0].virtual,
+ __pfn_to_phys(omap_sram_io_desc[0].pfn),
+ omap_sram_io_desc[0].virtual,
omap_sram_io_desc[0].length);
/*
@@ -118,8 +216,9 @@ void * omap_sram_push(void * start, unsigned long size)
printk(KERN_ERR "Not enough space in SRAM\n");
return NULL;
}
+
omap_sram_ceil -= size;
- omap_sram_ceil &= ~0x3;
+ omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, sizeof(void *));
memcpy((void *)omap_sram_ceil, start, size);
return (void *)omap_sram_ceil;
diff --git a/arch/arm/plat-omap/timer32k.c b/arch/arm/plat-omap/timer32k.c
new file mode 100644
index 0000000000000..b2a943bf11ef9
--- /dev/null
+++ b/arch/arm/plat-omap/timer32k.c
@@ -0,0 +1,325 @@
+/*
+ * linux/arch/arm/plat-omap/timer32k.c
+ *
+ * OMAP 32K Timer
+ *
+ * Copyright (C) 2004 - 2005 Nokia Corporation
+ * Partial timer rewrite and additional dynamic tick timer support by
+ * Tony Lindgen <tony@atomide.com> and
+ * Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
+ *
+ * MPU timer code based on the older MPU timer code for OMAP
+ * Copyright (C) 2000 RidgeRun, Inc.
+ * Author: Greg Lonnon <glonnon@ridgerun.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.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * 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 <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+
+#include <asm/system.h>
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/leds.h>
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
+#include <asm/mach/time.h>
+
+struct sys_timer omap_timer;
+
+/*
+ * ---------------------------------------------------------------------------
+ * 32KHz OS timer
+ *
+ * This currently works only on 16xx, as 1510 does not have the continuous
+ * 32KHz synchronous timer. The 32KHz synchronous timer is used to keep track
+ * of time in addition to the 32KHz OS timer. Using only the 32KHz OS timer
+ * on 1510 would be possible, but the timer would not be as accurate as
+ * with the 32KHz synchronized timer.
+ * ---------------------------------------------------------------------------
+ */
+
+#if defined(CONFIG_ARCH_OMAP16XX)
+#define TIMER_32K_SYNCHRONIZED 0xfffbc410
+#elif defined(CONFIG_ARCH_OMAP24XX)
+#define TIMER_32K_SYNCHRONIZED 0x48004010
+#else
+#error OMAP 32KHz timer does not currently work on 15XX!
+#endif
+
+/* 16xx specific defines */
+#define OMAP1_32K_TIMER_BASE 0xfffb9000
+#define OMAP1_32K_TIMER_CR 0x08
+#define OMAP1_32K_TIMER_TVR 0x00
+#define OMAP1_32K_TIMER_TCR 0x04
+
+/* 24xx specific defines */
+#define OMAP2_GP_TIMER_BASE 0x48028000
+#define CM_CLKSEL_WKUP 0x48008440
+#define GP_TIMER_TIDR 0x00
+#define GP_TIMER_TISR 0x18
+#define GP_TIMER_TIER 0x1c
+#define GP_TIMER_TCLR 0x24
+#define GP_TIMER_TCRR 0x28
+#define GP_TIMER_TLDR 0x2c
+#define GP_TIMER_TTGR 0x30
+#define GP_TIMER_TSICR 0x40
+
+#define OMAP_32K_TICKS_PER_HZ (32768 / HZ)
+
+/*
+ * TRM says 1 / HZ = ( TVR + 1) / 32768, so TRV = (32768 / HZ) - 1
+ * so with HZ = 128, TVR = 255.
+ */
+#define OMAP_32K_TIMER_TICK_PERIOD ((32768 / HZ) - 1)
+
+#define JIFFIES_TO_HW_TICKS(nr_jiffies, clock_rate) \
+ (((nr_jiffies) * (clock_rate)) / HZ)
+
+static inline void omap_32k_timer_write(int val, int reg)
+{
+ if (cpu_class_is_omap1())
+ omap_writew(val, OMAP1_32K_TIMER_BASE + reg);
+
+ if (cpu_is_omap24xx())
+ omap_writel(val, OMAP2_GP_TIMER_BASE + reg);
+}
+
+static inline unsigned long omap_32k_timer_read(int reg)
+{
+ if (cpu_class_is_omap1())
+ return omap_readl(OMAP1_32K_TIMER_BASE + reg) & 0xffffff;
+
+ if (cpu_is_omap24xx())
+ return omap_readl(OMAP2_GP_TIMER_BASE + reg);
+}
+
+/*
+ * The 32KHz synchronized timer is an additional timer on 16xx.
+ * It is always running.
+ */
+static inline unsigned long omap_32k_sync_timer_read(void)
+{
+ return omap_readl(TIMER_32K_SYNCHRONIZED);
+}
+
+static inline void omap_32k_timer_start(unsigned long load_val)
+{
+ if (cpu_class_is_omap1()) {
+ omap_32k_timer_write(load_val, OMAP1_32K_TIMER_TVR);
+ omap_32k_timer_write(0x0f, OMAP1_32K_TIMER_CR);
+ }
+
+ if (cpu_is_omap24xx()) {
+ omap_32k_timer_write(0xffffffff - load_val, GP_TIMER_TCRR);
+ omap_32k_timer_write((1 << 1), GP_TIMER_TIER);
+ omap_32k_timer_write((1 << 1) | 1, GP_TIMER_TCLR);
+ }
+}
+
+static inline void omap_32k_timer_stop(void)
+{
+ if (cpu_class_is_omap1())
+ omap_32k_timer_write(0x0, OMAP1_32K_TIMER_CR);
+
+ if (cpu_is_omap24xx())
+ omap_32k_timer_write(0x0, GP_TIMER_TCLR);
+}
+
+/*
+ * Rounds down to nearest usec. Note that this will overflow for larger values.
+ */
+static inline unsigned long omap_32k_ticks_to_usecs(unsigned long ticks_32k)
+{
+ return (ticks_32k * 5*5*5*5*5*5) >> 9;
+}
+
+/*
+ * Rounds down to nearest nsec.
+ */
+static inline unsigned long long
+omap_32k_ticks_to_nsecs(unsigned long ticks_32k)
+{
+ return (unsigned long long) ticks_32k * 1000 * 5*5*5*5*5*5 >> 9;
+}
+
+static unsigned long omap_32k_last_tick = 0;
+
+/*
+ * Returns elapsed usecs since last 32k timer interrupt
+ */
+static unsigned long omap_32k_timer_gettimeoffset(void)
+{
+ unsigned long now = omap_32k_sync_timer_read();
+ return omap_32k_ticks_to_usecs(now - omap_32k_last_tick);
+}
+
+/*
+ * Returns current time from boot in nsecs. It's OK for this to wrap
+ * around for now, as it's just a relative time stamp.
+ */
+unsigned long long sched_clock(void)
+{
+ return omap_32k_ticks_to_nsecs(omap_32k_sync_timer_read());
+}
+
+/*
+ * Timer interrupt for 32KHz timer. When dynamic tick is enabled, this
+ * function is also called from other interrupts to remove latency
+ * issues with dynamic tick. In the dynamic tick case, we need to lock
+ * with irqsave.
+ */
+static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id,
+ struct pt_regs *regs)
+{
+ unsigned long flags;
+ unsigned long now;
+
+ write_seqlock_irqsave(&xtime_lock, flags);
+
+ if (cpu_is_omap24xx()) {
+ u32 status = omap_32k_timer_read(GP_TIMER_TISR);
+ omap_32k_timer_write(status, GP_TIMER_TISR);
+ }
+
+ now = omap_32k_sync_timer_read();
+
+ while (now - omap_32k_last_tick >= OMAP_32K_TICKS_PER_HZ) {
+ omap_32k_last_tick += OMAP_32K_TICKS_PER_HZ;
+ timer_tick(regs);
+ }
+
+ /* Restart timer so we don't drift off due to modulo or dynamic tick.
+ * By default we program the next timer to be continuous to avoid
+ * latencies during high system load. During dynamic tick operation the
+ * continuous timer can be overridden from pm_idle to be longer.
+ */
+ omap_32k_timer_start(omap_32k_last_tick + OMAP_32K_TICKS_PER_HZ - now);
+ write_sequnlock_irqrestore(&xtime_lock, flags);
+
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_NO_IDLE_HZ
+/*
+ * Programs the next timer interrupt needed. Called when dynamic tick is
+ * enabled, and to reprogram the ticks to skip from pm_idle. Note that
+ * we can keep the timer continuous, and don't need to set it to run in
+ * one-shot mode. This is because the timer will get reprogrammed again
+ * after next interrupt.
+ */
+void omap_32k_timer_reprogram(unsigned long next_tick)
+{
+ omap_32k_timer_start(JIFFIES_TO_HW_TICKS(next_tick, 32768) + 1);
+}
+
+static struct irqaction omap_32k_timer_irq;
+extern struct timer_update_handler timer_update;
+
+static int omap_32k_timer_enable_dyn_tick(void)
+{
+ /* No need to reprogram timer, just use the next interrupt */
+ return 0;
+}
+
+static int omap_32k_timer_disable_dyn_tick(void)
+{
+ omap_32k_timer_start(OMAP_32K_TIMER_TICK_PERIOD);
+ return 0;
+}
+
+static struct dyn_tick_timer omap_dyn_tick_timer = {
+ .enable = omap_32k_timer_enable_dyn_tick,
+ .disable = omap_32k_timer_disable_dyn_tick,
+ .reprogram = omap_32k_timer_reprogram,
+ .handler = omap_32k_timer_interrupt,
+};
+#endif /* CONFIG_NO_IDLE_HZ */
+
+static struct irqaction omap_32k_timer_irq = {
+ .name = "32KHz timer",
+ .flags = SA_INTERRUPT | SA_TIMER,
+ .handler = omap_32k_timer_interrupt,
+};
+
+static struct clk * gpt1_ick;
+static struct clk * gpt1_fck;
+
+static __init void omap_init_32k_timer(void)
+{
+#ifdef CONFIG_NO_IDLE_HZ
+ omap_timer.dyn_tick = &omap_dyn_tick_timer;
+#endif
+
+ if (cpu_class_is_omap1())
+ setup_irq(INT_OS_TIMER, &omap_32k_timer_irq);
+ if (cpu_is_omap24xx())
+ setup_irq(37, &omap_32k_timer_irq);
+ omap_timer.offset = omap_32k_timer_gettimeoffset;
+ omap_32k_last_tick = omap_32k_sync_timer_read();
+
+ /* REVISIT: Check 24xx TIOCP_CFG settings after idle works */
+ if (cpu_is_omap24xx()) {
+ omap_32k_timer_write(0, GP_TIMER_TCLR);
+ omap_writel(0, CM_CLKSEL_WKUP); /* 32KHz clock source */
+
+ gpt1_ick = clk_get(NULL, "gpt1_ick");
+ if (IS_ERR(gpt1_ick))
+ printk(KERN_ERR "Could not get gpt1_ick\n");
+ else
+ clk_enable(gpt1_ick);
+
+ gpt1_fck = clk_get(NULL, "gpt1_fck");
+ if (IS_ERR(gpt1_fck))
+ printk(KERN_ERR "Could not get gpt1_fck\n");
+ else
+ clk_enable(gpt1_fck);
+
+ mdelay(100); /* Wait for clocks to stabilize */
+
+ omap_32k_timer_write(0x7, GP_TIMER_TISR);
+ }
+
+ omap_32k_timer_start(OMAP_32K_TIMER_TICK_PERIOD);
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * Timer initialization
+ * ---------------------------------------------------------------------------
+ */
+static void __init omap_timer_init(void)
+{
+ omap_init_32k_timer();
+}
+
+struct sys_timer omap_timer = {
+ .init = omap_timer_init,
+ .offset = NULL, /* Initialized later */
+};
diff --git a/arch/arm/vfp/vfpdouble.c b/arch/arm/vfp/vfpdouble.c
index 9b367a65cb4d6..febd115dba28a 100644
--- a/arch/arm/vfp/vfpdouble.c
+++ b/arch/arm/vfp/vfpdouble.c
@@ -588,6 +588,7 @@ static u32 vfp_double_ftosi(int sd, int unused, int dm, u32 fpscr)
struct vfp_double vdm;
u32 d, exceptions = 0;
int rmode = fpscr & FPSCR_RMODE_MASK;
+ int tm;
vfp_double_unpack(&vdm, vfp_get_double(dm));
vfp_double_dump("VDM", &vdm);
@@ -595,10 +596,14 @@ static u32 vfp_double_ftosi(int sd, int unused, int dm, u32 fpscr)
/*
* Do we have denormalised number?
*/
- if (vfp_double_type(&vdm) & VFP_DENORMAL)
+ tm = vfp_double_type(&vdm);
+ if (tm & VFP_DENORMAL)
exceptions |= FPSCR_IDC;
- if (vdm.exponent >= 1023 + 32) {
+ if (tm & VFP_NAN) {
+ d = 0;
+ exceptions |= FPSCR_IOC;
+ } else if (vdm.exponent >= 1023 + 32) {
d = 0x7fffffff;
if (vdm.sign)
d = ~d;
@@ -1122,9 +1127,9 @@ u32 vfp_double_cpdo(u32 inst, u32 fpscr)
{
u32 op = inst & FOP_MASK;
u32 exceptions = 0;
- unsigned int dd = vfp_get_sd(inst);
- unsigned int dn = vfp_get_sn(inst);
- unsigned int dm = vfp_get_sm(inst);
+ unsigned int dd = vfp_get_dd(inst);
+ unsigned int dn = vfp_get_dn(inst);
+ unsigned int dm = vfp_get_dm(inst);
unsigned int vecitr, veclen, vecstride;
u32 (*fop)(int, int, s32, u32);
@@ -1141,7 +1146,7 @@ u32 vfp_double_cpdo(u32 inst, u32 fpscr)
pr_debug("VFP: vecstride=%u veclen=%u\n", vecstride,
(veclen >> FPSCR_LENGTH_BIT) + 1);
- fop = (op == FOP_EXT) ? fop_extfns[dn] : fop_fns[FOP_TO_IDX(op)];
+ fop = (op == FOP_EXT) ? fop_extfns[FEXT_TO_IDX(inst)] : fop_fns[FOP_TO_IDX(op)];
if (!fop)
goto invalid;
@@ -1149,17 +1154,13 @@ u32 vfp_double_cpdo(u32 inst, u32 fpscr)
u32 except;
if (op == FOP_EXT)
- pr_debug("VFP: itr%d (d%u.%u) = op[%u] (d%u.%u)\n",
+ pr_debug("VFP: itr%d (d%u) = op[%u] (d%u)\n",
vecitr >> FPSCR_LENGTH_BIT,
- dd >> 1, dd & 1, dn,
- dm >> 1, dm & 1);
+ dd, dn, dm);
else
- pr_debug("VFP: itr%d (d%u.%u) = (d%u.%u) op[%u] (d%u.%u)\n",
+ pr_debug("VFP: itr%d (d%u) = (d%u) op[%u] (d%u)\n",
vecitr >> FPSCR_LENGTH_BIT,
- dd >> 1, dd & 1,
- dn >> 1, dn & 1,
- FOP_TO_IDX(op),
- dm >> 1, dm & 1);
+ dd, dn, FOP_TO_IDX(op), dm);
except = fop(dd, dn, dm, fpscr);
pr_debug("VFP: itr%d: exceptions=%08x\n",
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index b7ed57e00cd47..a3f65b47aea9e 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -189,11 +189,10 @@ vfp_put_float:
.globl vfp_get_double
vfp_get_double:
- mov r0, r0, lsr #1
add pc, pc, r0, lsl #3
mov r0, r0
.irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- mrrc p10, 1, r0, r1, c\dr @ fmrrd r0, r1, d\dr
+ mrrc p11, 1, r0, r1, c\dr @ fmrrd r0, r1, d\dr
mov pc, lr
.endr
@@ -204,10 +203,9 @@ vfp_get_double:
.globl vfp_put_double
vfp_put_double:
- mov r0, r0, lsr #1
add pc, pc, r0, lsl #3
mov r0, r0
.irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- mcrr p10, 1, r1, r2, c\dr @ fmrrd r1, r2, d\dr
+ mcrr p11, 1, r1, r2, c\dr @ fmdrr r1, r2, d\dr
mov pc, lr
.endr
diff --git a/arch/arm/vfp/vfpsingle.c b/arch/arm/vfp/vfpsingle.c
index 14dd696ddeb1e..4ac27f1939347 100644
--- a/arch/arm/vfp/vfpsingle.c
+++ b/arch/arm/vfp/vfpsingle.c
@@ -632,6 +632,7 @@ static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr)
struct vfp_single vsm;
u32 d, exceptions = 0;
int rmode = fpscr & FPSCR_RMODE_MASK;
+ int tm;
vfp_single_unpack(&vsm, m);
vfp_single_dump("VSM", &vsm);
@@ -639,10 +640,14 @@ static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr)
/*
* Do we have a denormalised number?
*/
+ tm = vfp_single_type(&vsm);
if (vfp_single_type(&vsm) & VFP_DENORMAL)
exceptions |= FPSCR_IDC;
- if (vsm.exponent >= 127 + 32) {
+ if (tm & VFP_NAN) {
+ d = 0;
+ exceptions |= FPSCR_IOC;
+ } else if (vsm.exponent >= 127 + 32) {
/*
* m >= 2^31-2^7: invalid
*/
@@ -1188,7 +1193,7 @@ u32 vfp_single_cpdo(u32 inst, u32 fpscr)
pr_debug("VFP: vecstride=%u veclen=%u\n", vecstride,
(veclen >> FPSCR_LENGTH_BIT) + 1);
- fop = (op == FOP_EXT) ? fop_extfns[sn] : fop_fns[FOP_TO_IDX(op)];
+ fop = (op == FOP_EXT) ? fop_extfns[FEXT_TO_IDX(inst)] : fop_fns[FOP_TO_IDX(op)];
if (!fop)
goto invalid;
diff --git a/arch/arm26/kernel/armksyms.c b/arch/arm26/kernel/armksyms.c
index a6a1b33734440..9d66c27f27241 100644
--- a/arch/arm26/kernel/armksyms.c
+++ b/arch/arm26/kernel/armksyms.c
@@ -152,7 +152,6 @@ EXPORT_SYMBOL(strncmp);
EXPORT_SYMBOL(strchr);
EXPORT_SYMBOL(strlen);
EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(memset);
diff --git a/arch/cris/kernel/crisksyms.c b/arch/cris/kernel/crisksyms.c
index de39725da9202..d57859053ce7a 100644
--- a/arch/cris/kernel/crisksyms.c
+++ b/arch/cris/kernel/crisksyms.c
@@ -39,7 +39,6 @@ EXPORT_SYMBOL(loops_per_usec);
/* String functions */
EXPORT_SYMBOL(memcmp);
EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(strcpy);
EXPORT_SYMBOL(strchr);
diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S
index 1d21c8d34d8ab..a9b59527a7415 100644
--- a/arch/frv/kernel/entry.S
+++ b/arch/frv/kernel/entry.S
@@ -1170,12 +1170,6 @@ __syscall_badsys:
# syscall vector table
#
###############################################################################
-#ifdef CONFIG_MMU
-#define __MMU(X) X
-#else
-#define __MMU(X) sys_ni_syscall
-#endif
-
.section .rodata
ALIGN
.globl sys_call_table
@@ -1305,7 +1299,7 @@ sys_call_table:
.long sys_newuname
.long sys_ni_syscall /* old "cacheflush" */
.long sys_adjtimex
- .long __MMU(sys_mprotect) /* 125 */
+ .long sys_mprotect /* 125 */
.long sys_sigprocmask
.long sys_ni_syscall /* old "create_module" */
.long sys_init_module
@@ -1324,16 +1318,16 @@ sys_call_table:
.long sys_getdents
.long sys_select
.long sys_flock
- .long __MMU(sys_msync)
+ .long sys_msync
.long sys_readv /* 145 */
.long sys_writev
.long sys_getsid
.long sys_fdatasync
.long sys_sysctl
- .long __MMU(sys_mlock) /* 150 */
- .long __MMU(sys_munlock)
- .long __MMU(sys_mlockall)
- .long __MMU(sys_munlockall)
+ .long sys_mlock /* 150 */
+ .long sys_munlock
+ .long sys_mlockall
+ .long sys_munlockall
.long sys_sched_setparam
.long sys_sched_getparam /* 155 */
.long sys_sched_setscheduler
@@ -1343,7 +1337,7 @@ sys_call_table:
.long sys_sched_get_priority_min /* 160 */
.long sys_sched_rr_get_interval
.long sys_nanosleep
- .long __MMU(sys_mremap)
+ .long sys_mremap
.long sys_setresuid16
.long sys_getresuid16 /* 165 */
.long sys_ni_syscall /* for vm86 */
@@ -1398,8 +1392,8 @@ sys_call_table:
.long sys_setfsuid /* 215 */
.long sys_setfsgid
.long sys_pivot_root
- .long __MMU(sys_mincore)
- .long __MMU(sys_madvise)
+ .long sys_mincore
+ .long sys_madvise
.long sys_getdents64 /* 220 */
.long sys_fcntl64
.long sys_ni_syscall /* reserved for TUX */
@@ -1437,7 +1431,7 @@ sys_call_table:
.long sys_epoll_create
.long sys_epoll_ctl /* 255 */
.long sys_epoll_wait
- .long __MMU(sys_remap_file_pages)
+ .long sys_remap_file_pages
.long sys_set_tid_address
.long sys_timer_create
.long sys_timer_settime /* 260 */
diff --git a/arch/frv/kernel/frv_ksyms.c b/arch/frv/kernel/frv_ksyms.c
index 07c8ffa0dd391..0f273a7aca5ae 100644
--- a/arch/frv/kernel/frv_ksyms.c
+++ b/arch/frv/kernel/frv_ksyms.c
@@ -27,7 +27,6 @@ EXPORT_SYMBOL(__ioremap);
EXPORT_SYMBOL(iounmap);
EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(strchr);
diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c
index b6cd78c972bb4..f8d6dee847811 100644
--- a/arch/h8300/kernel/h8300_ksyms.c
+++ b/arch/h8300/kernel/h8300_ksyms.c
@@ -25,7 +25,6 @@ extern char h8300_debug_device[];
/* platform dependent support */
EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(strchr);
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index f17bd1d2707eb..18ec9fe6deb69 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -53,6 +53,35 @@ source "init/Kconfig"
menu "Processor type and features"
+config SMP
+ bool "Symmetric multi-processing support"
+ ---help---
+ This enables support for systems with more than one CPU. If you have
+ a system with only one CPU, like most personal computers, say N. If
+ you have a system with more than one CPU, say Y.
+
+ If you say N here, the kernel will run on single and multiprocessor
+ machines, but will use only one CPU of a multiprocessor machine. If
+ you say Y here, the kernel will run on many, but not all,
+ singleprocessor machines. On a singleprocessor machine, the kernel
+ will run faster if you say N here.
+
+ Note that if you say Y here and choose architecture "586" or
+ "Pentium" under "Processor family", the kernel will not work on 486
+ architectures. Similarly, multiprocessor kernels for the "PPro"
+ architecture may not work on all Pentium based boards.
+
+ People using multiprocessor machines who say Y here should also say
+ Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
+ Management" code will be disabled if you say Y here.
+
+ See also the <file:Documentation/smp.txt>,
+ <file:Documentation/i386/IO-APIC.txt>,
+ <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
+ <http://www.tldp.org/docs.html#howto>.
+
+ If you don't know what to do here, say N.
+
choice
prompt "Subarchitecture Type"
default X86_PC
@@ -178,35 +207,6 @@ config HPET_EMULATE_RTC
depends on HPET_TIMER && RTC=y
default y
-config SMP
- bool "Symmetric multi-processing support"
- ---help---
- This enables support for systems with more than one CPU. If you have
- a system with only one CPU, like most personal computers, say N. If
- you have a system with more than one CPU, say Y.
-
- If you say N here, the kernel will run on single and multiprocessor
- machines, but will use only one CPU of a multiprocessor machine. If
- you say Y here, the kernel will run on many, but not all,
- singleprocessor machines. On a singleprocessor machine, the kernel
- will run faster if you say N here.
-
- Note that if you say Y here and choose architecture "586" or
- "Pentium" under "Processor family", the kernel will not work on 486
- architectures. Similarly, multiprocessor kernels for the "PPro"
- architecture may not work on all Pentium based boards.
-
- People using multiprocessor machines who say Y here should also say
- Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
- Management" code will be disabled if you say Y here.
-
- See also the <file:Documentation/smp.txt>,
- <file:Documentation/i386/IO-APIC.txt>,
- <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
- <http://www.tldp.org/docs.html#howto>.
-
- If you don't know what to do here, say N.
-
config NR_CPUS
int "Maximum number of CPUs (2-255)"
range 2 255
@@ -522,6 +522,12 @@ config NUMA
comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI)
+config NODES_SHIFT
+ int
+ default "4" if X86_NUMAQ
+ default "3"
+ depends on NEED_MULTIPLE_NODES
+
config HAVE_ARCH_BOOTMEM_NODE
bool
depends on NUMA
@@ -757,15 +763,6 @@ config HOTPLUG_CPU
Say N.
-config DOUBLEFAULT
- default y
- bool "Enable doublefault exception handler" if EMBEDDED
- help
- This option allows trapping of rare doublefault exceptions that
- would otherwise cause a system to silently reboot. Disabling this
- option saves about 4k and might cause you much additional grey
- hair.
-
endmenu
diff --git a/arch/i386/Kconfig.cpu b/arch/i386/Kconfig.cpu
index 79603b3471f96..eb130482ba186 100644
--- a/arch/i386/Kconfig.cpu
+++ b/arch/i386/Kconfig.cpu
@@ -311,5 +311,5 @@ config X86_OOSTORE
config X86_TSC
bool
- depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1) && !X86_NUMAQ
+ depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX) && !X86_NUMAQ
default y
diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S
index 0000a26745372..c9343c3a8082c 100644
--- a/arch/i386/boot/video.S
+++ b/arch/i386/boot/video.S
@@ -97,6 +97,7 @@
#define PARAM_VESAPM_OFF 0x30
#define PARAM_LFB_PAGES 0x32
#define PARAM_VESA_ATTRIB 0x34
+#define PARAM_CAPABILITIES 0x36
/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
#ifdef CONFIG_VIDEO_RETAIN
@@ -233,6 +234,10 @@ mopar_gr:
movw 18(%di), %ax
movl %eax, %fs:(PARAM_LFB_SIZE)
+# store mode capabilities
+ movl 10(%di), %eax
+ movl %eax, %fs:(PARAM_CAPABILITIES)
+
# switching the DAC to 8-bit is for <= 8 bpp only
movw %fs:(PARAM_LFB_DEPTH), %ax
cmpw $8, %ax
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 033066176b3ef..030a0007a4e07 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -168,7 +168,7 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
unsigned long i;
int config_size;
- if (!phys_addr || !size)
+ if (!phys_addr || !size || !cpu_has_apic)
return -EINVAL;
mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size);
@@ -215,7 +215,7 @@ static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
{
struct acpi_table_madt *madt = NULL;
- if (!phys_addr || !size)
+ if (!phys_addr || !size || !cpu_has_apic)
return -EINVAL;
madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
@@ -693,6 +693,9 @@ static int __init acpi_parse_madt_lapic_entries(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).
@@ -751,6 +754,9 @@ static int __init acpi_parse_madt_ioapic_entries(void)
return -ENODEV;
}
+ if (!cpu_has_apic)
+ return -ENODEV;
+
/*
* if "noapic" boot option, don't look for IO-APICs
*/
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 6273bf74c2031..254cee9f0b7b3 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -62,6 +62,18 @@ int apic_verbosity;
static void apic_pm_activate(void);
+int modern_apic(void)
+{
+ unsigned int lvr, version;
+ /* AMD systems use old APIC versions, so check the CPU */
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
+ boot_cpu_data.x86 >= 0xf)
+ return 1;
+ lvr = apic_read(APIC_LVR);
+ version = GET_APIC_VERSION(lvr);
+ return version >= 0x14;
+}
+
/*
* 'what should we do if we get a hw irq event on an illegal vector'.
* each architecture has to answer this themselves.
@@ -119,10 +131,7 @@ void enable_NMI_through_LVT0 (void * dummy)
int get_physical_broadcast(void)
{
- unsigned int lvr, version;
- lvr = apic_read(APIC_LVR);
- version = GET_APIC_VERSION(lvr);
- if (!APIC_INTEGRATED(version) || version >= 0x14)
+ if (modern_apic())
return 0xff;
else
return 0xf;
@@ -349,9 +358,9 @@ int __init verify_local_APIC(void)
void __init sync_Arb_IDs(void)
{
- /* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 */
- unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
- if (ver >= 0x14) /* P4 or higher */
+ /* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1
+ And not needed on AMD */
+ if (modern_apic())
return;
/*
* Wait for idle.
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 0810f81f2a05d..ff2b2154ac1b6 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -212,8 +212,6 @@ static void __init init_amd(struct cpuinfo_x86 *c)
if (cpuid_eax(0x80000000) >= 0x80000008) {
c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
- if (c->x86_max_cores & (c->x86_max_cores - 1))
- c->x86_max_cores = 1;
}
if (cpuid_eax(0x80000000) >= 0x80000007) {
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index 712a26bd44579..7c0e160a21450 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -46,7 +46,7 @@
#define PFX "powernow-k8: "
#define BFX PFX "BIOS error: "
-#define VERSION "version 1.60.1"
+#define VERSION "version 1.60.2"
#include "powernow-k8.h"
/* serialize freq changes */
@@ -55,7 +55,7 @@ static DEFINE_MUTEX(fidvid_mutex);
static struct powernow_k8_data *powernow_data[NR_CPUS];
#ifndef CONFIG_SMP
-static cpumask_t cpu_core_map[1] = { CPU_MASK_ALL };
+static cpumask_t cpu_core_map[1];
#endif
/* Return a frequency in MHz, given an input fid */
@@ -910,6 +910,9 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
unsigned int newstate;
int ret = -EIO;
+ if (!data)
+ return -EINVAL;
+
/* only run on specific CPU from here on */
oldmask = current->cpus_allowed;
set_cpus_allowed(current, cpumask_of_cpu(pol->cpu));
@@ -969,6 +972,9 @@ static int powernowk8_verify(struct cpufreq_policy *pol)
{
struct powernow_k8_data *data = powernow_data[pol->cpu];
+ if (!data)
+ return -EINVAL;
+
return cpufreq_frequency_table_verify(pol, data->powernow_table);
}
@@ -977,7 +983,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
{
struct powernow_k8_data *data;
cpumask_t oldmask = CPU_MASK_ALL;
- int rc, i;
+ int rc;
if (!cpu_online(pol->cpu))
return -ENODEV;
@@ -1063,8 +1069,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
printk("cpu_init done, current fid 0x%x, vid 0x%x\n",
data->currfid, data->currvid);
- for_each_cpu_mask(i, cpu_core_map[pol->cpu])
- powernow_data[i] = data;
+ powernow_data[pol->cpu] = data;
return 0;
@@ -1104,6 +1109,9 @@ static unsigned int powernowk8_get (unsigned int cpu)
if (!data)
return -EINVAL;
+ if (!data)
+ return -EINVAL;
+
set_cpus_allowed(current, cpumask_of_cpu(cpu));
if (smp_processor_id() != cpu) {
printk(KERN_ERR PFX "limiting to CPU %d failed in powernowk8_get\n", cpu);
diff --git a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
index 055325056a74a..036a9857936fa 100644
--- a/arch/i386/kernel/i386_ksyms.c
+++ b/arch/i386/kernel/i386_ksyms.c
@@ -19,7 +19,6 @@ EXPORT_SYMBOL(__put_user_2);
EXPORT_SYMBOL(__put_user_4);
EXPORT_SYMBOL(__put_user_8);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strstr);
#ifdef CONFIG_SMP
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index 8d8aa9d1796d5..34d21e21e0124 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -38,12 +38,6 @@
int smp_found_config;
unsigned int __initdata maxcpus = NR_CPUS;
-#ifdef CONFIG_HOTPLUG_CPU
-#define CPU_HOTPLUG_ENABLED (1)
-#else
-#define CPU_HOTPLUG_ENABLED (0)
-#endif
-
/*
* Various Linux-internal data structures created from the
* MP-table.
@@ -110,21 +104,6 @@ static int __init mpf_checksum(unsigned char *mp, int len)
static int mpc_record;
static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdata;
-#ifdef CONFIG_X86_NUMAQ
-static int MP_valid_apicid(int apicid, int version)
-{
- return hweight_long(apicid & 0xf) == 1 && (apicid >> 4) != 0xf;
-}
-#else
-static int MP_valid_apicid(int apicid, int version)
-{
- if (version >= 0x14)
- return apicid < 0xff;
- else
- return apicid < 0xf;
-}
-#endif
-
static void __devinit MP_processor_info (struct mpc_config_processor *m)
{
int ver, apicid;
@@ -190,12 +169,6 @@ static void __devinit MP_processor_info (struct mpc_config_processor *m)
ver = m->mpc_apicver;
- if (!MP_valid_apicid(apicid, ver)) {
- printk(KERN_WARNING "Processor #%d INVALID. (Max ID: %d).\n",
- m->mpc_apicid, MAX_APICS);
- return;
- }
-
/*
* Validate version
*/
@@ -225,7 +198,14 @@ static void __devinit MP_processor_info (struct mpc_config_processor *m)
cpu_set(num_processors, cpu_possible_map);
num_processors++;
- if (CPU_HOTPLUG_ENABLED || (num_processors > 8)) {
+ /*
+ * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
+ * but we need to work other dependencies like SMP_SUSPEND etc
+ * before this can be done without some confusion.
+ * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
+ * - Ashok Raj <ashok.raj@intel.com>
+ */
+ if (num_processors > 8) {
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
if (!APIC_XAPIC(ver)) {
@@ -249,6 +229,13 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
mpc_oem_bus_info(m, str, translation_table[mpc_record]);
+ if (m->mpc_busid >= MAX_MP_BUSSES) {
+ printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
+ " is too large, max. supported is %d\n",
+ m->mpc_busid, str, MAX_MP_BUSSES - 1);
+ return;
+ }
+
if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
} else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA)-1) == 0) {
diff --git a/arch/i386/kernel/reboot_fixups.c b/arch/i386/kernel/reboot_fixups.c
index 10e21a4773dd4..99aab41a05b0f 100644
--- a/arch/i386/kernel/reboot_fixups.c
+++ b/arch/i386/kernel/reboot_fixups.c
@@ -51,7 +51,5 @@ void mach_reboot_fixups(void)
cur->reboot_fixup(dev);
}
-
- printk(KERN_WARNING "No reboot fixup found for your hardware\n");
}
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index eacc3f0a2ea4d..80cb3b2d09979 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -963,6 +963,36 @@ efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
return 0;
}
+ /*
+ * This function checks if the entire range <start,end> is mapped with type.
+ *
+ * Note: this function only works correct if the e820 table is sorted and
+ * not-overlapping, which is the case
+ */
+int __init
+e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
+{
+ int i;
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
+ if (type && ei->type != type)
+ continue;
+ /* is the region (part) in overlap with the current region ?*/
+ if (ei->addr >= end || ei->addr + ei->size <= start)
+ continue;
+ /* if the region is at the beginning of <start,end> we move
+ * start to the end of the region since it's ok until there
+ */
+ if (ei->addr <= start)
+ start = ei->addr + ei->size;
+ /* if start is now at or beyond end, we're done, full
+ * coverage */
+ if (start >= end)
+ return 1; /* we're done */
+ }
+ return 0;
+}
+
/*
* Find the highest page frame number we have available
*/
@@ -1317,8 +1347,8 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
/*
* Request address space for all standard resources
*
- * This is called just before pcibios_assign_resources(), which is also
- * an fs_initcall, but is linked in later (in arch/i386/pci/i386.c).
+ * This is called just before pcibios_init(), which is also a
+ * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
*/
static int __init request_standard_resources(void)
{
@@ -1339,7 +1369,7 @@ static int __init request_standard_resources(void)
return 0;
}
-fs_initcall(request_standard_resources);
+subsys_initcall(request_standard_resources);
static void __init register_memory(void)
{
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index e38527994590f..2d22f5761b1dc 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -365,6 +365,9 @@ void die(const char * str, struct pt_regs * regs, long err)
if (++die.lock_owner_depth < 3) {
int nl = 0;
+ unsigned long esp;
+ unsigned short ss;
+
handle_BUG(regs);
printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
#ifdef CONFIG_PREEMPT
@@ -387,8 +390,19 @@ void die(const char * str, struct pt_regs * regs, long err)
printk("\n");
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEGV) !=
- NOTIFY_STOP)
+ NOTIFY_STOP) {
show_registers(regs);
+ /* Executive summary in case the oops scrolled away */
+ esp = (unsigned long) (&regs->esp);
+ savesegment(ss, ss);
+ if (user_mode(regs)) {
+ esp = regs->esp;
+ ss = regs->xss & 0xffff;
+ }
+ printk(KERN_EMERG "EIP: [<%08lx>] ", regs->eip);
+ print_symbol("%s", regs->eip);
+ printk(" SS:ESP %04x:%08lx\n", ss, esp);
+ }
else
regs = NULL;
} else
diff --git a/arch/i386/mach-voyager/voyager_cat.c b/arch/i386/mach-voyager/voyager_cat.c
index 23967fe658d3f..3039539de51e5 100644
--- a/arch/i386/mach-voyager/voyager_cat.c
+++ b/arch/i386/mach-voyager/voyager_cat.c
@@ -106,9 +106,15 @@ voyager_module_t *voyager_cat_list;
/* the I/O port assignments for the VIC and QIC */
static struct resource vic_res = {
- "Voyager Interrupt Controller", 0xFC00, 0xFC6F };
+ .name = "Voyager Interrupt Controller",
+ .start = 0xFC00,
+ .end = 0xFC6F
+};
static struct resource qic_res = {
- "Quad Interrupt Controller", 0xFC70, 0xFCFF };
+ .name = "Quad Interrupt Controller",
+ .start = 0xFC70,
+ .end = 0xFCFF
+};
/* This function is used to pack a data bit stream inside a message.
* It writes num_bits of the data buffer in msg starting at start_bit.
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 9f66ac582a8bf..ae6534ad81611 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -651,6 +651,7 @@ void __init mem_init(void)
* Specifically, in the case of x86, we will always add
* memory to the highmem for now.
*/
+#ifdef CONFIG_HOTPLUG_MEMORY
#ifndef CONFIG_NEED_MULTIPLE_NODES
int add_memory(u64 start, u64 size)
{
@@ -667,6 +668,7 @@ int remove_memory(u64 start, u64 size)
return -EINVAL;
}
#endif
+#endif
kmem_cache_t *pgd_cache;
kmem_cache_t *pmd_cache;
diff --git a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c
index 99012b93bd12b..5d81fb5103755 100644
--- a/arch/i386/pci/direct.c
+++ b/arch/i386/pci/direct.c
@@ -4,6 +4,7 @@
#include <linux/pci.h>
#include <linux/init.h>
+#include <linux/dmi.h>
#include "pci.h"
/*
@@ -18,8 +19,10 @@ int pci_conf1_read(unsigned int seg, unsigned int bus,
{
unsigned long flags;
- if (!value || (bus > 255) || (devfn > 255) || (reg > 255))
+ if ((bus > 255) || (devfn > 255) || (reg > 255)) {
+ *value = -1;
return -EINVAL;
+ }
spin_lock_irqsave(&pci_config_lock, flags);
@@ -91,8 +94,10 @@ static int pci_conf2_read(unsigned int seg, unsigned int bus,
unsigned long flags;
int dev, fn;
- if (!value || (bus > 255) || (devfn > 255) || (reg > 255))
+ if ((bus > 255) || (devfn > 255) || (reg > 255)) {
+ *value = -1;
return -EINVAL;
+ }
dev = PCI_SLOT(devfn);
fn = PCI_FUNC(devfn);
@@ -188,6 +193,10 @@ static int __init pci_sanity_check(struct pci_raw_ops *o)
if (pci_probe & PCI_NO_CHECKS)
return 1;
+ /* Assume Type 1 works for newer systems.
+ This handles machines that don't have anything on PCI Bus 0. */
+ if (dmi_get_year(DMI_BIOS_DATE) >= 2001)
+ return 1;
for (devfn = 0; devfn < 0x100; devfn++) {
if (o->read(0, 0, devfn, PCI_CLASS_DEVICE, 2, &x))
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index 613789071f30d..6b1ea0c9a570e 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -12,14 +12,20 @@
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/acpi.h>
+#include <asm/e820.h>
#include "pci.h"
+#define MMCONFIG_APER_SIZE (256*1024*1024)
+
+/* Assume systems with more busses have correct MCFG */
+#define MAX_CHECK_BUS 16
+
#define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG))
/* The base address of the last MMCONFIG device accessed */
static u32 mmcfg_last_accessed_device;
-static DECLARE_BITMAP(fallback_slots, 32);
+static DECLARE_BITMAP(fallback_slots, MAX_CHECK_BUS*32);
/*
* Functions for accessing PCI configuration space with MMCONFIG accesses
@@ -29,8 +35,8 @@ static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
int cfg_num = -1;
struct acpi_table_mcfg_config *cfg;
- if (seg == 0 && bus == 0 &&
- test_bit(PCI_SLOT(devfn), fallback_slots))
+ if (seg == 0 && bus < MAX_CHECK_BUS &&
+ test_bit(PCI_SLOT(devfn) + 32*bus, fallback_slots))
return 0;
while (1) {
@@ -74,8 +80,10 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
unsigned long flags;
u32 base;
- if (!value || (bus > 255) || (devfn > 255) || (reg > 4095))
+ if ((bus > 255) || (devfn > 255) || (reg > 4095)) {
+ *value = -1;
return -EINVAL;
+ }
base = get_base_addr(seg, bus, devfn);
if (!base)
@@ -146,29 +154,34 @@ static struct pci_raw_ops pci_mmcfg = {
Normally this can be expressed in the MCFG by not listing them
and assigning suitable _SEGs, but this isn't implemented in some BIOS.
Instead try to discover all devices on bus 0 that are unreachable using MM
- and fallback for them.
- We only do this for bus 0/seg 0 */
+ and fallback for them. */
static __init void unreachable_devices(void)
{
- int i;
+ int i, k;
unsigned long flags;
- for (i = 0; i < 32; i++) {
- u32 val1;
- u32 addr;
-
- pci_conf1_read(0, 0, PCI_DEVFN(i, 0), 0, 4, &val1);
- if (val1 == 0xffffffff)
- continue;
-
- /* Locking probably not needed, but safer */
- spin_lock_irqsave(&pci_config_lock, flags);
- addr = get_base_addr(0, 0, PCI_DEVFN(i, 0));
- if (addr != 0)
- pci_exp_set_dev_base(addr, 0, PCI_DEVFN(i, 0));
- if (addr == 0 || readl((u32 __iomem *)mmcfg_virt_addr) != val1)
- set_bit(i, fallback_slots);
- spin_unlock_irqrestore(&pci_config_lock, flags);
+ for (k = 0; k < MAX_CHECK_BUS; k++) {
+ for (i = 0; i < 32; i++) {
+ u32 val1;
+ u32 addr;
+
+ pci_conf1_read(0, k, PCI_DEVFN(i, 0), 0, 4, &val1);
+ if (val1 == 0xffffffff)
+ continue;
+
+ /* Locking probably not needed, but safer */
+ spin_lock_irqsave(&pci_config_lock, flags);
+ addr = get_base_addr(0, k, PCI_DEVFN(i, 0));
+ if (addr != 0)
+ pci_exp_set_dev_base(addr, k, PCI_DEVFN(i, 0));
+ if (addr == 0 ||
+ readl((u32 __iomem *)mmcfg_virt_addr) != val1) {
+ set_bit(i, fallback_slots);
+ printk(KERN_NOTICE
+ "PCI: No mmconfig possible on %x:%x\n", k, i);
+ }
+ spin_unlock_irqrestore(&pci_config_lock, flags);
+ }
}
}
@@ -183,6 +196,14 @@ void __init pci_mmcfg_init(void)
(pci_mmcfg_config[0].base_address == 0))
return;
+ if (!e820_all_mapped(pci_mmcfg_config[0].base_address,
+ pci_mmcfg_config[0].base_address + MMCONFIG_APER_SIZE,
+ E820_RESERVED)) {
+ printk(KERN_ERR "PCI: BIOS Bug: MCFG area is not E820-reserved\n");
+ printk(KERN_ERR "PCI: Not using MMCONFIG.\n");
+ return;
+ }
+
printk(KERN_INFO "PCI: Using MMCONFIG\n");
raw_pci_ops = &pci_mmcfg;
pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index edffe25a477ab..9f40eeff0b5ce 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -260,15 +260,6 @@ config NR_CPUS
than 64 will cause the use of a CPU mask array, causing a small
performance hit.
-config IA64_NR_NODES
- int "Maximum number of NODEs (256-1024)" if (IA64_SGI_SN2 || IA64_GENERIC)
- range 256 1024
- depends on IA64_SGI_SN2 || IA64_GENERIC
- default "256"
- help
- This option specifies the maximum number of nodes in your SSI system.
- If in doubt, use the default.
-
config HOTPLUG_CPU
bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
depends on SMP && EXPERIMENTAL
@@ -352,6 +343,16 @@ config NUMA
Access). This option is for configuring high-end multiprocessor
server systems. If in doubt, say N.
+config NODES_SHIFT
+ int "Max num nodes shift(3-10)"
+ range 3 10
+ default "8"
+ depends on NEED_MULTIPLE_NODES
+ help
+ This option specifies the maximum number of nodes in your SSI system.
+ MAX_NUMNODES will be 2^(This value).
+ If in doubt, use the default.
+
# VIRTUAL_MEM_MAP and FLAT_NODE_MEM_MAP are functionally equivalent.
# VIRTUAL_MEM_MAP has been retained for historical reasons.
config VIRTUAL_MEM_MAP
diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c
index 4a5574ff007b8..fff82929d225a 100644
--- a/arch/ia64/kernel/acpi-ext.c
+++ b/arch/ia64/kernel/acpi-ext.c
@@ -1,105 +1,104 @@
/*
- * arch/ia64/kernel/acpi-ext.c
+ * (c) Copyright 2003, 2006 Hewlett-Packard Development Company, L.P.
+ * Alex Williamson <alex.williamson@hp.com>
+ * Bjorn Helgaas <bjorn.helgaas@hp.com>
*
- * Copyright (C) 2003 Hewlett-Packard
- * Copyright (C) Alex Williamson
- * Copyright (C) Bjorn Helgaas
- *
- * Vendor specific extensions to ACPI.
+ * 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.
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/acpi.h>
-#include <linux/efi.h>
#include <asm/acpi-ext.h>
-struct acpi_vendor_descriptor {
- u8 guid_id;
- efi_guid_t guid;
-};
+/*
+ * Device CSRs that do not appear in PCI config space should be described
+ * via ACPI. This would normally be done with Address Space Descriptors
+ * marked as "consumer-only," but old versions of Windows and Linux ignore
+ * the producer/consumer flag, so HP invented a vendor-defined resource to
+ * describe the location and size of CSR space.
+ */
-struct acpi_vendor_info {
- struct acpi_vendor_descriptor *descriptor;
- u8 *data;
- u32 length;
+struct acpi_vendor_uuid hp_ccsr_uuid = {
+ .subtype = 2,
+ .data = { 0xf9, 0xad, 0xe9, 0x69, 0x4f, 0x92, 0x5f, 0xab, 0xf6, 0x4a,
+ 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad },
};
-acpi_status
-acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
+static acpi_status hp_ccsr_locate(acpi_handle obj, u64 *base, u64 *length)
{
- struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
- struct acpi_resource_vendor *vendor;
- struct acpi_vendor_descriptor *descriptor;
- u32 byte_length;
-
- if (resource->type != ACPI_RESOURCE_TYPE_VENDOR)
- return AE_OK;
-
- vendor = (struct acpi_resource_vendor *)&resource->data;
- descriptor = (struct acpi_vendor_descriptor *)vendor->byte_data;
- if (vendor->byte_length <= sizeof(*info->descriptor) ||
- descriptor->guid_id != info->descriptor->guid_id ||
- efi_guidcmp(descriptor->guid, info->descriptor->guid))
- return AE_OK;
-
- byte_length = vendor->byte_length - sizeof(struct acpi_vendor_descriptor);
- info->data = acpi_os_allocate(byte_length);
- if (!info->data)
- return AE_NO_MEMORY;
-
- memcpy(info->data,
- vendor->byte_data + sizeof(struct acpi_vendor_descriptor),
- byte_length);
- info->length = byte_length;
- return AE_CTRL_TERMINATE;
-}
+ acpi_status status;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct acpi_resource *resource;
+ struct acpi_resource_vendor_typed *vendor;
-acpi_status
-acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
- u8 ** data, u32 * byte_length)
-{
- struct acpi_vendor_info info;
+ status = acpi_get_vendor_resource(obj, METHOD_NAME__CRS, &hp_ccsr_uuid,
+ &buffer);
- info.descriptor = id;
- info.data = NULL;
+ resource = buffer.pointer;
+ vendor = &resource->data.vendor_typed;
- acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match,
- &info);
- if (!info.data)
- return AE_NOT_FOUND;
+ if (ACPI_FAILURE(status) || vendor->byte_length < 16) {
+ status = AE_NOT_FOUND;
+ goto exit;
+ }
- *data = info.data;
- *byte_length = info.length;
- return AE_OK;
+ memcpy(base, vendor->byte_data, sizeof(*base));
+ memcpy(length, vendor->byte_data + 8, sizeof(*length));
+
+ exit:
+ acpi_os_free(buffer.pointer);
+ return status;
}
-struct acpi_vendor_descriptor hp_ccsr_descriptor = {
- .guid_id = 2,
- .guid =
- EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01,
- 0x37, 0x0e, 0xad)
+struct csr_space {
+ u64 base;
+ u64 length;
};
-acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length)
+static acpi_status find_csr_space(struct acpi_resource *resource, void *data)
{
+ struct csr_space *space = data;
+ struct acpi_resource_address64 addr;
acpi_status status;
- u8 *data;
- u32 length;
- status =
- acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
+ status = acpi_resource_to_address64(resource, &addr);
+ if (ACPI_SUCCESS(status) &&
+ addr.resource_type == ACPI_MEMORY_RANGE &&
+ addr.address_length &&
+ addr.producer_consumer == ACPI_CONSUMER) {
+ space->base = addr.minimum;
+ space->length = addr.address_length;
+ return AE_CTRL_TERMINATE;
+ }
+ return AE_OK; /* keep looking */
+}
- if (ACPI_FAILURE(status) || length != 16)
- return AE_NOT_FOUND;
+static acpi_status hp_crs_locate(acpi_handle obj, u64 *base, u64 *length)
+{
+ struct csr_space space = { 0, 0 };
- memcpy(csr_base, data, sizeof(*csr_base));
- memcpy(csr_length, data + 8, sizeof(*csr_length));
- acpi_os_free(data);
+ acpi_walk_resources(obj, METHOD_NAME__CRS, find_csr_space, &space);
+ if (!space.length)
+ return AE_NOT_FOUND;
+ *base = space.base;
+ *length = space.length;
return AE_OK;
}
+acpi_status hp_acpi_csr_space(acpi_handle obj, u64 *csr_base, u64 *csr_length)
+{
+ acpi_status status;
+
+ status = hp_ccsr_locate(obj, csr_base, csr_length);
+ if (ACPI_SUCCESS(status))
+ return status;
+
+ return hp_crs_locate(obj, csr_base, csr_length);
+}
EXPORT_SYMBOL(hp_acpi_csr_space);
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index 750e8e7fbdc30..6e16f6b35bd33 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1606,5 +1606,8 @@ sys_call_table:
data8 sys_ni_syscall // 1295 reserved for ppoll
data8 sys_unshare
data8 sys_splice
+ data8 sys_set_robust_list
+ data8 sys_get_robust_list
+ data8 sys_sync_file_range // 1300
.org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 8963171788d52..5e6fdbe78bcd3 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -581,10 +581,12 @@ ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs)
{
unsigned long flags;
int cpu = smp_processor_id();
+ struct ia64_mca_notify_die nd =
+ { .sos = NULL, .monarch_cpu = &monarch_cpu };
/* Mask all interrupts */
local_irq_save(flags);
- if (notify_die(DIE_MCA_RENDZVOUS_ENTER, "MCA", regs, 0, 0, 0)
+ if (notify_die(DIE_MCA_RENDZVOUS_ENTER, "MCA", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
@@ -594,7 +596,7 @@ ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs)
*/
ia64_sal_mc_rendez();
- if (notify_die(DIE_MCA_RENDZVOUS_PROCESS, "MCA", regs, 0, 0, 0)
+ if (notify_die(DIE_MCA_RENDZVOUS_PROCESS, "MCA", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
@@ -602,7 +604,7 @@ ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs)
while (monarch_cpu != -1)
cpu_relax(); /* spin until monarch leaves */
- if (notify_die(DIE_MCA_RENDZVOUS_LEAVE, "MCA", regs, 0, 0, 0)
+ if (notify_die(DIE_MCA_RENDZVOUS_LEAVE, "MCA", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
@@ -1023,6 +1025,8 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
&sos->proc_state_param;
int recover, cpu = smp_processor_id();
task_t *previous_current;
+ struct ia64_mca_notify_die nd =
+ { .sos = sos, .monarch_cpu = &monarch_cpu };
oops_in_progress = 1; /* FIXME: make printk NMI/MCA/INIT safe */
console_loglevel = 15; /* make sure printks make it to console */
@@ -1031,7 +1035,7 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
previous_current = ia64_mca_modify_original_stack(regs, sw, sos, "MCA");
monarch_cpu = cpu;
- if (notify_die(DIE_MCA_MONARCH_ENTER, "MCA", regs, 0, 0, 0)
+ if (notify_die(DIE_MCA_MONARCH_ENTER, "MCA", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
ia64_wait_for_slaves(cpu);
@@ -1043,7 +1047,7 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
* spinning in SAL does not work.
*/
ia64_mca_wakeup_all();
- if (notify_die(DIE_MCA_MONARCH_PROCESS, "MCA", regs, 0, 0, 0)
+ if (notify_die(DIE_MCA_MONARCH_PROCESS, "MCA", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
@@ -1064,7 +1068,7 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
ia64_sal_clear_state_info(SAL_INFO_TYPE_MCA);
sos->os_status = IA64_MCA_CORRECTED;
}
- if (notify_die(DIE_MCA_MONARCH_LEAVE, "MCA", regs, 0, 0, recover)
+ if (notify_die(DIE_MCA_MONARCH_LEAVE, "MCA", regs, (long)&nd, 0, recover)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
@@ -1351,10 +1355,14 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
static atomic_t monarchs;
task_t *previous_current;
int cpu = smp_processor_id();
+ struct ia64_mca_notify_die nd =
+ { .sos = sos, .monarch_cpu = &monarch_cpu };
oops_in_progress = 1; /* FIXME: make printk NMI/MCA/INIT safe */
console_loglevel = 15; /* make sure printks make it to console */
+ (void) notify_die(DIE_INIT_ENTER, "INIT", regs, (long)&nd, 0, 0);
+
printk(KERN_INFO "Entered OS INIT handler. PSP=%lx cpu=%d monarch=%ld\n",
sos->proc_state_param, cpu, sos->monarch);
salinfo_log_wakeup(SAL_INFO_TYPE_INIT, NULL, 0, 0);
@@ -1390,15 +1398,15 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
ia64_mc_info.imi_rendez_checkin[cpu] = IA64_MCA_RENDEZ_CHECKIN_INIT;
while (monarch_cpu == -1)
cpu_relax(); /* spin until monarch enters */
- if (notify_die(DIE_INIT_SLAVE_ENTER, "INIT", regs, 0, 0, 0)
+ if (notify_die(DIE_INIT_SLAVE_ENTER, "INIT", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
- if (notify_die(DIE_INIT_SLAVE_PROCESS, "INIT", regs, 0, 0, 0)
+ if (notify_die(DIE_INIT_SLAVE_PROCESS, "INIT", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
while (monarch_cpu != -1)
cpu_relax(); /* spin until monarch leaves */
- if (notify_die(DIE_INIT_SLAVE_LEAVE, "INIT", regs, 0, 0, 0)
+ if (notify_die(DIE_INIT_SLAVE_LEAVE, "INIT", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
printk("Slave on cpu %d returning to normal service.\n", cpu);
@@ -1409,7 +1417,7 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
}
monarch_cpu = cpu;
- if (notify_die(DIE_INIT_MONARCH_ENTER, "INIT", regs, 0, 0, 0)
+ if (notify_die(DIE_INIT_MONARCH_ENTER, "INIT", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
@@ -1426,10 +1434,10 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
* to default_monarch_init_process() above and just print all the
* tasks.
*/
- if (notify_die(DIE_INIT_MONARCH_PROCESS, "INIT", regs, 0, 0, 0)
+ if (notify_die(DIE_INIT_MONARCH_PROCESS, "INIT", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
- if (notify_die(DIE_INIT_MONARCH_LEAVE, "INIT", regs, 0, 0, 0)
+ if (notify_die(DIE_INIT_MONARCH_LEAVE, "INIT", regs, (long)&nd, 0, 0)
== NOTIFY_STOP)
ia64_mca_spin(__FUNCTION__);
printk("\nINIT dump complete. Monarch on cpu %d returning to normal service.\n", cpu);
@@ -1631,6 +1639,7 @@ ia64_mca_init(void)
printk(KERN_INFO "Increasing MCA rendezvous timeout from "
"%ld to %ld milliseconds\n", timeout, isrv.v0);
timeout = isrv.v0;
+ (void) notify_die(DIE_MCA_NEW_TIMEOUT, "MCA", NULL, timeout, 0, 0);
continue;
}
printk(KERN_ERR "Failed to register rendezvous interrupt "
diff --git a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
index 60a464bfd9e27..6dff024cd62b0 100644
--- a/arch/ia64/kernel/mca_asm.S
+++ b/arch/ia64/kernel/mca_asm.S
@@ -827,7 +827,7 @@ ia64_state_restore:
ld8 r9=[temp2],16 // sal_gp
;;
ld8 r22=[temp1],16 // pal_min_state, virtual
- ld8 r21=[temp2],16 // prev_IA64_KR_CURRENT
+ ld8 r13=[temp2],16 // prev_IA64_KR_CURRENT
;;
ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
ld8 r20=[temp2],16 // prev_task
@@ -848,7 +848,7 @@ ia64_state_restore:
mov cr.iim=temp3
mov cr.iha=temp4
dep r22=0,r22,62,1 // pal_min_state, physical, uncached
- mov IA64_KR(CURRENT)=r21
+ mov IA64_KR(CURRENT)=r13
ld8 r8=[temp1] // os_status
ld8 r10=[temp2] // context
@@ -856,7 +856,7 @@ ia64_state_restore:
* avoid any dependencies on the algorithm in ia64_switch_to(), just
* purge any existing CURRENT_STACK mapping and insert the new one.
*
- * r16 contains prev_IA64_KR_CURRENT_STACK, r21 contains
+ * r16 contains prev_IA64_KR_CURRENT_STACK, r13 contains
* prev_IA64_KR_CURRENT, these values may have been changed by the C
* code. Do not use r8, r9, r10, r22, they contain values ready for
* the return to SAL.
@@ -873,7 +873,7 @@ ia64_state_restore:
;;
srlz.d
- extr.u r19=r21,61,3 // r21 = prev_IA64_KR_CURRENT
+ extr.u r19=r13,61,3 // r13 = prev_IA64_KR_CURRENT
shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
movl r21=PAGE_KERNEL // page properties
;;
@@ -883,7 +883,7 @@ ia64_state_restore:
(p6) br.spnt 1f // the dreaded cpu 0 idle task in region 5:(
;;
mov cr.itir=r18
- mov cr.ifa=r21
+ mov cr.ifa=r13
mov r20=IA64_TR_CURRENT_STACK
;;
itr.d dtr[r20]=r21
diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 7a2f0a798d121..3a30cfc9574fd 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -947,7 +947,7 @@ void
percpu_modcopy (void *pcpudst, const void *src, unsigned long size)
{
unsigned int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
memcpy(pcpudst + __per_cpu_offset[i], src, size);
}
}
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index af7eb087dca7a..d98ec49570b80 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -60,6 +60,9 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
struct siginfo si;
unsigned long mask;
+ /* mmap_sem is performance critical.... */
+ prefetchw(&mm->mmap_sem);
+
/*
* If we're in an interrupt or have no user context, we must not take the fault..
*/
diff --git a/arch/ia64/sn/kernel/xpc_channel.c b/arch/ia64/sn/kernel/xpc_channel.c
index d0abddd9ffe68..8255a9be4632a 100644
--- a/arch/ia64/sn/kernel/xpc_channel.c
+++ b/arch/ia64/sn/kernel/xpc_channel.c
@@ -1831,7 +1831,7 @@ xpc_initiate_allocate(partid_t partid, int ch_number, u32 flags, void **payload)
{
struct xpc_partition *part = &xpc_partitions[partid];
enum xpc_retval ret = xpcUnknownReason;
- struct xpc_msg *msg;
+ struct xpc_msg *msg = NULL;
DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 05c864c6c2d93..41fd490af3b47 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -285,6 +285,11 @@ config NUMA
depends on SMP && BROKEN
default n
+config NODES_SHIFT
+ int
+ default "1"
+ depends on NEED_MULTIPLE_NODES
+
# turning this on wastes a bunch of space.
# Summit needs it only when NUMA is on
config BOOT_IOREMAP
diff --git a/arch/m32r/kernel/m32r_ksyms.c b/arch/m32r/kernel/m32r_ksyms.c
index be8b711367ec5..c50330fa83b98 100644
--- a/arch/m32r/kernel/m32r_ksyms.c
+++ b/arch/m32r/kernel/m32r_ksyms.c
@@ -23,9 +23,6 @@ EXPORT_SYMBOL(boot_cpu_data);
EXPORT_SYMBOL(dump_fpu);
EXPORT_SYMBOL(__ioremap);
EXPORT_SYMBOL(iounmap);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(disable_irq_nosync);
EXPORT_SYMBOL(kernel_thread);
EXPORT_SYMBOL(__down);
EXPORT_SYMBOL(__down_interruptible);
@@ -38,13 +35,6 @@ EXPORT_SYMBOL(__udelay);
EXPORT_SYMBOL(__delay);
EXPORT_SYMBOL(__const_udelay);
-EXPORT_SYMBOL(__get_user_1);
-EXPORT_SYMBOL(__get_user_2);
-EXPORT_SYMBOL(__get_user_4);
-
-EXPORT_SYMBOL(strpbrk);
-EXPORT_SYMBOL(strstr);
-
EXPORT_SYMBOL(strncpy_from_user);
EXPORT_SYMBOL(__strncpy_from_user);
EXPORT_SYMBOL(clear_user);
@@ -59,11 +49,8 @@ extern void *dcache_dummy;
EXPORT_SYMBOL(dcache_dummy);
#endif
EXPORT_SYMBOL(cpu_data);
-EXPORT_SYMBOL(cpu_online_map);
-EXPORT_SYMBOL(cpu_callout_map);
/* Global SMP stuff */
-EXPORT_SYMBOL(synchronize_irq);
EXPORT_SYMBOL(smp_call_function);
/* TLB flushing */
@@ -83,27 +70,11 @@ EXPORT_SYMBOL(__lshrdi3);
EXPORT_SYMBOL(__muldi3);
/* memory and string operations */
-EXPORT_SYMBOL(memchr);
EXPORT_SYMBOL(memcpy);
-/* EXPORT_SYMBOL(memcpy_fromio); // not implement yet */
-/* EXPORT_SYMBOL(memcpy_toio); // not implement yet */
EXPORT_SYMBOL(memset);
-/* EXPORT_SYMBOL(memset_io); // not implement yet */
-EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memscan);
EXPORT_SYMBOL(copy_page);
EXPORT_SYMBOL(clear_page);
-
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strcpy);
EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(strncmp);
-EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strncpy);
EXPORT_SYMBOL(_inb);
EXPORT_SYMBOL(_inw);
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 0d78942b4c768..3cd3c2988a487 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -9,6 +9,7 @@
#include <linux/config.h>
#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/stddef.h>
#include <linux/fs.h>
#include <linux/sched.h>
@@ -219,8 +220,6 @@ static unsigned long __init setup_memory(void)
extern unsigned long setup_memory(void);
#endif /* CONFIG_DISCONTIGMEM */
-#define M32R_PCC_PCATCR 0x00ef7014 /* will move to m32r.h */
-
void __init setup_arch(char **cmdline_p)
{
ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
@@ -269,15 +268,14 @@ void __init setup_arch(char **cmdline_p)
paging_init();
}
-static struct cpu cpu[NR_CPUS];
+static struct cpu cpu_devices[NR_CPUS];
static int __init topology_init(void)
{
- int cpu_id;
+ int i;
- for (cpu_id = 0; cpu_id < NR_CPUS; cpu_id++)
- if (cpu_possible(cpu_id))
- register_cpu(&cpu[cpu_id], cpu_id, NULL);
+ for_each_present_cpu(i)
+ register_cpu(&cpu_devices[i], i, NULL);
return 0;
}
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index d7ec16e7fb259..840b4348bf0ce 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -39,8 +39,10 @@
* Martin J. Bligh : Added support for multi-quad systems
*/
+#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/irq.h>
@@ -72,11 +74,15 @@ physid_mask_t phys_cpu_present_map;
/* Bitmask of currently online CPUs */
cpumask_t cpu_online_map;
+EXPORT_SYMBOL(cpu_online_map);
cpumask_t cpu_bootout_map;
cpumask_t cpu_bootin_map;
-cpumask_t cpu_callout_map;
static cpumask_t cpu_callin_map;
+cpumask_t cpu_callout_map;
+EXPORT_SYMBOL(cpu_callout_map);
+cpumask_t cpu_possible_map = CPU_MASK_ALL;
+EXPORT_SYMBOL(cpu_possible_map);
/* Per CPU bogomips and other parameters */
struct cpuinfo_m32r cpu_data[NR_CPUS] __cacheline_aligned;
@@ -110,7 +116,6 @@ static unsigned int calibration_result;
void smp_prepare_boot_cpu(void);
void smp_prepare_cpus(unsigned int);
-static void smp_tune_scheduling(void);
static void init_ipi_lock(void);
static void do_boot_cpu(int);
int __cpu_up(unsigned int);
@@ -177,6 +182,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
}
for (phys_id = 0 ; phys_id < nr_cpu ; phys_id++)
physid_set(phys_id, phys_cpu_present_map);
+#ifndef CONFIG_HOTPLUG_CPU
+ cpu_present_map = cpu_possible_map;
+#endif
show_mp_info(nr_cpu);
@@ -186,7 +194,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
* Setup boot CPU information
*/
smp_store_cpu_info(0); /* Final full version of the data */
- smp_tune_scheduling();
/*
* If SMP should be disabled, then really disable it!
@@ -230,11 +237,6 @@ smp_done:
Dprintk("Boot done.\n");
}
-static void __init smp_tune_scheduling(void)
-{
- /* Nothing to do. */
-}
-
/*
* init_ipi_lock : Initialize IPI locks.
*/
@@ -629,4 +631,3 @@ static void __init unmap_cpu_to_physid(int cpu_id, int phys_id)
physid_2_cpu[phys_id] = -1;
cpu_2_physid[cpu_id] = -1;
}
-
diff --git a/arch/m32r/lib/Makefile b/arch/m32r/lib/Makefile
index e632d10c7d78e..d16b4e40d1ae9 100644
--- a/arch/m32r/lib/Makefile
+++ b/arch/m32r/lib/Makefile
@@ -2,6 +2,6 @@
# Makefile for M32R-specific library files..
#
-lib-y := checksum.o ashxdi3.o memset.o memcpy.o getuser.o \
- putuser.o delay.o strlen.o usercopy.o csum_partial_copy.o
+lib-y := checksum.o ashxdi3.o memset.o memcpy.o \
+ delay.o strlen.o usercopy.o csum_partial_copy.o
diff --git a/arch/m32r/lib/getuser.S b/arch/m32r/lib/getuser.S
deleted file mode 100644
index 58a0db055c5c6..0000000000000
--- a/arch/m32r/lib/getuser.S
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * __get_user functions.
- *
- * (C) Copyright 2001 Hirokazu Takata
- *
- * These functions have a non-standard call interface
- * to make them more efficient, especially as they
- * return an error value in addition to the "real"
- * return value.
- */
-
-#include <linux/config.h>
-
-/*
- * __get_user_X
- *
- * Inputs: r0 contains the address
- *
- * Outputs: r0 is error code (0 or -EFAULT)
- * r1 contains zero-extended value
- *
- * These functions should not modify any other registers,
- * as they get called from within inline assembly.
- */
-
-#ifdef CONFIG_ISA_DUAL_ISSUE
-
- .text
- .balign 4
- .globl __get_user_1
-__get_user_1:
-1: ldub r1, @r0 || ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __get_user_2
-__get_user_2:
-2: lduh r1, @r0 || ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __get_user_4
-__get_user_4:
-3: ld r1, @r0 || ldi r0, #0
- jmp r14
-
-bad_get_user:
- ldi r1, #0 || ldi r0, #-14
- jmp r14
-
-#else /* not CONFIG_ISA_DUAL_ISSUE */
-
- .text
- .balign 4
- .globl __get_user_1
-__get_user_1:
-1: ldub r1, @r0
- ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __get_user_2
-__get_user_2:
-2: lduh r1, @r0
- ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __get_user_4
-__get_user_4:
-3: ld r1, @r0
- ldi r0, #0
- jmp r14
-
-bad_get_user:
- ldi r1, #0
- ldi r0, #-14
- jmp r14
-
-#endif /* not CONFIG_ISA_DUAL_ISSUE */
-
-.section __ex_table,"a"
- .long 1b,bad_get_user
- .long 2b,bad_get_user
- .long 3b,bad_get_user
-.previous
-
- .end
diff --git a/arch/m32r/lib/putuser.S b/arch/m32r/lib/putuser.S
deleted file mode 100644
index 218154cc38904..0000000000000
--- a/arch/m32r/lib/putuser.S
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * __put_user functions.
- *
- * (C) Copyright 1998 Linus Torvalds
- * (C) Copyright 2001 Hirokazu Takata
- *
- * These functions have a non-standard call interface
- * to make them more efficient.
- */
-
-#include <linux/config.h>
-
-/*
- * __put_user_X
- *
- * Inputs: r0 contains the address
- * r1 contains the value
- *
- * Outputs: r0 is error code (0 or -EFAULT)
- * r1 is corrupted (will contain "current_task").
- *
- * These functions should not modify any other registers,
- * as they get called from within inline assembly.
- */
-
-#ifdef CONFIG_ISA_DUAL_ISSUE
-
- .text
- .balign 4
- .globl __put_user_1
-__put_user_1:
-1: stb r1, @r0 || ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __put_user_2
-__put_user_2:
-2: sth r1, @r0 || ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __put_user_4
-__put_user_4:
-3: st r1, @r0 || ldi r0, #0
- jmp r14
-
-bad_put_user:
- ldi r0, #-14 || jmp r14
-
-#else /* not CONFIG_ISA_DUAL_ISSUE */
-
- .text
- .balign 4
- .globl __put_user_1
-__put_user_1:
-1: stb r1, @r0
- ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __put_user_2
-__put_user_2:
-2: sth r1, @r0
- ldi r0, #0
- jmp r14
-
- .balign 4
- .globl __put_user_4
-__put_user_4:
-3: st r1, @r0
- ldi r0, #0
- jmp r14
-
-bad_put_user:
- ldi r0, #-14
- jmp r14
-
-#endif /* not CONFIG_ISA_DUAL_ISSUE */
-
-.section __ex_table,"a"
- .long 1b,bad_put_user
- .long 2b,bad_put_user
- .long 3b,bad_put_user
-.previous
diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c
index c3319514a85ed..5b7952ea2bae4 100644
--- a/arch/m68k/kernel/m68k_ksyms.c
+++ b/arch/m68k/kernel/m68k_ksyms.c
@@ -57,7 +57,6 @@ EXPORT_SYMBOL(dump_thread);
EXPORT_SYMBOL(strnlen);
EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(strstr);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(enable_irq);
EXPORT_SYMBOL(disable_irq);
EXPORT_SYMBOL(kernel_thread);
diff --git a/arch/m68knommu/kernel/m68k_ksyms.c b/arch/m68knommu/kernel/m68k_ksyms.c
index f9b4ea16c0998..4320d5dcc9cb9 100644
--- a/arch/m68knommu/kernel/m68k_ksyms.c
+++ b/arch/m68knommu/kernel/m68k_ksyms.c
@@ -26,7 +26,6 @@ EXPORT_SYMBOL(__ioremap);
EXPORT_SYMBOL(iounmap);
EXPORT_SYMBOL(dump_fpu);
EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(strchr);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index e15709ce88662..7aec60d404209 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1590,6 +1590,11 @@ config ARCH_FLATMEM_ENABLE
def_bool y
depends on !NUMA
+config NODES_SHIFT
+ int
+ default "6"
+ depends on NEED_MULTIPLE_NODES
+
source "mm/Kconfig"
config SMP
diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
index 86e42c633f73a..e042f9d2ba31f 100644
--- a/arch/mips/kernel/mips_ksyms.c
+++ b/arch/mips/kernel/mips_ksyms.c
@@ -39,7 +39,6 @@ EXPORT_SYMBOL(strchr);
EXPORT_SYMBOL(strncmp);
#endif
EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strncat);
EXPORT_SYMBOL(strnlen);
EXPORT_SYMBOL(strrchr);
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 2fdf21989dc20..19f911c5dd58d 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -177,6 +177,11 @@ config ARCH_DISCONTIGMEM_DEFAULT
def_bool y
depends on ARCH_DISCONTIGMEM_ENABLE
+config NODES_SHIFT
+ int
+ default "3"
+ depends on NEED_MULTIPLE_NODES
+
source "kernel/Kconfig.preempt"
source "kernel/Kconfig.hz"
source "mm/Kconfig"
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
index 47ca5c0a323b4..fc107add627cc 100644
--- a/arch/parisc/kernel/parisc_ksyms.c
+++ b/arch/parisc/kernel/parisc_ksyms.c
@@ -31,7 +31,6 @@
#include <linux/string.h>
EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(strpbrk);
#include <asm/atomic.h>
EXPORT_SYMBOL(__xchg8);
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2cdc35ce80451..167e70e95556c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -649,6 +649,11 @@ config NUMA
depends on PPC64
default y if SMP && PPC_PSERIES
+config NODES_SHIFT
+ int
+ default "4"
+ depends on NEED_MULTIPLE_NODES
+
config ARCH_SELECT_MEMORY_MODEL
def_bool y
depends on PPC64
diff --git a/arch/ppc/boot/lib/Makefile b/arch/ppc/boot/lib/Makefile
index d4077e69086f8..80c84d562fa4a 100644
--- a/arch/ppc/boot/lib/Makefile
+++ b/arch/ppc/boot/lib/Makefile
@@ -3,7 +3,7 @@
#
CFLAGS_kbd.o := -Idrivers/char
-CFLAGS_vreset.o := -I$(srctree)/arch/ppc/boot/include
+CFLAGS_vreset.o := -Iarch/ppc/boot/include
zlib := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 6c6b197898d0b..7bb16fb97d4fb 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -67,7 +67,6 @@ cflags-$(CONFIG_WARN_STACK) += -mwarn-framesize=$(CONFIG_WARN_STACK_SIZE)
endif
CFLAGS += -mbackchain -msoft-float $(cflags-y)
-CFLAGS += $(call cc-option,-finline-limit=10000)
CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare
AFLAGS += $(aflags-y)
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index f8d0cd540a06b..f4dfc10026d24 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,10 +1,11 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-rc2
-# Wed Feb 8 10:44:39 2006
+# Linux kernel version: 2.6.17-rc1
+# Mon Apr 3 14:34:15 2006
#
CONFIG_MMU=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_S390=y
@@ -30,8 +31,8 @@ CONFIG_AUDIT=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
# CONFIG_CPUSETS is not set
+# CONFIG_RELAY is not set
CONFIG_INITRAMFS_SOURCE=""
-CONFIG_UID16=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
# CONFIG_EMBEDDED is not set
CONFIG_KALLSYMS=y
@@ -45,10 +46,6 @@ CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
CONFIG_SLAB=y
# CONFIG_TINY_SHMEM is not set
CONFIG_BASE_SMALL=0
@@ -60,7 +57,6 @@ CONFIG_BASE_SMALL=0
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
CONFIG_MODVERSIONS=y
# CONFIG_MODULE_SRCVERSION_ALL is not set
CONFIG_KMOD=y
@@ -69,7 +65,7 @@ CONFIG_STOP_MACHINE=y
#
# Block layer
#
-# CONFIG_LBD is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
#
# IO Schedulers
@@ -91,17 +87,20 @@ CONFIG_DEFAULT_IOSCHED="deadline"
#
# Processor type and features
#
-# CONFIG_64BIT is not set
+CONFIG_64BIT=y
CONFIG_SMP=y
CONFIG_NR_CPUS=32
CONFIG_HOTPLUG_CPU=y
-CONFIG_MATHEMU=y
+CONFIG_DEFAULT_MIGRATION_COST=1000000
+CONFIG_COMPAT=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_BINFMT_ELF32=y
#
# Code generation options
#
-CONFIG_MARCH_G5=y
-# CONFIG_MARCH_Z900 is not set
+# CONFIG_MARCH_G5 is not set
+CONFIG_MARCH_Z900=y
# CONFIG_MARCH_Z990 is not set
CONFIG_PACK_STACK=y
# CONFIG_SMALL_STACK is not set
@@ -143,7 +142,7 @@ CONFIG_VIRT_CPU_ACCOUNTING=y
# CONFIG_APPLDATA_BASE is not set
CONFIG_NO_IDLE_HZ=y
CONFIG_NO_IDLE_HZ_INIT=y
-# CONFIG_KEXEC is not set
+CONFIG_KEXEC=y
#
# Networking
@@ -173,6 +172,7 @@ CONFIG_IP_FIB_HASH=y
# CONFIG_INET_AH is not set
# CONFIG_INET_ESP is not set
# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
# CONFIG_INET_TUNNEL is not set
CONFIG_INET_DIAG=y
CONFIG_INET_TCP_DIAG=y
@@ -180,9 +180,11 @@ CONFIG_INET_TCP_DIAG=y
CONFIG_TCP_CONG_BIC=y
CONFIG_IPV6=y
# CONFIG_IPV6_PRIVACY is not set
+# CONFIG_IPV6_ROUTER_PREF is not set
# CONFIG_INET6_AH is not set
# CONFIG_INET6_ESP is not set
# CONFIG_INET6_IPCOMP is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
# CONFIG_INET6_TUNNEL is not set
# CONFIG_IPV6_TUNNEL is not set
# CONFIG_NETFILTER is not set
@@ -276,6 +278,11 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
# CONFIG_DEBUG_DRIVER is not set
#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
# SCSI device support
#
# CONFIG_RAID_ATTRS is not set
@@ -340,8 +347,7 @@ CONFIG_DASD_PROFILE=y
CONFIG_DASD_ECKD=y
CONFIG_DASD_FBA=y
CONFIG_DASD_DIAG=y
-CONFIG_DASD_EER=m
-# CONFIG_DASD_CMB is not set
+CONFIG_DASD_EER=y
# CONFIG_ATA_OVER_ETH is not set
#
@@ -354,6 +360,7 @@ CONFIG_MD_RAID0=m
CONFIG_MD_RAID1=m
# CONFIG_MD_RAID10 is not set
CONFIG_MD_RAID5=m
+# CONFIG_MD_RAID5_RESHAPE is not set
# CONFIG_MD_RAID6 is not set
CONFIG_MD_MULTIPATH=m
# CONFIG_MD_FAULTY is not set
@@ -404,6 +411,7 @@ CONFIG_S390_TAPE_BLOCK=y
# S/390 tape hardware support
#
CONFIG_S390_TAPE_34XX=m
+# CONFIG_S390_TAPE_3590 is not set
# CONFIG_VMLOGRDR is not set
# CONFIG_VMCP is not set
# CONFIG_MONREADER is not set
@@ -529,7 +537,6 @@ CONFIG_SYSFS=y
CONFIG_TMPFS=y
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y
-# CONFIG_RELAYFS_FS is not set
# CONFIG_CONFIGFS_FS is not set
#
@@ -619,14 +626,15 @@ CONFIG_LOG_BUF_SHIFT=17
# CONFIG_DETECT_SOFTLOCKUP is not set
# CONFIG_SCHEDSTATS is not set
# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_PREEMPT is not set
+CONFIG_DEBUG_PREEMPT=y
CONFIG_DEBUG_MUTEXES=y
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
# CONFIG_DEBUG_KOBJECT is not set
# CONFIG_DEBUG_INFO is not set
CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_VM is not set
+# CONFIG_UNWIND_INFO is not set
CONFIG_FORCED_INLINING=y
# CONFIG_RCU_TORTURE_TEST is not set
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 58583f4594719..2bcecf4225734 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -527,6 +527,11 @@ config CPU_HAS_SR_RB
See <file:Documentation/sh/register-banks.txt> for further
information on SR.RB and register banking in the kernel in general.
+config NODES_SHIFT
+ int
+ default "1"
+ depends on NEED_MULTIPLE_NODES
+
endmenu
menu "Boot options"
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index 1cf94a618be3c..d5d032533a8b3 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -37,7 +37,6 @@ EXPORT_SYMBOL(disable_irq_nosync);
EXPORT_SYMBOL(irq_desc);
EXPORT_SYMBOL(no_irq_type);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(strlen);
EXPORT_SYMBOL(strnlen);
diff --git a/arch/sh64/kernel/sh_ksyms.c b/arch/sh64/kernel/sh_ksyms.c
index de29c45f23a72..6f3a1c9463394 100644
--- a/arch/sh64/kernel/sh_ksyms.c
+++ b/arch/sh64/kernel/sh_ksyms.c
@@ -41,7 +41,6 @@ EXPORT_SYMBOL(kernel_thread);
/* Networking helper routines. */
EXPORT_SYMBOL(csum_partial_copy);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strstr);
#ifdef CONFIG_VT
diff --git a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
index 2be8121151977..a93f5da6855d5 100644
--- a/arch/sparc/kernel/smp.c
+++ b/arch/sparc/kernel/smp.c
@@ -244,7 +244,7 @@ int setup_profiling_timer(unsigned int multiplier)
return -EINVAL;
spin_lock_irqsave(&prof_setup_lock, flags);
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
load_profile_irq(i, lvl14_resolution / multiplier);
prof_multiplier(i) = multiplier;
}
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 2c21d79076356..ec1c9687d6792 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -263,7 +263,6 @@ EXPORT_SYMBOL(strcmp);
EXPORT_SYMBOL(strncmp);
EXPORT_SYMBOL(strchr);
EXPORT_SYMBOL(strrchr);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strstr);
EXPORT_SYMBOL(page_kernel);
diff --git a/arch/sparc/math-emu/Makefile b/arch/sparc/math-emu/Makefile
index f84a9a6162be9..8136987977f45 100644
--- a/arch/sparc/math-emu/Makefile
+++ b/arch/sparc/math-emu/Makefile
@@ -5,4 +5,4 @@
obj-y := math.o
EXTRA_AFLAGS := -ansi
-EXTRA_CFLAGS = -I. -I$(TOPDIR)/include/math-emu -w
+EXTRA_CFLAGS = -I. -Iinclude/math-emu -w
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index d1e2fc5664862..648047a0bce34 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -194,6 +194,9 @@ endchoice
endmenu
+config ARCH_SELECT_MEMORY_MODEL
+ def_bool y
+
config ARCH_SPARSEMEM_ENABLE
def_bool y
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index 30389085a3591..1317380fa9377 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.16
-# Fri Mar 31 01:40:57 2006
+# Sun Apr 2 19:31:04 2006
#
CONFIG_SPARC=y
CONFIG_SPARC64=y
@@ -838,7 +838,6 @@ CONFIG_FB_TILEBLITTING=y
# CONFIG_FB_NVIDIA is not set
# CONFIG_FB_RIVA is not set
# CONFIG_FB_MATROX is not set
-# CONFIG_FB_RADEON_OLD is not set
CONFIG_FB_RADEON=y
CONFIG_FB_RADEON_I2C=y
# CONFIG_FB_RADEON_DEBUG is not set
@@ -924,6 +923,7 @@ CONFIG_SND_MTPAV=m
# PCI devices
#
# CONFIG_SND_AD1889 is not set
+# CONFIG_SND_ALS300 is not set
CONFIG_SND_ALI5451=m
# CONFIG_SND_ATIIXP is not set
# CONFIG_SND_ATIIXP_MODEM is not set
@@ -955,6 +955,7 @@ CONFIG_SND_ALI5451=m
# CONFIG_SND_MIXART is not set
# CONFIG_SND_NM256 is not set
# CONFIG_SND_PCXHR is not set
+# CONFIG_SND_RIPTIDE is not set
# CONFIG_SND_RME32 is not set
# CONFIG_SND_RME96 is not set
# CONFIG_SND_RME9652 is not set
@@ -1109,6 +1110,11 @@ CONFIG_USB_HIDDEV=y
# CONFIG_MMC is not set
#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
# InfiniBand support
#
# CONFIG_INFINIBAND is not set
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 9372d4f376d5a..9e94db2573a2f 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -1092,7 +1092,7 @@ void sun4v_pci_init(int node, char *model_name)
}
}
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
unsigned long page = get_zeroed_page(GFP_ATOMIC);
if (!page)
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index eb93e9c528462..49e6dedd027d6 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -244,6 +244,13 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
}
switch(request) {
+ case PTRACE_PEEKUSR:
+ if (addr != 0)
+ pt_error_return(regs, EIO);
+ else
+ pt_succ_return(regs, 0);
+ goto out_tsk;
+
case PTRACE_PEEKTEXT: /* read word at location addr. */
case PTRACE_PEEKDATA: {
unsigned long tmp64;
@@ -602,6 +609,22 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
/* PTRACE_DUMPCORE unsupported... */
+ case PTRACE_GETEVENTMSG: {
+ int err;
+
+ if (test_thread_flag(TIF_32BIT))
+ err = put_user(child->ptrace_message,
+ (unsigned int __user *) data);
+ else
+ err = put_user(child->ptrace_message,
+ (unsigned long __user *) data);
+ if (err)
+ pt_error_return(regs, -err);
+ else
+ pt_succ_return(regs, 0);
+ break;
+ }
+
default: {
int err = ptrace_request(child, request, addr, data);
if (err)
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 7d0e67c1ce509..005167f82419b 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -535,7 +535,7 @@ static int __init topology_init(void)
while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
ncpus_probed++;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
if (p) {
register_cpu(p, i, NULL);
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 8175a6968c6bc..90eaca3ec9a62 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -745,12 +745,21 @@ struct call_data_struct {
int wait;
};
-static DEFINE_SPINLOCK(call_lock);
+static __cacheline_aligned_in_smp DEFINE_SPINLOCK(call_lock);
static struct call_data_struct *call_data;
extern unsigned long xcall_call_function;
-/*
+/**
+ * smp_call_function(): Run a function on all other CPUs.
+ * @func: The function to run. This must be fast and non-blocking.
+ * @info: An arbitrary pointer to pass to the function.
+ * @nonatomic: currently unused.
+ * @wait: If true, wait (atomically) until function has completed on other CPUs.
+ *
+ * Returns 0 on success, else a negative status code. Does not return until
+ * remote CPUs are nearly ready to execute <<func>> or are or have executed.
+ *
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler.
*/
@@ -759,7 +768,6 @@ static int smp_call_function_mask(void (*func)(void *info), void *info,
{
struct call_data_struct data;
int cpus;
- long timeout;
/* Can deadlock when called with interrupts disabled */
WARN_ON(irqs_disabled());
@@ -777,31 +785,18 @@ static int smp_call_function_mask(void (*func)(void *info), void *info,
goto out_unlock;
call_data = &data;
+ mb();
smp_cross_call_masked(&xcall_call_function, 0, 0, 0, mask);
- /*
- * Wait for other cpus to complete function or at
- * least snap the call data.
- */
- timeout = 1000000;
- while (atomic_read(&data.finished) != cpus) {
- if (--timeout <= 0)
- goto out_timeout;
- barrier();
- udelay(1);
- }
+ /* Wait for response */
+ while (atomic_read(&data.finished) != cpus)
+ cpu_relax();
out_unlock:
spin_unlock(&call_lock);
return 0;
-
-out_timeout:
- spin_unlock(&call_lock);
- printk("XCALL: Remote cpus not responding, ncpus=%d finished=%d\n",
- cpus, atomic_read(&data.finished));
- return 0;
}
int smp_call_function(void (*func)(void *info), void *info,
@@ -1285,7 +1280,7 @@ int setup_profiling_timer(unsigned int multiplier)
return -EINVAL;
spin_lock_irqsave(&prof_setup_lock, flags);
- for_each_cpu(i)
+ for_each_possible_cpu(i)
prof_multiplier(i) = multiplier;
current_tick_offset = (timer_tick_offset / multiplier);
spin_unlock_irqrestore(&prof_setup_lock, flags);
@@ -1313,12 +1308,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
}
}
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
if (tlb_type == hypervisor) {
int j;
/* XXX get this mapping from machine description */
- for_each_cpu(j) {
+ for_each_possible_cpu(j) {
if ((j >> 2) == (i >> 2))
cpu_set(j, cpu_sibling_map[i]);
}
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index f5e8db1de76b5..62d8a99271eac 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -276,7 +276,6 @@ EXPORT_SYMBOL(__prom_getsibling);
EXPORT_SYMBOL(strlen);
EXPORT_SYMBOL(__strlen_user);
EXPORT_SYMBOL(__strnlen_user);
-EXPORT_SYMBOL(strpbrk);
#ifdef CONFIG_SOLARIS_EMUL_MODULE
EXPORT_SYMBOL(linux_sparc_syscall);
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index ff090bb9734b8..2793a5d823803 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -1130,9 +1130,9 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
(recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
afsr, afar,
(afsr & CHAFSR_TL1) ? 1 : 0);
- printk("%s" "ERROR(%d): TPC[%016lx] TNPC[%016lx] TSTATE[%016lx]\n",
+ printk("%s" "ERROR(%d): TPC[%lx] TNPC[%lx] O7[%lx] TSTATE[%lx]\n",
(recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
- regs->tpc, regs->tnpc, regs->tstate);
+ regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
(recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
(afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 24790bed2054d..a508e7a028910 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -159,6 +159,7 @@ archclean:
$(SYMLINK_HEADERS):
@echo ' SYMLINK $@'
ifneq ($(KBUILD_SRC),)
+ $(Q)mkdir -p $(objtree)/include/asm-um
$(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
else
$(Q)cd $(TOPDIR)/$(dir $@) ; \
@@ -168,7 +169,7 @@ endif
include/asm-um/arch:
@echo ' SYMLINK $@'
ifneq ($(KBUILD_SRC),)
- $(Q)mkdir -p include/asm-um
+ $(Q)mkdir -p $(objtree)/include/asm-um
$(Q)ln -fsn $(srctree)/include/asm-$(SUBARCH) include/asm-um/arch
else
$(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h
index 04e3958266e07..dc36b222100b9 100644
--- a/arch/um/drivers/cow.h
+++ b/arch/um/drivers/cow.h
@@ -46,7 +46,7 @@ extern int file_reader(__u64 offset, char *buf, int len, void *arg);
extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
void *arg, __u32 *version_out,
char **backing_file_out, time_t *mtime_out,
- __u64 *size_out, int *sectorsize_out,
+ unsigned long long *size_out, int *sectorsize_out,
__u32 *align_out, int *bitmap_offset_out);
extern int write_cow_header(char *cow_file, int fd, char *backing_file,
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h
index 94de4ead4f7a2..7a5b4afde6929 100644
--- a/arch/um/drivers/cow_sys.h
+++ b/arch/um/drivers/cow_sys.h
@@ -28,7 +28,7 @@ static inline int cow_seek_file(int fd, __u64 offset)
return(os_seek_file(fd, offset));
}
-static inline int cow_file_size(char *file, __u64 *size_out)
+static inline int cow_file_size(char *file, unsigned long long *size_out)
{
return(os_file_size(file, size_out));
}
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index 61951b721268f..0ec4052db9c5b 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -17,30 +17,34 @@
#define PATH_LEN_V1 256
+typedef __u32 time32_t;
+
struct cow_header_v1 {
- int magic;
- int version;
+ __s32 magic;
+ __s32 version;
char backing_file[PATH_LEN_V1];
- time_t mtime;
+ time32_t mtime;
__u64 size;
- int sectorsize;
-};
+ __s32 sectorsize;
+} __attribute__((packed));
-#define PATH_LEN_V2 MAXPATHLEN
+/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
+ * case other systems have different values for MAXPATHLEN.
+ *
+ * The same must hold for V2 - we want file format compatibility, not anything
+ * else.
+ */
+#define PATH_LEN_V3 4096
+#define PATH_LEN_V2 PATH_LEN_V3
struct cow_header_v2 {
__u32 magic;
__u32 version;
char backing_file[PATH_LEN_V2];
- time_t mtime;
+ time32_t mtime;
__u64 size;
- int sectorsize;
-};
-
-/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
- * case other systems have different values for MAXPATHLEN
- */
-#define PATH_LEN_V3 4096
+ __s32 sectorsize;
+} __attribute__((packed));
/* Changes from V2 -
* PATH_LEN_V3 as described above
@@ -66,6 +70,15 @@ struct cow_header_v2 {
* Fixed (finally!) the rounding bug
*/
+/* Until Dec2005, __attribute__((packed)) was left out from the below
+ * definition, leading on 64-bit systems to 4 bytes of padding after mtime, to
+ * align size to 8-byte alignment. This shifted all fields above (no padding
+ * was present on 32-bit, no other padding was added).
+ *
+ * However, this _can be detected_: it means that cow_format (always 0 until
+ * now) is shifted onto the first 4 bytes of backing_file, where it is otherwise
+ * impossible to find 4 zeros. -bb */
+
struct cow_header_v3 {
__u32 magic;
__u32 version;
@@ -75,6 +88,18 @@ struct cow_header_v3 {
__u32 alignment;
__u32 cow_format;
char backing_file[PATH_LEN_V3];
+} __attribute__((packed));
+
+/* This is the broken layout used by some 64-bit binaries. */
+struct cow_header_v3_broken {
+ __u32 magic;
+ __u32 version;
+ __s64 mtime;
+ __u64 size;
+ __u32 sectorsize;
+ __u32 alignment;
+ __u32 cow_format;
+ char backing_file[PATH_LEN_V3];
};
/* COW format definitions - for now, we have only the usual COW bitmap */
@@ -84,6 +109,7 @@ union cow_header {
struct cow_header_v1 v1;
struct cow_header_v2 v2;
struct cow_header_v3 v3;
+ struct cow_header_v3_broken v3_b;
};
#define COW_MAGIC 0x4f4f4f4d /* MOOO */
@@ -184,8 +210,9 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
err = -EINVAL;
if(strlen(backing_file) > sizeof(header->backing_file) - 1){
+ /* Below, %zd is for a size_t value */
cow_printf("Backing file name \"%s\" is too long - names are "
- "limited to %d characters\n", backing_file,
+ "limited to %zd characters\n", backing_file,
sizeof(header->backing_file) - 1);
goto out_free;
}
@@ -300,7 +327,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
*align_out = *sectorsize_out;
file = header->v2.backing_file;
}
- else if(version == 3){
+ /* This is very subtle - see above at union cow_header definition */
+ else if(version == 3 && (*((int*)header->v3.backing_file) != 0)){
if(n < sizeof(header->v3)){
cow_printf("read_cow_header - failed to read V3 "
"header\n");
@@ -310,9 +338,43 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
*size_out = ntohll(header->v3.size);
*sectorsize_out = ntohl(header->v3.sectorsize);
*align_out = ntohl(header->v3.alignment);
+ if (*align_out == 0) {
+ cow_printf("read_cow_header - invalid COW header, "
+ "align == 0\n");
+ }
*bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
file = header->v3.backing_file;
}
+ else if(version == 3){
+ cow_printf("read_cow_header - broken V3 file with"
+ " 64-bit layout - recovering content.\n");
+
+ if(n < sizeof(header->v3_b)){
+ cow_printf("read_cow_header - failed to read V3 "
+ "header\n");
+ goto out;
+ }
+
+ /* this was used until Dec2005 - 64bits are needed to represent
+ * 2038+. I.e. we can safely do this truncating cast.
+ *
+ * Additionally, we must use ntohl() instead of ntohll(), since
+ * the program used to use the former (tested - I got mtime
+ * mismatch "0 vs whatever").
+ *
+ * Ever heard about bug-to-bug-compatibility ? ;-) */
+ *mtime_out = (time32_t) ntohl(header->v3_b.mtime);
+
+ *size_out = ntohll(header->v3_b.size);
+ *sectorsize_out = ntohl(header->v3_b.sectorsize);
+ *align_out = ntohl(header->v3_b.alignment);
+ if (*align_out == 0) {
+ cow_printf("read_cow_header - invalid COW header, "
+ "align == 0\n");
+ }
+ *bitmap_offset_out = ROUND_UP(sizeof(header->v3_b), *align_out);
+ file = header->v3_b.backing_file;
+ }
else {
cow_printf("read_cow_header - invalid COW version\n");
goto out;
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 28e3760e8b981..6d7173fc55a39 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -62,7 +62,7 @@ static void mc_work_proc(void *unused)
unsigned long flags;
while(!list_empty(&mc_requests)){
- local_save_flags(flags);
+ local_irq_save(flags);
req = list_entry(mc_requests.next, struct mconsole_entry,
list);
list_del(&req->list);
@@ -87,7 +87,7 @@ static irqreturn_t mconsole_interrupt(int irq, void *dev_id,
if(req.cmd->context == MCONSOLE_INTR)
(*req.cmd->handler)(&req);
else {
- new = kmalloc(sizeof(*new), GFP_ATOMIC);
+ new = kmalloc(sizeof(*new), GFP_NOWAIT);
if(new == NULL)
mconsole_reply(&req, "Out of memory", 1, 0);
else {
@@ -415,7 +415,6 @@ static int mem_config(char *str)
unplugged = page_address(page);
if(unplug_index == UNPLUGGED_PER_PAGE){
- INIT_LIST_HEAD(&unplugged->list);
list_add(&unplugged->list, &unplugged_pages);
unplug_index = 0;
}
@@ -616,7 +615,7 @@ static void console_write(struct console *console, const char *string,
return;
while(1){
- n = min((size_t)len, ARRAY_SIZE(console_buf) - console_index);
+ n = min((size_t) len, ARRAY_SIZE(console_buf) - console_index);
strncpy(&console_buf[console_index], string, n);
console_index += n;
string += n;
@@ -655,7 +654,6 @@ static void with_console(struct mc_request *req, void (*proc)(void *),
struct mconsole_entry entry;
unsigned long flags;
- INIT_LIST_HEAD(&entry.list);
entry.request = *req;
list_add(&entry.list, &clients);
spin_lock_irqsave(&console_lock, flags);
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0e2f06187ea7a..0a7786e00cfb8 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -182,7 +182,9 @@ static int change_tramp(char **argv, char *output, int output_len)
pe_data.stdout = fds[1];
pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
- read_output(fds[0], output, output_len);
+ if (pid > 0) /* Avoid hang as we won't get data in failure case. */
+ read_output(fds[0], output, output_len);
+
os_close_file(fds[0]);
os_close_file(fds[1]);
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c
index b94c66114bc85..33c5f6e625e83 100644
--- a/arch/um/drivers/slirp_user.c
+++ b/arch/um/drivers/slirp_user.c
@@ -104,7 +104,7 @@ static void slirp_close(int fd, void *data)
}
if(err == 0) {
- printk("slirp_close: process %d has not exited\n");
+ printk("slirp_close: process %d has not exited\n", pri->pid);
return;
}
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 42557130a4081..efa3d33c0be65 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -117,10 +117,6 @@ extern struct task_struct *get_task(int pid, int require);
extern void machine_halt(void);
extern int is_syscall(unsigned long addr);
-extern void arch_switch_to_tt(struct task_struct *from, struct task_struct *to);
-
-extern void arch_switch_to_skas(struct task_struct *from, struct task_struct *to);
-
extern void free_irq(unsigned int, void *);
extern int cpu(void);
diff --git a/arch/um/include/tt/tt.h b/arch/um/include/tt/tt.h
index 8085219801861..acb8356e1f983 100644
--- a/arch/um/include/tt/tt.h
+++ b/arch/um/include/tt/tt.h
@@ -19,7 +19,8 @@ extern int fork_tramp(void *sig_stack);
extern int do_proc_op(void *t, int proc_id);
extern int tracer(int (*init_proc)(void *), void *sp);
extern void attach_process(int pid);
-extern void tracer_panic(char *format, ...);
+extern void tracer_panic(char *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
extern void set_init_pid(int pid);
extern int set_user_mode(void *task);
extern void set_tracing(void *t, int tracing);
diff --git a/arch/um/include/user.h b/arch/um/include/user.h
index 91b0ac4ad88cc..39f8c88010763 100644
--- a/arch/um/include/user.h
+++ b/arch/um/include/user.h
@@ -6,8 +6,10 @@
#ifndef __USER_H__
#define __USER_H__
-extern void panic(const char *fmt, ...);
-extern int printk(const char *fmt, ...);
+extern void panic(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+extern int printk(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
extern void schedule(void);
extern void *um_kmalloc(int size);
extern void *um_kmalloc_atomic(int size);
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h
index fe0c29b5144db..802d7842514d2 100644
--- a/arch/um/include/user_util.h
+++ b/arch/um/include/user_util.h
@@ -55,7 +55,8 @@ extern int get_pty(void);
extern void *um_kmalloc(int size);
extern int switcheroo(int fd, int prot, void *from, void *to, int size);
extern void do_exec(int old_pid, int new_pid);
-extern void tracer_panic(char *msg, ...);
+extern void tracer_panic(char *msg, ...)
+ __attribute__ ((format (printf, 1, 2)));
extern int detach(int pid, int sig);
extern int attach(int pid);
extern void kill_child_dead(int pid);
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index 7713e7a6f476f..432cf0b97a138 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -39,7 +39,6 @@ EXPORT_SYMBOL(um_virt_to_phys);
EXPORT_SYMBOL(mode_tt);
EXPORT_SYMBOL(handle_page_fault);
EXPORT_SYMBOL(find_iomem);
-EXPORT_SYMBOL(end_iomem);
#ifdef CONFIG_MODE_TT
EXPORT_SYMBOL(strncpy_from_user_tt);
@@ -89,12 +88,10 @@ EXPORT_SYMBOL(dump_thread);
EXPORT_SYMBOL(do_gettimeofday);
EXPORT_SYMBOL(do_settimeofday);
-/* This is here because UML expands open to sys_open, not to a system
+/* This is here because UML expands lseek to sys_lseek, not to a system
* call instruction.
*/
-EXPORT_SYMBOL(sys_open);
EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_read);
EXPORT_SYMBOL(sys_wait4);
#ifdef CONFIG_SMP
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index 901b85e8a1c65..8f49507e64ef5 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -40,7 +40,7 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask,
int fd)
{
struct addr_change change;
- void *output;
+ char *output;
int n;
change.what = op;
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index 6490a4ff40ac4..6987d1d247a2e 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -43,7 +43,7 @@ static int helper_child(void *arg)
(*data->pre_exec)(data->pre_data);
execvp(argv[0], argv);
errval = errno;
- printk("execvp of '%s' failed - errno = %d\n", argv[0], errno);
+ printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
os_write_file(data->fd, &errval, sizeof(errval));
kill(os_getpid(), SIGKILL);
return(0);
@@ -92,15 +92,15 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
close(fds[1]);
fds[1] = -1;
- /*Read the errno value from the child.*/
+ /* Read the errno value from the child, if the exec failed, or get 0 if
+ * the exec succeeded because the pipe fd was set as close-on-exec. */
n = os_read_file(fds[0], &ret, sizeof(ret));
- if(n < 0){
+ if (n < 0) {
printk("run_helper : read on pipe failed, ret = %d\n", -n);
ret = n;
kill(pid, SIGKILL);
CATCH_EINTR(waitpid(pid, NULL, 0));
- }
- else if(n != 0){
+ } else if(n != 0){
CATCH_EINTR(n = waitpid(pid, NULL, 0));
ret = -errno;
} else {
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 6ab372da96579..71bb90a7606d0 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -53,33 +53,36 @@ static void __init find_tempdir(void)
*/
int make_tempfile(const char *template, char **out_tempname, int do_unlink)
{
- char tempname[MAXPATHLEN];
+ char *tempname;
int fd;
+ tempname = malloc(MAXPATHLEN);
+
find_tempdir();
- if (*template != '/')
+ if (template[0] != '/')
strcpy(tempname, tempdir);
else
- *tempname = 0;
+ tempname[0] = '\0';
strcat(tempname, template);
fd = mkstemp(tempname);
if(fd < 0){
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
strerror(errno));
- return -1;
+ goto out;
}
if(do_unlink && (unlink(tempname) < 0)){
perror("unlink");
- return -1;
+ goto out;
}
if(out_tempname){
- *out_tempname = strdup(tempname);
- if(*out_tempname == NULL){
- perror("strdup");
- return -1;
- }
+ *out_tempname = tempname;
+ } else {
+ free(tempname);
}
return(fd);
+out:
+ free(tempname);
+ return -1;
}
#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index 9ba9429471468..00e9388e947af 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -304,8 +304,8 @@ out_clear_poll:
.size = 0,
.used = 0 });
out_free:
- kfree(p);
sigio_unlock();
+ kfree(p);
out_close2:
close(l_sigio_private[0]);
close(l_sigio_private[1]);
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c
index fbb080c2fc261..b3c11cfa995a7 100644
--- a/arch/um/os-Linux/skas/mem.c
+++ b/arch/um/os-Linux/skas/mem.c
@@ -82,8 +82,8 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
if (offset) {
data = (unsigned long *)(mm_idp->stack +
offset - UML_CONFIG_STUB_DATA);
- printk("do_syscall_stub : ret = %d, offset = %d, "
- "data = 0x%x\n", ret, offset, data);
+ printk("do_syscall_stub : ret = %ld, offset = %ld, "
+ "data = %p\n", ret, offset, data);
syscall = (unsigned long *)((unsigned long)data + data[0]);
printk("do_syscall_stub: syscall %ld failed, return value = "
"0x%lx, expected return value = 0x%lx\n",
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index bbf34cb91ce18..045ae0037456a 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -265,7 +265,7 @@ void userspace(union uml_pt_regs *regs)
if(err)
panic("userspace - could not resume userspace process, "
"pid=%d, ptrace operation = %d, errno = %d\n",
- op, errno);
+ pid, op, errno);
CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
if(err < 0)
@@ -369,7 +369,7 @@ int copy_context_skas0(unsigned long new_stack, int pid)
*/
wait_stub_done(pid, -1, "copy_context_skas0");
if (child_data->err != UML_CONFIG_STUB_DATA)
- panic("copy_context_skas0 - stub-child reports error %d\n",
+ panic("copy_context_skas0 - stub-child reports error %ld\n",
child_data->err);
if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c
index ba21f0e04a2f3..120abbe4e3ce2 100644
--- a/arch/um/os-Linux/sys-i386/tls.c
+++ b/arch/um/os-Linux/sys-i386/tls.c
@@ -1,3 +1,4 @@
+#include <errno.h>
#include <linux/unistd.h>
#include "sysdep/tls.h"
#include "user_util.h"
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index 198e591632887..34bfc1bb9e386 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -120,7 +120,8 @@ static int not_dead_yet(char *dir)
dead = 0;
fd = open(file, O_RDONLY);
- if(fd < 0){
+ if(fd < 0) {
+ fd = -errno;
if(fd != -ENOENT){
printk("not_dead_yet : couldn't open pid file '%s', "
"err = %d\n", file, -fd);
@@ -130,9 +131,13 @@ static int not_dead_yet(char *dir)
err = 0;
n = read(fd, pid, sizeof(pid));
- if(n <= 0){
+ if(n < 0){
+ printk("not_dead_yet : couldn't read pid file '%s', "
+ "err = %d\n", file, errno);
+ goto out_close;
+ } else if(n == 0){
printk("not_dead_yet : couldn't read pid file '%s', "
- "err = %d\n", file, -n);
+ "0-byte read\n", file);
goto out_close;
}
@@ -155,9 +160,9 @@ static int not_dead_yet(char *dir)
return err;
- out_close:
+out_close:
close(fd);
- out:
+out:
return 0;
}
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index 8da6ab31152ad..2598158e1f53a 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -18,14 +18,19 @@ extern void *memmove(void *, const void *, size_t);
extern void *memset(void *, int, size_t);
extern int printf(const char *, ...);
+/* If they're not defined, the export is included in lib/string.c.*/
+#ifdef __HAVE_ARCH_STRLEN
EXPORT_SYMBOL(strlen);
+#endif
+#ifdef __HAVE_ARCH_STRSTR
+EXPORT_SYMBOL(strstr);
+#endif
+
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(printf);
-EXPORT_SYMBOL(strstr);
-
/* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms.
* However, the modules will use the CRC defined *here*, no matter if it is
* good; so the versions of these symbols will always match
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index b696b451774cf..5e7a9c310aa50 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -9,10 +9,8 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
$(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \
c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@))
-$(USER_OBJS): cmd_checksrc =
-$(USER_OBJS): quiet_cmd_checksrc =
-$(USER_OBJS): cmd_force_checksrc =
-$(USER_OBJS): quiet_cmd_force_checksrc =
+$(USER_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \
+ -Dunix -D__unix__ -D__$(SUBARCH)__
# The stubs and unmap.o can't try to call mcount or update basic block data
diff --git a/arch/um/sys-i386/ksyms.c b/arch/um/sys-i386/ksyms.c
index db524ab3f743a..2a1eac1859ce7 100644
--- a/arch/um/sys-i386/ksyms.c
+++ b/arch/um/sys-i386/ksyms.c
@@ -15,7 +15,3 @@ EXPORT_SYMBOL(__up_wakeup);
/* Networking helper routines. */
EXPORT_SYMBOL(csum_partial);
-
-/* delay core functions */
-EXPORT_SYMBOL(__const_udelay);
-EXPORT_SYMBOL(__udelay);
diff --git a/arch/um/sys-i386/ptrace_user.c b/arch/um/sys-i386/ptrace_user.c
index 9f3bd8ed78f5b..40aa885314469 100644
--- a/arch/um/sys-i386/ptrace_user.c
+++ b/arch/um/sys-i386/ptrace_user.c
@@ -57,7 +57,7 @@ static void write_debugregs(int pid, unsigned long *regs)
if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
regs[i]) < 0)
printk("write_debugregs - ptrace failed on "
- "register %d, value = 0x%x, errno = %d\n", i,
+ "register %d, value = 0x%lx, errno = %d\n", i,
regs[i], errno);
}
}
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index f5d0e1c37ea26..618fd8594643b 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -147,7 +147,7 @@ int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate __user *fp,
* delivery. The sp passed in is the original, and this needs
* to be restored, so we stick it in separately.
*/
- err |= copy_to_user(&SC_SP(to), sp, sizeof(sp));
+ err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
if(from_fp != NULL){
err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
diff --git a/arch/um/sys-i386/tls.c b/arch/um/sys-i386/tls.c
index a3188e861cc7f..71b9796258ef6 100644
--- a/arch/um/sys-i386/tls.c
+++ b/arch/um/sys-i386/tls.c
@@ -378,7 +378,7 @@ static int __init __setup_host_supports_tls(void) {
} else
printk(KERN_ERR " Host TLS support NOT detected! "
"TLS support inside UML will not work\n");
- return 1;
+ return 0;
}
__initcall(__setup_host_supports_tls);
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index e75c4e1838b0d..a4c46a8af0084 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -137,7 +137,7 @@ int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp,
* delivery. The sp passed in is the original, and this needs
* to be restored, so we stick it in separately.
*/
- err |= copy_to_user(&SC_SP(to), sp, sizeof(sp));
+ err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
if(from_fp != NULL){
err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
diff --git a/arch/v850/kernel/v850_ksyms.c b/arch/v850/kernel/v850_ksyms.c
index 8ffc29c1c89df..6bcfcfe88384b 100644
--- a/arch/v850/kernel/v850_ksyms.c
+++ b/arch/v850/kernel/v850_ksyms.c
@@ -43,7 +43,6 @@ EXPORT_SYMBOL (strncmp);
EXPORT_SYMBOL (strchr);
EXPORT_SYMBOL (strlen);
EXPORT_SYMBOL (strnlen);
-EXPORT_SYMBOL (strpbrk);
EXPORT_SYMBOL (strrchr);
EXPORT_SYMBOL (strstr);
EXPORT_SYMBOL (memset);
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 4310b4a311a55..408d44a59756f 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -136,6 +136,11 @@ config X86_L1_CACHE_SHIFT
default "7" if GENERIC_CPU || MPSC
default "6" if MK8
+config X86_INTERNODE_CACHE_BYTES
+ int
+ default "4096" if X86_VSMP
+ default X86_L1_CACHE_BYTES if !X86_VSMP
+
config X86_TSC
bool
default y
@@ -283,6 +288,11 @@ config K8_NUMA
Northbridge of Opteron. It is recommended to use X86_64_ACPI_NUMA
instead, which also takes priority if both are compiled in.
+config NODES_SHIFT
+ int
+ default "6"
+ depends on NEED_MULTIPLE_NODES
+
# Dummy CONFIG option to select ACPI_NUMA from drivers/acpi/Kconfig.
config X86_64_ACPI_NUMA
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 585fd4a559c87..e573e2ab55108 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -24,37 +24,37 @@
LDFLAGS := -m elf_x86_64
OBJCOPYFLAGS := -O binary -R .note -R .comment -S
LDFLAGS_vmlinux :=
-
CHECKFLAGS += -D__x86_64__ -m64
+cflags-y :=
cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
-CFLAGS += $(cflags-y)
-CFLAGS += -m64
-CFLAGS += -mno-red-zone
-CFLAGS += -mcmodel=kernel
-CFLAGS += -pipe
+cflags-y += -m64
+cflags-y += -mno-red-zone
+cflags-y += -mcmodel=kernel
+cflags-y += -pipe
cflags-$(CONFIG_REORDER) += -ffunction-sections
# this makes reading assembly source easier, but produces worse code
# actually it makes the kernel smaller too.
-CFLAGS += -fno-reorder-blocks
-CFLAGS += -Wno-sign-compare
+cflags-y += -fno-reorder-blocks
+cflags-y += -Wno-sign-compare
ifneq ($(CONFIG_UNWIND_INFO),y)
-CFLAGS += -fno-asynchronous-unwind-tables
+cflags-y += -fno-asynchronous-unwind-tables
endif
ifneq ($(CONFIG_DEBUG_INFO),y)
# -fweb shrinks the kernel a bit, but the difference is very small
# it also messes up debugging, so don't use it for now.
-#CFLAGS += $(call cc-option,-fweb)
+#cflags-y += $(call cc-option,-fweb)
endif
# -funit-at-a-time shrinks the kernel .text considerably
# unfortunately it makes reading oopses harder.
-CFLAGS += $(call cc-option,-funit-at-a-time)
+cflags-y += $(call cc-option,-funit-at-a-time)
# prevent gcc from generating any FP code by mistake
-CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
+cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
+CFLAGS += $(cflags-y)
AFLAGS += -m64
head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
diff --git a/arch/x86_64/boot/video.S b/arch/x86_64/boot/video.S
index 0587477c99f2f..32327bb37aff8 100644
--- a/arch/x86_64/boot/video.S
+++ b/arch/x86_64/boot/video.S
@@ -97,6 +97,7 @@
#define PARAM_VESAPM_OFF 0x30
#define PARAM_LFB_PAGES 0x32
#define PARAM_VESA_ATTRIB 0x34
+#define PARAM_CAPABILITIES 0x36
/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
#ifdef CONFIG_VIDEO_RETAIN
@@ -233,6 +234,10 @@ mopar_gr:
movw 18(%di), %ax
movl %eax, %fs:(PARAM_LFB_SIZE)
+# store mode capabilities
+ movl 10(%di), %eax
+ movl %eax, %fs:(PARAM_CAPABILITIES)
+
# switching the DAC to 8-bit is for <= 8 bpp only
movw %fs:(PARAM_LFB_DEPTH), %ax
cmpw $8, %ax
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 566ecc97ee5a1..3c45ec22b3fea 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-git9
-# Sat Mar 25 15:18:40 2006
+# Linux kernel version: 2.6.17-rc1
+# Mon Apr 3 16:11:14 2006
#
CONFIG_X86_64=y
CONFIG_64BIT=y
@@ -9,6 +9,7 @@ CONFIG_X86=y
CONFIG_SEMAPHORE_SLEEPERS=y
CONFIG_MMU=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_X86_CMPXCHG=y
CONFIG_EARLY_PRINTK=y
@@ -55,10 +56,6 @@ CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
CONFIG_SLAB=y
# CONFIG_TINY_SHMEM is not set
CONFIG_BASE_SMALL=0
@@ -70,7 +67,6 @@ CONFIG_BASE_SMALL=0
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODULE_FORCE_UNLOAD=y
-CONFIG_OBSOLETE_MODPARM=y
# CONFIG_MODVERSIONS is not set
# CONFIG_MODULE_SRCVERSION_ALL is not set
# CONFIG_KMOD is not set
@@ -81,6 +77,7 @@ CONFIG_STOP_MACHINE=y
#
CONFIG_LBD=y
# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_LSF is not set
#
# IO Schedulers
@@ -105,6 +102,7 @@ CONFIG_X86_PC=y
CONFIG_GENERIC_CPU=y
CONFIG_X86_L1_CACHE_BYTES=128
CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_INTERNODE_CACHE_BYTES=128
CONFIG_X86_TSC=y
CONFIG_X86_GOOD_APIC=y
# CONFIG_MICROCODE is not set
@@ -116,6 +114,7 @@ CONFIG_X86_LOCAL_APIC=y
CONFIG_MTRR=y
CONFIG_SMP=y
CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
@@ -138,6 +137,7 @@ CONFIG_NEED_MULTIPLE_NODES=y
CONFIG_SPLIT_PTLOCK_CPUS=4
CONFIG_MIGRATION=y
CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
+CONFIG_OUT_OF_LINE_PFN_TO_PAGE=y
CONFIG_NR_CPUS=32
CONFIG_HOTPLUG_CPU=y
CONFIG_HPET_TIMER=y
@@ -289,6 +289,7 @@ CONFIG_IP_PNP_DHCP=y
# CONFIG_INET_AH is not set
# CONFIG_INET_ESP is not set
# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
# CONFIG_INET_TUNNEL is not set
CONFIG_INET_DIAG=y
CONFIG_INET_TCP_DIAG=y
@@ -300,6 +301,7 @@ CONFIG_IPV6=y
# CONFIG_INET6_AH is not set
# CONFIG_INET6_ESP is not set
# CONFIG_INET6_IPCOMP is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
# CONFIG_INET6_TUNNEL is not set
# CONFIG_IPV6_TUNNEL is not set
# CONFIG_NETFILTER is not set
@@ -704,7 +706,6 @@ CONFIG_S2IO=m
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set
-# CONFIG_NET_WIRELESS_RTNETLINK is not set
#
# Wan interfaces
@@ -791,7 +792,7 @@ CONFIG_HW_CONSOLE=y
#
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_ACPI is not set
+CONFIG_SERIAL_8250_PCI=y
CONFIG_SERIAL_8250_NR_UARTS=4
CONFIG_SERIAL_8250_RUNTIME_UARTS=4
# CONFIG_SERIAL_8250_EXTENDED is not set
@@ -921,6 +922,7 @@ CONFIG_HWMON=y
# Digital Video Broadcasting Devices
#
# CONFIG_DVB is not set
+# CONFIG_USB_DABUSB is not set
#
# Graphics support
@@ -932,6 +934,8 @@ CONFIG_VIDEO_SELECT=y
# Console display driver support
#
CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=256
CONFIG_DUMMY_CONSOLE=y
#
@@ -1058,15 +1062,6 @@ CONFIG_USB_HIDINPUT=y
# CONFIG_USB_MICROTEK is not set
#
-# USB Multimedia devices
-#
-# CONFIG_USB_DABUSB is not set
-
-#
-# Video4Linux support is needed for USB Multimedia device support
-#
-
-#
# USB Network Adapters
#
# CONFIG_USB_CATC is not set
@@ -1118,9 +1113,15 @@ CONFIG_USB_MON=y
# CONFIG_MMC is not set
#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
# InfiniBand support
#
# CONFIG_INFINIBAND is not set
+# CONFIG_IPATH_CORE is not set
#
# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -1128,6 +1129,11 @@ CONFIG_USB_MON=y
# CONFIG_EDAC is not set
#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
# Firmware Drivers
#
# CONFIG_EDD is not set
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 35b2faccdc6c2..5a9802676689e 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -15,6 +15,8 @@
#include <asm/vsyscall32.h>
#include <linux/linkage.h>
+#define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
+
.macro IA32_ARG_FIXUP noebp=0
movl %edi,%r8d
.if \noebp
@@ -109,8 +111,8 @@ ENTRY(ia32_sysenter_target)
CFI_REMEMBER_STATE
jnz sysenter_tracesys
sysenter_do_call:
- cmpl $(IA32_NR_syscalls),%eax
- jae ia32_badsys
+ cmpl $(IA32_NR_syscalls-1),%eax
+ ja ia32_badsys
IA32_ARG_FIXUP 1
call *ia32_sys_call_table(,%rax,8)
movq %rax,RAX-ARGOFFSET(%rsp)
@@ -210,8 +212,8 @@ ENTRY(ia32_cstar_target)
CFI_REMEMBER_STATE
jnz cstar_tracesys
cstar_do_call:
- cmpl $IA32_NR_syscalls,%eax
- jae ia32_badsys
+ cmpl $IA32_NR_syscalls-1,%eax
+ ja ia32_badsys
IA32_ARG_FIXUP 1
call *ia32_sys_call_table(,%rax,8)
movq %rax,RAX-ARGOFFSET(%rsp)
@@ -296,8 +298,8 @@ ENTRY(ia32_syscall)
testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
jnz ia32_tracesys
ia32_do_syscall:
- cmpl $(IA32_NR_syscalls),%eax
- jae ia32_badsys
+ cmpl $(IA32_NR_syscalls-1),%eax
+ ja ia32_badsys
IA32_ARG_FIXUP
call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
ia32_sysret:
@@ -685,12 +687,11 @@ ia32_sys_call_table:
.quad sys_readlinkat /* 305 */
.quad sys_fchmodat
.quad sys_faccessat
- .quad sys_ni_syscall /* pselect6 for now */
- .quad sys_ni_syscall /* ppoll for now */
+ .quad quiet_ni_syscall /* pselect6 for now */
+ .quad quiet_ni_syscall /* ppoll for now */
.quad sys_unshare /* 310 */
.quad compat_sys_set_robust_list
.quad compat_sys_get_robust_list
+ .quad sys_splice
+ .quad sys_sync_file_range
ia32_syscall_end:
- .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8
- .quad ni_syscall
- .endr
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index fffd6b0a2fab9..70b9d21ed675b 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -80,7 +80,7 @@ static int __init aperture_valid(char *name, u64 aper_base, u32 aper_size)
printk("Aperture from %s beyond 4GB. Ignoring.\n",name);
return 0;
}
- if (e820_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
+ if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
printk("Aperture from %s pointing to e820 RAM. Ignoring.\n",name);
return 0;
}
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 293cd71a266aa..62776c07cff15 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -80,7 +80,12 @@ static inline int bad_addr(unsigned long *addrp, unsigned long size)
return 0;
}
-int __init e820_mapped(unsigned long start, unsigned long end, unsigned type)
+/*
+ * This function checks if any part of the range <start,end> is mapped
+ * with type.
+ */
+int __meminit
+e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
{
int i;
for (i = 0; i < e820.nr_map; i++) {
@@ -94,6 +99,35 @@ int __init e820_mapped(unsigned long start, unsigned long end, unsigned type)
return 0;
}
+/*
+ * This function checks if the entire range <start,end> is mapped with type.
+ *
+ * Note: this function only works correct if the e820 table is sorted and
+ * not-overlapping, which is the case
+ */
+int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
+{
+ int i;
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
+ if (type && ei->type != type)
+ continue;
+ /* is the region (part) in overlap with the current region ?*/
+ if (ei->addr >= end || ei->addr + ei->size <= start)
+ continue;
+
+ /* if the region is at the beginning of <start,end> we move
+ * start to the end of the region since it's ok until there
+ */
+ if (ei->addr <= start)
+ start = ei->addr + ei->size;
+ /* if start is now at or beyond end, we're done, full coverage */
+ if (start >= end)
+ return 1; /* we're done */
+ }
+ return 0;
+}
+
/*
* Find a free area in a specific range.
*/
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 8538bfea30e6b..c946e4fe67a79 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -180,6 +180,10 @@ rff_trace:
*
* XXX if we had a free scratch register we could save the RSP into the stack frame
* and report it properly in ps. Unfortunately we haven't.
+ *
+ * When user can change the frames always force IRET. That is because
+ * it deals with uncanonical addresses better. SYSRET has trouble
+ * with them due to bugs in both AMD and Intel CPUs.
*/
ENTRY(system_call)
@@ -254,7 +258,10 @@ sysret_signal:
xorl %esi,%esi # oldset -> arg2
call ptregscall_common
1: movl $_TIF_NEED_RESCHED,%edi
- jmp sysret_check
+ /* Use IRET because user could have changed frame. This
+ works because ptregscall_common has called FIXUP_TOP_OF_STACK. */
+ cli
+ jmp int_with_check
badsys:
movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
@@ -280,7 +287,8 @@ tracesys:
call syscall_trace_leave
RESTORE_TOP_OF_STACK %rbx
RESTORE_REST
- jmp ret_from_sys_call
+ /* Use IRET because user could have changed frame */
+ jmp int_ret_from_sys_call
CFI_ENDPROC
/*
@@ -408,25 +416,9 @@ ENTRY(stub_execve)
CFI_ADJUST_CFA_OFFSET -8
CFI_REGISTER rip, r11
SAVE_REST
- movq %r11, %r15
- CFI_REGISTER rip, r15
FIXUP_TOP_OF_STACK %r11
call sys_execve
- GET_THREAD_INFO(%rcx)
- bt $TIF_IA32,threadinfo_flags(%rcx)
- CFI_REMEMBER_STATE
- jc exec_32bit
RESTORE_TOP_OF_STACK %r11
- movq %r15, %r11
- CFI_REGISTER rip, r11
- RESTORE_REST
- pushq %r11
- CFI_ADJUST_CFA_OFFSET 8
- CFI_REL_OFFSET rip, 0
- ret
-
-exec_32bit:
- CFI_RESTORE_STATE
movq %rax,RAX(%rsp)
RESTORE_REST
jmp int_ret_from_sys_call
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 10b3e348fc996..6f0790e8b6d3b 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -29,6 +29,8 @@
#define MISC_MCELOG_MINOR 227
#define NR_BANKS 6
+atomic_t mce_entry;
+
static int mce_dont_init;
/* 0: always panic, 1: panic if deadlock possible, 2: try to avoid panic,
@@ -172,10 +174,12 @@ void do_machine_check(struct pt_regs * regs, long error_code)
int i;
int panicm_found = 0;
+ atomic_inc(&mce_entry);
+
if (regs)
notify_die(DIE_NMI, "machine check", regs, error_code, 18, SIGKILL);
if (!banks)
- return;
+ goto out2;
memset(&m, 0, sizeof(struct mce));
m.cpu = safe_smp_processor_id();
@@ -266,6 +270,8 @@ void do_machine_check(struct pt_regs * regs, long error_code)
out:
/* Last thing done in the machine check exception to clear state. */
wrmsrl(MSR_IA32_MCG_STATUS, 0);
+ out2:
+ atomic_dec(&mce_entry);
}
/*
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index d9e4067faf057..4e6357fe0ec3e 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -34,6 +34,7 @@
#include <asm/proto.h>
#include <asm/kdebug.h>
#include <asm/local.h>
+#include <asm/mce.h>
/*
* lapic_nmi_owner tracks the ownership of the lapic NMI hardware:
@@ -480,6 +481,12 @@ void __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
__get_cpu_var(nmi_touch) = 0;
touched = 1;
}
+#ifdef CONFIG_X86_MCE
+ /* Could check oops_in_progress here too, but it's safer
+ not too */
+ if (atomic_read(&mce_entry) > 0)
+ touched = 1;
+#endif
if (!touched && __get_cpu_var(last_irq_sum) == sum) {
/*
* Ayiee, looks like this CPU is stuck ...
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index 03c9eeedb0f30..af035ede70cd4 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -48,9 +48,11 @@ dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
{
struct page *page;
int node;
+#ifdef CONFIG_PCI
if (dev->bus == &pci_bus_type)
node = pcibus_to_node(to_pci_dev(dev)->bus);
else
+#endif
node = numa_node_id();
page = alloc_pages_node(node, gfp, order);
return page ? page_address(page) : NULL;
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 70dd8e5c68897..1c44b53cb15bb 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -781,10 +781,16 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
}
case ARCH_GET_GS: {
unsigned long base;
+ unsigned gsindex;
if (task->thread.gsindex == GS_TLS_SEL)
base = read_32bit_tls(task, GS_TLS);
- else if (doit)
- rdmsrl(MSR_KERNEL_GS_BASE, base);
+ else if (doit) {
+ asm("movl %%gs,%0" : "=r" (gsindex));
+ if (gsindex)
+ rdmsrl(MSR_KERNEL_GS_BASE, base);
+ else
+ base = task->thread.gs;
+ }
else
base = task->thread.gs;
ret = put_user(base, (unsigned long __user *)addr);
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index d44b2c1e63a6a..da8e7903d8174 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -274,11 +274,6 @@ static int putreg(struct task_struct *child,
return -EIO;
value &= 0xffff;
break;
- case offsetof(struct user_regs_struct, rip):
- /* Check if the new RIP address is canonical */
- if (value >= TASK_SIZE_OF(child))
- return -EIO;
- break;
}
put_stack_long(child, regno - sizeof(struct pt_regs), value);
return 0;
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 0856ad444f90d..c50b06765a80d 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -353,8 +353,10 @@ static __init void parse_cmdline_early (char ** cmdline_p)
if (fullarg(from, "enable_timer_pin_1"))
disable_timer_pin_1 = -1;
- if (fullarg(from, "nolapic") || fullarg(from, "disableapic"))
+ if (fullarg(from, "nolapic") || fullarg(from, "disableapic")) {
+ clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
disable_apic = 1;
+ }
if (fullarg(from, "noapic"))
skip_ioapic_setup = 1;
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index ef8bc46dc1402..7392570f975dc 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -726,7 +726,7 @@ static __init int late_hpet_init(void)
unsigned int ntimer;
if (!vxtime.hpet_address)
- return -1;
+ return 0;
memset(&hd, 0, sizeof (hd));
@@ -917,6 +917,8 @@ void __init time_init(void)
vxtime.hpet_address = 0;
if (hpet_use_timer) {
+ /* set tick_nsec to use the proper rate for HPET */
+ tick_nsec = TICK_NSEC_HPET;
cpu_khz = hpet_calibrate_tsc();
timename = "HPET";
#ifdef CONFIG_X86_PM_TIMER
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 39ff0708f803a..b81f473c4a19b 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -65,7 +65,7 @@ SECTIONS
.data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
*(.data.cacheline_aligned)
}
- . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
+ . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
.data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
*(.data.read_mostly)
}
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index d78f46056bda7..1def21c9f7cd9 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -112,7 +112,6 @@ EXPORT_SYMBOL_GPL(unset_nmi_callback);
#undef memcpy
#undef memset
#undef memmove
-#undef strlen
extern void * memset(void *,int,__kernel_size_t);
extern size_t strlen(const char *);
@@ -121,8 +120,6 @@ extern void * memcpy(void *,const void *,__kernel_size_t);
extern void * __memcpy(void *,const void *,__kernel_size_t);
EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(__memcpy);
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index e5f7f1c344624..4ba34e95d835a 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -305,7 +305,7 @@ static void __meminit phys_pud_init(pud_t *pud, unsigned long address, unsigned
if (paddr >= end)
break;
- if (!after_bootmem && !e820_mapped(paddr, paddr+PUD_SIZE, 0)) {
+ if (!after_bootmem && !e820_any_mapped(paddr, paddr+PUD_SIZE, 0)) {
set_pud(pud, __pud(0));
continue;
}
@@ -507,9 +507,8 @@ void __init clear_kernel_mapping(unsigned long address, unsigned long size)
/*
* Memory hotplug specific functions
- * These are only for non-NUMA machines right now.
*/
-#ifdef CONFIG_MEMORY_HOTPLUG
+#if defined(CONFIG_ACPI_HOTPLUG_MEMORY) || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)
void online_page(struct page *page)
{
@@ -520,6 +519,38 @@ void online_page(struct page *page)
num_physpages++;
}
+#ifndef CONFIG_MEMORY_HOTPLUG
+/*
+ * Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
+ * just online the pages.
+ */
+int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
+{
+ int err = -EIO;
+ unsigned long pfn;
+ unsigned long total = 0, mem = 0;
+ for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) {
+ if (pfn_valid(pfn)) {
+ online_page(pfn_to_page(pfn));
+ err = 0;
+ mem++;
+ }
+ total++;
+ }
+ if (!err) {
+ z->spanned_pages += total;
+ z->present_pages += mem;
+ z->zone_pgdat->node_spanned_pages += total;
+ z->zone_pgdat->node_present_pages += mem;
+ }
+ return err;
+}
+#endif
+
+/*
+ * Memory is added always to NORMAL zone. This means you will never get
+ * additional DMA/DMA32 memory.
+ */
int add_memory(u64 start, u64 size)
{
struct pglist_data *pgdat = NODE_DATA(0);
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 4be82d6e2b481..cc02573a32717 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -100,11 +100,30 @@ int early_pfn_to_nid(unsigned long pfn)
}
#endif
+static void * __init
+early_node_mem(int nodeid, unsigned long start, unsigned long end,
+ unsigned long size)
+{
+ unsigned long mem = find_e820_area(start, end, size);
+ void *ptr;
+ if (mem != -1L)
+ return __va(mem);
+ ptr = __alloc_bootmem_nopanic(size,
+ SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS));
+ if (ptr == 0) {
+ printk(KERN_ERR "Cannot find %lu bytes in node %d\n",
+ size, nodeid);
+ return NULL;
+ }
+ return ptr;
+}
+
/* Initialize bootmem allocator for a node */
void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
{
unsigned long start_pfn, end_pfn, bootmap_pages, bootmap_size, bootmap_start;
unsigned long nodedata_phys;
+ void *bootmap;
const int pgdat_size = round_up(sizeof(pg_data_t), PAGE_SIZE);
start = round_up(start, ZONE_ALIGN);
@@ -114,13 +133,11 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
start_pfn = start >> PAGE_SHIFT;
end_pfn = end >> PAGE_SHIFT;
- nodedata_phys = find_e820_area(start, end, pgdat_size);
- if (nodedata_phys == -1L)
- panic("Cannot find memory pgdat in node %d\n", nodeid);
-
- Dprintk("nodedata_phys %lx\n", nodedata_phys);
+ node_data[nodeid] = early_node_mem(nodeid, start, end, pgdat_size);
+ if (node_data[nodeid] == NULL)
+ return;
+ nodedata_phys = __pa(node_data[nodeid]);
- node_data[nodeid] = phys_to_virt(nodedata_phys);
memset(NODE_DATA(nodeid), 0, sizeof(pg_data_t));
NODE_DATA(nodeid)->bdata = &plat_node_bdata[nodeid];
NODE_DATA(nodeid)->node_start_pfn = start_pfn;
@@ -129,9 +146,15 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
/* Find a place for the bootmem map */
bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
bootmap_start = round_up(nodedata_phys + pgdat_size, PAGE_SIZE);
- bootmap_start = find_e820_area(bootmap_start, end, bootmap_pages<<PAGE_SHIFT);
- if (bootmap_start == -1L)
- panic("Not enough continuous space for bootmap on node %d", nodeid);
+ bootmap = early_node_mem(nodeid, bootmap_start, end,
+ bootmap_pages<<PAGE_SHIFT);
+ if (bootmap == NULL) {
+ if (nodedata_phys < start || nodedata_phys >= end)
+ free_bootmem((unsigned long)node_data[nodeid],pgdat_size);
+ node_data[nodeid] = NULL;
+ return;
+ }
+ bootmap_start = __pa(bootmap);
Dprintk("bootmap start %lu pages %lu\n", bootmap_start, bootmap_pages);
bootmap_size = init_bootmem_node(NODE_DATA(nodeid),
@@ -142,6 +165,9 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
reserve_bootmem_node(NODE_DATA(nodeid), nodedata_phys, pgdat_size);
reserve_bootmem_node(NODE_DATA(nodeid), bootmap_start, bootmap_pages<<PAGE_SHIFT);
+#ifdef CONFIG_ACPI_NUMA
+ srat_reserve_add_area(nodeid);
+#endif
node_set_online(nodeid);
}
@@ -335,6 +361,8 @@ __init int numa_setup(char *opt)
#ifdef CONFIG_ACPI_NUMA
if (!strncmp(opt,"noacpi",6))
acpi_numa = -1;
+ if (!strncmp(opt,"hotadd=", 7))
+ hotadd_percent = simple_strtoul(opt+7, NULL, 10);
#endif
return 1;
}
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 2eb879590dc42..15ae9fcd65a70 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -15,15 +15,26 @@
#include <linux/bitmap.h>
#include <linux/module.h>
#include <linux/topology.h>
+#include <linux/bootmem.h>
+#include <linux/mm.h>
#include <asm/proto.h>
#include <asm/numa.h>
#include <asm/e820.h>
+#if (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \
+ defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) \
+ && !defined(CONFIG_MEMORY_HOTPLUG)
+#define RESERVE_HOTADD 1
+#endif
+
static struct acpi_table_slit *acpi_slit;
static nodemask_t nodes_parsed __initdata;
static nodemask_t nodes_found __initdata;
static struct bootnode nodes[MAX_NUMNODES] __initdata;
+static struct bootnode nodes_add[MAX_NUMNODES] __initdata;
+static int found_add_area __initdata;
+int hotadd_percent __initdata = 10;
static u8 pxm2node[256] = { [0 ... 255] = 0xff };
/* Too small nodes confuse the VM badly. Usually they result
@@ -71,6 +82,10 @@ static __init int conflicting_nodes(unsigned long start, unsigned long end)
static __init void cutoff_node(int i, unsigned long start, unsigned long end)
{
struct bootnode *nd = &nodes[i];
+
+ if (found_add_area)
+ return;
+
if (nd->start < start) {
nd->start = start;
if (nd->end < nd->start)
@@ -90,6 +105,8 @@ static __init void bad_srat(void)
acpi_numa = -1;
for (i = 0; i < MAX_LOCAL_APIC; i++)
apicid_to_node[i] = NUMA_NO_NODE;
+ for (i = 0; i < MAX_NUMNODES; i++)
+ nodes_add[i].start = nodes[i].end = 0;
}
static __init inline int srat_disabled(void)
@@ -155,11 +172,114 @@ acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
pxm, pa->apic_id, node);
}
+#ifdef RESERVE_HOTADD
+/*
+ * Protect against too large hotadd areas that would fill up memory.
+ */
+static int hotadd_enough_memory(struct bootnode *nd)
+{
+ static unsigned long allocated;
+ static unsigned long last_area_end;
+ unsigned long pages = (nd->end - nd->start) >> PAGE_SHIFT;
+ long mem = pages * sizeof(struct page);
+ unsigned long addr;
+ unsigned long allowed;
+ unsigned long oldpages = pages;
+
+ if (mem < 0)
+ return 0;
+ allowed = (end_pfn - e820_hole_size(0, end_pfn)) * PAGE_SIZE;
+ allowed = (allowed / 100) * hotadd_percent;
+ if (allocated + mem > allowed) {
+ /* Give them at least part of their hotadd memory upto hotadd_percent
+ It would be better to spread the limit out
+ over multiple hotplug areas, but that is too complicated
+ right now */
+ if (allocated >= allowed)
+ return 0;
+ pages = (allowed - allocated + mem) / sizeof(struct page);
+ mem = pages * sizeof(struct page);
+ nd->end = nd->start + pages*PAGE_SIZE;
+ }
+ /* Not completely fool proof, but a good sanity check */
+ addr = find_e820_area(last_area_end, end_pfn<<PAGE_SHIFT, mem);
+ if (addr == -1UL)
+ return 0;
+ if (pages != oldpages)
+ printk(KERN_NOTICE "SRAT: Hotadd area limited to %lu bytes\n",
+ pages << PAGE_SHIFT);
+ last_area_end = addr + mem;
+ allocated += mem;
+ return 1;
+}
+
+/*
+ * It is fine to add this area to the nodes data it will be used later
+ * This code supports one contigious hot add area per node.
+ */
+static int reserve_hotadd(int node, unsigned long start, unsigned long end)
+{
+ unsigned long s_pfn = start >> PAGE_SHIFT;
+ unsigned long e_pfn = end >> PAGE_SHIFT;
+ int changed = 0;
+ struct bootnode *nd = &nodes_add[node];
+
+ /* I had some trouble with strange memory hotadd regions breaking
+ the boot. Be very strict here and reject anything unexpected.
+ If you want working memory hotadd write correct SRATs.
+
+ The node size check is a basic sanity check to guard against
+ mistakes */
+ if ((signed long)(end - start) < NODE_MIN_SIZE) {
+ printk(KERN_ERR "SRAT: Hotplug area too small\n");
+ return -1;
+ }
+
+ /* This check might be a bit too strict, but I'm keeping it for now. */
+ if (e820_hole_size(s_pfn, e_pfn) != e_pfn - s_pfn) {
+ printk(KERN_ERR "SRAT: Hotplug area has existing memory\n");
+ return -1;
+ }
+
+ if (!hotadd_enough_memory(&nodes_add[node])) {
+ printk(KERN_ERR "SRAT: Hotplug area too large\n");
+ return -1;
+ }
+
+ /* Looks good */
+
+ found_add_area = 1;
+ if (nd->start == nd->end) {
+ nd->start = start;
+ nd->end = end;
+ changed = 1;
+ } else {
+ if (nd->start == end) {
+ nd->start = start;
+ changed = 1;
+ }
+ if (nd->end == start) {
+ nd->end = end;
+ changed = 1;
+ }
+ if (!changed)
+ printk(KERN_ERR "SRAT: Hotplug zone not continuous. Partly ignored\n");
+ }
+
+ if ((nd->end >> PAGE_SHIFT) > end_pfn)
+ end_pfn = nd->end >> PAGE_SHIFT;
+
+ if (changed)
+ printk(KERN_INFO "SRAT: hot plug zone found %Lx - %Lx\n", nd->start, nd->end);
+ return 0;
+}
+#endif
+
/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
void __init
acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
{
- struct bootnode *nd;
+ struct bootnode *nd, oldnode;
unsigned long start, end;
int node, pxm;
int i;
@@ -172,6 +292,8 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
}
if (ma->flags.enabled == 0)
return;
+ if (ma->flags.hot_pluggable && hotadd_percent == 0)
+ return;
start = ma->base_addr_lo | ((u64)ma->base_addr_hi << 32);
end = start + (ma->length_lo | ((u64)ma->length_hi << 32));
pxm = ma->proximity_domain;
@@ -181,10 +303,6 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
bad_srat();
return;
}
- /* It is fine to add this area to the nodes data it will be used later*/
- if (ma->flags.hot_pluggable == 1)
- printk(KERN_INFO "SRAT: hot plug zone found %lx - %lx \n",
- start, end);
i = conflicting_nodes(start, end);
if (i == node) {
printk(KERN_WARNING
@@ -199,6 +317,7 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
return;
}
nd = &nodes[node];
+ oldnode = *nd;
if (!node_test_and_set(node, nodes_parsed)) {
nd->start = start;
nd->end = end;
@@ -208,8 +327,19 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
if (nd->end < end)
nd->end = end;
}
+
printk(KERN_INFO "SRAT: Node %u PXM %u %Lx-%Lx\n", node, pxm,
nd->start, nd->end);
+
+#ifdef RESERVE_HOTADD
+ if (ma->flags.hot_pluggable && reserve_hotadd(node, start, end) < 0) {
+ /* Ignore hotadd region. Undo damage */
+ printk(KERN_NOTICE "SRAT: Hotplug region ignored\n");
+ *nd = oldnode;
+ if ((nd->start | nd->end) == 0)
+ node_clear(node, nodes_parsed);
+ }
+#endif
}
/* Sanity check to catch more bad SRATs (they are amazingly common).
@@ -225,6 +355,9 @@ static int nodes_cover_memory(void)
unsigned long e = nodes[i].end >> PAGE_SHIFT;
pxmram += e - s;
pxmram -= e820_hole_size(s, e);
+ pxmram -= nodes_add[i].end - nodes_add[i].start;
+ if ((long)pxmram < 0)
+ pxmram = 0;
}
e820ram = end_pfn - e820_hole_size(0, end_pfn);
@@ -258,7 +391,7 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
/* First clean up the node list */
for (i = 0; i < MAX_NUMNODES; i++) {
- cutoff_node(i, start, end);
+ cutoff_node(i, start, end);
if ((nodes[i].end - nodes[i].start) < NODE_MIN_SIZE)
unparse_node(i);
}
@@ -282,6 +415,12 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
/* Finally register nodes */
for_each_node_mask(i, nodes_parsed)
setup_node_bootmem(i, nodes[i].start, nodes[i].end);
+ /* Try again in case setup_node_bootmem missed one due
+ to missing bootmem */
+ for_each_node_mask(i, nodes_parsed)
+ if (!node_online(i))
+ setup_node_bootmem(i, nodes[i].start, nodes[i].end);
+
for (i = 0; i < NR_CPUS; i++) {
if (cpu_to_node[i] == NUMA_NO_NODE)
continue;
@@ -303,6 +442,25 @@ static int node_to_pxm(int n)
return 0;
}
+void __init srat_reserve_add_area(int nodeid)
+{
+ if (found_add_area && nodes_add[nodeid].end) {
+ u64 total_mb;
+
+ printk(KERN_INFO "SRAT: Reserving hot-add memory space "
+ "for node %d at %Lx-%Lx\n",
+ nodeid, nodes_add[nodeid].start, nodes_add[nodeid].end);
+ total_mb = (nodes_add[nodeid].end - nodes_add[nodeid].start)
+ >> PAGE_SHIFT;
+ total_mb *= sizeof(struct page);
+ total_mb >>= 20;
+ printk(KERN_INFO "SRAT: This will cost you %Lu MB of "
+ "pre-allocated memory.\n", (unsigned long long)total_mb);
+ reserve_bootmem_node(NODE_DATA(nodeid), nodes_add[nodeid].start,
+ nodes_add[nodeid].end - nodes_add[nodeid].start);
+ }
+}
+
int __node_distance(int a, int b)
{
int index;
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index e616500207e4b..a2060e4d5de66 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -9,11 +9,16 @@
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/bitmap.h>
+#include <asm/e820.h>
+
#include "pci.h"
#define MMCONFIG_APER_SIZE (256*1024*1024)
+/* Verify the first 16 busses. We assume that systems with more busses
+ get MCFG right. */
+#define MAX_CHECK_BUS 16
-static DECLARE_BITMAP(fallback_slots, 32);
+static DECLARE_BITMAP(fallback_slots, 32*MAX_CHECK_BUS);
/* Static virtual mapping of the MMCONFIG aperture */
struct mmcfg_virt {
@@ -55,7 +60,8 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus)
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
{
char __iomem *addr;
- if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), fallback_slots))
+ if (seg == 0 && bus < MAX_CHECK_BUS &&
+ test_bit(32*bus + PCI_SLOT(devfn), fallback_slots))
return NULL;
addr = get_virt(seg, bus);
if (!addr)
@@ -69,8 +75,10 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
char __iomem *addr;
/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
- if (unlikely(!value || (bus > 255) || (devfn > 255) || (reg > 4095)))
+ if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) {
+ *value = -1;
return -EINVAL;
+ }
addr = pci_dev_base(seg, bus, devfn);
if (!addr)
@@ -129,21 +137,26 @@ static struct pci_raw_ops pci_mmcfg = {
Normally this can be expressed in the MCFG by not listing them
and assigning suitable _SEGs, but this isn't implemented in some BIOS.
Instead try to discover all devices on bus 0 that are unreachable using MM
- and fallback for them.
- We only do this for bus 0/seg 0 */
+ and fallback for them. */
static __init void unreachable_devices(void)
{
- int i;
- for (i = 0; i < 32; i++) {
- u32 val1;
- char __iomem *addr;
-
- pci_conf1_read(0, 0, PCI_DEVFN(i,0), 0, 4, &val1);
- if (val1 == 0xffffffff)
- continue;
- addr = pci_dev_base(0, 0, PCI_DEVFN(i, 0));
- if (addr == NULL|| readl(addr) != val1) {
- set_bit(i, fallback_slots);
+ int i, k;
+ /* Use the max bus number from ACPI here? */
+ for (k = 0; k < MAX_CHECK_BUS; k++) {
+ for (i = 0; i < 32; i++) {
+ u32 val1;
+ char __iomem *addr;
+
+ pci_conf1_read(0, k, PCI_DEVFN(i,0), 0, 4, &val1);
+ if (val1 == 0xffffffff)
+ continue;
+ addr = pci_dev_base(0, k, PCI_DEVFN(i, 0));
+ if (addr == NULL|| readl(addr) != val1) {
+ set_bit(i + 32*k, fallback_slots);
+ printk(KERN_NOTICE
+ "PCI: No mmconfig possible on device %x:%x\n",
+ k, i);
+ }
}
}
}
@@ -161,6 +174,14 @@ void __init pci_mmcfg_init(void)
(pci_mmcfg_config[0].base_address == 0))
return;
+ if (!e820_all_mapped(pci_mmcfg_config[0].base_address,
+ pci_mmcfg_config[0].base_address + MMCONFIG_APER_SIZE,
+ E820_RESERVED)) {
+ printk(KERN_ERR "PCI: BIOS Bug: MCFG area is not E820-reserved\n");
+ printk(KERN_ERR "PCI: Not using MMCONFIG.\n");
+ return;
+ }
+
/* RED-PEN i386 doesn't do _nocache right now */
pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
if (pci_mmcfg_virt == NULL) {
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 152b9370789b1..a15b6e3e72c86 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -48,7 +48,6 @@ EXPORT_SYMBOL(memchr);
EXPORT_SYMBOL(strcat);
EXPORT_SYMBOL(strchr);
EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strpbrk);
EXPORT_SYMBOL(strncat);
EXPORT_SYMBOL(strnlen);
EXPORT_SYMBOL(strrchr);
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 5cb96300eb0f9..c24652d31bf9b 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -329,7 +329,7 @@ config ACPI_CONTAINER
config ACPI_HOTPLUG_MEMORY
tristate "Memory Hotplug"
depends on ACPI
- depends on MEMORY_HOTPLUG
+ depends on MEMORY_HOTPLUG || X86_64
default n
help
This driver adds supports for ACPI Memory Hotplug. This driver
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 16c513aa4d487..c80c3aeed004a 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -106,7 +106,7 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
other_node = 0;
for (i = 0; i < MAX_NR_ZONES; i++) {
struct zone *z = &pg->node_zones[i];
- for (cpu = 0; cpu < NR_CPUS; cpu++) {
+ for_each_online_cpu(cpu) {
struct per_cpu_pageset *ps = zone_pcp(z,cpu);
numa_hit += ps->numa_hit;
numa_miss += ps->numa_miss;
diff --git a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c
index ce4a1ce59d6a2..ec004897b6349 100644
--- a/drivers/cdrom/aztcd.c
+++ b/drivers/cdrom/aztcd.c
@@ -1763,7 +1763,7 @@ static int __init aztcd_init(void)
release_region(azt_port, 4);
}
}
- if ((azt_port_auto[i] == 0) || (i == 16)) {
+ if ((i == 16) || (azt_port_auto[i] == 0)) {
printk(KERN_INFO "aztcd: no AZTECH CD-ROM drive found\n");
return -EIO;
}
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 889cad07774e8..402296670d3a5 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -805,10 +805,6 @@ config S3C2410_RTC
Samsung S3C2410. This can provide periodic interrupt rates
from 1Hz to 64Hz for user programs, and wakeup from Alarm.
-config RTC_VR41XX
- tristate "NEC VR4100 series Real Time Clock Support"
- depends on CPU_VR41XX
-
config COBALT_LCD
bool "Support for Cobalt LCD"
depends on MIPS_COBALT
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index a73cb4956928f..f5b01c6d498e1 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -67,7 +67,6 @@ obj-$(CONFIG_SGI_DS1286) += ds1286.o
obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
obj-$(CONFIG_DS1302) += ds1302.o
obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o
-obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o
ifeq ($(CONFIG_GENERIC_NVRAM),y)
obj-$(CONFIG_NVRAM) += generic_nvram.o
else
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index 927a5bbe112c9..a370e7a0bad5a 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -142,7 +142,7 @@ static int ac_register_board(unsigned long physloc, void __iomem *loc,
if (!boardno)
boardno = readb(loc + NUMCARD_OWNER_TO_PC);
- if (!boardno && boardno > MAX_BOARD) {
+ if (!boardno || boardno > MAX_BOARD) {
printk(KERN_WARNING "Board #%d (at 0x%lx) is out of range (1 <= x <= %d).\n",
boardno, physloc, MAX_BOARD);
return 0;
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index a229915ce1b26..87dcaa237f075 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -490,7 +490,7 @@ for (i = 0; i < 10; i++) \
release_region(dtlk_portlist[i], DTLK_IO_EXTENT);
}
- printk(KERN_INFO "\nDoubleTalk PC - not found\n");
+ printk(KERN_INFO "DoubleTalk PC - not found\n");
return -ENODEV;
}
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 0ded046d5aa80..9f2f8fdec69a4 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -941,6 +941,7 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
list_del(&msg->link);
list_add_tail(&msg->link, &msgs);
}
+ intf->waiting_events_count = 0;
}
/* Hold the events lock while doing this to preserve order. */
@@ -2916,6 +2917,7 @@ 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 {
/* There's too many things in the queue, discard this
message. */
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 86be04b241e1b..58f3512c52e16 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1584,7 +1584,6 @@ u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dpo
return twothirdsMD4Transform(daddr, hash);
}
-EXPORT_SYMBOL(secure_ipv6_port_ephemeral);
#endif
#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 2546637a55c03..f58ad7f682673 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -327,7 +327,7 @@ static ssize_t store_received_ref_clk3a(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(received_ref_clk3a, S_IWUGO, NULL,
+static DEVICE_ATTR(received_ref_clk3a, (S_IWUSR|S_IWGRP), NULL,
store_received_ref_clk3a);
@@ -349,7 +349,7 @@ static ssize_t store_received_ref_clk3b(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(received_ref_clk3b, S_IWUGO, NULL,
+static DEVICE_ATTR(received_ref_clk3b, (S_IWUSR|S_IWGRP), NULL,
store_received_ref_clk3b);
@@ -371,7 +371,7 @@ static ssize_t store_enable_clk3b_output(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(enable_clk3b_output, S_IWUGO, NULL,
+static DEVICE_ATTR(enable_clk3b_output, (S_IWUSR|S_IWGRP), NULL,
store_enable_clk3b_output);
static ssize_t store_enable_clk3a_output(struct device *d,
@@ -392,7 +392,7 @@ static ssize_t store_enable_clk3a_output(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(enable_clk3a_output, S_IWUGO, NULL,
+static DEVICE_ATTR(enable_clk3a_output, (S_IWUSR|S_IWGRP), NULL,
store_enable_clk3a_output);
static ssize_t store_enable_clkb1_output(struct device *d,
@@ -413,7 +413,7 @@ static ssize_t store_enable_clkb1_output(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(enable_clkb1_output, S_IWUGO, NULL,
+static DEVICE_ATTR(enable_clkb1_output, (S_IWUSR|S_IWGRP), NULL,
store_enable_clkb1_output);
@@ -435,7 +435,7 @@ static ssize_t store_enable_clka1_output(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(enable_clka1_output, S_IWUGO, NULL,
+static DEVICE_ATTR(enable_clka1_output, (S_IWUSR|S_IWGRP), NULL,
store_enable_clka1_output);
static ssize_t store_enable_clkb0_output(struct device *d,
@@ -456,7 +456,7 @@ static ssize_t store_enable_clkb0_output(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(enable_clkb0_output, S_IWUGO, NULL,
+static DEVICE_ATTR(enable_clkb0_output, (S_IWUSR|S_IWGRP), NULL,
store_enable_clkb0_output);
static ssize_t store_enable_clka0_output(struct device *d,
@@ -477,7 +477,7 @@ static ssize_t store_enable_clka0_output(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(enable_clka0_output, S_IWUGO, NULL,
+static DEVICE_ATTR(enable_clka0_output, (S_IWUSR|S_IWGRP), NULL,
store_enable_clka0_output);
static ssize_t store_select_amcb2_transmit_clock(struct device *d,
@@ -519,7 +519,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(select_amcb2_transmit_clock, S_IWUGO, NULL,
+static DEVICE_ATTR(select_amcb2_transmit_clock, (S_IWUSR|S_IWGRP), NULL,
store_select_amcb2_transmit_clock);
static ssize_t store_select_amcb1_transmit_clock(struct device *d,
@@ -560,7 +560,7 @@ static ssize_t store_select_amcb1_transmit_clock(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(select_amcb1_transmit_clock, S_IWUGO, NULL,
+static DEVICE_ATTR(select_amcb1_transmit_clock, (S_IWUSR|S_IWGRP), NULL,
store_select_amcb1_transmit_clock);
static ssize_t store_select_redundant_clock(struct device *d,
@@ -581,7 +581,7 @@ static ssize_t store_select_redundant_clock(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(select_redundant_clock, S_IWUGO, NULL,
+static DEVICE_ATTR(select_redundant_clock, (S_IWUSR|S_IWGRP), NULL,
store_select_redundant_clock);
static ssize_t store_select_ref_frequency(struct device *d,
@@ -602,7 +602,7 @@ static ssize_t store_select_ref_frequency(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(select_ref_frequency, S_IWUGO, NULL,
+static DEVICE_ATTR(select_ref_frequency, (S_IWUSR|S_IWGRP), NULL,
store_select_ref_frequency);
static ssize_t store_filter_select(struct device *d,
@@ -623,7 +623,7 @@ static ssize_t store_filter_select(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(filter_select, S_IWUGO, NULL, store_filter_select);
+static DEVICE_ATTR(filter_select, (S_IWUSR|S_IWGRP), NULL, store_filter_select);
static ssize_t store_hardware_switching_mode(struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
@@ -643,7 +643,7 @@ static ssize_t store_hardware_switching_mode(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(hardware_switching_mode, S_IWUGO, NULL,
+static DEVICE_ATTR(hardware_switching_mode, (S_IWUSR|S_IWGRP), NULL,
store_hardware_switching_mode);
static ssize_t store_hardware_switching(struct device *d,
@@ -664,7 +664,7 @@ static ssize_t store_hardware_switching(struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(hardware_switching, S_IWUGO, NULL,
+static DEVICE_ATTR(hardware_switching, (S_IWUSR|S_IWGRP), NULL,
store_hardware_switching);
static ssize_t store_refalign (struct device *d,
@@ -684,7 +684,7 @@ static ssize_t store_refalign (struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(refalign, S_IWUGO, NULL, store_refalign);
+static DEVICE_ATTR(refalign, (S_IWUSR|S_IWGRP), NULL, store_refalign);
static ssize_t store_mode_select (struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
@@ -704,7 +704,7 @@ static ssize_t store_mode_select (struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(mode_select, S_IWUGO, NULL, store_mode_select);
+static DEVICE_ATTR(mode_select, (S_IWUSR|S_IWGRP), NULL, store_mode_select);
static ssize_t store_reset (struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
@@ -724,7 +724,7 @@ static ssize_t store_reset (struct device *d,
return strnlen(buf, count);
}
-static DEVICE_ATTR(reset, S_IWUGO, NULL, store_reset);
+static DEVICE_ATTR(reset, (S_IWUSR|S_IWGRP), NULL, store_reset);
static struct attribute *tlclk_sysfs_entries[] = {
&dev_attr_current_ref.attr,
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 98b126c2ded86..f70a47eadb52a 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -351,10 +351,10 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
spin_unlock_irqrestore(&tty->buf.lock, flags);
return size;
}
-
EXPORT_SYMBOL_GPL(tty_buffer_request_room);
-int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)
+int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
+ size_t size)
{
int copied = 0;
do {
@@ -368,17 +368,16 @@ int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, s
tb->used += space;
copied += space;
chars += space;
-/* printk("Flip insert %d.\n", space); */
}
/* There is a small chance that we need to split the data over
several buffers. If this is the case we must loop */
while (unlikely(size > copied));
return copied;
}
-
EXPORT_SYMBOL(tty_insert_flip_string);
-int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size)
+int tty_insert_flip_string_flags(struct tty_struct *tty,
+ const unsigned char *chars, const char *flags, size_t size)
{
int copied = 0;
do {
@@ -399,9 +398,20 @@ int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *ch
while (unlikely(size > copied));
return copied;
}
-
EXPORT_SYMBOL_GPL(tty_insert_flip_string_flags);
+void tty_schedule_flip(struct tty_struct *tty)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&tty->buf.lock, flags);
+ if (tty->buf.tail != NULL) {
+ tty->buf.tail->active = 0;
+ tty->buf.tail->commit = tty->buf.tail->used;
+ }
+ spin_unlock_irqrestore(&tty->buf.lock, flags);
+ schedule_delayed_work(&tty->buf.work, 1);
+}
+EXPORT_SYMBOL(tty_schedule_flip);
/*
* Prepare a block of space in the buffer for data. Returns the length
@@ -1730,7 +1740,7 @@ static void release_dev(struct file * filp)
{
struct tty_struct *tty, *o_tty;
int pty_master, tty_closing, o_tty_closing, do_sleep;
- int devpts_master, devpts;
+ int devpts;
int idx;
char buf[64];
unsigned long flags;
@@ -1747,7 +1757,6 @@ static void release_dev(struct file * filp)
pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER);
devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;
- devpts_master = pty_master && devpts;
o_tty = tty->link;
#ifdef TTY_PARANOIA_CHECK
@@ -2185,6 +2194,7 @@ static int ptmx_open(struct inode * inode, struct file * filp)
return 0;
out1:
release_dev(filp);
+ return retval;
out:
down(&allocated_ptys_lock);
idr_remove(&allocated_ptys, index);
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index 23a9e1ea8e321..1659f6c414581 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -509,12 +509,22 @@ static int hdaps_dmi_match_invert(struct dmi_system_id *id)
} \
}
+#define HDAPS_DMI_MATCH_LENOVO(model) { \
+ .ident = "Lenovo " model, \
+ .callback = hdaps_dmi_match_invert, \
+ .matches = { \
+ DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), \
+ DMI_MATCH(DMI_PRODUCT_VERSION, model) \
+ } \
+}
+
static int __init hdaps_init(void)
{
int ret;
/* Note that DMI_MATCH(...,"ThinkPad T42") will match "ThinkPad T42p" */
struct dmi_system_id hdaps_whitelist[] = {
+ HDAPS_DMI_MATCH_NORMAL("ThinkPad H"),
HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"),
@@ -524,15 +534,17 @@ static int __init hdaps_init(void)
HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad T42"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"),
+ HDAPS_DMI_MATCH_LENOVO("ThinkPad T60p"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad X41 Tablet"),
HDAPS_DMI_MATCH_NORMAL("ThinkPad X41"),
+ HDAPS_DMI_MATCH_LENOVO("ThinkPad X60"),
{ .ident = NULL }
};
if (!dmi_check_system(hdaps_whitelist)) {
printk(KERN_WARNING "hdaps: supported laptop not found!\n");
- ret = -ENXIO;
+ ret = -ENODEV;
goto out;
}
diff --git a/drivers/isdn/gigaset/Kconfig b/drivers/isdn/gigaset/Kconfig
index 53c4fb62ed855..5b203fe21dcd5 100644
--- a/drivers/isdn/gigaset/Kconfig
+++ b/drivers/isdn/gigaset/Kconfig
@@ -3,8 +3,8 @@ menu "Siemens Gigaset"
config ISDN_DRV_GIGASET
tristate "Siemens Gigaset support (isdn)"
- depends on ISDN_I4L && m
-# depends on ISDN_I4L && MODULES
+ depends on ISDN_I4L
+ select CRC_CCITT
help
Say m here if you have a Gigaset or Sinus isdn device.
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c
index 171f8b703d61d..ce3cd77094b33 100644
--- a/drivers/isdn/gigaset/asyncdata.c
+++ b/drivers/isdn/gigaset/asyncdata.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2005 by Tilman Schmidt <tilman@imap.cc>,
* Hansjoerg Lipp <hjlipp@web.de>,
- * Stefan Eilers <Eilers.Stefan@epost.de>.
+ * Stefan Eilers.
*
* =====================================================================
* This program is free software; you can redistribute it and/or
@@ -11,10 +11,6 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: asyncdata.c,v 1.2.2.7 2005/11/13 23:05:18 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
@@ -45,7 +41,7 @@ static inline int muststuff(unsigned char c)
* number of processed bytes
*/
static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
- struct inbuf_t *inbuf)
+ struct inbuf_t *inbuf)
{
struct cardstate *cs = inbuf->cs;
unsigned cbytes = cs->cbytes;
@@ -55,10 +51,11 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
for (;;) {
cs->respdata[cbytes] = c;
if (c == 10 || c == 13) {
- dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
- __func__, cbytes);
+ gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
+ __func__, cbytes);
cs->cbytes = cbytes;
- gigaset_handle_modem_response(cs); /* can change cs->dle */
+ gigaset_handle_modem_response(cs); /* can change
+ cs->dle */
cbytes = 0;
if (cs->dle &&
@@ -71,7 +68,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
if (cbytes < MAX_RESP_SIZE - 1)
cbytes++;
else
- warn("response too large");
+ dev_warn(cs->dev, "response too large\n");
}
if (!numbytes)
@@ -96,11 +93,12 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
* number of processed bytes
*/
static inline int lock_loop(unsigned char *src, int numbytes,
- struct inbuf_t *inbuf)
+ struct inbuf_t *inbuf)
{
struct cardstate *cs = inbuf->cs;
- gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", numbytes, src, 0);
+ gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
+ numbytes, src);
gigaset_if_receive(cs, src, numbytes);
return numbytes;
@@ -115,24 +113,18 @@ static inline int lock_loop(unsigned char *src, int numbytes,
* numbytes (all bytes processed) on error --FIXME
*/
static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
- struct inbuf_t *inbuf)
+ struct inbuf_t *inbuf)
{
struct cardstate *cs = inbuf->cs;
struct bc_state *bcs = inbuf->bcs;
- int inputstate;
- __u16 fcs;
- struct sk_buff *skb;
+ int inputstate = bcs->inputstate;
+ __u16 fcs = bcs->fcs;
+ struct sk_buff *skb = bcs->skb;
unsigned char error;
struct sk_buff *compskb;
int startbytes = numbytes;
int l;
- IFNULLRETVAL(bcs, numbytes);
- inputstate = bcs->inputstate;
- fcs = bcs->fcs;
- skb = bcs->skb;
- IFNULLRETVAL(skb, numbytes);
-
if (unlikely(inputstate & INS_byte_stuff)) {
inputstate &= ~INS_byte_stuff;
goto byte_stuff;
@@ -156,39 +148,37 @@ byte_stuff:
c ^= PPP_TRANS;
#ifdef CONFIG_GIGASET_DEBUG
if (unlikely(!muststuff(c)))
- dbg(DEBUG_HDLC,
- "byte stuffed: 0x%02x", c);
+ gig_dbg(DEBUG_HDLC, "byte stuffed: 0x%02x", c);
#endif
} else if (unlikely(c == PPP_FLAG)) {
if (unlikely(inputstate & INS_skip_frame)) {
if (!(inputstate & INS_have_data)) { /* 7E 7E */
- //dbg(DEBUG_HDLC, "(7e)7e------------------------");
#ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount;
#endif
} else
- dbg(DEBUG_HDLC,
+ gig_dbg(DEBUG_HDLC,
"7e----------------------------");
/* end of frame */
error = 1;
gigaset_rcv_error(NULL, cs, bcs);
} else if (!(inputstate & INS_have_data)) { /* 7E 7E */
- //dbg(DEBUG_HDLC, "(7e)7e------------------------");
#ifdef CONFIG_GIGASET_DEBUG
++bcs->emptycount;
#endif
break;
} else {
- dbg(DEBUG_HDLC,
- "7e----------------------------");
+ gig_dbg(DEBUG_HDLC,
+ "7e----------------------------");
/* end of frame */
error = 0;
if (unlikely(fcs != PPP_GOODFCS)) {
- err("Packet checksum at %lu failed, "
- "packet is corrupted (%u bytes)!",
+ dev_err(cs->dev,
+ "Packet checksum at %lu failed, "
+ "packet is corrupted (%u bytes)!\n",
bcs->rcvbytes, skb->len);
compskb = NULL;
gigaset_rcv_error(compskb, cs, bcs);
@@ -202,9 +192,11 @@ byte_stuff:
skb = NULL;
inputstate |= INS_skip_frame;
if (l == 1) {
- err("invalid packet size (1)!");
+ dev_err(cs->dev,
+ "invalid packet size (1)!\n");
error = 1;
- gigaset_rcv_error(NULL, cs, bcs);
+ gigaset_rcv_error(NULL,
+ cs, bcs);
}
}
if (likely(!(error ||
@@ -227,7 +219,8 @@ byte_stuff:
} else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
skb_reserve(skb, HW_HDR_LEN);
} else {
- warn("could not allocate new skb");
+ dev_warn(cs->dev,
+ "could not allocate new skb\n");
inputstate |= INS_skip_frame;
}
@@ -235,7 +228,7 @@ byte_stuff:
#ifdef CONFIG_GIGASET_DEBUG
} else if (unlikely(muststuff(c))) {
/* Should not happen. Possible after ZDLE=1<CR><LF>. */
- dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c);
+ gig_dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c);
#endif
}
@@ -243,8 +236,8 @@ byte_stuff:
#ifdef CONFIG_GIGASET_DEBUG
if (unlikely(!(inputstate & INS_have_data))) {
- dbg(DEBUG_HDLC,
- "7e (%d x) ================", bcs->emptycount);
+ gig_dbg(DEBUG_HDLC, "7e (%d x) ================",
+ bcs->emptycount);
bcs->emptycount = 0;
}
#endif
@@ -253,14 +246,13 @@ byte_stuff:
if (likely(!(inputstate & INS_skip_frame))) {
if (unlikely(skb->len == SBUFSIZE)) {
- warn("received packet too long");
+ dev_warn(cs->dev, "received packet too long\n");
dev_kfree_skb_any(skb);
skb = NULL;
inputstate |= INS_skip_frame;
break;
}
- *gigaset_skb_put_quick(skb, 1) = c;
- /* *__skb_put (skb, 1) = c; */
+ *__skb_put(skb, 1) = c;
fcs = crc_ccitt_byte(fcs, c);
}
@@ -289,19 +281,14 @@ byte_stuff:
* numbytes (all bytes processed) on error --FIXME
*/
static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
- struct inbuf_t *inbuf)
+ struct inbuf_t *inbuf)
{
struct cardstate *cs = inbuf->cs;
struct bc_state *bcs = inbuf->bcs;
- int inputstate;
- struct sk_buff *skb;
+ int inputstate = bcs->inputstate;
+ struct sk_buff *skb = bcs->skb;
int startbytes = numbytes;
- IFNULLRETVAL(bcs, numbytes);
- inputstate = bcs->inputstate;
- skb = bcs->skb;
- IFNULLRETVAL(skb, numbytes);
-
for (;;) {
/* add character */
inputstate |= INS_have_data;
@@ -309,13 +296,13 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
if (likely(!(inputstate & INS_skip_frame))) {
if (unlikely(skb->len == SBUFSIZE)) {
//FIXME just pass skb up and allocate a new one
- warn("received packet too long");
+ dev_warn(cs->dev, "received packet too long\n");
dev_kfree_skb_any(skb);
skb = NULL;
inputstate |= INS_skip_frame;
break;
}
- *gigaset_skb_put_quick(skb, 1) = gigaset_invtab[c];
+ *__skb_put(skb, 1) = gigaset_invtab[c];
}
if (unlikely(!numbytes))
@@ -343,7 +330,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
!= NULL)) {
skb_reserve(skb, HW_HDR_LEN);
} else {
- warn("could not allocate new skb");
+ dev_warn(cs->dev, "could not allocate new skb\n");
inputstate |= INS_skip_frame;
}
}
@@ -364,13 +351,13 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
head = atomic_read(&inbuf->head);
tail = atomic_read(&inbuf->tail);
- dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
+ gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
if (head != tail) {
cs = inbuf->cs;
src = inbuf->data + head;
numbytes = (head > tail ? RBUFSIZE : tail) - head;
- dbg(DEBUG_INTR, "processing %u bytes", numbytes);
+ gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
while (numbytes) {
if (atomic_read(&cs->mstate) == MS_LOCKED) {
@@ -392,8 +379,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
if (!(inbuf->inputstate & INS_DLE_char)) {
- /* FIXME Einfach je nach Modus Funktionszeiger in cs setzen [hier+hdlc_loop]? */
- /* FIXME Spart folgendes "if" und ermoeglicht andere Protokolle */
+ /* FIXME use function pointers? */
if (inbuf->inputstate & INS_command)
procbytes = cmd_loop(c, src, numbytes, inbuf);
else if (inbuf->bcs->proto2 == ISDN_PROTO_L2_HDLC)
@@ -403,13 +389,14 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
src += procbytes;
numbytes -= procbytes;
- } else { /* DLE-char */
+ } else { /* DLE char */
inbuf->inputstate &= ~INS_DLE_char;
switch (c) {
case 'X': /*begin of command*/
#ifdef CONFIG_GIGASET_DEBUG
if (inbuf->inputstate & INS_command)
- err("received <DLE> 'X' in command mode");
+ dev_err(cs->dev,
+ "received <DLE> 'X' in command mode\n");
#endif
inbuf->inputstate |=
INS_command | INS_DLE_command;
@@ -417,7 +404,8 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
case '.': /*end of command*/
#ifdef CONFIG_GIGASET_DEBUG
if (!(inbuf->inputstate & INS_command))
- err("received <DLE> '.' in hdlc mode");
+ dev_err(cs->dev,
+ "received <DLE> '.' in hdlc mode\n");
#endif
inbuf->inputstate &= cs->dle ?
~(INS_DLE_command|INS_command)
@@ -425,7 +413,9 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
break;
//case DLE_FLAG: /*DLE_FLAG in data stream*/ /* schon oben behandelt! */
default:
- err("received 0x10 0x%02x!", (int) c);
+ dev_err(cs->dev,
+ "received 0x10 0x%02x!\n",
+ (int) c);
/* FIXME: reset driver?? */
}
}
@@ -444,7 +434,7 @@ nextbyte:
}
}
- dbg(DEBUG_INTR, "setting head to %u", head);
+ gig_dbg(DEBUG_INTR, "setting head to %u", head);
atomic_set(&inbuf->head, head);
}
}
@@ -479,14 +469,13 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
stuf_cnt++;
fcs = crc_ccitt_byte(fcs, *cp++);
}
- fcs ^= 0xffff; /* complement */
+ fcs ^= 0xffff; /* complement */
/* size of new buffer: original size + number of stuffing bytes
* + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
*/
hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head);
if (!hdlc_skb) {
- err("unable to allocate memory for HDLC encoding!");
dev_kfree_skb(skb);
return NULL;
}
@@ -508,7 +497,7 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
}
/* Finally add FCS (byte stuffed) and flag sequence */
- c = (fcs & 0x00ff); /* least significant byte first */
+ c = (fcs & 0x00ff); /* least significant byte first */
if (muststuff(c)) {
*(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
c ^= PPP_TRANS;
@@ -546,7 +535,6 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
/* worst case: every byte must be stuffed */
iraw_skb = dev_alloc_skb(2*skb->len + tail + head);
if (!iraw_skb) {
- err("unable to allocate memory for HDLC encoding!");
dev_kfree_skb(skb);
return NULL;
}
@@ -577,21 +565,23 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
*/
int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
{
- unsigned len;
-
- IFNULLRETVAL(bcs, -EFAULT);
- IFNULLRETVAL(skb, -EFAULT);
- len = skb->len;
+ unsigned len = skb->len;
+ unsigned long flags;
if (bcs->proto2 == ISDN_PROTO_L2_HDLC)
skb = HDLC_Encode(skb, HW_HDR_LEN, 0);
else
skb = iraw_encode(skb, HW_HDR_LEN, 0);
- if (!skb)
+ if (!skb) {
+ err("unable to allocate memory for encoding!\n");
return -ENOMEM;
+ }
skb_queue_tail(&bcs->squeue, skb);
- tasklet_schedule(&bcs->cs->write_tasklet);
+ spin_lock_irqsave(&bcs->cs->lock, flags);
+ if (bcs->cs->connected)
+ tasklet_schedule(&bcs->cs->write_tasklet);
+ spin_unlock_irqrestore(&bcs->cs->lock, flags);
return len; /* ok so far */
}
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 31f0f07832bc4..f86ed6af3aa2d 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2001 by Hansjoerg Lipp <hjlipp@web.de>,
* Tilman Schmidt <tilman@imap.cc>,
- * Stefan Eilers <Eilers.Stefan@epost.de>.
+ * Stefan Eilers.
*
* Based on usb-gigaset.c.
*
@@ -13,10 +13,6 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: bas-gigaset.c,v 1.52.4.19 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
@@ -30,7 +26,7 @@
#include <linux/moduleparam.h>
/* Version Information */
-#define DRIVER_AUTHOR "Tilman Schmidt <tilman@imap.cc>, Hansjoerg Lipp <hjlipp@web.de>, Stefan Eilers <Eilers.Stefan@epost.de>"
+#define DRIVER_AUTHOR "Tilman Schmidt <tilman@imap.cc>, Hansjoerg Lipp <hjlipp@web.de>, Stefan Eilers"
#define DRIVER_DESC "USB Driver for Gigaset 307x"
@@ -70,9 +66,6 @@ static struct usb_device_id gigaset_table [] = {
MODULE_DEVICE_TABLE(usb, gigaset_table);
-/* Get a minor range for your devices from the usb maintainer */
-#define USB_SKEL_MINOR_BASE 200
-
/*======================= local function prototypes =============================*/
/* This function is called if a new device is connected to the USB port. It
@@ -88,25 +81,25 @@ static void gigaset_disconnect(struct usb_interface *interface);
/*==============================================================================*/
struct bas_cardstate {
- struct usb_device *udev; /* USB device pointer */
- struct usb_interface *interface; /* interface for this device */
+ struct usb_device *udev; /* USB device pointer */
+ struct usb_interface *interface; /* interface for this device */
unsigned char minor; /* starting minor number */
- struct urb *urb_ctrl; /* control pipe default URB */
+ struct urb *urb_ctrl; /* control pipe default URB */
struct usb_ctrlrequest dr_ctrl;
struct timer_list timer_ctrl; /* control request timeout */
struct timer_list timer_atrdy; /* AT command ready timeout */
- struct urb *urb_cmd_out; /* for sending AT commands */
+ struct urb *urb_cmd_out; /* for sending AT commands */
struct usb_ctrlrequest dr_cmd_out;
int retry_cmd_out;
- struct urb *urb_cmd_in; /* for receiving AT replies */
+ struct urb *urb_cmd_in; /* for receiving AT replies */
struct usb_ctrlrequest dr_cmd_in;
struct timer_list timer_cmd_in; /* receive request timeout */
- unsigned char *rcvbuf; /* AT reply receive buffer */
+ unsigned char *rcvbuf; /* AT reply receive buffer */
- struct urb *urb_int_in; /* URB for interrupt pipe */
+ struct urb *urb_int_in; /* URB for interrupt pipe */
unsigned char int_in_buf[3];
spinlock_t lock; /* locks all following */
@@ -208,53 +201,54 @@ static inline char *usb_pipetype_str(int pipe)
* write content of URB to syslog for debugging
*/
static inline void dump_urb(enum debuglevel level, const char *tag,
- struct urb *urb)
+ struct urb *urb)
{
#ifdef CONFIG_GIGASET_DEBUG
int i;
- IFNULLRET(tag);
- dbg(level, "%s urb(0x%08lx)->{", tag, (unsigned long) urb);
+ gig_dbg(level, "%s urb(0x%08lx)->{", tag, (unsigned long) urb);
if (urb) {
- dbg(level,
- " dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, "
- "status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,",
- (unsigned long) urb->dev,
- usb_pipetype_str(urb->pipe),
- usb_pipeendpoint(urb->pipe), usb_pipedevice(urb->pipe),
- usb_pipein(urb->pipe) ? "in" : "out",
- urb->status, (unsigned long) urb->hcpriv,
- urb->transfer_flags);
- dbg(level,
- " transfer_buffer=0x%08lx[%d], actual_length=%d, "
- "bandwidth=%d, setup_packet=0x%08lx,",
- (unsigned long) urb->transfer_buffer,
- urb->transfer_buffer_length, urb->actual_length,
- urb->bandwidth, (unsigned long) urb->setup_packet);
- dbg(level,
- " start_frame=%d, number_of_packets=%d, interval=%d, "
- "error_count=%d,",
- urb->start_frame, urb->number_of_packets, urb->interval,
- urb->error_count);
- dbg(level,
- " context=0x%08lx, complete=0x%08lx, iso_frame_desc[]={",
- (unsigned long) urb->context,
- (unsigned long) urb->complete);
+ gig_dbg(level,
+ " dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, "
+ "status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,",
+ (unsigned long) urb->dev,
+ usb_pipetype_str(urb->pipe),
+ usb_pipeendpoint(urb->pipe), usb_pipedevice(urb->pipe),
+ usb_pipein(urb->pipe) ? "in" : "out",
+ urb->status, (unsigned long) urb->hcpriv,
+ urb->transfer_flags);
+ gig_dbg(level,
+ " transfer_buffer=0x%08lx[%d], actual_length=%d, "
+ "bandwidth=%d, setup_packet=0x%08lx,",
+ (unsigned long) urb->transfer_buffer,
+ urb->transfer_buffer_length, urb->actual_length,
+ urb->bandwidth, (unsigned long) urb->setup_packet);
+ gig_dbg(level,
+ " start_frame=%d, number_of_packets=%d, interval=%d, "
+ "error_count=%d,",
+ urb->start_frame, urb->number_of_packets, urb->interval,
+ urb->error_count);
+ gig_dbg(level,
+ " context=0x%08lx, complete=0x%08lx, "
+ "iso_frame_desc[]={",
+ (unsigned long) urb->context,
+ (unsigned long) urb->complete);
for (i = 0; i < urb->number_of_packets; i++) {
- struct usb_iso_packet_descriptor *pifd = &urb->iso_frame_desc[i];
- dbg(level,
- " {offset=%u, length=%u, actual_length=%u, "
- "status=%u}",
- pifd->offset, pifd->length, pifd->actual_length,
- pifd->status);
+ struct usb_iso_packet_descriptor *pifd
+ = &urb->iso_frame_desc[i];
+ gig_dbg(level,
+ " {offset=%u, length=%u, actual_length=%u, "
+ "status=%u}",
+ pifd->offset, pifd->length, pifd->actual_length,
+ pifd->status);
}
}
- dbg(level, "}}");
+ gig_dbg(level, "}}");
#endif
}
/* read/set modem control bits etc. (m10x only) */
static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
- unsigned new_state)
+ unsigned new_state)
{
return -EINVAL;
}
@@ -280,8 +274,8 @@ static inline void error_hangup(struct bc_state *bcs)
{
struct cardstate *cs = bcs->cs;
- dbg(DEBUG_ANY,
- "%s: scheduling HUP for channel %d", __func__, bcs->channel);
+ gig_dbg(DEBUG_ANY, "%s: scheduling HUP for channel %d",
+ __func__, bcs->channel);
if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) {
//FIXME what should we do?
@@ -301,22 +295,19 @@ static inline void error_hangup(struct bc_state *bcs)
static inline void error_reset(struct cardstate *cs)
{
//FIXME try to recover without bothering the user
- err("unrecoverable error - please disconnect the Gigaset base to reset");
+ dev_err(cs->dev,
+ "unrecoverable error - please disconnect Gigaset base to reset\n");
}
/* check_pending
* check for completion of pending control request
* parameter:
- * urb USB request block of completed request
- * urb->context = hardware specific controller state structure
+ * ucs hardware specific controller state structure
*/
static void check_pending(struct bas_cardstate *ucs)
{
unsigned long flags;
- IFNULLRET(ucs);
- IFNULLRET(cardstate);
-
spin_lock_irqsave(&ucs->lock, flags);
switch (ucs->pending) {
case 0:
@@ -336,8 +327,6 @@ static void check_pending(struct bas_cardstate *ucs)
case HD_CLOSE_ATCHANNEL:
if (!(atomic_read(&ucs->basstate) & BS_ATOPEN))
ucs->pending = 0;
- //wake_up_interruptible(cs->initwait);
- //FIXME need own wait queue?
break;
case HD_CLOSE_B1CHANNEL:
if (!(atomic_read(&ucs->basstate) & BS_B1OPEN))
@@ -354,7 +343,9 @@ static void check_pending(struct bas_cardstate *ucs)
* are handled separately and should never end up here
*/
default:
- warn("unknown pending request 0x%02x cleared", ucs->pending);
+ dev_warn(&ucs->interface->dev,
+ "unknown pending request 0x%02x cleared\n",
+ ucs->pending);
ucs->pending = 0;
}
@@ -372,27 +363,23 @@ static void check_pending(struct bas_cardstate *ucs)
static void cmd_in_timeout(unsigned long data)
{
struct cardstate *cs = (struct cardstate *) data;
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = cs->hw.bas;
unsigned long flags;
- IFNULLRET(cs);
- ucs = cs->hw.bas;
- IFNULLRET(ucs);
-
spin_lock_irqsave(&cs->lock, flags);
- if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_USBREQ, "%s: disconnected", __func__);
+ if (unlikely(!cs->connected)) {
+ gig_dbg(DEBUG_USBREQ, "%s: disconnected", __func__);
spin_unlock_irqrestore(&cs->lock, flags);
return;
}
if (!ucs->rcvbuf_size) {
- dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__);
+ gig_dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__);
spin_unlock_irqrestore(&cs->lock, flags);
return;
}
spin_unlock_irqrestore(&cs->lock, flags);
- err("timeout reading AT response");
+ dev_err(cs->dev, "timeout reading AT response\n");
error_reset(cs); //FIXME retry?
}
@@ -412,18 +399,15 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs);
*/
static int atread_submit(struct cardstate *cs, int timeout)
{
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = cs->hw.bas;
int ret;
- IFNULLRETVAL(cs, -EINVAL);
- ucs = cs->hw.bas;
- IFNULLRETVAL(ucs, -EINVAL);
- IFNULLRETVAL(ucs->urb_cmd_in, -EINVAL);
-
- dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)", ucs->rcvbuf_size);
+ gig_dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)",
+ ucs->rcvbuf_size);
if (ucs->urb_cmd_in->status == -EINPROGRESS) {
- err("could not submit HD_READ_ATMESSAGE: URB busy");
+ dev_err(cs->dev,
+ "could not submit HD_READ_ATMESSAGE: URB busy\n");
return -EBUSY;
}
@@ -433,19 +417,19 @@ static int atread_submit(struct cardstate *cs, int timeout)
ucs->dr_cmd_in.wIndex = 0;
ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size);
usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev,
- usb_rcvctrlpipe(ucs->udev, 0),
- (unsigned char*) & ucs->dr_cmd_in,
- ucs->rcvbuf, ucs->rcvbuf_size,
- read_ctrl_callback, cs->inbuf);
+ usb_rcvctrlpipe(ucs->udev, 0),
+ (unsigned char*) & ucs->dr_cmd_in,
+ ucs->rcvbuf, ucs->rcvbuf_size,
+ read_ctrl_callback, cs->inbuf);
if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) {
- err("could not submit HD_READ_ATMESSAGE: %s",
- get_usb_statmsg(ret));
+ dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
+ get_usb_statmsg(ret));
return ret;
}
if (timeout > 0) {
- dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
+ gig_dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
ucs->timer_cmd_in.expires = jiffies + timeout * HZ / 10;
ucs->timer_cmd_in.data = (unsigned long) cs;
ucs->timer_cmd_in.function = cmd_in_timeout;
@@ -483,25 +467,14 @@ inline static void update_basstate(struct bas_cardstate *ucs,
*/
static void read_int_callback(struct urb *urb, struct pt_regs *regs)
{
- struct cardstate *cs;
- struct bas_cardstate *ucs;
+ struct cardstate *cs = urb->context;
+ struct bas_cardstate *ucs = cs->hw.bas;
struct bc_state *bcs;
unsigned long flags;
int status;
unsigned l;
int channel;
- IFNULLRET(urb);
- cs = (struct cardstate *) urb->context;
- IFNULLRET(cs);
- ucs = cs->hw.bas;
- IFNULLRET(ucs);
-
- if (unlikely(!atomic_read(&cs->connected))) {
- warn("%s: disconnected", __func__);
- return;
- }
-
switch (urb->status) {
case 0: /* success */
break;
@@ -509,11 +482,12 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
case -ECONNRESET: /* canceled (async) */
case -EINPROGRESS: /* pending */
/* ignore silently */
- dbg(DEBUG_USBREQ,
- "%s: %s", __func__, get_usb_statmsg(urb->status));
+ gig_dbg(DEBUG_USBREQ, "%s: %s",
+ __func__, get_usb_statmsg(urb->status));
return;
default: /* severe trouble */
- warn("interrupt read: %s", get_usb_statmsg(urb->status));
+ dev_warn(cs->dev, "interrupt read: %s\n",
+ get_usb_statmsg(urb->status));
//FIXME corrective action? resubmission always ok?
goto resubmit;
}
@@ -521,10 +495,9 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
l = (unsigned) ucs->int_in_buf[1] +
(((unsigned) ucs->int_in_buf[2]) << 8);
- dbg(DEBUG_USBREQ,
- "<-------%d: 0x%02x (%u [0x%02x 0x%02x])", urb->actual_length,
- (int)ucs->int_in_buf[0], l,
- (int)ucs->int_in_buf[1], (int)ucs->int_in_buf[2]);
+ gig_dbg(DEBUG_USBREQ, "<-------%d: 0x%02x (%u [0x%02x 0x%02x])",
+ urb->actual_length, (int)ucs->int_in_buf[0], l,
+ (int)ucs->int_in_buf[1], (int)ucs->int_in_buf[2]);
channel = 0;
@@ -570,28 +543,30 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
case HD_B1_FLOW_CONTROL:
bcs = cs->bcs + channel;
atomic_add((l - BAS_NORMFRAME) * BAS_CORRFRAMES,
- &bcs->hw.bas->corrbytes);
- dbg(DEBUG_ISO,
- "Flow control (channel %d, sub %d): 0x%02x => %d",
- channel, bcs->hw.bas->numsub, l,
- atomic_read(&bcs->hw.bas->corrbytes));
+ &bcs->hw.bas->corrbytes);
+ gig_dbg(DEBUG_ISO,
+ "Flow control (channel %d, sub %d): 0x%02x => %d",
+ channel, bcs->hw.bas->numsub, l,
+ atomic_read(&bcs->hw.bas->corrbytes));
break;
case HD_RECEIVEATDATA_ACK: /* AT response ready to be received */
if (!l) {
- warn("HD_RECEIVEATDATA_ACK with length 0 ignored");
+ dev_warn(cs->dev,
+ "HD_RECEIVEATDATA_ACK with length 0 ignored\n");
break;
}
spin_lock_irqsave(&cs->lock, flags);
if (ucs->rcvbuf_size) {
spin_unlock_irqrestore(&cs->lock, flags);
- err("receive AT data overrun, %d bytes lost", l);
+ dev_err(cs->dev,
+ "receive AT data overrun, %d bytes lost\n", l);
error_reset(cs); //FIXME reschedule
break;
}
if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) {
spin_unlock_irqrestore(&cs->lock, flags);
- err("%s: out of memory, %d bytes lost", __func__, l);
+ dev_err(cs->dev, "out of memory, %d bytes lost\n", l);
error_reset(cs); //FIXME reschedule
break;
}
@@ -607,25 +582,28 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
break;
case HD_RESET_INTERRUPT_PIPE_ACK:
- dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK");
+ gig_dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK");
break;
case HD_SUSPEND_END:
- dbg(DEBUG_USBREQ, "HD_SUSPEND_END");
+ gig_dbg(DEBUG_USBREQ, "HD_SUSPEND_END");
break;
default:
- warn("unknown Gigaset signal 0x%02x (%u) ignored",
- (int) ucs->int_in_buf[0], l);
+ dev_warn(cs->dev,
+ "unknown Gigaset signal 0x%02x (%u) ignored\n",
+ (int) ucs->int_in_buf[0], l);
}
check_pending(ucs);
resubmit:
- status = usb_submit_urb(urb, SLAB_ATOMIC);
+ spin_lock_irqsave(&cs->lock, flags);
+ status = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
+ spin_unlock_irqrestore(&cs->lock, flags);
if (unlikely(status)) {
- err("could not resubmit interrupt URB: %s",
- get_usb_statmsg(status));
+ dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
+ get_usb_statmsg(status));
error_reset(cs);
}
}
@@ -639,30 +617,22 @@ resubmit:
*/
static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
{
- struct cardstate *cs;
- struct bas_cardstate *ucs;
+ struct inbuf_t *inbuf = urb->context;
+ struct cardstate *cs = inbuf->cs;
+ struct bas_cardstate *ucs = cs->hw.bas;
+ int have_data = 0;
unsigned numbytes;
unsigned long flags;
- struct inbuf_t *inbuf;
- int have_data = 0;
-
- IFNULLRET(urb);
- inbuf = (struct inbuf_t *) urb->context;
- IFNULLRET(inbuf);
- cs = inbuf->cs;
- IFNULLRET(cs);
- ucs = cs->hw.bas;
- IFNULLRET(ucs);
spin_lock_irqsave(&cs->lock, flags);
- if (!atomic_read(&cs->connected)) {
+ if (unlikely(!cs->connected)) {
warn("%s: disconnected", __func__);
spin_unlock_irqrestore(&cs->lock, flags);
return;
}
if (!ucs->rcvbuf_size) {
- warn("%s: no receive in progress", __func__);
+ dev_warn(cs->dev, "%s: no receive in progress\n", __func__);
spin_unlock_irqrestore(&cs->lock, flags);
return;
}
@@ -673,12 +643,14 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
case 0: /* normal completion */
numbytes = urb->actual_length;
if (unlikely(numbytes == 0)) {
- warn("control read: empty block received");
+ dev_warn(cs->dev,
+ "control read: empty block received\n");
goto retry;
}
if (unlikely(numbytes != ucs->rcvbuf_size)) {
- warn("control read: received %d chars, expected %d",
- numbytes, ucs->rcvbuf_size);
+ dev_warn(cs->dev,
+ "control read: received %d chars, expected %d\n",
+ numbytes, ucs->rcvbuf_size);
if (numbytes > ucs->rcvbuf_size)
numbytes = ucs->rcvbuf_size;
}
@@ -698,23 +670,26 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
case -ECONNRESET: /* canceled (async) */
case -EINPROGRESS: /* pending */
/* no action necessary */
- dbg(DEBUG_USBREQ,
- "%s: %s", __func__, get_usb_statmsg(urb->status));
+ gig_dbg(DEBUG_USBREQ, "%s: %s",
+ __func__, get_usb_statmsg(urb->status));
break;
default: /* severe trouble */
- warn("control read: %s", get_usb_statmsg(urb->status));
+ dev_warn(cs->dev, "control read: %s\n",
+ get_usb_statmsg(urb->status));
retry:
if (ucs->retry_cmd_in++ < BAS_RETRY) {
- notice("control read: retry %d", ucs->retry_cmd_in);
+ dev_notice(cs->dev, "control read: retry %d\n",
+ ucs->retry_cmd_in);
if (atread_submit(cs, BAS_TIMEOUT) >= 0) {
/* resubmitted - bypass regular exit block */
spin_unlock_irqrestore(&cs->lock, flags);
return;
}
} else {
- err("control read: giving up after %d tries",
- ucs->retry_cmd_in);
+ dev_err(cs->dev,
+ "control read: giving up after %d tries\n",
+ ucs->retry_cmd_in);
}
error_reset(cs);
}
@@ -724,7 +699,7 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
ucs->rcvbuf_size = 0;
spin_unlock_irqrestore(&cs->lock, flags);
if (have_data) {
- dbg(DEBUG_INTR, "%s-->BH", __func__);
+ gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
gigaset_schedule_event(cs);
}
}
@@ -743,21 +718,16 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs)
unsigned long flags;
int i, rc;
- IFNULLRET(urb);
- IFNULLRET(urb->context);
- IFNULLRET(cardstate);
-
/* status codes not worth bothering the tasklet with */
if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
- urb->status == -EINPROGRESS)) {
- dbg(DEBUG_ISO,
- "%s: %s", __func__, get_usb_statmsg(urb->status));
+ urb->status == -EINPROGRESS)) {
+ gig_dbg(DEBUG_ISO, "%s: %s",
+ __func__, get_usb_statmsg(urb->status));
return;
}
- bcs = (struct bc_state *) urb->context;
+ bcs = urb->context;
ubc = bcs->hw.bas;
- IFNULLRET(ubc);
spin_lock_irqsave(&ubc->isoinlock, flags);
if (likely(ubc->isoindone == NULL)) {
@@ -777,14 +747,17 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs)
urb->iso_frame_desc[i].actual_length = 0;
}
if (likely(atomic_read(&ubc->running))) {
- urb->dev = bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */
+ /* urb->dev is clobbered by USB subsystem */
+ urb->dev = bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP;
urb->number_of_packets = BAS_NUMFRAMES;
- dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", __func__);
+ gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
+ __func__);
rc = usb_submit_urb(urb, SLAB_ATOMIC);
if (unlikely(rc != 0)) {
- err("could not resubmit isochronous read URB: %s",
- get_usb_statmsg(rc));
+ dev_err(bcs->cs->dev,
+ "could not resubmit isochronous read "
+ "URB: %s\n", get_usb_statmsg(rc));
dump_urb(DEBUG_ISO, "isoc read", urb);
error_hangup(bcs);
}
@@ -806,23 +779,17 @@ static void write_iso_callback(struct urb *urb, struct pt_regs *regs)
struct bas_bc_state *ubc;
unsigned long flags;
- IFNULLRET(urb);
- IFNULLRET(urb->context);
- IFNULLRET(cardstate);
-
/* status codes not worth bothering the tasklet with */
if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
- urb->status == -EINPROGRESS)) {
- dbg(DEBUG_ISO,
- "%s: %s", __func__, get_usb_statmsg(urb->status));
+ urb->status == -EINPROGRESS)) {
+ gig_dbg(DEBUG_ISO, "%s: %s",
+ __func__, get_usb_statmsg(urb->status));
return;
}
/* pass URB context to tasklet */
- ucx = (struct isow_urbctx_t *) urb->context;
- IFNULLRET(ucx->bcs);
+ ucx = urb->context;
ubc = ucx->bcs->hw.bas;
- IFNULLRET(ubc);
spin_lock_irqsave(&ubc->isooutlock, flags);
ubc->isooutovfl = ubc->isooutdone;
@@ -841,15 +808,11 @@ static void write_iso_callback(struct urb *urb, struct pt_regs *regs)
*/
static int starturbs(struct bc_state *bcs)
{
+ struct bas_bc_state *ubc = bcs->hw.bas;
struct urb *urb;
- struct bas_bc_state *ubc;
int j, k;
int rc;
- IFNULLRETVAL(bcs, -EFAULT);
- ubc = bcs->hw.bas;
- IFNULLRETVAL(ubc, -EFAULT);
-
/* initialize L2 reception */
if (bcs->proto2 == ISDN_PROTO_L2_HDLC)
bcs->inputstate |= INS_flag_hunt;
@@ -859,7 +822,7 @@ static int starturbs(struct bc_state *bcs)
for (k = 0; k < BAS_INURBS; k++) {
urb = ubc->isoinurbs[k];
if (!urb) {
- err("isoinurbs[%d]==NULL", k);
+ dev_err(bcs->cs->dev, "isoinurbs[%d]==NULL\n", k);
rc = -EFAULT;
goto error;
}
@@ -882,8 +845,9 @@ static int starturbs(struct bc_state *bcs)
dump_urb(DEBUG_ISO, "Initial isoc read", urb);
if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
- err("could not submit isochronous read URB %d: %s",
- k, get_usb_statmsg(rc));
+ dev_err(bcs->cs->dev,
+ "could not submit isochronous read URB %d: %s\n",
+ k, get_usb_statmsg(rc));
goto error;
}
}
@@ -895,7 +859,7 @@ static int starturbs(struct bc_state *bcs)
for (k = 0; k < BAS_OUTURBS; ++k) {
urb = ubc->isoouturbs[k].urb;
if (!urb) {
- err("isoouturbs[%d].urb==NULL", k);
+ dev_err(bcs->cs->dev, "isoouturbs[%d].urb==NULL\n", k);
rc = -EFAULT;
goto error;
}
@@ -922,8 +886,9 @@ static int starturbs(struct bc_state *bcs)
dump_urb(DEBUG_ISO, "Initial isoc write", urb);
rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC);
if (rc != 0) {
- err("could not submit isochronous write URB %d: %s",
- k, get_usb_statmsg(rc));
+ dev_err(bcs->cs->dev,
+ "could not submit isochronous write URB %d: %s\n",
+ k, get_usb_statmsg(rc));
goto error;
}
}
@@ -946,20 +911,20 @@ static void stopurbs(struct bas_bc_state *ubc)
{
int k, rc;
- IFNULLRET(ubc);
-
atomic_set(&ubc->running, 0);
for (k = 0; k < BAS_INURBS; ++k) {
rc = usb_unlink_urb(ubc->isoinurbs[k]);
- dbg(DEBUG_ISO, "%s: isoc input URB %d unlinked, result = %d",
- __func__, k, rc);
+ gig_dbg(DEBUG_ISO,
+ "%s: isoc input URB %d unlinked, result = %d",
+ __func__, k, rc);
}
for (k = 0; k < BAS_OUTURBS; ++k) {
rc = usb_unlink_urb(ubc->isoouturbs[k].urb);
- dbg(DEBUG_ISO, "%s: isoc output URB %d unlinked, result = %d",
- __func__, k, rc);
+ gig_dbg(DEBUG_ISO,
+ "%s: isoc output URB %d unlinked, result = %d",
+ __func__, k, rc);
}
}
@@ -977,19 +942,14 @@ static void stopurbs(struct bas_bc_state *ubc)
*/
static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
{
- struct urb *urb;
- struct bas_bc_state *ubc;
+ struct urb *urb = ucx->urb;
+ struct bas_bc_state *ubc = ucx->bcs->hw.bas;
struct usb_iso_packet_descriptor *ifd;
int corrbytes, nframe, rc;
+ unsigned long flags;
- IFNULLRETVAL(ucx, -EFAULT);
- urb = ucx->urb;
- IFNULLRETVAL(urb, -EFAULT);
- IFNULLRETVAL(ucx->bcs, -EFAULT);
- ubc = ucx->bcs->hw.bas;
- IFNULLRETVAL(ubc, -EFAULT);
-
- urb->dev = ucx->bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */
+ /* urb->dev is clobbered by USB subsystem */
+ urb->dev = ucx->bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = ubc->isooutbuf->data;
urb->transfer_buffer_length = sizeof(ubc->isooutbuf->data);
@@ -1000,7 +960,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
/* compute frame length according to flow control */
ifd->length = BAS_NORMFRAME;
if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) {
- dbg(DEBUG_ISO, "%s: corrbytes=%d", __func__, corrbytes);
+ gig_dbg(DEBUG_ISO, "%s: corrbytes=%d",
+ __func__, corrbytes);
if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME)
corrbytes = BAS_HIGHFRAME - BAS_NORMFRAME;
else if (corrbytes < BAS_LOWFRAME - BAS_NORMFRAME)
@@ -1008,18 +969,21 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
ifd->length += corrbytes;
atomic_add(-corrbytes, &ubc->corrbytes);
}
- //dbg(DEBUG_ISO, "%s: frame %d length=%d", __func__, nframe, ifd->length);
/* retrieve block of data to send */
- ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf, ifd->length);
+ ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf,
+ ifd->length);
if (ifd->offset < 0) {
if (ifd->offset == -EBUSY) {
- dbg(DEBUG_ISO, "%s: buffer busy at frame %d",
- __func__, nframe);
- /* tasklet will be restarted from gigaset_send_skb() */
+ gig_dbg(DEBUG_ISO,
+ "%s: buffer busy at frame %d",
+ __func__, nframe);
+ /* tasklet will be restarted from
+ gigaset_send_skb() */
} else {
- err("%s: buffer error %d at frame %d",
- __func__, ifd->offset, nframe);
+ dev_err(ucx->bcs->cs->dev,
+ "%s: buffer error %d at frame %d\n",
+ __func__, ifd->offset, nframe);
return ifd->offset;
}
break;
@@ -1029,9 +993,14 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
ifd->actual_length = 0;
}
if ((urb->number_of_packets = nframe) > 0) {
- if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
- err("could not submit isochronous write URB: %s",
- get_usb_statmsg(rc));
+ spin_lock_irqsave(&ucx->bcs->cs->lock, flags);
+ rc = ucx->bcs->cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
+ spin_unlock_irqrestore(&ucx->bcs->cs->lock, flags);
+
+ if (rc) {
+ dev_err(ucx->bcs->cs->dev,
+ "could not submit isochronous write URB: %s\n",
+ get_usb_statmsg(rc));
dump_urb(DEBUG_ISO, "isoc write", urb);
return rc;
}
@@ -1048,9 +1017,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
*/
static void write_iso_tasklet(unsigned long data)
{
- struct bc_state *bcs;
- struct bas_bc_state *ubc;
- struct cardstate *cs;
+ struct bc_state *bcs = (struct bc_state *) data;
+ struct bas_bc_state *ubc = bcs->hw.bas;
+ struct cardstate *cs = bcs->cs;
struct isow_urbctx_t *done, *next, *ovfl;
struct urb *urb;
struct usb_iso_packet_descriptor *ifd;
@@ -1060,22 +1029,10 @@ static void write_iso_tasklet(unsigned long data)
struct sk_buff *skb;
int len;
- bcs = (struct bc_state *) data;
- IFNULLRET(bcs);
- ubc = bcs->hw.bas;
- IFNULLRET(ubc);
- cs = bcs->cs;
- IFNULLRET(cs);
-
/* loop while completed URBs arrive in time */
for (;;) {
- if (unlikely(!atomic_read(&cs->connected))) {
- warn("%s: disconnected", __func__);
- return;
- }
-
if (unlikely(!(atomic_read(&ubc->running)))) {
- dbg(DEBUG_ISO, "%s: not running", __func__);
+ gig_dbg(DEBUG_ISO, "%s: not running", __func__);
return;
}
@@ -1087,7 +1044,7 @@ static void write_iso_tasklet(unsigned long data)
ubc->isooutovfl = NULL;
spin_unlock_irqrestore(&ubc->isooutlock, flags);
if (ovfl) {
- err("isochronous write buffer underrun - buy a faster machine :-)");
+ dev_err(cs->dev, "isochronous write buffer underrun\n");
error_hangup(bcs);
break;
}
@@ -1110,7 +1067,8 @@ static void write_iso_tasklet(unsigned long data)
spin_unlock_irqrestore(&ubc->isooutlock, flags);
if (next) {
/* couldn't put it back */
- err("losing isochronous write URB");
+ dev_err(cs->dev,
+ "losing isochronous write URB\n");
error_hangup(bcs);
}
}
@@ -1123,22 +1081,25 @@ static void write_iso_tasklet(unsigned long data)
break;
case -EXDEV: /* inspect individual frames */
/* assumptions (for lack of documentation):
- * - actual_length bytes of the frame in error are successfully sent
+ * - actual_length bytes of the frame in error are
+ * successfully sent
* - all following frames are not sent at all
*/
- dbg(DEBUG_ISO, "%s: URB partially completed", __func__);
+ gig_dbg(DEBUG_ISO, "%s: URB partially completed",
+ __func__);
offset = done->limit; /* just in case */
for (i = 0; i < BAS_NUMFRAMES; i++) {
ifd = &urb->iso_frame_desc[i];
if (ifd->status ||
ifd->actual_length != ifd->length) {
- warn("isochronous write: frame %d: %s, "
- "only %d of %d bytes sent",
+ dev_warn(cs->dev,
+ "isochronous write: frame %d: %s, "
+ "only %d of %d bytes sent\n",
i, get_usb_statmsg(ifd->status),
ifd->actual_length, ifd->length);
offset = (ifd->offset +
- ifd->actual_length)
- % BAS_OUTBUFSIZE;
+ ifd->actual_length)
+ % BAS_OUTBUFSIZE;
break;
}
}
@@ -1148,25 +1109,26 @@ static void write_iso_tasklet(unsigned long data)
ifd = &urb->iso_frame_desc[i];
if (ifd->status != -EINPROGRESS
|| ifd->actual_length != 0) {
- warn("isochronous write: frame %d: %s, "
- "%d of %d bytes sent",
+ dev_warn(cs->dev,
+ "isochronous write: frame %d: %s, "
+ "%d of %d bytes sent\n",
i, get_usb_statmsg(ifd->status),
ifd->actual_length, ifd->length);
offset = (ifd->offset +
- ifd->actual_length)
- % BAS_OUTBUFSIZE;
+ ifd->actual_length)
+ % BAS_OUTBUFSIZE;
break;
}
}
#endif
break;
- case -EPIPE: //FIXME is this the code for "underrun"?
- err("isochronous write stalled");
+ case -EPIPE: //FIXME is this the code for "underrun"?
+ dev_err(cs->dev, "isochronous write stalled\n");
error_hangup(bcs);
break;
default: /* severe trouble */
- warn("isochronous write: %s",
- get_usb_statmsg(urb->status));
+ dev_warn(cs->dev, "isochronous write: %s\n",
+ get_usb_statmsg(urb->status));
}
/* mark the write buffer area covered by this URB as free */
@@ -1194,8 +1156,8 @@ static void write_iso_tasklet(unsigned long data)
if (gigaset_isoc_buildframe(bcs, skb->data, len) == -EAGAIN) {
/* insufficient buffer space, push back onto queue */
skb_queue_head(&bcs->squeue, skb);
- dbg(DEBUG_ISO, "%s: skb requeued, qlen=%d",
- __func__, skb_queue_len(&bcs->squeue));
+ gig_dbg(DEBUG_ISO, "%s: skb requeued, qlen=%d",
+ __func__, skb_queue_len(&bcs->squeue));
break;
}
skb_pull(skb, len);
@@ -1215,28 +1177,16 @@ static void write_iso_tasklet(unsigned long data)
*/
static void read_iso_tasklet(unsigned long data)
{
- struct bc_state *bcs;
- struct bas_bc_state *ubc;
- struct cardstate *cs;
+ struct bc_state *bcs = (struct bc_state *) data;
+ struct bas_bc_state *ubc = bcs->hw.bas;
+ struct cardstate *cs = bcs->cs;
struct urb *urb;
char *rcvbuf;
unsigned long flags;
int totleft, numbytes, offset, frame, rc;
- bcs = (struct bc_state *) data;
- IFNULLRET(bcs);
- ubc = bcs->hw.bas;
- IFNULLRET(ubc);
- cs = bcs->cs;
- IFNULLRET(cs);
-
/* loop while more completed URBs arrive in the meantime */
for (;;) {
- if (!atomic_read(&cs->connected)) {
- warn("%s: disconnected", __func__);
- return;
- }
-
/* retrieve URB */
spin_lock_irqsave(&ubc->isoinlock, flags);
if (!(urb = ubc->isoindone)) {
@@ -1245,38 +1195,45 @@ static void read_iso_tasklet(unsigned long data)
}
ubc->isoindone = NULL;
if (unlikely(ubc->loststatus != -EINPROGRESS)) {
- warn("isochronous read overrun, dropped URB with status: %s, %d bytes lost",
- get_usb_statmsg(ubc->loststatus), ubc->isoinlost);
+ dev_warn(cs->dev,
+ "isochronous read overrun, "
+ "dropped URB with status: %s, %d bytes lost\n",
+ get_usb_statmsg(ubc->loststatus),
+ ubc->isoinlost);
ubc->loststatus = -EINPROGRESS;
}
spin_unlock_irqrestore(&ubc->isoinlock, flags);
if (unlikely(!(atomic_read(&ubc->running)))) {
- dbg(DEBUG_ISO, "%s: channel not running, dropped URB with status: %s",
- __func__, get_usb_statmsg(urb->status));
+ gig_dbg(DEBUG_ISO,
+ "%s: channel not running, "
+ "dropped URB with status: %s",
+ __func__, get_usb_statmsg(urb->status));
return;
}
switch (urb->status) {
case 0: /* normal completion */
break;
- case -EXDEV: /* inspect individual frames (we do that anyway) */
- dbg(DEBUG_ISO, "%s: URB partially completed", __func__);
+ case -EXDEV: /* inspect individual frames
+ (we do that anyway) */
+ gig_dbg(DEBUG_ISO, "%s: URB partially completed",
+ __func__);
break;
case -ENOENT:
case -ECONNRESET:
- dbg(DEBUG_ISO, "%s: URB canceled", __func__);
+ gig_dbg(DEBUG_ISO, "%s: URB canceled", __func__);
continue; /* -> skip */
case -EINPROGRESS: /* huh? */
- dbg(DEBUG_ISO, "%s: URB still pending", __func__);
+ gig_dbg(DEBUG_ISO, "%s: URB still pending", __func__);
continue; /* -> skip */
case -EPIPE:
- err("isochronous read stalled");
+ dev_err(cs->dev, "isochronous read stalled\n");
error_hangup(bcs);
continue; /* -> skip */
default: /* severe trouble */
- warn("isochronous read: %s",
- get_usb_statmsg(urb->status));
+ dev_warn(cs->dev, "isochronous read: %s\n",
+ get_usb_statmsg(urb->status));
goto error;
}
@@ -1284,33 +1241,44 @@ static void read_iso_tasklet(unsigned long data)
totleft = urb->actual_length;
for (frame = 0; totleft > 0 && frame < BAS_NUMFRAMES; frame++) {
if (unlikely(urb->iso_frame_desc[frame].status)) {
- warn("isochronous read: frame %d: %s",
- frame, get_usb_statmsg(urb->iso_frame_desc[frame].status));
+ dev_warn(cs->dev,
+ "isochronous read: frame %d: %s\n",
+ frame,
+ get_usb_statmsg(
+ urb->iso_frame_desc[frame].status));
break;
}
numbytes = urb->iso_frame_desc[frame].actual_length;
if (unlikely(numbytes > BAS_MAXFRAME)) {
- warn("isochronous read: frame %d: numbytes (%d) > BAS_MAXFRAME",
- frame, numbytes);
+ dev_warn(cs->dev,
+ "isochronous read: frame %d: "
+ "numbytes (%d) > BAS_MAXFRAME\n",
+ frame, numbytes);
break;
}
if (unlikely(numbytes > totleft)) {
- warn("isochronous read: frame %d: numbytes (%d) > totleft (%d)",
- frame, numbytes, totleft);
+ dev_warn(cs->dev,
+ "isochronous read: frame %d: "
+ "numbytes (%d) > totleft (%d)\n",
+ frame, numbytes, totleft);
break;
}
offset = urb->iso_frame_desc[frame].offset;
if (unlikely(offset + numbytes > BAS_INBUFSIZE)) {
- warn("isochronous read: frame %d: offset (%d) + numbytes (%d) > BAS_INBUFSIZE",
- frame, offset, numbytes);
+ dev_warn(cs->dev,
+ "isochronous read: frame %d: "
+ "offset (%d) + numbytes (%d) "
+ "> BAS_INBUFSIZE\n",
+ frame, offset, numbytes);
break;
}
gigaset_isoc_receive(rcvbuf + offset, numbytes, bcs);
totleft -= numbytes;
}
if (unlikely(totleft > 0))
- warn("isochronous read: %d data bytes missing",
- totleft);
+ dev_warn(cs->dev,
+ "isochronous read: %d data bytes missing\n",
+ totleft);
error:
/* URB processed, resubmit */
@@ -1318,12 +1286,17 @@ static void read_iso_tasklet(unsigned long data)
urb->iso_frame_desc[frame].status = 0;
urb->iso_frame_desc[frame].actual_length = 0;
}
- urb->dev = bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */
+ /* urb->dev is clobbered by USB subsystem */
+ urb->dev = bcs->cs->hw.bas->udev;
urb->transfer_flags = URB_ISO_ASAP;
urb->number_of_packets = BAS_NUMFRAMES;
- if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
- err("could not resubmit isochronous read URB: %s",
- get_usb_statmsg(rc));
+ spin_lock_irqsave(&cs->lock, flags);
+ rc = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
+ spin_unlock_irqrestore(&cs->lock, flags);
+ if (rc) {
+ dev_err(cs->dev,
+ "could not resubmit isochronous read URB: %s\n",
+ get_usb_statmsg(rc));
dump_urb(DEBUG_ISO, "resubmit iso read", urb);
error_hangup(bcs);
}
@@ -1341,15 +1314,10 @@ static void read_iso_tasklet(unsigned long data)
static void req_timeout(unsigned long data)
{
struct bc_state *bcs = (struct bc_state *) data;
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = bcs->cs->hw.bas;
int pending;
unsigned long flags;
- IFNULLRET(bcs);
- IFNULLRET(bcs->cs);
- ucs = bcs->cs->hw.bas;
- IFNULLRET(ucs);
-
check_pending(ucs);
spin_lock_irqsave(&ucs->lock, flags);
@@ -1359,33 +1327,34 @@ static void req_timeout(unsigned long data)
switch (pending) {
case 0: /* no pending request */
- dbg(DEBUG_USBREQ, "%s: no request pending", __func__);
+ gig_dbg(DEBUG_USBREQ, "%s: no request pending", __func__);
break;
case HD_OPEN_ATCHANNEL:
- err("timeout opening AT channel");
+ dev_err(bcs->cs->dev, "timeout opening AT channel\n");
error_reset(bcs->cs);
break;
case HD_OPEN_B2CHANNEL:
case HD_OPEN_B1CHANNEL:
- err("timeout opening channel %d", bcs->channel + 1);
+ dev_err(bcs->cs->dev, "timeout opening channel %d\n",
+ bcs->channel + 1);
error_hangup(bcs);
break;
case HD_CLOSE_ATCHANNEL:
- err("timeout closing AT channel");
- //wake_up_interruptible(cs->initwait);
- //FIXME need own wait queue?
+ dev_err(bcs->cs->dev, "timeout closing AT channel\n");
break;
case HD_CLOSE_B2CHANNEL:
case HD_CLOSE_B1CHANNEL:
- err("timeout closing channel %d", bcs->channel + 1);
+ dev_err(bcs->cs->dev, "timeout closing channel %d\n",
+ bcs->channel + 1);
break;
default:
- warn("request 0x%02x timed out, clearing", pending);
+ dev_warn(bcs->cs->dev, "request 0x%02x timed out, clearing\n",
+ pending);
}
}
@@ -1398,18 +1367,14 @@ static void req_timeout(unsigned long data)
*/
static void write_ctrl_callback(struct urb *urb, struct pt_regs *regs)
{
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = urb->context;
unsigned long flags;
- IFNULLRET(urb);
- IFNULLRET(urb->context);
- IFNULLRET(cardstate);
-
- ucs = (struct bas_cardstate *) urb->context;
spin_lock_irqsave(&ucs->lock, flags);
if (urb->status && ucs->pending) {
- err("control request 0x%02x failed: %s",
- ucs->pending, get_usb_statmsg(urb->status));
+ dev_err(&ucs->interface->dev,
+ "control request 0x%02x failed: %s\n",
+ ucs->pending, get_usb_statmsg(urb->status));
del_timer(&ucs->timer_ctrl);
ucs->pending = 0;
}
@@ -1438,28 +1403,25 @@ static void write_ctrl_callback(struct urb *urb, struct pt_regs *regs)
*/
static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
{
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = bcs->cs->hw.bas;
int ret;
unsigned long flags;
- IFNULLRETVAL(bcs, -EINVAL);
- IFNULLRETVAL(bcs->cs, -EINVAL);
- ucs = bcs->cs->hw.bas;
- IFNULLRETVAL(ucs, -EINVAL);
- IFNULLRETVAL(ucs->urb_ctrl, -EINVAL);
-
- dbg(DEBUG_USBREQ, "-------> 0x%02x (%d)", req, val);
+ gig_dbg(DEBUG_USBREQ, "-------> 0x%02x (%d)", req, val);
spin_lock_irqsave(&ucs->lock, flags);
if (ucs->pending) {
spin_unlock_irqrestore(&ucs->lock, flags);
- err("submission of request 0x%02x failed: request 0x%02x still pending",
- req, ucs->pending);
+ dev_err(bcs->cs->dev,
+ "submission of request 0x%02x failed: "
+ "request 0x%02x still pending\n",
+ req, ucs->pending);
return -EBUSY;
}
if (ucs->urb_ctrl->status == -EINPROGRESS) {
spin_unlock_irqrestore(&ucs->lock, flags);
- err("could not submit request 0x%02x: URB busy", req);
+ dev_err(bcs->cs->dev,
+ "could not submit request 0x%02x: URB busy\n", req);
return -EBUSY;
}
@@ -1469,19 +1431,19 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
ucs->dr_ctrl.wIndex = 0;
ucs->dr_ctrl.wLength = 0;
usb_fill_control_urb(ucs->urb_ctrl, ucs->udev,
- usb_sndctrlpipe(ucs->udev, 0),
- (unsigned char*) &ucs->dr_ctrl, NULL, 0,
- write_ctrl_callback, ucs);
+ usb_sndctrlpipe(ucs->udev, 0),
+ (unsigned char*) &ucs->dr_ctrl, NULL, 0,
+ write_ctrl_callback, ucs);
if ((ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC)) != 0) {
- err("could not submit request 0x%02x: %s",
- req, get_usb_statmsg(ret));
+ dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
+ req, get_usb_statmsg(ret));
spin_unlock_irqrestore(&ucs->lock, flags);
return ret;
}
ucs->pending = req;
if (timeout > 0) {
- dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
+ gig_dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
ucs->timer_ctrl.expires = jiffies + timeout * HZ / 10;
ucs->timer_ctrl.data = (unsigned long) bcs;
ucs->timer_ctrl.function = req_timeout;
@@ -1504,19 +1466,18 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
{
int req, ret;
- IFNULLRETVAL(bcs, -EINVAL);
-
if ((ret = starturbs(bcs)) < 0) {
- err("could not start isochronous I/O for channel %d",
- bcs->channel + 1);
+ dev_err(bcs->cs->dev,
+ "could not start isochronous I/O for channel %d\n",
+ bcs->channel + 1);
error_hangup(bcs);
return ret;
}
req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL;
if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) {
- err("could not open channel %d: %s",
- bcs->channel + 1, get_usb_statmsg(ret));
+ dev_err(bcs->cs->dev, "could not open channel %d: %s\n",
+ bcs->channel + 1, get_usb_statmsg(ret));
stopurbs(bcs->hw.bas);
error_hangup(bcs);
}
@@ -1537,8 +1498,6 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
{
int req, ret;
- IFNULLRETVAL(bcs, -EINVAL);
-
if (!(atomic_read(&bcs->cs->hw.bas->basstate) &
(bcs->channel ? BS_B2OPEN : BS_B1OPEN))) {
/* channel not running: just signal common.c */
@@ -1548,8 +1507,9 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL;
if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0)
- err("could not submit HD_CLOSE_BxCHANNEL request: %s",
- get_usb_statmsg(ret));
+ dev_err(bcs->cs->dev,
+ "could not submit HD_CLOSE_BxCHANNEL request: %s\n",
+ get_usb_statmsg(ret));
return ret;
}
@@ -1564,17 +1524,13 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
*/
static void complete_cb(struct cardstate *cs)
{
- struct cmdbuf_t *cb;
-
- IFNULLRET(cs);
- cb = cs->cmdbuf;
- IFNULLRET(cb);
+ struct cmdbuf_t *cb = cs->cmdbuf;
/* unqueue completed buffer */
cs->cmdbytes -= cs->curlen;
- dbg(DEBUG_TRANSCMD | DEBUG_LOCKCMD,
- "write_command: sent %u bytes, %u left",
- cs->curlen, cs->cmdbytes);
+ gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD,
+ "write_command: sent %u bytes, %u left",
+ cs->curlen, cs->cmdbytes);
if ((cs->cmdbuf = cb->next) != NULL) {
cs->cmdbuf->prev = NULL;
cs->curlen = cs->cmdbuf->len;
@@ -1600,15 +1556,9 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len);
*/
static void write_command_callback(struct urb *urb, struct pt_regs *regs)
{
- struct cardstate *cs;
+ struct cardstate *cs = urb->context;
+ struct bas_cardstate *ucs = cs->hw.bas;
unsigned long flags;
- struct bas_cardstate *ucs;
-
- IFNULLRET(urb);
- cs = (struct cardstate *) urb->context;
- IFNULLRET(cs);
- ucs = cs->hw.bas;
- IFNULLRET(ucs);
/* check status */
switch (urb->status) {
@@ -1618,22 +1568,27 @@ static void write_command_callback(struct urb *urb, struct pt_regs *regs)
case -ECONNRESET: /* canceled (async) */
case -EINPROGRESS: /* pending */
/* ignore silently */
- dbg(DEBUG_USBREQ,
- "%s: %s", __func__, get_usb_statmsg(urb->status));
+ gig_dbg(DEBUG_USBREQ, "%s: %s",
+ __func__, get_usb_statmsg(urb->status));
return;
default: /* any failure */
if (++ucs->retry_cmd_out > BAS_RETRY) {
- warn("command write: %s, giving up after %d retries",
- get_usb_statmsg(urb->status), ucs->retry_cmd_out);
+ dev_warn(cs->dev,
+ "command write: %s, "
+ "giving up after %d retries\n",
+ get_usb_statmsg(urb->status),
+ ucs->retry_cmd_out);
break;
}
if (cs->cmdbuf == NULL) {
- warn("command write: %s, cannot retry - cmdbuf gone",
- get_usb_statmsg(urb->status));
+ dev_warn(cs->dev,
+ "command write: %s, "
+ "cannot retry - cmdbuf gone\n",
+ get_usb_statmsg(urb->status));
break;
}
- notice("command write: %s, retry %d",
- get_usb_statmsg(urb->status), ucs->retry_cmd_out);
+ dev_notice(cs->dev, "command write: %s, retry %d\n",
+ get_usb_statmsg(urb->status), ucs->retry_cmd_out);
if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0)
/* resubmitted - bypass regular exit block */
return;
@@ -1655,13 +1610,9 @@ static void write_command_callback(struct urb *urb, struct pt_regs *regs)
static void atrdy_timeout(unsigned long data)
{
struct cardstate *cs = (struct cardstate *) data;
- struct bas_cardstate *ucs;
-
- IFNULLRET(cs);
- ucs = cs->hw.bas;
- IFNULLRET(ucs);
+ struct bas_cardstate *ucs = cs->hw.bas;
- warn("timeout waiting for HD_READY_SEND_ATDATA");
+ dev_warn(cs->dev, "timeout waiting for HD_READY_SEND_ATDATA\n");
/* fake the missing signal - what else can I do? */
update_basstate(ucs, BS_ATREADY, BS_ATTIMER);
@@ -1682,18 +1633,15 @@ static void atrdy_timeout(unsigned long data)
*/
static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
{
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = cs->hw.bas;
+ unsigned long flags;
int ret;
- IFNULLRETVAL(cs, -EFAULT);
- ucs = cs->hw.bas;
- IFNULLRETVAL(ucs, -EFAULT);
- IFNULLRETVAL(ucs->urb_cmd_out, -EFAULT);
-
- dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len);
+ gig_dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len);
if (ucs->urb_cmd_out->status == -EINPROGRESS) {
- err("could not submit HD_WRITE_ATMESSAGE: URB busy");
+ dev_err(cs->dev,
+ "could not submit HD_WRITE_ATMESSAGE: URB busy\n");
return -EBUSY;
}
@@ -1707,9 +1655,13 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
(unsigned char*) &ucs->dr_cmd_out, buf, len,
write_command_callback, cs);
- if ((ret = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC)) != 0) {
- err("could not submit HD_WRITE_ATMESSAGE: %s",
- get_usb_statmsg(ret));
+ spin_lock_irqsave(&cs->lock, flags);
+ ret = cs->connected ? usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC) : -ENODEV;
+ spin_unlock_irqrestore(&cs->lock, flags);
+
+ if (ret) {
+ dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
+ get_usb_statmsg(ret));
return ret;
}
@@ -1718,8 +1670,8 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
/* start timeout if necessary */
if (!(atomic_read(&ucs->basstate) & BS_ATTIMER)) {
- dbg(DEBUG_OUTPUT,
- "setting ATREADY timeout of %d/10 secs", ATRDY_TIMEOUT);
+ gig_dbg(DEBUG_OUTPUT, "setting ATREADY timeout of %d/10 secs",
+ ATRDY_TIMEOUT);
ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10;
ucs->timer_atrdy.data = (unsigned long) cs;
ucs->timer_atrdy.function = atrdy_timeout;
@@ -1740,21 +1692,17 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
static int start_cbsend(struct cardstate *cs)
{
struct cmdbuf_t *cb;
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = cs->hw.bas;
unsigned long flags;
int rc;
int retval = 0;
- IFNULLRETVAL(cs, -EFAULT);
- ucs = cs->hw.bas;
- IFNULLRETVAL(ucs, -EFAULT);
-
/* check if AT channel is open */
if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) {
- dbg(DEBUG_TRANSCMD | DEBUG_LOCKCMD, "AT channel not open");
+ gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open");
rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT);
if (rc < 0) {
- err("could not open AT channel");
+ dev_err(cs->dev, "could not open AT channel\n");
/* flush command queue */
spin_lock_irqsave(&cs->cmdlock, flags);
while (cs->cmdbuf != NULL)
@@ -1792,27 +1740,23 @@ static int start_cbsend(struct cardstate *cs)
* cs controller state structure
* buf command string to send
* len number of bytes to send (max. IF_WRITEBUF)
- * wake_tasklet tasklet to run when transmission is completed (NULL if none)
+ * wake_tasklet tasklet to run when transmission is completed
+ * (NULL if none)
* return value:
* number of bytes queued on success
* error code < 0 on error
*/
static int gigaset_write_cmd(struct cardstate *cs,
- const unsigned char *buf, int len,
- struct tasklet_struct *wake_tasklet)
+ const unsigned char *buf, int len,
+ struct tasklet_struct *wake_tasklet)
{
struct cmdbuf_t *cb;
unsigned long flags;
int status;
gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ?
- DEBUG_TRANSCMD : DEBUG_LOCKCMD,
- "CMD Transmit", len, buf, 0);
-
- if (!atomic_read(&cs->connected)) {
- err("%s: not connected", __func__);
- return -ENODEV;
- }
+ DEBUG_TRANSCMD : DEBUG_LOCKCMD,
+ "CMD Transmit", len, buf);
if (len <= 0)
return 0; /* nothing to do */
@@ -1820,7 +1764,7 @@ static int gigaset_write_cmd(struct cardstate *cs,
if (len > IF_WRITEBUF)
len = IF_WRITEBUF;
if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) {
- err("%s: out of memory", __func__);
+ dev_err(cs->dev, "%s: out of memory\n", __func__);
return -ENOMEM;
}
@@ -1849,7 +1793,8 @@ static int gigaset_write_cmd(struct cardstate *cs,
/* gigaset_write_room
* tty_driver.write_room interface routine
- * return number of characters the driver will accept to be written via gigaset_write_cmd
+ * return number of characters the driver will accept to be written via
+ * gigaset_write_cmd
* parameter:
* controller state structure
* return value:
@@ -1947,7 +1892,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
return 0;
}
tasklet_init(&ubc->sent_tasklet,
- &write_iso_tasklet, (unsigned long) bcs);
+ &write_iso_tasklet, (unsigned long) bcs);
spin_lock_init(&ubc->isoinlock);
for (i = 0; i < BAS_INURBS; ++i)
@@ -1968,7 +1913,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
ubc->shared0s = 0;
ubc->stolen0s = 0;
tasklet_init(&ubc->rcvd_tasklet,
- &read_iso_tasklet, (unsigned long) bcs);
+ &read_iso_tasklet, (unsigned long) bcs);
return 1;
}
@@ -2027,57 +1972,56 @@ static int gigaset_initcshw(struct cardstate *cs)
*/
static void freeurbs(struct cardstate *cs)
{
- struct bas_cardstate *ucs;
+ struct bas_cardstate *ucs = cs->hw.bas;
struct bas_bc_state *ubc;
int i, j;
- IFNULLRET(cs);
- ucs = cs->hw.bas;
- IFNULLRET(ucs);
-
for (j = 0; j < 2; ++j) {
ubc = cs->bcs[j].hw.bas;
- IFNULLCONT(ubc);
for (i = 0; i < BAS_OUTURBS; ++i)
if (ubc->isoouturbs[i].urb) {
usb_kill_urb(ubc->isoouturbs[i].urb);
- dbg(DEBUG_INIT,
- "%s: isoc output URB %d/%d unlinked",
- __func__, j, i);
+ gig_dbg(DEBUG_INIT,
+ "%s: isoc output URB %d/%d unlinked",
+ __func__, j, i);
usb_free_urb(ubc->isoouturbs[i].urb);
ubc->isoouturbs[i].urb = NULL;
}
for (i = 0; i < BAS_INURBS; ++i)
if (ubc->isoinurbs[i]) {
usb_kill_urb(ubc->isoinurbs[i]);
- dbg(DEBUG_INIT,
- "%s: isoc input URB %d/%d unlinked",
- __func__, j, i);
+ gig_dbg(DEBUG_INIT,
+ "%s: isoc input URB %d/%d unlinked",
+ __func__, j, i);
usb_free_urb(ubc->isoinurbs[i]);
ubc->isoinurbs[i] = NULL;
}
}
if (ucs->urb_int_in) {
usb_kill_urb(ucs->urb_int_in);
- dbg(DEBUG_INIT, "%s: interrupt input URB unlinked", __func__);
+ gig_dbg(DEBUG_INIT, "%s: interrupt input URB unlinked",
+ __func__);
usb_free_urb(ucs->urb_int_in);
ucs->urb_int_in = NULL;
}
if (ucs->urb_cmd_out) {
usb_kill_urb(ucs->urb_cmd_out);
- dbg(DEBUG_INIT, "%s: command output URB unlinked", __func__);
+ gig_dbg(DEBUG_INIT, "%s: command output URB unlinked",
+ __func__);
usb_free_urb(ucs->urb_cmd_out);
ucs->urb_cmd_out = NULL;
}
if (ucs->urb_cmd_in) {
usb_kill_urb(ucs->urb_cmd_in);
- dbg(DEBUG_INIT, "%s: command input URB unlinked", __func__);
+ gig_dbg(DEBUG_INIT, "%s: command input URB unlinked",
+ __func__);
usb_free_urb(ucs->urb_cmd_in);
ucs->urb_cmd_in = NULL;
}
if (ucs->urb_ctrl) {
usb_kill_urb(ucs->urb_ctrl);
- dbg(DEBUG_INIT, "%s: control output URB unlinked", __func__);
+ gig_dbg(DEBUG_INIT, "%s: control output URB unlinked",
+ __func__);
usb_free_urb(ucs->urb_ctrl);
ucs->urb_ctrl = NULL;
}
@@ -2099,12 +2043,10 @@ static int gigaset_probe(struct usb_interface *interface,
int i, j;
int ret;
- IFNULLRETVAL(udev, -ENODEV);
-
- dbg(DEBUG_ANY,
- "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
- __func__, le16_to_cpu(udev->descriptor.idVendor),
- le16_to_cpu(udev->descriptor.idProduct));
+ gig_dbg(DEBUG_ANY,
+ "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
+ __func__, le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
/* See if the device offered us matches what we can accept */
if ((le16_to_cpu(udev->descriptor.idVendor) != USB_GIGA_VENDOR_ID) ||
@@ -2112,20 +2054,21 @@ static int gigaset_probe(struct usb_interface *interface,
le16_to_cpu(udev->descriptor.idProduct) != USB_4175_PRODUCT_ID &&
le16_to_cpu(udev->descriptor.idProduct) != USB_SX303_PRODUCT_ID &&
le16_to_cpu(udev->descriptor.idProduct) != USB_SX353_PRODUCT_ID)) {
- dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__);
+ gig_dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__);
return -ENODEV;
}
/* set required alternate setting */
hostif = interface->cur_altsetting;
if (hostif->desc.bAlternateSetting != 3) {
- dbg(DEBUG_ANY,
- "%s: wrong alternate setting %d - trying to switch",
- __func__, hostif->desc.bAlternateSetting);
+ gig_dbg(DEBUG_ANY,
+ "%s: wrong alternate setting %d - trying to switch",
+ __func__, hostif->desc.bAlternateSetting);
if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) {
- warn("usb_set_interface failed, device %d interface %d altsetting %d",
- udev->devnum, hostif->desc.bInterfaceNumber,
- hostif->desc.bAlternateSetting);
+ dev_warn(&udev->dev, "usb_set_interface failed, "
+ "device %d interface %d altsetting %d\n",
+ udev->devnum, hostif->desc.bInterfaceNumber,
+ hostif->desc.bAlternateSetting);
return -ENODEV;
}
hostif = interface->cur_altsetting;
@@ -2134,23 +2077,28 @@ static int gigaset_probe(struct usb_interface *interface,
/* Reject application specific interfaces
*/
if (hostif->desc.bInterfaceClass != 255) {
- warn("%s: bInterfaceClass == %d",
- __func__, hostif->desc.bInterfaceClass);
+ dev_warn(&udev->dev, "%s: bInterfaceClass == %d\n",
+ __func__, hostif->desc.bInterfaceClass);
return -ENODEV;
}
- info("%s: Device matched (Vendor: 0x%x, Product: 0x%x)",
- __func__, le16_to_cpu(udev->descriptor.idVendor),
- le16_to_cpu(udev->descriptor.idProduct));
+ dev_info(&udev->dev,
+ "%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n",
+ __func__, le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
cs = gigaset_getunassignedcs(driver);
if (!cs) {
- err("%s: no free cardstate", __func__);
+ dev_err(&udev->dev, "no free cardstate\n");
return -ENODEV;
}
ucs = cs->hw.bas;
+
+ /* save off device structure ptrs for later use */
+ usb_get_dev(udev);
ucs->udev = udev;
ucs->interface = interface;
+ cs->dev = &interface->dev;
/* allocate URBs:
* - one for the interrupt pipe
@@ -2159,22 +2107,22 @@ static int gigaset_probe(struct usb_interface *interface,
*/
ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_int_in) {
- err("No free urbs available");
+ dev_err(cs->dev, "no free urbs available\n");
goto error;
}
ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_cmd_in) {
- err("No free urbs available");
+ dev_err(cs->dev, "no free urbs available\n");
goto error;
}
ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_cmd_out) {
- err("No free urbs available");
+ dev_err(cs->dev, "no free urbs available\n");
goto error;
}
ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->urb_ctrl) {
- err("No free urbs available");
+ dev_err(cs->dev, "no free urbs available\n");
goto error;
}
@@ -2184,7 +2132,7 @@ static int gigaset_probe(struct usb_interface *interface,
ubc->isoouturbs[i].urb =
usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL);
if (!ubc->isoouturbs[i].urb) {
- err("No free urbs available");
+ dev_err(cs->dev, "no free urbs available\n");
goto error;
}
}
@@ -2192,7 +2140,7 @@ static int gigaset_probe(struct usb_interface *interface,
ubc->isoinurbs[i] =
usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL);
if (!ubc->isoinurbs[i]) {
- err("No free urbs available");
+ dev_err(cs->dev, "no free urbs available\n");
goto error;
}
}
@@ -2204,13 +2152,14 @@ static int gigaset_probe(struct usb_interface *interface,
/* Fill the interrupt urb and send it to the core */
endpoint = &hostif->endpoint[0].desc;
usb_fill_int_urb(ucs->urb_int_in, udev,
- usb_rcvintpipe(udev,
- (endpoint->bEndpointAddress) & 0x0f),
- ucs->int_in_buf, 3, read_int_callback, cs,
- endpoint->bInterval);
+ usb_rcvintpipe(udev,
+ (endpoint->bEndpointAddress) & 0x0f),
+ ucs->int_in_buf, 3, read_int_callback, cs,
+ endpoint->bInterval);
ret = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL);
if (ret) {
- err("could not submit interrupt URB: %s", get_usb_statmsg(ret));
+ dev_err(cs->dev, "could not submit interrupt URB: %s\n",
+ get_usb_statmsg(ret));
goto error;
}
@@ -2221,18 +2170,18 @@ static int gigaset_probe(struct usb_interface *interface,
/* tell common part that the device is ready */
if (startmode == SM_LOCKED)
atomic_set(&cs->mstate, MS_LOCKED);
- if (!gigaset_start(cs))
- goto error;
/* save address of controller structure */
usb_set_intfdata(interface, cs);
- /* set up device sysfs */
- gigaset_init_dev_sysfs(interface);
+ if (!gigaset_start(cs))
+ goto error;
+
return 0;
error:
freeurbs(cs);
+ usb_set_intfdata(interface, NULL);
gigaset_unassign(cs);
return -ENODEV;
}
@@ -2245,23 +2194,22 @@ static void gigaset_disconnect(struct usb_interface *interface)
struct cardstate *cs;
struct bas_cardstate *ucs;
- /* clear device sysfs */
- gigaset_free_dev_sysfs(interface);
-
cs = usb_get_intfdata(interface);
- usb_set_intfdata(interface, NULL);
- IFNULLRET(cs);
ucs = cs->hw.bas;
- IFNULLRET(ucs);
- info("disconnecting GigaSet base");
+ dev_info(cs->dev, "disconnecting Gigaset base\n");
gigaset_stop(cs);
freeurbs(cs);
+ usb_set_intfdata(interface, NULL);
kfree(ucs->rcvbuf);
ucs->rcvbuf = NULL;
ucs->rcvbuf_size = 0;
atomic_set(&ucs->basstate, 0);
+ usb_put_dev(ucs->udev);
+ ucs->interface = NULL;
+ ucs->udev = NULL;
+ cs->dev = NULL;
gigaset_unassign(cs);
}
@@ -2293,13 +2241,14 @@ static int __init bas_gigaset_init(void)
/* allocate memory for our driver state and intialize it */
if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
- GIGASET_MODULENAME, GIGASET_DEVNAME,
- GIGASET_DEVFSNAME, &gigops,
- THIS_MODULE)) == NULL)
+ GIGASET_MODULENAME, GIGASET_DEVNAME,
+ GIGASET_DEVFSNAME, &gigops,
+ THIS_MODULE)) == NULL)
goto error;
/* allocate memory for our device state and intialize it */
- cardstate = gigaset_initcs(driver, 2, 0, 0, cidmode, GIGASET_MODULENAME);
+ cardstate = gigaset_initcs(driver, 2, 0, 0, cidmode,
+ GIGASET_MODULENAME);
if (!cardstate)
goto error;
@@ -2329,19 +2278,18 @@ error: if (cardstate)
static void __exit bas_gigaset_exit(void)
{
gigaset_blockdriver(driver); /* => probe will fail
- * => no gigaset_start any more
- */
+ * => no gigaset_start any more
+ */
gigaset_shutdown(cardstate);
/* from now on, no isdn callback should be possible */
if (atomic_read(&cardstate->hw.bas->basstate) & BS_ATOPEN) {
- dbg(DEBUG_ANY, "closing AT channel");
+ gig_dbg(DEBUG_ANY, "closing AT channel");
if (req_submit(cardstate->bcs,
- HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) {
- /* successfully submitted - wait for completion */
- //wait_event_interruptible(cs->initwait, !cs->hw.bas->pending);
- //FIXME need own wait queue? wakeup?
+ HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) {
+ /* successfully submitted */
+ //FIXME wait for completion?
}
}
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 64371995c1a97..749b3da1236e3 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -1,7 +1,7 @@
/*
* Stuff used by all variants of the driver
*
- * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>,
+ * Copyright (c) 2001 by Stefan Eilers,
* Hansjoerg Lipp <hjlipp@web.de>,
* Tilman Schmidt <tilman@imap.cc>.
*
@@ -11,10 +11,6 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: common.c,v 1.104.4.22 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
@@ -23,7 +19,7 @@
#include <linux/moduleparam.h>
/* Version Information */
-#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers <Eilers.Stefan@epost.de>"
+#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers"
#define DRIVER_DESC "Driver for Gigaset 307x"
/* Module parameters */
@@ -32,21 +28,10 @@ EXPORT_SYMBOL_GPL(gigaset_debuglevel);
module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(debug, "debug level");
-/*======================================================================
- Prototypes of internal functions
- */
-
-//static void gigaset_process_response(int resp_code, int parameter,
-// struct at_state_t *at_state,
-// unsigned char ** pstring);
-static struct cardstate *alloc_cs(struct gigaset_driver *drv);
-static void free_cs(struct cardstate *cs);
-static void make_valid(struct cardstate *cs, unsigned mask);
-static void make_invalid(struct cardstate *cs, unsigned mask);
-
-#define VALID_MINOR 0x01
-#define VALID_ID 0x02
-#define ASSIGNED 0x04
+/* driver state flags */
+#define VALID_MINOR 0x01
+#define VALID_ID 0x02
+#define ASSIGNED 0x04
/* bitwise byte inversion table */
__u8 gigaset_invtab[256] = {
@@ -86,42 +71,40 @@ __u8 gigaset_invtab[256] = {
EXPORT_SYMBOL_GPL(gigaset_invtab);
void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
- size_t len, const unsigned char *buf, int from_user)
+ size_t len, const unsigned char *buf)
{
unsigned char outbuf[80];
- unsigned char inbuf[80 - 1];
- size_t numin;
- const unsigned char *in;
+ unsigned char c;
size_t space = sizeof outbuf - 1;
unsigned char *out = outbuf;
+ size_t numin = len;
- if (!from_user) {
- in = buf;
- numin = len;
- } else {
- numin = len < sizeof inbuf ? len : sizeof inbuf;
- in = inbuf;
- if (copy_from_user(inbuf, (const unsigned char __user *) buf, numin)) {
- strncpy(inbuf, "<FAULT>", sizeof inbuf);
- numin = sizeof "<FAULT>" - 1;
+ while (numin--) {
+ c = *buf++;
+ if (c == '~' || c == '^' || c == '\\') {
+ if (!space--)
+ break;
+ *out++ = '\\';
}
- }
-
- for (; numin && space; --numin, ++in) {
- --space;
- if (*in >= 32)
- *out++ = *in;
- else {
+ if (c & 0x80) {
+ if (!space--)
+ break;
+ *out++ = '~';
+ c ^= 0x80;
+ }
+ if (c < 0x20 || c == 0x7f) {
+ if (!space--)
+ break;
*out++ = '^';
- if (space) {
- *out++ = '@' + *in;
- --space;
- }
+ c ^= 0x40;
}
+ if (!space--)
+ break;
+ *out++ = c;
}
*out = 0;
- dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf);
+ gig_dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf);
}
EXPORT_SYMBOL_GPL(gigaset_dbg_buffer);
@@ -146,11 +129,6 @@ int gigaset_enterconfigmode(struct cardstate *cs)
{
int i, r;
- if (!atomic_read(&cs->connected)) {
- err("not connected!");
- return -1;
- }
-
cs->control_state = TIOCM_RTS; //FIXME
r = setflags(cs, TIOCM_DTR, 200);
@@ -174,7 +152,7 @@ int gigaset_enterconfigmode(struct cardstate *cs)
return 0;
error:
- err("error %d on setuartbits!\n", -r);
+ dev_err(cs->dev, "error %d on setuartbits\n", -r);
cs->control_state = TIOCM_RTS|TIOCM_DTR; // FIXME is this a good value?
cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR);
@@ -187,13 +165,13 @@ static int test_timeout(struct at_state_t *at_state)
return 0;
if (--at_state->timer_expires) {
- dbg(DEBUG_MCMD, "decreased timer of %p to %lu",
- at_state, at_state->timer_expires);
+ gig_dbg(DEBUG_MCMD, "decreased timer of %p to %lu",
+ at_state, at_state->timer_expires);
return 0;
}
if (!gigaset_add_event(at_state->cs, at_state, EV_TIMEOUT, NULL,
- atomic_read(&at_state->timer_index), NULL)) {
+ at_state->timer_index, NULL)) {
//FIXME what should we do?
}
@@ -221,10 +199,10 @@ static void timer_tick(unsigned long data)
if (test_timeout(at_state))
timeout = 1;
- if (atomic_read(&cs->running)) {
- mod_timer(&cs->timer, jiffies + GIG_TICK);
+ if (cs->running) {
+ mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK));
if (timeout) {
- dbg(DEBUG_CMD, "scheduling timeout");
+ gig_dbg(DEBUG_CMD, "scheduling timeout");
tasklet_schedule(&cs->event_tasklet);
}
}
@@ -238,13 +216,14 @@ int gigaset_get_channel(struct bc_state *bcs)
spin_lock_irqsave(&bcs->cs->lock, flags);
if (bcs->use_count) {
- dbg(DEBUG_ANY, "could not allocate channel %d", bcs->channel);
+ gig_dbg(DEBUG_ANY, "could not allocate channel %d",
+ bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags);
return 0;
}
++bcs->use_count;
bcs->busy = 1;
- dbg(DEBUG_ANY, "allocated channel %d", bcs->channel);
+ gig_dbg(DEBUG_ANY, "allocated channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags);
return 1;
}
@@ -255,13 +234,13 @@ void gigaset_free_channel(struct bc_state *bcs)
spin_lock_irqsave(&bcs->cs->lock, flags);
if (!bcs->busy) {
- dbg(DEBUG_ANY, "could not free channel %d", bcs->channel);
+ gig_dbg(DEBUG_ANY, "could not free channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags);
return;
}
--bcs->use_count;
bcs->busy = 0;
- dbg(DEBUG_ANY, "freed channel %d", bcs->channel);
+ gig_dbg(DEBUG_ANY, "freed channel %d", bcs->channel);
spin_unlock_irqrestore(&bcs->cs->lock, flags);
}
@@ -274,14 +253,14 @@ int gigaset_get_channels(struct cardstate *cs)
for (i = 0; i < cs->channels; ++i)
if (cs->bcs[i].use_count) {
spin_unlock_irqrestore(&cs->lock, flags);
- dbg(DEBUG_ANY, "could not allocated all channels");
+ gig_dbg(DEBUG_ANY, "could not allocate all channels");
return 0;
}
for (i = 0; i < cs->channels; ++i)
++cs->bcs[i].use_count;
spin_unlock_irqrestore(&cs->lock, flags);
- dbg(DEBUG_ANY, "allocated all channels");
+ gig_dbg(DEBUG_ANY, "allocated all channels");
return 1;
}
@@ -291,7 +270,7 @@ void gigaset_free_channels(struct cardstate *cs)
unsigned long flags;
int i;
- dbg(DEBUG_ANY, "unblocking all channels");
+ gig_dbg(DEBUG_ANY, "unblocking all channels");
spin_lock_irqsave(&cs->lock, flags);
for (i = 0; i < cs->channels; ++i)
--cs->bcs[i].use_count;
@@ -303,7 +282,7 @@ void gigaset_block_channels(struct cardstate *cs)
unsigned long flags;
int i;
- dbg(DEBUG_ANY, "blocking all channels");
+ gig_dbg(DEBUG_ANY, "blocking all channels");
spin_lock_irqsave(&cs->lock, flags);
for (i = 0; i < cs->channels; ++i)
++cs->bcs[i].use_count;
@@ -314,25 +293,27 @@ static void clear_events(struct cardstate *cs)
{
struct event_t *ev;
unsigned head, tail;
+ unsigned long flags;
- /* no locking needed (no reader/writer allowed) */
+ spin_lock_irqsave(&cs->ev_lock, flags);
- head = atomic_read(&cs->ev_head);
- tail = atomic_read(&cs->ev_tail);
+ head = cs->ev_head;
+ tail = cs->ev_tail;
while (tail != head) {
ev = cs->events + head;
kfree(ev->ptr);
-
head = (head + 1) % MAX_EVENTS;
}
- atomic_set(&cs->ev_head, tail);
+ cs->ev_head = tail;
+
+ spin_unlock_irqrestore(&cs->ev_lock, flags);
}
struct event_t *gigaset_add_event(struct cardstate *cs,
- struct at_state_t *at_state, int type,
- void *ptr, int parameter, void *arg)
+ struct at_state_t *at_state, int type,
+ void *ptr, int parameter, void *arg)
{
unsigned long flags;
unsigned next, tail;
@@ -340,9 +321,9 @@ struct event_t *gigaset_add_event(struct cardstate *cs,
spin_lock_irqsave(&cs->ev_lock, flags);
- tail = atomic_read(&cs->ev_tail);
+ tail = cs->ev_tail;
next = (tail + 1) % MAX_EVENTS;
- if (unlikely(next == atomic_read(&cs->ev_head)))
+ if (unlikely(next == cs->ev_head))
err("event queue full");
else {
event = cs->events + tail;
@@ -352,7 +333,7 @@ struct event_t *gigaset_add_event(struct cardstate *cs,
event->ptr = ptr;
event->arg = arg;
event->parameter = parameter;
- atomic_set(&cs->ev_tail, next);
+ cs->ev_tail = next;
}
spin_unlock_irqrestore(&cs->ev_lock, flags);
@@ -391,14 +372,14 @@ static void gigaset_freebcs(struct bc_state *bcs)
{
int i;
- dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
+ gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
if (!bcs->cs->ops->freebcshw(bcs)) {
- dbg(DEBUG_INIT, "failed");
+ gig_dbg(DEBUG_INIT, "failed");
}
- dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
+ gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
clear_at_state(&bcs->at_state);
- dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
+ gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
if (bcs->skb)
dev_kfree_skb(bcs->skb);
@@ -408,6 +389,52 @@ static void gigaset_freebcs(struct bc_state *bcs)
}
}
+static struct cardstate *alloc_cs(struct gigaset_driver *drv)
+{
+ unsigned long flags;
+ unsigned i;
+ static struct cardstate *ret = NULL;
+
+ spin_lock_irqsave(&drv->lock, flags);
+ for (i = 0; i < drv->minors; ++i) {
+ if (!(drv->flags[i] & VALID_MINOR)) {
+ drv->flags[i] = VALID_MINOR;
+ ret = drv->cs + i;
+ }
+ if (ret)
+ break;
+ }
+ spin_unlock_irqrestore(&drv->lock, flags);
+ return ret;
+}
+
+static void free_cs(struct cardstate *cs)
+{
+ unsigned long flags;
+ struct gigaset_driver *drv = cs->driver;
+ spin_lock_irqsave(&drv->lock, flags);
+ drv->flags[cs->minor_index] = 0;
+ spin_unlock_irqrestore(&drv->lock, flags);
+}
+
+static void make_valid(struct cardstate *cs, unsigned mask)
+{
+ unsigned long flags;
+ struct gigaset_driver *drv = cs->driver;
+ spin_lock_irqsave(&drv->lock, flags);
+ drv->flags[cs->minor_index] |= mask;
+ spin_unlock_irqrestore(&drv->lock, flags);
+}
+
+static void make_invalid(struct cardstate *cs, unsigned mask)
+{
+ unsigned long flags;
+ struct gigaset_driver *drv = cs->driver;
+ spin_lock_irqsave(&drv->lock, flags);
+ drv->flags[cs->minor_index] &= ~mask;
+ spin_unlock_irqrestore(&drv->lock, flags);
+}
+
void gigaset_freecs(struct cardstate *cs)
{
int i;
@@ -416,7 +443,7 @@ void gigaset_freecs(struct cardstate *cs)
if (!cs)
return;
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->bcs)
goto f_cs;
@@ -424,8 +451,9 @@ void gigaset_freecs(struct cardstate *cs)
goto f_bcs;
spin_lock_irqsave(&cs->lock, flags);
- atomic_set(&cs->running, 0);
- spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are not rescheduled below */
+ cs->running = 0;
+ spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are
+ not rescheduled below */
tasklet_kill(&cs->event_tasklet);
del_timer_sync(&cs->timer);
@@ -434,7 +462,7 @@ void gigaset_freecs(struct cardstate *cs)
default:
gigaset_if_free(cs);
- dbg(DEBUG_INIT, "clearing hw");
+ gig_dbg(DEBUG_INIT, "clearing hw");
cs->ops->freecshw(cs);
//FIXME cmdbuf
@@ -443,36 +471,36 @@ void gigaset_freecs(struct cardstate *cs)
case 2: /* error in initcshw */
/* Deregister from LL */
make_invalid(cs, VALID_ID);
- dbg(DEBUG_INIT, "clearing iif");
+ gig_dbg(DEBUG_INIT, "clearing iif");
gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD);
/* fall through */
case 1: /* error when regestering to LL */
- dbg(DEBUG_INIT, "clearing at_state");
+ gig_dbg(DEBUG_INIT, "clearing at_state");
clear_at_state(&cs->at_state);
dealloc_at_states(cs);
/* fall through */
case 0: /* error in one call to initbcs */
for (i = 0; i < cs->channels; ++i) {
- dbg(DEBUG_INIT, "clearing bcs[%d]", i);
+ gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
gigaset_freebcs(cs->bcs + i);
}
clear_events(cs);
- dbg(DEBUG_INIT, "freeing inbuf");
+ gig_dbg(DEBUG_INIT, "freeing inbuf");
kfree(cs->inbuf);
}
-f_bcs: dbg(DEBUG_INIT, "freeing bcs[]");
+f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
kfree(cs->bcs);
-f_cs: dbg(DEBUG_INIT, "freeing cs");
- up(&cs->sem);
+f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
+ mutex_unlock(&cs->mutex);
free_cs(cs);
}
EXPORT_SYMBOL_GPL(gigaset_freecs);
void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
- struct cardstate *cs, int cid)
+ struct cardstate *cs, int cid)
{
int i;
@@ -482,8 +510,8 @@ void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
at_state->pending_commands = 0;
at_state->timer_expires = 0;
at_state->timer_active = 0;
- atomic_set(&at_state->timer_index, 0);
- atomic_set(&at_state->seq_index, 0);
+ at_state->timer_index = 0;
+ at_state->seq_index = 0;
at_state->ConState = 0;
for (i = 0; i < STR_NUM; ++i)
at_state->str_var[i] = NULL;
@@ -501,7 +529,7 @@ void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs,
- struct cardstate *cs, int inputstate)
+ struct cardstate *cs, int inputstate)
/* inbuf->read must be allocated before! */
{
atomic_set(&inbuf->head, 0);
@@ -512,9 +540,50 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs,
inbuf->inputstate = inputstate;
}
+/* append received bytes to inbuf */
+int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
+ unsigned numbytes)
+{
+ unsigned n, head, tail, bytesleft;
+
+ gig_dbg(DEBUG_INTR, "received %u bytes", numbytes);
+
+ if (!numbytes)
+ return 0;
+
+ bytesleft = numbytes;
+ tail = atomic_read(&inbuf->tail);
+ head = atomic_read(&inbuf->head);
+ gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
+
+ while (bytesleft) {
+ if (head > tail)
+ n = head - 1 - tail;
+ else if (head == 0)
+ n = (RBUFSIZE-1) - tail;
+ else
+ n = RBUFSIZE - tail;
+ if (!n) {
+ dev_err(inbuf->cs->dev,
+ "buffer overflow (%u bytes lost)", bytesleft);
+ break;
+ }
+ if (n > bytesleft)
+ n = bytesleft;
+ memcpy(inbuf->data + tail, src, n);
+ bytesleft -= n;
+ tail = (tail + n) % RBUFSIZE;
+ src += n;
+ }
+ gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
+ atomic_set(&inbuf->tail, tail);
+ return numbytes != bytesleft;
+}
+EXPORT_SYMBOL_GPL(gigaset_fill_inbuf);
+
/* Initialize the b-channel structure */
static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
- struct cardstate *cs, int channel)
+ struct cardstate *cs, int channel)
{
int i;
@@ -526,7 +595,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
bcs->trans_down = 0;
bcs->trans_up = 0;
- dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel);
+ gig_dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel);
gigaset_at_init(&bcs->at_state, bcs, cs, -1);
bcs->rcvbytes = 0;
@@ -535,7 +604,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
bcs->emptycount = 0;
#endif
- dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel);
+ gig_dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel);
bcs->fcs = PPP_INITFCS;
bcs->inputstate = 0;
if (cs->ignoreframes) {
@@ -544,7 +613,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
} else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN);
else {
- warn("could not allocate skb");
+ dev_warn(cs->dev, "could not allocate skb\n");
bcs->inputstate |= INS_skip_frame;
}
@@ -559,14 +628,13 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
for (i = 0; i < AT_NUM; ++i)
bcs->commands[i] = NULL;
- dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
+ gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
if (cs->ops->initbcshw(bcs))
return bcs;
-//error:
- dbg(DEBUG_INIT, " failed");
+ gig_dbg(DEBUG_INIT, " failed");
- dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel);
+ gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel);
if (bcs->skb)
dev_kfree_skb(bcs->skb);
@@ -578,9 +646,10 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
* Calls hardware dependent gigaset_initcshw() function
* Calls B channel initialization function gigaset_initbcs() for each B channel
* parameters:
- * drv hardware driver the device belongs to
+ * drv hardware driver the device belongs to
* channels number of B channels supported by device
- * onechannel !=0: B channel data and AT commands share one communication channel
+ * onechannel !=0: B channel data and AT commands share one
+ * communication channel
* ==0: B channels have separate communication channels
* ignoreframes number of frames to ignore after setting up B channel
* cidmode !=0: start in CallID mode
@@ -593,17 +662,18 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
int cidmode, const char *modulename)
{
struct cardstate *cs = NULL;
+ unsigned long flags;
int i;
- dbg(DEBUG_INIT, "allocating cs");
+ gig_dbg(DEBUG_INIT, "allocating cs");
cs = alloc_cs(drv);
if (!cs)
goto error;
- dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
+ gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
if (!cs->bcs)
goto error;
- dbg(DEBUG_INIT, "allocating inbuf");
+ gig_dbg(DEBUG_INIT, "allocating inbuf");
cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
if (!cs->inbuf)
goto error;
@@ -613,19 +683,23 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->onechannel = onechannel;
cs->ignoreframes = ignoreframes;
INIT_LIST_HEAD(&cs->temp_at_states);
- atomic_set(&cs->running, 0);
+ cs->running = 0;
init_timer(&cs->timer); /* clear next & prev */
spin_lock_init(&cs->ev_lock);
- atomic_set(&cs->ev_tail, 0);
- atomic_set(&cs->ev_head, 0);
- init_MUTEX_LOCKED(&cs->sem);
- tasklet_init(&cs->event_tasklet, &gigaset_handle_event, (unsigned long) cs);
+ cs->ev_tail = 0;
+ cs->ev_head = 0;
+ mutex_init(&cs->mutex);
+ mutex_lock(&cs->mutex);
+
+ tasklet_init(&cs->event_tasklet, &gigaset_handle_event,
+ (unsigned long) cs);
atomic_set(&cs->commands_pending, 0);
cs->cur_at_seq = 0;
cs->gotfwver = -1;
cs->open_count = 0;
+ cs->dev = NULL;
cs->tty = NULL;
- atomic_set(&cs->cidmode, cidmode != 0);
+ cs->cidmode = cidmode != 0;
//if(onechannel) { //FIXME
cs->tabnocid = gigaset_tab_nocid_m10x;
@@ -642,50 +716,43 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
atomic_set(&cs->mstate, MS_UNINITIALIZED);
for (i = 0; i < channels; ++i) {
- dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
+ gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
if (!gigaset_initbcs(cs->bcs + i, cs, i))
goto error;
}
++cs->cs_init;
- dbg(DEBUG_INIT, "setting up at_state");
+ gig_dbg(DEBUG_INIT, "setting up at_state");
spin_lock_init(&cs->lock);
gigaset_at_init(&cs->at_state, NULL, cs, 0);
cs->dle = 0;
cs->cbytes = 0;
- dbg(DEBUG_INIT, "setting up inbuf");
+ gig_dbg(DEBUG_INIT, "setting up inbuf");
if (onechannel) { //FIXME distinction necessary?
gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command);
} else
gigaset_inbuf_init(cs->inbuf, NULL, cs, INS_command);
- atomic_set(&cs->connected, 0);
+ cs->connected = 0;
+ cs->isdn_up = 0;
- dbg(DEBUG_INIT, "setting up cmdbuf");
+ gig_dbg(DEBUG_INIT, "setting up cmdbuf");
cs->cmdbuf = cs->lastcmdbuf = NULL;
spin_lock_init(&cs->cmdlock);
cs->curlen = 0;
cs->cmdbytes = 0;
- /*
- * Tell the ISDN4Linux subsystem (the LL) that
- * a driver for a USB-Device is available !
- * If this is done, "isdnctrl" is able to bind a device for this driver even
- * if no physical usb-device is currently connected.
- * But this device will just be accessable if a physical USB device is connected
- * (via "gigaset_probe") .
- */
- dbg(DEBUG_INIT, "setting up iif");
+ gig_dbg(DEBUG_INIT, "setting up iif");
if (!gigaset_register_to_LL(cs, modulename)) {
- err("register_isdn=>error");
+ err("register_isdn failed");
goto error;
}
make_valid(cs, VALID_ID);
++cs->cs_init;
- dbg(DEBUG_INIT, "setting up hw");
+ gig_dbg(DEBUG_INIT, "setting up hw");
if (!cs->ops->initcshw(cs))
goto error;
@@ -693,27 +760,29 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
gigaset_if_init(cs);
- atomic_set(&cs->running, 1);
- cs->timer.data = (unsigned long) cs;
- cs->timer.function = timer_tick;
- cs->timer.expires = jiffies + GIG_TICK;
+ spin_lock_irqsave(&cs->lock, flags);
+ cs->running = 1;
+ spin_unlock_irqrestore(&cs->lock, flags);
+ setup_timer(&cs->timer, timer_tick, (unsigned long) cs);
+ cs->timer.expires = jiffies + msecs_to_jiffies(GIG_TICK);
/* FIXME: can jiffies increase too much until the timer is added?
* Same problem(?) with mod_timer() in timer_tick(). */
add_timer(&cs->timer);
- dbg(DEBUG_INIT, "cs initialized!");
- up(&cs->sem);
+ gig_dbg(DEBUG_INIT, "cs initialized");
+ mutex_unlock(&cs->mutex);
return cs;
error: if (cs)
- up(&cs->sem);
- dbg(DEBUG_INIT, "failed");
+ mutex_unlock(&cs->mutex);
+ gig_dbg(DEBUG_INIT, "failed");
gigaset_freecs(cs);
return NULL;
}
EXPORT_SYMBOL_GPL(gigaset_initcs);
-/* ReInitialize the b-channel structure */ /* e.g. called on hangup, disconnect */
+/* ReInitialize the b-channel structure */
+/* e.g. called on hangup, disconnect */
void gigaset_bcs_reinit(struct bc_state *bcs)
{
struct sk_buff *skb;
@@ -723,12 +792,12 @@ void gigaset_bcs_reinit(struct bc_state *bcs)
while ((skb = skb_dequeue(&bcs->squeue)) != NULL)
dev_kfree_skb(skb);
- spin_lock_irqsave(&cs->lock, flags); //FIXME
+ spin_lock_irqsave(&cs->lock, flags);
clear_at_state(&bcs->at_state);
bcs->at_state.ConState = 0;
bcs->at_state.timer_active = 0;
bcs->at_state.timer_expires = 0;
- bcs->at_state.cid = -1; /* No CID defined */
+ bcs->at_state.cid = -1; /* No CID defined */
spin_unlock_irqrestore(&cs->lock, flags);
bcs->inputstate = 0;
@@ -803,11 +872,14 @@ static void cleanup_cs(struct cardstate *cs)
int gigaset_start(struct cardstate *cs)
{
- if (down_interruptible(&cs->sem))
+ unsigned long flags;
+
+ if (mutex_lock_interruptible(&cs->mutex))
return 0;
- //info("USB device for Gigaset 307x now attached to Dev %d", ucs->minor);
- atomic_set(&cs->connected, 1);
+ spin_lock_irqsave(&cs->lock, flags);
+ cs->connected = 1;
+ spin_unlock_irqrestore(&cs->lock, flags);
if (atomic_read(&cs->mstate) != MS_LOCKED) {
cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
@@ -826,23 +898,26 @@ int gigaset_start(struct cardstate *cs)
goto error;
}
- dbg(DEBUG_CMD, "scheduling START");
+ gig_dbg(DEBUG_CMD, "scheduling START");
gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting);
- up(&cs->sem);
+ /* set up device sysfs */
+ gigaset_init_dev_sysfs(cs);
+
+ mutex_unlock(&cs->mutex);
return 1;
error:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return 0;
}
EXPORT_SYMBOL_GPL(gigaset_start);
void gigaset_shutdown(struct cardstate *cs)
{
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
cs->waiting = 1;
@@ -851,11 +926,11 @@ void gigaset_shutdown(struct cardstate *cs)
goto exit;
}
- dbg(DEBUG_CMD, "scheduling SHUTDOWN");
+ gig_dbg(DEBUG_CMD, "scheduling SHUTDOWN");
gigaset_schedule_event(cs);
if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
- warn("aborted");
+ warn("%s: aborted", __func__);
//FIXME
}
@@ -872,15 +947,13 @@ void gigaset_shutdown(struct cardstate *cs)
cleanup_cs(cs);
exit:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
EXPORT_SYMBOL_GPL(gigaset_shutdown);
void gigaset_stop(struct cardstate *cs)
{
- down(&cs->sem);
-
- atomic_set(&cs->connected, 0);
+ mutex_lock(&cs->mutex);
cs->waiting = 1;
@@ -889,21 +962,21 @@ void gigaset_stop(struct cardstate *cs)
goto exit;
}
- dbg(DEBUG_CMD, "scheduling STOP");
+ gig_dbg(DEBUG_CMD, "scheduling STOP");
gigaset_schedule_event(cs);
if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
- warn("aborted");
+ warn("%s: aborted", __func__);
//FIXME
}
- /* Tell the LL that the device is not available .. */
- gigaset_i4l_cmd(cs, ISDN_STAT_STOP); // FIXME move to event layer?
+ /* clear device sysfs */
+ gigaset_free_dev_sysfs(cs);
cleanup_cs(cs);
exit:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
EXPORT_SYMBOL_GPL(gigaset_stop);
@@ -947,31 +1020,25 @@ void gigaset_debugdrivers(void)
spin_lock_irqsave(&driver_lock, flags);
list_for_each_entry(drv, &drivers, list) {
- dbg(DEBUG_DRIVER, "driver %p", drv);
+ gig_dbg(DEBUG_DRIVER, "driver %p", drv);
spin_lock(&drv->lock);
for (i = 0; i < drv->minors; ++i) {
- dbg(DEBUG_DRIVER, " index %u", i);
- dbg(DEBUG_DRIVER, " flags 0x%02x", drv->flags[i]);
+ gig_dbg(DEBUG_DRIVER, " index %u", i);
+ gig_dbg(DEBUG_DRIVER, " flags 0x%02x",
+ drv->flags[i]);
cs = drv->cs + i;
- dbg(DEBUG_DRIVER, " cardstate %p", cs);
- dbg(DEBUG_DRIVER, " minor_index %u", cs->minor_index);
- dbg(DEBUG_DRIVER, " driver %p", cs->driver);
- dbg(DEBUG_DRIVER, " i4l id %d", cs->myid);
+ gig_dbg(DEBUG_DRIVER, " cardstate %p", cs);
+ gig_dbg(DEBUG_DRIVER, " minor_index %u",
+ cs->minor_index);
+ gig_dbg(DEBUG_DRIVER, " driver %p", cs->driver);
+ gig_dbg(DEBUG_DRIVER, " i4l id %d", cs->myid);
}
spin_unlock(&drv->lock);
}
spin_unlock_irqrestore(&driver_lock, flags);
}
-EXPORT_SYMBOL_GPL(gigaset_debugdrivers);
-
-struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty)
-{
- if (tty->index < 0 || tty->index >= tty->driver->num)
- return NULL;
- return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start);
-}
-struct cardstate *gigaset_get_cs_by_minor(unsigned minor)
+static struct cardstate *gigaset_get_cs_by_minor(unsigned minor)
{
unsigned long flags;
static struct cardstate *ret = NULL;
@@ -994,6 +1061,13 @@ struct cardstate *gigaset_get_cs_by_minor(unsigned minor)
return ret;
}
+struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty)
+{
+ if (tty->index < 0 || tty->index >= tty->driver->num)
+ return NULL;
+ return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start);
+}
+
void gigaset_freedriver(struct gigaset_driver *drv)
{
unsigned long flags;
@@ -1014,20 +1088,20 @@ EXPORT_SYMBOL_GPL(gigaset_freedriver);
/* gigaset_initdriver
* Allocate and initialize gigaset_driver structure. Initialize interface.
* parameters:
- * minor First minor number
- * minors Number of minors this driver can handle
- * procname Name of the driver (e.g. for /proc/tty/drivers, path in /proc/driver)
- * devname Name of the device files (prefix without minor number)
- * devfsname Devfs name of the device files without %d
+ * minor First minor number
+ * minors Number of minors this driver can handle
+ * procname Name of the driver
+ * devname Name of the device files (prefix without minor number)
+ * devfsname Devfs name of the device files without %d
* return value:
- * Pointer to the gigaset_driver structure on success, NULL on failure.
+ * Pointer to the gigaset_driver structure on success, NULL on failure.
*/
struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
- const char *procname,
- const char *devname,
- const char *devfsname,
- const struct gigaset_ops *ops,
- struct module *owner)
+ const char *procname,
+ const char *devname,
+ const char *devfsname,
+ const struct gigaset_ops *ops,
+ struct module *owner)
{
struct gigaset_driver *drv;
unsigned long flags;
@@ -1036,8 +1110,9 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
drv = kmalloc(sizeof *drv, GFP_KERNEL);
if (!drv)
return NULL;
+
if (!try_module_get(owner))
- return NULL;
+ goto out1;
drv->cs = NULL;
drv->have_tty = 0;
@@ -1051,10 +1126,11 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
if (!drv->cs)
- goto out1;
+ goto out2;
+
drv->flags = kmalloc(minors * sizeof *drv->flags, GFP_KERNEL);
if (!drv->flags)
- goto out2;
+ goto out3;
for (i = 0; i < minors; ++i) {
drv->flags[i] = 0;
@@ -1071,61 +1147,16 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
return drv;
-out2:
+out3:
kfree(drv->cs);
+out2:
+ module_put(owner);
out1:
kfree(drv);
- module_put(owner);
return NULL;
}
EXPORT_SYMBOL_GPL(gigaset_initdriver);
-static struct cardstate *alloc_cs(struct gigaset_driver *drv)
-{
- unsigned long flags;
- unsigned i;
- static struct cardstate *ret = NULL;
-
- spin_lock_irqsave(&drv->lock, flags);
- for (i = 0; i < drv->minors; ++i) {
- if (!(drv->flags[i] & VALID_MINOR)) {
- drv->flags[i] = VALID_MINOR;
- ret = drv->cs + i;
- }
- if (ret)
- break;
- }
- spin_unlock_irqrestore(&drv->lock, flags);
- return ret;
-}
-
-static void free_cs(struct cardstate *cs)
-{
- unsigned long flags;
- struct gigaset_driver *drv = cs->driver;
- spin_lock_irqsave(&drv->lock, flags);
- drv->flags[cs->minor_index] = 0;
- spin_unlock_irqrestore(&drv->lock, flags);
-}
-
-static void make_valid(struct cardstate *cs, unsigned mask)
-{
- unsigned long flags;
- struct gigaset_driver *drv = cs->driver;
- spin_lock_irqsave(&drv->lock, flags);
- drv->flags[cs->minor_index] |= mask;
- spin_unlock_irqrestore(&drv->lock, flags);
-}
-
-static void make_invalid(struct cardstate *cs, unsigned mask)
-{
- unsigned long flags;
- struct gigaset_driver *drv = cs->driver;
- spin_lock_irqsave(&drv->lock, flags);
- drv->flags[cs->minor_index] &= ~mask;
- spin_unlock_irqrestore(&drv->lock, flags);
-}
-
/* For drivers without fixed assignment device<->cardstate (usb) */
struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv)
{
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index fdcb80bb21c7c..1ba3424a286b6 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -1,7 +1,7 @@
/*
* Stuff used by all variants of the driver
*
- * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>,
+ * Copyright (c) 2001 by Stefan Eilers,
* Hansjoerg Lipp <hjlipp@web.de>,
* Tilman Schmidt <tilman@imap.cc>.
*
@@ -11,82 +11,78 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: ev-layer.c,v 1.4.2.18 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
/* ========================================================== */
/* bit masks for pending commands */
-#define PC_INIT 0x004
-#define PC_DLE0 0x008
-#define PC_DLE1 0x010
-#define PC_CID 0x080
-#define PC_NOCID 0x100
-#define PC_HUP 0x002
-#define PC_DIAL 0x001
-#define PC_ACCEPT 0x040
-#define PC_SHUTDOWN 0x020
-#define PC_CIDMODE 0x200
-#define PC_UMMODE 0x400
+#define PC_DIAL 0x001
+#define PC_HUP 0x002
+#define PC_INIT 0x004
+#define PC_DLE0 0x008
+#define PC_DLE1 0x010
+#define PC_SHUTDOWN 0x020
+#define PC_ACCEPT 0x040
+#define PC_CID 0x080
+#define PC_NOCID 0x100
+#define PC_CIDMODE 0x200
+#define PC_UMMODE 0x400
/* types of modem responses */
-#define RT_NOTHING 0
-#define RT_ZSAU 1
-#define RT_RING 2
-#define RT_NUMBER 3
-#define RT_STRING 4
-#define RT_HEX 5
-#define RT_ZCAU 6
+#define RT_NOTHING 0
+#define RT_ZSAU 1
+#define RT_RING 2
+#define RT_NUMBER 3
+#define RT_STRING 4
+#define RT_HEX 5
+#define RT_ZCAU 6
/* Possible ASCII responses */
-#define RSP_OK 0
-//#define RSP_BUSY 1
-//#define RSP_CONNECT 2
-#define RSP_ZGCI 3
-#define RSP_RING 4
-#define RSP_ZAOC 5
-#define RSP_ZCSTR 6
-#define RSP_ZCFGT 7
-#define RSP_ZCFG 8
-#define RSP_ZCCR 9
-#define RSP_EMPTY 10
-#define RSP_ZLOG 11
-#define RSP_ZCAU 12
-#define RSP_ZMWI 13
-#define RSP_ZABINFO 14
-#define RSP_ZSMLSTCHG 15
-#define RSP_VAR 100
-#define RSP_ZSAU (RSP_VAR + VAR_ZSAU)
-#define RSP_ZDLE (RSP_VAR + VAR_ZDLE)
-#define RSP_ZVLS (RSP_VAR + VAR_ZVLS)
-#define RSP_ZCTP (RSP_VAR + VAR_ZCTP)
-#define RSP_STR (RSP_VAR + VAR_NUM)
-#define RSP_NMBR (RSP_STR + STR_NMBR)
-#define RSP_ZCPN (RSP_STR + STR_ZCPN)
-#define RSP_ZCON (RSP_STR + STR_ZCON)
-#define RSP_ZBC (RSP_STR + STR_ZBC)
-#define RSP_ZHLC (RSP_STR + STR_ZHLC)
-#define RSP_ERROR -1 /* ERROR */
-#define RSP_WRONG_CID -2 /* unknown cid in cmd */
-//#define RSP_EMPTY -3
-#define RSP_UNKNOWN -4 /* unknown response */
-#define RSP_FAIL -5 /* internal error */
-#define RSP_INVAL -6 /* invalid response */
-
-#define RSP_NONE -19
-#define RSP_STRING -20
-#define RSP_NULL -21
-//#define RSP_RETRYFAIL -22
-//#define RSP_RETRY -23
-//#define RSP_SKIP -24
-#define RSP_INIT -27
-#define RSP_ANY -26
-#define RSP_LAST -28
-#define RSP_NODEV -9
+#define RSP_OK 0
+//#define RSP_BUSY 1
+//#define RSP_CONNECT 2
+#define RSP_ZGCI 3
+#define RSP_RING 4
+#define RSP_ZAOC 5
+#define RSP_ZCSTR 6
+#define RSP_ZCFGT 7
+#define RSP_ZCFG 8
+#define RSP_ZCCR 9
+#define RSP_EMPTY 10
+#define RSP_ZLOG 11
+#define RSP_ZCAU 12
+#define RSP_ZMWI 13
+#define RSP_ZABINFO 14
+#define RSP_ZSMLSTCHG 15
+#define RSP_VAR 100
+#define RSP_ZSAU (RSP_VAR + VAR_ZSAU)
+#define RSP_ZDLE (RSP_VAR + VAR_ZDLE)
+#define RSP_ZVLS (RSP_VAR + VAR_ZVLS)
+#define RSP_ZCTP (RSP_VAR + VAR_ZCTP)
+#define RSP_STR (RSP_VAR + VAR_NUM)
+#define RSP_NMBR (RSP_STR + STR_NMBR)
+#define RSP_ZCPN (RSP_STR + STR_ZCPN)
+#define RSP_ZCON (RSP_STR + STR_ZCON)
+#define RSP_ZBC (RSP_STR + STR_ZBC)
+#define RSP_ZHLC (RSP_STR + STR_ZHLC)
+#define RSP_ERROR -1 /* ERROR */
+#define RSP_WRONG_CID -2 /* unknown cid in cmd */
+//#define RSP_EMPTY -3
+#define RSP_UNKNOWN -4 /* unknown response */
+#define RSP_FAIL -5 /* internal error */
+#define RSP_INVAL -6 /* invalid response */
+
+#define RSP_NONE -19
+#define RSP_STRING -20
+#define RSP_NULL -21
+//#define RSP_RETRYFAIL -22
+//#define RSP_RETRY -23
+//#define RSP_SKIP -24
+#define RSP_INIT -27
+#define RSP_ANY -26
+#define RSP_LAST -28
+#define RSP_NODEV -9
/* actions for process_response */
#define ACT_NOTHING 0
@@ -112,7 +108,7 @@
#define ACT_DISCONNECT 20
#define ACT_CONNECT 21
#define ACT_REMOTEREJECT 22
-#define ACT_CONNTIMEOUT 23
+#define ACT_CONNTIMEOUT 23
#define ACT_REMOTEHUP 24
#define ACT_ABORTHUP 25
#define ACT_ICALL 26
@@ -127,40 +123,40 @@
#define ACT_ERROR 35
#define ACT_ABORTCID 36
#define ACT_ZCAU 37
-#define ACT_NOTIFY_BC_DOWN 38
-#define ACT_NOTIFY_BC_UP 39
-#define ACT_DIAL 40
-#define ACT_ACCEPT 41
-#define ACT_PROTO_L2 42
-#define ACT_HUP 43
-#define ACT_IF_LOCK 44
-#define ACT_START 45
-#define ACT_STOP 46
-#define ACT_FAKEDLE0 47
-#define ACT_FAKEHUP 48
-#define ACT_FAKESDOWN 49
-#define ACT_SHUTDOWN 50
-#define ACT_PROC_CIDMODE 51
-#define ACT_UMODESET 52
-#define ACT_FAILUMODE 53
-#define ACT_CMODESET 54
-#define ACT_FAILCMODE 55
-#define ACT_IF_VER 56
+#define ACT_NOTIFY_BC_DOWN 38
+#define ACT_NOTIFY_BC_UP 39
+#define ACT_DIAL 40
+#define ACT_ACCEPT 41
+#define ACT_PROTO_L2 42
+#define ACT_HUP 43
+#define ACT_IF_LOCK 44
+#define ACT_START 45
+#define ACT_STOP 46
+#define ACT_FAKEDLE0 47
+#define ACT_FAKEHUP 48
+#define ACT_FAKESDOWN 49
+#define ACT_SHUTDOWN 50
+#define ACT_PROC_CIDMODE 51
+#define ACT_UMODESET 52
+#define ACT_FAILUMODE 53
+#define ACT_CMODESET 54
+#define ACT_FAILCMODE 55
+#define ACT_IF_VER 56
#define ACT_CMD 100
/* at command sequences */
-#define SEQ_NONE 0
-#define SEQ_INIT 100
-#define SEQ_DLE0 200
-#define SEQ_DLE1 250
-#define SEQ_CID 300
-#define SEQ_NOCID 350
-#define SEQ_HUP 400
-#define SEQ_DIAL 600
-#define SEQ_ACCEPT 720
-#define SEQ_SHUTDOWN 500
-#define SEQ_CIDMODE 10
-#define SEQ_UMMODE 11
+#define SEQ_NONE 0
+#define SEQ_INIT 100
+#define SEQ_DLE0 200
+#define SEQ_DLE1 250
+#define SEQ_CID 300
+#define SEQ_NOCID 350
+#define SEQ_HUP 400
+#define SEQ_DIAL 600
+#define SEQ_ACCEPT 720
+#define SEQ_SHUTDOWN 500
+#define SEQ_CIDMODE 10
+#define SEQ_UMMODE 11
// 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid), 400: hup, 500: reset, 600: dial, 700: ring
@@ -175,7 +171,7 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
// {ACT_TIMEOUT}},
{RSP_INIT, -1, -1,SEQ_INIT, 100, INIT_TIMEOUT,
- {ACT_TIMEOUT}}, /* wait until device is ready */
+ {ACT_TIMEOUT}}, /* wait until device is ready */
{EV_TIMEOUT, 100,100, -1, 101, 3, {0}, "Z\r"}, /* device in transparent mode? try to initialize it. */
{RSP_OK, 101,103, -1, 120, 5, {ACT_GETSTRING}, "+GMR\r"}, /* get version */
@@ -190,8 +186,8 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
{RSP_ERROR, 108,108, -1, 0, 0, {ACT_FAILINIT}},
{EV_TIMEOUT, 108,108, -1, 105, 2, {ACT_SETDLE0,
- ACT_HUPMODEM,
- ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */
+ ACT_HUPMODEM,
+ ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */
{EV_TIMEOUT, 105,105, -1, 103, 5, {0}, "Z\r"},
{RSP_ERROR, 102,102, -1, 107, 5, {0}, "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */
@@ -393,7 +389,7 @@ struct reply_t gigaset_tab_cid_m10x[] = /* for M10x */
#if 0
-static struct reply_t tab_nocid[]= /* no dle mode */ //FIXME aenderungen uebernehmen
+static struct reply_t tab_nocid[]= /* no dle mode */ //FIXME
{
/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
@@ -401,7 +397,7 @@ static struct reply_t tab_nocid[]= /* no dle mode */ //FIXME aenderungen ueberne
{RSP_LAST,0,0,0,0,0,0}
};
-static struct reply_t tab_cid[] = /* no dle mode */ //FIXME aenderungen uebernehmen
+static struct reply_t tab_cid[] = /* no dle mode */ //FIXME
{
/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
@@ -412,30 +408,30 @@ static struct reply_t tab_cid[] = /* no dle mode */ //FIXME aenderungen ueberneh
static struct resp_type_t resp_type[]=
{
- /*{"", RSP_EMPTY, RT_NOTHING},*/
- {"OK", RSP_OK, RT_NOTHING},
- {"ERROR", RSP_ERROR, RT_NOTHING},
- {"ZSAU", RSP_ZSAU, RT_ZSAU},
- {"ZCAU", RSP_ZCAU, RT_ZCAU},
- {"RING", RSP_RING, RT_RING},
- {"ZGCI", RSP_ZGCI, RT_NUMBER},
- {"ZVLS", RSP_ZVLS, RT_NUMBER},
- {"ZCTP", RSP_ZCTP, RT_NUMBER},
- {"ZDLE", RSP_ZDLE, RT_NUMBER},
- {"ZCFGT", RSP_ZCFGT, RT_NUMBER},
- {"ZCCR", RSP_ZCCR, RT_NUMBER},
- {"ZMWI", RSP_ZMWI, RT_NUMBER},
- {"ZHLC", RSP_ZHLC, RT_STRING},
- {"ZBC", RSP_ZBC, RT_STRING},
- {"NMBR", RSP_NMBR, RT_STRING},
- {"ZCPN", RSP_ZCPN, RT_STRING},
- {"ZCON", RSP_ZCON, RT_STRING},
- {"ZAOC", RSP_ZAOC, RT_STRING},
- {"ZCSTR", RSP_ZCSTR, RT_STRING},
- {"ZCFG", RSP_ZCFG, RT_HEX},
- {"ZLOG", RSP_ZLOG, RT_NOTHING},
- {"ZABINFO", RSP_ZABINFO, RT_NOTHING},
- {"ZSMLSTCHG", RSP_ZSMLSTCHG, RT_NOTHING},
+ /*{"", RSP_EMPTY, RT_NOTHING},*/
+ {"OK", RSP_OK, RT_NOTHING},
+ {"ERROR", RSP_ERROR, RT_NOTHING},
+ {"ZSAU", RSP_ZSAU, RT_ZSAU},
+ {"ZCAU", RSP_ZCAU, RT_ZCAU},
+ {"RING", RSP_RING, RT_RING},
+ {"ZGCI", RSP_ZGCI, RT_NUMBER},
+ {"ZVLS", RSP_ZVLS, RT_NUMBER},
+ {"ZCTP", RSP_ZCTP, RT_NUMBER},
+ {"ZDLE", RSP_ZDLE, RT_NUMBER},
+ {"ZCFGT", RSP_ZCFGT, RT_NUMBER},
+ {"ZCCR", RSP_ZCCR, RT_NUMBER},
+ {"ZMWI", RSP_ZMWI, RT_NUMBER},
+ {"ZHLC", RSP_ZHLC, RT_STRING},
+ {"ZBC", RSP_ZBC, RT_STRING},
+ {"NMBR", RSP_NMBR, RT_STRING},
+ {"ZCPN", RSP_ZCPN, RT_STRING},
+ {"ZCON", RSP_ZCON, RT_STRING},
+ {"ZAOC", RSP_ZAOC, RT_STRING},
+ {"ZCSTR", RSP_ZCSTR, RT_STRING},
+ {"ZCFG", RSP_ZCFG, RT_HEX},
+ {"ZLOG", RSP_ZLOG, RT_NOTHING},
+ {"ZABINFO", RSP_ZABINFO, RT_NOTHING},
+ {"ZSMLSTCHG", RSP_ZSMLSTCHG, RT_NOTHING},
{NULL,0,0}
};
@@ -446,9 +442,7 @@ static int isdn_getnum(char *p)
{
int v = -1;
- IFNULLRETVAL(p, -1);
-
- dbg(DEBUG_TRANSCMD, "string: %s", p);
+ gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
while (*p >= '0' && *p <= '9')
v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
@@ -465,9 +459,7 @@ static int isdn_gethex(char *p)
int v = 0;
int c;
- IFNULLRETVAL(p, -1);
-
- dbg(DEBUG_TRANSCMD, "string: %s", p);
+ gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
if (!*p)
return -1;
@@ -490,14 +482,6 @@ static int isdn_gethex(char *p)
return v;
}
-static inline void new_index(atomic_t *index, int max)
-{
- if (atomic_read(index) == max) //FIXME race?
- atomic_set(index, 0);
- else
- atomic_inc(index);
-}
-
/* retrieve CID from parsed response
* returns 0 if no CID, -1 if invalid CID, or CID value 1..65535
*/
@@ -536,16 +520,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
int cid;
int rawstring;
- IFNULLRET(cs);
-
len = cs->cbytes;
if (!len) {
/* ignore additional LFs/CRs (M10x config mode or cx100) */
- dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]);
+ gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]);
return;
}
cs->respdata[len] = 0;
- dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata);
+ gig_dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata);
argv[0] = cs->respdata;
params = 1;
if (cs->at_state.getstring) {
@@ -561,7 +543,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
case ',':
case '=':
if (params > MAX_REC_PARAMS) {
- warn("too many parameters in response");
+ dev_warn(cs->dev,
+ "too many parameters in response\n");
/* need last parameter (might be CID) */
params--;
}
@@ -572,33 +555,33 @@ void gigaset_handle_modem_response(struct cardstate *cs)
cid = params > 1 ? cid_of_response(argv[params-1]) : 0;
if (cid < 0) {
gigaset_add_event(cs, &cs->at_state, RSP_INVAL,
- NULL, 0, NULL);
+ NULL, 0, NULL);
return;
}
for (j = 1; j < params; ++j)
argv[j][-1] = 0;
- dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
+ gig_dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
if (cid) {
--params;
- dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]);
+ gig_dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]);
}
- dbg(DEBUG_TRANSCMD, "available params: %d", params - 1);
+ gig_dbg(DEBUG_TRANSCMD, "available params: %d", params - 1);
for (j = 1; j < params; j++)
- dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]);
+ gig_dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]);
}
spin_lock_irqsave(&cs->ev_lock, flags);
- head = atomic_read(&cs->ev_head);
- tail = atomic_read(&cs->ev_tail);
+ head = cs->ev_head;
+ tail = cs->ev_tail;
abort = 1;
curarg = 0;
while (curarg < params) {
next = (tail + 1) % MAX_EVENTS;
if (unlikely(next == head)) {
- err("event queue full");
+ dev_err(cs->dev, "event queue full\n");
break;
}
@@ -619,8 +602,9 @@ void gigaset_handle_modem_response(struct cardstate *cs)
if (!rt->response) {
event->type = RSP_UNKNOWN;
- warn("unknown modem response: %s",
- argv[curarg]);
+ dev_warn(cs->dev,
+ "unknown modem response: %s\n",
+ argv[curarg]);
break;
}
@@ -636,7 +620,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
break;
case RT_RING:
if (!cid) {
- err("received RING without CID!");
+ dev_err(cs->dev,
+ "received RING without CID!\n");
event->type = RSP_INVAL;
abort = 1;
} else {
@@ -664,27 +649,25 @@ void gigaset_handle_modem_response(struct cardstate *cs)
event->parameter = ZSAU_DISCONNECT_REQ;
else {
event->parameter = ZSAU_UNKNOWN;
- warn("%s: unknown parameter %s after ZSAU",
- __func__, argv[curarg]);
+ dev_warn(cs->dev,
+ "%s: unknown parameter %s after ZSAU\n",
+ __func__, argv[curarg]);
}
++curarg;
break;
case RT_STRING:
if (curarg < params) {
- len = strlen(argv[curarg]) + 1;
- event->ptr = kmalloc(len, GFP_ATOMIC);
- if (event->ptr)
- memcpy(event->ptr, argv[curarg], len);
- else
- err("no memory for string!");
+ event->ptr = kstrdup(argv[curarg], GFP_ATOMIC);
+ if (!event->ptr)
+ dev_err(cs->dev, "out of memory\n");
++curarg;
}
#ifdef CONFIG_GIGASET_DEBUG
if (!event->ptr)
- dbg(DEBUG_CMD, "string==NULL");
+ gig_dbg(DEBUG_CMD, "string==NULL");
else
- dbg(DEBUG_CMD,
- "string==%s", (char *) event->ptr);
+ gig_dbg(DEBUG_CMD, "string==%s",
+ (char *) event->ptr);
#endif
break;
case RT_ZCAU:
@@ -694,7 +677,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
j = isdn_gethex(argv[curarg + 1]);
if (i >= 0 && i < 256 && j >= 0 && j < 256)
event->parameter = (unsigned) i << 8
- | j;
+ | j;
curarg += 2;
} else
curarg = params - 1;
@@ -712,7 +695,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
} else
event->parameter = -1;
#ifdef CONFIG_GIGASET_DEBUG
- dbg(DEBUG_CMD, "parameter==%d", event->parameter);
+ gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter);
#endif
break;
}
@@ -724,12 +707,13 @@ void gigaset_handle_modem_response(struct cardstate *cs)
break;
}
- atomic_set(&cs->ev_tail, tail);
+ cs->ev_tail = tail;
spin_unlock_irqrestore(&cs->ev_lock, flags);
if (curarg != params)
- dbg(DEBUG_ANY, "invalid number of processed parameters: %d/%d",
- curarg, params);
+ gig_dbg(DEBUG_ANY,
+ "invalid number of processed parameters: %d/%d",
+ curarg, params);
}
EXPORT_SYMBOL_GPL(gigaset_handle_modem_response);
@@ -739,23 +723,19 @@ EXPORT_SYMBOL_GPL(gigaset_handle_modem_response);
static void disconnect(struct at_state_t **at_state_p)
{
unsigned long flags;
- struct bc_state *bcs;
- struct cardstate *cs;
+ struct bc_state *bcs = (*at_state_p)->bcs;
+ struct cardstate *cs = (*at_state_p)->cs;
- IFNULLRET(at_state_p);
- IFNULLRET(*at_state_p);
- bcs = (*at_state_p)->bcs;
- cs = (*at_state_p)->cs;
- IFNULLRET(cs);
-
- new_index(&(*at_state_p)->seq_index, MAX_SEQ_INDEX);
+ spin_lock_irqsave(&cs->lock, flags);
+ ++(*at_state_p)->seq_index;
/* revert to selected idle mode */
- if (!atomic_read(&cs->cidmode)) {
+ if (!cs->cidmode) {
cs->at_state.pending_commands |= PC_UMMODE;
atomic_set(&cs->commands_pending, 1); //FIXME
- dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
+ gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
}
+ spin_unlock_irqrestore(&cs->lock, flags);
if (bcs) {
/* B channel assigned: invoke hardware specific handler */
@@ -777,7 +757,7 @@ static void disconnect(struct at_state_t **at_state_p)
* The structure should be freed by calling disconnect() after use.
*/
static inline struct at_state_t *get_free_channel(struct cardstate *cs,
- int cid)
+ int cid)
/* cids: >0: siemens-cid
0: without cid
-1: no cid assigned yet
@@ -826,7 +806,7 @@ static void init_failed(struct cardstate *cs, int mode)
static void schedule_init(struct cardstate *cs, int state)
{
if (cs->at_state.pending_commands & PC_INIT) {
- dbg(DEBUG_CMD, "not scheduling PC_INIT again");
+ gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again");
return;
}
atomic_set(&cs->mstate, state);
@@ -834,52 +814,56 @@ static void schedule_init(struct cardstate *cs, int state)
gigaset_block_channels(cs);
cs->at_state.pending_commands |= PC_INIT;
atomic_set(&cs->commands_pending, 1);
- dbg(DEBUG_CMD, "Scheduling PC_INIT");
+ gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
}
-/* Add "AT" to a command, add the cid, dle encode it, send the result to the hardware. */
+/* Add "AT" to a command, add the cid, dle encode it, send the result to the
+ hardware. */
static void send_command(struct cardstate *cs, const char *cmd, int cid,
- int dle, gfp_t kmallocflags)
+ int dle, gfp_t kmallocflags)
{
size_t cmdlen, buflen;
char *cmdpos, *cmdbuf, *cmdtail;
cmdlen = strlen(cmd);
buflen = 11 + cmdlen;
+ if (unlikely(buflen <= cmdlen)) {
+ dev_err(cs->dev, "integer overflow in buflen\n");
+ return;
+ }
- if (likely(buflen > cmdlen)) {
- cmdbuf = kmalloc(buflen, kmallocflags);
- if (likely(cmdbuf != NULL)) {
- cmdpos = cmdbuf + 9;
- cmdtail = cmdpos + cmdlen;
- memcpy(cmdpos, cmd, cmdlen);
-
- if (cid > 0 && cid <= 65535) {
- do {
- *--cmdpos = '0' + cid % 10;
- cid /= 10;
- ++cmdlen;
- } while (cid);
- }
+ cmdbuf = kmalloc(buflen, kmallocflags);
+ if (unlikely(!cmdbuf)) {
+ dev_err(cs->dev, "out of memory\n");
+ return;
+ }
- cmdlen += 2;
- *--cmdpos = 'T';
- *--cmdpos = 'A';
+ cmdpos = cmdbuf + 9;
+ cmdtail = cmdpos + cmdlen;
+ memcpy(cmdpos, cmd, cmdlen);
- if (dle) {
- cmdlen += 4;
- *--cmdpos = '(';
- *--cmdpos = 0x10;
- *cmdtail++ = 0x10;
- *cmdtail++ = ')';
- }
+ if (cid > 0 && cid <= 65535) {
+ do {
+ *--cmdpos = '0' + cid % 10;
+ cid /= 10;
+ ++cmdlen;
+ } while (cid);
+ }
- cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL);
- kfree(cmdbuf);
- } else
- err("no memory for command buffer");
- } else
- err("overflow in buflen");
+ cmdlen += 2;
+ *--cmdpos = 'T';
+ *--cmdpos = 'A';
+
+ if (dle) {
+ cmdlen += 4;
+ *--cmdpos = '(';
+ *--cmdpos = 0x10;
+ *cmdtail++ = 0x10;
+ *cmdtail++ = ')';
+ }
+
+ cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL);
+ kfree(cmdbuf);
}
static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid)
@@ -910,9 +894,6 @@ static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid)
static void bchannel_down(struct bc_state *bcs)
{
- IFNULLRET(bcs);
- IFNULLRET(bcs->cs);
-
if (bcs->chstate & CHS_B_UP) {
bcs->chstate &= ~CHS_B_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BHUP);
@@ -930,16 +911,15 @@ static void bchannel_down(struct bc_state *bcs)
static void bchannel_up(struct bc_state *bcs)
{
- IFNULLRET(bcs);
-
if (!(bcs->chstate & CHS_D_UP)) {
- notice("%s: D channel not up", __func__);
+ dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
bcs->chstate |= CHS_D_UP;
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
}
if (bcs->chstate & CHS_B_UP) {
- notice("%s: B channel already up", __func__);
+ dev_notice(bcs->cs->dev, "%s: B channel already up\n",
+ __func__);
return;
}
@@ -947,17 +927,21 @@ static void bchannel_up(struct bc_state *bcs)
gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BCONN);
}
-static void start_dial(struct at_state_t *at_state, void *data, int seq_index)
+static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index)
{
struct bc_state *bcs = at_state->bcs;
struct cardstate *cs = at_state->cs;
int retval;
+ unsigned long flags;
bcs->chstate |= CHS_NOTIFY_LL;
- //atomic_set(&bcs->status, BCS_INIT);
- if (atomic_read(&at_state->seq_index) != seq_index)
+ spin_lock_irqsave(&cs->lock, flags);
+ if (at_state->seq_index != seq_index) {
+ spin_unlock_irqrestore(&cs->lock, flags);
goto error;
+ }
+ spin_unlock_irqrestore(&cs->lock, flags);
retval = gigaset_isdn_setup_dial(at_state, data);
if (retval != 0)
@@ -965,20 +949,14 @@ static void start_dial(struct at_state_t *at_state, void *data, int seq_index)
at_state->pending_commands |= PC_CID;
- dbg(DEBUG_CMD, "Scheduling PC_CID");
-//#ifdef GIG_MAYINITONDIAL
-// if (atomic_read(&cs->MState) == MS_UNKNOWN) {
-// cs->at_state.pending_commands |= PC_INIT;
-// dbg(DEBUG_CMD, "Scheduling PC_INIT");
-// }
-//#endif
- atomic_set(&cs->commands_pending, 1); //FIXME
+ gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
+ atomic_set(&cs->commands_pending, 1);
return;
error:
at_state->pending_commands |= PC_NOCID;
- dbg(DEBUG_CMD, "Scheduling PC_NOCID");
- atomic_set(&cs->commands_pending, 1); //FIXME
+ gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
+ atomic_set(&cs->commands_pending, 1);
return;
}
@@ -991,13 +969,13 @@ static void start_accept(struct at_state_t *at_state)
if (retval == 0) {
at_state->pending_commands |= PC_ACCEPT;
- dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
- atomic_set(&cs->commands_pending, 1); //FIXME
+ gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
+ atomic_set(&cs->commands_pending, 1);
} else {
//FIXME
at_state->pending_commands |= PC_HUP;
- dbg(DEBUG_CMD, "Scheduling PC_HUP");
- atomic_set(&cs->commands_pending, 1); //FIXME
+ gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
+ atomic_set(&cs->commands_pending, 1);
}
}
@@ -1008,9 +986,10 @@ static void do_start(struct cardstate *cs)
if (atomic_read(&cs->mstate) != MS_LOCKED)
schedule_init(cs, MS_INIT);
+ cs->isdn_up = 1;
gigaset_i4l_cmd(cs, ISDN_STAT_RUN);
- // FIXME: not in locked mode
- // FIXME 2: only after init sequence
+ // FIXME: not in locked mode
+ // FIXME 2: only after init sequence
cs->waiting = 0;
wake_up(&cs->waitqueue);
@@ -1023,6 +1002,12 @@ static void finish_shutdown(struct cardstate *cs)
atomic_set(&cs->mode, M_UNKNOWN);
}
+ /* Tell the LL that the device is not available .. */
+ if (cs->isdn_up) {
+ cs->isdn_up = 0;
+ gigaset_i4l_cmd(cs, ISDN_STAT_STOP);
+ }
+
/* The rest is done by cleanup_cs () in user mode. */
cs->cmd_result = -ENODEV;
@@ -1037,15 +1022,20 @@ static void do_shutdown(struct cardstate *cs)
if (atomic_read(&cs->mstate) == MS_READY) {
atomic_set(&cs->mstate, MS_SHUTDOWN);
cs->at_state.pending_commands |= PC_SHUTDOWN;
- atomic_set(&cs->commands_pending, 1); //FIXME
- dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN"); //FIXME
- //gigaset_schedule_event(cs); //FIXME
+ atomic_set(&cs->commands_pending, 1);
+ gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
} else
finish_shutdown(cs);
}
static void do_stop(struct cardstate *cs)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&cs->lock, flags);
+ cs->connected = 0;
+ spin_unlock_irqrestore(&cs->lock, flags);
+
do_shutdown(cs);
}
@@ -1069,9 +1059,11 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
return 0;
if (channel < 0)
- warn("Could not enter cid mode. Reinit device and try again.");
+ dev_warn(cs->dev,
+ "Could not enter cid mode. Reinit device and try again.\n");
else {
- warn("Could not get a call id. Reinit device and try again.");
+ dev_warn(cs->dev,
+ "Could not get a call id. Reinit device and try again.\n");
cs->bcs[channel].at_state.pending_commands |= PC_CID;
}
schedule_init(cs, MS_INIT);
@@ -1079,7 +1071,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
}
static int at_state_invalid(struct cardstate *cs,
- struct at_state_t *test_ptr)
+ struct at_state_t *test_ptr)
{
unsigned long flags;
unsigned channel;
@@ -1116,7 +1108,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
case ICALL_ACCEPT:
break;
default:
- err("internal error: disposition=%d", retval);
+ dev_err(cs->dev, "internal error: disposition=%d\n", retval);
/* --v-- fall through --v-- */
case ICALL_IGNORE:
case ICALL_REJECT:
@@ -1160,7 +1152,6 @@ static int do_lock(struct cardstate *cs)
mode = atomic_read(&cs->mode);
atomic_set(&cs->mstate, MS_LOCKED);
atomic_set(&cs->mode, M_UNKNOWN);
- //FIXME reset card state / at states / bcs states
return mode;
}
@@ -1173,8 +1164,7 @@ static int do_unlock(struct cardstate *cs)
atomic_set(&cs->mstate, MS_UNINITIALIZED);
atomic_set(&cs->mode, M_UNKNOWN);
gigaset_free_channels(cs);
- //FIXME reset card state / at states / bcs states
- if (atomic_read(&cs->connected))
+ if (cs->connected)
schedule_init(cs, MS_INIT);
return 0;
@@ -1203,21 +1193,23 @@ static void do_action(int action, struct cardstate *cs,
at_state->waiting = 1;
break;
case ACT_INIT:
- //FIXME setup everything
cs->at_state.pending_commands &= ~PC_INIT;
cs->cur_at_seq = SEQ_NONE;
atomic_set(&cs->mode, M_UNIMODEM);
- if (!atomic_read(&cs->cidmode)) {
+ spin_lock_irqsave(&cs->lock, flags);
+ if (!cs->cidmode) {
+ spin_unlock_irqrestore(&cs->lock, flags);
gigaset_free_channels(cs);
atomic_set(&cs->mstate, MS_READY);
break;
}
+ spin_unlock_irqrestore(&cs->lock, flags);
cs->at_state.pending_commands |= PC_CIDMODE;
- atomic_set(&cs->commands_pending, 1); //FIXME
- dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
+ atomic_set(&cs->commands_pending, 1);
+ gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
break;
case ACT_FAILINIT:
- warn("Could not initialize the device.");
+ dev_warn(cs->dev, "Could not initialize the device.\n");
cs->dle = 0;
init_failed(cs, M_UNKNOWN);
cs->cur_at_seq = SEQ_NONE;
@@ -1273,8 +1265,8 @@ static void do_action(int action, struct cardstate *cs,
/* get fresh AT state structure for new CID */
at_state2 = get_free_channel(cs, ev->parameter);
if (!at_state2) {
- warn("RING ignored: "
- "could not allocate channel structure");
+ dev_warn(cs->dev,
+ "RING ignored: could not allocate channel structure\n");
break;
}
@@ -1302,7 +1294,7 @@ static void do_action(int action, struct cardstate *cs,
at_state = *p_at_state;
break;
case ACT_FAILSDOWN:
- warn("Could not shut down the device.");
+ dev_warn(cs->dev, "Could not shut down the device.\n");
/* fall through */
case ACT_FAKESDOWN:
case ACT_SDOWN:
@@ -1355,7 +1347,7 @@ static void do_action(int action, struct cardstate *cs,
break;
case ACT_ABORTHUP:
cs->cur_at_seq = SEQ_NONE;
- warn("Could not hang up.");
+ dev_warn(cs->dev, "Could not hang up.\n");
at_state->cid = -1;
if (bcs && cs->onechannel)
at_state->pending_commands |= PC_DLE0;
@@ -1367,14 +1359,15 @@ static void do_action(int action, struct cardstate *cs,
break;
case ACT_FAILDLE0:
cs->cur_at_seq = SEQ_NONE;
- warn("Could not leave DLE mode.");
+ dev_warn(cs->dev, "Could not leave DLE mode.\n");
at_state2 = &cs->bcs[cs->curchannel].at_state;
disconnect(&at_state2);
schedule_init(cs, MS_RECOVER);
break;
case ACT_FAILDLE1:
cs->cur_at_seq = SEQ_NONE;
- warn("Could not enter DLE mode. Try to hang up.");
+ dev_warn(cs->dev,
+ "Could not enter DLE mode. Trying to hang up.\n");
channel = cs->curchannel;
cs->bcs[channel].at_state.pending_commands |= PC_HUP;
atomic_set(&cs->commands_pending, 1);
@@ -1395,7 +1388,8 @@ static void do_action(int action, struct cardstate *cs,
cs->cur_at_seq = SEQ_NONE;
channel = cs->curchannel;
if (!reinit_and_retry(cs, channel)) {
- warn("Could not get a call id. Dialing not possible");
+ dev_warn(cs->dev,
+ "Could not get a call ID. Cannot dial.\n");
at_state2 = &cs->bcs[channel].at_state;
disconnect(&at_state2);
}
@@ -1428,7 +1422,8 @@ static void do_action(int action, struct cardstate *cs,
at_state->pending_commands |= PC_HUP;
atomic_set(&cs->commands_pending, 1);
break;
- case ACT_GETSTRING: /* warning: RING, ZDLE, ... are not handled properly any more */
+ case ACT_GETSTRING: /* warning: RING, ZDLE, ...
+ are not handled properly anymore */
at_state->getstring = 1;
break;
case ACT_SETVER:
@@ -1469,16 +1464,16 @@ static void do_action(int action, struct cardstate *cs,
case ACT_GOTVER:
if (cs->gotfwver == 0) {
cs->gotfwver = 1;
- dbg(DEBUG_ANY,
- "firmware version %02d.%03d.%02d.%02d",
- cs->fwver[0], cs->fwver[1],
- cs->fwver[2], cs->fwver[3]);
+ gig_dbg(DEBUG_ANY,
+ "firmware version %02d.%03d.%02d.%02d",
+ cs->fwver[0], cs->fwver[1],
+ cs->fwver[2], cs->fwver[3]);
break;
}
/* fall through */
case ACT_FAILVER:
cs->gotfwver = -1;
- err("could not read firmware version.");
+ dev_err(cs->dev, "could not read firmware version.\n");
break;
#ifdef CONFIG_GIGASET_DEBUG
case ACT_ERROR:
@@ -1496,16 +1491,16 @@ static void do_action(int action, struct cardstate *cs,
break;
#endif
case ACT_DEBUG:
- dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
+ gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
__func__, ev->type, at_state->ConState);
break;
case ACT_WARN:
- warn("%s: resp_code %d in ConState %d!",
- __func__, ev->type, at_state->ConState);
+ dev_warn(cs->dev, "%s: resp_code %d in ConState %d!\n",
+ __func__, ev->type, at_state->ConState);
break;
case ACT_ZCAU:
- warn("cause code %04x in connection state %d.",
- ev->parameter, at_state->ConState);
+ dev_warn(cs->dev, "cause code %04x in connection state %d.\n",
+ ev->parameter, at_state->ConState);
break;
/* events from the LL */
@@ -1516,14 +1511,14 @@ static void do_action(int action, struct cardstate *cs,
start_accept(at_state);
break;
case ACT_PROTO_L2:
- dbg(DEBUG_CMD,
- "set protocol to %u", (unsigned) ev->parameter);
+ gig_dbg(DEBUG_CMD, "set protocol to %u",
+ (unsigned) ev->parameter);
at_state->bcs->proto2 = ev->parameter;
break;
case ACT_HUP:
at_state->pending_commands |= PC_HUP;
- atomic_set(&cs->commands_pending, 1); //FIXME
- dbg(DEBUG_CMD, "Scheduling PC_HUP");
+ atomic_set(&cs->commands_pending, 1);
+ gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
break;
/* hotplug events */
@@ -1555,17 +1550,19 @@ static void do_action(int action, struct cardstate *cs,
/* events from the proc file system */ // FIXME without ACT_xxxx?
case ACT_PROC_CIDMODE:
- if (ev->parameter != atomic_read(&cs->cidmode)) {
- atomic_set(&cs->cidmode, ev->parameter);
+ spin_lock_irqsave(&cs->lock, flags);
+ if (ev->parameter != cs->cidmode) {
+ cs->cidmode = ev->parameter;
if (ev->parameter) {
cs->at_state.pending_commands |= PC_CIDMODE;
- dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
+ gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
} else {
cs->at_state.pending_commands |= PC_UMMODE;
- dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
+ gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
}
atomic_set(&cs->commands_pending, 1);
}
+ spin_unlock_irqrestore(&cs->lock, flags);
cs->waiting = 0;
wake_up(&cs->waitqueue);
break;
@@ -1590,7 +1587,7 @@ static void do_action(int action, struct cardstate *cs,
*p_resp_code = RSP_NULL;
}
} else
- err("%s: action==%d!", __func__, action);
+ dev_err(cs->dev, "%s: action==%d!\n", __func__, action);
}
}
@@ -1609,47 +1606,46 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
int curact;
unsigned long flags;
- IFNULLRET(cs);
- IFNULLRET(ev);
-
if (ev->cid >= 0) {
at_state = at_state_from_cid(cs, ev->cid);
if (!at_state) {
gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID,
- NULL, 0, NULL);
+ NULL, 0, NULL);
return;
}
} else {
at_state = ev->at_state;
if (at_state_invalid(cs, at_state)) {
- dbg(DEBUG_ANY,
- "event for invalid at_state %p", at_state);
+ gig_dbg(DEBUG_ANY, "event for invalid at_state %p",
+ at_state);
return;
}
}
- dbg(DEBUG_CMD,
- "connection state %d, event %d", at_state->ConState, ev->type);
+ gig_dbg(DEBUG_CMD, "connection state %d, event %d",
+ at_state->ConState, ev->type);
bcs = at_state->bcs;
sendcid = at_state->cid;
/* Setting the pointer to the dial array */
rep = at_state->replystruct;
- IFNULLRET(rep);
+ spin_lock_irqsave(&cs->lock, flags);
if (ev->type == EV_TIMEOUT) {
- if (ev->parameter != atomic_read(&at_state->timer_index)
+ if (ev->parameter != at_state->timer_index
|| !at_state->timer_active) {
ev->type = RSP_NONE; /* old timeout */
- dbg(DEBUG_ANY, "old timeout");
+ gig_dbg(DEBUG_ANY, "old timeout");
} else if (!at_state->waiting)
- dbg(DEBUG_ANY, "timeout occured");
+ gig_dbg(DEBUG_ANY, "timeout occurred");
else
- dbg(DEBUG_ANY, "stopped waiting");
+ gig_dbg(DEBUG_ANY, "stopped waiting");
}
+ spin_unlock_irqrestore(&cs->lock, flags);
- /* if the response belongs to a variable in at_state->int_var[VAR_XXXX] or at_state->str_var[STR_XXXX], set it */
+ /* if the response belongs to a variable in at_state->int_var[VAR_XXXX]
+ or at_state->str_var[STR_XXXX], set it */
if (ev->type >= RSP_VAR && ev->type < RSP_VAR + VAR_NUM) {
index = ev->type - RSP_VAR;
at_state->int_var[index] = ev->parameter;
@@ -1657,20 +1653,22 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
index = ev->type - RSP_STR;
kfree(at_state->str_var[index]);
at_state->str_var[index] = ev->ptr;
- ev->ptr = NULL; /* prevent process_events() from deallocating ptr */
+ ev->ptr = NULL; /* prevent process_events() from
+ deallocating ptr */
}
if (ev->type == EV_TIMEOUT || ev->type == RSP_STRING)
at_state->getstring = 0;
- /* Search row in dial array which matches modem response and current constate */
+ /* Search row in dial array which matches modem response and current
+ constate */
for (;; rep++) {
rcode = rep->resp_code;
- /* dbg (DEBUG_ANY, "rcode %d", rcode); */
if (rcode == RSP_LAST) {
/* found nothing...*/
- warn("%s: rcode=RSP_LAST: resp_code %d in ConState %d!",
- __func__, ev->type, at_state->ConState);
+ dev_warn(cs->dev, "%s: rcode=RSP_LAST: "
+ "resp_code %d in ConState %d!\n",
+ __func__, ev->type, at_state->ConState);
return;
}
if ((rcode == RSP_ANY || rcode == ev->type)
@@ -1706,14 +1704,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
} else {
/* Send command to modem if not NULL... */
if (p_command/*rep->command*/) {
- if (atomic_read(&cs->connected))
+ if (cs->connected)
send_command(cs, p_command,
- sendcid, cs->dle,
- GFP_ATOMIC);
+ sendcid, cs->dle,
+ GFP_ATOMIC);
else
gigaset_add_event(cs, at_state,
- RSP_NODEV,
- NULL, 0, NULL);
+ RSP_NODEV,
+ NULL, 0, NULL);
}
spin_lock_irqsave(&cs->lock, flags);
@@ -1723,8 +1721,7 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
} else if (rep->timeout > 0) { /* new timeout */
at_state->timer_expires = rep->timeout * 10;
at_state->timer_active = 1;
- new_index(&at_state->timer_index,
- MAX_TIMER_INDEX);
+ ++at_state->timer_index;
}
spin_unlock_irqrestore(&cs->lock, flags);
}
@@ -1744,17 +1741,16 @@ static void process_command_flags(struct cardstate *cs)
struct bc_state *bcs;
int i;
int sequence;
-
- IFNULLRET(cs);
+ unsigned long flags;
atomic_set(&cs->commands_pending, 0);
if (cs->cur_at_seq) {
- dbg(DEBUG_CMD, "not searching scheduled commands: busy");
+ gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
return;
}
- dbg(DEBUG_CMD, "searching scheduled commands");
+ gig_dbg(DEBUG_CMD, "searching scheduled commands");
sequence = SEQ_NONE;
@@ -1795,8 +1791,9 @@ static void process_command_flags(struct cardstate *cs)
}
/* only switch back to unimodem mode, if no commands are pending and no channels are up */
+ spin_lock_irqsave(&cs->lock, flags);
if (cs->at_state.pending_commands == PC_UMMODE
- && !atomic_read(&cs->cidmode)
+ && !cs->cidmode
&& list_empty(&cs->temp_at_states)
&& atomic_read(&cs->mode) == M_CID) {
sequence = SEQ_UMMODE;
@@ -1810,6 +1807,7 @@ static void process_command_flags(struct cardstate *cs)
}
}
}
+ spin_unlock_irqrestore(&cs->lock, flags);
cs->at_state.pending_commands &= ~PC_UMMODE;
if (sequence != SEQ_NONE) {
schedule_sequence(cs, at_state, sequence);
@@ -1865,11 +1863,7 @@ static void process_command_flags(struct cardstate *cs)
if (cs->at_state.pending_commands & PC_CIDMODE) {
cs->at_state.pending_commands &= ~PC_CIDMODE;
if (atomic_read(&cs->mode) == M_UNIMODEM) {
-#if 0
- cs->retry_count = 2;
-#else
cs->retry_count = 1;
-#endif
schedule_sequence(cs, &cs->at_state, SEQ_CIDMODE);
return;
}
@@ -1897,7 +1891,7 @@ static void process_command_flags(struct cardstate *cs)
switch (atomic_read(&cs->mode)) {
case M_UNIMODEM:
cs->at_state.pending_commands |= PC_CIDMODE;
- dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
+ gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
atomic_set(&cs->commands_pending, 1);
return;
#ifdef GIG_MAYINITONDIAL
@@ -1926,18 +1920,21 @@ static void process_events(struct cardstate *cs)
int i;
int check_flags = 0;
int was_busy;
+ unsigned long flags;
- /* no locking needed (only one reader) */
- head = atomic_read(&cs->ev_head);
+ spin_lock_irqsave(&cs->ev_lock, flags);
+ head = cs->ev_head;
for (i = 0; i < 2 * MAX_EVENTS; ++i) {
- tail = atomic_read(&cs->ev_tail);
+ tail = cs->ev_tail;
if (tail == head) {
if (!check_flags && !atomic_read(&cs->commands_pending))
break;
check_flags = 0;
+ spin_unlock_irqrestore(&cs->ev_lock, flags);
process_command_flags(cs);
- tail = atomic_read(&cs->ev_tail);
+ spin_lock_irqsave(&cs->ev_lock, flags);
+ tail = cs->ev_tail;
if (tail == head) {
if (!atomic_read(&cs->commands_pending))
break;
@@ -1947,18 +1944,23 @@ static void process_events(struct cardstate *cs)
ev = cs->events + head;
was_busy = cs->cur_at_seq != SEQ_NONE;
+ spin_unlock_irqrestore(&cs->ev_lock, flags);
process_event(cs, ev);
+ spin_lock_irqsave(&cs->ev_lock, flags);
kfree(ev->ptr);
ev->ptr = NULL;
if (was_busy && cs->cur_at_seq == SEQ_NONE)
check_flags = 1;
head = (head + 1) % MAX_EVENTS;
- atomic_set(&cs->ev_head, head);
+ cs->ev_head = head;
}
+ spin_unlock_irqrestore(&cs->ev_lock, flags);
+
if (i == 2 * MAX_EVENTS) {
- err("infinite loop in process_events; aborting.");
+ dev_err(cs->dev,
+ "infinite loop in process_events; aborting.\n");
}
}
@@ -1970,12 +1972,9 @@ void gigaset_handle_event(unsigned long data)
{
struct cardstate *cs = (struct cardstate *) data;
- IFNULLRET(cs);
- IFNULLRET(cs->inbuf);
-
/* handle incoming data on control/common channel */
if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) {
- dbg(DEBUG_INTR, "processing new data");
+ gig_dbg(DEBUG_INTR, "processing new data");
cs->ops->handle_input(cs->inbuf);
}
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 729edcdb6dacd..9d21ba8757b04 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -1,11 +1,16 @@
-/* Siemens Gigaset 307x driver
+/*
+ * Siemens Gigaset 307x driver
* Common header file for all connection variants
*
- * Written by Stefan Eilers <Eilers.Stefan@epost.de>
+ * Written by Stefan Eilers
* and Hansjoerg Lipp <hjlipp@web.de>
*
- * Version: $Id: gigaset.h,v 1.97.4.26 2006/02/04 18:28:16 hjlipp Exp $
- * ===========================================================================
+ * =====================================================================
+ * 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 GIGASET_H
@@ -15,7 +20,6 @@
#include <linux/kernel.h>
#include <linux/compiler.h>
#include <linux/types.h>
-#include <asm/atomic.h>
#include <linux/spinlock.h>
#include <linux/isdnif.h>
#include <linux/usb.h>
@@ -27,21 +31,22 @@
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/list.h>
+#include <asm/atomic.h>
#define GIG_VERSION {0,5,0,0}
#define GIG_COMPAT {0,4,0,0}
-#define MAX_REC_PARAMS 10 /* Max. number of params in response string */
-#define MAX_RESP_SIZE 512 /* Max. size of a response string */
-#define HW_HDR_LEN 2 /* Header size used to store ack info */
+#define MAX_REC_PARAMS 10 /* Max. number of params in response string */
+#define MAX_RESP_SIZE 512 /* Max. size of a response string */
+#define HW_HDR_LEN 2 /* Header size used to store ack info */
-#define MAX_EVENTS 64 /* size of event queue */
+#define MAX_EVENTS 64 /* size of event queue */
#define RBUFSIZE 8192
-#define SBUFSIZE 4096 /* sk_buff payload size */
+#define SBUFSIZE 4096 /* sk_buff payload size */
-#define MAX_BUF_SIZE (SBUFSIZE - 2) /* Max. size of a data packet from LL */
-#define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */
+#define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */
+#define MAX_BUF_SIZE (SBUFSIZE - 2) /* Max. size of a data packet from LL */
/* compile time options */
#define GIG_MAJOR 0
@@ -50,10 +55,7 @@
#define GIG_RETRYCID
#define GIG_X75
-#define MAX_TIMER_INDEX 1000
-#define MAX_SEQ_INDEX 1000
-
-#define GIG_TICK (HZ / 10)
+#define GIG_TICK 100 /* in milliseconds */
/* timeout values (unit: 1 sec) */
#define INIT_TIMEOUT 1
@@ -67,74 +69,89 @@
#define MAXACT 3
-#define IFNULL(a) if (unlikely(!(a)))
-#define IFNULLRET(a) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); return; }
-#define IFNULLRETVAL(a,b) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); return (b); }
-#define IFNULLCONT(a) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); continue; }
-#define IFNULLGOTO(a,b) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); goto b; }
-
extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */
-/* any combination of these can be given with the 'debug=' parameter to insmod, e.g.
- * 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and DEBUG_INTR. */
+/* any combination of these can be given with the 'debug=' parameter to insmod,
+ * e.g. 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and
+ * DEBUG_INTR.
+ */
enum debuglevel { /* up to 24 bits (atomic_t) */
DEBUG_REG = 0x0002, /* serial port I/O register operations */
DEBUG_OPEN = 0x0004, /* open/close serial port */
DEBUG_INTR = 0x0008, /* interrupt processing */
- DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on interrupt
- requests, not available as run-time option */
+ DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on
+ interrupt requests, not available as
+ run-time option */
DEBUG_CMD = 0x00020, /* sent/received LL commands */
DEBUG_STREAM = 0x00040, /* application data stream I/O events */
DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */
DEBUG_LLDATA = 0x00100, /* sent/received LL data */
- DEBUG_INTR_0 = 0x00200, /* serial port output interrupt processing */
+ DEBUG_INTR_0 = 0x00200, /* serial port interrupt processing */
DEBUG_DRIVER = 0x00400, /* driver structure */
DEBUG_HDLC = 0x00800, /* M10x HDLC processing */
DEBUG_WRITE = 0x01000, /* M105 data write */
- DEBUG_TRANSCMD = 0x02000, /*AT-COMMANDS+RESPONSES*/
- DEBUG_MCMD = 0x04000, /*COMMANDS THAT ARE SENT VERY OFTEN*/
- DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data structures */
+ DEBUG_TRANSCMD = 0x02000, /* AT-COMMANDS+RESPONSES */
+ DEBUG_MCMD = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */
+ DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data
+ structures */
DEBUG_LOCK = 0x10000, /* semaphore operations */
DEBUG_OUTPUT = 0x20000, /* output to device */
- DEBUG_ISO = 0x40000, /* isochronous transfers */
+ DEBUG_ISO = 0x40000, /* isochronous transfers */
DEBUG_IF = 0x80000, /* character device operations */
- DEBUG_USBREQ = 0x100000, /* USB communication (except payload data) */
- DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when MS_LOCKED */
+ DEBUG_USBREQ = 0x100000, /* USB communication (except payload
+ data) */
+ DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when
+ MS_LOCKED */
- DEBUG_ANY = 0x3fffff, /* print message if any of the others is activated */
+ DEBUG_ANY = 0x3fffff, /* print message if any of the others is
+ activated */
};
-#ifdef CONFIG_GIGASET_DEBUG
-#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
-//#define DEBUG_DEFAULT (DEBUG_LOCK | DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUF_IF | DEBUG_DRIVER | DEBUG_OUTPUT | DEBUG_INTR)
-#else
-#define DEBUG_DEFAULT 0
+/* missing from linux/device.h ... */
+#ifndef dev_notice
+#define dev_notice(dev, format, arg...) \
+ dev_printk(KERN_NOTICE , dev , format , ## arg)
#endif
-/* redefine syslog macros to prepend module name instead of entire source path */
-/* The space before the comma in ", ##" is needed by gcc 2.95 */
+/* Kernel message macros for situations where dev_printk and friends cannot be
+ * used for lack of reliable access to a device structure.
+ * linux/usb.h already contains these but in an obsolete form which clutters
+ * the log needlessly, and according to the USB maintainer those should be
+ * removed rather than fixed anyway.
+ */
+#undef err
#undef info
-#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
-
-#undef notice
-#define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
-
#undef warn
-#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
+#undef notice
-#undef err
-#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
+#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
+ format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
+ format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
+ format "\n" , ## arg)
+#define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \
+ format "\n" , ## arg)
-#undef dbg
#ifdef CONFIG_GIGASET_DEBUG
-#define dbg(level, format, arg...) do { if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
- printk(KERN_DEBUG "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg); } while (0)
+
+#define gig_dbg(level, format, arg...) \
+ do { \
+ if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
+ printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \
+ ## arg); \
+ } while (0)
+#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
+
#else
-#define dbg(level, format, arg...) do {} while (0)
+
+#define gig_dbg(level, format, arg...) do {} while (0)
+#define DEBUG_DEFAULT 0
+
#endif
void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
- size_t len, const unsigned char *buf, int from_user);
+ size_t len, const unsigned char *buf);
/* connection state */
#define ZSAU_NONE 0
@@ -148,13 +165,14 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define ZSAU_UNKNOWN -1
/* USB control transfer requests */
-#define OUT_VENDOR_REQ (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
-#define IN_VENDOR_REQ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
+#define OUT_VENDOR_REQ (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
+#define IN_VENDOR_REQ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
/* int-in-events 3070 */
#define HD_B1_FLOW_CONTROL 0x80
#define HD_B2_FLOW_CONTROL 0x81
-#define HD_RECEIVEATDATA_ACK (0x35) // 3070 // att: HD_RECEIVE>>AT<<DATA_ACK
+#define HD_RECEIVEATDATA_ACK (0x35) // 3070
+ // att: HD_RECEIVE>>AT<<DATA_ACK
#define HD_READY_SEND_ATDATA (0x36) // 3070
#define HD_OPEN_ATCHANNEL_ACK (0x37) // 3070
#define HD_CLOSE_ATCHANNEL_ACK (0x38) // 3070
@@ -181,17 +199,18 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define HD_CLOSE_ATCHANNEL (0x29) // 3070
/* USB frames for isochronous transfer */
-#define BAS_FRAMETIME 1 /* number of milliseconds between frames */
-#define BAS_NUMFRAMES 8 /* number of frames per URB */
-#define BAS_MAXFRAME 16 /* allocated bytes per frame */
-#define BAS_NORMFRAME 8 /* send size without flow control */
-#define BAS_HIGHFRAME 10 /* " " with positive flow control */
-#define BAS_LOWFRAME 5 /* " " with negative flow control */
-#define BAS_CORRFRAMES 4 /* flow control multiplicator */
-
-#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) /* size of isochronous input buffer per URB */
-#define BAS_OUTBUFSIZE 4096 /* size of common isochronous output buffer */
-#define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isochronous output buffer */
+#define BAS_FRAMETIME 1 /* number of milliseconds between frames */
+#define BAS_NUMFRAMES 8 /* number of frames per URB */
+#define BAS_MAXFRAME 16 /* allocated bytes per frame */
+#define BAS_NORMFRAME 8 /* send size without flow control */
+#define BAS_HIGHFRAME 10 /* " " with positive flow control */
+#define BAS_LOWFRAME 5 /* " " with negative flow control */
+#define BAS_CORRFRAMES 4 /* flow control multiplicator */
+
+#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES)
+ /* size of isoc in buf per URB */
+#define BAS_OUTBUFSIZE 4096 /* size of common isoc out buffer */
+#define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isoc out buf */
#define BAS_INURBS 3
#define BAS_OUTURBS 3
@@ -207,40 +226,40 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define AT_NUM 7
/* variables in struct at_state_t */
-#define VAR_ZSAU 0
-#define VAR_ZDLE 1
-#define VAR_ZVLS 2
-#define VAR_ZCTP 3
-#define VAR_NUM 4
-
-#define STR_NMBR 0
-#define STR_ZCPN 1
-#define STR_ZCON 2
-#define STR_ZBC 3
-#define STR_ZHLC 4
-#define STR_NUM 5
-
-#define EV_TIMEOUT -105
-#define EV_IF_VER -106
-#define EV_PROC_CIDMODE -107
-#define EV_SHUTDOWN -108
-#define EV_START -110
-#define EV_STOP -111
-#define EV_IF_LOCK -112
-#define EV_PROTO_L2 -113
-#define EV_ACCEPT -114
-#define EV_DIAL -115
-#define EV_HUP -116
-#define EV_BC_OPEN -117
-#define EV_BC_CLOSED -118
+#define VAR_ZSAU 0
+#define VAR_ZDLE 1
+#define VAR_ZVLS 2
+#define VAR_ZCTP 3
+#define VAR_NUM 4
+
+#define STR_NMBR 0
+#define STR_ZCPN 1
+#define STR_ZCON 2
+#define STR_ZBC 3
+#define STR_ZHLC 4
+#define STR_NUM 5
+
+#define EV_TIMEOUT -105
+#define EV_IF_VER -106
+#define EV_PROC_CIDMODE -107
+#define EV_SHUTDOWN -108
+#define EV_START -110
+#define EV_STOP -111
+#define EV_IF_LOCK -112
+#define EV_PROTO_L2 -113
+#define EV_ACCEPT -114
+#define EV_DIAL -115
+#define EV_HUP -116
+#define EV_BC_OPEN -117
+#define EV_BC_CLOSED -118
/* input state */
-#define INS_command 0x0001
-#define INS_DLE_char 0x0002
-#define INS_byte_stuff 0x0004
-#define INS_have_data 0x0008
-#define INS_skip_frame 0x0010
-#define INS_DLE_command 0x0020
+#define INS_command 0x0001
+#define INS_DLE_char 0x0002
+#define INS_byte_stuff 0x0004
+#define INS_have_data 0x0008
+#define INS_skip_frame 0x0010
+#define INS_DLE_command 0x0020
#define INS_flag_hunt 0x0040
/* channel state */
@@ -248,27 +267,27 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define CHS_B_UP 0x02
#define CHS_NOTIFY_LL 0x04
-#define ICALL_REJECT 0
-#define ICALL_ACCEPT 1
-#define ICALL_IGNORE 2
+#define ICALL_REJECT 0
+#define ICALL_ACCEPT 1
+#define ICALL_IGNORE 2
/* device state */
-#define MS_UNINITIALIZED 0
-#define MS_INIT 1
-#define MS_LOCKED 2
-#define MS_SHUTDOWN 3
-#define MS_RECOVER 4
-#define MS_READY 5
+#define MS_UNINITIALIZED 0
+#define MS_INIT 1
+#define MS_LOCKED 2
+#define MS_SHUTDOWN 3
+#define MS_RECOVER 4
+#define MS_READY 5
/* mode */
-#define M_UNKNOWN 0
-#define M_CONFIG 1
-#define M_UNIMODEM 2
-#define M_CID 3
+#define M_UNKNOWN 0
+#define M_CONFIG 1
+#define M_UNIMODEM 2
+#define M_CID 3
/* start mode */
-#define SM_LOCKED 0
-#define SM_ISDN 1 /* default */
+#define SM_LOCKED 0
+#define SM_ISDN 1 /* default */
struct gigaset_ops;
struct gigaset_driver;
@@ -283,27 +302,26 @@ struct ser_bc_state;
struct bas_bc_state;
struct reply_t {
- int resp_code; /* RSP_XXXX */
- int min_ConState; /* <0 => ignore */
- int max_ConState; /* <0 => ignore */
- int parameter; /* e.g. ZSAU_XXXX <0: ignore*/
- int new_ConState; /* <0 => ignore */
- int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/
- int action[MAXACT]; /* ACT_XXXX */
- char *command; /* NULL==none */
+ int resp_code; /* RSP_XXXX */
+ int min_ConState; /* <0 => ignore */
+ int max_ConState; /* <0 => ignore */
+ int parameter; /* e.g. ZSAU_XXXX <0: ignore*/
+ int new_ConState; /* <0 => ignore */
+ int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/
+ int action[MAXACT]; /* ACT_XXXX */
+ char *command; /* NULL==none */
};
extern struct reply_t gigaset_tab_cid_m10x[];
extern struct reply_t gigaset_tab_nocid_m10x[];
struct inbuf_t {
- unsigned char *rcvbuf; /* usb-gigaset receive buffer */
+ unsigned char *rcvbuf; /* usb-gigaset receive buffer */
struct bc_state *bcs;
- struct cardstate *cs;
- int inputstate;
-
- atomic_t head, tail;
- unsigned char data[RBUFSIZE];
+ struct cardstate *cs;
+ int inputstate;
+ atomic_t head, tail;
+ unsigned char data[RBUFSIZE];
};
/* isochronous write buffer structure
@@ -319,16 +337,9 @@ struct inbuf_t {
* if writesem <= 0, data[write..read-1] is currently being written to
* - idle contains the byte value to repeat when the end of valid data is
* reached; if nextread==write (buffer contains no data to send), either the
- * BAS_OUTBUFPAD bytes immediately before data[write] (if write>=BAS_OUTBUFPAD)
- * or those of the pad area (if write<BAS_OUTBUFPAD) are also filled with that
- * value
- * - optionally, the following statistics on the buffer's usage can be collected:
- * maxfill: maximum number of bytes occupied
- * idlefills: number of times a frame of idle bytes is prepared
- * emptygets: number of times the buffer was empty when a data frame was requested
- * backtoback: number of times two data packets were entered into the buffer
- * without intervening idle flags
- * nakedback: set if no idle flags have been inserted since the last data packet
+ * BAS_OUTBUFPAD bytes immediately before data[write] (if
+ * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD)
+ * are also filled with that value
*/
struct isowbuf_t {
atomic_t read;
@@ -358,34 +369,28 @@ struct isow_urbctx_t {
* it is currently assigned a B channel
*/
struct at_state_t {
- struct list_head list;
- int waiting;
- int getstring;
- atomic_t timer_index;
+ struct list_head list;
+ int waiting;
+ int getstring;
+ unsigned timer_index;
unsigned long timer_expires;
int timer_active;
- unsigned int ConState; /* State of connection */
- struct reply_t *replystruct;
- int cid;
- int int_var[VAR_NUM]; /* see VAR_XXXX */
- char *str_var[STR_NUM]; /* see STR_XXXX */
- unsigned pending_commands; /* see PC_XXXX */
- atomic_t seq_index;
-
- struct cardstate *cs;
- struct bc_state *bcs;
+ unsigned int ConState; /* State of connection */
+ struct reply_t *replystruct;
+ int cid;
+ int int_var[VAR_NUM]; /* see VAR_XXXX */
+ char *str_var[STR_NUM]; /* see STR_XXXX */
+ unsigned pending_commands; /* see PC_XXXX */
+ unsigned seq_index;
+
+ struct cardstate *cs;
+ struct bc_state *bcs;
};
struct resp_type_t {
unsigned char *response;
- int resp_code; /* RSP_XXXX */
- int type; /* RT_XXXX */
-};
-
-struct prot_skb {
- atomic_t empty;
- struct semaphore *sem;
- struct sk_buff *skb;
+ int resp_code; /* RSP_XXXX */
+ int type; /* RT_XXXX */
};
struct event_t {
@@ -398,29 +403,29 @@ struct event_t {
/* This buffer holds all information about the used B-Channel */
struct bc_state {
- struct sk_buff *tx_skb; /* Current transfer buffer to modem */
- struct sk_buff_head squeue; /* B-Channel send Queue */
+ struct sk_buff *tx_skb; /* Current transfer buffer to modem */
+ struct sk_buff_head squeue; /* B-Channel send Queue */
/* Variables for debugging .. */
- int corrupted; /* Counter for corrupted packages */
- int trans_down; /* Counter of packages (downstream) */
- int trans_up; /* Counter of packages (upstream) */
+ int corrupted; /* Counter for corrupted packages */
+ int trans_down; /* Counter of packages (downstream) */
+ int trans_up; /* Counter of packages (upstream) */
struct at_state_t at_state;
unsigned long rcvbytes;
__u16 fcs;
struct sk_buff *skb;
- int inputstate; /* see INS_XXXX */
+ int inputstate; /* see INS_XXXX */
int channel;
struct cardstate *cs;
- unsigned chstate; /* bitmap (CHS_*) */
+ unsigned chstate; /* bitmap (CHS_*) */
int ignore;
- unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */
- char *commands[AT_NUM]; /* see AT_XXXX */
+ unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */
+ char *commands[AT_NUM]; /* see AT_XXXX */
#ifdef CONFIG_GIGASET_DEBUG
int emptycount;
@@ -428,37 +433,39 @@ struct bc_state {
int busy;
int use_count;
- /* hardware drivers */
+ /* private data of hardware drivers */
union {
- struct ser_bc_state *ser; /* private data of serial hardware driver */
- struct usb_bc_state *usb; /* private data of usb hardware driver */
- struct bas_bc_state *bas;
+ struct ser_bc_state *ser; /* serial hardware driver */
+ struct usb_bc_state *usb; /* usb hardware driver (m105) */
+ struct bas_bc_state *bas; /* usb hardware driver (base) */
} hw;
};
struct cardstate {
struct gigaset_driver *driver;
unsigned minor_index;
+ struct device *dev;
const struct gigaset_ops *ops;
/* Stuff to handle communication */
- //wait_queue_head_t initwait;
wait_queue_head_t waitqueue;
int waiting;
- atomic_t mode; /* see M_XXXX */
- atomic_t mstate; /* Modem state: see MS_XXXX */
- /* only changed by the event layer */
+ atomic_t mode; /* see M_XXXX */
+ atomic_t mstate; /* Modem state: see MS_XXXX */
+ /* only changed by the event layer */
int cmd_result;
int channels;
- struct bc_state *bcs; /* Array of struct bc_state */
+ struct bc_state *bcs; /* Array of struct bc_state */
- int onechannel; /* data and commands transmitted in one stream (M10x) */
+ int onechannel; /* data and commands transmitted in one
+ stream (M10x) */
spinlock_t lock;
- struct at_state_t at_state; /* at_state_t for cid == 0 */
- struct list_head temp_at_states; /* list of temporary "struct at_state_t"s without B channel */
+ struct at_state_t at_state; /* at_state_t for cid == 0 */
+ struct list_head temp_at_states;/* list of temporary "struct
+ at_state_t"s without B channel */
struct inbuf_t *inbuf;
@@ -474,58 +481,69 @@ struct cardstate {
unsigned fwver[4];
int gotfwver;
- atomic_t running; /* !=0 if events are handled */
- atomic_t connected; /* !=0 if hardware is connected */
+ unsigned running; /* !=0 if events are handled */
+ unsigned connected; /* !=0 if hardware is connected */
+ unsigned isdn_up; /* !=0 after ISDN_STAT_RUN */
- atomic_t cidmode;
+ unsigned cidmode;
- int myid; /* id for communication with LL */
+ int myid; /* id for communication with LL */
isdn_if iif;
struct reply_t *tabnocid;
struct reply_t *tabcid;
int cs_init;
- int ignoreframes; /* frames to ignore after setting up the B channel */
- struct semaphore sem; /* locks this structure: */
- /* connected is not changed, */
- /* hardware_up is not changed, */
- /* MState is not changed to or from MS_LOCKED */
+ int ignoreframes; /* frames to ignore after setting up the
+ B channel */
+ struct mutex mutex; /* locks this structure:
+ * connected is not changed,
+ * hardware_up is not changed,
+ * MState is not changed to or from
+ * MS_LOCKED */
struct timer_list timer;
int retry_count;
- int dle; /* !=0 if modem commands/responses are dle encoded */
- int cur_at_seq; /* sequence of AT commands being processed */
- int curchannel; /* channel, those commands are meant for */
- atomic_t commands_pending; /* flag(s) in xxx.commands_pending have been set */
- struct tasklet_struct event_tasklet; /* tasklet for serializing AT commands. Scheduled
- * -> for modem reponses (and incomming data for M10x)
- * -> on timeout
- * -> after setting bits in xxx.at_state.pending_command
- * (e.g. command from LL) */
- struct tasklet_struct write_tasklet; /* tasklet for serial output
- * (not used in base driver) */
+ int dle; /* !=0 if modem commands/responses are
+ dle encoded */
+ int cur_at_seq; /* sequence of AT commands being
+ processed */
+ int curchannel; /* channel those commands are meant
+ for */
+ atomic_t commands_pending; /* flag(s) in xxx.commands_pending have
+ been set */
+ struct tasklet_struct event_tasklet;
+ /* tasklet for serializing AT commands.
+ * Scheduled
+ * -> for modem reponses (and
+ * incoming data for M10x)
+ * -> on timeout
+ * -> after setting bits in
+ * xxx.at_state.pending_command
+ * (e.g. command from LL) */
+ struct tasklet_struct write_tasklet;
+ /* tasklet for serial output
+ * (not used in base driver) */
/* event queue */
struct event_t events[MAX_EVENTS];
- atomic_t ev_tail, ev_head;
+ unsigned ev_tail, ev_head;
spinlock_t ev_lock;
/* current modem response */
unsigned char respdata[MAX_RESP_SIZE];
unsigned cbytes;
- /* hardware drivers */
+ /* private data of hardware drivers */
union {
- struct usb_cardstate *usb; /* private data of USB hardware driver */
- struct ser_cardstate *ser; /* private data of serial hardware driver */
- struct bas_cardstate *bas; /* private data of base hardware driver */
+ struct usb_cardstate *usb; /* USB hardware driver (m105) */
+ struct ser_cardstate *ser; /* serial hardware driver */
+ struct bas_cardstate *bas; /* USB hardware driver (base) */
} hw;
};
struct gigaset_driver {
struct list_head list;
- spinlock_t lock; /* locks minor tables and blocked */
- //struct semaphore sem; /* locks this structure */
+ spinlock_t lock; /* locks minor tables and blocked */
struct tty_driver *tty;
unsigned have_tty;
unsigned minor;
@@ -553,37 +571,42 @@ struct bas_bc_state {
struct isow_urbctx_t isoouturbs[BAS_OUTURBS];
struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl;
struct isowbuf_t *isooutbuf;
- unsigned numsub; /* submitted URB counter (for diagnostic messages only) */
+ unsigned numsub; /* submitted URB counter
+ (for diagnostic messages only) */
struct tasklet_struct sent_tasklet;
/* isochronous input state */
spinlock_t isoinlock;
struct urb *isoinurbs[BAS_INURBS];
unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS];
- struct urb *isoindone; /* completed isoc read URB */
- int loststatus; /* status of dropped URB */
- unsigned isoinlost; /* number of bytes lost */
- /* state of bit unstuffing algorithm (in addition to BC_state.inputstate) */
- unsigned seqlen; /* number of '1' bits not yet unstuffed */
- unsigned inbyte, inbits; /* collected bits for next byte */
+ struct urb *isoindone; /* completed isoc read URB */
+ int loststatus; /* status of dropped URB */
+ unsigned isoinlost; /* number of bytes lost */
+ /* state of bit unstuffing algorithm
+ (in addition to BC_state.inputstate) */
+ unsigned seqlen; /* number of '1' bits not yet
+ unstuffed */
+ unsigned inbyte, inbits; /* collected bits for next byte */
/* statistics */
- unsigned goodbytes; /* bytes correctly received */
- unsigned alignerrs; /* frames with incomplete byte at end */
- unsigned fcserrs; /* FCS errors */
- unsigned frameerrs; /* framing errors */
- unsigned giants; /* long frames */
- unsigned runts; /* short frames */
- unsigned aborts; /* HDLC aborts */
- unsigned shared0s; /* '0' bits shared between flags */
- unsigned stolen0s; /* '0' stuff bits also serving as leading flag bits */
+ unsigned goodbytes; /* bytes correctly received */
+ unsigned alignerrs; /* frames with incomplete byte at end */
+ unsigned fcserrs; /* FCS errors */
+ unsigned frameerrs; /* framing errors */
+ unsigned giants; /* long frames */
+ unsigned runts; /* short frames */
+ unsigned aborts; /* HDLC aborts */
+ unsigned shared0s; /* '0' bits shared between flags */
+ unsigned stolen0s; /* '0' stuff bits also serving as
+ leading flag bits */
struct tasklet_struct rcvd_tasklet;
};
struct gigaset_ops {
- /* Called from ev-layer.c/interface.c for sending AT commands to the device */
+ /* Called from ev-layer.c/interface.c for sending AT commands to the
+ device */
int (*write_cmd)(struct cardstate *cs,
- const unsigned char *buf, int len,
- struct tasklet_struct *wake_tasklet);
+ const unsigned char *buf, int len,
+ struct tasklet_struct *wake_tasklet);
/* Called from interface.c for additional device control */
int (*write_room)(struct cardstate *cs);
@@ -604,7 +627,8 @@ struct gigaset_ops {
/* Called by gigaset_freecs() for freeing bcs->hw.xxx */
int (*freebcshw)(struct bc_state *bcs);
- /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting bcs->hw.xxx */
+ /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting
+ bcs->hw.xxx */
void (*reinitbcshw)(struct bc_state *bcs);
/* Called by gigaset_initcs() for setting up cs->hw.xxx */
@@ -613,13 +637,10 @@ struct gigaset_ops {
/* Called by gigaset_freecs() for freeing cs->hw.xxx */
void (*freecshw)(struct cardstate *cs);
- ///* Called by gigaset_stop() for killing URBs, shutting down the device, ...
- // hardwareup: ==0: don't try to shut down the device, hardware is really not accessible
- // !=0: hardware still up */
- //void (*stophw)(struct cardstate *cs, int hardwareup);
-
- /* Called from common.c/interface.c for additional serial port control */
- int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state, unsigned new_state);
+ /* Called from common.c/interface.c for additional serial port
+ control */
+ int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state,
+ unsigned new_state);
int (*baud_rate)(struct cardstate *cs, unsigned cflag);
int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag);
@@ -639,7 +660,7 @@ struct gigaset_ops {
* <DLE_FLAG>: 0x10
* <EVENT>: ((a-z)* | (A-Z)* | (0-10)*)+
*/
-#define DLE_FLAG 0x10
+#define DLE_FLAG 0x10
/* ===========================================================================
* Functions implemented in asyncdata.c
@@ -667,7 +688,8 @@ void gigaset_isoc_input(struct inbuf_t *inbuf);
/* Called from bas-gigaset.c to process a block of data
* received through the isochronous channel */
-void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs);
+void gigaset_isoc_receive(unsigned char *src, unsigned count,
+ struct bc_state *bcs);
/* Called from bas-gigaset.c to put a block of data
* into the isochronous output buffer */
@@ -703,7 +725,7 @@ static inline void gigaset_isdn_rcv_err(struct bc_state *bcs)
isdn_ctrl response;
/* error -> LL */
- dbg(DEBUG_CMD, "sending L1ERR");
+ gig_dbg(DEBUG_CMD, "sending L1ERR");
response.driver = bcs->cs->myid;
response.command = ISDN_STAT_L1ERR;
response.arg = bcs->channel;
@@ -727,8 +749,8 @@ void gigaset_handle_modem_response(struct cardstate *cs);
*/
/* initialize sysfs for device */
-void gigaset_init_dev_sysfs(struct usb_interface *interface);
-void gigaset_free_dev_sysfs(struct usb_interface *interface);
+void gigaset_init_dev_sysfs(struct cardstate *cs);
+void gigaset_free_dev_sysfs(struct cardstate *cs);
/* ===========================================================================
* Functions implemented in common.c/gigaset.h
@@ -736,7 +758,7 @@ void gigaset_free_dev_sysfs(struct usb_interface *interface);
void gigaset_bcs_reinit(struct bc_state *bcs);
void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
- struct cardstate *cs, int cid);
+ struct cardstate *cs, int cid);
int gigaset_get_channel(struct bc_state *bcs);
void gigaset_free_channel(struct bc_state *bcs);
int gigaset_get_channels(struct cardstate *cs);
@@ -745,16 +767,15 @@ void gigaset_block_channels(struct cardstate *cs);
/* Allocate and initialize driver structure. */
struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
- const char *procname,
- const char *devname,
- const char *devfsname,
- const struct gigaset_ops *ops,
- struct module *owner);
+ const char *procname,
+ const char *devname,
+ const char *devfsname,
+ const struct gigaset_ops *ops,
+ struct module *owner);
/* Deallocate driver structure. */
void gigaset_freedriver(struct gigaset_driver *drv);
void gigaset_debugdrivers(void);
-struct cardstate *gigaset_get_cs_by_minor(unsigned minor);
struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty);
struct cardstate *gigaset_get_cs_by_id(int id);
@@ -763,7 +784,8 @@ struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv);
void gigaset_unassign(struct cardstate *cs);
void gigaset_blockdriver(struct gigaset_driver *drv);
-/* Allocate and initialize card state. Calls hardware dependent gigaset_init[b]cs(). */
+/* Allocate and initialize card state. Calls hardware dependent
+ gigaset_init[b]cs(). */
struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
int onechannel, int ignoreframes,
int cidmode, const char *modulename);
@@ -788,8 +810,8 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);
* ptr must be kmalloc()ed (and not be freed by the caller).
*/
struct event_t *gigaset_add_event(struct cardstate *cs,
- struct at_state_t *at_state, int type,
- void *ptr, int parameter, void *arg);
+ struct at_state_t *at_state, int type,
+ void *ptr, int parameter, void *arg);
/* Called on CONFIG1 command from frontend. */
int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode
@@ -799,7 +821,7 @@ static inline void gigaset_schedule_event(struct cardstate *cs)
{
unsigned long flags;
spin_lock_irqsave(&cs->lock, flags);
- if (atomic_read(&cs->running))
+ if (cs->running)
tasklet_schedule(&cs->event_tasklet);
spin_unlock_irqrestore(&cs->lock, flags);
}
@@ -810,7 +832,7 @@ static inline void gigaset_bchannel_down(struct bc_state *bcs)
{
gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL);
- dbg(DEBUG_CMD, "scheduling BC_CLOSED");
+ gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED");
gigaset_schedule_event(bcs->cs);
}
@@ -820,36 +842,19 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
{
gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL);
- dbg(DEBUG_CMD, "scheduling BC_OPEN");
+ gig_dbg(DEBUG_CMD, "scheduling BC_OPEN");
gigaset_schedule_event(bcs->cs);
}
/* handling routines for sk_buff */
/* ============================= */
-/* private version of __skb_put()
- * append 'len' bytes to the content of 'skb', already knowing that the
- * existing buffer can accomodate them
- * returns a pointer to the location where the new bytes should be copied to
- * This function does not take any locks so it must be called with the
- * appropriate locks held only.
- */
-static inline unsigned char *gigaset_skb_put_quick(struct sk_buff *skb,
- unsigned int len)
-{
- unsigned char *tmp = skb->tail;
- /*SKB_LINEAR_ASSERT(skb);*/ /* not needed here */
- skb->tail += len;
- skb->len += len;
- return tmp;
-}
-
/* pass received skb to LL
* Warning: skb must not be accessed anymore!
*/
static inline void gigaset_rcv_skb(struct sk_buff *skb,
- struct cardstate *cs,
- struct bc_state *bcs)
+ struct cardstate *cs,
+ struct bc_state *bcs)
{
cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb);
bcs->trans_down++;
@@ -859,8 +864,8 @@ static inline void gigaset_rcv_skb(struct sk_buff *skb,
* Warning: skb must not be accessed anymore!
*/
static inline void gigaset_rcv_error(struct sk_buff *procskb,
- struct cardstate *cs,
- struct bc_state *bcs)
+ struct cardstate *cs,
+ struct bc_state *bcs)
{
if (procskb)
dev_kfree_skb(procskb);
@@ -877,46 +882,9 @@ static inline void gigaset_rcv_error(struct sk_buff *procskb,
/* bitwise byte inversion table */
extern __u8 gigaset_invtab[]; /* in common.c */
-
/* append received bytes to inbuf */
-static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
- const unsigned char *src,
- unsigned numbytes)
-{
- unsigned n, head, tail, bytesleft;
-
- dbg(DEBUG_INTR, "received %u bytes", numbytes);
-
- if (!numbytes)
- return 0;
-
- bytesleft = numbytes;
- tail = atomic_read(&inbuf->tail);
- head = atomic_read(&inbuf->head);
- dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
-
- while (bytesleft) {
- if (head > tail)
- n = head - 1 - tail;
- else if (head == 0)
- n = (RBUFSIZE-1) - tail;
- else
- n = RBUFSIZE - tail;
- if (!n) {
- err("buffer overflow (%u bytes lost)", bytesleft);
- break;
- }
- if (n > bytesleft)
- n = bytesleft;
- memcpy(inbuf->data + tail, src, n);
- bytesleft -= n;
- tail = (tail + n) % RBUFSIZE;
- src += n;
- }
- dbg(DEBUG_INTR, "setting tail to %u", tail);
- atomic_set(&inbuf->tail, tail);
- return numbytes != bytesleft;
-}
+int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
+ unsigned numbytes);
/* ===========================================================================
* Functions implemented in interface.c
@@ -924,7 +892,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
/* initialize interface */
void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
- const char *devname, const char *devfsname);
+ const char *devname, const char *devfsname);
/* release interface */
void gigaset_if_freedriver(struct gigaset_driver *drv);
/* add minor */
@@ -933,6 +901,6 @@ void gigaset_if_init(struct cardstate *cs);
void gigaset_if_free(struct cardstate *cs);
/* device received data */
void gigaset_if_receive(struct cardstate *cs,
- unsigned char *buffer, size_t len);
+ unsigned char *buffer, size_t len);
#endif
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c
index 731a675f21b0b..0815dbfb82911 100644
--- a/drivers/isdn/gigaset/i4l.c
+++ b/drivers/isdn/gigaset/i4l.c
@@ -1,9 +1,9 @@
/*
* Stuff used by all variants of the driver
*
- * Copyright (c) 2001 by Stefan Eilers (Eilers.Stefan@epost.de),
- * Hansjoerg Lipp (hjlipp@web.de),
- * Tilman Schmidt (tilman@imap.cc).
+ * Copyright (c) 2001 by Stefan Eilers,
+ * Hansjoerg Lipp <hjlipp@web.de>,
+ * Tilman Schmidt <tilman@imap.cc>.
*
* =====================================================================
* This program is free software; you can redistribute it and/or
@@ -11,15 +11,11 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: i4l.c,v 1.3.2.9 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
-/* == Handling of I4L IO ============================================================================*/
+/* == Handling of I4L IO =====================================================*/
/* writebuf_from_LL
* called by LL to transmit data on an open channel
@@ -29,14 +25,16 @@
* parameters:
* driverID driver ID as assigned by LL
* channel channel number
- * ack if != 0 LL wants to be notified on completion via statcallb(ISDN_STAT_BSENT)
+ * ack if != 0 LL wants to be notified on completion via
+ * statcallb(ISDN_STAT_BSENT)
* skb skb containing data to send
* return value:
* number of accepted bytes
* 0 if temporarily unable to accept data (out of buffer space)
* <0 on error (eg. -EINVAL)
*/
-static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *skb)
+static int writebuf_from_LL(int driverID, int channel, int ack,
+ struct sk_buff *skb)
{
struct cardstate *cs;
struct bc_state *bcs;
@@ -54,31 +52,28 @@ static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *
bcs = &cs->bcs[channel];
len = skb->len;
- dbg(DEBUG_LLDATA,
- "Receiving data from LL (id: %d, channel: %d, ack: %d, size: %d)",
- driverID, channel, ack, len);
+ gig_dbg(DEBUG_LLDATA,
+ "Receiving data from LL (id: %d, ch: %d, ack: %d, sz: %d)",
+ driverID, channel, ack, len);
if (!len) {
if (ack)
- warn("not ACKing empty packet from LL");
+ notice("%s: not ACKing empty packet", __func__);
return 0;
}
if (len > MAX_BUF_SIZE) {
- err("%s: packet too large (%d bytes)", __func__, channel);
+ err("%s: packet too large (%d bytes)", __func__, len);
return -EINVAL;
}
- if (!atomic_read(&cs->connected))
- return -ENODEV;
-
skblen = ack ? len : 0;
skb->head[0] = skblen & 0xff;
skb->head[1] = skblen >> 8;
- dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x", len, skblen,
- (unsigned) skb->head[0], (unsigned) skb->head[1]);
+ gig_dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x",
+ len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]);
/* pass to device-specific module */
- return cs->ops->send_skb(bcs, skb);
+ return cs->ops->send_skb(bcs, skb); //FIXME cs->ops->send_skb() must handle !cs->connected correctly
}
void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb)
@@ -89,14 +84,14 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb)
++bcs->trans_up;
if (skb->len)
- warn("%s: skb->len==%d", __func__, skb->len);
+ dev_warn(bcs->cs->dev, "%s: skb->len==%d\n",
+ __func__, skb->len);
len = (unsigned char) skb->head[0] |
(unsigned) (unsigned char) skb->head[1] << 8;
if (len) {
- dbg(DEBUG_MCMD,
- "Acknowledge sending to LL (id: %d, channel: %d size: %u)",
- bcs->cs->myid, bcs->channel, len);
+ gig_dbg(DEBUG_MCMD, "ACKing to LL (id: %d, ch: %d, sz: %u)",
+ bcs->cs->myid, bcs->channel, len);
response.driver = bcs->cs->myid;
response.command = ISDN_STAT_BSENT;
@@ -119,15 +114,12 @@ static int command_from_LL(isdn_ctrl *cntrl)
struct bc_state *bcs;
int retval = 0;
struct setup_parm *sp;
+ unsigned param;
+ unsigned long flags;
- //dbg(DEBUG_ANY, "Gigaset_HW: Receiving command");
gigaset_debugdrivers();
- /* Terminate this call if no device is present. Bt if the command is "ISDN_CMD_LOCK" or
- * "ISDN_CMD_UNLOCK" then execute it due to the fact that they are device independent !
- */
- //FIXME "remove test for &connected"
- if ((!cs || !atomic_read(&cs->connected))) {
+ if (!cs) {
warn("LL tried to access unknown device with nr. %d",
cntrl->driver);
return -ENODEV;
@@ -135,29 +127,30 @@ static int command_from_LL(isdn_ctrl *cntrl)
switch (cntrl->command) {
case ISDN_CMD_IOCTL:
-
- dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver:%d,arg: %ld)",
- cntrl->driver, cntrl->arg);
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver: %d, arg: %ld)",
+ cntrl->driver, cntrl->arg);
warn("ISDN_CMD_IOCTL is not supported.");
return -EINVAL;
case ISDN_CMD_DIAL:
- dbg(DEBUG_ANY, "ISDN_CMD_DIAL (driver: %d, channel: %ld, "
- "phone: %s,ownmsn: %s, si1: %d, si2: %d)",
- cntrl->driver, cntrl->arg,
- cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn,
- cntrl->parm.setup.si1, cntrl->parm.setup.si2);
+ gig_dbg(DEBUG_ANY,
+ "ISDN_CMD_DIAL (driver: %d, ch: %ld, "
+ "phone: %s, ownmsn: %s, si1: %d, si2: %d)",
+ cntrl->driver, cntrl->arg,
+ cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn,
+ cntrl->parm.setup.si1, cntrl->parm.setup.si2);
if (cntrl->arg >= cs->channels) {
- err("invalid channel (%d)", (int) cntrl->arg);
+ err("ISDN_CMD_DIAL: invalid channel (%d)",
+ (int) cntrl->arg);
return -EINVAL;
}
bcs = cs->bcs + cntrl->arg;
if (!gigaset_get_channel(bcs)) {
- err("channel not free");
+ err("ISDN_CMD_DIAL: channel not free");
return -EBUSY;
}
@@ -169,42 +162,46 @@ static int command_from_LL(isdn_ctrl *cntrl)
}
*sp = cntrl->parm.setup;
- if (!gigaset_add_event(cs, &bcs->at_state, EV_DIAL, sp,
- atomic_read(&bcs->at_state.seq_index),
- NULL)) {
+ spin_lock_irqsave(&cs->lock, flags);
+ param = bcs->at_state.seq_index;
+ spin_unlock_irqrestore(&cs->lock, flags);
+
+ if (!gigaset_add_event(cs, &bcs->at_state, EV_DIAL, sp, param,
+ NULL)) {
//FIXME what should we do?
kfree(sp);
gigaset_free_channel(bcs);
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling DIAL");
+ gig_dbg(DEBUG_CMD, "scheduling DIAL");
gigaset_schedule_event(cs);
break;
case ISDN_CMD_ACCEPTD: //FIXME
- dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD");
if (cntrl->arg >= cs->channels) {
- err("invalid channel (%d)", (int) cntrl->arg);
+ err("ISDN_CMD_ACCEPTD: invalid channel (%d)",
+ (int) cntrl->arg);
return -EINVAL;
}
if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg].at_state,
- EV_ACCEPT, NULL, 0, NULL)) {
+ EV_ACCEPT, NULL, 0, NULL)) {
//FIXME what should we do?
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling ACCEPT");
+ gig_dbg(DEBUG_CMD, "scheduling ACCEPT");
gigaset_schedule_event(cs);
break;
case ISDN_CMD_ACCEPTB:
- dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB");
break;
case ISDN_CMD_HANGUP:
- dbg(DEBUG_ANY,
- "ISDN_CMD_HANGUP (channel: %d)", (int) cntrl->arg);
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_HANGUP (ch: %d)",
+ (int) cntrl->arg);
if (cntrl->arg >= cs->channels) {
err("ISDN_CMD_HANGUP: invalid channel (%u)",
@@ -213,66 +210,68 @@ static int command_from_LL(isdn_ctrl *cntrl)
}
if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg].at_state,
- EV_HUP, NULL, 0, NULL)) {
+ EV_HUP, NULL, 0, NULL)) {
//FIXME what should we do?
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling HUP");
+ gig_dbg(DEBUG_CMD, "scheduling HUP");
gigaset_schedule_event(cs);
break;
- case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME
- dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ");
+ case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ");
break;
- case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME
- dbg(DEBUG_ANY,
- "ISDN_CMD_SETEAZ (id:%d, channel: %ld, number: %s)",
- cntrl->driver, cntrl->arg, cntrl->parm.num);
+ case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME
+ gig_dbg(DEBUG_ANY,
+ "ISDN_CMD_SETEAZ (id: %d, ch: %ld, number: %s)",
+ cntrl->driver, cntrl->arg, cntrl->parm.num);
break;
- case ISDN_CMD_SETL2: /* Set L2 to given protocol */
- dbg(DEBUG_ANY, "ISDN_CMD_SETL2 (Channel: %ld, Proto: %lx)",
- cntrl->arg & 0xff, (cntrl->arg >> 8));
+ case ISDN_CMD_SETL2: /* Set L2 to given protocol */
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_SETL2 (ch: %ld, proto: %lx)",
+ cntrl->arg & 0xff, (cntrl->arg >> 8));
if ((cntrl->arg & 0xff) >= cs->channels) {
- err("invalid channel (%u)",
+ err("ISDN_CMD_SETL2: invalid channel (%u)",
(unsigned) cntrl->arg & 0xff);
return -EINVAL;
}
if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg & 0xff].at_state,
- EV_PROTO_L2, NULL, cntrl->arg >> 8,
- NULL)) {
+ EV_PROTO_L2, NULL, cntrl->arg >> 8,
+ NULL)) {
//FIXME what should we do?
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling PROTO_L2");
+ gig_dbg(DEBUG_CMD, "scheduling PROTO_L2");
gigaset_schedule_event(cs);
break;
- case ISDN_CMD_SETL3: /* Set L3 to given protocol */
- dbg(DEBUG_ANY, "ISDN_CMD_SETL3 (Channel: %ld, Proto: %lx)",
- cntrl->arg & 0xff, (cntrl->arg >> 8));
+ case ISDN_CMD_SETL3: /* Set L3 to given protocol */
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_SETL3 (ch: %ld, proto: %lx)",
+ cntrl->arg & 0xff, (cntrl->arg >> 8));
if ((cntrl->arg & 0xff) >= cs->channels) {
- err("invalid channel (%u)",
+ err("ISDN_CMD_SETL3: invalid channel (%u)",
(unsigned) cntrl->arg & 0xff);
return -EINVAL;
}
if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) {
- err("invalid protocol %lu", cntrl->arg >> 8);
+ err("ISDN_CMD_SETL3: invalid protocol %lu",
+ cntrl->arg >> 8);
return -EINVAL;
}
break;
case ISDN_CMD_PROCEED:
- dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME
break;
case ISDN_CMD_ALERT:
- dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME
if (cntrl->arg >= cs->channels) {
- err("invalid channel (%d)", (int) cntrl->arg);
+ err("ISDN_CMD_ALERT: invalid channel (%d)",
+ (int) cntrl->arg);
return -EINVAL;
}
//bcs = cs->bcs + cntrl->arg;
@@ -280,32 +279,31 @@ static int command_from_LL(isdn_ctrl *cntrl)
// FIXME
break;
case ISDN_CMD_REDIR:
- dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME
break;
case ISDN_CMD_PROT_IO:
- dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO");
break;
case ISDN_CMD_FAXCMD:
- dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD");
break;
case ISDN_CMD_GETL2:
- dbg(DEBUG_ANY, "ISDN_CMD_GETL2");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL2");
break;
case ISDN_CMD_GETL3:
- dbg(DEBUG_ANY, "ISDN_CMD_GETL3");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL3");
break;
case ISDN_CMD_GETEAZ:
- dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ");
break;
case ISDN_CMD_SETSIL:
- dbg(DEBUG_ANY, "ISDN_CMD_SETSIL");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_SETSIL");
break;
case ISDN_CMD_GETSIL:
- dbg(DEBUG_ANY, "ISDN_CMD_GETSIL");
+ gig_dbg(DEBUG_ANY, "ISDN_CMD_GETSIL");
break;
default:
- err("unknown command %d from LL",
- cntrl->command);
+ err("unknown command %d from LL", cntrl->command);
return -EINVAL;
}
@@ -350,7 +348,8 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
break;
default:
- err("invalid protocol: %u", bcs->proto2);
+ dev_err(bcs->cs->dev, "%s: invalid L2 protocol: %u\n",
+ __func__, bcs->proto2);
return -EINVAL;
}
@@ -378,7 +377,7 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
bcs->commands[i] = NULL;
if (length[i] &&
!(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
- err("out of memory");
+ dev_err(bcs->cs->dev, "out of memory\n");
return -ENOMEM;
}
}
@@ -396,10 +395,14 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
}
if (bcs->commands[AT_MSN])
- snprintf(bcs->commands[AT_MSN], length[AT_MSN], "^SMSN=%s\r", sp->eazmsn);
- snprintf(bcs->commands[AT_BC ], length[AT_BC ], "^SBC=%s\r", bc);
- snprintf(bcs->commands[AT_PROTO], length[AT_PROTO], "^SBPR=%u\r", proto);
- snprintf(bcs->commands[AT_ISO ], length[AT_ISO ], "^SISO=%u\r", (unsigned)bcs->channel + 1);
+ snprintf(bcs->commands[AT_MSN], length[AT_MSN],
+ "^SMSN=%s\r", sp->eazmsn);
+ snprintf(bcs->commands[AT_BC ], length[AT_BC ],
+ "^SBC=%s\r", bc);
+ snprintf(bcs->commands[AT_PROTO], length[AT_PROTO],
+ "^SBPR=%u\r", proto);
+ snprintf(bcs->commands[AT_ISO ], length[AT_ISO ],
+ "^SISO=%u\r", (unsigned)bcs->channel + 1);
return 0;
}
@@ -419,7 +422,8 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
break;
default:
- err("invalid protocol: %u", bcs->proto2);
+ dev_err(at_state->cs->dev, "%s: invalid protocol: %u\n",
+ __func__, bcs->proto2);
return -EINVAL;
}
@@ -436,13 +440,15 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
bcs->commands[i] = NULL;
if (length[i] &&
!(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
- err("out of memory");
+ dev_err(at_state->cs->dev, "out of memory\n");
return -ENOMEM;
}
}
- snprintf(bcs->commands[AT_PROTO], length[AT_PROTO], "^SBPR=%u\r", proto);
- snprintf(bcs->commands[AT_ISO ], length[AT_ISO ], "^SISO=%u\r", (unsigned) bcs->channel + 1);
+ snprintf(bcs->commands[AT_PROTO], length[AT_PROTO],
+ "^SBPR=%u\r", proto);
+ snprintf(bcs->commands[AT_ISO ], length[AT_ISO ],
+ "^SISO=%u\r", (unsigned) bcs->channel + 1);
return 0;
}
@@ -473,7 +479,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
response.parm.setup.si1 = 1;
response.parm.setup.si2 = 2;
} else {
- warn("RING ignored - unsupported BC %s",
+ dev_warn(cs->dev, "RING ignored - unsupported BC %s\n",
at_state->str_var[STR_ZBC]);
return ICALL_IGNORE;
}
@@ -491,18 +497,17 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
response.parm.setup.eazmsn[0] = 0;
if (!bcs) {
- notice("no channel for incoming call");
- dbg(DEBUG_CMD, "Sending ICALLW");
+ dev_notice(cs->dev, "no channel for incoming call\n");
response.command = ISDN_STAT_ICALLW;
response.arg = 0; //FIXME
} else {
- dbg(DEBUG_CMD, "Sending ICALL");
+ gig_dbg(DEBUG_CMD, "Sending ICALL");
response.command = ISDN_STAT_ICALL;
response.arg = bcs->channel; //FIXME
}
response.driver = cs->myid;
retval = cs->iif.statcallb(&response);
- dbg(DEBUG_CMD, "Response: %d", retval);
+ gig_dbg(DEBUG_CMD, "Response: %d", retval);
switch (retval) {
case 0: /* no takers */
return ICALL_IGNORE;
@@ -512,7 +517,8 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
case 2: /* reject */
return ICALL_REJECT;
case 3: /* incomplete */
- warn("LL requested unsupported feature: Incomplete Number");
+ dev_warn(cs->dev,
+ "LL requested unsupported feature: Incomplete Number\n");
return ICALL_IGNORE;
case 4: /* proceeding */
/* Gigaset will send ALERTING anyway.
@@ -520,10 +526,11 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
*/
return ICALL_ACCEPT;
case 5: /* deflect */
- warn("LL requested unsupported feature: Call Deflection");
+ dev_warn(cs->dev,
+ "LL requested unsupported feature: Call Deflection\n");
return ICALL_IGNORE;
default:
- err("LL error %d on ICALL", retval);
+ dev_err(cs->dev, "LL error %d on ICALL\n", retval);
return ICALL_IGNORE;
}
}
@@ -533,7 +540,7 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
{
isdn_if *iif = &cs->iif;
- dbg(DEBUG_ANY, "Register driver capabilities to LL");
+ gig_dbg(DEBUG_ANY, "Register driver capabilities to LL");
//iif->id[sizeof(iif->id) - 1]=0;
//strncpy(iif->id, isdnid, sizeof(iif->id) - 1);
@@ -542,26 +549,26 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
return -ENOMEM; //FIXME EINVAL/...??
iif->owner = THIS_MODULE;
- iif->channels = cs->channels; /* I am supporting just one channel *//* I was supporting...*/
+ iif->channels = cs->channels;
iif->maxbufsize = MAX_BUF_SIZE;
- iif->features = ISDN_FEATURE_L2_TRANS | /* Our device is very advanced, therefore */
+ iif->features = ISDN_FEATURE_L2_TRANS |
ISDN_FEATURE_L2_HDLC |
#ifdef GIG_X75
ISDN_FEATURE_L2_X75I |
#endif
ISDN_FEATURE_L3_TRANS |
ISDN_FEATURE_P_EURO;
- iif->hl_hdrlen = HW_HDR_LEN; /* Area for storing ack */
+ iif->hl_hdrlen = HW_HDR_LEN; /* Area for storing ack */
iif->command = command_from_LL;
iif->writebuf_skb = writebuf_from_LL;
- iif->writecmd = NULL; /* Don't support isdnctrl */
- iif->readstat = NULL; /* Don't support isdnctrl */
- iif->rcvcallb_skb = NULL; /* Will be set by LL */
- iif->statcallb = NULL; /* Will be set by LL */
+ iif->writecmd = NULL; /* Don't support isdnctrl */
+ iif->readstat = NULL; /* Don't support isdnctrl */
+ iif->rcvcallb_skb = NULL; /* Will be set by LL */
+ iif->statcallb = NULL; /* Will be set by LL */
if (!register_isdn(iif))
return 0;
- cs->myid = iif->channels; /* Set my device id */
+ cs->myid = iif->channels; /* Set my device id */
return 1;
}
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 3a81d9c65141b..08e4c4eea14d9 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -9,8 +9,6 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * Version: $Id: interface.c,v 1.14.4.15 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
@@ -24,7 +22,7 @@ static int if_lock(struct cardstate *cs, int *arg)
{
int cmd = *arg;
- dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd);
+ gig_dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd);
if (cmd > 1)
return -EINVAL;
@@ -35,7 +33,7 @@ static int if_lock(struct cardstate *cs, int *arg)
}
if (!cmd && atomic_read(&cs->mstate) == MS_LOCKED
- && atomic_read(&cs->connected)) {
+ && cs->connected) {
cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
cs->ops->baud_rate(cs, B115200);
cs->ops->set_line_ctrl(cs, CS8);
@@ -44,12 +42,12 @@ static int if_lock(struct cardstate *cs, int *arg)
cs->waiting = 1;
if (!gigaset_add_event(cs, &cs->at_state, EV_IF_LOCK,
- NULL, cmd, NULL)) {
+ NULL, cmd, NULL)) {
cs->waiting = 0;
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling IF_LOCK");
+ gig_dbg(DEBUG_CMD, "scheduling IF_LOCK");
gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting);
@@ -68,7 +66,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
static const unsigned compat[4] = GIG_COMPAT;
unsigned cmd = arg[0];
- dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd);
+ gig_dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd);
switch (cmd) {
case GIGVER_DRIVER:
@@ -80,12 +78,12 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
case GIGVER_FWBASE:
cs->waiting = 1;
if (!gigaset_add_event(cs, &cs->at_state, EV_IF_VER,
- NULL, 0, arg)) {
+ NULL, 0, arg)) {
cs->waiting = 0;
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling IF_VER");
+ gig_dbg(DEBUG_CMD, "scheduling IF_VER");
gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting);
@@ -101,7 +99,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
static int if_config(struct cardstate *cs, int *arg)
{
- dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg);
+ gig_dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg);
if (*arg != 1)
return -EINVAL;
@@ -109,6 +107,11 @@ static int if_config(struct cardstate *cs, int *arg)
if (atomic_read(&cs->mstate) != MS_LOCKED)
return -EBUSY;
+ if (!cs->connected) {
+ err("not connected!");
+ return -ENODEV;
+ }
+
*arg = 0;
return gigaset_enterconfigmode(cs);
}
@@ -119,7 +122,7 @@ static int if_config(struct cardstate *cs, int *arg)
static int if_open(struct tty_struct *tty, struct file *filp);
static void if_close(struct tty_struct *tty, struct file *filp);
static int if_ioctl(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg);
+ unsigned int cmd, unsigned long arg);
static int if_write_room(struct tty_struct *tty);
static int if_chars_in_buffer(struct tty_struct *tty);
static void if_throttle(struct tty_struct *tty);
@@ -127,9 +130,9 @@ static void if_unthrottle(struct tty_struct *tty);
static void if_set_termios(struct tty_struct *tty, struct termios *old);
static int if_tiocmget(struct tty_struct *tty, struct file *file);
static int if_tiocmset(struct tty_struct *tty, struct file *file,
- unsigned int set, unsigned int clear);
+ unsigned int set, unsigned int clear);
static int if_write(struct tty_struct *tty,
- const unsigned char *buf, int count);
+ const unsigned char *buf, int count);
static struct tty_operations if_ops = {
.open = if_open,
@@ -153,8 +156,8 @@ static int if_open(struct tty_struct *tty, struct file *filp)
struct cardstate *cs;
unsigned long flags;
- dbg(DEBUG_IF, "%d+%d: %s()", tty->driver->minor_start, tty->index,
- __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%d+%d: %s()",
+ tty->driver->minor_start, tty->index, __func__);
tty->driver_data = NULL;
@@ -162,7 +165,7 @@ static int if_open(struct tty_struct *tty, struct file *filp)
if (!cs)
return -ENODEV;
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
tty->driver_data = cs;
@@ -173,10 +176,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
cs->tty = tty;
spin_unlock_irqrestore(&cs->lock, flags);
tty->low_latency = 1; //FIXME test
- //FIXME
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return 0;
}
@@ -187,30 +189,29 @@ static void if_close(struct tty_struct *tty, struct file *filp)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else {
if (!--cs->open_count) {
spin_lock_irqsave(&cs->lock, flags);
cs->tty = NULL;
spin_unlock_irqrestore(&cs->lock, flags);
- //FIXME
}
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
static int if_ioctl(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
struct cardstate *cs;
int retval = -ENODEV;
@@ -220,17 +221,17 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return -ENODEV;
}
- dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __FUNCTION__, cmd);
+ gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else {
retval = 0;
switch (cmd) {
@@ -250,37 +251,40 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
break;
case GIGASET_BRKCHARS:
//FIXME test if MS_LOCKED
- gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS",
- 6, (const unsigned char *) arg, 1);
- if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_ANY, "can't communicate with unplugged device");
+ if (!cs->connected) {
+ gig_dbg(DEBUG_ANY,
+ "can't communicate with unplugged device");
retval = -ENODEV;
break;
}
retval = copy_from_user(&buf,
- (const unsigned char __user *) arg, 6)
- ? -EFAULT : 0;
- if (retval >= 0)
+ (const unsigned char __user *) arg, 6)
+ ? -EFAULT : 0;
+ if (retval >= 0) {
+ gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS",
+ 6, (const unsigned char *) arg);
retval = cs->ops->brkchars(cs, buf);
+ }
break;
case GIGASET_VERSION:
- retval = copy_from_user(version, (unsigned __user *) arg,
- sizeof version) ? -EFAULT : 0;
+ retval = copy_from_user(version,
+ (unsigned __user *) arg, sizeof version)
+ ? -EFAULT : 0;
if (retval >= 0)
retval = if_version(cs, version);
if (retval >= 0)
- retval = copy_to_user((unsigned __user *) arg, version,
- sizeof version)
- ? -EFAULT : 0;
+ retval = copy_to_user((unsigned __user *) arg,
+ version, sizeof version)
+ ? -EFAULT : 0;
break;
- default:
- dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x",
- __FUNCTION__, cmd);
+ default:
+ gig_dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x",
+ __func__, cmd);
retval = -ENOIOCTLCMD;
}
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
@@ -292,25 +296,25 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return -ENODEV;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
// FIXME read from device?
retval = cs->control_state & (TIOCM_RTS|TIOCM_DTR);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
static int if_tiocmset(struct tty_struct *tty, struct file *file,
- unsigned int set, unsigned int clear)
+ unsigned int set, unsigned int clear)
{
struct cardstate *cs;
int retval;
@@ -318,18 +322,18 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return -ENODEV;
}
- dbg(DEBUG_IF,
- "%u: %s(0x%x, 0x%x)", cs->minor_index, __FUNCTION__, set, clear);
+ gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
+ cs->minor_index, __func__, set, clear);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
- if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_ANY, "can't communicate with unplugged device");
+ if (!cs->connected) {
+ gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
retval = -ENODEV;
} else {
mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR);
@@ -337,7 +341,7 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
cs->control_state = mc;
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
@@ -349,29 +353,29 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return -ENODEV;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else if (atomic_read(&cs->mstate) != MS_LOCKED) {
warn("can't write to unlocked device");
retval = -EBUSY;
- } else if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_ANY, "can't write to unplugged device");
+ } else if (!cs->connected) {
+ gig_dbg(DEBUG_ANY, "can't write to unplugged device");
retval = -EBUSY; //FIXME
} else {
retval = cs->ops->write_cmd(cs, buf, count,
- &cs->if_wake_tasklet);
+ &cs->if_wake_tasklet);
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
@@ -383,27 +387,27 @@ static int if_write_room(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return -ENODEV;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else if (atomic_read(&cs->mstate) != MS_LOCKED) {
warn("can't write to unlocked device");
retval = -EBUSY; //FIXME
- } else if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_ANY, "can't write to unplugged device");
+ } else if (!cs->connected) {
+ gig_dbg(DEBUG_ANY, "can't write to unplugged device");
retval = -EBUSY; //FIXME
} else
retval = cs->ops->write_room(cs);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
@@ -415,27 +419,27 @@ static int if_chars_in_buffer(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return -ENODEV;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else if (atomic_read(&cs->mstate) != MS_LOCKED) {
warn("can't write to unlocked device");
retval = -EBUSY;
- } else if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_ANY, "can't write to unplugged device");
+ } else if (!cs->connected) {
+ gig_dbg(DEBUG_ANY, "can't write to unplugged device");
retval = -EBUSY; //FIXME
} else
retval = cs->ops->chars_in_buffer(cs);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return retval;
}
@@ -446,21 +450,21 @@ static void if_throttle(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else {
//FIXME
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
static void if_unthrottle(struct tty_struct *tty)
@@ -469,21 +473,21 @@ static void if_unthrottle(struct tty_struct *tty)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count)
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
else {
//FIXME
}
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
static void if_set_termios(struct tty_struct *tty, struct termios *old)
@@ -496,21 +500,21 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
cs = (struct cardstate *) tty->driver_data;
if (!cs) {
- err("cs==NULL in %s", __FUNCTION__);
+ err("cs==NULL in %s", __func__);
return;
}
- dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__);
+ gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
- down(&cs->sem);
+ mutex_lock(&cs->mutex);
if (!cs->open_count) {
- warn("%s: device not opened", __FUNCTION__);
+ warn("%s: device not opened", __func__);
goto out;
}
- if (!atomic_read(&cs->connected)) {
- dbg(DEBUG_ANY, "can't communicate with unplugged device");
+ if (!cs->connected) {
+ gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
goto out;
}
@@ -518,8 +522,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
iflag = tty->termios->c_iflag;
cflag = tty->termios->c_cflag;
old_cflag = old ? old->c_cflag : cflag; //FIXME?
- dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x", cs->minor_index,
- iflag, cflag, old_cflag);
+ gig_dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x",
+ cs->minor_index, iflag, cflag, old_cflag);
/* get a local copy of the current port settings */
control_state = cs->control_state;
@@ -531,14 +535,15 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
* Premature optimization is the root of all evil.
*/
- /* reassert DTR and (maybe) RTS on transition from B0 */
+ /* reassert DTR and (maybe) RTS on transition from B0 */
if ((old_cflag & CBAUD) == B0) {
new_state = control_state | TIOCM_DTR;
/* don't set RTS if using hardware flow control */
if (!(old_cflag & CRTSCTS))
new_state |= TIOCM_RTS;
- dbg(DEBUG_IF, "%u: from B0 - set DTR%s", cs->minor_index,
- (new_state & TIOCM_RTS) ? " only" : "/RTS");
+ gig_dbg(DEBUG_IF, "%u: from B0 - set DTR%s",
+ cs->minor_index,
+ (new_state & TIOCM_RTS) ? " only" : "/RTS");
cs->ops->set_modem_ctrl(cs, control_state, new_state);
control_state = new_state;
}
@@ -547,7 +552,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
if ((cflag & CBAUD) == B0) {
/* Drop RTS and DTR */
- dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index);
+ gig_dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index);
new_state = control_state & ~(TIOCM_DTR | TIOCM_RTS);
cs->ops->set_modem_ctrl(cs, control_state, new_state);
control_state = new_state;
@@ -567,15 +572,17 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
* Just do what we have seen with SniffUSB on Win98.
*/
/* Drop DTR/RTS if no flow control otherwise assert */
- dbg(DEBUG_IF, "%u: control_state %x", cs->minor_index, control_state);
+ gig_dbg(DEBUG_IF, "%u: control_state %x",
+ cs->minor_index, control_state);
new_state = control_state;
if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
new_state |= TIOCM_DTR | TIOCM_RTS;
else
new_state &= ~(TIOCM_DTR | TIOCM_RTS);
if (new_state != control_state) {
- dbg(DEBUG_IF, "%u: new_state %x", cs->minor_index, new_state);
- gigaset_set_modem_ctrl(cs, control_state, new_state); // FIXME: mct_u232.c sets the old state here. is this a bug?
+ gig_dbg(DEBUG_IF, "%u: new_state %x",
+ cs->minor_index, new_state);
+ gigaset_set_modem_ctrl(cs, control_state, new_state);
control_state = new_state;
}
#endif
@@ -584,7 +591,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
cs->control_state = control_state;
out:
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
}
@@ -600,7 +607,7 @@ static void if_wake(unsigned long data)
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup) {
- dbg(DEBUG_IF, "write wakeup call");
+ gig_dbg(DEBUG_IF, "write wakeup call");
tty->ldisc.write_wakeup(tty);
}
@@ -635,14 +642,14 @@ void gigaset_if_free(struct cardstate *cs)
}
void gigaset_if_receive(struct cardstate *cs,
- unsigned char *buffer, size_t len)
+ unsigned char *buffer, size_t len)
{
unsigned long flags;
struct tty_struct *tty;
spin_lock_irqsave(&cs->lock, flags);
if ((tty = cs->tty) == NULL)
- dbg(DEBUG_ANY, "receive on closed device");
+ gig_dbg(DEBUG_ANY, "receive on closed device");
else {
tty_buffer_request_room(tty, len);
tty_insert_flip_string(tty, buffer, len);
@@ -655,13 +662,13 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive);
/* gigaset_if_initdriver
* Initialize tty interface.
* parameters:
- * drv Driver
- * procname Name of the driver (e.g. for /proc/tty/drivers)
- * devname Name of the device files (prefix without minor number)
- * devfsname Devfs name of the device files without %d
+ * drv Driver
+ * procname Name of the driver (e.g. for /proc/tty/drivers)
+ * devname Name of the device files (prefix without minor number)
+ * devfsname Devfs name of the device files without %d
*/
void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
- const char *devname, const char *devfsname)
+ const char *devname, const char *devfsname)
{
unsigned minors = drv->minors;
int ret;
@@ -696,7 +703,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
warn("failed to register tty driver (error %d)", ret);
goto error;
}
- dbg(DEBUG_IF, "tty driver initialized");
+ gig_dbg(DEBUG_IF, "tty driver initialized");
drv->have_tty = 1;
return;
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index 5744eb91b315b..45f017ed6e8ca 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -10,10 +10,6 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: isocdata.c,v 1.2.2.5 2005/11/13 23:05:19 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
@@ -87,14 +83,14 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
{
if (!atomic_dec_and_test(&iwb->writesem)) {
atomic_inc(&iwb->writesem);
- dbg(DEBUG_ISO,
- "%s: couldn't acquire iso write semaphore", __func__);
+ gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
+ __func__);
return 0;
}
#ifdef CONFIG_GIGASET_DEBUG
- dbg(DEBUG_ISO,
- "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
- __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits);
+ gig_dbg(DEBUG_ISO,
+ "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
+ __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits);
#endif
return 1;
}
@@ -147,7 +143,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb)
/* recover the idle flag byte */
write = atomic_read(&iwb->write);
iwb->idle = iwb->data[write];
- dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle);
+ gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle);
/* mask extraneous bits in buffer */
iwb->data[write] &= (1 << iwb->wbits) - 1;
}
@@ -166,15 +162,14 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
read = atomic_read(&iwb->nextread);
write = atomic_read(&iwb->write);
if (likely(read == write)) {
- //dbg(DEBUG_STREAM, "%s: send buffer empty", __func__);
/* return idle frame */
return read < BAS_OUTBUFPAD ?
- BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD;
+ BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD;
}
limit = read + size;
- dbg(DEBUG_STREAM,
- "%s: read=%d write=%d limit=%d", __func__, read, write, limit);
+ gig_dbg(DEBUG_STREAM, "%s: read=%d write=%d limit=%d",
+ __func__, read, write, limit);
#ifdef CONFIG_GIGASET_DEBUG
if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) {
err("invalid size %d", size);
@@ -196,11 +191,12 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
return -EBUSY;
/* write position could have changed */
if (limit >= (write = atomic_read(&iwb->write))) {
- pbyte = iwb->data[write]; /* save partial byte */
+ pbyte = iwb->data[write]; /* save
+ partial byte */
limit = write + BAS_OUTBUFPAD;
- dbg(DEBUG_STREAM,
- "%s: filling %d->%d with %02x",
- __func__, write, limit, iwb->idle);
+ gig_dbg(DEBUG_STREAM,
+ "%s: filling %d->%d with %02x",
+ __func__, write, limit, iwb->idle);
if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE)
memset(iwb->data + write, iwb->idle,
BAS_OUTBUFPAD);
@@ -211,9 +207,11 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
- write);
limit = 0;
}
- dbg(DEBUG_STREAM, "%s: restoring %02x at %d",
- __func__, pbyte, limit);
- iwb->data[limit] = pbyte; /* restore partial byte */
+ gig_dbg(DEBUG_STREAM,
+ "%s: restoring %02x at %d",
+ __func__, pbyte, limit);
+ iwb->data[limit] = pbyte; /* restore
+ partial byte */
atomic_set(&iwb->write, limit);
}
isowbuf_donewrite(iwb);
@@ -242,19 +240,17 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
* write hex bytes to syslog for debugging
*/
static inline void dump_bytes(enum debuglevel level, const char *tag,
- unsigned char *bytes, int count)
+ unsigned char *bytes, int count)
{
#ifdef CONFIG_GIGASET_DEBUG
unsigned char c;
static char dbgline[3 * 32 + 1];
static const char hexdigit[] = "0123456789abcdef";
int i = 0;
- IFNULLRET(tag);
- IFNULLRET(bytes);
while (count-- > 0) {
if (i > sizeof(dbgline) - 4) {
dbgline[i] = '\0';
- dbg(level, "%s:%s", tag, dbgline);
+ gig_dbg(level, "%s:%s", tag, dbgline);
i = 0;
}
c = *bytes++;
@@ -264,7 +260,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
dbgline[i++] = hexdigit[c & 0x0f];
}
dbgline[i] = '\0';
- dbg(level, "%s:%s", tag, dbgline);
+ gig_dbg(level, "%s:%s", tag, dbgline);
#endif
}
@@ -380,7 +376,7 @@ static u16 stufftab[5 * 256] = {
*/
static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
- int ones)
+ int ones)
{
u16 stuff;
int shiftinc, newones;
@@ -422,7 +418,7 @@ static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
*/
static inline int hdlc_buildframe(struct isowbuf_t *iwb,
- unsigned char *in, int count)
+ unsigned char *in, int count)
{
int ones;
u16 fcs;
@@ -431,8 +427,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
!isowbuf_startwrite(iwb)) {
- dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
- __func__, isowbuf_freebytes(iwb));
+ gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
+ __func__, isowbuf_freebytes(iwb));
return -EAGAIN;
}
@@ -484,11 +480,11 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
if (isowbuf_freebytes(iwb) < count ||
!isowbuf_startwrite(iwb)) {
- dbg(DEBUG_ISO, "can't put %d bytes", count);
+ gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
return -EAGAIN;
}
- dbg(DEBUG_STREAM, "put %d bytes", count);
+ gig_dbg(DEBUG_STREAM, "put %d bytes", count);
write = atomic_read(&iwb->write);
do {
c = gigaset_invtab[*in++];
@@ -508,11 +504,13 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
switch (bcs->proto2) {
case ISDN_PROTO_L2_HDLC:
result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len);
- dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d", __func__, len, result);
+ gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d",
+ __func__, len, result);
break;
default: /* assume transparent */
result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len);
- dbg(DEBUG_ISO, "%s: %d bytes trans -> %d", __func__, len, result);
+ gig_dbg(DEBUG_ISO, "%s: %d bytes trans -> %d",
+ __func__, len, result);
}
return result;
}
@@ -528,13 +526,13 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
return;
}
if (unlikely(bcs->skb->len == SBUFSIZE)) {
- warn("received oversized packet discarded");
+ dev_warn(bcs->cs->dev, "received oversized packet discarded\n");
bcs->hw.bas->giants++;
dev_kfree_skb_any(bcs->skb);
bcs->skb = NULL;
return;
}
- *gigaset_skb_put_quick(bcs->skb, 1) = c;
+ *__skb_put(bcs->skb, 1) = c;
}
/* hdlc_flush
@@ -549,7 +547,7 @@ static inline void hdlc_flush(struct bc_state *bcs)
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN);
else
- err("could not allocate skb");
+ dev_err(bcs->cs->dev, "could not allocate skb\n");
}
/* reset packet state */
@@ -571,23 +569,25 @@ static inline void hdlc_done(struct bc_state *bcs)
if ((procskb = bcs->skb) == NULL) {
/* previous error */
- dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
+ gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
gigaset_rcv_error(NULL, bcs->cs, bcs);
} else if (procskb->len < 2) {
- notice("received short frame (%d octets)", procskb->len);
+ dev_notice(bcs->cs->dev, "received short frame (%d octets)\n",
+ procskb->len);
bcs->hw.bas->runts++;
gigaset_rcv_error(procskb, bcs->cs, bcs);
} else if (bcs->fcs != PPP_GOODFCS) {
- notice("frame check error (0x%04x)", bcs->fcs);
+ dev_notice(bcs->cs->dev, "frame check error (0x%04x)\n",
+ bcs->fcs);
bcs->hw.bas->fcserrs++;
gigaset_rcv_error(procskb, bcs->cs, bcs);
} else {
procskb->len -= 2; /* subtract FCS */
procskb->tail -= 2;
- dbg(DEBUG_ISO,
- "%s: good frame (%d octets)", __func__, procskb->len);
+ gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)",
+ __func__, procskb->len);
dump_bytes(DEBUG_STREAM,
- "rcv data", procskb->data, procskb->len);
+ "rcv data", procskb->data, procskb->len);
bcs->hw.bas->goodbytes += procskb->len;
gigaset_rcv_skb(procskb, bcs->cs, bcs);
}
@@ -595,7 +595,7 @@ static inline void hdlc_done(struct bc_state *bcs)
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN);
else
- err("could not allocate skb");
+ dev_err(bcs->cs->dev, "could not allocate skb\n");
bcs->fcs = PPP_INITFCS;
}
@@ -610,14 +610,14 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
return;
}
- notice("received partial byte (%d bits)", inbits);
+ dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
bcs->hw.bas->alignerrs++;
gigaset_rcv_error(bcs->skb, bcs->cs, bcs);
if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
skb_reserve(bcs->skb, HW_HDR_LEN);
else
- err("could not allocate skb");
+ dev_err(bcs->cs->dev, "could not allocate skb\n");
bcs->fcs = PPP_INITFCS;
}
@@ -659,16 +659,12 @@ static unsigned char bitcounts[256] = {
* bcs receiving B channel structure
*/
static inline void hdlc_unpack(unsigned char *src, unsigned count,
- struct bc_state *bcs)
+ struct bc_state *bcs)
{
- struct bas_bc_state *ubc;
+ struct bas_bc_state *ubc = bcs->hw.bas;
int inputstate;
unsigned seqlen, inbyte, inbits;
- IFNULLRET(bcs);
- ubc = bcs->hw.bas;
- IFNULLRET(ubc);
-
/* load previous state:
* inputstate = set of flag bits:
* - INS_flag_hunt: no complete opening flag received since connection setup or last abort
@@ -856,7 +852,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
* bcs receiving B channel structure
*/
static inline void trans_receive(unsigned char *src, unsigned count,
- struct bc_state *bcs)
+ struct bc_state *bcs)
{
struct sk_buff *skb;
int dobytes;
@@ -870,7 +866,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
if (unlikely((skb = bcs->skb) == NULL)) {
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
if (!skb) {
- err("could not allocate skb");
+ dev_err(bcs->cs->dev, "could not allocate skb\n");
return;
}
skb_reserve(skb, HW_HDR_LEN);
@@ -888,7 +884,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
gigaset_rcv_skb(skb, bcs->cs, bcs);
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
if (!skb) {
- err("could not allocate skb");
+ dev_err(bcs->cs->dev,
+ "could not allocate skb\n");
return;
}
skb_reserve(bcs->skb, HW_HDR_LEN);
@@ -921,8 +918,8 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
case '\r':
case '\n':
/* end of line */
- dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
- __func__, cbytes);
+ gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
+ __func__, cbytes);
cs->cbytes = cbytes;
gigaset_handle_modem_response(cs);
cbytes = 0;
@@ -932,7 +929,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
if (cbytes < MAX_RESP_SIZE - 1)
cbytes++;
else
- warn("response too large");
+ dev_warn(cs->dev, "response too large\n");
}
}
@@ -951,27 +948,27 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
head = atomic_read(&inbuf->head);
while (head != (tail = atomic_read(&inbuf->tail))) {
- dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
+ gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
if (head > tail)
tail = RBUFSIZE;
src = inbuf->data + head;
numbytes = tail - head;
- dbg(DEBUG_INTR, "processing %u bytes", numbytes);
+ gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
if (atomic_read(&cs->mstate) == MS_LOCKED) {
gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
- numbytes, src, 0);
+ numbytes, src);
gigaset_if_receive(inbuf->cs, src, numbytes);
} else {
gigaset_dbg_buffer(DEBUG_CMD, "received response",
- numbytes, src, 0);
+ numbytes, src);
cmd_loop(src, numbytes, inbuf);
}
head += numbytes;
if (head == RBUFSIZE)
head = 0;
- dbg(DEBUG_INTR, "setting head to %u", head);
+ gig_dbg(DEBUG_INTR, "setting head to %u", head);
atomic_set(&inbuf->head, head);
}
}
@@ -992,18 +989,18 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
*/
int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
{
- int len;
-
- IFNULLRETVAL(bcs, -EFAULT);
- IFNULLRETVAL(skb, -EFAULT);
- len = skb->len;
+ int len = skb->len;
+ unsigned long flags;
skb_queue_tail(&bcs->squeue, skb);
- dbg(DEBUG_ISO,
- "%s: skb queued, qlen=%d", __func__, skb_queue_len(&bcs->squeue));
+ gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d",
+ __func__, skb_queue_len(&bcs->squeue));
/* tasklet submits URB if necessary */
- tasklet_schedule(&bcs->hw.bas->sent_tasklet);
+ spin_lock_irqsave(&bcs->cs->lock, flags);
+ if (bcs->cs->connected)
+ tasklet_schedule(&bcs->hw.bas->sent_tasklet);
+ spin_unlock_irqrestore(&bcs->cs->lock, flags);
return len; /* ok so far */
}
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index c6915fa2be6cc..d267a636b53c6 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -1,7 +1,7 @@
/*
* Stuff used by all variants of the driver
*
- * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>,
+ * Copyright (c) 2001 by Stefan Eilers,
* Hansjoerg Lipp <hjlipp@web.de>,
* Tilman Schmidt <tilman@imap.cc>.
*
@@ -11,26 +11,29 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: proc.c,v 1.5.2.13 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
#include <linux/ctype.h>
-static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t show_cidmode(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
- struct usb_interface *intf = to_usb_interface(dev);
- struct cardstate *cs = usb_get_intfdata(intf);
- return sprintf(buf, "%d\n", atomic_read(&cs->cidmode)); // FIXME use scnprintf for 13607 bit architectures (if PAGE_SIZE==4096)
+ int ret;
+ unsigned long flags;
+ struct cardstate *cs = dev_get_drvdata(dev);
+
+ spin_lock_irqsave(&cs->lock, flags);
+ ret = sprintf(buf, "%u\n", cs->cidmode);
+ spin_unlock_irqrestore(&cs->lock, flags);
+
+ return ret;
}
-static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
{
- struct usb_interface *intf = to_usb_interface(dev);
- struct cardstate *cs = usb_get_intfdata(intf);
+ struct cardstate *cs = dev_get_drvdata(dev);
long int value;
char *end;
@@ -41,23 +44,23 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, co
if (value < 0 || value > 1)
return -EINVAL;
- if (down_interruptible(&cs->sem))
+ if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
cs->waiting = 1;
if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
- NULL, value, NULL)) {
+ NULL, value, NULL)) {
cs->waiting = 0;
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return -ENOMEM;
}
- dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
+ gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
gigaset_schedule_event(cs);
wait_event(cs->waitqueue, !cs->waiting);
- up(&cs->sem);
+ mutex_unlock(&cs->mutex);
return count;
}
@@ -65,17 +68,15 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, co
static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
/* free sysfs for device */
-void gigaset_free_dev_sysfs(struct usb_interface *interface)
+void gigaset_free_dev_sysfs(struct cardstate *cs)
{
- dbg(DEBUG_INIT, "removing sysfs entries");
- device_remove_file(&interface->dev, &dev_attr_cidmode);
+ gig_dbg(DEBUG_INIT, "removing sysfs entries");
+ device_remove_file(cs->dev, &dev_attr_cidmode);
}
-EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
/* initialize sysfs for device */
-void gigaset_init_dev_sysfs(struct usb_interface *interface)
+void gigaset_init_dev_sysfs(struct cardstate *cs)
{
- dbg(DEBUG_INIT, "setting up sysfs");
- device_create_file(&interface->dev, &dev_attr_cidmode);
+ gig_dbg(DEBUG_INIT, "setting up sysfs");
+ device_create_file(cs->dev, &dev_attr_cidmode);
}
-EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs);
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 323fc7349dec1..bfb73fd5077e8 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -1,7 +1,7 @@
/*
* USB driver for Gigaset 307x directly or using M105 Data.
*
- * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>
+ * Copyright (c) 2001 by Stefan Eilers
* and Hansjoerg Lipp <hjlipp@web.de>.
*
* This driver was derived from the USB skeleton driver by
@@ -13,10 +13,6 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* =====================================================================
- * ToDo: ...
- * =====================================================================
- * Version: $Id: usb-gigaset.c,v 1.85.4.18 2006/02/04 18:28:16 hjlipp Exp $
- * =====================================================================
*/
#include "gigaset.h"
@@ -29,7 +25,7 @@
#include <linux/moduleparam.h>
/* Version Information */
-#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Stefan Eilers <Eilers.Stefan@epost.de>"
+#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Stefan Eilers"
#define DRIVER_DESC "USB Driver for Gigaset 307x using M105"
/* Module parameters */
@@ -62,10 +58,6 @@ static struct usb_device_id gigaset_table [] = {
MODULE_DEVICE_TABLE(usb, gigaset_table);
-/* Get a minor range for your devices from the usb maintainer */
-#define USB_SKEL_MINOR_BASE 200
-
-
/*
* Control requests (empty fields: 00)
*
@@ -114,7 +106,7 @@ MODULE_DEVICE_TABLE(usb, gigaset_table);
*/
static int gigaset_probe(struct usb_interface *interface,
- const struct usb_device_id *id);
+ const struct usb_device_id *id);
static void gigaset_disconnect(struct usb_interface *interface);
static struct gigaset_driver *driver = NULL;
@@ -122,29 +114,29 @@ static struct cardstate *cardstate = NULL;
/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver gigaset_usb_driver = {
- .name = GIGASET_MODULENAME,
- .probe = gigaset_probe,
- .disconnect = gigaset_disconnect,
- .id_table = gigaset_table,
+ .name = GIGASET_MODULENAME,
+ .probe = gigaset_probe,
+ .disconnect = gigaset_disconnect,
+ .id_table = gigaset_table,
};
struct usb_cardstate {
- struct usb_device *udev; /* save off the usb device pointer */
- struct usb_interface *interface; /* the interface for this device */
- atomic_t busy; /* bulk output in progress */
-
- /* Output buffer for commands (M105: and data)*/
- unsigned char *bulk_out_buffer; /* the buffer to send data */
- int bulk_out_size; /* the size of the send buffer */
- __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */
- struct urb *bulk_out_urb; /* the urb used to transmit data */
-
- /* Input buffer for command responses (M105: and data)*/
- int rcvbuf_size; /* the size of the receive buffer */
- struct urb *read_urb; /* the urb used to receive data */
- __u8 int_in_endpointAddr; /* the address of the bulk in endpoint */
-
- char bchars[6]; /* req. 0x19 */
+ struct usb_device *udev; /* usb device pointer */
+ struct usb_interface *interface; /* interface for this device */
+ atomic_t busy; /* bulk output in progress */
+
+ /* Output buffer */
+ unsigned char *bulk_out_buffer;
+ int bulk_out_size;
+ __u8 bulk_out_endpointAddr;
+ struct urb *bulk_out_urb;
+
+ /* Input buffer */
+ int rcvbuf_size;
+ struct urb *read_urb;
+ __u8 int_in_endpointAddr;
+
+ char bchars[6]; /* for request 0x19 */
};
struct usb_bc_state {};
@@ -157,19 +149,20 @@ static inline unsigned tiocm_to_gigaset(unsigned state)
#ifdef CONFIG_GIGASET_UNDOCREQ
/* WARNING: EXPERIMENTAL! */
static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
- unsigned new_state)
+ unsigned new_state)
{
+ struct usb_device *udev = cs->hw.usb->udev;
unsigned mask, val;
int r;
mask = tiocm_to_gigaset(old_state ^ new_state);
val = tiocm_to_gigaset(new_state);
- dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask);
- r = usb_control_msg(cs->hw.usb->udev,
- usb_sndctrlpipe(cs->hw.usb->udev, 0), 7, 0x41,
- (val & 0xff) | ((mask & 0xff) << 8), 0,
- NULL, 0, 2000 /*timeout??*/); // don't use this in an interrupt/BH
+ gig_dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask);
+ // don't use this in an interrupt/BH
+ r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 7, 0x41,
+ (val & 0xff) | ((mask & 0xff) << 8), 0,
+ NULL, 0, 2000 /* timeout? */);
if (r < 0)
return r;
//..
@@ -178,30 +171,29 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
static int set_value(struct cardstate *cs, u8 req, u16 val)
{
+ struct usb_device *udev = cs->hw.usb->udev;
int r, r2;
- dbg(DEBUG_USBREQ, "request %02x (%04x)", (unsigned)req, (unsigned)val);
- r = usb_control_msg(cs->hw.usb->udev,
- usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x12, 0x41,
- 0xf /*?*/, 0,
- NULL, 0, 2000 /*?*/); /* no idea, what this does */
+ gig_dbg(DEBUG_USBREQ, "request %02x (%04x)",
+ (unsigned)req, (unsigned)val);
+ r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x12, 0x41,
+ 0xf /*?*/, 0, NULL, 0, 2000 /*?*/);
+ /* no idea what this does */
if (r < 0) {
- err("error %d on request 0x12", -r);
+ dev_err(&udev->dev, "error %d on request 0x12\n", -r);
return r;
}
- r = usb_control_msg(cs->hw.usb->udev,
- usb_sndctrlpipe(cs->hw.usb->udev, 0), req, 0x41,
- val, 0,
- NULL, 0, 2000 /*?*/);
+ r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), req, 0x41,
+ val, 0, NULL, 0, 2000 /*?*/);
if (r < 0)
- err("error %d on request 0x%02x", -r, (unsigned)req);
+ dev_err(&udev->dev, "error %d on request 0x%02x\n",
+ -r, (unsigned)req);
- r2 = usb_control_msg(cs->hw.usb->udev,
- usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41,
- 0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/);
+ r2 = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
+ 0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/);
if (r2 < 0)
- err("error %d on request 0x19", -r2);
+ dev_err(&udev->dev, "error %d on request 0x19\n", -r2);
return r < 0 ? r : (r2 < 0 ? r2 : 0);
}
@@ -229,8 +221,8 @@ static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
case B115200: rate = 115200; break;
default:
rate = 9600;
- err("unsupported baudrate request 0x%x,"
- " using default of B9600", cflag);
+ dev_err(cs->dev, "unsupported baudrate request 0x%x,"
+ " using default of B9600\n", cflag);
}
val = 0x383fff / rate + 1;
@@ -259,7 +251,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
case CS8:
val |= 8 << 8; break;
default:
- err("CSIZE was not CS5-CS8, using default of 8");
+ dev_err(cs->dev, "CSIZE was not CS5-CS8, using default of 8\n");
val |= 8 << 8;
break;
}
@@ -277,7 +269,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
#else
static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
- unsigned new_state)
+ unsigned new_state)
{
return -EINVAL;
}
@@ -309,15 +301,12 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
return 0;
}
-//void send_ack_to_LL(void *data);
static int write_modem(struct cardstate *cs);
static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb);
-/* Handling of send queue. If there is already a skb opened, put data to
- * the transfer buffer by calling "write_modem". Otherwise take a new skb out of the queue.
- * This function will be called by the ISR via "transmit_chars" (USB: B-Channel Bulk callback handler
- * via immediate task queue) or by writebuf_from_LL if the LL wants to transmit data.
+/* Write tasklet handler: Continue sending current skb, or send command, or
+ * start sending an skb from the send queue.
*/
static void gigaset_modem_fill(unsigned long data)
{
@@ -327,10 +316,10 @@ static void gigaset_modem_fill(unsigned long data)
unsigned long flags;
int again;
- dbg(DEBUG_OUTPUT, "modem_fill");
+ gig_dbg(DEBUG_OUTPUT, "modem_fill");
if (atomic_read(&cs->hw.usb->busy)) {
- dbg(DEBUG_OUTPUT, "modem_fill: busy");
+ gig_dbg(DEBUG_OUTPUT, "modem_fill: busy");
return;
}
@@ -341,26 +330,27 @@ static void gigaset_modem_fill(unsigned long data)
cb = cs->cmdbuf;
spin_unlock_irqrestore(&cs->cmdlock, flags);
if (cb) { /* commands to send? */
- dbg(DEBUG_OUTPUT, "modem_fill: cb");
+ gig_dbg(DEBUG_OUTPUT, "modem_fill: cb");
if (send_cb(cs, cb) < 0) {
- dbg(DEBUG_OUTPUT,
- "modem_fill: send_cb failed");
- again = 1; /* no callback will be called! */
+ gig_dbg(DEBUG_OUTPUT,
+ "modem_fill: send_cb failed");
+ again = 1; /* no callback will be
+ called! */
}
} else { /* skbs to send? */
bcs->tx_skb = skb_dequeue(&bcs->squeue);
if (bcs->tx_skb)
- dbg(DEBUG_INTR,
- "Dequeued skb (Adr: %lx)!",
- (unsigned long) bcs->tx_skb);
+ gig_dbg(DEBUG_INTR,
+ "Dequeued skb (Adr: %lx)!",
+ (unsigned long) bcs->tx_skb);
}
}
if (bcs->tx_skb) {
- dbg(DEBUG_OUTPUT, "modem_fill: tx_skb");
+ gig_dbg(DEBUG_OUTPUT, "modem_fill: tx_skb");
if (write_modem(cs) < 0) {
- dbg(DEBUG_OUTPUT,
- "modem_fill: write_modem failed");
+ gig_dbg(DEBUG_OUTPUT,
+ "modem_fill: write_modem failed");
// FIXME should we tell the LL?
again = 1; /* no callback will be called! */
}
@@ -371,88 +361,85 @@ static void gigaset_modem_fill(unsigned long data)
/**
* gigaset_read_int_callback
*
- * It is called if the data was received from the device. This is almost similiar to
- * the interrupt service routine in the serial device.
+ * It is called if the data was received from the device.
*/
static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
{
+ struct inbuf_t *inbuf = urb->context;
+ struct cardstate *cs = inbuf->cs;
int resubmit = 0;
int r;
- struct cardstate *cs;
unsigned numbytes;
unsigned char *src;
- //unsigned long flags;
- struct inbuf_t *inbuf;
-
- IFNULLRET(urb);
- inbuf = (struct inbuf_t *) urb->context;
- IFNULLRET(inbuf);
- //spin_lock_irqsave(&inbuf->lock, flags);
- cs = inbuf->cs;
- IFNULLGOTO(cs, exit);
- IFNULLGOTO(cardstate, exit);
-
- if (!atomic_read(&cs->connected)) {
- err("%s: disconnected", __func__);
- goto exit;
- }
+ unsigned long flags;
if (!urb->status) {
+ if (!cs->connected) {
+ err("%s: disconnected", __func__); /* should never happen */
+ return;
+ }
+
numbytes = urb->actual_length;
if (numbytes) {
src = inbuf->rcvbuf;
if (unlikely(*src))
- warn("%s: There was no leading 0, but 0x%02x!",
- __func__, (unsigned) *src);
+ dev_warn(cs->dev,
+ "%s: There was no leading 0, but 0x%02x!\n",
+ __func__, (unsigned) *src);
++src; /* skip leading 0x00 */
--numbytes;
if (gigaset_fill_inbuf(inbuf, src, numbytes)) {
- dbg(DEBUG_INTR, "%s-->BH", __func__);
+ gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
gigaset_schedule_event(inbuf->cs);
}
} else
- dbg(DEBUG_INTR, "Received zero block length");
+ gig_dbg(DEBUG_INTR, "Received zero block length");
resubmit = 1;
} else {
/* The urb might have been killed. */
- dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d",
- __func__, urb->status);
- if (urb->status != -ENOENT) /* not killed */
+ gig_dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d",
+ __func__, urb->status);
+ if (urb->status != -ENOENT) { /* not killed */
+ if (!cs->connected) {
+ err("%s: disconnected", __func__); /* should never happen */
+ return;
+ }
resubmit = 1;
+ }
}
-exit:
- //spin_unlock_irqrestore(&inbuf->lock, flags);
+
if (resubmit) {
- r = usb_submit_urb(urb, SLAB_ATOMIC);
+ spin_lock_irqsave(&cs->lock, flags);
+ r = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV;
+ spin_unlock_irqrestore(&cs->lock, flags);
if (r)
- err("error %d when resubmitting urb.", -r);
+ dev_err(cs->dev, "error %d when resubmitting urb.\n",
+ -r);
}
}
-/* This callback routine is called when data was transmitted to a B-Channel.
- * Therefore it has to check if there is still data to transmit. This
- * happens by calling modem_fill via task queue.
- *
- */
+/* This callback routine is called when data was transmitted to the device. */
static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
{
- struct cardstate *cs = (struct cardstate *) urb->context;
+ struct cardstate *cs = urb->context;
+ unsigned long flags;
- IFNULLRET(cs);
-#ifdef CONFIG_GIGASET_DEBUG
- if (!atomic_read(&cs->connected)) {
- err("%s:not connected", __func__);
- return;
- }
-#endif
if (urb->status)
- err("bulk transfer failed (status %d)", -urb->status); /* That's all we can do. Communication problems
- are handeled by timeouts or network protocols */
+ dev_err(cs->dev, "bulk transfer failed (status %d)\n",
+ -urb->status);
+ /* That's all we can do. Communication problems
+ are handled by timeouts or network protocols. */
- atomic_set(&cs->hw.usb->busy, 0);
- tasklet_schedule(&cs->write_tasklet);
+ spin_lock_irqsave(&cs->lock, flags);
+ if (!cs->connected) {
+ err("%s: not connected", __func__);
+ } else {
+ atomic_set(&cs->hw.usb->busy, 0);
+ tasklet_schedule(&cs->write_tasklet);
+ }
+ spin_unlock_irqrestore(&cs->lock, flags);
}
static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
@@ -469,8 +456,8 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
spin_lock_irqsave(&cs->cmdlock, flags);
cs->cmdbytes -= cs->curlen;
- dbg(DEBUG_OUTPUT, "send_cb: sent %u bytes, %u left",
- cs->curlen, cs->cmdbytes);
+ gig_dbg(DEBUG_OUTPUT, "send_cb: sent %u bytes, %u left",
+ cs->curlen, cs->cmdbytes);
cs->cmdbuf = cb = cb->next;
if (cb) {
cb->prev = NULL;
@@ -487,52 +474,51 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
}
if (cb) {
count = min(cb->len, ucs->bulk_out_size);
+ gig_dbg(DEBUG_OUTPUT, "send_cb: send %d bytes", count);
+
usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev,
- usb_sndbulkpipe(ucs->udev,
- ucs->bulk_out_endpointAddr & 0x0f),
- cb->buf + cb->offset, count,
- gigaset_write_bulk_callback, cs);
+ usb_sndbulkpipe(ucs->udev,
+ ucs->bulk_out_endpointAddr & 0x0f),
+ cb->buf + cb->offset, count,
+ gigaset_write_bulk_callback, cs);
cb->offset += count;
cb->len -= count;
atomic_set(&ucs->busy, 1);
- dbg(DEBUG_OUTPUT, "send_cb: send %d bytes", count);
- status = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
+ spin_lock_irqsave(&cs->lock, flags);
+ status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC) : -ENODEV;
+ spin_unlock_irqrestore(&cs->lock, flags);
+
if (status) {
atomic_set(&ucs->busy, 0);
- err("could not submit urb (error %d).",
+ err("could not submit urb (error %d)\n",
-status);
- cb->len = 0; /* skip urb => remove cb+wakeup in next loop cycle */
+ cb->len = 0; /* skip urb => remove cb+wakeup
+ in next loop cycle */
}
}
- } while (cb && status); /* bei Fehler naechster Befehl //FIXME: ist das OK? */
+ } while (cb && status); /* next command on error */
return status;
}
-/* Write string into transbuf and send it to modem.
- */
+/* Send command to device. */
static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
- int len, struct tasklet_struct *wake_tasklet)
+ int len, struct tasklet_struct *wake_tasklet)
{
struct cmdbuf_t *cb;
unsigned long flags;
gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ?
- DEBUG_TRANSCMD : DEBUG_LOCKCMD,
- "CMD Transmit", len, buf, 0);
-
- if (!atomic_read(&cs->connected)) {
- err("%s: not connected", __func__);
- return -ENODEV;
- }
+ DEBUG_TRANSCMD : DEBUG_LOCKCMD,
+ "CMD Transmit", len, buf);
if (len <= 0)
return 0;
if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) {
- err("%s: out of memory", __func__);
+ dev_err(cs->dev, "%s: out of memory\n", __func__);
return -ENOMEM;
}
@@ -554,7 +540,10 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
cs->lastcmdbuf = cb;
spin_unlock_irqrestore(&cs->cmdlock, flags);
- tasklet_schedule(&cs->write_tasklet);
+ spin_lock_irqsave(&cs->lock, flags);
+ if (cs->connected)
+ tasklet_schedule(&cs->write_tasklet);
+ spin_unlock_irqrestore(&cs->lock, flags);
return len;
}
@@ -578,11 +567,12 @@ static int gigaset_chars_in_buffer(struct cardstate *cs)
static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
{
#ifdef CONFIG_GIGASET_UNDOCREQ
- gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf, 0);
+ struct usb_device *udev = cs->hw.usb->udev;
+
+ gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
memcpy(cs->hw.usb->bchars, buf, 6);
- return usb_control_msg(cs->hw.usb->udev,
- usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41,
- 0, 0, &buf, 6, 2000);
+ return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
+ 0, 0, &buf, 6, 2000);
#else
return -EINVAL;
#endif
@@ -604,7 +594,6 @@ static int gigaset_initbcshw(struct bc_state *bcs)
if (!bcs->hw.usb)
return 0;
- //bcs->hw.usb->trans_flg = READY_TO_TRNSMIT; /* B-Channel ready to transmit */
return 1;
}
@@ -614,7 +603,6 @@ static void gigaset_reinitbcshw(struct bc_state *bcs)
static void gigaset_freecshw(struct cardstate *cs)
{
- //FIXME
tasklet_kill(&cs->write_tasklet);
kfree(cs->hw.usb);
}
@@ -639,33 +627,21 @@ static int gigaset_initcshw(struct cardstate *cs)
//ucs->urb_cmd_out = NULL;
ucs->read_urb = NULL;
tasklet_init(&cs->write_tasklet,
- &gigaset_modem_fill, (unsigned long) cs);
+ &gigaset_modem_fill, (unsigned long) cs);
return 1;
}
-/* Writes the data of the current open skb into the modem.
- * We have to protect against multiple calls until the
- * callback handler () is called , due to the fact that we
- * are just allowed to send data once to an endpoint. Therefore
- * we using "trans_flg" to synchonize ...
- */
+/* Send data from current skb to the device. */
static int write_modem(struct cardstate *cs)
{
- int ret;
+ int ret = 0;
int count;
struct bc_state *bcs = &cs->bcs[0]; /* only one channel */
struct usb_cardstate *ucs = cs->hw.usb;
- //unsigned long flags;
-
- IFNULLRETVAL(bcs->tx_skb, -EINVAL);
-
- dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len);
+ unsigned long flags;
- ret = -ENODEV;
- IFNULLGOTO(ucs->bulk_out_buffer, error);
- IFNULLGOTO(ucs->bulk_out_urb, error);
- ret = 0;
+ gig_dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len);
if (!bcs->tx_skb->len) {
dev_kfree_skb_any(bcs->tx_skb);
@@ -679,40 +655,42 @@ static int write_modem(struct cardstate *cs)
count = min(bcs->tx_skb->len, (unsigned) ucs->bulk_out_size);
memcpy(ucs->bulk_out_buffer, bcs->tx_skb->data, count);
skb_pull(bcs->tx_skb, count);
-
- usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev,
- usb_sndbulkpipe(ucs->udev,
- ucs->bulk_out_endpointAddr & 0x0f),
- ucs->bulk_out_buffer, count,
- gigaset_write_bulk_callback, cs);
atomic_set(&ucs->busy, 1);
- dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count);
+ gig_dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count);
+
+ spin_lock_irqsave(&cs->lock, flags);
+ if (cs->connected) {
+ usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev,
+ usb_sndbulkpipe(ucs->udev,
+ ucs->bulk_out_endpointAddr & 0x0f),
+ ucs->bulk_out_buffer, count,
+ gigaset_write_bulk_callback, cs);
+ ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
+ } else {
+ ret = -ENODEV;
+ }
+ spin_unlock_irqrestore(&cs->lock, flags);
- ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
if (ret) {
- err("could not submit urb (error %d).", -ret);
+ err("could not submit urb (error %d)\n", -ret);
atomic_set(&ucs->busy, 0);
}
+
if (!bcs->tx_skb->len) {
/* skb sent completely */
gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0?
- dbg(DEBUG_INTR,
- "kfree skb (Adr: %lx)!", (unsigned long) bcs->tx_skb);
+ gig_dbg(DEBUG_INTR, "kfree skb (Adr: %lx)!",
+ (unsigned long) bcs->tx_skb);
dev_kfree_skb_any(bcs->tx_skb);
bcs->tx_skb = NULL;
}
return ret;
-error:
- dev_kfree_skb_any(bcs->tx_skb);
- bcs->tx_skb = NULL;
- return ret;
-
}
static int gigaset_probe(struct usb_interface *interface,
- const struct usb_device_id *id)
+ const struct usb_device_id *id)
{
int retval;
struct usb_device *udev = interface_to_usbdev(interface);
@@ -720,16 +698,14 @@ static int gigaset_probe(struct usb_interface *interface,
struct usb_host_interface *hostif;
struct cardstate *cs = NULL;
struct usb_cardstate *ucs = NULL;
- //struct usb_interface_descriptor *iface_desc;
struct usb_endpoint_descriptor *endpoint;
- //isdn_ctrl command;
int buffer_size;
int alt;
- //unsigned long flags;
- info("%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
- __func__, le16_to_cpu(udev->descriptor.idVendor),
- le16_to_cpu(udev->descriptor.idProduct));
+ gig_dbg(DEBUG_ANY,
+ "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
+ __func__, le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
retval = -ENODEV; //FIXME
@@ -744,7 +720,7 @@ static int gigaset_probe(struct usb_interface *interface,
ifnum = hostif->desc.bInterfaceNumber; // FIXME ?
if (alt != 0 || ifnum != 0) {
- warn("ifnum %d, alt %d", ifnum, alt);
+ dev_warn(&udev->dev, "ifnum %d, alt %d\n", ifnum, alt);
return -ENODEV;
}
@@ -752,42 +728,29 @@ static int gigaset_probe(struct usb_interface *interface,
*
*/
if (hostif->desc.bInterfaceClass != 255) {
- info("%s: Device matched, but iface_desc[%d]->bInterfaceClass==%d !",
- __func__, ifnum, hostif->desc.bInterfaceClass);
+ dev_info(&udev->dev,
+ "%s: Device matched but iface_desc[%d]->bInterfaceClass==%d!\n",
+ __func__, ifnum, hostif->desc.bInterfaceClass);
return -ENODEV;
}
- info("%s: Device matched ... !", __func__);
+ dev_info(&udev->dev, "%s: Device matched ... !\n", __func__);
cs = gigaset_getunassignedcs(driver);
if (!cs) {
- warn("No free cardstate!");
+ dev_warn(&udev->dev, "no free cardstate\n");
return -ENODEV;
}
ucs = cs->hw.usb;
-#if 0
- if (usb_set_configuration(udev, udev->config[0].desc.bConfigurationValue) < 0) {
- warn("set_configuration failed");
- goto error;
- }
-
-
- if (usb_set_interface(udev, ifnum/*==0*/, alt/*==0*/) < 0) {
- warn("usb_set_interface failed, device %d interface %d altsetting %d",
- udev->devnum, ifnum, alt);
- goto error;
- }
-#endif
+ /* save off device structure ptrs for later use */
+ usb_get_dev(udev);
+ ucs->udev = udev;
+ ucs->interface = interface;
+ cs->dev = &interface->dev;
- /* set up the endpoint information */
- /* check out the endpoints */
- /* We will get 2 endpoints: One for sending commands to the device (bulk out) and one to
- * poll messages from the device(int in).
- * Therefore we will have an almost similiar situation as with our serial port handler.
- * If an connection will be established, we will have to create data in/out pipes
- * dynamically...
- */
+ /* save address of controller structure */
+ usb_set_intfdata(interface, cs); // dev_set_drvdata(&interface->dev, cs);
endpoint = &hostif->endpoint[0].desc;
@@ -796,14 +759,14 @@ static int gigaset_probe(struct usb_interface *interface,
ucs->bulk_out_endpointAddr = endpoint->bEndpointAddress;
ucs->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!ucs->bulk_out_buffer) {
- err("Couldn't allocate bulk_out_buffer");
+ dev_err(cs->dev, "Couldn't allocate bulk_out_buffer\n");
retval = -ENOMEM;
goto error;
}
ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->bulk_out_urb) {
- err("Couldn't allocate bulk_out_buffer");
+ dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
retval = -ENOMEM;
goto error;
}
@@ -811,12 +774,10 @@ static int gigaset_probe(struct usb_interface *interface,
endpoint = &hostif->endpoint[1].desc;
atomic_set(&ucs->busy, 0);
- ucs->udev = udev;
- ucs->interface = interface;
ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL);
if (!ucs->read_urb) {
- err("No free urbs available");
+ dev_err(cs->dev, "No free urbs available\n");
retval = -ENOMEM;
goto error;
}
@@ -825,38 +786,33 @@ static int gigaset_probe(struct usb_interface *interface,
ucs->int_in_endpointAddr = endpoint->bEndpointAddress;
cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL);
if (!cs->inbuf[0].rcvbuf) {
- err("Couldn't allocate rcvbuf");
+ dev_err(cs->dev, "Couldn't allocate rcvbuf\n");
retval = -ENOMEM;
goto error;
}
/* Fill the interrupt urb and send it to the core */
usb_fill_int_urb(ucs->read_urb, udev,
- usb_rcvintpipe(udev,
- endpoint->bEndpointAddress & 0x0f),
- cs->inbuf[0].rcvbuf, buffer_size,
- gigaset_read_int_callback,
- cs->inbuf + 0, endpoint->bInterval);
+ usb_rcvintpipe(udev,
+ endpoint->bEndpointAddress & 0x0f),
+ cs->inbuf[0].rcvbuf, buffer_size,
+ gigaset_read_int_callback,
+ cs->inbuf + 0, endpoint->bInterval);
retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL);
if (retval) {
- err("Could not submit URB!");
+ dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
goto error;
}
/* tell common part that the device is ready */
if (startmode == SM_LOCKED)
atomic_set(&cs->mstate, MS_LOCKED);
+
if (!gigaset_start(cs)) {
tasklet_kill(&cs->write_tasklet);
retval = -ENODEV; //FIXME
goto error;
}
-
- /* save address of controller structure */
- usb_set_intfdata(interface, cs);
-
- /* set up device sysfs */
- gigaset_init_dev_sysfs(interface);
return 0;
error:
@@ -868,48 +824,45 @@ error:
kfree(cs->inbuf[0].rcvbuf);
if (ucs->read_urb != NULL)
usb_free_urb(ucs->read_urb);
+ usb_set_intfdata(interface, NULL);
ucs->read_urb = ucs->bulk_out_urb = NULL;
cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
+ usb_put_dev(ucs->udev);
+ ucs->udev = NULL;
+ ucs->interface = NULL;
gigaset_unassign(cs);
return retval;
}
-/**
- * skel_disconnect
- */
static void gigaset_disconnect(struct usb_interface *interface)
{
struct cardstate *cs;
struct usb_cardstate *ucs;
cs = usb_get_intfdata(interface);
-
- /* clear device sysfs */
- gigaset_free_dev_sysfs(interface);
-
- usb_set_intfdata(interface, NULL);
ucs = cs->hw.usb;
usb_kill_urb(ucs->read_urb);
- //info("GigaSet USB device #%d will be disconnected", minor);
gigaset_stop(cs);
+ usb_set_intfdata(interface, NULL);
tasklet_kill(&cs->write_tasklet);
- usb_kill_urb(ucs->bulk_out_urb); /* FIXME: nur, wenn noetig */
- //usb_kill_urb(ucs->urb_cmd_out); /* FIXME: nur, wenn noetig */
+ usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */
kfree(ucs->bulk_out_buffer);
if (ucs->bulk_out_urb != NULL)
usb_free_urb(ucs->bulk_out_urb);
- //if(ucs->urb_cmd_out != NULL)
- // usb_free_urb(ucs->urb_cmd_out);
kfree(cs->inbuf[0].rcvbuf);
if (ucs->read_urb != NULL)
usb_free_urb(ucs->read_urb);
- ucs->read_urb = ucs->bulk_out_urb/*=ucs->urb_cmd_out*/=NULL;
+ ucs->read_urb = ucs->bulk_out_urb = NULL;
cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
+ usb_put_dev(ucs->udev);
+ ucs->interface = NULL;
+ ucs->udev = NULL;
+ cs->dev = NULL;
gigaset_unassign(cs);
}
@@ -942,9 +895,9 @@ static int __init usb_gigaset_init(void)
/* allocate memory for our driver state and intialize it */
if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
- GIGASET_MODULENAME, GIGASET_DEVNAME,
- GIGASET_DEVFSNAME, &ops,
- THIS_MODULE)) == NULL)
+ GIGASET_MODULENAME, GIGASET_DEVNAME,
+ GIGASET_DEVFSNAME, &ops,
+ THIS_MODULE)) == NULL)
goto error;
/* allocate memory for our device state and intialize it */
@@ -981,8 +934,8 @@ error: if (cardstate)
static void __exit usb_gigaset_exit(void)
{
gigaset_blockdriver(driver); /* => probe will fail
- * => no gigaset_start any more
- */
+ * => no gigaset_start any more
+ */
gigaset_shutdown(cardstate);
/* from now on, no isdn callback should be possible */
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index a0927d1b7a0c9..918742271c79f 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -109,7 +109,7 @@ isdn_ppp_free(isdn_net_local * lp)
{
struct ippp_struct *is;
- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) {
+ if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: ppp_slot(%d) out of range\n",
__FUNCTION__, lp->ppp_slot);
return 0;
@@ -126,7 +126,7 @@ isdn_ppp_free(isdn_net_local * lp)
lp->netdev->pb->ref_ct--;
spin_unlock(&lp->netdev->pb->lock);
#endif /* CONFIG_ISDN_MPP */
- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) {
+ if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: ppp_slot(%d) now invalid\n",
__FUNCTION__, lp->ppp_slot);
return 0;
@@ -279,7 +279,7 @@ isdn_ppp_open(int min, struct file *file)
int slot;
struct ippp_struct *is;
- if (min < 0 || min > ISDN_MAX_CHANNELS)
+ if (min < 0 || min >= ISDN_MAX_CHANNELS)
return -ENODEV;
slot = isdn_ppp_get_slot();
@@ -1042,7 +1042,7 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff
if (lp->master) { // FIXME?
mlp = (isdn_net_local *) lp->master->priv;
slot = mlp->ppp_slot;
- if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n",
lp->ppp_slot);
goto drop_packet;
@@ -1264,7 +1264,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
/* we have our lp locked from now on */
slot = lp->ppp_slot;
- if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n",
lp->ppp_slot);
kfree_skb(skb);
@@ -1603,7 +1603,7 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
mp = net_dev->pb;
stats = &mp->stats;
slot = lp->ppp_slot;
- if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: lp->ppp_slot(%d)\n",
__FUNCTION__, lp->ppp_slot);
stats->frame_drops++;
@@ -1640,7 +1640,7 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
is->last_link_seqno = minseq = newseq;
for (lpq = net_dev->queue;;) {
slot = lpq->ppp_slot;
- if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: lpq->ppp_slot(%d)\n",
__FUNCTION__, lpq->ppp_slot);
} else {
@@ -2648,7 +2648,7 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
printk(KERN_DEBUG "Received CCP frame from peer slot(%d)\n",
lp->ppp_slot);
- if (lp->ppp_slot < 0 || lp->ppp_slot > ISDN_MAX_CHANNELS) {
+ if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n",
__FUNCTION__, lp->ppp_slot);
return;
@@ -2658,7 +2658,7 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
if(lp->master) {
int slot = ((isdn_net_local *) (lp->master->priv))->ppp_slot;
- if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: slot(%d) out of range\n",
__FUNCTION__, slot);
return;
@@ -2845,7 +2845,7 @@ static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct
if (lp->master) {
slot = ((isdn_net_local *) (lp->master->priv))->ppp_slot;
- if (slot < 0 || slot > ISDN_MAX_CHANNELS) {
+ if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
printk(KERN_ERR "%s: slot(%d) out of range\n",
__FUNCTION__, slot);
return;
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 2c4f20b7f0215..3f5b647945426 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -14,13 +14,7 @@ config LEDS_CLASS
This option enables the led sysfs class in /sys/class/leds. You'll
need this to do anything useful with LEDs. If unsure, say N.
-config LEDS_TRIGGERS
- bool "LED Trigger support"
- depends NEW_LEDS
- help
- This option enables trigger support for the leds class.
- These triggers allow kernel events to drive the LEDs and can
- be configured via sysfs. If unsure, say Y.
+comment "LED drivers"
config LEDS_CORGI
tristate "LED Support for the Sharp SL-C7x0 series"
@@ -59,6 +53,23 @@ config LEDS_TOSA
This option enables support for the LEDs on Sharp Zaurus
SL-6000 series.
+config LEDS_S3C24XX
+ tristate "LED Support for Samsung S3C24XX GPIO LEDs"
+ depends on LEDS_CLASS && ARCH_S3C2410
+ help
+ This option enables support for LEDs connected to GPIO lines
+ on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440.
+
+comment "LED Triggers"
+
+config LEDS_TRIGGERS
+ bool "LED Trigger support"
+ depends NEW_LEDS
+ help
+ This option enables trigger support for the leds class.
+ These triggers allow kernel events to drive the LEDs and can
+ be configured via sysfs. If unsure, say Y.
+
config LEDS_TRIGGER_TIMER
tristate "LED Timer Trigger"
depends LEDS_TRIGGERS
@@ -67,7 +78,7 @@ config LEDS_TRIGGER_TIMER
via sysfs. If unsure, say Y.
config LEDS_TRIGGER_IDE_DISK
- bool "LED Timer Trigger"
+ bool "LED IDE Disk Trigger"
depends LEDS_TRIGGERS && BLK_DEV_IDEDISK
help
This allows LEDs to be controlled by IDE disk activity.
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 40699d3cabbf3..40f042633bf54 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o
obj-$(CONFIG_LEDS_IXP4XX) += leds-ixp4xx-gpio.o
obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
+obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
# LED Triggers
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
new file mode 100644
index 0000000000000..650cf72dc675e
--- /dev/null
+++ b/drivers/leds/leds-s3c24xx.c
@@ -0,0 +1,163 @@
+/* drivers/leds/leds-s3c24xx.c
+ *
+ * (c) 2006 Simtec Electronics
+ * http://armlinux.simtec.co.uk/
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C24XX - LEDs GPIO driver
+ *
+ * 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.
+*/
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/leds-gpio.h>
+
+/* our context */
+
+struct s3c24xx_gpio_led {
+ struct led_classdev cdev;
+ struct s3c24xx_led_platdata *pdata;
+};
+
+static inline struct s3c24xx_gpio_led *pdev_to_gpio(struct platform_device *dev)
+{
+ return platform_get_drvdata(dev);
+}
+
+static inline struct s3c24xx_gpio_led *to_gpio(struct led_classdev *led_cdev)
+{
+ return container_of(led_cdev, struct s3c24xx_gpio_led, cdev);
+}
+
+static void s3c24xx_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ struct s3c24xx_gpio_led *led = to_gpio(led_cdev);
+ struct s3c24xx_led_platdata *pd = led->pdata;
+
+ /* there will be a sort delay between setting the output and
+ * going from output to input when using tristate. */
+
+ s3c2410_gpio_setpin(pd->gpio, (value ? 1 : 0) ^
+ (pd->flags & S3C24XX_LEDF_ACTLOW));
+
+ if (pd->flags & S3C24XX_LEDF_TRISTATE)
+ s3c2410_gpio_cfgpin(pd->gpio,
+ value ? S3C2410_GPIO_OUTPUT : S3C2410_GPIO_INPUT);
+
+}
+
+static int s3c24xx_led_remove(struct platform_device *dev)
+{
+ struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
+
+ led_classdev_unregister(&led->cdev);
+ kfree(led);
+
+ return 0;
+}
+
+static int s3c24xx_led_probe(struct platform_device *dev)
+{
+ struct s3c24xx_led_platdata *pdata = dev->dev.platform_data;
+ struct s3c24xx_gpio_led *led;
+ int ret;
+
+ led = kzalloc(sizeof(struct s3c24xx_gpio_led), GFP_KERNEL);
+ if (led == NULL) {
+ dev_err(&dev->dev, "No memory for device\n");
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(dev, led);
+
+ led->cdev.brightness_set = s3c24xx_led_set;
+ led->cdev.default_trigger = pdata->def_trigger;
+ led->cdev.name = pdata->name;
+
+ led->pdata = pdata;
+
+ /* no point in having a pull-up if we are always driving */
+
+ if (pdata->flags & S3C24XX_LEDF_TRISTATE) {
+ s3c2410_gpio_setpin(pdata->gpio, 0);
+ s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_INPUT);
+ } else {
+ s3c2410_gpio_pullup(pdata->gpio, 0);
+ s3c2410_gpio_setpin(pdata->gpio, 0);
+ s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_OUTPUT);
+ }
+
+ /* register our new led device */
+
+ ret = led_classdev_register(&dev->dev, &led->cdev);
+ if (ret < 0) {
+ dev_err(&dev->dev, "led_classdev_register failed\n");
+ goto exit_err1;
+ }
+
+ return 0;
+
+ exit_err1:
+ kfree(led);
+ return ret;
+}
+
+
+#ifdef CONFIG_PM
+static int s3c24xx_led_suspend(struct platform_device *dev, pm_message_t state)
+{
+ struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
+
+ led_classdev_suspend(&led->cdev);
+ return 0;
+}
+
+static int s3c24xx_led_resume(struct platform_device *dev)
+{
+ struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
+
+ led_classdev_resume(&led->cdev);
+ return 0;
+}
+#else
+#define s3c24xx_led_suspend NULL
+#define s3c24xx_led_resume NULL
+#endif
+
+static struct platform_driver s3c24xx_led_driver = {
+ .probe = s3c24xx_led_probe,
+ .remove = s3c24xx_led_remove,
+ .suspend = s3c24xx_led_suspend,
+ .resume = s3c24xx_led_resume,
+ .driver = {
+ .name = "s3c24xx_led",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init s3c24xx_led_init(void)
+{
+ return platform_driver_register(&s3c24xx_led_driver);
+}
+
+static void __exit s3c24xx_led_exit(void)
+{
+ platform_driver_unregister(&s3c24xx_led_driver);
+}
+
+module_init(s3c24xx_led_init);
+module_exit(s3c24xx_led_exit);
+
+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
+MODULE_DESCRIPTION("S3C24XX LED driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index fd2aae150ccc5..ac25a48362aca 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -139,11 +139,12 @@ config MD_RAID5_RESHAPE
is online. However it is still EXPERIMENTAL code. It should
work, but please be sure that you have backups.
- You will need a version of mdadm newer than 2.3.1. During the
- early stage of reshape there is a critical section where live data
- is being over-written. A crash during this time needs extra care
- for recovery. The newer mdadm takes a copy of the data in the
- critical section and will restore it, if necessary, after a crash.
+ You will need mdadm verion 2.4.1 or later to use this
+ feature safely. During the early stage of reshape there is
+ a critical section where live data is being over-written. A
+ crash during this time needs extra care for recovery. The
+ newer mdadm takes a copy of the data in the critical section
+ and will restore it, if necessary, after a crash.
The mdadm usage is e.g.
mdadm --grow /dev/md1 --raid-disks=6
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 4092a5e37ffce..b3ea2d63db9b0 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -84,4 +84,4 @@ obj-$(CONFIG_USB_IBMCAM) += usbvideo/
obj-$(CONFIG_USB_KONICAWC) += usbvideo/
obj-$(CONFIG_USB_VICAM) += usbvideo/
-EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
+EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
diff --git a/drivers/media/video/bt8xx/Makefile b/drivers/media/video/bt8xx/Makefile
index 94350f21cdc0a..db641a36b197a 100644
--- a/drivers/media/video/bt8xx/Makefile
+++ b/drivers/media/video/bt8xx/Makefile
@@ -9,4 +9,4 @@ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
obj-$(CONFIG_VIDEO_BT848) += bttv.o
EXTRA_CFLAGS += -I$(src)/..
-EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
+EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
diff --git a/drivers/media/video/cx25840/Makefile b/drivers/media/video/cx25840/Makefile
index 32a896c23d1e4..6e8665be8954f 100644
--- a/drivers/media/video/cx25840/Makefile
+++ b/drivers/media/video/cx25840/Makefile
@@ -3,4 +3,4 @@ cx25840-objs := cx25840-core.o cx25840-audio.o cx25840-firmware.o \
obj-$(CONFIG_VIDEO_CX25840) += cx25840.o
-EXTRA_CFLAGS += -I$(src)/..
+EXTRA_CFLAGS += -Idrivers/media/video
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index 6482b9aa6a1fa..0dcd09b9b727a 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -8,9 +8,9 @@ obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o
obj-$(CONFIG_VIDEO_CX88_ALSA) += cx88-alsa.o
obj-$(CONFIG_VIDEO_CX88_VP3054) += cx88-vp3054-i2c.o
-EXTRA_CFLAGS += -I$(src)/..
-EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
-EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
+EXTRA_CFLAGS += -Idrivers/media/video
+EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
+EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
extra-cflags-$(CONFIG_DVB_CX22702) += -DHAVE_CX22702=1
diff --git a/drivers/media/video/em28xx/Makefile b/drivers/media/video/em28xx/Makefile
index da457a05b0dd4..826d0e3407535 100644
--- a/drivers/media/video/em28xx/Makefile
+++ b/drivers/media/video/em28xx/Makefile
@@ -3,4 +3,4 @@ em28xx-objs := em28xx-video.o em28xx-i2c.o em28xx-cards.o em28xx-core.o \
obj-$(CONFIG_VIDEO_EM28XX) += em28xx.o
-EXTRA_CFLAGS += -I$(src)/..
+EXTRA_CFLAGS += -Idrivers/media/video
diff --git a/drivers/media/video/saa7134/Makefile b/drivers/media/video/saa7134/Makefile
index 1ba998424bbdc..be7b9ee697d6c 100644
--- a/drivers/media/video/saa7134/Makefile
+++ b/drivers/media/video/saa7134/Makefile
@@ -11,9 +11,9 @@ obj-$(CONFIG_VIDEO_SAA7134_OSS) += saa7134-oss.o
obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
-EXTRA_CFLAGS += -I$(src)/..
-EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
-EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
+EXTRA_CFLAGS += -Idrivers/media/video
+EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
+EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index c98571c9d5a63..13de05532e0ac 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -32,6 +32,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/mutex.h>
+#include <linux/dma-mapping.h>
#include "saa7134-reg.h"
#include "saa7134.h"
@@ -870,7 +871,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
dev->pci_lat,pci_resource_start(pci_dev,0));
pci_set_master(pci_dev);
- if (!pci_dma_supported(pci_dev,0xffffffff)) {
+ if (!pci_dma_supported(pci_dev, DMA_32BIT_MASK)) {
printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name);
err = -EIO;
goto fail1;
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 7cc162e8978be..003b077c2324c 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -91,4 +91,22 @@ config MMC_AU1X
If unsure, say N.
+config MMC_AT91RM9200
+ tristate "AT91RM9200 SD/MMC Card Interface support"
+ depends on ARCH_AT91RM9200 && MMC
+ help
+ This selects the AT91RM9200 MCI controller.
+
+ If unsure, say N.
+
+config MMC_IMX
+ tristate "Motorola i.MX Multimedia Card Interface support"
+ depends on ARCH_IMX && MMC
+ help
+ This selects the Motorola i.MX Multimedia card Interface.
+ If you have a i.MX platform with a Multimedia Card slot,
+ say Y or M here.
+
+ If unsure, say N.
+
endmenu
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index c7c34aadfc92c..d2957e35cc6f2 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -17,10 +17,12 @@ obj-$(CONFIG_MMC_BLOCK) += mmc_block.o
#
obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
obj-$(CONFIG_MMC_PXA) += pxamci.o
+obj-$(CONFIG_MMC_IMX) += imxmmc.o
obj-$(CONFIG_MMC_SDHCI) += sdhci.o
obj-$(CONFIG_MMC_WBSD) += wbsd.o
obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
obj-$(CONFIG_MMC_OMAP) += omap.o
+obj-$(CONFIG_MMC_AT91RM9200) += at91_mci.o
mmc_core-y := mmc.o mmc_queue.o mmc_sysfs.o
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c
new file mode 100644
index 0000000000000..6061c2d101a06
--- /dev/null
+++ b/drivers/mmc/at91_mci.c
@@ -0,0 +1,988 @@
+/*
+ * linux/drivers/mmc/at91_mci.c - ATMEL AT91RM9200 MCI Driver
+ *
+ * Copyright (C) 2005 Cougar Creek Computing Devices Ltd, All Rights Reserved
+ *
+ * Copyright (C) 2006 Malcolm Noyes
+ *
+ * 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 is the AT91RM9200 MCI driver that has been tested with both MMC cards
+ and SD-cards. Boards that support write protect are now supported.
+ The CCAT91SBC001 board does not support SD cards.
+
+ The three entry points are at91_mci_request, at91_mci_set_ios
+ and at91_mci_get_ro.
+
+ SET IOS
+ This configures the device to put it into the correct mode and clock speed
+ required.
+
+ MCI REQUEST
+ MCI request processes the commands sent in the mmc_request structure. This
+ can consist of a processing command and a stop command in the case of
+ multiple block transfers.
+
+ There are three main types of request, commands, reads and writes.
+
+ Commands are straight forward. The command is submitted to the controller and
+ the request function returns. When the controller generates an interrupt to indicate
+ the command is finished, the response to the command are read and the mmc_request_done
+ function called to end the request.
+
+ Reads and writes work in a similar manner to normal commands but involve the PDC (DMA)
+ controller to manage the transfers.
+
+ A read is done from the controller directly to the scatterlist passed in from the request.
+ Due to a bug in the controller, when a read is completed, all the words are byte
+ swapped in the scatterlist buffers.
+
+ The sequence of read interrupts is: ENDRX, RXBUFF, CMDRDY
+
+ A write is slightly different in that the bytes to write are read from the scatterlist
+ into a dma memory buffer (this is in case the source buffer should be read only). The
+ entire write buffer is then done from this single dma memory buffer.
+
+ The sequence of write interrupts is: ENDTX, TXBUFE, NOTBUSY, CMDRDY
+
+ GET RO
+ Gets the status of the write protect pin, if available.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/dma-mapping.h>
+#include <linux/clk.h>
+
+#include <linux/mmc/host.h>
+#include <linux/mmc/protocol.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach/mmc.h>
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/at91rm9200_mci.h>
+#include <asm/arch/at91rm9200_pdc.h>
+
+#define DRIVER_NAME "at91_mci"
+
+#undef SUPPORT_4WIRE
+
+#ifdef CONFIG_MMC_DEBUG
+#define DBG(fmt...) \
+ printk(fmt)
+#else
+#define DBG(fmt...) do { } while (0)
+#endif
+
+static struct clk *mci_clk;
+
+#define FL_SENT_COMMAND (1 << 0)
+#define FL_SENT_STOP (1 << 1)
+
+
+
+/*
+ * Read from a MCI register.
+ */
+static inline unsigned long at91_mci_read(unsigned int reg)
+{
+ void __iomem *mci_base = (void __iomem *)AT91_VA_BASE_MCI;
+
+ return __raw_readl(mci_base + reg);
+}
+
+/*
+ * Write to a MCI register.
+ */
+static inline void at91_mci_write(unsigned int reg, unsigned long value)
+{
+ void __iomem *mci_base = (void __iomem *)AT91_VA_BASE_MCI;
+
+ __raw_writel(value, mci_base + reg);
+}
+
+/*
+ * Low level type for this driver
+ */
+struct at91mci_host
+{
+ struct mmc_host *mmc;
+ struct mmc_command *cmd;
+ struct mmc_request *request;
+
+ struct at91_mmc_data *board;
+ int present;
+
+ /*
+ * Flag indicating when the command has been sent. This is used to
+ * work out whether or not to send the stop
+ */
+ unsigned int flags;
+ /* flag for current bus settings */
+ u32 bus_mode;
+
+ /* DMA buffer used for transmitting */
+ unsigned int* buffer;
+ dma_addr_t physical_address;
+ unsigned int total_length;
+
+ /* Latest in the scatterlist that has been enabled for transfer, but not freed */
+ int in_use_index;
+
+ /* Latest in the scatterlist that has been enabled for transfer */
+ int transfer_index;
+};
+
+/*
+ * Copy from sg to a dma block - used for transfers
+ */
+static inline void at91mci_sg_to_dma(struct at91mci_host *host, struct mmc_data *data)
+{
+ unsigned int len, i, size;
+ unsigned *dmabuf = host->buffer;
+
+ size = host->total_length;
+ len = data->sg_len;
+
+ /*
+ * Just loop through all entries. Size might not
+ * be the entire list though so make sure that
+ * we do not transfer too much.
+ */
+ for (i = 0; i < len; i++) {
+ struct scatterlist *sg;
+ int amount;
+ int index;
+ unsigned int *sgbuffer;
+
+ sg = &data->sg[i];
+
+ sgbuffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset;
+ amount = min(size, sg->length);
+ size -= amount;
+ amount /= 4;
+
+ for (index = 0; index < amount; index++)
+ *dmabuf++ = swab32(sgbuffer[index]);
+
+ kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ);
+
+ if (size == 0)
+ break;
+ }
+
+ /*
+ * Check that we didn't get a request to transfer
+ * more data than can fit into the SG list.
+ */
+ BUG_ON(size != 0);
+}
+
+/*
+ * Prepare a dma read
+ */
+static void at91mci_pre_dma_read(struct at91mci_host *host)
+{
+ int i;
+ struct scatterlist *sg;
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+
+ DBG("pre dma read\n");
+
+ cmd = host->cmd;
+ if (!cmd) {
+ DBG("no command\n");
+ return;
+ }
+
+ data = cmd->data;
+ if (!data) {
+ DBG("no data\n");
+ return;
+ }
+
+ for (i = 0; i < 2; i++) {
+ /* nothing left to transfer */
+ if (host->transfer_index >= data->sg_len) {
+ DBG("Nothing left to transfer (index = %d)\n", host->transfer_index);
+ break;
+ }
+
+ /* Check to see if this needs filling */
+ if (i == 0) {
+ if (at91_mci_read(AT91_PDC_RCR) != 0) {
+ DBG("Transfer active in current\n");
+ continue;
+ }
+ }
+ else {
+ if (at91_mci_read(AT91_PDC_RNCR) != 0) {
+ DBG("Transfer active in next\n");
+ continue;
+ }
+ }
+
+ /* Setup the next transfer */
+ DBG("Using transfer index %d\n", host->transfer_index);
+
+ sg = &data->sg[host->transfer_index++];
+ DBG("sg = %p\n", sg);
+
+ sg->dma_address = dma_map_page(NULL, sg->page, sg->offset, sg->length, DMA_FROM_DEVICE);
+
+ DBG("dma address = %08X, length = %d\n", sg->dma_address, sg->length);
+
+ if (i == 0) {
+ at91_mci_write(AT91_PDC_RPR, sg->dma_address);
+ at91_mci_write(AT91_PDC_RCR, sg->length / 4);
+ }
+ else {
+ at91_mci_write(AT91_PDC_RNPR, sg->dma_address);
+ at91_mci_write(AT91_PDC_RNCR, sg->length / 4);
+ }
+ }
+
+ DBG("pre dma read done\n");
+}
+
+/*
+ * Handle after a dma read
+ */
+static void at91mci_post_dma_read(struct at91mci_host *host)
+{
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+
+ DBG("post dma read\n");
+
+ cmd = host->cmd;
+ if (!cmd) {
+ DBG("no command\n");
+ return;
+ }
+
+ data = cmd->data;
+ if (!data) {
+ DBG("no data\n");
+ return;
+ }
+
+ while (host->in_use_index < host->transfer_index) {
+ unsigned int *buffer;
+ int index;
+ int len;
+
+ struct scatterlist *sg;
+
+ DBG("finishing index %d\n", host->in_use_index);
+
+ sg = &data->sg[host->in_use_index++];
+
+ DBG("Unmapping page %08X\n", sg->dma_address);
+
+ dma_unmap_page(NULL, sg->dma_address, sg->length, DMA_FROM_DEVICE);
+
+ /* Swap the contents of the buffer */
+ buffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset;
+ DBG("buffer = %p, length = %d\n", buffer, sg->length);
+
+ data->bytes_xfered += sg->length;
+
+ len = sg->length / 4;
+
+ for (index = 0; index < len; index++) {
+ buffer[index] = swab32(buffer[index]);
+ }
+ kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
+ flush_dcache_page(sg->page);
+ }
+
+ /* Is there another transfer to trigger? */
+ if (host->transfer_index < data->sg_len)
+ at91mci_pre_dma_read(host);
+ else {
+ at91_mci_write(AT91_MCI_IER, AT91_MCI_RXBUFF);
+ at91_mci_write(AT91_PDC_PTCR, AT91_PDC_RXTDIS | AT91_PDC_TXTDIS);
+ }
+
+ DBG("post dma read done\n");
+}
+
+/*
+ * Handle transmitted data
+ */
+static void at91_mci_handle_transmitted(struct at91mci_host *host)
+{
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+
+ DBG("Handling the transmit\n");
+
+ /* Disable the transfer */
+ at91_mci_write(AT91_PDC_PTCR, AT91_PDC_RXTDIS | AT91_PDC_TXTDIS);
+
+ /* Now wait for cmd ready */
+ at91_mci_write(AT91_MCI_IDR, AT91_MCI_TXBUFE);
+ at91_mci_write(AT91_MCI_IER, AT91_MCI_NOTBUSY);
+
+ cmd = host->cmd;
+ if (!cmd) return;
+
+ data = cmd->data;
+ if (!data) return;
+
+ data->bytes_xfered = host->total_length;
+}
+
+/*
+ * Enable the controller
+ */
+static void at91_mci_enable(void)
+{
+ at91_mci_write(AT91_MCI_CR, AT91_MCI_MCIEN);
+ at91_mci_write(AT91_MCI_IDR, 0xFFFFFFFF);
+ at91_mci_write(AT91_MCI_DTOR, AT91_MCI_DTOMUL_1M | AT91_MCI_DTOCYC);
+ at91_mci_write(AT91_MCI_MR, 0x834A);
+ at91_mci_write(AT91_MCI_SDCR, 0x0);
+}
+
+/*
+ * Disable the controller
+ */
+static void at91_mci_disable(void)
+{
+ at91_mci_write(AT91_MCI_CR, AT91_MCI_MCIDIS | AT91_MCI_SWRST);
+}
+
+/*
+ * Send a command
+ * return the interrupts to enable
+ */
+static unsigned int at91_mci_send_command(struct at91mci_host *host, struct mmc_command *cmd)
+{
+ unsigned int cmdr, mr;
+ unsigned int block_length;
+ struct mmc_data *data = cmd->data;
+
+ unsigned int blocks;
+ unsigned int ier = 0;
+
+ host->cmd = cmd;
+
+ /* Not sure if this is needed */
+#if 0
+ if ((at91_mci_read(AT91_MCI_SR) & AT91_MCI_RTOE) && (cmd->opcode == 1)) {
+ DBG("Clearing timeout\n");
+ at91_mci_write(AT91_MCI_ARGR, 0);
+ at91_mci_write(AT91_MCI_CMDR, AT91_MCI_OPDCMD);
+ while (!(at91_mci_read(AT91_MCI_SR) & AT91_MCI_CMDRDY)) {
+ /* spin */
+ DBG("Clearing: SR = %08X\n", at91_mci_read(AT91_MCI_SR));
+ }
+ }
+#endif
+ cmdr = cmd->opcode;
+
+ if (mmc_resp_type(cmd) == MMC_RSP_NONE)
+ cmdr |= AT91_MCI_RSPTYP_NONE;
+ else {
+ /* if a response is expected then allow maximum response latancy */
+ cmdr |= AT91_MCI_MAXLAT;
+ /* set 136 bit response for R2, 48 bit response otherwise */
+ if (mmc_resp_type(cmd) == MMC_RSP_R2)
+ cmdr |= AT91_MCI_RSPTYP_136;
+ else
+ cmdr |= AT91_MCI_RSPTYP_48;
+ }
+
+ if (data) {
+ block_length = 1 << data->blksz_bits;
+ blocks = data->blocks;
+
+ /* always set data start - also set direction flag for read */
+ if (data->flags & MMC_DATA_READ)
+ cmdr |= (AT91_MCI_TRDIR | AT91_MCI_TRCMD_START);
+ else if (data->flags & MMC_DATA_WRITE)
+ cmdr |= AT91_MCI_TRCMD_START;
+
+ if (data->flags & MMC_DATA_STREAM)
+ cmdr |= AT91_MCI_TRTYP_STREAM;
+ if (data->flags & MMC_DATA_MULTI)
+ cmdr |= AT91_MCI_TRTYP_MULTIPLE;
+ }
+ else {
+ block_length = 0;
+ blocks = 0;
+ }
+
+ if (cmd->opcode == MMC_STOP_TRANSMISSION)
+ cmdr |= AT91_MCI_TRCMD_STOP;
+
+ if (host->bus_mode == MMC_BUSMODE_OPENDRAIN)
+ cmdr |= AT91_MCI_OPDCMD;
+
+ /*
+ * Set the arguments and send the command
+ */
+ DBG("Sending command %d as %08X, arg = %08X, blocks = %d, length = %d (MR = %08lX)\n",
+ cmd->opcode, cmdr, cmd->arg, blocks, block_length, at91_mci_read(AT91_MCI_MR));
+
+ if (!data) {
+ at91_mci_write(AT91_PDC_PTCR, AT91_PDC_TXTDIS | AT91_PDC_RXTDIS);
+ at91_mci_write(AT91_PDC_RPR, 0);
+ at91_mci_write(AT91_PDC_RCR, 0);
+ at91_mci_write(AT91_PDC_RNPR, 0);
+ at91_mci_write(AT91_PDC_RNCR, 0);
+ at91_mci_write(AT91_PDC_TPR, 0);
+ at91_mci_write(AT91_PDC_TCR, 0);
+ at91_mci_write(AT91_PDC_TNPR, 0);
+ at91_mci_write(AT91_PDC_TNCR, 0);
+
+ at91_mci_write(AT91_MCI_ARGR, cmd->arg);
+ at91_mci_write(AT91_MCI_CMDR, cmdr);
+ return AT91_MCI_CMDRDY;
+ }
+
+ mr = at91_mci_read(AT91_MCI_MR) & 0x7fff; /* zero block length and PDC mode */
+ at91_mci_write(AT91_MCI_MR, mr | (block_length << 16) | AT91_MCI_PDCMODE);
+
+ /*
+ * Disable the PDC controller
+ */
+ at91_mci_write(AT91_PDC_PTCR, AT91_PDC_RXTDIS | AT91_PDC_TXTDIS);
+
+ if (cmdr & AT91_MCI_TRCMD_START) {
+ data->bytes_xfered = 0;
+ host->transfer_index = 0;
+ host->in_use_index = 0;
+ if (cmdr & AT91_MCI_TRDIR) {
+ /*
+ * Handle a read
+ */
+ host->buffer = NULL;
+ host->total_length = 0;
+
+ at91mci_pre_dma_read(host);
+ ier = AT91_MCI_ENDRX /* | AT91_MCI_RXBUFF */;
+ }
+ else {
+ /*
+ * Handle a write
+ */
+ host->total_length = block_length * blocks;
+ host->buffer = dma_alloc_coherent(NULL,
+ host->total_length,
+ &host->physical_address, GFP_KERNEL);
+
+ at91mci_sg_to_dma(host, data);
+
+ DBG("Transmitting %d bytes\n", host->total_length);
+
+ at91_mci_write(AT91_PDC_TPR, host->physical_address);
+ at91_mci_write(AT91_PDC_TCR, host->total_length / 4);
+ ier = AT91_MCI_TXBUFE;
+ }
+ }
+
+ /*
+ * Send the command and then enable the PDC - not the other way round as
+ * the data sheet says
+ */
+
+ at91_mci_write(AT91_MCI_ARGR, cmd->arg);
+ at91_mci_write(AT91_MCI_CMDR, cmdr);
+
+ if (cmdr & AT91_MCI_TRCMD_START) {
+ if (cmdr & AT91_MCI_TRDIR)
+ at91_mci_write(AT91_PDC_PTCR, AT91_PDC_RXTEN);
+ else
+ at91_mci_write(AT91_PDC_PTCR, AT91_PDC_TXTEN);
+ }
+ return ier;
+}
+
+/*
+ * Wait for a command to complete
+ */
+static void at91mci_process_command(struct at91mci_host *host, struct mmc_command *cmd)
+{
+ unsigned int ier;
+
+ ier = at91_mci_send_command(host, cmd);
+
+ DBG("setting ier to %08X\n", ier);
+
+ /* Stop on errors or the required value */
+ at91_mci_write(AT91_MCI_IER, 0xffff0000 | ier);
+}
+
+/*
+ * Process the next step in the request
+ */
+static void at91mci_process_next(struct at91mci_host *host)
+{
+ if (!(host->flags & FL_SENT_COMMAND)) {
+ host->flags |= FL_SENT_COMMAND;
+ at91mci_process_command(host, host->request->cmd);
+ }
+ else if ((!(host->flags & FL_SENT_STOP)) && host->request->stop) {
+ host->flags |= FL_SENT_STOP;
+ at91mci_process_command(host, host->request->stop);
+ }
+ else
+ mmc_request_done(host->mmc, host->request);
+}
+
+/*
+ * Handle a command that has been completed
+ */
+static void at91mci_completed_command(struct at91mci_host *host)
+{
+ struct mmc_command *cmd = host->cmd;
+ unsigned int status;
+
+ at91_mci_write(AT91_MCI_IDR, 0xffffffff);
+
+ cmd->resp[0] = at91_mci_read(AT91_MCI_RSPR(0));
+ cmd->resp[1] = at91_mci_read(AT91_MCI_RSPR(1));
+ cmd->resp[2] = at91_mci_read(AT91_MCI_RSPR(2));
+ cmd->resp[3] = at91_mci_read(AT91_MCI_RSPR(3));
+
+ if (host->buffer) {
+ dma_free_coherent(NULL, host->total_length, host->buffer, host->physical_address);
+ host->buffer = NULL;
+ }
+
+ status = at91_mci_read(AT91_MCI_SR);
+
+ DBG("Status = %08X [%08X %08X %08X %08X]\n",
+ status, cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
+
+ if (status & (AT91_MCI_RINDE | AT91_MCI_RDIRE | AT91_MCI_RCRCE |
+ AT91_MCI_RENDE | AT91_MCI_RTOE | AT91_MCI_DCRCE |
+ AT91_MCI_DTOE | AT91_MCI_OVRE | AT91_MCI_UNRE)) {
+ if ((status & AT91_MCI_RCRCE) &&
+ ((cmd->opcode == MMC_SEND_OP_COND) || (cmd->opcode == SD_APP_OP_COND))) {
+ cmd->error = MMC_ERR_NONE;
+ }
+ else {
+ if (status & (AT91_MCI_RTOE | AT91_MCI_DTOE))
+ cmd->error = MMC_ERR_TIMEOUT;
+ else if (status & (AT91_MCI_RCRCE | AT91_MCI_DCRCE))
+ cmd->error = MMC_ERR_BADCRC;
+ else if (status & (AT91_MCI_OVRE | AT91_MCI_UNRE))
+ cmd->error = MMC_ERR_FIFO;
+ else
+ cmd->error = MMC_ERR_FAILED;
+
+ DBG("Error detected and set to %d (cmd = %d, retries = %d)\n",
+ cmd->error, cmd->opcode, cmd->retries);
+ }
+ }
+ else
+ cmd->error = MMC_ERR_NONE;
+
+ at91mci_process_next(host);
+}
+
+/*
+ * Handle an MMC request
+ */
+static void at91_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+ struct at91mci_host *host = mmc_priv(mmc);
+ host->request = mrq;
+ host->flags = 0;
+
+ at91mci_process_next(host);
+}
+
+/*
+ * Set the IOS
+ */
+static void at91_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+ int clkdiv;
+ struct at91mci_host *host = mmc_priv(mmc);
+ unsigned long at91_master_clock = clk_get_rate(mci_clk);
+
+ DBG("Clock %uHz, busmode %u, powermode %u, Vdd %u\n",
+ ios->clock, ios->bus_mode, ios->power_mode, ios->vdd);
+
+ if (host)
+ host->bus_mode = ios->bus_mode;
+ else
+ printk("MMC: No host for bus_mode\n");
+
+ if (ios->clock == 0) {
+ /* Disable the MCI controller */
+ at91_mci_write(AT91_MCI_CR, AT91_MCI_MCIDIS);
+ clkdiv = 0;
+ }
+ else {
+ /* Enable the MCI controller */
+ at91_mci_write(AT91_MCI_CR, AT91_MCI_MCIEN);
+
+ if ((at91_master_clock % (ios->clock * 2)) == 0)
+ clkdiv = ((at91_master_clock / ios->clock) / 2) - 1;
+ else
+ clkdiv = (at91_master_clock / ios->clock) / 2;
+
+ DBG("clkdiv = %d. mcck = %ld\n", clkdiv,
+ at91_master_clock / (2 * (clkdiv + 1)));
+ }
+ if (ios->bus_width == MMC_BUS_WIDTH_4 && host->board->wire4) {
+ DBG("MMC: Setting controller bus width to 4\n");
+ at91_mci_write(AT91_MCI_SDCR, at91_mci_read(AT91_MCI_SDCR) | AT91_MCI_SDCBUS);
+ }
+ else {
+ DBG("MMC: Setting controller bus width to 1\n");
+ at91_mci_write(AT91_MCI_SDCR, at91_mci_read(AT91_MCI_SDCR) & ~AT91_MCI_SDCBUS);
+ }
+
+ /* Set the clock divider */
+ at91_mci_write(AT91_MCI_MR, (at91_mci_read(AT91_MCI_MR) & ~AT91_MCI_CLKDIV) | clkdiv);
+
+ /* maybe switch power to the card */
+ if (host && host->board->vcc_pin) {
+ switch (ios->power_mode) {
+ case MMC_POWER_OFF:
+ at91_set_gpio_output(host->board->vcc_pin, 0);
+ break;
+ case MMC_POWER_UP:
+ case MMC_POWER_ON:
+ at91_set_gpio_output(host->board->vcc_pin, 1);
+ break;
+ }
+ }
+}
+
+/*
+ * Handle an interrupt
+ */
+static irqreturn_t at91_mci_irq(int irq, void *devid, struct pt_regs *regs)
+{
+ struct at91mci_host *host = devid;
+ int completed = 0;
+
+ unsigned int int_status;
+
+ if (host == NULL)
+ return IRQ_HANDLED;
+
+ int_status = at91_mci_read(AT91_MCI_SR);
+ DBG("MCI irq: status = %08X, %08lX, %08lX\n", int_status, at91_mci_read(AT91_MCI_IMR),
+ int_status & at91_mci_read(AT91_MCI_IMR));
+
+ if ((int_status & at91_mci_read(AT91_MCI_IMR)) & 0xffff0000)
+ completed = 1;
+
+ int_status &= at91_mci_read(AT91_MCI_IMR);
+
+ if (int_status & AT91_MCI_UNRE)
+ DBG("MMC: Underrun error\n");
+ if (int_status & AT91_MCI_OVRE)
+ DBG("MMC: Overrun error\n");
+ if (int_status & AT91_MCI_DTOE)
+ DBG("MMC: Data timeout\n");
+ if (int_status & AT91_MCI_DCRCE)
+ DBG("MMC: CRC error in data\n");
+ if (int_status & AT91_MCI_RTOE)
+ DBG("MMC: Response timeout\n");
+ if (int_status & AT91_MCI_RENDE)
+ DBG("MMC: Response end bit error\n");
+ if (int_status & AT91_MCI_RCRCE)
+ DBG("MMC: Response CRC error\n");
+ if (int_status & AT91_MCI_RDIRE)
+ DBG("MMC: Response direction error\n");
+ if (int_status & AT91_MCI_RINDE)
+ DBG("MMC: Response index error\n");
+
+ /* Only continue processing if no errors */
+ if (!completed) {
+ if (int_status & AT91_MCI_TXBUFE) {
+ DBG("TX buffer empty\n");
+ at91_mci_handle_transmitted(host);
+ }
+
+ if (int_status & AT91_MCI_RXBUFF) {
+ DBG("RX buffer full\n");
+ at91_mci_write(AT91_MCI_IER, AT91_MCI_CMDRDY);
+ }
+
+ if (int_status & AT91_MCI_ENDTX) {
+ DBG("Transmit has ended\n");
+ }
+
+ if (int_status & AT91_MCI_ENDRX) {
+ DBG("Receive has ended\n");
+ at91mci_post_dma_read(host);
+ }
+
+ if (int_status & AT91_MCI_NOTBUSY) {
+ DBG("Card is ready\n");
+ at91_mci_write(AT91_MCI_IER, AT91_MCI_CMDRDY);
+ }
+
+ if (int_status & AT91_MCI_DTIP) {
+ DBG("Data transfer in progress\n");
+ }
+
+ if (int_status & AT91_MCI_BLKE) {
+ DBG("Block transfer has ended\n");
+ }
+
+ if (int_status & AT91_MCI_TXRDY) {
+ DBG("Ready to transmit\n");
+ }
+
+ if (int_status & AT91_MCI_RXRDY) {
+ DBG("Ready to receive\n");
+ }
+
+ if (int_status & AT91_MCI_CMDRDY) {
+ DBG("Command ready\n");
+ completed = 1;
+ }
+ }
+ at91_mci_write(AT91_MCI_IDR, int_status);
+
+ if (completed) {
+ DBG("Completed command\n");
+ at91_mci_write(AT91_MCI_IDR, 0xffffffff);
+ at91mci_completed_command(host);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t at91_mmc_det_irq(int irq, void *_host, struct pt_regs *regs)
+{
+ struct at91mci_host *host = _host;
+ int present = !at91_get_gpio_value(irq);
+
+ /*
+ * we expect this irq on both insert and remove,
+ * and use a short delay to debounce.
+ */
+ if (present != host->present) {
+ host->present = present;
+ DBG("%s: card %s\n", mmc_hostname(host->mmc),
+ present ? "insert" : "remove");
+ if (!present) {
+ DBG("****** Resetting SD-card bus width ******\n");
+ at91_mci_write(AT91_MCI_SDCR, 0);
+ }
+ mmc_detect_change(host->mmc, msecs_to_jiffies(100));
+ }
+ return IRQ_HANDLED;
+}
+
+int at91_mci_get_ro(struct mmc_host *mmc)
+{
+ int read_only = 0;
+ struct at91mci_host *host = mmc_priv(mmc);
+
+ if (host->board->wp_pin) {
+ read_only = at91_get_gpio_value(host->board->wp_pin);
+ printk(KERN_WARNING "%s: card is %s\n", mmc_hostname(mmc),
+ (read_only ? "read-only" : "read-write") );
+ }
+ else {
+ printk(KERN_WARNING "%s: host does not support reading read-only "
+ "switch. Assuming write-enable.\n", mmc_hostname(mmc));
+ }
+ return read_only;
+}
+
+static struct mmc_host_ops at91_mci_ops = {
+ .request = at91_mci_request,
+ .set_ios = at91_mci_set_ios,
+ .get_ro = at91_mci_get_ro,
+};
+
+/*
+ * Probe for the device
+ */
+static int at91_mci_probe(struct platform_device *pdev)
+{
+ struct mmc_host *mmc;
+ struct at91mci_host *host;
+ int ret;
+
+ DBG("Probe MCI devices\n");
+ at91_mci_disable();
+ at91_mci_enable();
+
+ mmc = mmc_alloc_host(sizeof(struct at91mci_host), &pdev->dev);
+ if (!mmc) {
+ DBG("Failed to allocate mmc host\n");
+ return -ENOMEM;
+ }
+
+ mmc->ops = &at91_mci_ops;
+ mmc->f_min = 375000;
+ mmc->f_max = 25000000;
+ mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+
+ host = mmc_priv(mmc);
+ host->mmc = mmc;
+ host->buffer = NULL;
+ host->bus_mode = 0;
+ host->board = pdev->dev.platform_data;
+ if (host->board->wire4) {
+#ifdef SUPPORT_4WIRE
+ mmc->caps |= MMC_CAP_4_BIT_DATA;
+#else
+ printk("MMC: 4 wire bus mode not supported by this driver - using 1 wire\n");
+#endif
+ }
+
+ /*
+ * Get Clock
+ */
+ mci_clk = clk_get(&pdev->dev, "mci_clk");
+ if (!mci_clk) {
+ printk(KERN_ERR "AT91 MMC: no clock defined.\n");
+ return -ENODEV;
+ }
+ clk_enable(mci_clk); /* Enable the peripheral clock */
+
+ /*
+ * Allocate the MCI interrupt
+ */
+ ret = request_irq(AT91_ID_MCI, at91_mci_irq, SA_SHIRQ, DRIVER_NAME, host);
+ if (ret) {
+ DBG("Failed to request MCI interrupt\n");
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, mmc);
+
+ /*
+ * Add host to MMC layer
+ */
+ if (host->board->det_pin)
+ host->present = !at91_get_gpio_value(host->board->det_pin);
+ else
+ host->present = -1;
+
+ mmc_add_host(mmc);
+
+ /*
+ * monitor card insertion/removal if we can
+ */
+ if (host->board->det_pin) {
+ ret = request_irq(host->board->det_pin, at91_mmc_det_irq,
+ SA_SAMPLE_RANDOM, DRIVER_NAME, host);
+ if (ret)
+ DBG("couldn't allocate MMC detect irq\n");
+ }
+
+ DBG(KERN_INFO "Added MCI driver\n");
+
+ return 0;
+}
+
+/*
+ * Remove a device
+ */
+static int at91_mci_remove(struct platform_device *pdev)
+{
+ struct mmc_host *mmc = platform_get_drvdata(pdev);
+ struct at91mci_host *host;
+
+ if (!mmc)
+ return -1;
+
+ host = mmc_priv(mmc);
+
+ if (host->present != -1) {
+ free_irq(host->board->det_pin, host);
+ cancel_delayed_work(&host->mmc->detect);
+ }
+
+ mmc_remove_host(mmc);
+ at91_mci_disable();
+ free_irq(AT91_ID_MCI, host);
+ mmc_free_host(mmc);
+
+ clk_disable(mci_clk); /* Disable the peripheral clock */
+ clk_put(mci_clk);
+
+ platform_set_drvdata(pdev, NULL);
+
+ DBG("Removed\n");
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct mmc_host *mmc = platform_get_drvdata(pdev);
+ int ret = 0;
+
+ if (mmc)
+ ret = mmc_suspend_host(mmc, state);
+
+ return ret;
+}
+
+static int at91_mci_resume(struct platform_device *pdev)
+{
+ struct mmc_host *mmc = platform_get_drvdata(pdev);
+ int ret = 0;
+
+ if (mmc)
+ ret = mmc_resume_host(mmc);
+
+ return ret;
+}
+#else
+#define at91_mci_suspend NULL
+#define at91_mci_resume NULL
+#endif
+
+static struct platform_driver at91_mci_driver = {
+ .probe = at91_mci_probe,
+ .remove = at91_mci_remove,
+ .suspend = at91_mci_suspend,
+ .resume = at91_mci_resume,
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init at91_mci_init(void)
+{
+ return platform_driver_register(&at91_mci_driver);
+}
+
+static void __exit at91_mci_exit(void)
+{
+ platform_driver_unregister(&at91_mci_driver);
+}
+
+module_init(at91_mci_init);
+module_exit(at91_mci_exit);
+
+MODULE_DESCRIPTION("AT91 Multimedia Card Interface driver");
+MODULE_AUTHOR("Nick Randell");
+MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c
new file mode 100644
index 0000000000000..ffb7f55d34676
--- /dev/null
+++ b/drivers/mmc/imxmmc.c
@@ -0,0 +1,1096 @@
+/*
+ * linux/drivers/mmc/imxmmc.c - Motorola i.MX MMCI driver
+ *
+ * Copyright (C) 2004 Sascha Hauer, Pengutronix <sascha@saschahauer.de>
+ * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com>
+ *
+ * derived from pxamci.c by Russell King
+ *
+ * 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.
+ *
+ * 2005-04-17 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * Changed to conform redesigned i.MX scatter gather DMA interface
+ *
+ * 2005-11-04 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * Updated for 2.6.14 kernel
+ *
+ * 2005-12-13 Jay Monkman <jtm@smoothsmoothie.com>
+ * Found and corrected problems in the write path
+ *
+ * 2005-12-30 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * The event handling rewritten right way in softirq.
+ * Added many ugly hacks and delays to overcome SDHC
+ * deficiencies
+ *
+ */
+#include <linux/config.h>
+
+#ifdef CONFIG_MMC_DEBUG
+#define DEBUG
+#else
+#undef DEBUG
+#endif
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/dma-mapping.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/protocol.h>
+#include <linux/delay.h>
+
+#include <asm/dma.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/sizes.h>
+#include <asm/arch/mmc.h>
+#include <asm/arch/imx-dma.h>
+
+#include "imxmmc.h"
+
+#define DRIVER_NAME "imx-mmc"
+
+#define IMXMCI_INT_MASK_DEFAULT (INT_MASK_BUF_READY | INT_MASK_DATA_TRAN | \
+ INT_MASK_WRITE_OP_DONE | INT_MASK_END_CMD_RES | \
+ INT_MASK_AUTO_CARD_DETECT | INT_MASK_DAT0_EN | INT_MASK_SDIO)
+
+struct imxmci_host {
+ struct mmc_host *mmc;
+ spinlock_t lock;
+ struct resource *res;
+ int irq;
+ imx_dmach_t dma;
+ unsigned int clkrt;
+ unsigned int cmdat;
+ volatile unsigned int imask;
+ unsigned int power_mode;
+ unsigned int present;
+ struct imxmmc_platform_data *pdata;
+
+ struct mmc_request *req;
+ struct mmc_command *cmd;
+ struct mmc_data *data;
+
+ struct timer_list timer;
+ struct tasklet_struct tasklet;
+ unsigned int status_reg;
+ unsigned long pending_events;
+ /* Next to fields are there for CPU driven transfers to overcome SDHC deficiencies */
+ u16 *data_ptr;
+ unsigned int data_cnt;
+ atomic_t stuck_timeout;
+
+ unsigned int dma_nents;
+ unsigned int dma_size;
+ unsigned int dma_dir;
+ int dma_allocated;
+
+ unsigned char actual_bus_width;
+};
+
+#define IMXMCI_PEND_IRQ_b 0
+#define IMXMCI_PEND_DMA_END_b 1
+#define IMXMCI_PEND_DMA_ERR_b 2
+#define IMXMCI_PEND_WAIT_RESP_b 3
+#define IMXMCI_PEND_DMA_DATA_b 4
+#define IMXMCI_PEND_CPU_DATA_b 5
+#define IMXMCI_PEND_CARD_XCHG_b 6
+#define IMXMCI_PEND_SET_INIT_b 7
+
+#define IMXMCI_PEND_IRQ_m (1 << IMXMCI_PEND_IRQ_b)
+#define IMXMCI_PEND_DMA_END_m (1 << IMXMCI_PEND_DMA_END_b)
+#define IMXMCI_PEND_DMA_ERR_m (1 << IMXMCI_PEND_DMA_ERR_b)
+#define IMXMCI_PEND_WAIT_RESP_m (1 << IMXMCI_PEND_WAIT_RESP_b)
+#define IMXMCI_PEND_DMA_DATA_m (1 << IMXMCI_PEND_DMA_DATA_b)
+#define IMXMCI_PEND_CPU_DATA_m (1 << IMXMCI_PEND_CPU_DATA_b)
+#define IMXMCI_PEND_CARD_XCHG_m (1 << IMXMCI_PEND_CARD_XCHG_b)
+#define IMXMCI_PEND_SET_INIT_m (1 << IMXMCI_PEND_SET_INIT_b)
+
+static void imxmci_stop_clock(struct imxmci_host *host)
+{
+ int i = 0;
+ MMC_STR_STP_CLK &= ~STR_STP_CLK_START_CLK;
+ while(i < 0x1000) {
+ if(!(i & 0x7f))
+ MMC_STR_STP_CLK |= STR_STP_CLK_STOP_CLK;
+
+ if(!(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN)) {
+ /* Check twice before cut */
+ if(!(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN))
+ return;
+ }
+
+ i++;
+ }
+ dev_dbg(mmc_dev(host->mmc), "imxmci_stop_clock blocked, no luck\n");
+}
+
+static void imxmci_start_clock(struct imxmci_host *host)
+{
+ int i = 0;
+ MMC_STR_STP_CLK &= ~STR_STP_CLK_STOP_CLK;
+ while(i < 0x1000) {
+ if(!(i & 0x7f))
+ MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK;
+
+ if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) {
+ /* Check twice before cut */
+ if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN)
+ return;
+ }
+
+ i++;
+ }
+ dev_dbg(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n");
+}
+
+static void imxmci_softreset(void)
+{
+ /* reset sequence */
+ MMC_STR_STP_CLK = 0x8;
+ MMC_STR_STP_CLK = 0xD;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+ MMC_STR_STP_CLK = 0x5;
+
+ MMC_RES_TO = 0xff;
+ MMC_BLK_LEN = 512;
+ MMC_NOB = 1;
+}
+
+static int imxmci_busy_wait_for_status(struct imxmci_host *host,
+ unsigned int *pstat, unsigned int stat_mask,
+ int timeout, const char *where)
+{
+ int loops=0;
+ while(!(*pstat & stat_mask)) {
+ loops+=2;
+ if(loops >= timeout) {
+ dev_dbg(mmc_dev(host->mmc), "busy wait timeout in %s, STATUS = 0x%x (0x%x)\n",
+ where, *pstat, stat_mask);
+ return -1;
+ }
+ udelay(2);
+ *pstat |= MMC_STATUS;
+ }
+ if(!loops)
+ return 0;
+
+ dev_info(mmc_dev(host->mmc), "busy wait for %d usec in %s, STATUS = 0x%x (0x%x)\n",
+ loops, where, *pstat, stat_mask);
+ return loops;
+}
+
+static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data)
+{
+ unsigned int nob = data->blocks;
+ unsigned int blksz = 1 << data->blksz_bits;
+ unsigned int datasz = nob * blksz;
+ int i;
+
+ if (data->flags & MMC_DATA_STREAM)
+ nob = 0xffff;
+
+ host->data = data;
+ data->bytes_xfered = 0;
+
+ MMC_NOB = nob;
+ MMC_BLK_LEN = blksz;
+
+ /*
+ * DMA cannot be used for small block sizes, we have to use CPU driven transfers otherwise.
+ * We are in big troubles for non-512 byte transfers according to note in the paragraph
+ * 20.6.7 of User Manual anyway, but we need to be able to transfer SCR at least.
+ * The situation is even more complex in reality. The SDHC in not able to handle wll
+ * partial FIFO fills and reads. The length has to be rounded up to burst size multiple.
+ * This is required for SCR read at least.
+ */
+ if (datasz < 64) {
+ host->dma_size = datasz;
+ if (data->flags & MMC_DATA_READ) {
+ host->dma_dir = DMA_FROM_DEVICE;
+
+ /* Hack to enable read SCR */
+ if(datasz < 16) {
+ MMC_NOB = 1;
+ MMC_BLK_LEN = 16;
+ }
+ } else {
+ host->dma_dir = DMA_TO_DEVICE;
+ }
+
+ /* Convert back to virtual address */
+ host->data_ptr = (u16*)(page_address(data->sg->page) + data->sg->offset);
+ host->data_cnt = 0;
+
+ clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events);
+ set_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events);
+
+ return;
+ }
+
+ if (data->flags & MMC_DATA_READ) {
+ host->dma_dir = DMA_FROM_DEVICE;
+ host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
+ data->sg_len, host->dma_dir);
+
+ imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz,
+ host->res->start + MMC_BUFFER_ACCESS_OFS, DMA_MODE_READ);
+
+ /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_READ, IMX_DMA_WIDTH_16, CCR_REN);*/
+ CCR(host->dma) = CCR_DMOD_LINEAR | CCR_DSIZ_32 | CCR_SMOD_FIFO | CCR_SSIZ_16 | CCR_REN;
+ } else {
+ host->dma_dir = DMA_TO_DEVICE;
+
+ host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
+ data->sg_len, host->dma_dir);
+
+ imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz,
+ host->res->start + MMC_BUFFER_ACCESS_OFS, DMA_MODE_WRITE);
+
+ /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_WRITE, IMX_DMA_WIDTH_16, CCR_REN);*/
+ CCR(host->dma) = CCR_SMOD_LINEAR | CCR_SSIZ_32 | CCR_DMOD_FIFO | CCR_DSIZ_16 | CCR_REN;
+ }
+
+#if 1 /* This code is there only for consistency checking and can be disabled in future */
+ host->dma_size = 0;
+ for(i=0; i<host->dma_nents; i++)
+ host->dma_size+=data->sg[i].length;
+
+ if (datasz > host->dma_size) {
+ dev_err(mmc_dev(host->mmc), "imxmci_setup_data datasz 0x%x > 0x%x dm_size\n",
+ datasz, host->dma_size);
+ }
+#endif
+
+ host->dma_size = datasz;
+
+ wmb();
+
+ if(host->actual_bus_width == MMC_BUS_WIDTH_4)
+ BLR(host->dma) = 0; /* burst 64 byte read / 64 bytes write */
+ else
+ BLR(host->dma) = 16; /* burst 16 byte read / 16 bytes write */
+
+ RSSR(host->dma) = DMA_REQ_SDHC;
+
+ set_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events);
+ clear_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events);
+
+ /* start DMA engine for read, write is delayed after initial response */
+ if (host->dma_dir == DMA_FROM_DEVICE) {
+ imx_dma_enable(host->dma);
+ }
+}
+
+static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd, unsigned int cmdat)
+{
+ unsigned long flags;
+ u32 imask;
+
+ WARN_ON(host->cmd != NULL);
+ host->cmd = cmd;
+
+ if (cmd->flags & MMC_RSP_BUSY)
+ cmdat |= CMD_DAT_CONT_BUSY;
+
+ switch (mmc_resp_type(cmd)) {
+ case MMC_RSP_R1: /* short CRC, OPCODE */
+ case MMC_RSP_R1B:/* short CRC, OPCODE, BUSY */
+ cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R1;
+ break;
+ case MMC_RSP_R2: /* long 136 bit + CRC */
+ cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R2;
+ break;
+ case MMC_RSP_R3: /* short */
+ cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R3;
+ break;
+ case MMC_RSP_R6: /* short CRC */
+ cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R6;
+ break;
+ default:
+ break;
+ }
+
+ if ( test_and_clear_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events) )
+ cmdat |= CMD_DAT_CONT_INIT; /* This command needs init */
+
+ if ( host->actual_bus_width == MMC_BUS_WIDTH_4 )
+ cmdat |= CMD_DAT_CONT_BUS_WIDTH_4;
+
+ MMC_CMD = cmd->opcode;
+ MMC_ARGH = cmd->arg >> 16;
+ MMC_ARGL = cmd->arg & 0xffff;
+ MMC_CMD_DAT_CONT = cmdat;
+
+ atomic_set(&host->stuck_timeout, 0);
+ set_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events);
+
+
+ imask = IMXMCI_INT_MASK_DEFAULT;
+ imask &= ~INT_MASK_END_CMD_RES;
+ if ( cmdat & CMD_DAT_CONT_DATA_ENABLE ) {
+ /*imask &= ~INT_MASK_BUF_READY;*/
+ imask &= ~INT_MASK_DATA_TRAN;
+ if ( cmdat & CMD_DAT_CONT_WRITE )
+ imask &= ~INT_MASK_WRITE_OP_DONE;
+ if(test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events))
+ imask &= ~INT_MASK_BUF_READY;
+ }
+
+ spin_lock_irqsave(&host->lock, flags);
+ host->imask = imask;
+ MMC_INT_MASK = host->imask;
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ dev_dbg(mmc_dev(host->mmc), "CMD%02d (0x%02x) mask set to 0x%04x\n",
+ cmd->opcode, cmd->opcode, imask);
+
+ imxmci_start_clock(host);
+}
+
+static void imxmci_finish_request(struct imxmci_host *host, struct mmc_request *req)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ host->pending_events &= ~(IMXMCI_PEND_WAIT_RESP_m | IMXMCI_PEND_DMA_END_m |
+ IMXMCI_PEND_DMA_DATA_m | IMXMCI_PEND_CPU_DATA_m);
+
+ host->imask = IMXMCI_INT_MASK_DEFAULT;
+ MMC_INT_MASK = host->imask;
+
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ host->req = NULL;
+ host->cmd = NULL;
+ host->data = NULL;
+ mmc_request_done(host->mmc, req);
+}
+
+static int imxmci_finish_data(struct imxmci_host *host, unsigned int stat)
+{
+ struct mmc_data *data = host->data;
+ int data_error;
+
+ if(test_and_clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)){
+ imx_dma_disable(host->dma);
+ dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_nents,
+ host->dma_dir);
+ }
+
+ if ( stat & STATUS_ERR_MASK ) {
+ dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n",stat);
+ if(stat & (STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR))
+ data->error = MMC_ERR_BADCRC;
+ else if(stat & STATUS_TIME_OUT_READ)
+ data->error = MMC_ERR_TIMEOUT;
+ else
+ data->error = MMC_ERR_FAILED;
+ } else {
+ data->bytes_xfered = host->dma_size;
+ }
+
+ data_error = data->error;
+
+ host->data = NULL;
+
+ return data_error;
+}
+
+static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat)
+{
+ struct mmc_command *cmd = host->cmd;
+ int i;
+ u32 a,b,c;
+ struct mmc_data *data = host->data;
+
+ if (!cmd)
+ return 0;
+
+ host->cmd = NULL;
+
+ if (stat & STATUS_TIME_OUT_RESP) {
+ dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n");
+ cmd->error = MMC_ERR_TIMEOUT;
+ } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) {
+ dev_dbg(mmc_dev(host->mmc), "cmd crc error\n");
+ cmd->error = MMC_ERR_BADCRC;
+ }
+
+ if(cmd->flags & MMC_RSP_PRESENT) {
+ if(cmd->flags & MMC_RSP_136) {
+ for (i = 0; i < 4; i++) {
+ u32 a = MMC_RES_FIFO & 0xffff;
+ u32 b = MMC_RES_FIFO & 0xffff;
+ cmd->resp[i] = a<<16 | b;
+ }
+ } else {
+ a = MMC_RES_FIFO & 0xffff;
+ b = MMC_RES_FIFO & 0xffff;
+ c = MMC_RES_FIFO & 0xffff;
+ cmd->resp[0] = a<<24 | b<<8 | c>>8;
+ }
+ }
+
+ dev_dbg(mmc_dev(host->mmc), "RESP 0x%08x, 0x%08x, 0x%08x, 0x%08x, error %d\n",
+ cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3], cmd->error);
+
+ if (data && (cmd->error == MMC_ERR_NONE) && !(stat & STATUS_ERR_MASK)) {
+ if (host->req->data->flags & MMC_DATA_WRITE) {
+
+ /* Wait for FIFO to be empty before starting DMA write */
+
+ stat = MMC_STATUS;
+ if(imxmci_busy_wait_for_status(host, &stat,
+ STATUS_APPL_BUFF_FE,
+ 40, "imxmci_cmd_done DMA WR") < 0) {
+ cmd->error = MMC_ERR_FIFO;
+ imxmci_finish_data(host, stat);
+ if(host->req)
+ imxmci_finish_request(host, host->req);
+ dev_warn(mmc_dev(host->mmc), "STATUS = 0x%04x\n",
+ stat);
+ return 0;
+ }
+
+ if(test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) {
+ imx_dma_enable(host->dma);
+ }
+ }
+ } else {
+ struct mmc_request *req;
+ imxmci_stop_clock(host);
+ req = host->req;
+
+ if(data)
+ imxmci_finish_data(host, stat);
+
+ if( req ) {
+ imxmci_finish_request(host, req);
+ } else {
+ dev_warn(mmc_dev(host->mmc), "imxmci_cmd_done: no request to finish\n");
+ }
+ }
+
+ return 1;
+}
+
+static int imxmci_data_done(struct imxmci_host *host, unsigned int stat)
+{
+ struct mmc_data *data = host->data;
+ int data_error;
+
+ if (!data)
+ return 0;
+
+ data_error = imxmci_finish_data(host, stat);
+
+ if (host->req->stop && (data_error == MMC_ERR_NONE)) {
+ imxmci_stop_clock(host);
+ imxmci_start_cmd(host, host->req->stop, 0);
+ } else {
+ struct mmc_request *req;
+ req = host->req;
+ if( req ) {
+ imxmci_finish_request(host, req);
+ } else {
+ dev_warn(mmc_dev(host->mmc), "imxmci_data_done: no request to finish\n");
+ }
+ }
+
+ return 1;
+}
+
+static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat)
+{
+ int i;
+ int burst_len;
+ int flush_len;
+ int trans_done = 0;
+ unsigned int stat = *pstat;
+
+ if(host->actual_bus_width == MMC_BUS_WIDTH_4)
+ burst_len = 16;
+ else
+ burst_len = 64;
+
+ /* This is unfortunately required */
+ dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data running STATUS = 0x%x\n",
+ stat);
+
+ if(host->dma_dir == DMA_FROM_DEVICE) {
+ imxmci_busy_wait_for_status(host, &stat,
+ STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE,
+ 20, "imxmci_cpu_driven_data read");
+
+ while((stat & (STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE)) &&
+ (host->data_cnt < host->dma_size)) {
+ if(burst_len >= host->dma_size - host->data_cnt) {
+ flush_len = burst_len;
+ burst_len = host->dma_size - host->data_cnt;
+ flush_len -= burst_len;
+ host->data_cnt = host->dma_size;
+ trans_done = 1;
+ } else {
+ flush_len = 0;
+ host->data_cnt += burst_len;
+ }
+
+ for(i = burst_len; i>=2 ; i-=2) {
+ *(host->data_ptr++) = MMC_BUFFER_ACCESS;
+ udelay(20); /* required for clocks < 8MHz*/
+ }
+
+ if(i == 1)
+ *(u8*)(host->data_ptr) = MMC_BUFFER_ACCESS;
+
+ stat = MMC_STATUS;
+
+ /* Flush extra bytes from FIFO */
+ while(flush_len >= 2){
+ flush_len -= 2;
+ i = MMC_BUFFER_ACCESS;
+ stat = MMC_STATUS;
+ stat &= ~STATUS_CRC_READ_ERR; /* Stupid but required there */
+ }
+
+ dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read burst %d STATUS = 0x%x\n",
+ burst_len, stat);
+ }
+ } else {
+ imxmci_busy_wait_for_status(host, &stat,
+ STATUS_APPL_BUFF_FE,
+ 20, "imxmci_cpu_driven_data write");
+
+ while((stat & STATUS_APPL_BUFF_FE) &&
+ (host->data_cnt < host->dma_size)) {
+ if(burst_len >= host->dma_size - host->data_cnt) {
+ burst_len = host->dma_size - host->data_cnt;
+ host->data_cnt = host->dma_size;
+ trans_done = 1;
+ } else {
+ host->data_cnt += burst_len;
+ }
+
+ for(i = burst_len; i>0 ; i-=2)
+ MMC_BUFFER_ACCESS = *(host->data_ptr++);
+
+ stat = MMC_STATUS;
+
+ dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data write burst %d STATUS = 0x%x\n",
+ burst_len, stat);
+ }
+ }
+
+ *pstat = stat;
+
+ return trans_done;
+}
+
+static void imxmci_dma_irq(int dma, void *devid, struct pt_regs *regs)
+{
+ struct imxmci_host *host = devid;
+ uint32_t stat = MMC_STATUS;
+
+ atomic_set(&host->stuck_timeout, 0);
+ host->status_reg = stat;
+ set_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events);
+ tasklet_schedule(&host->tasklet);
+}
+
+static irqreturn_t imxmci_irq(int irq, void *devid, struct pt_regs *regs)
+{
+ struct imxmci_host *host = devid;
+ uint32_t stat = MMC_STATUS;
+ int handled = 1;
+
+ MMC_INT_MASK = host->imask | INT_MASK_SDIO | INT_MASK_AUTO_CARD_DETECT;
+
+ atomic_set(&host->stuck_timeout, 0);
+ host->status_reg = stat;
+ set_bit(IMXMCI_PEND_IRQ_b, &host->pending_events);
+ tasklet_schedule(&host->tasklet);
+
+ return IRQ_RETVAL(handled);;
+}
+
+static void imxmci_tasklet_fnc(unsigned long data)
+{
+ struct imxmci_host *host = (struct imxmci_host *)data;
+ u32 stat;
+ unsigned int data_dir_mask = 0; /* STATUS_WR_CRC_ERROR_CODE_MASK */
+ int timeout = 0;
+
+ if(atomic_read(&host->stuck_timeout) > 4) {
+ char *what;
+ timeout = 1;
+ stat = MMC_STATUS;
+ host->status_reg = stat;
+ if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events))
+ if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events))
+ what = "RESP+DMA";
+ else
+ what = "RESP";
+ else
+ if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events))
+ if(test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events))
+ what = "DATA";
+ else
+ what = "DMA";
+ else
+ what = "???";
+
+ dev_err(mmc_dev(host->mmc), "%s TIMEOUT, hardware stucked STATUS = 0x%04x IMASK = 0x%04x\n",
+ what, stat, MMC_INT_MASK);
+ dev_err(mmc_dev(host->mmc), "CMD_DAT_CONT = 0x%04x, MMC_BLK_LEN = 0x%04x, MMC_NOB = 0x%04x, DMA_CCR = 0x%08x\n",
+ MMC_CMD_DAT_CONT, MMC_BLK_LEN, MMC_NOB, CCR(host->dma));
+ dev_err(mmc_dev(host->mmc), "CMD%d, bus %d-bit, dma_size = 0x%x\n",
+ host->cmd?host->cmd->opcode:0, 1<<host->actual_bus_width, host->dma_size);
+ }
+
+ if(!host->present || timeout)
+ host->status_reg = STATUS_TIME_OUT_RESP | STATUS_TIME_OUT_READ |
+ STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR;
+
+ if(test_bit(IMXMCI_PEND_IRQ_b, &host->pending_events) || timeout) {
+ clear_bit(IMXMCI_PEND_IRQ_b, &host->pending_events);
+
+ stat = MMC_STATUS;
+ /*
+ * This is not required in theory, but there is chance to miss some flag
+ * which clears automatically by mask write, FreeScale original code keeps
+ * stat from IRQ time so do I
+ */
+ stat |= host->status_reg;
+
+ if(test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) {
+ imxmci_busy_wait_for_status(host, &stat,
+ STATUS_END_CMD_RESP | STATUS_ERR_MASK,
+ 20, "imxmci_tasklet_fnc resp (ERRATUM #4)");
+ }
+
+ if(stat & (STATUS_END_CMD_RESP | STATUS_ERR_MASK)) {
+ if(test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events))
+ imxmci_cmd_done(host, stat);
+ if(host->data && (stat & STATUS_ERR_MASK))
+ imxmci_data_done(host, stat);
+ }
+
+ if(test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) {
+ stat |= MMC_STATUS;
+ if(imxmci_cpu_driven_data(host, &stat)){
+ if(test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events))
+ imxmci_cmd_done(host, stat);
+ atomic_clear_mask(IMXMCI_PEND_IRQ_m|IMXMCI_PEND_CPU_DATA_m,
+ &host->pending_events);
+ imxmci_data_done(host, stat);
+ }
+ }
+ }
+
+ if(test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events) &&
+ !test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) {
+
+ stat = MMC_STATUS;
+ /* Same as above */
+ stat |= host->status_reg;
+
+ if(host->dma_dir == DMA_TO_DEVICE) {
+ data_dir_mask = STATUS_WRITE_OP_DONE;
+ } else {
+ data_dir_mask = STATUS_DATA_TRANS_DONE;
+ }
+
+ imxmci_busy_wait_for_status(host, &stat,
+ data_dir_mask,
+ 50, "imxmci_tasklet_fnc data");
+
+ if(stat & data_dir_mask) {
+ clear_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events);
+ imxmci_data_done(host, stat);
+ }
+ }
+
+ if(test_and_clear_bit(IMXMCI_PEND_CARD_XCHG_b, &host->pending_events)) {
+
+ if(host->cmd)
+ imxmci_cmd_done(host, STATUS_TIME_OUT_RESP);
+
+ if(host->data)
+ imxmci_data_done(host, STATUS_TIME_OUT_READ |
+ STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR);
+
+ if(host->req)
+ imxmci_finish_request(host, host->req);
+
+ mmc_detect_change(host->mmc, msecs_to_jiffies(100));
+
+ }
+}
+
+static void imxmci_request(struct mmc_host *mmc, struct mmc_request *req)
+{
+ struct imxmci_host *host = mmc_priv(mmc);
+ unsigned int cmdat;
+
+ WARN_ON(host->req != NULL);
+
+ host->req = req;
+
+ cmdat = 0;
+
+ if (req->data) {
+ imxmci_setup_data(host, req->data);
+
+ cmdat |= CMD_DAT_CONT_DATA_ENABLE;
+
+ if (req->data->flags & MMC_DATA_WRITE)
+ cmdat |= CMD_DAT_CONT_WRITE;
+
+ if (req->data->flags & MMC_DATA_STREAM) {
+ cmdat |= CMD_DAT_CONT_STREAM_BLOCK;
+ }
+ }
+
+ imxmci_start_cmd(host, req->cmd, cmdat);
+}
+
+#define CLK_RATE 19200000
+
+static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+ struct imxmci_host *host = mmc_priv(mmc);
+ int prescaler;
+
+ dev_dbg(mmc_dev(host->mmc), "clock %u power %u vdd %u width %u\n",
+ ios->clock, ios->power_mode, ios->vdd,
+ (ios->bus_width==MMC_BUS_WIDTH_4)?4:1);
+
+ if( ios->bus_width==MMC_BUS_WIDTH_4 ) {
+ host->actual_bus_width = MMC_BUS_WIDTH_4;
+ imx_gpio_mode(PB11_PF_SD_DAT3);
+ }else{
+ host->actual_bus_width = MMC_BUS_WIDTH_1;
+ imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11);
+ }
+
+ if ( host->power_mode != ios->power_mode ) {
+ switch (ios->power_mode) {
+ case MMC_POWER_OFF:
+ break;
+ case MMC_POWER_UP:
+ set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events);
+ break;
+ case MMC_POWER_ON:
+ break;
+ }
+ host->power_mode = ios->power_mode;
+ }
+
+ if ( ios->clock ) {
+ unsigned int clk;
+
+ /* The prescaler is 5 for PERCLK2 equal to 96MHz
+ * then 96MHz / 5 = 19.2 MHz
+ */
+ clk=imx_get_perclk2();
+ prescaler=(clk+(CLK_RATE*7)/8)/CLK_RATE;
+ switch(prescaler) {
+ case 0:
+ case 1: prescaler = 0;
+ break;
+ case 2: prescaler = 1;
+ break;
+ case 3: prescaler = 2;
+ break;
+ case 4: prescaler = 4;
+ break;
+ default:
+ case 5: prescaler = 5;
+ break;
+ }
+
+ dev_dbg(mmc_dev(host->mmc), "PERCLK2 %d MHz -> prescaler %d\n",
+ clk, prescaler);
+
+ for(clk=0; clk<8; clk++) {
+ int x;
+ x = CLK_RATE / (1<<clk);
+ if( x <= ios->clock)
+ break;
+ }
+
+ MMC_STR_STP_CLK |= STR_STP_CLK_ENABLE; /* enable controller */
+
+ imxmci_stop_clock(host);
+ MMC_CLK_RATE = (prescaler<<3) | clk;
+ imxmci_start_clock(host);
+
+ dev_dbg(mmc_dev(host->mmc), "MMC_CLK_RATE: 0x%08x\n", MMC_CLK_RATE);
+ } else {
+ imxmci_stop_clock(host);
+ }
+}
+
+static struct mmc_host_ops imxmci_ops = {
+ .request = imxmci_request,
+ .set_ios = imxmci_set_ios,
+};
+
+static struct resource *platform_device_resource(struct platform_device *dev, unsigned int mask, int nr)
+{
+ int i;
+
+ for (i = 0; i < dev->num_resources; i++)
+ if (dev->resource[i].flags == mask && nr-- == 0)
+ return &dev->resource[i];
+ return NULL;
+}
+
+static int platform_device_irq(struct platform_device *dev, int nr)
+{
+ int i;
+
+ for (i = 0; i < dev->num_resources; i++)
+ if (dev->resource[i].flags == IORESOURCE_IRQ && nr-- == 0)
+ return dev->resource[i].start;
+ return NO_IRQ;
+}
+
+static void imxmci_check_status(unsigned long data)
+{
+ struct imxmci_host *host = (struct imxmci_host *)data;
+
+ if( host->pdata->card_present() != host->present ) {
+ host->present ^= 1;
+ dev_info(mmc_dev(host->mmc), "card %s\n",
+ host->present ? "inserted" : "removed");
+
+ set_bit(IMXMCI_PEND_CARD_XCHG_b, &host->pending_events);
+ tasklet_schedule(&host->tasklet);
+ }
+
+ if(test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events) ||
+ test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) {
+ atomic_inc(&host->stuck_timeout);
+ if(atomic_read(&host->stuck_timeout) > 4)
+ tasklet_schedule(&host->tasklet);
+ } else {
+ atomic_set(&host->stuck_timeout, 0);
+
+ }
+
+ mod_timer(&host->timer, jiffies + (HZ>>1));
+}
+
+static int imxmci_probe(struct platform_device *pdev)
+{
+ struct mmc_host *mmc;
+ struct imxmci_host *host = NULL;
+ struct resource *r;
+ int ret = 0, irq;
+
+ printk(KERN_INFO "i.MX mmc driver\n");
+
+ r = platform_device_resource(pdev, IORESOURCE_MEM, 0);
+ irq = platform_device_irq(pdev, 0);
+ if (!r || irq == NO_IRQ)
+ return -ENXIO;
+
+ r = request_mem_region(r->start, 0x100, "IMXMCI");
+ if (!r)
+ return -EBUSY;
+
+ mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev);
+ if (!mmc) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ mmc->ops = &imxmci_ops;
+ mmc->f_min = 150000;
+ mmc->f_max = CLK_RATE/2;
+ mmc->ocr_avail = MMC_VDD_32_33;
+ mmc->caps |= MMC_CAP_4_BIT_DATA;
+
+ /* MMC core transfer sizes tunable parameters */
+ mmc->max_hw_segs = 64;
+ mmc->max_phys_segs = 64;
+ mmc->max_sectors = 64; /* default 1 << (PAGE_CACHE_SHIFT - 9) */
+ mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */
+
+ host = mmc_priv(mmc);
+ host->mmc = mmc;
+ host->dma_allocated = 0;
+ host->pdata = pdev->dev.platform_data;
+
+ spin_lock_init(&host->lock);
+ host->res = r;
+ host->irq = irq;
+
+ imx_gpio_mode(PB8_PF_SD_DAT0);
+ imx_gpio_mode(PB9_PF_SD_DAT1);
+ imx_gpio_mode(PB10_PF_SD_DAT2);
+ /* Configured as GPIO with pull-up to ensure right MCC card mode */
+ /* Switched to PB11_PF_SD_DAT3 if 4 bit bus is configured */
+ imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11);
+ /* imx_gpio_mode(PB11_PF_SD_DAT3); */
+ imx_gpio_mode(PB12_PF_SD_CLK);
+ imx_gpio_mode(PB13_PF_SD_CMD);
+
+ imxmci_softreset();
+
+ if ( MMC_REV_NO != 0x390 ) {
+ dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n",
+ MMC_REV_NO);
+ goto out;
+ }
+
+ MMC_READ_TO = 0x2db4; /* recommended in data sheet */
+
+ host->imask = IMXMCI_INT_MASK_DEFAULT;
+ MMC_INT_MASK = host->imask;
+
+
+ if(imx_dma_request_by_prio(&host->dma, DRIVER_NAME, DMA_PRIO_LOW)<0){
+ dev_err(mmc_dev(host->mmc), "imx_dma_request_by_prio failed\n");
+ ret = -EBUSY;
+ goto out;
+ }
+ host->dma_allocated=1;
+ imx_dma_setup_handlers(host->dma, imxmci_dma_irq, NULL, host);
+
+ tasklet_init(&host->tasklet, imxmci_tasklet_fnc, (unsigned long)host);
+ host->status_reg=0;
+ host->pending_events=0;
+
+ ret = request_irq(host->irq, imxmci_irq, 0, DRIVER_NAME, host);
+ if (ret)
+ goto out;
+
+ host->present = host->pdata->card_present();
+ init_timer(&host->timer);
+ host->timer.data = (unsigned long)host;
+ host->timer.function = imxmci_check_status;
+ add_timer(&host->timer);
+ mod_timer(&host->timer, jiffies + (HZ>>1));
+
+ platform_set_drvdata(pdev, mmc);
+
+ mmc_add_host(mmc);
+
+ return 0;
+
+out:
+ if (host) {
+ if(host->dma_allocated){
+ imx_dma_free(host->dma);
+ host->dma_allocated=0;
+ }
+ }
+ if (mmc)
+ mmc_free_host(mmc);
+ release_resource(r);
+ return ret;
+}
+
+static int imxmci_remove(struct platform_device *pdev)
+{
+ struct mmc_host *mmc = platform_get_drvdata(pdev);
+
+ platform_set_drvdata(pdev, NULL);
+
+ if (mmc) {
+ struct imxmci_host *host = mmc_priv(mmc);
+
+ tasklet_disable(&host->tasklet);
+
+ del_timer_sync(&host->timer);
+ mmc_remove_host(mmc);
+
+ free_irq(host->irq, host);
+ if(host->dma_allocated){
+ imx_dma_free(host->dma);
+ host->dma_allocated=0;
+ }
+
+ tasklet_kill(&host->tasklet);
+
+ release_resource(host->res);
+
+ mmc_free_host(mmc);
+ }
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int imxmci_suspend(struct platform_device *dev, pm_message_t state)
+{
+ struct mmc_host *mmc = platform_get_drvdata(dev);
+ int ret = 0;
+
+ if (mmc)
+ ret = mmc_suspend_host(mmc, state);
+
+ return ret;
+}
+
+static int imxmci_resume(struct platform_device *dev)
+{
+ struct mmc_host *mmc = platform_get_drvdata(dev);
+ struct imxmci_host *host;
+ int ret = 0;
+
+ if (mmc) {
+ host = mmc_priv(mmc);
+ if(host)
+ set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events);
+ ret = mmc_resume_host(mmc);
+ }
+
+ return ret;
+}
+#else
+#define imxmci_suspend NULL
+#define imxmci_resume NULL
+#endif /* CONFIG_PM */
+
+static struct platform_driver imxmci_driver = {
+ .probe = imxmci_probe,
+ .remove = imxmci_remove,
+ .suspend = imxmci_suspend,
+ .resume = imxmci_resume,
+ .driver = {
+ .name = DRIVER_NAME,
+ }
+};
+
+static int __init imxmci_init(void)
+{
+ return platform_driver_register(&imxmci_driver);
+}
+
+static void __exit imxmci_exit(void)
+{
+ platform_driver_unregister(&imxmci_driver);
+}
+
+module_init(imxmci_init);
+module_exit(imxmci_exit);
+
+MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
+MODULE_AUTHOR("Sascha Hauer, Pengutronix");
+MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/imxmmc.h b/drivers/mmc/imxmmc.h
new file mode 100644
index 0000000000000..e5339e334dbb3
--- /dev/null
+++ b/drivers/mmc/imxmmc.h
@@ -0,0 +1,67 @@
+
+# define __REG16(x) (*((volatile u16 *)IO_ADDRESS(x)))
+
+#define MMC_STR_STP_CLK __REG16(IMX_MMC_BASE + 0x00)
+#define MMC_STATUS __REG16(IMX_MMC_BASE + 0x04)
+#define MMC_CLK_RATE __REG16(IMX_MMC_BASE + 0x08)
+#define MMC_CMD_DAT_CONT __REG16(IMX_MMC_BASE + 0x0C)
+#define MMC_RES_TO __REG16(IMX_MMC_BASE + 0x10)
+#define MMC_READ_TO __REG16(IMX_MMC_BASE + 0x14)
+#define MMC_BLK_LEN __REG16(IMX_MMC_BASE + 0x18)
+#define MMC_NOB __REG16(IMX_MMC_BASE + 0x1C)
+#define MMC_REV_NO __REG16(IMX_MMC_BASE + 0x20)
+#define MMC_INT_MASK __REG16(IMX_MMC_BASE + 0x24)
+#define MMC_CMD __REG16(IMX_MMC_BASE + 0x28)
+#define MMC_ARGH __REG16(IMX_MMC_BASE + 0x2C)
+#define MMC_ARGL __REG16(IMX_MMC_BASE + 0x30)
+#define MMC_RES_FIFO __REG16(IMX_MMC_BASE + 0x34)
+#define MMC_BUFFER_ACCESS __REG16(IMX_MMC_BASE + 0x38)
+#define MMC_BUFFER_ACCESS_OFS 0x38
+
+
+#define STR_STP_CLK_ENDIAN (1<<5)
+#define STR_STP_CLK_RESET (1<<3)
+#define STR_STP_CLK_ENABLE (1<<2)
+#define STR_STP_CLK_START_CLK (1<<1)
+#define STR_STP_CLK_STOP_CLK (1<<0)
+#define STATUS_CARD_PRESENCE (1<<15)
+#define STATUS_SDIO_INT_ACTIVE (1<<14)
+#define STATUS_END_CMD_RESP (1<<13)
+#define STATUS_WRITE_OP_DONE (1<<12)
+#define STATUS_DATA_TRANS_DONE (1<<11)
+#define STATUS_WR_CRC_ERROR_CODE_MASK (3<<10)
+#define STATUS_CARD_BUS_CLK_RUN (1<<8)
+#define STATUS_APPL_BUFF_FF (1<<7)
+#define STATUS_APPL_BUFF_FE (1<<6)
+#define STATUS_RESP_CRC_ERR (1<<5)
+#define STATUS_CRC_READ_ERR (1<<3)
+#define STATUS_CRC_WRITE_ERR (1<<2)
+#define STATUS_TIME_OUT_RESP (1<<1)
+#define STATUS_TIME_OUT_READ (1<<0)
+#define STATUS_ERR_MASK 0x2f
+#define CLK_RATE_PRESCALER(x) ((x) & 0x7)
+#define CLK_RATE_CLK_RATE(x) (((x) & 0x7) << 3)
+#define CMD_DAT_CONT_CMD_RESP_LONG_OFF (1<<12)
+#define CMD_DAT_CONT_STOP_READWAIT (1<<11)
+#define CMD_DAT_CONT_START_READWAIT (1<<10)
+#define CMD_DAT_CONT_BUS_WIDTH_1 (0<<8)
+#define CMD_DAT_CONT_BUS_WIDTH_4 (2<<8)
+#define CMD_DAT_CONT_INIT (1<<7)
+#define CMD_DAT_CONT_BUSY (1<<6)
+#define CMD_DAT_CONT_STREAM_BLOCK (1<<5)
+#define CMD_DAT_CONT_WRITE (1<<4)
+#define CMD_DAT_CONT_DATA_ENABLE (1<<3)
+#define CMD_DAT_CONT_RESPONSE_FORMAT_R1 (1)
+#define CMD_DAT_CONT_RESPONSE_FORMAT_R2 (2)
+#define CMD_DAT_CONT_RESPONSE_FORMAT_R3 (3)
+#define CMD_DAT_CONT_RESPONSE_FORMAT_R4 (4)
+#define CMD_DAT_CONT_RESPONSE_FORMAT_R5 (5)
+#define CMD_DAT_CONT_RESPONSE_FORMAT_R6 (6)
+#define INT_MASK_AUTO_CARD_DETECT (1<<6)
+#define INT_MASK_DAT0_EN (1<<5)
+#define INT_MASK_SDIO (1<<4)
+#define INT_MASK_BUF_READY (1<<3)
+#define INT_MASK_END_CMD_RES (1<<2)
+#define INT_MASK_WRITE_OP_DONE (1<<1)
+#define INT_MASK_DATA_TRAN (1<<0)
+#define INT_ALL (0x7f)
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index dd628cb51e312..7fac438b5c32c 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -129,8 +129,8 @@ config MTDRAM_ABS_POS
allocating space from Linux's available memory. Otherwise, leave
this set to zero. Most people will want to leave this as zero.
-config MTD_BLKMTD
- tristate "MTD emulation using block device"
+config MTD_BLOCK2MTD
+ tristate "MTD using block device"
depends on MTD
help
This driver allows a block device to appear as an MTD. It would
@@ -141,15 +141,6 @@ config MTD_BLKMTD
Testing MTD users (eg JFFS2) on large media and media that might
be removed during a write (using the floppy drive).
-config MTD_BLOCK2MTD
- tristate "MTD using block device (rewrite)"
- depends on MTD && EXPERIMENTAL
- help
- This driver is basically the same at MTD_BLKMTD above, but
- experienced some interface changes plus serious speedups. In
- the long term, it should replace MTD_BLKMTD. Right now, you
- shouldn't entrust important data to it yet.
-
comment "Disk-On-Chip Device Drivers"
config MTD_DOC2000
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index 7c5ed21783801..b6573670316f1 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_MTD_PMC551) += pmc551.o
obj-$(CONFIG_MTD_MS02NV) += ms02-nv.o
obj-$(CONFIG_MTD_MTDRAM) += mtdram.o
obj-$(CONFIG_MTD_LART) += lart.o
-obj-$(CONFIG_MTD_BLKMTD) += blkmtd.o
obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o
obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o
obj-$(CONFIG_MTD_M25P80) += m25p80.o
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
deleted file mode 100644
index 79f2e1f23ebd7..0000000000000
--- a/drivers/mtd/devices/blkmtd.c
+++ /dev/null
@@ -1,819 +0,0 @@
-/*
- * $Id: blkmtd.c,v 1.27 2005/11/07 11:14:24 gleixner Exp $
- *
- * blkmtd.c - use a block device as a fake MTD
- *
- * Author: Simon Evans <spse@secret.org.uk>
- *
- * Copyright (C) 2001,2002 Simon Evans
- *
- * Licence: GPL
- *
- * How it works:
- * The driver uses raw/io to read/write the device and the page
- * cache to cache access. Writes update the page cache with the
- * new data and mark it dirty and add the page into a BIO which
- * is then written out.
- *
- * It can be loaded Read-Only to prevent erases and writes to the
- * medium.
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/blkdev.h>
-#include <linux/bio.h>
-#include <linux/pagemap.h>
-#include <linux/list.h>
-#include <linux/init.h>
-#include <linux/mount.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mutex.h>
-
-#define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg)
-#define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg)
-#define warn(format, arg...) printk(KERN_WARNING "blkmtd: " format "\n" , ## arg)
-#define crit(format, arg...) printk(KERN_CRIT "blkmtd: " format "\n" , ## arg)
-
-
-/* Default erase size in K, always make it a multiple of PAGE_SIZE */
-#define CONFIG_MTD_BLKDEV_ERASESIZE (128 << 10) /* 128KiB */
-#define VERSION "$Revision: 1.27 $"
-
-/* Info for the block device */
-struct blkmtd_dev {
- struct list_head list;
- struct block_device *blkdev;
- struct mtd_info mtd_info;
- struct mutex wrbuf_mutex;
-};
-
-
-/* Static info about the MTD, used in cleanup_module */
-static LIST_HEAD(blkmtd_device_list);
-
-
-static void blkmtd_sync(struct mtd_info *mtd);
-
-#define MAX_DEVICES 4
-
-/* Module parameters passed by insmod/modprobe */
-static char *device[MAX_DEVICES]; /* the block device to use */
-static int erasesz[MAX_DEVICES]; /* optional default erase size */
-static int ro[MAX_DEVICES]; /* optional read only flag */
-static int sync;
-
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Simon Evans <spse@secret.org.uk>");
-MODULE_DESCRIPTION("Emulate an MTD using a block device");
-module_param_array(device, charp, NULL, 0);
-MODULE_PARM_DESC(device, "block device to use");
-module_param_array(erasesz, int, NULL, 0);
-MODULE_PARM_DESC(erasesz, "optional erase size to use in KiB. eg 4=4KiB.");
-module_param_array(ro, bool, NULL, 0);
-MODULE_PARM_DESC(ro, "1=Read only, writes and erases cause errors");
-module_param(sync, bool, 0);
-MODULE_PARM_DESC(sync, "1=Synchronous writes");
-
-
-/* completion handler for BIO reads */
-static int bi_read_complete(struct bio *bio, unsigned int bytes_done, int error)
-{
- if (bio->bi_size)
- return 1;
-
- complete((struct completion*)bio->bi_private);
- return 0;
-}
-
-
-/* completion handler for BIO writes */
-static int bi_write_complete(struct bio *bio, unsigned int bytes_done, int error)
-{
- const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
- struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
-
- if (bio->bi_size)
- return 1;
-
- if(!uptodate)
- err("bi_write_complete: not uptodate\n");
-
- do {
- struct page *page = bvec->bv_page;
- DEBUG(3, "Cleaning up page %ld\n", page->index);
- if (--bvec >= bio->bi_io_vec)
- prefetchw(&bvec->bv_page->flags);
-
- if (uptodate) {
- SetPageUptodate(page);
- } else {
- ClearPageUptodate(page);
- SetPageError(page);
- }
- clear_page_dirty(page);
- unlock_page(page);
- page_cache_release(page);
- } while (bvec >= bio->bi_io_vec);
-
- complete((struct completion*)bio->bi_private);
- return 0;
-}
-
-
-/* read one page from the block device */
-static int blkmtd_readpage(struct blkmtd_dev *dev, struct page *page)
-{
- struct bio *bio;
- struct completion event;
- int err = -ENOMEM;
-
- if(PageUptodate(page)) {
- DEBUG(2, "blkmtd: readpage page %ld is already upto date\n", page->index);
- unlock_page(page);
- return 0;
- }
-
- ClearPageUptodate(page);
- ClearPageError(page);
-
- bio = bio_alloc(GFP_KERNEL, 1);
- if(bio) {
- init_completion(&event);
- bio->bi_bdev = dev->blkdev;
- bio->bi_sector = page->index << (PAGE_SHIFT-9);
- bio->bi_private = &event;
- bio->bi_end_io = bi_read_complete;
- if(bio_add_page(bio, page, PAGE_SIZE, 0) == PAGE_SIZE) {
- submit_bio(READ_SYNC, bio);
- wait_for_completion(&event);
- err = test_bit(BIO_UPTODATE, &bio->bi_flags) ? 0 : -EIO;
- bio_put(bio);
- }
- }
-
- if(err)
- SetPageError(page);
- else
- SetPageUptodate(page);
- flush_dcache_page(page);
- unlock_page(page);
- return err;
-}
-
-
-/* write out the current BIO and wait for it to finish */
-static int blkmtd_write_out(struct bio *bio)
-{
- struct completion event;
- int err;
-
- if(!bio->bi_vcnt) {
- bio_put(bio);
- return 0;
- }
-
- init_completion(&event);
- bio->bi_private = &event;
- bio->bi_end_io = bi_write_complete;
- submit_bio(WRITE_SYNC, bio);
- wait_for_completion(&event);
- DEBUG(3, "submit_bio completed, bi_vcnt = %d\n", bio->bi_vcnt);
- err = test_bit(BIO_UPTODATE, &bio->bi_flags) ? 0 : -EIO;
- bio_put(bio);
- return err;
-}
-
-
-/**
- * blkmtd_add_page - add a page to the current BIO
- * @bio: bio to add to (NULL to alloc initial bio)
- * @blkdev: block device
- * @page: page to add
- * @pagecnt: pages left to add
- *
- * Adds a page to the current bio, allocating it if necessary. If it cannot be
- * added, the current bio is written out and a new one is allocated. Returns
- * the new bio to add or NULL on error
- */
-static struct bio *blkmtd_add_page(struct bio *bio, struct block_device *blkdev,
- struct page *page, int pagecnt)
-{
-
- retry:
- if(!bio) {
- bio = bio_alloc(GFP_KERNEL, pagecnt);
- if(!bio)
- return NULL;
- bio->bi_sector = page->index << (PAGE_SHIFT-9);
- bio->bi_bdev = blkdev;
- }
-
- if(bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
- blkmtd_write_out(bio);
- bio = NULL;
- goto retry;
- }
- return bio;
-}
-
-
-/**
- * write_pages - write block of data to device via the page cache
- * @dev: device to write to
- * @buf: data source or NULL if erase (output is set to 0xff)
- * @to: offset into output device
- * @len: amount to data to write
- * @retlen: amount of data written
- *
- * Grab pages from the page cache and fill them with the source data.
- * Non page aligned start and end result in a readin of the page and
- * part of the page being modified. Pages are added to the bio and then written
- * out.
- */
-static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
- size_t len, size_t *retlen)
-{
- int pagenr, offset;
- size_t start_len = 0, end_len;
- int pagecnt = 0;
- int err = 0;
- struct bio *bio = NULL;
- size_t thislen = 0;
-
- pagenr = to >> PAGE_SHIFT;
- offset = to & ~PAGE_MASK;
-
- DEBUG(2, "blkmtd: write_pages: buf = %p to = %ld len = %zd pagenr = %d offset = %d\n",
- buf, (long)to, len, pagenr, offset);
-
- /* see if we have to do a partial write at the start */
- if(offset) {
- start_len = ((offset + len) > PAGE_SIZE) ? PAGE_SIZE - offset : len;
- len -= start_len;
- }
-
- /* calculate the length of the other two regions */
- end_len = len & ~PAGE_MASK;
- len -= end_len;
-
- if(start_len)
- pagecnt++;
-
- if(len)
- pagecnt += len >> PAGE_SHIFT;
-
- if(end_len)
- pagecnt++;
-
- mutex_lock(&dev->wrbuf_mutex);
-
- DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n",
- start_len, len, end_len, pagecnt);
-
- if(start_len) {
- /* do partial start region */
- struct page *page;
-
- DEBUG(3, "blkmtd: write: doing partial start, page = %d len = %zd offset = %d\n",
- pagenr, start_len, offset);
-
- BUG_ON(!buf);
- page = read_cache_page(dev->blkdev->bd_inode->i_mapping, pagenr, (filler_t *)blkmtd_readpage, dev);
- lock_page(page);
- if(PageDirty(page)) {
- err("to = %lld start_len = %zd len = %zd end_len = %zd pagenr = %d\n",
- to, start_len, len, end_len, pagenr);
- BUG();
- }
- memcpy(page_address(page)+offset, buf, start_len);
- set_page_dirty(page);
- SetPageUptodate(page);
- buf += start_len;
- thislen = start_len;
- bio = blkmtd_add_page(bio, dev->blkdev, page, pagecnt);
- if(!bio) {
- err = -ENOMEM;
- err("bio_add_page failed\n");
- goto write_err;
- }
- pagecnt--;
- pagenr++;
- }
-
- /* Now do the main loop to a page aligned, n page sized output */
- if(len) {
- int pagesc = len >> PAGE_SHIFT;
- DEBUG(3, "blkmtd: write: whole pages start = %d, count = %d\n",
- pagenr, pagesc);
- while(pagesc) {
- struct page *page;
-
- /* see if page is in the page cache */
- DEBUG(3, "blkmtd: write: grabbing page %d from page cache\n", pagenr);
- page = grab_cache_page(dev->blkdev->bd_inode->i_mapping, pagenr);
- if(PageDirty(page)) {
- BUG();
- }
- if(!page) {
- warn("write: cannot grab cache page %d", pagenr);
- err = -ENOMEM;
- goto write_err;
- }
- if(!buf) {
- memset(page_address(page), 0xff, PAGE_SIZE);
- } else {
- memcpy(page_address(page), buf, PAGE_SIZE);
- buf += PAGE_SIZE;
- }
- bio = blkmtd_add_page(bio, dev->blkdev, page, pagecnt);
- if(!bio) {
- err = -ENOMEM;
- err("bio_add_page failed\n");
- goto write_err;
- }
- pagenr++;
- pagecnt--;
- set_page_dirty(page);
- SetPageUptodate(page);
- pagesc--;
- thislen += PAGE_SIZE;
- }
- }
-
- if(end_len) {
- /* do the third region */
- struct page *page;
- DEBUG(3, "blkmtd: write: doing partial end, page = %d len = %zd\n",
- pagenr, end_len);
- BUG_ON(!buf);
- page = read_cache_page(dev->blkdev->bd_inode->i_mapping, pagenr, (filler_t *)blkmtd_readpage, dev);
- lock_page(page);
- if(PageDirty(page)) {
- err("to = %lld start_len = %zd len = %zd end_len = %zd pagenr = %d\n",
- to, start_len, len, end_len, pagenr);
- BUG();
- }
- memcpy(page_address(page), buf, end_len);
- set_page_dirty(page);
- SetPageUptodate(page);
- DEBUG(3, "blkmtd: write: writing out partial end\n");
- thislen += end_len;
- bio = blkmtd_add_page(bio, dev->blkdev, page, pagecnt);
- if(!bio) {
- err = -ENOMEM;
- err("bio_add_page failed\n");
- goto write_err;
- }
- pagenr++;
- }
-
- DEBUG(3, "blkmtd: write: got %d vectors to write\n", bio->bi_vcnt);
- write_err:
- if(bio)
- blkmtd_write_out(bio);
-
- DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err);
- mutex_unlock(&dev->wrbuf_mutex);
-
- if(retlen)
- *retlen = thislen;
- return err;
-}
-
-
-/* erase a specified part of the device */
-static int blkmtd_erase(struct mtd_info *mtd, struct erase_info *instr)
-{
- struct blkmtd_dev *dev = mtd->priv;
- struct mtd_erase_region_info *einfo = mtd->eraseregions;
- int numregions = mtd->numeraseregions;
- size_t from;
- u_long len;
- int err = -EIO;
- size_t retlen;
-
- instr->state = MTD_ERASING;
- from = instr->addr;
- len = instr->len;
-
- /* check erase region has valid start and length */
- DEBUG(2, "blkmtd: erase: dev = `%s' from = 0x%zx len = 0x%lx\n",
- mtd->name+9, from, len);
- while(numregions) {
- DEBUG(3, "blkmtd: checking erase region = 0x%08X size = 0x%X num = 0x%x\n",
- einfo->offset, einfo->erasesize, einfo->numblocks);
- if(from >= einfo->offset
- && from < einfo->offset + (einfo->erasesize * einfo->numblocks)) {
- if(len == einfo->erasesize
- && ( (from - einfo->offset) % einfo->erasesize == 0))
- break;
- }
- numregions--;
- einfo++;
- }
-
- if(!numregions) {
- /* Not a valid erase block */
- err("erase: invalid erase request 0x%lX @ 0x%08zX", len, from);
- instr->state = MTD_ERASE_FAILED;
- err = -EIO;
- }
-
- if(instr->state != MTD_ERASE_FAILED) {
- /* do the erase */
- DEBUG(3, "Doing erase from = %zd len = %ld\n", from, len);
- err = write_pages(dev, NULL, from, len, &retlen);
- if(err || retlen != len) {
- err("erase failed err = %d", err);
- instr->state = MTD_ERASE_FAILED;
- } else {
- instr->state = MTD_ERASE_DONE;
- }
- }
-
- DEBUG(3, "blkmtd: erase: checking callback\n");
- mtd_erase_callback(instr);
- DEBUG(2, "blkmtd: erase: finished (err = %d)\n", err);
- return err;
-}
-
-
-/* read a range of the data via the page cache */
-static int blkmtd_read(struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf)
-{
- struct blkmtd_dev *dev = mtd->priv;
- int err = 0;
- int offset;
- int pagenr, pages;
- size_t thislen = 0;
-
- DEBUG(2, "blkmtd: read: dev = `%s' from = %lld len = %zd buf = %p\n",
- mtd->name+9, from, len, buf);
-
- if(from > mtd->size)
- return -EINVAL;
- if(from + len > mtd->size)
- len = mtd->size - from;
-
- pagenr = from >> PAGE_SHIFT;
- offset = from - (pagenr << PAGE_SHIFT);
-
- pages = (offset+len+PAGE_SIZE-1) >> PAGE_SHIFT;
- DEBUG(3, "blkmtd: read: pagenr = %d offset = %d, pages = %d\n",
- pagenr, offset, pages);
-
- while(pages) {
- struct page *page;
- int cpylen;
-
- DEBUG(3, "blkmtd: read: looking for page: %d\n", pagenr);
- page = read_cache_page(dev->blkdev->bd_inode->i_mapping, pagenr, (filler_t *)blkmtd_readpage, dev);
- if(IS_ERR(page)) {
- err = -EIO;
- goto readerr;
- }
-
- cpylen = (PAGE_SIZE > len) ? len : PAGE_SIZE;
- if(offset+cpylen > PAGE_SIZE)
- cpylen = PAGE_SIZE-offset;
-
- memcpy(buf + thislen, page_address(page) + offset, cpylen);
- offset = 0;
- len -= cpylen;
- thislen += cpylen;
- pagenr++;
- pages--;
- if(!PageDirty(page))
- page_cache_release(page);
- }
-
- readerr:
- if(retlen)
- *retlen = thislen;
- DEBUG(2, "blkmtd: end read: retlen = %zd, err = %d\n", thislen, err);
- return err;
-}
-
-
-/* write data to the underlying device */
-static int blkmtd_write(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf)
-{
- struct blkmtd_dev *dev = mtd->priv;
- int err;
-
- if(!len)
- return 0;
-
- DEBUG(2, "blkmtd: write: dev = `%s' to = %lld len = %zd buf = %p\n",
- mtd->name+9, to, len, buf);
-
- if(to >= mtd->size) {
- return -ENOSPC;
- }
-
- if(to + len > mtd->size) {
- len = mtd->size - to;
- }
-
- err = write_pages(dev, buf, to, len, retlen);
- if(err > 0)
- err = 0;
- DEBUG(2, "blkmtd: write: end, err = %d\n", err);
- return err;
-}
-
-
-/* sync the device - wait until the write queue is empty */
-static void blkmtd_sync(struct mtd_info *mtd)
-{
- /* Currently all writes are synchronous */
-}
-
-
-static void free_device(struct blkmtd_dev *dev)
-{
- DEBUG(2, "blkmtd: free_device() dev = %p\n", dev);
- if(dev) {
- kfree(dev->mtd_info.eraseregions);
- kfree(dev->mtd_info.name);
- if(dev->blkdev) {
- invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
- close_bdev_excl(dev->blkdev);
- }
- kfree(dev);
- }
-}
-
-
-/* For a given size and initial erase size, calculate the number
- * and size of each erase region. Goes round the loop twice,
- * once to find out how many regions, then allocates space,
- * then round the loop again to fill it in.
- */
-static struct mtd_erase_region_info *calc_erase_regions(
- size_t erase_size, size_t total_size, int *regions)
-{
- struct mtd_erase_region_info *info = NULL;
-
- DEBUG(2, "calc_erase_regions, es = %zd size = %zd regions = %d\n",
- erase_size, total_size, *regions);
- /* Make any user specified erasesize be a power of 2
- and at least PAGE_SIZE */
- if(erase_size) {
- int es = erase_size;
- erase_size = 1;
- while(es != 1) {
- es >>= 1;
- erase_size <<= 1;
- }
- if(erase_size < PAGE_SIZE)
- erase_size = PAGE_SIZE;
- } else {
- erase_size = CONFIG_MTD_BLKDEV_ERASESIZE;
- }
-
- *regions = 0;
-
- do {
- int tot_size = total_size;
- int er_size = erase_size;
- int count = 0, offset = 0, regcnt = 0;
-
- while(tot_size) {
- count = tot_size / er_size;
- if(count) {
- tot_size = tot_size % er_size;
- if(info) {
- DEBUG(2, "adding to erase info off=%d er=%d cnt=%d\n",
- offset, er_size, count);
- (info+regcnt)->offset = offset;
- (info+regcnt)->erasesize = er_size;
- (info+regcnt)->numblocks = count;
- (*regions)++;
- }
- regcnt++;
- offset += (count * er_size);
- }
- while(er_size > tot_size)
- er_size >>= 1;
- }
- if(info == NULL) {
- info = kmalloc(regcnt * sizeof(struct mtd_erase_region_info), GFP_KERNEL);
- if(!info)
- break;
- }
- } while(!(*regions));
- DEBUG(2, "calc_erase_regions done, es = %zd size = %zd regions = %d\n",
- erase_size, total_size, *regions);
- return info;
-}
-
-
-static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size)
-{
- struct block_device *bdev;
- int mode;
- struct blkmtd_dev *dev;
-
- if(!devname)
- return NULL;
-
- /* Get a handle on the device */
-
-
-#ifdef MODULE
- mode = (readonly) ? O_RDONLY : O_RDWR;
- bdev = open_bdev_excl(devname, mode, NULL);
-#else
- mode = (readonly) ? FMODE_READ : FMODE_WRITE;
- bdev = open_by_devnum(name_to_dev_t(devname), mode);
-#endif
- if(IS_ERR(bdev)) {
- err("error: cannot open device %s", devname);
- DEBUG(2, "blkmtd: opening bdev returned %ld\n", PTR_ERR(bdev));
- return NULL;
- }
-
- DEBUG(1, "blkmtd: found a block device major = %d, minor = %d\n",
- MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
-
- if(MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
- err("attempting to use an MTD device as a block device");
- blkdev_put(bdev);
- return NULL;
- }
-
- dev = kmalloc(sizeof(struct blkmtd_dev), GFP_KERNEL);
- if(dev == NULL) {
- blkdev_put(bdev);
- return NULL;
- }
-
- memset(dev, 0, sizeof(struct blkmtd_dev));
- dev->blkdev = bdev;
- if(!readonly) {
- mutex_init(&dev->wrbuf_mutex);
- }
-
- dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
-
- /* Setup the MTD structure */
- /* make the name contain the block device in */
- dev->mtd_info.name = kmalloc(sizeof("blkmtd: ") + strlen(devname), GFP_KERNEL);
- if(dev->mtd_info.name == NULL)
- goto devinit_err;
-
- sprintf(dev->mtd_info.name, "blkmtd: %s", devname);
- dev->mtd_info.eraseregions = calc_erase_regions(erase_size, dev->mtd_info.size,
- &dev->mtd_info.numeraseregions);
- if(dev->mtd_info.eraseregions == NULL)
- goto devinit_err;
-
- dev->mtd_info.erasesize = dev->mtd_info.eraseregions->erasesize;
- DEBUG(1, "blkmtd: init: found %d erase regions\n",
- dev->mtd_info.numeraseregions);
-
- if(readonly) {
- dev->mtd_info.type = MTD_ROM;
- dev->mtd_info.flags = MTD_CAP_ROM;
- } else {
- dev->mtd_info.type = MTD_RAM;
- dev->mtd_info.flags = MTD_CAP_RAM;
- dev->mtd_info.erase = blkmtd_erase;
- dev->mtd_info.write = blkmtd_write;
- dev->mtd_info.writev = default_mtd_writev;
- dev->mtd_info.sync = blkmtd_sync;
- }
- dev->mtd_info.read = blkmtd_read;
- dev->mtd_info.readv = default_mtd_readv;
- dev->mtd_info.priv = dev;
- dev->mtd_info.owner = THIS_MODULE;
-
- list_add(&dev->list, &blkmtd_device_list);
- if (add_mtd_device(&dev->mtd_info)) {
- /* Device didnt get added, so free the entry */
- list_del(&dev->list);
- goto devinit_err;
- } else {
- info("mtd%d: [%s] erase_size = %dKiB %s",
- dev->mtd_info.index, dev->mtd_info.name + strlen("blkmtd: "),
- dev->mtd_info.erasesize >> 10,
- readonly ? "(read-only)" : "");
- }
-
- return dev;
-
- devinit_err:
- free_device(dev);
- return NULL;
-}
-
-
-/* Cleanup and exit - sync the device and kill of the kernel thread */
-static void __devexit cleanup_blkmtd(void)
-{
- struct list_head *temp1, *temp2;
-
- /* Remove the MTD devices */
- list_for_each_safe(temp1, temp2, &blkmtd_device_list) {
- struct blkmtd_dev *dev = list_entry(temp1, struct blkmtd_dev,
- list);
- blkmtd_sync(&dev->mtd_info);
- del_mtd_device(&dev->mtd_info);
- info("mtd%d: [%s] removed", dev->mtd_info.index,
- dev->mtd_info.name + strlen("blkmtd: "));
- list_del(&dev->list);
- free_device(dev);
- }
-}
-
-#ifndef MODULE
-
-/* Handle kernel boot params */
-
-
-static int __init param_blkmtd_device(char *str)
-{
- int i;
-
- for(i = 0; i < MAX_DEVICES; i++) {
- device[i] = str;
- DEBUG(2, "blkmtd: device setup: %d = %s\n", i, device[i]);
- strsep(&str, ",");
- }
- return 1;
-}
-
-
-static int __init param_blkmtd_erasesz(char *str)
-{
- int i;
- for(i = 0; i < MAX_DEVICES; i++) {
- char *val = strsep(&str, ",");
- if(val)
- erasesz[i] = simple_strtoul(val, NULL, 0);
- DEBUG(2, "blkmtd: erasesz setup: %d = %d\n", i, erasesz[i]);
- }
-
- return 1;
-}
-
-
-static int __init param_blkmtd_ro(char *str)
-{
- int i;
- for(i = 0; i < MAX_DEVICES; i++) {
- char *val = strsep(&str, ",");
- if(val)
- ro[i] = simple_strtoul(val, NULL, 0);
- DEBUG(2, "blkmtd: ro setup: %d = %d\n", i, ro[i]);
- }
-
- return 1;
-}
-
-
-static int __init param_blkmtd_sync(char *str)
-{
- if(str[0] == '1')
- sync = 1;
- return 1;
-}
-
-__setup("blkmtd_device=", param_blkmtd_device);
-__setup("blkmtd_erasesz=", param_blkmtd_erasesz);
-__setup("blkmtd_ro=", param_blkmtd_ro);
-__setup("blkmtd_sync=", param_blkmtd_sync);
-
-#endif
-
-
-/* Startup */
-static int __init init_blkmtd(void)
-{
- int i;
-
- info("version " VERSION);
- /* Check args - device[0] is the bare minimum*/
- if(!device[0]) {
- err("error: missing `device' name\n");
- return -EINVAL;
- }
-
- for(i = 0; i < MAX_DEVICES; i++)
- add_device(device[i], ro[i], erasesz[i] << 10);
-
- if(list_empty(&blkmtd_device_list))
- return -EINVAL;
-
- return 0;
-}
-
-module_init(init_blkmtd);
-module_exit(cleanup_blkmtd);
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index c4e12b5cbb92c..3d306681919e1 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -2,6 +2,7 @@
*
* Copyright (C) 2002 David S. Miller (davem@redhat.com)
* Fixed by Pekka Pietikainen (pp@ee.oulu.fi)
+ * Copyright (C) 2006 Broadcom Corporation.
*
* Distribute under GPL.
*/
@@ -28,8 +29,8 @@
#define DRV_MODULE_NAME "b44"
#define PFX DRV_MODULE_NAME ": "
-#define DRV_MODULE_VERSION "0.97"
-#define DRV_MODULE_RELDATE "Nov 30, 2005"
+#define DRV_MODULE_VERSION "1.00"
+#define DRV_MODULE_RELDATE "Apr 7, 2006"
#define B44_DEF_MSG_ENABLE \
(NETIF_MSG_DRV | \
@@ -136,7 +137,7 @@ static inline unsigned long br32(const struct b44 *bp, unsigned long reg)
return readl(bp->regs + reg);
}
-static inline void bw32(const struct b44 *bp,
+static inline void bw32(const struct b44 *bp,
unsigned long reg, unsigned long val)
{
writel(val, bp->regs + reg);
@@ -286,13 +287,13 @@ static void __b44_cam_write(struct b44 *bp, unsigned char *data, int index)
val |= ((u32) data[4]) << 8;
val |= ((u32) data[5]) << 0;
bw32(bp, B44_CAM_DATA_LO, val);
- val = (CAM_DATA_HI_VALID |
+ val = (CAM_DATA_HI_VALID |
(((u32) data[0]) << 8) |
(((u32) data[1]) << 0));
bw32(bp, B44_CAM_DATA_HI, val);
bw32(bp, B44_CAM_CTRL, (CAM_CTRL_WRITE |
(index << CAM_CTRL_INDEX_SHIFT)));
- b44_wait_bit(bp, B44_CAM_CTRL, CAM_CTRL_BUSY, 100, 1);
+ b44_wait_bit(bp, B44_CAM_CTRL, CAM_CTRL_BUSY, 100, 1);
}
static inline void __b44_disable_ints(struct b44 *bp)
@@ -410,25 +411,18 @@ static void __b44_set_flow_ctrl(struct b44 *bp, u32 pause_flags)
static void b44_set_flow_ctrl(struct b44 *bp, u32 local, u32 remote)
{
- u32 pause_enab = bp->flags & (B44_FLAG_TX_PAUSE |
- B44_FLAG_RX_PAUSE);
+ u32 pause_enab = 0;
- if (local & ADVERTISE_PAUSE_CAP) {
- if (local & ADVERTISE_PAUSE_ASYM) {
- if (remote & LPA_PAUSE_CAP)
- pause_enab |= (B44_FLAG_TX_PAUSE |
- B44_FLAG_RX_PAUSE);
- else if (remote & LPA_PAUSE_ASYM)
- pause_enab |= B44_FLAG_RX_PAUSE;
- } else {
- if (remote & LPA_PAUSE_CAP)
- pause_enab |= (B44_FLAG_TX_PAUSE |
- B44_FLAG_RX_PAUSE);
- }
- } else if (local & ADVERTISE_PAUSE_ASYM) {
- if ((remote & LPA_PAUSE_CAP) &&
- (remote & LPA_PAUSE_ASYM))
- pause_enab |= B44_FLAG_TX_PAUSE;
+ /* The driver supports only rx pause by default because
+ the b44 mac tx pause mechanism generates excessive
+ pause frames.
+ Use ethtool to turn on b44 tx pause if necessary.
+ */
+ if ((local & ADVERTISE_PAUSE_CAP) &&
+ (local & ADVERTISE_PAUSE_ASYM)){
+ if ((remote & LPA_PAUSE_ASYM) &&
+ !(remote & LPA_PAUSE_CAP))
+ pause_enab |= B44_FLAG_RX_PAUSE;
}
__b44_set_flow_ctrl(bp, pause_enab);
@@ -1063,7 +1057,7 @@ static int b44_change_mtu(struct net_device *dev, int new_mtu)
spin_unlock_irq(&bp->lock);
b44_enable_ints(bp);
-
+
return 0;
}
@@ -1381,7 +1375,7 @@ static void b44_init_hw(struct b44 *bp)
bw32(bp, B44_DMARX_ADDR, bp->rx_ring_dma + bp->dma_offset);
bw32(bp, B44_DMARX_PTR, bp->rx_pending);
- bp->rx_prod = bp->rx_pending;
+ bp->rx_prod = bp->rx_pending;
bw32(bp, B44_MIB_CTRL, MIB_CTRL_CLR_ON_READ);
@@ -1553,9 +1547,9 @@ static void __b44_set_rx_mode(struct net_device *dev)
val |= RXCONFIG_ALLMULTI;
else
i = __b44_load_mcast(bp, dev);
-
+
for (; i < 64; i++) {
- __b44_cam_write(bp, zero, i);
+ __b44_cam_write(bp, zero, i);
}
bw32(bp, B44_RXCONFIG, val);
val = br32(bp, B44_CAM_CTRL);
@@ -1737,7 +1731,7 @@ static int b44_set_ringparam(struct net_device *dev,
spin_unlock_irq(&bp->lock);
b44_enable_ints(bp);
-
+
return 0;
}
@@ -1782,7 +1776,7 @@ static int b44_set_pauseparam(struct net_device *dev,
spin_unlock_irq(&bp->lock);
b44_enable_ints(bp);
-
+
return 0;
}
@@ -1898,7 +1892,7 @@ static int __devinit b44_get_invariants(struct b44 *bp)
bp->core_unit = ssb_core_unit(bp);
bp->dma_offset = SB_PCI_DMA;
- /* XXX - really required?
+ /* XXX - really required?
bp->flags |= B44_FLAG_BUGGY_TXPTR;
*/
out:
@@ -1946,7 +1940,7 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
"aborting.\n");
goto err_out_free_res;
}
-
+
err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK);
if (err) {
printk(KERN_ERR PFX "No usable DMA configuration, "
@@ -2041,9 +2035,9 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
pci_save_state(bp->pdev);
- /* Chip reset provides power to the b44 MAC & PCI cores, which
+ /* Chip reset provides power to the b44 MAC & PCI cores, which
* is necessary for MAC register access.
- */
+ */
b44_chip_reset(bp);
printk(KERN_INFO "%s: Broadcom 4400 10/100BaseT Ethernet ", dev->name);
@@ -2091,10 +2085,10 @@ static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
del_timer_sync(&bp->timer);
- spin_lock_irq(&bp->lock);
+ spin_lock_irq(&bp->lock);
b44_halt(bp);
- netif_carrier_off(bp->dev);
+ netif_carrier_off(bp->dev);
netif_device_detach(bp->dev);
b44_free_rings(bp);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 2671da20a4967..5ca99e26660af 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -63,7 +63,7 @@
/* Time in jiffies before concluding the transmitter is hung. */
#define TX_TIMEOUT (5*HZ)
-static char version[] __devinitdata =
+static const char version[] __devinitdata =
"Broadcom NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>");
diff --git a/drivers/net/chelsio/Makefile b/drivers/net/chelsio/Makefile
index 91e927827c433..54c78d94f48be 100644
--- a/drivers/net/chelsio/Makefile
+++ b/drivers/net/chelsio/Makefile
@@ -4,7 +4,7 @@
obj-$(CONFIG_CHELSIO_T1) += cxgb.o
-EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/chelsio $(DEBUG_FLAGS)
+EXTRA_CFLAGS += -Idrivers/net/chelsio $(DEBUG_FLAGS)
cxgb-objs := cxgb2.o espi.o pm3393.o sge.o subr.o mv88x201x.o
diff --git a/drivers/net/hydra.h b/drivers/net/hydra.h
deleted file mode 100644
index 37414146258d8..0000000000000
--- a/drivers/net/hydra.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/* $Linux: hydra.h,v 1.0 1994/10/26 02:03:47 cgd Exp $ */
-
-/*
- * Copyright (c) 1994 Timo Rossi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Timo Rossi
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * The Hydra Systems card uses the National Semiconductor
- * 8390 NIC (Network Interface Controller) chip, located
- * at card base address + 0xffe1. NIC registers are accessible
- * only at odd byte addresses, so the register offsets must
- * be multiplied by two.
- *
- * Card address PROM is located at card base + 0xffc0 (even byte addresses)
- *
- * RAM starts at the card base address, and is 16K or 64K.
- * The current Amiga NetBSD hydra driver is hardwired for 16K.
- * It seems that the RAM should be accessed as words or longwords only.
- *
- */
-
-/* adapted for Linux by Topi Kanerva 03/29/95
- with original author's permission */
-
-#define HYDRA_NIC_BASE 0xffe1
-
-/* Page0 registers */
-
-#define NIC_CR 0 /* Command register */
-#define NIC_PSTART (1*2) /* Page start (write) */
-#define NIC_PSTOP (2*2) /* Page stop (write) */
-#define NIC_BNDRY (3*2) /* Boundary pointer */
-#define NIC_TSR (4*2) /* Transmit status (read) */
-#define NIC_TPSR (4*2) /* Transmit page start (write) */
-#define NIC_NCR (5*2) /* Number of collisions, read */
-#define NIC_TBCR0 (5*2) /* Transmit byte count low (write) */
-#define NIC_FIFO (6*2) /* FIFO reg. (read) */
-#define NIC_TBCR1 (6*2) /* Transmit byte count high (write) */
-#define NIC_ISR (7*2) /* Interrupt status register */
-#define NIC_RBCR0 (0xa*2) /* Remote byte count low (write) */
-#define NIC_RBCR1 (0xb*2) /* Remote byte count high (write) */
-#define NIC_RSR (0xc*2) /* Receive status (read) */
-#define NIC_RCR (0xc*2) /* Receive config (write) */
-#define NIC_CNTR0 (0xd*2) /* Frame alignment error count (read) */
-#define NIC_TCR (0xd*2) /* Transmit config (write) */
-#define NIC_CNTR1 (0xe*2) /* CRC error counter (read) */
-#define NIC_DCR (0xe*2) /* Data config (write) */
-#define NIC_CNTR2 (0xf*2) /* missed packet counter (read) */
-#define NIC_IMR (0xf*2) /* Interrupt mask reg. (write) */
-
-/* Page1 registers */
-
-#define NIC_PAR0 (1*2) /* Physical address */
-#define NIC_PAR1 (2*2)
-#define NIC_PAR2 (3*2)
-#define NIC_PAR3 (4*2)
-#define NIC_PAR4 (5*2)
-#define NIC_PAR5 (6*2)
-#define NIC_CURR (7*2) /* Current RX ring-buffer page */
-#define NIC_MAR0 (8*2) /* Multicast address */
-#define NIC_MAR1 (9*2)
-#define NIC_MAR2 (0xa*2)
-#define NIC_MAR3 (0xb*2)
-#define NIC_MAR4 (0xc*2)
-#define NIC_MAR5 (0xd*2)
-#define NIC_MAR6 (0xe*2)
-#define NIC_MAR7 (0xf*2)
-
-/* Command register definitions */
-
-#define CR_STOP 0x01 /* Stop -- software reset command */
-#define CR_START 0x02 /* Start */
-#define CR_TXP 0x04 /* Transmit packet */
-
-#define CR_RD0 0x08 /* Remote DMA cmd */
-#define CR_RD1 0x10
-#define CR_RD2 0x20
-
-#define CR_NODMA CR_RD2
-
-#define CR_PS0 0x40 /* Page select */
-#define CR_PS1 0x80
-
-#define CR_PAGE0 0
-#define CR_PAGE1 CR_PS0
-#define CR_PAGE2 CR_PS1
-
-/* Interrupt status reg. definitions */
-
-#define ISR_PRX 0x01 /* Packet received without errors */
-#define ISR_PTX 0x02 /* Packet transmitted without errors */
-#define ISR_RXE 0x04 /* Receive error */
-#define ISR_TXE 0x08 /* Transmit error */
-#define ISR_OVW 0x10 /* Ring buffer overrun */
-#define ISR_CNT 0x20 /* Counter overflow */
-#define ISR_RDC 0x40 /* Remote DMA compile */
-#define ISR_RST 0x80 /* Reset status */
-
-/* Data config reg. definitions */
-
-#define DCR_WTS 0x01 /* Word transfer select */
-#define DCR_BOS 0x02 /* Byte order select */
-#define DCR_LAS 0x04 /* Long address select */
-#define DCR_LS 0x08 /* Loopback select */
-#define DCR_AR 0x10 /* Auto-init remote */
-#define DCR_FT0 0x20 /* FIFO threshold select */
-#define DCR_FT1 0x40
-
-/* Transmit config reg. definitions */
-
-#define TCR_CRC 0x01 /* Inhibit CRC */
-#define TCR_LB0 0x02 /* Loopback control */
-#define TCR_LB1 0x04
-#define TCR_ATD 0x08 /* Auto transmit disable */
-#define TCR_OFST 0x10 /* Collision offset enable */
-
-/* Transmit status reg. definitions */
-
-#define TSR_PTX 0x01 /* Packet transmitted */
-#define TSR_COL 0x04 /* Transmit collided */
-#define TSR_ABT 0x08 /* Transmit aborted */
-#define TSR_CRS 0x10 /* Carrier sense lost */
-#define TSR_FU 0x20 /* FIFO underrun */
-#define TSR_CDH 0x40 /* CD Heartbeat */
-#define TSR_OWC 0x80 /* Out of Window Collision */
-
-/* Receiver config register definitions */
-
-#define RCR_SEP 0x01 /* Save errored packets */
-#define RCR_AR 0x02 /* Accept runt packets */
-#define RCR_AB 0x04 /* Accept broadcast */
-#define RCR_AM 0x08 /* Accept multicast */
-#define RCR_PRO 0x10 /* Promiscuous mode */
-#define RCR_MON 0x20 /* Monitor mode */
-
-/* Receiver status register definitions */
-
-#define RSR_PRX 0x01 /* Packet received without error */
-#define RSR_CRC 0x02 /* CRC error */
-#define RSR_FAE 0x04 /* Frame alignment error */
-#define RSR_FO 0x08 /* FIFO overrun */
-#define RSR_MPA 0x10 /* Missed packet */
-#define RSR_PHY 0x20 /* Physical address */
-#define RSR_DIS 0x40 /* Received disabled */
-#define RSR_DFR 0x80 /* Deferring (jabber) */
-
-/* Hydra System card address PROM offset */
-
-#define HYDRA_ADDRPROM 0xffc0
-
-
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 6e2ec56cde0b1..606243d117937 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1,7 +1,7 @@
/*****************************************************************************
*
* Filename: irda-usb.c
- * Version: 0.9b
+ * Version: 0.10
* Description: IrDA-USB Driver
* Status: Experimental
* Author: Dag Brattli <dag@brattli.net>
@@ -9,6 +9,9 @@
* Copyright (C) 2000, Roman Weissgaerber <weissg@vienna.at>
* Copyright (C) 2001, Dag Brattli <dag@brattli.net>
* Copyright (C) 2001, Jean Tourrilhes <jt@hpl.hp.com>
+ * Copyright (C) 2004, SigmaTel, Inc. <irquality@sigmatel.com>
+ * Copyright (C) 2005, Milan Beno <beno@pobox.sk>
+ * Copyright (C) 2006, Nick Fedchik <nick@fedchik.org.ua>
*
* 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
@@ -61,6 +64,7 @@
#include <linux/slab.h>
#include <linux/rtnetlink.h>
#include <linux/usb.h>
+#include <linux/firmware.h>
#include "irda-usb.h"
@@ -78,8 +82,12 @@ static struct usb_device_id dongles[] = {
{ USB_DEVICE(0x50f, 0x180), .driver_info = IUC_SPEED_BUG | IUC_NO_WINDOW },
/* Extended Systems, Inc., XTNDAccess IrDA USB (ESI-9685) */
{ USB_DEVICE(0x8e9, 0x100), .driver_info = IUC_SPEED_BUG | IUC_NO_WINDOW },
+ /* SigmaTel STIR4210/4220/4116 USB IrDA (VFIR) Bridge */
+ { USB_DEVICE(0x66f, 0x4210), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG },
+ { USB_DEVICE(0x66f, 0x4220), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG },
+ { USB_DEVICE(0x66f, 0x4116), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG },
{ .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
- USB_DEVICE_ID_MATCH_INT_SUBCLASS,
+ USB_DEVICE_ID_MATCH_INT_SUBCLASS,
.bInterfaceClass = USB_CLASS_APP_SPEC,
.bInterfaceSubClass = USB_CLASS_IRDA,
.driver_info = IUC_DEFAULT, },
@@ -99,6 +107,7 @@ MODULE_DEVICE_TABLE(usb, dongles);
/*------------------------------------------------------------------*/
+static void irda_usb_init_qos(struct irda_usb_cb *self) ;
static struct irda_class_desc *irda_usb_find_class_desc(struct usb_interface *intf);
static void irda_usb_disconnect(struct usb_interface *intf);
static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self);
@@ -141,7 +150,24 @@ static void irda_usb_build_header(struct irda_usb_cb *self,
__u8 *header,
int force)
{
- /* Set the negotiated link speed */
+ /* Here we check if we have an STIR421x chip,
+ * and if either speed or xbofs (or both) needs
+ * to be changed.
+ */
+ if (self->capability & IUC_STIR_4210 &&
+ ((self->new_speed != -1) || (self->new_xbofs != -1))) {
+
+ /* With STIR421x, speed and xBOFs must be set at the same
+ * time, even if only one of them changes.
+ */
+ if (self->new_speed == -1)
+ self->new_speed = self->speed ;
+
+ if (self->new_xbofs == -1)
+ self->new_xbofs = self->xbofs ;
+ }
+
+ /* Set the link speed */
if (self->new_speed != -1) {
/* Hum... Ugly hack :-(
* Some device are not compliant with the spec and change
@@ -191,7 +217,11 @@ static void irda_usb_build_header(struct irda_usb_cb *self,
*header = SPEED_4000000;
self->new_xbofs = 0;
break;
- }
+ case 16000000:
+ *header = SPEED_16000000;
+ self->new_xbofs = 0;
+ break;
+ }
} else
/* No change */
*header = 0;
@@ -235,6 +265,32 @@ static void irda_usb_build_header(struct irda_usb_cb *self,
}
}
+/*
+* calculate turnaround time for SigmaTel header
+*/
+static __u8 get_turnaround_time(struct sk_buff *skb)
+{
+ int turnaround_time = irda_get_mtt(skb);
+
+ if ( turnaround_time == 0 )
+ return 0;
+ else if ( turnaround_time <= 10 )
+ return 1;
+ else if ( turnaround_time <= 50 )
+ return 2;
+ else if ( turnaround_time <= 100 )
+ return 3;
+ else if ( turnaround_time <= 500 )
+ return 4;
+ else if ( turnaround_time <= 1000 )
+ return 5;
+ else if ( turnaround_time <= 5000 )
+ return 6;
+ else
+ return 7;
+}
+
+
/*------------------------------------------------------------------*/
/*
* Send a command to change the speed of the dongle
@@ -262,12 +318,18 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
/* Set the new speed and xbofs in this fake frame */
irda_usb_build_header(self, frame, 1);
+ if ( self->capability & IUC_STIR_4210 ) {
+ if (frame[0] == 0) return ; // do nothing if no change
+ frame[1] = 0; // other parameters don't change here
+ frame[2] = 0;
+ }
+
/* Submit the 0 length IrDA frame to trigger new speed settings */
usb_fill_bulk_urb(urb, self->usbdev,
usb_sndbulkpipe(self->usbdev, self->bulk_out_ep),
frame, IRDA_USB_SPEED_MTU,
speed_bulk_callback, self);
- urb->transfer_buffer_length = USB_IRDA_HEADER;
+ urb->transfer_buffer_length = self->header_length;
urb->transfer_flags = 0;
/* Irq disabled -> GFP_ATOMIC */
@@ -383,16 +445,35 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
* allocation will be done lower in skb_push().
* Also, we don't use directly skb_cow(), because it require
* headroom >= 16, which force unnecessary copies - Jean II */
- if (skb_headroom(skb) < USB_IRDA_HEADER) {
+ if (skb_headroom(skb) < self->header_length) {
IRDA_DEBUG(0, "%s(), Insuficient skb headroom.\n", __FUNCTION__);
- if (skb_cow(skb, USB_IRDA_HEADER)) {
+ if (skb_cow(skb, self->header_length)) {
IRDA_WARNING("%s(), failed skb_cow() !!!\n", __FUNCTION__);
goto drop;
}
}
/* Change setting for next frame */
- irda_usb_build_header(self, skb_push(skb, USB_IRDA_HEADER), 0);
+
+ if ( self->capability & IUC_STIR_4210 ) {
+ __u8 turnaround_time;
+ __u8* frame;
+ turnaround_time = get_turnaround_time( skb );
+ frame= skb_push(skb, self->header_length);
+ irda_usb_build_header(self, frame, 0);
+ frame[2] = turnaround_time;
+ if ((skb->len != 0) &&
+ ((skb->len % 128) == 0) &&
+ ((skb->len % 512) != 0)) {
+ /* add extra byte for special SigmaTel feature */
+ frame[1] = 1;
+ skb_put(skb, 1);
+ } else {
+ frame[1] = 0;
+ }
+ } else {
+ irda_usb_build_header(self, skb_push(skb, self->header_length), 0);
+ }
/* FIXME: Make macro out of this one */
((struct irda_skb_cb *)skb->cb)->context = self;
@@ -795,7 +876,7 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
}
/* Check for empty frames */
- if (urb->actual_length <= USB_IRDA_HEADER) {
+ if (urb->actual_length <= self->header_length) {
IRDA_WARNING("%s(), empty frame!\n", __FUNCTION__);
goto done;
}
@@ -816,7 +897,11 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
docopy = (urb->actual_length < IRDA_RX_COPY_THRESHOLD);
/* Allocate a new skb */
- newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU);
+ if ( self->capability & IUC_STIR_4210 )
+ newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU + USB_IRDA_SIGMATEL_HEADER);
+ else
+ newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU);
+
if (!newskb) {
self->stats.rx_dropped++;
/* We could deliver the current skb, but this would stall
@@ -845,7 +930,7 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
/* Set proper length on skb & remove USB-IrDA header */
skb_put(dataskb, urb->actual_length);
- skb_pull(dataskb, USB_IRDA_HEADER);
+ skb_pull(dataskb, self->header_length);
/* Ask the networking layer to queue the packet for the IrDA stack */
dataskb->dev = self->netdev;
@@ -937,6 +1022,191 @@ static int irda_usb_is_receiving(struct irda_usb_cb *self)
return 0; /* For now */
}
+
+#define STIR421X_PATCH_PRODUCT_VERSION_STR "Product Version: "
+#define STIR421X_PATCH_COMPONENT_VERSION_STR "Component Version: "
+#define STIR421X_PATCH_DATA_TAG_STR "STMP"
+#define STIR421X_PATCH_FILE_VERSION_MAX_OFFSET 512 /* version info is before here */
+#define STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET 512 /* patch image starts before here */
+#define STIR421X_PATCH_FILE_END_OF_HEADER_TAG 0x1A /* marks end of patch file header (PC DOS text file EOF character) */
+
+/*
+ * Known firmware patches for STIR421x dongles
+ */
+static char * stir421x_patches[] = {
+ "42101001.sb",
+ "42101002.sb",
+};
+
+static int stir421x_get_patch_version(unsigned char * patch, const unsigned long patch_len)
+{
+ unsigned int version_offset;
+ unsigned long version_major, version_minor, version_build;
+ unsigned char * version_start;
+ int version_found = 0;
+
+ for (version_offset = 0;
+ version_offset < STIR421X_PATCH_FILE_END_OF_HEADER_TAG;
+ version_offset++) {
+ if (!memcmp(patch + version_offset,
+ STIR421X_PATCH_PRODUCT_VERSION_STR,
+ sizeof(STIR421X_PATCH_PRODUCT_VERSION_STR) - 1)) {
+ version_found = 1;
+ version_start = patch +
+ version_offset +
+ sizeof(STIR421X_PATCH_PRODUCT_VERSION_STR) - 1;
+ break;
+ }
+ }
+
+ /* We couldn't find a product version on this patch */
+ if (!version_found)
+ return -EINVAL;
+
+ /* Let's check if the product version is dotted */
+ if (version_start[3] != '.' ||
+ version_start[7] != '.')
+ return -EINVAL;
+
+ version_major = simple_strtoul(version_start, NULL, 10);
+ version_minor = simple_strtoul(version_start + 4, NULL, 10);
+ version_build = simple_strtoul(version_start + 8, NULL, 10);
+
+ IRDA_DEBUG(2, "%s(), Major: %ld Minor: %ld Build: %ld\n",
+ __FUNCTION__,
+ version_major, version_minor, version_build);
+
+ return (((version_major) << 12) +
+ ((version_minor) << 8) +
+ ((version_build / 10) << 4) +
+ (version_build % 10));
+
+}
+
+
+static int stir421x_upload_patch (struct irda_usb_cb *self,
+ unsigned char * patch,
+ const unsigned int patch_len)
+{
+ int retval = 0;
+ int actual_len;
+ unsigned int i = 0, download_amount = 0;
+ unsigned char * patch_chunk;
+
+ IRDA_DEBUG (2, "%s(), Uploading STIR421x Patch\n", __FUNCTION__);
+
+ patch_chunk = kzalloc(STIR421X_MAX_PATCH_DOWNLOAD_SIZE, GFP_KERNEL);
+ if (patch_chunk == NULL)
+ return -ENOMEM;
+
+ /* break up patch into 1023-byte sections */
+ for (i = 0; retval >= 0 && i < patch_len; i += download_amount) {
+ download_amount = patch_len - i;
+ if (download_amount > STIR421X_MAX_PATCH_DOWNLOAD_SIZE)
+ download_amount = STIR421X_MAX_PATCH_DOWNLOAD_SIZE;
+
+ /* download the patch section */
+ memcpy(patch_chunk, patch + i, download_amount);
+
+ retval = usb_bulk_msg (self->usbdev,
+ usb_sndbulkpipe (self->usbdev,
+ self->bulk_out_ep),
+ patch_chunk, download_amount,
+ &actual_len, msecs_to_jiffies (500));
+ IRDA_DEBUG (2, "%s(), Sent %u bytes\n", __FUNCTION__,
+ actual_len);
+ if (retval == 0)
+ mdelay(10);
+ }
+
+ kfree(patch_chunk);
+
+ if (i != patch_len) {
+ IRDA_ERROR ("%s(), Pushed %d bytes (!= patch_len (%d))\n",
+ __FUNCTION__, i, patch_len);
+ retval = -EIO;
+ }
+
+ if (retval < 0)
+ /* todo - mark device as not ready */
+ IRDA_ERROR ("%s(), STIR421x patch upload failed (%d)\n",
+ __FUNCTION__, retval);
+
+ return retval;
+}
+
+
+static int stir421x_patch_device(struct irda_usb_cb *self)
+{
+ unsigned int i, patch_found = 0, data_found = 0, data_offset;
+ int patch_version, ret = 0;
+ const struct firmware *fw_entry;
+
+ for (i = 0; i < ARRAY_SIZE(stir421x_patches); i++) {
+ if(request_firmware(&fw_entry, stir421x_patches[i], &self->usbdev->dev) != 0) {
+ IRDA_ERROR( "%s(), Patch %s is not available\n", __FUNCTION__, stir421x_patches[i]);
+ continue;
+ }
+
+ /* We found a patch from userspace */
+ patch_version = stir421x_get_patch_version (fw_entry->data, fw_entry->size);
+
+ if (patch_version < 0) {
+ /* Couldn't fetch a version, let's move on to the next file */
+ IRDA_ERROR("%s(), version parsing failed\n", __FUNCTION__);
+ ret = patch_version;
+ release_firmware(fw_entry);
+ continue;
+ }
+
+ if (patch_version != self->usbdev->descriptor.bcdDevice) {
+ /* Patch version and device don't match */
+ IRDA_ERROR ("%s(), wrong patch version (%d <-> %d)\n",
+ __FUNCTION__,
+ patch_version, self->usbdev->descriptor.bcdDevice);
+ ret = -EINVAL;
+ release_firmware(fw_entry);
+ continue;
+ }
+
+ /* If we're here, we've found a correct patch */
+ patch_found = 1;
+ break;
+
+ }
+
+ /* We couldn't find a valid firmware, let's leave */
+ if (!patch_found)
+ return ret;
+
+ /* The actual image starts after the "STMP" keyword */
+ for (data_offset = 0; data_offset < STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET; data_offset++) {
+ if (!memcmp(fw_entry->data + data_offset,
+ STIR421X_PATCH_DATA_TAG_STR,
+ sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET))) {
+ IRDA_DEBUG(2, "%s(), found patch data for STIR421x at offset %d\n",
+ __FUNCTION__, data_offset);
+ data_found = 1;
+ break;
+ }
+ }
+
+ /* We couldn't find "STMP" from the header */
+ if (!data_found)
+ return -EINVAL;
+
+ /* Let's upload the patch to the target */
+ ret = stir421x_upload_patch(self,
+ &fw_entry->data[data_offset + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET)],
+ fw_entry->size - (data_offset + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET)));
+
+ release_firmware(fw_entry);
+
+ return ret;
+
+}
+
+
/********************** IRDA DEVICE CALLBACKS **********************/
/*
* Main calls from the IrDA/Network subsystem.
@@ -972,6 +1242,11 @@ static int irda_usb_net_open(struct net_device *netdev)
return -1;
}
+ if(self->needspatch) {
+ IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ;
+ return -EIO ;
+ }
+
/* Initialise default speed and xbofs value
* (IrLAP will change that soon) */
self->speed = -1;
@@ -1050,7 +1325,7 @@ static int irda_usb_net_close(struct net_device *netdev)
del_timer(&self->rx_defer_timer);
/* Deallocate all the Rx path buffers (URBs and skb) */
- for (i = 0; i < IU_MAX_RX_URBS; i++) {
+ for (i = 0; i < self->max_rx_urb; i++) {
struct urb *urb = self->rx_urb[i];
struct sk_buff *skb = (struct sk_buff *) urb->context;
/* Cancel the receive command */
@@ -1426,8 +1701,22 @@ static int irda_usb_probe(struct usb_interface *intf,
spin_lock_init(&self->lock);
init_timer(&self->rx_defer_timer);
+ self->capability = id->driver_info;
+ self->needspatch = ((self->capability & IUC_STIR_4210) != 0) ;
+
/* Create all of the needed urbs */
- for (i = 0; i < IU_MAX_RX_URBS; i++) {
+ if (self->capability & IUC_STIR_4210) {
+ self->max_rx_urb = IU_SIGMATEL_MAX_RX_URBS;
+ self->header_length = USB_IRDA_SIGMATEL_HEADER;
+ } else {
+ self->max_rx_urb = IU_MAX_RX_URBS;
+ self->header_length = USB_IRDA_HEADER;
+ }
+
+ self->rx_urb = kzalloc(self->max_rx_urb * sizeof(struct urb *),
+ GFP_KERNEL);
+
+ for (i = 0; i < self->max_rx_urb; i++) {
self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
if (!self->rx_urb[i]) {
goto err_out_1;
@@ -1479,17 +1768,28 @@ static int irda_usb_probe(struct usb_interface *intf,
goto err_out_3;
}
+ self->usbdev = dev;
+
/* Find IrDA class descriptor */
irda_desc = irda_usb_find_class_desc(intf);
ret = -ENODEV;
if (irda_desc == NULL)
goto err_out_3;
+ if (self->needspatch) {
+ ret = usb_control_msg (self->usbdev, usb_sndctrlpipe (self->usbdev, 0),
+ 0x02, 0x40, 0, 0, 0, 0, msecs_to_jiffies(500));
+ if (ret < 0) {
+ IRDA_DEBUG (0, "usb_control_msg failed %d\n", ret);
+ goto err_out_3;
+ } else {
+ mdelay(10);
+ }
+ }
+
self->irda_desc = irda_desc;
self->present = 1;
self->netopen = 0;
- self->capability = id->driver_info;
- self->usbdev = dev;
self->usbintf = intf;
/* Allocate the buffer for speed changes */
@@ -1508,6 +1808,28 @@ static int irda_usb_probe(struct usb_interface *intf,
IRDA_MESSAGE("IrDA: Registered device %s\n", net->name);
usb_set_intfdata(intf, self);
+
+ if (self->needspatch) {
+ /* Now we fetch and upload the firmware patch */
+ ret = stir421x_patch_device(self);
+ self->needspatch = (ret < 0);
+ if (ret < 0) {
+ printk("patch_device failed\n");
+ goto err_out_4;
+ }
+
+ /* replace IrDA class descriptor with what patched device is now reporting */
+ irda_desc = irda_usb_find_class_desc (self->usbintf);
+ if (irda_desc == NULL) {
+ ret = -ENODEV;
+ goto err_out_4;
+ }
+ if (self->irda_desc)
+ kfree (self->irda_desc);
+ self->irda_desc = irda_desc;
+ irda_usb_init_qos(self);
+ }
+
return 0;
err_out_4:
@@ -1518,7 +1840,7 @@ err_out_3:
err_out_2:
usb_free_urb(self->tx_urb);
err_out_1:
- for (i = 0; i < IU_MAX_RX_URBS; i++) {
+ for (i = 0; i < self->max_rx_urb; i++) {
if (self->rx_urb[i])
usb_free_urb(self->rx_urb[i]);
}
@@ -1571,7 +1893,7 @@ static void irda_usb_disconnect(struct usb_interface *intf)
/*netif_device_detach(self->netdev);*/
netif_stop_queue(self->netdev);
/* Stop all the receive URBs. Must be synchronous. */
- for (i = 0; i < IU_MAX_RX_URBS; i++)
+ for (i = 0; i < self->max_rx_urb; i++)
usb_kill_urb(self->rx_urb[i]);
/* Cancel Tx and speed URB.
* Make sure it's synchronous to avoid races. */
@@ -1586,8 +1908,9 @@ static void irda_usb_disconnect(struct usb_interface *intf)
self->usbintf = NULL;
/* Clean up our urbs */
- for (i = 0; i < IU_MAX_RX_URBS; i++)
+ for (i = 0; i < self->max_rx_urb; i++)
usb_free_urb(self->rx_urb[i]);
+ kfree(self->rx_urb);
/* Clean up Tx and speed URB */
usb_free_urb(self->tx_urb);
usb_free_urb(self->speed_urb);
@@ -1648,6 +1971,6 @@ module_exit(usb_irda_cleanup);
*/
module_param(qos_mtt_bits, int, 0);
MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time");
-MODULE_AUTHOR("Roman Weissgaerber <weissg@vienna.at>, Dag Brattli <dag@brattli.net> and Jean Tourrilhes <jt@hpl.hp.com>");
-MODULE_DESCRIPTION("IrDA-USB Dongle Driver");
+MODULE_AUTHOR("Roman Weissgaerber <weissg@vienna.at>, Dag Brattli <dag@brattli.net>, Jean Tourrilhes <jt@hpl.hp.com> and Nick Fedchik <nick@fedchik.org.ua>");
+MODULE_DESCRIPTION("IrDA-USB Dongle Driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h
index 4026af42dd47d..d833db52cebf2 100644
--- a/drivers/net/irda/irda-usb.h
+++ b/drivers/net/irda/irda-usb.h
@@ -1,7 +1,7 @@
/*****************************************************************************
*
* Filename: irda-usb.h
- * Version: 0.9b
+ * Version: 0.10
* Description: IrDA-USB Driver
* Status: Experimental
* Author: Dag Brattli <dag@brattli.net>
@@ -9,6 +9,9 @@
* Copyright (C) 2001, Roman Weissgaerber <weissg@vienna.at>
* Copyright (C) 2000, Dag Brattli <dag@brattli.net>
* Copyright (C) 2001, Jean Tourrilhes <jt@hpl.hp.com>
+ * Copyright (C) 2004, SigmaTel, Inc. <irquality@sigmatel.com>
+ * Copyright (C) 2005, Milan Beno <beno@pobox.sk>
+ * Copyright (C) 2006, Nick FEdchik <nick@fedchik.org.ua>
*
* 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
@@ -31,6 +34,9 @@
#include <net/irda/irda.h>
#include <net/irda/irda_device.h> /* struct irlap_cb */
+#define PATCH_FILE_SIZE_MAX 65536
+#define PATCH_FILE_SIZE_MIN 80
+
#define RX_COPY_THRESHOLD 200
#define IRDA_USB_MAX_MTU 2051
#define IRDA_USB_SPEED_MTU 64 /* Weird, but work like this */
@@ -79,15 +85,16 @@
/* Inbound header */
#define MEDIA_BUSY 0x80
-#define SPEED_2400 0x01
-#define SPEED_9600 0x02
-#define SPEED_19200 0x03
-#define SPEED_38400 0x04
-#define SPEED_57600 0x05
-#define SPEED_115200 0x06
-#define SPEED_576000 0x07
-#define SPEED_1152000 0x08
-#define SPEED_4000000 0x09
+#define SPEED_2400 0x01
+#define SPEED_9600 0x02
+#define SPEED_19200 0x03
+#define SPEED_38400 0x04
+#define SPEED_57600 0x05
+#define SPEED_115200 0x06
+#define SPEED_576000 0x07
+#define SPEED_1152000 0x08
+#define SPEED_4000000 0x09
+#define SPEED_16000000 0x0a
/* Basic capabilities */
#define IUC_DEFAULT 0x00 /* Basic device compliant with 1.0 spec */
@@ -100,11 +107,14 @@
#define IUC_SMALL_PKT 0x10 /* Device doesn't behave with big Rx packets */
#define IUC_MAX_WINDOW 0x20 /* Device underestimate the Rx window */
#define IUC_MAX_XBOFS 0x40 /* Device need more xbofs than advertised */
+#define IUC_STIR_4210 0x80 /* SigmaTel 4210/4220/4116 VFIR */
/* USB class definitions */
-#define USB_IRDA_HEADER 0x01
-#define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */
-#define USB_DT_IRDA 0x21
+#define USB_IRDA_HEADER 0x01
+#define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */
+#define USB_DT_IRDA 0x21
+#define USB_IRDA_SIGMATEL_HEADER 0x03
+#define IU_SIGMATEL_MAX_RX_URBS (IU_MAX_ACTIVE_RX_URBS + USB_IRDA_SIGMATEL_HEADER)
struct irda_class_desc {
__u8 bLength;
@@ -123,6 +133,7 @@ struct irda_class_desc {
* (6.2.5, USB-IrDA class spec 1.0) */
#define IU_REQ_GET_CLASS_DESC 0x06
+#define STIR421X_MAX_PATCH_DOWNLOAD_SIZE 1023
struct irda_usb_cb {
struct irda_class_desc *irda_desc;
@@ -136,7 +147,8 @@ struct irda_usb_cb {
__u16 bulk_out_mtu; /* Max Tx packet size in bytes */
__u8 bulk_int_ep; /* Interrupt Endpoint assignments */
- struct urb *rx_urb[IU_MAX_RX_URBS]; /* URBs used to receive data frames */
+ __u8 max_rx_urb;
+ struct urb **rx_urb; /* URBs used to receive data frames */
struct urb *idle_rx_urb; /* Pointer to idle URB in Rx path */
struct urb *tx_urb; /* URB used to send data frames */
struct urb *speed_urb; /* URB used to send speed commands */
@@ -157,6 +169,9 @@ struct irda_usb_cb {
__u32 speed; /* Current speed */
__s32 new_speed; /* speed we need to set */
+ __u8 header_length; /* USB-IrDA frame header size */
+ int needspatch; /* device needs firmware patch */
+
struct timer_list rx_defer_timer; /* Wait for Rx error to clear */
};
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index ec94ecdb103dc..bbcfc8ec35a15 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -11,6 +11,7 @@
* Copyright (c) 2002 Daniele Peri
* All Rights Reserved.
* Copyright (c) 2002 Jean Tourrilhes
+ * Copyright (c) 2006 Linus Walleij
*
*
* Based on smc-ircc.c:
@@ -61,6 +62,9 @@
#include <linux/spinlock.h>
#include <linux/pm.h>
+#ifdef CONFIG_PCI
+#include <linux/pci.h>
+#endif
#include <net/irda/wrapper.h>
#include <net/irda/irda.h>
@@ -100,6 +104,22 @@ MODULE_PARM_DESC(ircc_transceiver, "Transceiver type");
/* Types */
+#ifdef CONFIG_PCI
+struct smsc_ircc_subsystem_configuration {
+ unsigned short vendor; /* PCI vendor ID */
+ unsigned short device; /* PCI vendor ID */
+ unsigned short subvendor; /* PCI subsystem vendor ID */
+ unsigned short subdevice; /* PCI sybsystem device ID */
+ unsigned short sir_io; /* I/O port for SIR */
+ unsigned short fir_io; /* I/O port for FIR */
+ unsigned char fir_irq; /* FIR IRQ */
+ unsigned char fir_dma; /* FIR DMA */
+ unsigned short cfg_base; /* I/O port for chip configuration */
+ int (*preconfigure)(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); /* Preconfig function */
+ const char *name; /* name shown as info */
+};
+#endif
+
struct smsc_transceiver {
char *name;
void (*set_for_speed)(int fir_base, u32 speed);
@@ -202,6 +222,16 @@ static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned shor
static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
static int __init smsc_superio_fdc(unsigned short cfg_base);
static int __init smsc_superio_lpc(unsigned short cfg_base);
+#ifdef CONFIG_PCI
+static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf);
+static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
+static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
+static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
+ unsigned short ircc_fir,
+ unsigned short ircc_sir,
+ unsigned char ircc_dma,
+ unsigned char ircc_irq);
+#endif
/* Transceivers specific functions */
@@ -353,6 +383,13 @@ static int __init smsc_ircc_init(void)
return ret;
}
+#ifdef CONFIG_PCI
+ if (smsc_ircc_preconfigure_subsystems(ircc_cfg, ircc_fir, ircc_sir, ircc_dma, ircc_irq) < 0) {
+ /* Ignore errors from preconfiguration */
+ IRDA_ERROR("%s, Preconfiguration failed !\n", driver_name);
+ }
+#endif
+
dev_count = 0;
if (ircc_fir > 0 && ircc_sir > 0) {
@@ -2285,6 +2322,280 @@ static int __init smsc_superio_lpc(unsigned short cfg_base)
return ret;
}
+/*
+ * Look for some specific subsystem setups that need
+ * pre-configuration not properly done by the BIOS (especially laptops)
+ * This code is based in part on smcinit.c, tosh1800-smcinit.c
+ * and tosh2450-smcinit.c. The table lists the device entries
+ * for ISA bridges with an LPC (Local Peripheral Configurator)
+ * that are in turn used to configure the SMSC device with default
+ * SIR and FIR I/O ports, DMA and IRQ.
+ */
+#ifdef CONFIG_PCI
+#define PCIID_VENDOR_INTEL 0x8086
+#define PCIID_VENDOR_ALI 0x10b9
+static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __devinitdata = {
+ {
+ .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
+ .device = 0x24cc,
+ .subvendor = 0x103c,
+ .subdevice = 0x088c,
+ .sir_io = 0x02f8, /* Quite certain these are the same for nc8000 as for nc6000 */
+ .fir_io = 0x0130,
+ .fir_irq = 0x09,
+ .fir_dma = 0x03,
+ .cfg_base = 0x004e,
+ .preconfigure = preconfigure_through_82801,
+ .name = "HP nc8000",
+ },
+ {
+ .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
+ .device = 0x24cc,
+ .subvendor = 0x103c,
+ .subdevice = 0x0890,
+ .sir_io = 0x02f8,
+ .fir_io = 0x0130,
+ .fir_irq = 0x09,
+ .fir_dma = 0x03,
+ .cfg_base = 0x004e,
+ .preconfigure = preconfigure_through_82801,
+ .name = "HP nc6000",
+ },
+ {
+ .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge */
+ .device = 0x24c0,
+ .subvendor = 0x1179,
+ .subdevice = 0xffff, /* 0xffff is "any", Not sure, 0x0001 or 0x0002 */
+ .sir_io = 0x03f8,
+ .fir_io = 0x0130,
+ .fir_irq = 0x07,
+ .fir_dma = 0x01,
+ .cfg_base = 0x002e,
+ .preconfigure = preconfigure_through_82801,
+ .name = "Toshiba Satellite 2450",
+ },
+ {
+ .vendor = PCIID_VENDOR_INTEL, /* Intel 82801CAM ISA bridge */
+ .device = 0x248c, /* Some use 24cc? */
+ .subvendor = 0x1179,
+ .subdevice = 0xffff, /* 0xffff is "any", Not sure, 0x0001 or 0x0002 */
+ .sir_io = 0x03f8,
+ .fir_io = 0x0130,
+ .fir_irq = 0x03,
+ .fir_dma = 0x03,
+ .cfg_base = 0x002e,
+ .preconfigure = preconfigure_through_82801,
+ .name = "Toshiba Satellite 5100/5200, Tecra 9100",
+ },
+ {
+ .vendor = PCIID_VENDOR_ALI, /* ALi M1533/M1535 PCI to ISA Bridge [Aladdin IV/V/V+] */
+ .device = 0x1533,
+ .subvendor = 0x1179,
+ .subdevice = 0xffff, /* 0xffff is "any", Not sure, 0x0001 or 0x0002 */
+ .sir_io = 0x02e8,
+ .fir_io = 0x02f8,
+ .fir_irq = 0x07,
+ .fir_dma = 0x03,
+ .cfg_base = 0x002e,
+ .preconfigure = preconfigure_through_ali,
+ .name = "Toshiba Satellite 1800",
+ },
+ { } // Terminator
+};
+
+
+/*
+ * This sets up the basic SMSC parameters (FIR port, SIR port, FIR DMA, FIR IRQ)
+ * through the chip configuration port.
+ */
+static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf)
+{
+ unsigned short iobase = conf->cfg_base;
+ unsigned char tmpbyte;
+
+ outb(LPC47N227_CFGACCESSKEY, iobase); // enter configuration state
+ outb(SMSCSIOFLAT_DEVICEID_REG, iobase); // set for device ID
+ tmpbyte = inb(iobase +1); // Read device ID
+ IRDA_DEBUG(0, "Detected Chip id: 0x%02x, setting up registers...\n",tmpbyte);
+
+ /* Disable UART1 and set up SIR I/O port */
+ outb(0x24, iobase); // select CR24 - UART1 base addr
+ outb(0x00, iobase + 1); // disable UART1
+ outb(SMSCSIOFLAT_UART2BASEADDR_REG, iobase); // select CR25 - UART2 base addr
+ outb( (conf->sir_io >> 2), iobase + 1); // bits 2-9 of 0x3f8
+ tmpbyte = inb(iobase + 1);
+ if (tmpbyte != (conf->sir_io >> 2) ) {
+ IRDA_WARNING("ERROR: could not configure SIR ioport.\n");
+ return -ENXIO;
+ }
+
+ /* Set up FIR IRQ channel for UART2 */
+ outb(SMSCSIOFLAT_UARTIRQSELECT_REG, iobase); // select CR28 - UART1,2 IRQ select
+ tmpbyte = inb(iobase + 1);
+ tmpbyte &= SMSCSIOFLAT_UART1IRQSELECT_MASK; // Do not touch the UART1 portion
+ tmpbyte |= (conf->fir_irq & SMSCSIOFLAT_UART2IRQSELECT_MASK);
+ outb(tmpbyte, iobase + 1);
+ tmpbyte = inb(iobase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
+ if (tmpbyte != conf->fir_irq) {
+ IRDA_WARNING("ERROR: could not configure FIR IRQ channel.\n");
+ return -ENXIO;
+ }
+
+ /* Set up FIR I/O port */
+ outb(SMSCSIOFLAT_FIRBASEADDR_REG, iobase); // CR2B - SCE (FIR) base addr
+ outb((conf->fir_io >> 3), iobase + 1);
+ tmpbyte = inb(iobase + 1);
+ if (tmpbyte != (conf->fir_io >> 3) ) {
+ IRDA_WARNING("ERROR: could not configure FIR I/O port.\n");
+ return -ENXIO;
+ }
+
+ /* Set up FIR DMA channel */
+ outb(SMSCSIOFLAT_FIRDMASELECT_REG, iobase); // CR2C - SCE (FIR) DMA select
+ outb((conf->fir_dma & LPC47N227_FIRDMASELECT_MASK), iobase + 1); // DMA
+ tmpbyte = inb(iobase + 1) & LPC47N227_FIRDMASELECT_MASK;
+ if (tmpbyte != (conf->fir_dma & LPC47N227_FIRDMASELECT_MASK)) {
+ IRDA_WARNING("ERROR: could not configure FIR DMA channel.\n");
+ return -ENXIO;
+ }
+
+ outb(SMSCSIOFLAT_UARTMODE0C_REG, iobase); // CR0C - UART mode
+ tmpbyte = inb(iobase + 1);
+ tmpbyte &= ~SMSCSIOFLAT_UART2MODE_MASK | SMSCSIOFLAT_UART2MODE_VAL_IRDA;
+ outb(tmpbyte, iobase + 1); // enable IrDA (HPSIR) mode, high speed
+
+ outb(LPC47N227_APMBOOTDRIVE_REG, iobase); // CR07 - Auto Pwr Mgt/boot drive sel
+ tmpbyte = inb(iobase + 1);
+ outb(tmpbyte | LPC47N227_UART2AUTOPWRDOWN_MASK, iobase + 1); // enable UART2 autopower down
+
+ /* This one was not part of tosh1800 */
+ outb(0x0a, iobase); // CR0a - ecp fifo / ir mux
+ tmpbyte = inb(iobase + 1);
+ outb(tmpbyte | 0x40, iobase + 1); // send active device to ir port
+
+ outb(LPC47N227_UART12POWER_REG, iobase); // CR02 - UART 1,2 power
+ tmpbyte = inb(iobase + 1);
+ outb(tmpbyte | LPC47N227_UART2POWERDOWN_MASK, iobase + 1); // UART2 power up mode, UART1 power down
+
+ outb(LPC47N227_FDCPOWERVALIDCONF_REG, iobase); // CR00 - FDC Power/valid config cycle
+ tmpbyte = inb(iobase + 1);
+ outb(tmpbyte | LPC47N227_VALID_MASK, iobase + 1); // valid config cycle done
+
+ outb(LPC47N227_CFGEXITKEY, iobase); // Exit configuration
+
+ return 0;
+}
+
+/* 82801CAM registers */
+#define VID 0x00
+#define DID 0x02
+#define PIRQA_ROUT 0x60
+#define PCI_DMA_C 0x90
+#define COM_DEC 0xe0
+#define LPC_EN 0xe6
+#define GEN2_DEC 0xec
+/*
+ * Sets up the I/O range using the 82801CAM ISA bridge, 82801DBM LPC bridge or
+ * Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge. They all work the same way!
+ */
+static int __init preconfigure_through_82801(struct pci_dev *dev,
+ struct smsc_ircc_subsystem_configuration *conf)
+{
+ unsigned short tmpword;
+ int ret;
+
+ IRDA_MESSAGE("Setting up the SMSC device via the 82801 controller.\n");
+ pci_write_config_byte(dev, COM_DEC, 0x10);
+
+ /* Enable LPC */
+ pci_read_config_word(dev, LPC_EN, &tmpword); /* LPC_EN register */
+ tmpword &= 0xfffd; /* mask bit 1 */
+ tmpword |= 0x0001; /* set bit 0 : COMA addr range enable */
+ pci_write_config_word(dev, LPC_EN, tmpword);
+
+ /* Setup DMA */
+ pci_write_config_word(dev, PCI_DMA_C, 0xc0c0); /* LPC I/F DMA on, channel 3 -- rtm (?? PCI DMA ?) */
+ pci_write_config_word(dev, GEN2_DEC, 0x131); /* LPC I/F 2nd decode range */
+
+ /* Pre-configure chip */
+ ret = preconfigure_smsc_chip(conf);
+
+ /* Disable LPC */
+ pci_read_config_word(dev, LPC_EN, &tmpword); /* LPC_EN register */
+ tmpword &= 0xfffc; /* mask bit 1 and bit 0, COMA addr range disable */
+ pci_write_config_word(dev, LPC_EN, tmpword);
+ return ret;
+}
+
+static int __init preconfigure_through_ali(struct pci_dev *dev,
+ struct smsc_ircc_subsystem_configuration *conf)
+{
+ /* TODO: put in ALi 1533 configuration here. */
+ IRDA_MESSAGE("SORRY: %s has an unsupported bridge controller (ALi): not pre-configured.\n", conf->name);
+ return -ENODEV;
+}
+
+static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
+ unsigned short ircc_fir,
+ unsigned short ircc_sir,
+ unsigned char ircc_dma,
+ unsigned char ircc_irq)
+{
+ struct pci_dev *dev = NULL;
+ unsigned short ss_vendor = 0x0000;
+ unsigned short ss_device = 0x0000;
+ int ret = 0;
+
+ dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
+
+ while (dev != NULL) {
+ struct smsc_ircc_subsystem_configuration *conf;
+
+ /*
+ * Cache the subsystem vendor/device: some manufacturers fail to set
+ * this for all components, so we save it in case there is just
+ * 0x0000 0x0000 on the device we want to check.
+ */
+ if (dev->subsystem_vendor != 0x0000U) {
+ ss_vendor = dev->subsystem_vendor;
+ ss_device = dev->subsystem_device;
+ }
+ conf = subsystem_configurations;
+ for( ; conf->subvendor; conf++) {
+ if(conf->vendor == dev->vendor &&
+ conf->device == dev->device &&
+ conf->subvendor == ss_vendor && /* Sometimes these are cached values */
+ (conf->subdevice == ss_device || conf->subdevice == 0xffff)) {
+ struct smsc_ircc_subsystem_configuration tmpconf;
+
+ memcpy(&tmpconf, conf, sizeof(struct smsc_ircc_subsystem_configuration));
+
+ /* Override the default values with anything passed in as parameter */
+ if (ircc_cfg != 0)
+ tmpconf.cfg_base = ircc_cfg;
+ if (ircc_fir != 0)
+ tmpconf.fir_io = ircc_fir;
+ if (ircc_sir != 0)
+ tmpconf.sir_io = ircc_sir;
+ if (ircc_dma != 0xff)
+ tmpconf.fir_dma = ircc_dma;
+ if (ircc_irq != 0xff)
+ tmpconf.fir_irq = ircc_irq;
+
+ IRDA_MESSAGE("Detected unconfigured %s SMSC IrDA chip, pre-configuring device.\n", conf->name);
+ if (conf->preconfigure)
+ ret = conf->preconfigure(dev, &tmpconf);
+ else
+ ret = -ENODEV;
+ }
+ }
+ dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
+ }
+
+ return ret;
+}
+#endif // CONFIG_PCI
+
/************************************************
*
* Transceivers specific functions
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index f9f77e4f59650..cfd67d812f0db 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -357,18 +357,20 @@ ixgb_probe(struct pci_dev *pdev,
if((err = pci_enable_device(pdev)))
return err;
- if(!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
+ if(!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
+ !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
pci_using_dac = 1;
} else {
- if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
+ if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
+ (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
IXGB_ERR("No usable DMA configuration, aborting\n");
- return err;
+ goto err_dma_mask;
}
pci_using_dac = 0;
}
if((err = pci_request_regions(pdev, ixgb_driver_name)))
- return err;
+ goto err_request_regions;
pci_set_master(pdev);
@@ -502,6 +504,9 @@ err_ioremap:
free_netdev(netdev);
err_alloc_etherdev:
pci_release_regions(pdev);
+err_request_regions:
+err_dma_mask:
+ pci_disable_device(pdev);
return err;
}
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 9f2661355a4ac..ea62a3e7d5860 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -281,10 +281,16 @@ static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
- netif_device_detach(dev);
+ if (!netif_running(dev))
+ return;
+
+ netif_stop_queue(dev);
+
eth_port_reset(mp->port_num);
eth_port_start(dev);
- netif_device_attach(dev);
+
+ if (mp->tx_ring_size - mp->tx_desc_count >= MAX_DESCS_PER_SKB)
+ netif_wake_queue(dev);
}
/**
@@ -552,9 +558,9 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id,
#else
if (eth_int_cause & ETH_INT_CAUSE_RX)
mv643xx_eth_receive_queue(dev, INT_MAX);
+#endif
if (eth_int_cause_ext & ETH_INT_CAUSE_TX)
mv643xx_eth_free_completed_tx_descs(dev);
-#endif
/*
* If no real interrupt occured, exit.
@@ -1186,7 +1192,12 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
BUG_ON(netif_queue_stopped(dev));
BUG_ON(skb == NULL);
- BUG_ON(mp->tx_ring_size - mp->tx_desc_count < MAX_DESCS_PER_SKB);
+
+ if (mp->tx_ring_size - mp->tx_desc_count < MAX_DESCS_PER_SKB) {
+ printk(KERN_ERR "%s: transmit with queue full\n", dev->name);
+ netif_stop_queue(dev);
+ return 1;
+ }
if (has_tiny_unaligned_frags(skb)) {
if ((skb_linearize(skb, GFP_ATOMIC) != 0)) {
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 7826afbb9db91..90627756d6fa4 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -238,7 +238,7 @@ static int full_duplex[MAX_UNITS];
#define NATSEMI_RX_LIMIT 2046 /* maximum supported by hardware */
/* These identify the driver base version and may not be removed. */
-static char version[] __devinitdata =
+static const char version[] __devinitdata =
KERN_INFO DRV_NAME " dp8381x driver, version "
DRV_VERSION ", " DRV_RELDATE "\n"
KERN_INFO " originally by Donald Becker <becker@scyld.com>\n"
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 75b35ad760de3..66e74f7402610 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -87,6 +87,7 @@ static void write_msg(struct console *con, const char *msg, unsigned int len)
}
static struct console netconsole = {
+ .name = "netcon",
.flags = CON_ENABLED | CON_PRINTBUFFER,
.write = write_msg
};
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 56233afcb2b3d..448a09488529f 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1560,7 +1560,7 @@ static void ei_receive(struct net_device *dev)
static void ei_rx_overrun(struct net_device *dev)
{
- axnet_dev_t *info = (axnet_dev_t *)dev;
+ axnet_dev_t *info = PRIV(dev);
long e8390_base = dev->base_addr;
unsigned char was_txing, must_resend = 0;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 35dbf05c7f063..a70c2b0cc1042 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -78,6 +78,8 @@ static const struct pci_device_id skge_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) },
{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) },
{ PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), },
+ { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) },
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) },
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */
{ PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD) },
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 68f9c206a6205..67b0eab16589e 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -99,8 +99,6 @@ MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
static const struct pci_device_id sky2_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
- { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },
- { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) },
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
@@ -579,8 +577,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
reg = gma_read16(hw, port, GM_PHY_ADDR);
gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR);
- for (i = 0; i < GM_MIB_CNT_SIZE; i++)
- gma_read16(hw, port, GM_MIB_CNT_BASE + 8 * i);
+ for (i = GM_MIB_CNT_BASE; i <= GM_MIB_CNT_END; i += 4)
+ gma_read16(hw, port, i);
gma_write16(hw, port, GM_PHY_ADDR, reg);
/* transmit control */
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 62532b4e45c5e..89dd18cd12f0b 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1375,7 +1375,7 @@ enum {
GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */
/* MIB Counters */
GM_MIB_CNT_BASE = 0x0100, /* Base Address of MIB Counters */
- GM_MIB_CNT_SIZE = 256,
+ GM_MIB_CNT_END = 0x025C, /* Last MIB counter */
};
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 45ad036733e21..9b7805be21dab 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -335,7 +335,7 @@ do { \
/* These identify the driver base version and may not be removed. */
-static char version[] __devinitdata =
+static const char version[] __devinitdata =
KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n"
KERN_INFO " (unofficial 2.2/2.4 kernel port, version " DRV_VERSION ", " DRV_RELDATE ")\n";
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 0b5358072172a..73e271e59c6a2 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -497,21 +497,20 @@ static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
unsigned long flags;
spin_lock_irqsave(&tp->indirect_lock, flags);
- pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
- pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val);
+ if (tp->tg3_flags & TG3_FLAG_SRAM_USE_CONFIG) {
+ pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
+ pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val);
- /* Always leave this as zero. */
- pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
- spin_unlock_irqrestore(&tp->indirect_lock, flags);
-}
+ /* Always leave this as zero. */
+ pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
+ } else {
+ tw32_f(TG3PCI_MEM_WIN_BASE_ADDR, off);
+ tw32_f(TG3PCI_MEM_WIN_DATA, val);
-static void tg3_write_mem_fast(struct tg3 *tp, u32 off, u32 val)
-{
- /* If no workaround is needed, write to mem space directly */
- if (tp->write32 != tg3_write_indirect_reg32)
- tw32(NIC_SRAM_WIN_BASE + off, val);
- else
- tg3_write_mem(tp, off, val);
+ /* Always leave this as zero. */
+ tw32_f(TG3PCI_MEM_WIN_BASE_ADDR, 0);
+ }
+ spin_unlock_irqrestore(&tp->indirect_lock, flags);
}
static void tg3_read_mem(struct tg3 *tp, u32 off, u32 *val)
@@ -519,11 +518,19 @@ static void tg3_read_mem(struct tg3 *tp, u32 off, u32 *val)
unsigned long flags;
spin_lock_irqsave(&tp->indirect_lock, flags);
- pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
- pci_read_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val);
+ if (tp->tg3_flags & TG3_FLAG_SRAM_USE_CONFIG) {
+ pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
+ pci_read_config_dword(tp->pdev, TG3PCI_MEM_WIN_DATA, val);
- /* Always leave this as zero. */
- pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
+ /* Always leave this as zero. */
+ pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
+ } else {
+ tw32_f(TG3PCI_MEM_WIN_BASE_ADDR, off);
+ *val = tr32(TG3PCI_MEM_WIN_DATA);
+
+ /* Always leave this as zero. */
+ tw32_f(TG3PCI_MEM_WIN_BASE_ADDR, 0);
+ }
spin_unlock_irqrestore(&tp->indirect_lock, flags);
}
@@ -1367,12 +1374,12 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
}
}
+ tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
+
/* Finally, set the new power state. */
pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
udelay(100); /* Delay after power state change */
- tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
-
return 0;
}
@@ -5828,10 +5835,14 @@ static int tg3_reset_hw(struct tg3 *tp)
GRC_MODE_NO_TX_PHDR_CSUM |
GRC_MODE_NO_RX_PHDR_CSUM);
tp->grc_mode |= GRC_MODE_HOST_SENDBDS;
- if (tp->tg3_flags & TG3_FLAG_NO_TX_PSEUDO_CSUM)
- tp->grc_mode |= GRC_MODE_NO_TX_PHDR_CSUM;
- if (tp->tg3_flags & TG3_FLAG_NO_RX_PSEUDO_CSUM)
- tp->grc_mode |= GRC_MODE_NO_RX_PHDR_CSUM;
+
+ /* Pseudo-header checksum is done by hardware logic and not
+ * the offload processers, so make the chip do the pseudo-
+ * header checksums on receive. For transmit it is more
+ * convenient to do the pseudo-header checksum in software
+ * as Linux does that on transmit for us in all cases.
+ */
+ tp->grc_mode |= GRC_MODE_NO_TX_PHDR_CSUM;
tw32(GRC_MODE,
tp->grc_mode |
@@ -6535,11 +6546,11 @@ static void tg3_timer(unsigned long __opaque)
if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
u32 val;
- tg3_write_mem_fast(tp, NIC_SRAM_FW_CMD_MBOX,
- FWCMD_NICDRV_ALIVE2);
- tg3_write_mem_fast(tp, NIC_SRAM_FW_CMD_LEN_MBOX, 4);
+ tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX,
+ FWCMD_NICDRV_ALIVE2);
+ tg3_write_mem(tp, NIC_SRAM_FW_CMD_LEN_MBOX, 4);
/* 5 seconds timeout */
- tg3_write_mem_fast(tp, NIC_SRAM_FW_CMD_DATA_MBOX, 5);
+ tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX, 5);
val = tr32(GRC_RX_CPU_EVENT);
val |= (1 << 14);
tw32(GRC_RX_CPU_EVENT, val);
@@ -8034,9 +8045,13 @@ static int tg3_test_nvram(struct tg3 *tp)
for (i = 0; i < size; i++)
csum8 += buf8[i];
- if (csum8 == 0)
- return 0;
- return -EIO;
+ if (csum8 == 0) {
+ err = 0;
+ goto out;
+ }
+
+ err = -EIO;
+ goto out;
}
/* Bootstrap checksum at offset 0x10 */
@@ -9531,8 +9546,11 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
tp->led_ctrl = LED_CTRL_MODE_PHY_1;
/* Do not even try poking around in here on Sun parts. */
- if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
+ if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
+ /* All SUN chips are built-in LOMs. */
+ tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
return;
+ }
tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
if (val == NIC_SRAM_DATA_SIG_MAGIC) {
@@ -9630,9 +9648,7 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)
tp->led_ctrl = LED_CTRL_MODE_PHY_2;
- if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700) &&
- (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) &&
- (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP))
+ if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP)
tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
@@ -10257,6 +10273,13 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
}
+ if (tp->write32 == tg3_write_indirect_reg32 ||
+ ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&
+ (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) ||
+ (tp->tg3_flags2 & TG3_FLG2_SUN_570X))
+ tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
+
/* Get eeprom hw config before calling tg3_set_power_state().
* In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be
* determined before calling tg3_set_power_state() so that
@@ -10299,15 +10322,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
if (tp->pci_chip_rev_id == CHIPREV_ID_5700_B0)
tp->tg3_flags |= TG3_FLAG_BROKEN_CHECKSUMS;
- /* Pseudo-header checksum is done by hardware logic and not
- * the offload processers, so make the chip do the pseudo-
- * header checksums on receive. For transmit it is more
- * convenient to do the pseudo-header checksum in software
- * as Linux does that on transmit for us in all cases.
- */
- tp->tg3_flags |= TG3_FLAG_NO_TX_PSEUDO_CSUM;
- tp->tg3_flags &= ~TG3_FLAG_NO_RX_PSEUDO_CSUM;
-
/* Derive initial jumbo mode from MTU assigned in
* ether_setup() via the alloc_etherdev() call
*/
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index c43cc32642025..8c8b987d12508 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2171,8 +2171,7 @@ struct tg3 {
#define TG3_FLAG_PCIX_MODE 0x00020000
#define TG3_FLAG_PCI_HIGH_SPEED 0x00040000
#define TG3_FLAG_PCI_32BIT 0x00080000
-#define TG3_FLAG_NO_TX_PSEUDO_CSUM 0x00100000
-#define TG3_FLAG_NO_RX_PSEUDO_CSUM 0x00200000
+#define TG3_FLAG_SRAM_USE_CONFIG 0x00100000
#define TG3_FLAG_SERDES_WOL_CAP 0x00400000
#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000
#define TG3_FLAG_10_100_ONLY 0x01000000
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index c1ce87a5f8d3a..d9258d42090c3 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -134,7 +134,7 @@ static const int multicast_filter_limit = 32;
#include "typhoon.h"
#include "typhoon-firmware.h"
-static char version[] __devinitdata =
+static const char version[] __devinitdata =
"typhoon.c: version " DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
MODULE_AUTHOR("David Dillow <dave@thedillows.org>");
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index a9b2150909d60..6a23964c13174 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -469,7 +469,7 @@ struct rhine_private {
struct sk_buff *tx_skbuff[TX_RING_SIZE];
dma_addr_t tx_skbuff_dma[TX_RING_SIZE];
- /* Tx bounce buffers */
+ /* Tx bounce buffers (Rhine-I only) */
unsigned char *tx_buf[TX_RING_SIZE];
unsigned char *tx_bufs;
dma_addr_t tx_bufs_dma;
@@ -1043,7 +1043,8 @@ static void alloc_tbufs(struct net_device* dev)
rp->tx_ring[i].desc_length = cpu_to_le32(TXDESC);
next += sizeof(struct tx_desc);
rp->tx_ring[i].next_desc = cpu_to_le32(next);
- rp->tx_buf[i] = &rp->tx_bufs[i * PKT_BUF_SZ];
+ if (rp->quirks & rqRhineI)
+ rp->tx_buf[i] = &rp->tx_bufs[i * PKT_BUF_SZ];
}
rp->tx_ring[i-1].next_desc = cpu_to_le32(rp->tx_ring_dma);
@@ -1091,7 +1092,7 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media)
}
/* Called after status of force_media possibly changed */
-void rhine_set_carrier(struct mii_if_info *mii)
+static void rhine_set_carrier(struct mii_if_info *mii)
{
if (mii->force_media) {
/* autoneg is off: Link is always assumed to be up */
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 883cf7da10fcb..b5328b0ff927d 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -410,103 +410,6 @@ config WAN_ROUTER_DRIVERS
If unsure, say N.
-config VENDOR_SANGOMA
- tristate "Sangoma WANPIPE(tm) multiprotocol cards"
- depends on WAN_ROUTER_DRIVERS && WAN_ROUTER && (PCI || ISA) && BROKEN
- ---help---
- Driver for S514-PCI/ISA Synchronous Data Link Adapters (SDLA).
-
- WANPIPE from Sangoma Technologies Inc. <http://www.sangoma.com/>
- is a family of intelligent multiprotocol WAN adapters with data
- transfer rates up to 4Mbps. Cards support:
-
- - X.25, Frame Relay, PPP, Cisco HDLC protocols.
-
- - API for protocols like HDLC (LAPB), HDLC Streaming, X.25,
- Frame Relay and BiSync.
-
- - Ethernet Bridging over Frame Relay protocol.
-
- - MULTILINK PPP
-
- - Async PPP (Modem Dialup)
-
- The next questions will ask you about the protocols you want
- the driver to support.
-
- If you have one or more of these cards, say M to this option;
- and read <file:Documentation/networking/wan-router.txt>.
-
- To compile this driver as a module, choose M here: the
- module will be called wanpipe.
-
-config WANPIPE_CHDLC
- bool "WANPIPE Cisco HDLC support"
- depends on VENDOR_SANGOMA
- ---help---
- Connect a WANPIPE card to a leased line using the Cisco HDLC.
-
- - Supports Dual Port Cisco HDLC on the S514-PCI/S508-ISA cards
- which allows user to build applications using the HDLC streaming API.
-
- - CHDLC Streaming MULTILINK PPP that can bind multiple WANPIPE T1
- cards into a single logical channel.
-
- Say Y and the Cisco HDLC support, HDLC streaming API and
- MULTILINK PPP will be included in the driver.
-
-config WANPIPE_FR
- bool "WANPIPE Frame Relay support"
- depends on VENDOR_SANGOMA
- help
- Connect a WANPIPE card to a Frame Relay network, or use Frame Relay
- API to develop custom applications.
-
- Contains the Ethernet Bridging over Frame Relay feature, where
- a WANPIPE frame relay link can be directly connected to the Linux
- kernel bridge. The Frame Relay option is supported on S514-PCI
- and S508-ISA cards.
-
- Say Y and the Frame Relay support will be included in the driver.
-
-config WANPIPE_X25
- bool "WANPIPE X.25 support"
- depends on VENDOR_SANGOMA
- help
- Connect a WANPIPE card to an X.25 network.
-
- Includes the X.25 API support for custom applications over the
- X.25 protocol. The X.25 option is supported on S514-PCI and
- S508-ISA cards.
-
- Say Y and the X.25 support will be included in the driver.
-
-config WANPIPE_PPP
- bool "WANPIPE PPP support"
- depends on VENDOR_SANGOMA
- help
- Connect a WANPIPE card to a leased line using Point-to-Point
- Protocol (PPP).
-
- The PPP option is supported on S514-PCI/S508-ISA cards.
-
- Say Y and the PPP support will be included in the driver.
-
-config WANPIPE_MULTPPP
- bool "WANPIPE Multi-Port PPP support"
- depends on VENDOR_SANGOMA
- help
- Connect a WANPIPE card to a leased line using Point-to-Point
- Protocol (PPP).
-
- Uses in-kernel SyncPPP protocol over the Sangoma HDLC Streaming
- adapter. In this case each Sangoma adapter port can support an
- independent PPP connection. For example, a single Quad-Port PCI
- adapter can support up to four independent PPP links. The PPP
- option is supported on S514-PCI/S508-ISA cards.
-
- Say Y and the Multi-Port PPP support will be included in the driver.
-
config CYCLADES_SYNC
tristate "Cyclom 2X(tm) cards (EXPERIMENTAL)"
depends on WAN_ROUTER_DRIVERS && (PCI || ISA)
diff --git a/drivers/net/wan/Makefile b/drivers/net/wan/Makefile
index ce6c56b903e79..823c6d5ab90d8 100644
--- a/drivers/net/wan/Makefile
+++ b/drivers/net/wan/Makefile
@@ -5,14 +5,6 @@
# Rewritten to use lists instead of if-statements.
#
-wanpipe-y := sdlamain.o sdla_ft1.o
-wanpipe-$(CONFIG_WANPIPE_X25) += sdla_x25.o
-wanpipe-$(CONFIG_WANPIPE_FR) += sdla_fr.o
-wanpipe-$(CONFIG_WANPIPE_CHDLC) += sdla_chdlc.o
-wanpipe-$(CONFIG_WANPIPE_PPP) += sdla_ppp.o
-wanpipe-$(CONFIG_WANPIPE_MULTPPP) += wanpipe_multppp.o
-wanpipe-objs := $(wanpipe-y)
-
cyclomx-y := cycx_main.o
cyclomx-$(CONFIG_CYCLOMX_X25) += cycx_x25.o
cyclomx-objs := $(cyclomx-y)
@@ -43,11 +35,6 @@ obj-$(CONFIG_LANMEDIA) += lmc/
obj-$(CONFIG_DLCI) += dlci.o
obj-$(CONFIG_SDLA) += sdla.o
-ifeq ($(CONFIG_WANPIPE_MULTPPP),y)
- obj-$(CONFIG_VENDOR_SANGOMA) += sdladrv.o wanpipe.o syncppp.o
-else
- obj-$(CONFIG_VENDOR_SANGOMA) += sdladrv.o wanpipe.o
-endif
obj-$(CONFIG_CYCLADES_SYNC) += cycx_drv.o cyclomx.o
obj-$(CONFIG_LAPBETHER) += lapbether.o
obj-$(CONFIG_SBNI) += sbni.o
diff --git a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c
deleted file mode 100644
index 496d29237e927..0000000000000
--- a/drivers/net/wan/sdla_chdlc.c
+++ /dev/null
@@ -1,4428 +0,0 @@
-/*****************************************************************************
-* sdla_chdlc.c WANPIPE(tm) Multiprotocol WAN Link Driver. Cisco HDLC module.
-*
-* Authors: Nenad Corbic <ncorbic@sangoma.com>
-* Gideon Hack
-*
-* Copyright: (c) 1995-2001 Sangoma Technologies 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.
-* ============================================================================
-* Feb 28, 2001 Nenad Corbic Updated if_tx_timeout() routine for
-* 2.4.X kernels.
-* Jan 25, 2001 Nenad Corbic Added a TTY Sync serial driver over the
-* HDLC streaming protocol
-* Added a TTY Async serial driver over the
-* Async protocol.
-* Dec 15, 2000 Nenad Corbic Updated for 2.4.X Kernel support
-* Nov 13, 2000 Nenad Corbic Added true interface type encoding option.
-* Tcpdump doesn't support CHDLC inteface
-* types, to fix this "true type" option will set
-* the interface type to RAW IP mode.
-* Nov 07, 2000 Nenad Corbic Added security features for UDP debugging:
-* Deny all and specify allowed requests.
-* Jun 20, 2000 Nenad Corbic Fixed the API IP ERROR bug. Caused by the
-* latest update.
-* May 09, 2000 Nenad Corbic Option to bring down an interface
-* upon disconnect.
-* Mar 23, 2000 Nenad Corbic Improved task queue, bh handling.
-* Mar 16, 2000 Nenad Corbic Fixed the SLARP Dynamic IP addressing.
-* Mar 06, 2000 Nenad Corbic Bug Fix: corrupted mbox recovery.
-* Feb 10, 2000 Gideon Hack Added ASYNC support.
-* Feb 09, 2000 Nenad Corbic Fixed two shutdown bugs in update() and
-* if_stats() functions.
-* Jan 24, 2000 Nenad Corbic Fixed a startup wanpipe state racing,
-* condition between if_open and isr.
-* Jan 10, 2000 Nenad Corbic Added new socket API support.
-* Dev 15, 1999 Nenad Corbic Fixed up header files for 2.0.X kernels
-* Nov 20, 1999 Nenad Corbic Fixed zero length API bug.
-* Sep 30, 1999 Nenad Corbic Fixed dynamic IP and route setup.
-* Sep 23, 1999 Nenad Corbic Added SMP support, fixed tracing
-* Sep 13, 1999 Nenad Corbic Split up Port 0 and 1 into separate devices.
-* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
-* Oct 30, 1998 Jaspreet Singh Added Support for CHDLC API (HDLC STREAMING).
-* Oct 28, 1998 Jaspreet Singh Added Support for Dual Port CHDLC.
-* Aug 07, 1998 David Fong Initial version.
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/if_arp.h> /* ARPHRD_* defines */
-
-
-#include <asm/uaccess.h>
-#include <linux/inetdevice.h>
-#include <linux/netdevice.h>
-
-#include <linux/in.h> /* sockaddr_in */
-#include <linux/inet.h>
-#include <linux/if.h>
-#include <asm/byteorder.h> /* htons(), etc. */
-#include <linux/sdlapci.h>
-#include <asm/io.h>
-
-#include <linux/sdla_chdlc.h> /* CHDLC firmware API definitions */
-#include <linux/sdla_asy.h> /* CHDLC (async) API definitions */
-
-#include <linux/if_wanpipe_common.h> /* Socket Driver common area */
-#include <linux/if_wanpipe.h>
-
-/* TTY Includes */
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/serial.h>
-
-
-/****** Defines & Macros ****************************************************/
-
-/* reasons for enabling the timer interrupt on the adapter */
-#define TMR_INT_ENABLED_UDP 0x01
-#define TMR_INT_ENABLED_UPDATE 0x02
-#define TMR_INT_ENABLED_CONFIG 0x10
-
-#define MAX_IP_ERRORS 10
-
-#define TTY_CHDLC_MAX_MTU 2000
-#define CHDLC_DFLT_DATA_LEN 1500 /* default MTU */
-#define CHDLC_HDR_LEN 1
-
-#define CHDLC_API 0x01
-
-#define PORT(x) (x == 0 ? "PRIMARY" : "SECONDARY" )
-#define MAX_BH_BUFF 10
-
-//#define PRINT_DEBUG
-#ifdef PRINT_DEBUG
-#define dbg_printk(format, a...) printk(format, ## a)
-#else
-#define dbg_printk(format, a...)
-#endif
-
-/******Data Structures*****************************************************/
-
-/* This structure is placed in the private data area of the device structure.
- * The card structure used to occupy the private area but now the following
- * structure will incorporate the card structure along with CHDLC specific data
- */
-
-typedef struct chdlc_private_area
-{
- wanpipe_common_t common;
- sdla_t *card;
- int TracingEnabled; /* For enabling Tracing */
- unsigned long curr_trace_addr; /* Used for Tracing */
- unsigned long start_trace_addr;
- unsigned long end_trace_addr;
- unsigned long base_addr_trace_buffer;
- unsigned long end_addr_trace_buffer;
- unsigned short number_trace_elements;
- unsigned available_buffer_space;
- unsigned long router_start_time;
- unsigned char route_status;
- unsigned char route_removed;
- unsigned long tick_counter; /* For 5s timeout counter */
- unsigned long router_up_time;
- u32 IP_address; /* IP addressing */
- u32 IP_netmask;
- u32 ip_local;
- u32 ip_remote;
- u32 ip_local_tmp;
- u32 ip_remote_tmp;
- u8 ip_error;
- u8 config_chdlc;
- u8 config_chdlc_timeout;
- unsigned char mc; /* Mulitcast support on/off */
- unsigned short udp_pkt_lgth; /* udp packet processing */
- char udp_pkt_src;
- char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
- unsigned short timer_int_enabled;
- char update_comms_stats; /* updating comms stats */
-
- bh_data_t *bh_head; /* Circular buffer for chdlc_bh */
- unsigned long tq_working;
- volatile int bh_write;
- volatile int bh_read;
- atomic_t bh_buff_used;
-
- unsigned char interface_down;
-
- /* Polling work queue entry. Each interface
- * has its own work queue entry, which is used
- * to defer events from the interrupt */
- struct work_struct poll_work;
- struct timer_list poll_delay_timer;
-
- u8 gateway;
- u8 true_if_encoding;
- //FIXME: add driver stats as per frame relay!
-
-} chdlc_private_area_t;
-
-/* Route Status options */
-#define NO_ROUTE 0x00
-#define ADD_ROUTE 0x01
-#define ROUTE_ADDED 0x02
-#define REMOVE_ROUTE 0x03
-
-
-/* variable for keeping track of enabling/disabling FT1 monitor status */
-static int rCount = 0;
-
-/* variable for tracking how many interfaces to open for WANPIPE on the
- two ports */
-
-extern void disable_irq(unsigned int);
-extern void enable_irq(unsigned int);
-
-/****** Function Prototypes *************************************************/
-/* WAN link driver entry points. These are called by the WAN router module. */
-static int update(struct wan_device* wandev);
-static int new_if(struct wan_device* wandev, struct net_device* dev,
- wanif_conf_t* conf);
-
-/* Network device interface */
-static int if_init(struct net_device* dev);
-static int if_open(struct net_device* dev);
-static int if_close(struct net_device* dev);
-static int if_header(struct sk_buff* skb, struct net_device* dev,
- unsigned short type, void* daddr, void* saddr,
- unsigned len);
-
-static int if_rebuild_hdr (struct sk_buff *skb);
-static struct net_device_stats* if_stats(struct net_device* dev);
-
-static int if_send(struct sk_buff* skb, struct net_device* dev);
-
-/* CHDLC Firmware interface functions */
-static int chdlc_configure (sdla_t* card, void* data);
-static int chdlc_comm_enable (sdla_t* card);
-static int chdlc_read_version (sdla_t* card, char* str);
-static int chdlc_set_intr_mode (sdla_t* card, unsigned mode);
-static int chdlc_send (sdla_t* card, void* data, unsigned len);
-static int chdlc_read_comm_err_stats (sdla_t* card);
-static int chdlc_read_op_stats (sdla_t* card);
-static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb);
-
-
-static int chdlc_disable_comm_shutdown (sdla_t *card);
-static void if_tx_timeout(struct net_device *dev);
-
-/* Miscellaneous CHDLC Functions */
-static int set_chdlc_config (sdla_t* card);
-static void init_chdlc_tx_rx_buff( sdla_t* card);
-static int process_chdlc_exception(sdla_t *card);
-static int process_global_exception(sdla_t *card);
-static int update_comms_stats(sdla_t* card,
- chdlc_private_area_t* chdlc_priv_area);
-static int configure_ip (sdla_t* card);
-static int unconfigure_ip (sdla_t* card);
-static void process_route(sdla_t *card);
-static void port_set_state (sdla_t *card, int);
-static int config_chdlc (sdla_t *card);
-static void disable_comm (sdla_t *card);
-
-static void trigger_chdlc_poll(struct net_device *dev);
-static void chdlc_poll(struct net_device *dev);
-static void chdlc_poll_delay (unsigned long dev_ptr);
-
-
-/* Miscellaneous asynchronous interface Functions */
-static int set_asy_config (sdla_t* card);
-static int asy_comm_enable (sdla_t* card);
-
-/* Interrupt handlers */
-static void wpc_isr (sdla_t* card);
-static void rx_intr (sdla_t* card);
-static void timer_intr(sdla_t *);
-
-/* Bottom half handlers */
-static void chdlc_work(struct net_device *dev);
-static int chdlc_work_cleanup(struct net_device *dev);
-static int bh_enqueue(struct net_device *dev, struct sk_buff *skb);
-
-/* Miscellaneous functions */
-static int chk_bcast_mcast_addr(sdla_t* card, struct net_device* dev,
- struct sk_buff *skb);
-static int reply_udp( unsigned char *data, unsigned int mbox_len );
-static int intr_test( sdla_t* card);
-static int udp_pkt_type( struct sk_buff *skb , sdla_t* card);
-static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area);
-static int process_udp_mgmt_pkt(sdla_t* card, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area);
-static unsigned short calc_checksum (char *, int);
-static void s508_lock (sdla_t *card, unsigned long *smp_flags);
-static void s508_unlock (sdla_t *card, unsigned long *smp_flags);
-
-
-static int Intr_test_counter;
-
-/* TTY Global Definitions */
-
-#define NR_PORTS 4
-#define WAN_TTY_MAJOR 226
-#define WAN_TTY_MINOR 0
-
-#define WAN_CARD(port) (tty_card_map[port])
-#define MIN_PORT 0
-#define MAX_PORT NR_PORTS-1
-
-#define CRC_LENGTH 2
-
-static int wanpipe_tty_init(sdla_t *card);
-static void wanpipe_tty_receive(sdla_t *, unsigned, unsigned int);
-static void wanpipe_tty_trigger_poll(sdla_t *card);
-
-static struct tty_driver serial_driver;
-static int tty_init_cnt=0;
-
-static struct serial_state rs_table[NR_PORTS];
-
-static char tty_driver_mode=WANOPT_TTY_SYNC;
-
-static char *opt_decode[] = {"NONE","CRTSCTS","XONXOFF-RX",
- "CRTSCTS XONXOFF-RX","XONXOFF-TX",
- "CRTSCTS XONXOFF-TX","CRTSCTS XONXOFF"};
-static char *p_decode[] = {"NONE","ODD","EVEN"};
-
-static void* tty_card_map[NR_PORTS] = {NULL,NULL,NULL,NULL};
-
-
-/****** Public Functions ****************************************************/
-
-/*============================================================================
- * Cisco HDLC protocol initialization routine.
- *
- * This routine is called by the main WANPIPE module during setup. At this
- * point adapter is completely initialized and firmware is running.
- * o read firmware version (to make sure it's alive)
- * o configure adapter
- * o initialize protocol-specific fields of the adapter data space.
- *
- * Return: 0 o.k.
- * < 0 failure.
- */
-int wpc_init (sdla_t* card, wandev_conf_t* conf)
-{
- unsigned char port_num;
- int err;
- unsigned long max_permitted_baud = 0;
- SHARED_MEMORY_INFO_STRUCT *flags;
-
- union
- {
- char str[80];
- } u;
- volatile CHDLC_MAILBOX_STRUCT* mb;
- CHDLC_MAILBOX_STRUCT* mb1;
- unsigned long timeout;
-
- /* Verify configuration ID */
- if (conf->config_id != WANCONFIG_CHDLC) {
- printk(KERN_INFO "%s: invalid configuration ID %u!\n",
- card->devname, conf->config_id);
- return -EINVAL;
- }
-
- /* Find out which Port to use */
- if ((conf->comm_port == WANOPT_PRI) || (conf->comm_port == WANOPT_SEC)){
- if (card->next){
-
- if (conf->comm_port != card->next->u.c.comm_port){
- card->u.c.comm_port = conf->comm_port;
- }else{
- printk(KERN_INFO "%s: ERROR - %s port used!\n",
- card->wandev.name, PORT(conf->comm_port));
- return -EINVAL;
- }
- }else{
- card->u.c.comm_port = conf->comm_port;
- }
- }else{
- printk(KERN_INFO "%s: ERROR - Invalid Port Selected!\n",
- card->wandev.name);
- return -EINVAL;
- }
-
-
- /* Initialize protocol-specific fields */
- if(card->hw.type != SDLA_S514){
-
- if (card->u.c.comm_port == WANOPT_PRI){
- card->mbox = (void *) card->hw.dpmbase;
- }else{
- card->mbox = (void *) card->hw.dpmbase +
- SEC_BASE_ADDR_MB_STRUCT - PRI_BASE_ADDR_MB_STRUCT;
- }
- }else{
- /* for a S514 adapter, set a pointer to the actual mailbox in the */
- /* allocated virtual memory area */
- if (card->u.c.comm_port == WANOPT_PRI){
- card->mbox = (void *) card->hw.dpmbase + PRI_BASE_ADDR_MB_STRUCT;
- }else{
- card->mbox = (void *) card->hw.dpmbase + SEC_BASE_ADDR_MB_STRUCT;
- }
- }
-
- mb = mb1 = card->mbox;
-
- if (!card->configured){
-
- /* The board will place an 'I' in the return code to indicate that it is
- ready to accept commands. We expect this to be completed in less
- than 1 second. */
-
- timeout = jiffies;
- while (mb->return_code != 'I') /* Wait 1s for board to initialize */
- if ((jiffies - timeout) > 1*HZ) break;
-
- if (mb->return_code != 'I') {
- printk(KERN_INFO
- "%s: Initialization not completed by adapter\n",
- card->devname);
- printk(KERN_INFO "Please contact Sangoma representative.\n");
- return -EIO;
- }
- }
-
- /* Read firmware version. Note that when adapter initializes, it
- * clears the mailbox, so it may appear that the first command was
- * executed successfully when in fact it was merely erased. To work
- * around this, we execute the first command twice.
- */
-
- if (chdlc_read_version(card, u.str))
- return -EIO;
-
- printk(KERN_INFO "%s: Running Cisco HDLC firmware v%s\n",
- card->devname, u.str);
-
- card->isr = &wpc_isr;
- card->poll = NULL;
- card->exec = NULL;
- card->wandev.update = &update;
- card->wandev.new_if = &new_if;
- card->wandev.del_if = NULL;
- card->wandev.udp_port = conf->udp_port;
- card->disable_comm = &disable_comm;
- card->wandev.new_if_cnt = 0;
-
- /* reset the number of times the 'update()' proc has been called */
- card->u.c.update_call_count = 0;
-
- card->wandev.ttl = conf->ttl;
- card->wandev.interface = conf->interface;
-
- if ((card->u.c.comm_port == WANOPT_SEC && conf->interface == WANOPT_V35)&&
- card->hw.type != SDLA_S514){
- printk(KERN_INFO "%s: ERROR - V35 Interface not supported on S508 %s port \n",
- card->devname, PORT(card->u.c.comm_port));
- return -EIO;
- }
-
- card->wandev.clocking = conf->clocking;
-
- port_num = card->u.c.comm_port;
-
- /* in API mode, we can configure for "receive only" buffering */
- if(card->hw.type == SDLA_S514) {
- card->u.c.receive_only = conf->receive_only;
- if(conf->receive_only) {
- printk(KERN_INFO
- "%s: Configured for 'receive only' mode\n",
- card->devname);
- }
- }
-
- /* Setup Port Bps */
-
- if(card->wandev.clocking) {
- if((port_num == WANOPT_PRI) || card->u.c.receive_only) {
- /* For Primary Port 0 */
- max_permitted_baud =
- (card->hw.type == SDLA_S514) ?
- PRI_MAX_BAUD_RATE_S514 :
- PRI_MAX_BAUD_RATE_S508;
-
- }else if(port_num == WANOPT_SEC) {
- /* For Secondary Port 1 */
- max_permitted_baud =
- (card->hw.type == SDLA_S514) ?
- SEC_MAX_BAUD_RATE_S514 :
- SEC_MAX_BAUD_RATE_S508;
- }
-
- if(conf->bps > max_permitted_baud) {
- conf->bps = max_permitted_baud;
- printk(KERN_INFO "%s: Baud too high!\n",
- card->wandev.name);
- printk(KERN_INFO "%s: Baud rate set to %lu bps\n",
- card->wandev.name, max_permitted_baud);
- }
- card->wandev.bps = conf->bps;
- }else{
- card->wandev.bps = 0;
- }
-
- /* Setup the Port MTU */
- if((port_num == WANOPT_PRI) || card->u.c.receive_only) {
-
- /* For Primary Port 0 */
- card->wandev.mtu =
- (conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
- min_t(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
- CHDLC_DFLT_DATA_LEN;
- } else if(port_num == WANOPT_SEC) {
- /* For Secondary Port 1 */
- card->wandev.mtu =
- (conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
- min_t(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
- CHDLC_DFLT_DATA_LEN;
- }
-
- /* Set up the interrupt status area */
- /* Read the CHDLC Configuration and obtain:
- * Ptr to shared memory infor struct
- * Use this pointer to calculate the value of card->u.c.flags !
- */
- mb1->buffer_length = 0;
- mb1->command = READ_CHDLC_CONFIGURATION;
- err = sdla_exec(mb1) ? mb1->return_code : CMD_TIMEOUT;
- if(err != COMMAND_OK) {
- if(card->hw.type != SDLA_S514)
- enable_irq(card->hw.irq);
-
- chdlc_error(card, err, mb1);
- return -EIO;
- }
-
- if(card->hw.type == SDLA_S514){
- card->u.c.flags = (void *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb1->data)->
- ptr_shared_mem_info_struct));
- }else{
- card->u.c.flags = (void *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb1->data)->
- ptr_shared_mem_info_struct % SDLA_WINDOWSIZE));
- }
-
- flags = card->u.c.flags;
-
- /* This is for the ports link state */
- card->wandev.state = WAN_DUALPORT;
- card->u.c.state = WAN_DISCONNECTED;
-
-
- if (!card->wandev.piggyback){
- int err;
-
- /* Perform interrupt testing */
- err = intr_test(card);
-
- if(err || (Intr_test_counter < MAX_INTR_TEST_COUNTER)) {
- printk(KERN_INFO "%s: Interrupt test failed (%i)\n",
- card->devname, Intr_test_counter);
- printk(KERN_INFO "%s: Please choose another interrupt\n",
- card->devname);
- return -EIO;
- }
-
- printk(KERN_INFO "%s: Interrupt test passed (%i)\n",
- card->devname, Intr_test_counter);
- card->configured = 1;
- }
-
- if ((card->tty_opt=conf->tty) == WANOPT_YES){
- int err;
- card->tty_minor = conf->tty_minor;
-
- /* On ASYNC connections internal clocking
- * is mandatory */
- if ((card->u.c.async_mode = conf->tty_mode)){
- card->wandev.clocking = 1;
- }
- err=wanpipe_tty_init(card);
- if (err){
- return err;
- }
- }else{
-
-
- if (chdlc_set_intr_mode(card, APP_INT_ON_TIMER)){
- printk (KERN_INFO "%s: "
- "Failed to set interrupt triggers!\n",
- card->devname);
- return -EIO;
- }
-
- /* Mask the Timer interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TIMER;
- }
-
- /* If we are using CHDLC in backup mode, this flag will
- * indicate not to look for IP addresses in config_chdlc()*/
- card->u.c.backup = conf->backup;
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-/******* WAN Device Driver Entry Points *************************************/
-
-/*============================================================================
- * Update device status & statistics
- * This procedure is called when updating the PROC file system and returns
- * various communications statistics. These statistics are accumulated from 3
- * different locations:
- * 1) The 'if_stats' recorded for the device.
- * 2) Communication error statistics on the adapter.
- * 3) CHDLC operational statistics on the adapter.
- * The board level statistics are read during a timer interrupt. Note that we
- * read the error and operational statistics during consecitive timer ticks so
- * as to minimize the time that we are inside the interrupt handler.
- *
- */
-static int update(struct wan_device* wandev)
-{
- sdla_t* card = wandev->private;
- struct net_device* dev;
- volatile chdlc_private_area_t* chdlc_priv_area;
- SHARED_MEMORY_INFO_STRUCT *flags;
- unsigned long timeout;
-
- /* sanity checks */
- if((wandev == NULL) || (wandev->private == NULL))
- return -EFAULT;
-
- if(wandev->state == WAN_UNCONFIGURED)
- return -ENODEV;
-
- /* more sanity checks */
- if(!card->u.c.flags)
- return -ENODEV;
-
- if(test_bit(PERI_CRIT, (void*)&card->wandev.critical))
- return -EAGAIN;
-
- if((dev=card->wandev.dev) == NULL)
- return -ENODEV;
-
- if((chdlc_priv_area=dev->priv) == NULL)
- return -ENODEV;
-
- flags = card->u.c.flags;
- if(chdlc_priv_area->update_comms_stats){
- return -EAGAIN;
- }
-
- /* we will need 2 timer interrupts to complete the */
- /* reading of the statistics */
- chdlc_priv_area->update_comms_stats = 2;
- flags->interrupt_info_struct.interrupt_permission |= APP_INT_ON_TIMER;
- chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE;
-
- /* wait a maximum of 1 second for the statistics to be updated */
- timeout = jiffies;
- for(;;) {
- if(chdlc_priv_area->update_comms_stats == 0)
- break;
- if ((jiffies - timeout) > (1 * HZ)){
- chdlc_priv_area->update_comms_stats = 0;
- chdlc_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_UPDATE;
- return -EAGAIN;
- }
- }
-
- return 0;
-}
-
-
-/*============================================================================
- * Create new logical channel.
- * This routine is called by the router when ROUTER_IFNEW IOCTL is being
- * handled.
- * o parse media- and hardware-specific configuration
- * o make sure that a new channel can be created
- * o allocate resources, if necessary
- * o prepare network device structure for registaration.
- *
- * Return: 0 o.k.
- * < 0 failure (channel will not be created)
- */
-static int new_if(struct wan_device* wandev, struct net_device* dev,
- wanif_conf_t* conf)
-{
- sdla_t* card = wandev->private;
- chdlc_private_area_t* chdlc_priv_area;
-
-
- printk(KERN_INFO "%s: Configuring Interface: %s\n",
- card->devname, conf->name);
-
- if ((conf->name[0] == '\0') || (strlen(conf->name) > WAN_IFNAME_SZ)) {
- printk(KERN_INFO "%s: Invalid interface name!\n",
- card->devname);
- return -EINVAL;
- }
-
- /* allocate and initialize private data */
- chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
-
- if(chdlc_priv_area == NULL)
- return -ENOMEM;
-
- memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t));
-
- chdlc_priv_area->card = card;
- chdlc_priv_area->common.sk = NULL;
- chdlc_priv_area->common.func = NULL;
-
- /* initialize data */
- strcpy(card->u.c.if_name, conf->name);
-
- if(card->wandev.new_if_cnt > 0) {
- kfree(chdlc_priv_area);
- return -EEXIST;
- }
-
- card->wandev.new_if_cnt++;
-
- chdlc_priv_area->TracingEnabled = 0;
- chdlc_priv_area->route_status = NO_ROUTE;
- chdlc_priv_area->route_removed = 0;
-
- card->u.c.async_mode = conf->async_mode;
-
- /* setup for asynchronous mode */
- if(conf->async_mode) {
- printk(KERN_INFO "%s: Configuring for asynchronous mode\n",
- wandev->name);
-
- if(card->u.c.comm_port == WANOPT_PRI) {
- printk(KERN_INFO
- "%s:Asynchronous mode on secondary port only\n",
- wandev->name);
- kfree(chdlc_priv_area);
- return -EINVAL;
- }
-
- if(strcmp(conf->usedby, "WANPIPE") == 0) {
- printk(KERN_INFO
- "%s: Running in WANIPE Async Mode\n", wandev->name);
- card->u.c.usedby = WANPIPE;
- }else{
- card->u.c.usedby = API;
- }
-
- if(!card->wandev.clocking) {
- printk(KERN_INFO
- "%s: Asynch. clocking must be 'Internal'\n",
- wandev->name);
- kfree(chdlc_priv_area);
- return -EINVAL;
- }
-
- if((card->wandev.bps < MIN_ASY_BAUD_RATE) ||
- (card->wandev.bps > MAX_ASY_BAUD_RATE)) {
- printk(KERN_INFO "%s: Selected baud rate is invalid.\n",
- wandev->name);
- printk(KERN_INFO "Must be between %u and %u bps.\n",
- MIN_ASY_BAUD_RATE, MAX_ASY_BAUD_RATE);
- kfree(chdlc_priv_area);
- return -EINVAL;
- }
-
- card->u.c.api_options = 0;
- if (conf->asy_data_trans == WANOPT_YES) {
- card->u.c.api_options |= ASY_RX_DATA_TRANSPARENT;
- }
-
- card->u.c.protocol_options = 0;
- if (conf->rts_hs_for_receive == WANOPT_YES) {
- card->u.c.protocol_options |= ASY_RTS_HS_FOR_RX;
- }
- if (conf->xon_xoff_hs_for_receive == WANOPT_YES) {
- card->u.c.protocol_options |= ASY_XON_XOFF_HS_FOR_RX;
- }
- if (conf->xon_xoff_hs_for_transmit == WANOPT_YES) {
- card->u.c.protocol_options |= ASY_XON_XOFF_HS_FOR_TX;
- }
- if (conf->dcd_hs_for_transmit == WANOPT_YES) {
- card->u.c.protocol_options |= ASY_DCD_HS_FOR_TX;
- }
- if (conf->cts_hs_for_transmit == WANOPT_YES) {
- card->u.c.protocol_options |= ASY_CTS_HS_FOR_TX;
- }
-
- card->u.c.tx_bits_per_char = conf->tx_bits_per_char;
- card->u.c.rx_bits_per_char = conf->rx_bits_per_char;
- card->u.c.stop_bits = conf->stop_bits;
- card->u.c.parity = conf->parity;
- card->u.c.break_timer = conf->break_timer;
- card->u.c.inter_char_timer = conf->inter_char_timer;
- card->u.c.rx_complete_length = conf->rx_complete_length;
- card->u.c.xon_char = conf->xon_char;
-
- } else { /* setup for synchronous mode */
-
- card->u.c.protocol_options = 0;
- if (conf->ignore_dcd == WANOPT_YES){
- card->u.c.protocol_options |= IGNORE_DCD_FOR_LINK_STAT;
- }
- if (conf->ignore_cts == WANOPT_YES){
- card->u.c.protocol_options |= IGNORE_CTS_FOR_LINK_STAT;
- }
-
- if (conf->ignore_keepalive == WANOPT_YES) {
- card->u.c.protocol_options |=
- IGNORE_KPALV_FOR_LINK_STAT;
- card->u.c.kpalv_tx = MIN_Tx_KPALV_TIMER;
- card->u.c.kpalv_rx = MIN_Rx_KPALV_TIMER;
- card->u.c.kpalv_err = MIN_KPALV_ERR_TOL;
-
- } else { /* Do not ignore keepalives */
- card->u.c.kpalv_tx =
- ((conf->keepalive_tx_tmr - MIN_Tx_KPALV_TIMER)
- >= 0) ?
- min_t(unsigned int, conf->keepalive_tx_tmr,MAX_Tx_KPALV_TIMER) :
- DEFAULT_Tx_KPALV_TIMER;
-
- card->u.c.kpalv_rx =
- ((conf->keepalive_rx_tmr - MIN_Rx_KPALV_TIMER)
- >= 0) ?
- min_t(unsigned int, conf->keepalive_rx_tmr,MAX_Rx_KPALV_TIMER) :
- DEFAULT_Rx_KPALV_TIMER;
-
- card->u.c.kpalv_err =
- ((conf->keepalive_err_margin-MIN_KPALV_ERR_TOL)
- >= 0) ?
- min_t(unsigned int, conf->keepalive_err_margin,
- MAX_KPALV_ERR_TOL) :
- DEFAULT_KPALV_ERR_TOL;
- }
-
- /* Setup slarp timer to control delay between slarps */
- card->u.c.slarp_timer =
- ((conf->slarp_timer - MIN_SLARP_REQ_TIMER) >= 0) ?
- min_t(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
- DEFAULT_SLARP_REQ_TIMER;
-
- if (conf->hdlc_streaming == WANOPT_YES) {
- printk(KERN_INFO "%s: Enabling HDLC STREAMING Mode\n",
- wandev->name);
- card->u.c.protocol_options = HDLC_STREAMING_MODE;
- }
-
- if ((chdlc_priv_area->true_if_encoding = conf->true_if_encoding) == WANOPT_YES){
- printk(KERN_INFO
- "%s: Enabling, true interface type encoding.\n",
- card->devname);
- }
-
- /* Setup wanpipe as a router (WANPIPE) or as an API */
- if( strcmp(conf->usedby, "WANPIPE") == 0) {
-
- printk(KERN_INFO "%s: Running in WANPIPE mode!\n",
- wandev->name);
- card->u.c.usedby = WANPIPE;
-
- /* Option to bring down the interface when
- * the link goes down */
- if (conf->if_down){
- set_bit(DYN_OPT_ON,&chdlc_priv_area->interface_down);
- printk(KERN_INFO
- "%s: Dynamic interface configuration enabled\n",
- card->devname);
- }
-
- } else if( strcmp(conf->usedby, "API") == 0) {
- card->u.c.usedby = API;
- printk(KERN_INFO "%s: Running in API mode !\n",
- wandev->name);
- }
- }
-
- /* Tells us that if this interface is a
- * gateway or not */
- if ((chdlc_priv_area->gateway = conf->gateway) == WANOPT_YES){
- printk(KERN_INFO "%s: Interface %s is set as a gateway.\n",
- card->devname,card->u.c.if_name);
- }
-
- /* Get Multicast Information */
- chdlc_priv_area->mc = conf->mc;
-
- /* prepare network device data space for registration */
- strcpy(dev->name,card->u.c.if_name);
-
- dev->init = &if_init;
- dev->priv = chdlc_priv_area;
-
- /* Initialize the polling work routine */
- INIT_WORK(&chdlc_priv_area->poll_work, (void*)(void*)chdlc_poll, dev);
-
- /* Initialize the polling delay timer */
- init_timer(&chdlc_priv_area->poll_delay_timer);
- chdlc_priv_area->poll_delay_timer.data = (unsigned long)dev;
- chdlc_priv_area->poll_delay_timer.function = chdlc_poll_delay;
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-
-/****** Network Device Interface ********************************************/
-
-/*============================================================================
- * Initialize Linux network interface.
- *
- * This routine is called only once for each interface, during Linux network
- * interface registration. Returning anything but zero will fail interface
- * registration.
- */
-static int if_init(struct net_device* dev)
-{
- chdlc_private_area_t* chdlc_priv_area = dev->priv;
- sdla_t* card = chdlc_priv_area->card;
- struct wan_device* wandev = &card->wandev;
-
- /* Initialize device driver entry points */
- dev->open = &if_open;
- dev->stop = &if_close;
- dev->hard_header = &if_header;
- dev->rebuild_header = &if_rebuild_hdr;
- dev->hard_start_xmit = &if_send;
- dev->get_stats = &if_stats;
- dev->tx_timeout = &if_tx_timeout;
- dev->watchdog_timeo = TX_TIMEOUT;
-
- /* Initialize media-specific parameters */
- dev->flags |= IFF_POINTOPOINT;
- dev->flags |= IFF_NOARP;
-
- /* Enable Mulitcasting if user selected */
- if (chdlc_priv_area->mc == WANOPT_YES){
- dev->flags |= IFF_MULTICAST;
- }
-
- if (chdlc_priv_area->true_if_encoding){
- dev->type = ARPHRD_HDLC; /* This breaks the tcpdump */
- }else{
- dev->type = ARPHRD_PPP;
- }
-
- dev->mtu = card->wandev.mtu;
- /* for API usage, add the API header size to the requested MTU size */
- if(card->u.c.usedby == API) {
- dev->mtu += sizeof(api_tx_hdr_t);
- }
-
- dev->hard_header_len = CHDLC_HDR_LEN;
-
- /* Initialize hardware parameters */
- dev->irq = wandev->irq;
- dev->dma = wandev->dma;
- dev->base_addr = wandev->ioport;
- dev->mem_start = wandev->maddr;
- dev->mem_end = wandev->maddr + wandev->msize - 1;
-
- /* Set transmit buffer queue length
- * If too low packets will not be retransmitted
- * by stack.
- */
- dev->tx_queue_len = 100;
- SET_MODULE_OWNER(dev);
-
- return 0;
-}
-
-/*============================================================================
- * Open network interface.
- * o enable communications and interrupts.
- * o prevent module from unloading by incrementing use count
- *
- * Return 0 if O.k. or errno.
- */
-static int if_open(struct net_device* dev)
-{
- chdlc_private_area_t* chdlc_priv_area = dev->priv;
- sdla_t* card = chdlc_priv_area->card;
- struct timeval tv;
- int err = 0;
-
- /* Only one open per interface is allowed */
-
- if (netif_running(dev))
- return -EBUSY;
-
- /* Initialize the work queue entry */
- chdlc_priv_area->tq_working=0;
-
- INIT_WORK(&chdlc_priv_area->common.wanpipe_work,
- (void *)(void *)chdlc_work, dev);
-
- /* Allocate and initialize BH circular buffer */
- /* Add 1 to MAX_BH_BUFF so we don't have test with (MAX_BH_BUFF-1) */
- chdlc_priv_area->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
- memset(chdlc_priv_area->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1)));
- atomic_set(&chdlc_priv_area->bh_buff_used, 0);
-
- do_gettimeofday(&tv);
- chdlc_priv_area->router_start_time = tv.tv_sec;
-
- netif_start_queue(dev);
-
- wanpipe_open(card);
-
- /* TTY is configured during wanpipe_set_termios
- * call, not here */
- if (card->tty_opt)
- return err;
-
- set_bit(0,&chdlc_priv_area->config_chdlc);
- chdlc_priv_area->config_chdlc_timeout=jiffies;
-
- /* Start the CHDLC configuration after 1sec delay.
- * This will give the interface initilization time
- * to finish its configuration */
- mod_timer(&chdlc_priv_area->poll_delay_timer, jiffies + HZ);
- return err;
-}
-
-/*============================================================================
- * Close network interface.
- * o if this is the last close, then disable communications and interrupts.
- * o reset flags.
- */
-static int if_close(struct net_device* dev)
-{
- chdlc_private_area_t* chdlc_priv_area = dev->priv;
- sdla_t* card = chdlc_priv_area->card;
-
- if (chdlc_priv_area->bh_head){
- int i;
- struct sk_buff *skb;
-
- for (i=0; i<(MAX_BH_BUFF+1); i++){
- skb = ((bh_data_t *)&chdlc_priv_area->bh_head[i])->skb;
- if (skb != NULL){
- dev_kfree_skb_any(skb);
- }
- }
- kfree(chdlc_priv_area->bh_head);
- chdlc_priv_area->bh_head=NULL;
- }
-
- netif_stop_queue(dev);
- wanpipe_close(card);
- del_timer(&chdlc_priv_area->poll_delay_timer);
- return 0;
-}
-
-static void disable_comm (sdla_t *card)
-{
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
-
- if (card->u.c.comm_enabled){
- chdlc_disable_comm_shutdown (card);
- }else{
- flags->interrupt_info_struct.interrupt_permission = 0;
- }
-
- if (!tty_init_cnt)
- return;
-
- if (card->tty_opt){
- struct serial_state * state;
- if (!(--tty_init_cnt)){
- int e1;
- serial_driver.refcount=0;
-
- if ((e1 = tty_unregister_driver(&serial_driver)))
- printk("SERIAL: failed to unregister serial driver (%d)\n",
- e1);
- printk(KERN_INFO "%s: Unregistering TTY Driver, Major %i\n",
- card->devname,WAN_TTY_MAJOR);
- }
- card->tty=NULL;
- tty_card_map[card->tty_minor]=NULL;
- state = &rs_table[card->tty_minor];
- memset(state, 0, sizeof(*state));
- }
- return;
-}
-
-
-/*============================================================================
- * Build media header.
- *
- * The trick here is to put packet type (Ethertype) into 'protocol' field of
- * the socket buffer, so that we don't forget it. If packet type is not
- * supported, set skb->protocol to 0 and discard packet later.
- *
- * Return: media header length.
- */
-static int if_header(struct sk_buff* skb, struct net_device* dev,
- unsigned short type, void* daddr, void* saddr,
- unsigned len)
-{
- skb->protocol = htons(type);
-
- return CHDLC_HDR_LEN;
-}
-
-
-/*============================================================================
- * Handle transmit timeout event from netif watchdog
- */
-static void if_tx_timeout(struct net_device *dev)
-{
- chdlc_private_area_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
- /* If our device stays busy for at least 5 seconds then we will
- * kick start the device by making dev->tbusy = 0. We expect
- * that our device never stays busy more than 5 seconds. So this
- * is only used as a last resort.
- */
-
- ++card->wandev.stats.collisions;
-
- printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name);
- netif_wake_queue (dev);
-}
-
-
-
-/*============================================================================
- * Re-build media header.
- *
- * Return: 1 physical address resolved.
- * 0 physical address not resolved
- */
-static int if_rebuild_hdr (struct sk_buff *skb)
-{
- return 1;
-}
-
-
-/*============================================================================
- * Send a packet on a network interface.
- * o set tbusy flag (marks start of the transmission) to block a timer-based
- * transmit from overlapping.
- * o check link state. If link is not up, then drop the packet.
- * o execute adapter send command.
- * o free socket buffer
- *
- * Return: 0 complete (socket buffer must be freed)
- * non-0 packet may be re-transmitted (tbusy must be set)
- *
- * Notes:
- * 1. This routine is called either by the protocol stack or by the "net
- * bottom half" (with interrupts enabled).
- * 2. Setting tbusy flag will inhibit further transmit requests from the
- * protocol stack and can be used for flow control with protocol layer.
- */
-static int if_send(struct sk_buff* skb, struct net_device* dev)
-{
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
- sdla_t *card = chdlc_priv_area->card;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- INTERRUPT_INFORMATION_STRUCT *chdlc_int = &flags->interrupt_info_struct;
- int udp_type = 0;
- unsigned long smp_flags;
- int err=0;
-
- netif_stop_queue(dev);
-
- if (skb == NULL){
- /* If we get here, some higher layer thinks we've missed an
- * tx-done interrupt.
- */
- printk(KERN_INFO "%s: interface %s got kicked!\n",
- card->devname, dev->name);
-
- netif_wake_queue(dev);
- return 0;
- }
-
- if (ntohs(skb->protocol) != htons(PVC_PROT)){
-
- /* check the udp packet type */
-
- udp_type = udp_pkt_type(skb, card);
-
- if (udp_type == UDP_CPIPE_TYPE){
- if(store_udp_mgmt_pkt(UDP_PKT_FRM_STACK, card, skb, dev,
- chdlc_priv_area)){
- chdlc_int->interrupt_permission |=
- APP_INT_ON_TIMER;
- }
- netif_start_queue(dev);
- return 0;
- }
-
- /* check to see if the source IP address is a broadcast or */
- /* multicast IP address */
- if(chk_bcast_mcast_addr(card, dev, skb)){
- ++card->wandev.stats.tx_dropped;
- dev_kfree_skb_any(skb);
- netif_start_queue(dev);
- return 0;
- }
- }
-
- /* Lock the 508 Card: SMP is supported */
- if(card->hw.type != SDLA_S514){
- s508_lock(card,&smp_flags);
- }
-
- if(test_and_set_bit(SEND_CRIT, (void*)&card->wandev.critical)) {
-
- printk(KERN_INFO "%s: Critical in if_send: %lx\n",
- card->wandev.name,card->wandev.critical);
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
- goto if_send_exit_crit;
- }
-
- if(card->u.c.state != WAN_CONNECTED){
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
-
- }else if(!skb->protocol){
- ++card->wandev.stats.tx_errors;
- netif_start_queue(dev);
-
- }else {
- void* data = skb->data;
- unsigned len = skb->len;
- unsigned char attr;
-
- /* If it's an API packet pull off the API
- * header. Also check that the packet size
- * is larger than the API header
- */
- if (card->u.c.usedby == API){
- api_tx_hdr_t* api_tx_hdr;
-
- /* discard the frame if we are configured for */
- /* 'receive only' mode or if there is no data */
- if (card->u.c.receive_only ||
- (len <= sizeof(api_tx_hdr_t))) {
-
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
- goto if_send_exit_crit;
- }
-
- api_tx_hdr = (api_tx_hdr_t *)data;
- attr = api_tx_hdr->attr;
- data += sizeof(api_tx_hdr_t);
- len -= sizeof(api_tx_hdr_t);
- }
-
- if(chdlc_send(card, data, len)) {
- netif_stop_queue(dev);
- }else{
- ++card->wandev.stats.tx_packets;
- card->wandev.stats.tx_bytes += len;
-
- netif_start_queue(dev);
-
- dev->trans_start = jiffies;
- }
- }
-
-if_send_exit_crit:
-
- if (!(err=netif_queue_stopped(dev))) {
- dev_kfree_skb_any(skb);
- }else{
- chdlc_priv_area->tick_counter = jiffies;
- chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME;
- }
-
- clear_bit(SEND_CRIT, (void*)&card->wandev.critical);
- if(card->hw.type != SDLA_S514){
- s508_unlock(card,&smp_flags);
- }
-
- return err;
-}
-
-
-/*============================================================================
- * Check to see if the packet to be transmitted contains a broadcast or
- * multicast source IP address.
- */
-
-static int chk_bcast_mcast_addr(sdla_t *card, struct net_device* dev,
- struct sk_buff *skb)
-{
- u32 src_ip_addr;
- u32 broadcast_ip_addr = 0;
- struct in_device *in_dev;
-
- /* read the IP source address from the outgoing packet */
- src_ip_addr = *(u32 *)(skb->data + 12);
-
- /* read the IP broadcast address for the device */
- in_dev = dev->ip_ptr;
- if(in_dev != NULL) {
- struct in_ifaddr *ifa= in_dev->ifa_list;
- if(ifa != NULL)
- broadcast_ip_addr = ifa->ifa_broadcast;
- else
- return 0;
- }
-
- /* check if the IP Source Address is a Broadcast address */
- if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) {
- printk(KERN_INFO "%s: Broadcast Source Address silently discarded\n",
- card->devname);
- return 1;
- }
-
- /* check if the IP Source Address is a Multicast address */
- if((ntohl(src_ip_addr) >= 0xE0000001) &&
- (ntohl(src_ip_addr) <= 0xFFFFFFFE)) {
- printk(KERN_INFO "%s: Multicast Source Address silently discarded\n",
- card->devname);
- return 1;
- }
-
- return 0;
-}
-
-
-/*============================================================================
- * Reply to UDP Management system.
- * Return length of reply.
- */
-static int reply_udp( unsigned char *data, unsigned int mbox_len )
-{
-
- unsigned short len, udp_length, temp, ip_length;
- unsigned long ip_temp;
- int even_bound = 0;
- chdlc_udp_pkt_t *c_udp_pkt = (chdlc_udp_pkt_t *)data;
-
- /* Set length of packet */
- len = sizeof(ip_pkt_t)+
- sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- sizeof(trace_info_t)+
- mbox_len;
-
- /* fill in UDP reply */
- c_udp_pkt->wp_mgmt.request_reply = UDPMGMT_REPLY;
-
- /* fill in UDP length */
- udp_length = sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- sizeof(trace_info_t)+
- mbox_len;
-
- /* put it on an even boundary */
- if ( udp_length & 0x0001 ) {
- udp_length += 1;
- len += 1;
- even_bound = 1;
- }
-
- temp = (udp_length<<8)|(udp_length>>8);
- c_udp_pkt->udp_pkt.udp_length = temp;
-
- /* swap UDP ports */
- temp = c_udp_pkt->udp_pkt.udp_src_port;
- c_udp_pkt->udp_pkt.udp_src_port =
- c_udp_pkt->udp_pkt.udp_dst_port;
- c_udp_pkt->udp_pkt.udp_dst_port = temp;
-
- /* add UDP pseudo header */
- temp = 0x1100;
- *((unsigned short *)(c_udp_pkt->data+mbox_len+even_bound)) = temp;
- temp = (udp_length<<8)|(udp_length>>8);
- *((unsigned short *)(c_udp_pkt->data+mbox_len+even_bound+2)) = temp;
-
-
- /* calculate UDP checksum */
- c_udp_pkt->udp_pkt.udp_checksum = 0;
- c_udp_pkt->udp_pkt.udp_checksum = calc_checksum(&data[UDP_OFFSET],udp_length+UDP_OFFSET);
-
- /* fill in IP length */
- ip_length = len;
- temp = (ip_length<<8)|(ip_length>>8);
- c_udp_pkt->ip_pkt.total_length = temp;
-
- /* swap IP addresses */
- ip_temp = c_udp_pkt->ip_pkt.ip_src_address;
- c_udp_pkt->ip_pkt.ip_src_address = c_udp_pkt->ip_pkt.ip_dst_address;
- c_udp_pkt->ip_pkt.ip_dst_address = ip_temp;
-
- /* fill in IP checksum */
- c_udp_pkt->ip_pkt.hdr_checksum = 0;
- c_udp_pkt->ip_pkt.hdr_checksum = calc_checksum(data,sizeof(ip_pkt_t));
-
- return len;
-
-} /* reply_udp */
-
-unsigned short calc_checksum (char *data, int len)
-{
- unsigned short temp;
- unsigned long sum=0;
- int i;
-
- for( i = 0; i <len; i+=2 ) {
- memcpy(&temp,&data[i],2);
- sum += (unsigned long)temp;
- }
-
- while (sum >> 16 ) {
- sum = (sum & 0xffffUL) + (sum >> 16);
- }
-
- temp = (unsigned short)sum;
- temp = ~temp;
-
- if( temp == 0 )
- temp = 0xffff;
-
- return temp;
-}
-
-
-/*============================================================================
- * Get ethernet-style interface statistics.
- * Return a pointer to struct enet_statistics.
- */
-static struct net_device_stats* if_stats(struct net_device* dev)
-{
- sdla_t *my_card;
- chdlc_private_area_t* chdlc_priv_area;
-
- if ((chdlc_priv_area=dev->priv) == NULL)
- return NULL;
-
- my_card = chdlc_priv_area->card;
- return &my_card->wandev.stats;
-}
-
-
-/****** Cisco HDLC Firmware Interface Functions *******************************/
-
-/*============================================================================
- * Read firmware code version.
- * Put code version as ASCII string in str.
- */
-static int chdlc_read_version (sdla_t* card, char* str)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int len;
- char err;
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CODE_VERSION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if(err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- }
- else if (str) { /* is not null */
- len = mb->buffer_length;
- memcpy(str, mb->data, len);
- str[len] = '\0';
- }
- return (err);
-}
-
-/*-----------------------------------------------------------------------------
- * Configure CHDLC firmware.
- */
-static int chdlc_configure (sdla_t* card, void* data)
-{
- int err;
- CHDLC_MAILBOX_STRUCT *mailbox = card->mbox;
- int data_length = sizeof(CHDLC_CONFIGURATION_STRUCT);
-
- mailbox->buffer_length = data_length;
- memcpy(mailbox->data, data, data_length);
- mailbox->command = SET_CHDLC_CONFIGURATION;
- err = sdla_exec(mailbox) ? mailbox->return_code : CMD_TIMEOUT;
-
- if (err != COMMAND_OK) chdlc_error (card, err, mailbox);
-
- return err;
-}
-
-
-/*============================================================================
- * Set interrupt mode -- HDLC Version.
- */
-
-static int chdlc_set_intr_mode (sdla_t* card, unsigned mode)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- CHDLC_INT_TRIGGERS_STRUCT* int_data =
- (CHDLC_INT_TRIGGERS_STRUCT *)mb->data;
- int err;
-
- int_data->CHDLC_interrupt_triggers = mode;
- int_data->IRQ = card->hw.irq;
- int_data->interrupt_timer = 1;
-
- mb->buffer_length = sizeof(CHDLC_INT_TRIGGERS_STRUCT);
- mb->command = SET_CHDLC_INTERRUPT_TRIGGERS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error (card, err, mb);
- return err;
-}
-
-
-/*===========================================================
- * chdlc_disable_comm_shutdown
- *
- * Shutdown() disables the communications. We must
- * have a sparate functions, because we must not
- * call chdlc_error() hander since the private
- * area has already been replaced */
-
-static int chdlc_disable_comm_shutdown (sdla_t *card)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- CHDLC_INT_TRIGGERS_STRUCT* int_data =
- (CHDLC_INT_TRIGGERS_STRUCT *)mb->data;
- int err;
-
- /* Disable Interrutps */
- int_data->CHDLC_interrupt_triggers = 0;
- int_data->IRQ = card->hw.irq;
- int_data->interrupt_timer = 1;
-
- mb->buffer_length = sizeof(CHDLC_INT_TRIGGERS_STRUCT);
- mb->command = SET_CHDLC_INTERRUPT_TRIGGERS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- /* Disable Communications */
-
- if (card->u.c.async_mode) {
- mb->command = DISABLE_ASY_COMMUNICATIONS;
- }else{
- mb->command = DISABLE_CHDLC_COMMUNICATIONS;
- }
-
- mb->buffer_length = 0;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- card->u.c.comm_enabled = 0;
-
- return 0;
-}
-
-/*============================================================================
- * Enable communications.
- */
-
-static int chdlc_comm_enable (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = ENABLE_CHDLC_COMMUNICATIONS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card, err, mb);
- else
- card->u.c.comm_enabled = 1;
-
- return err;
-}
-
-/*============================================================================
- * Read communication error statistics.
- */
-static int chdlc_read_comm_err_stats (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = READ_COMMS_ERROR_STATS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card,err,mb);
- return err;
-}
-
-
-/*============================================================================
- * Read CHDLC operational statistics.
- */
-static int chdlc_read_op_stats (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_OPERATIONAL_STATS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card,err,mb);
- return err;
-}
-
-
-/*============================================================================
- * Update communications error and general packet statistics.
- */
-static int update_comms_stats(sdla_t* card,
- chdlc_private_area_t* chdlc_priv_area)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- COMMS_ERROR_STATS_STRUCT* err_stats;
- CHDLC_OPERATIONAL_STATS_STRUCT *op_stats;
-
- /* on the first timer interrupt, read the comms error statistics */
- if(chdlc_priv_area->update_comms_stats == 2) {
- if(chdlc_read_comm_err_stats(card))
- return 1;
- err_stats = (COMMS_ERROR_STATS_STRUCT *)mb->data;
- card->wandev.stats.rx_over_errors =
- err_stats->Rx_overrun_err_count;
- card->wandev.stats.rx_crc_errors =
- err_stats->CRC_err_count;
- card->wandev.stats.rx_frame_errors =
- err_stats->Rx_abort_count;
- card->wandev.stats.rx_fifo_errors =
- err_stats->Rx_dis_pri_bfrs_full_count;
- card->wandev.stats.rx_missed_errors =
- card->wandev.stats.rx_fifo_errors;
- card->wandev.stats.tx_aborted_errors =
- err_stats->sec_Tx_abort_count;
- }
-
- /* on the second timer interrupt, read the operational statistics */
- else {
- if(chdlc_read_op_stats(card))
- return 1;
- op_stats = (CHDLC_OPERATIONAL_STATS_STRUCT *)mb->data;
- card->wandev.stats.rx_length_errors =
- (op_stats->Rx_Data_discard_short_count +
- op_stats->Rx_Data_discard_long_count);
- }
-
- return 0;
-}
-
-/*============================================================================
- * Send packet.
- * Return: 0 - o.k.
- * 1 - no transmit buffers available
- */
-static int chdlc_send (sdla_t* card, void* data, unsigned len)
-{
- CHDLC_DATA_TX_STATUS_EL_STRUCT *txbuf = card->u.c.txbuf;
-
- if (txbuf->opp_flag)
- return 1;
-
- sdla_poke(&card->hw, txbuf->ptr_data_bfr, data, len);
-
- txbuf->frame_length = len;
- txbuf->opp_flag = 1; /* start transmission */
-
- /* Update transmit buffer control fields */
- card->u.c.txbuf = ++txbuf;
-
- if ((void*)txbuf > card->u.c.txbuf_last)
- card->u.c.txbuf = card->u.c.txbuf_base;
-
- return 0;
-}
-
-/****** Firmware Error Handler **********************************************/
-
-/*============================================================================
- * Firmware error handler.
- * This routine is called whenever firmware command returns non-zero
- * return code.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb)
-{
- unsigned cmd = mb->command;
-
- switch (err) {
-
- case CMD_TIMEOUT:
- printk(KERN_INFO "%s: command 0x%02X timed out!\n",
- card->devname, cmd);
- break;
-
- case S514_BOTH_PORTS_SAME_CLK_MODE:
- if(cmd == SET_CHDLC_CONFIGURATION) {
- printk(KERN_INFO
- "%s: Configure both ports for the same clock source\n",
- card->devname);
- break;
- }
-
- default:
- printk(KERN_INFO "%s: command 0x%02X returned 0x%02X!\n",
- card->devname, cmd, err);
- }
-
- return 0;
-}
-
-
-/********** Bottom Half Handlers ********************************************/
-
-/* NOTE: There is no API, BH support for Kernels lower than 2.2.X.
- * DO NOT INSERT ANY CODE HERE, NOTICE THE
- * PREPROCESSOR STATEMENT ABOVE, UNLESS YOU KNOW WHAT YOU ARE
- * DOING */
-
-static void chdlc_work(struct net_device * dev)
-{
- chdlc_private_area_t* chan = dev->priv;
- sdla_t *card = chan->card;
- struct sk_buff *skb;
-
- if (atomic_read(&chan->bh_buff_used) == 0){
- clear_bit(0, &chan->tq_working);
- return;
- }
-
- while (atomic_read(&chan->bh_buff_used)){
-
- skb = ((bh_data_t *)&chan->bh_head[chan->bh_read])->skb;
-
- if (skb != NULL){
-
- if (chan->common.sk == NULL || chan->common.func == NULL){
- ++card->wandev.stats.rx_dropped;
- dev_kfree_skb_any(skb);
- chdlc_work_cleanup(dev);
- continue;
- }
-
- if (chan->common.func(skb,dev,chan->common.sk) != 0){
- /* Sock full cannot send, queue us for another
- * try */
- atomic_set(&chan->common.receive_block,1);
- return;
- }else{
- chdlc_work_cleanup(dev);
- }
- }else{
- chdlc_work_cleanup(dev);
- }
- }
- clear_bit(0, &chan->tq_working);
-
- return;
-}
-
-static int chdlc_work_cleanup(struct net_device *dev)
-{
- chdlc_private_area_t* chan = dev->priv;
-
- ((bh_data_t *)&chan->bh_head[chan->bh_read])->skb = NULL;
-
- if (chan->bh_read == MAX_BH_BUFF){
- chan->bh_read=0;
- }else{
- ++chan->bh_read;
- }
-
- atomic_dec(&chan->bh_buff_used);
- return 0;
-}
-
-
-
-static int bh_enqueue(struct net_device *dev, struct sk_buff *skb)
-{
- /* Check for full */
- chdlc_private_area_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
- if (atomic_read(&chan->bh_buff_used) == (MAX_BH_BUFF+1)){
- ++card->wandev.stats.rx_dropped;
- dev_kfree_skb_any(skb);
- return 1;
- }
-
- ((bh_data_t *)&chan->bh_head[chan->bh_write])->skb = skb;
-
- if (chan->bh_write == MAX_BH_BUFF){
- chan->bh_write=0;
- }else{
- ++chan->bh_write;
- }
-
- atomic_inc(&chan->bh_buff_used);
-
- return 0;
-}
-
-/* END OF API BH Support */
-
-
-/****** Interrupt Handlers **************************************************/
-
-/*============================================================================
- * Cisco HDLC interrupt service routine.
- */
-static void wpc_isr (sdla_t* card)
-{
- struct net_device* dev;
- SHARED_MEMORY_INFO_STRUCT* flags = NULL;
- int i;
- sdla_t *my_card;
-
-
- /* Check for which port the interrupt has been generated
- * Since Secondary Port is piggybacking on the Primary
- * the check must be done here.
- */
-
- flags = card->u.c.flags;
- if (!flags->interrupt_info_struct.interrupt_type){
- /* Check for a second port (piggybacking) */
- if ((my_card = card->next)){
- flags = my_card->u.c.flags;
- if (flags->interrupt_info_struct.interrupt_type){
- card = my_card;
- card->isr(card);
- return;
- }
- }
- }
-
- flags = card->u.c.flags;
- card->in_isr = 1;
- dev = card->wandev.dev;
-
- /* If we get an interrupt with no network device, stop the interrupts
- * and issue an error */
- if (!card->tty_opt && !dev &&
- flags->interrupt_info_struct.interrupt_type !=
- COMMAND_COMPLETE_APP_INT_PEND){
-
- goto isr_done;
- }
-
- /* if critical due to peripheral operations
- * ie. update() or getstats() then reset the interrupt and
- * wait for the board to retrigger.
- */
- if(test_bit(PERI_CRIT, (void*)&card->wandev.critical)) {
- printk(KERN_INFO "ISR CRIT TO PERI\n");
- goto isr_done;
- }
-
- /* On a 508 Card, if critical due to if_send
- * Major Error !!! */
- if(card->hw.type != SDLA_S514) {
- if(test_bit(SEND_CRIT, (void*)&card->wandev.critical)) {
- printk(KERN_INFO "%s: Critical while in ISR: %lx\n",
- card->devname, card->wandev.critical);
- card->in_isr = 0;
- flags->interrupt_info_struct.interrupt_type = 0;
- return;
- }
- }
-
- switch(flags->interrupt_info_struct.interrupt_type) {
-
- case RX_APP_INT_PEND: /* 0x01: receive interrupt */
- rx_intr(card);
- break;
-
- case TX_APP_INT_PEND: /* 0x02: transmit interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TX_FRAME;
-
- if (card->tty_opt){
- wanpipe_tty_trigger_poll(card);
- break;
- }
-
- if (dev && netif_queue_stopped(dev)){
- if (card->u.c.usedby == API){
- netif_start_queue(dev);
- wakeup_sk_bh(dev);
- }else{
- netif_wake_queue(dev);
- }
- }
- break;
-
- case COMMAND_COMPLETE_APP_INT_PEND:/* 0x04: cmd cplt */
- ++ Intr_test_counter;
- break;
-
- case CHDLC_EXCEP_COND_APP_INT_PEND: /* 0x20 */
- process_chdlc_exception(card);
- break;
-
- case GLOBAL_EXCEP_COND_APP_INT_PEND:
- process_global_exception(card);
- break;
-
- case TIMER_APP_INT_PEND:
- timer_intr(card);
- break;
-
- default:
- printk(KERN_INFO "%s: spurious interrupt 0x%02X!\n",
- card->devname,
- flags->interrupt_info_struct.interrupt_type);
- printk(KERN_INFO "Code name: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codename[i]);
- printk(KERN_INFO "\nCode version: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codeversion[i]);
- printk(KERN_INFO "\n");
- break;
- }
-
-isr_done:
-
- card->in_isr = 0;
- flags->interrupt_info_struct.interrupt_type = 0;
- return;
-}
-
-/*============================================================================
- * Receive interrupt handler.
- */
-static void rx_intr (sdla_t* card)
-{
- struct net_device *dev;
- chdlc_private_area_t *chdlc_priv_area;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- CHDLC_DATA_RX_STATUS_EL_STRUCT *rxbuf = card->u.c.rxmb;
- struct sk_buff *skb;
- unsigned len;
- unsigned addr = rxbuf->ptr_data_bfr;
- void *buf;
- int i,udp_type;
-
- if (rxbuf->opp_flag != 0x01) {
- printk(KERN_INFO
- "%s: corrupted Rx buffer @ 0x%X, flag = 0x%02X!\n",
- card->devname, (unsigned)rxbuf, rxbuf->opp_flag);
- printk(KERN_INFO "Code name: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codename[i]);
- printk(KERN_INFO "\nCode version: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codeversion[i]);
- printk(KERN_INFO "\n");
-
-
- /* Bug Fix: Mar 6 2000
- * If we get a corrupted mailbox, it measn that driver
- * is out of sync with the firmware. There is no recovery.
- * If we don't turn off all interrupts for this card
- * the machine will crash.
- */
- printk(KERN_INFO "%s: Critical router failure ...!!!\n", card->devname);
- printk(KERN_INFO "Please contact Sangoma Technologies !\n");
- chdlc_set_intr_mode(card,0);
- return;
- }
-
- len = rxbuf->frame_length;
-
- if (card->tty_opt){
-
- if (rxbuf->error_flag){
- goto rx_exit;
- }
-
- if (len <= CRC_LENGTH){
- goto rx_exit;
- }
-
- if (!card->u.c.async_mode){
- len -= CRC_LENGTH;
- }
-
- wanpipe_tty_receive(card,addr,len);
- goto rx_exit;
- }
-
- dev = card->wandev.dev;
-
- if (!dev){
- goto rx_exit;
- }
-
- if (!netif_running(dev))
- goto rx_exit;
-
- chdlc_priv_area = dev->priv;
-
-
- /* Allocate socket buffer */
- skb = dev_alloc_skb(len);
-
- if (skb == NULL) {
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- ++card->wandev.stats.rx_dropped;
- goto rx_exit;
- }
-
- /* Copy data to the socket buffer */
- if((addr + len) > card->u.c.rx_top + 1) {
- unsigned tmp = card->u.c.rx_top - addr + 1;
- buf = skb_put(skb, tmp);
- sdla_peek(&card->hw, addr, buf, tmp);
- addr = card->u.c.rx_base;
- len -= tmp;
- }
-
- buf = skb_put(skb, len);
- sdla_peek(&card->hw, addr, buf, len);
-
- skb->protocol = htons(ETH_P_IP);
-
- card->wandev.stats.rx_packets ++;
- card->wandev.stats.rx_bytes += skb->len;
- udp_type = udp_pkt_type( skb, card );
-
- if(udp_type == UDP_CPIPE_TYPE) {
- if(store_udp_mgmt_pkt(UDP_PKT_FRM_NETWORK,
- card, skb, dev, chdlc_priv_area)) {
- flags->interrupt_info_struct.
- interrupt_permission |=
- APP_INT_ON_TIMER;
- }
- } else if(card->u.c.usedby == API) {
-
- api_rx_hdr_t* api_rx_hdr;
- skb_push(skb, sizeof(api_rx_hdr_t));
- api_rx_hdr = (api_rx_hdr_t*)&skb->data[0x00];
- api_rx_hdr->error_flag = rxbuf->error_flag;
- api_rx_hdr->time_stamp = rxbuf->time_stamp;
-
- skb->protocol = htons(PVC_PROT);
- skb->mac.raw = skb->data;
- skb->dev = dev;
- skb->pkt_type = WAN_PACKET_DATA;
-
- bh_enqueue(dev, skb);
-
- if (!test_and_set_bit(0,&chdlc_priv_area->tq_working))
- wanpipe_queue_work(&chdlc_priv_area->common.wanpipe_work);
- }else{
- /* FIXME: we should check to see if the received packet is a
- multicast packet so that we can increment the multicast
- statistic
- ++ chdlc_priv_area->if_stats.multicast;
- */
- /* Pass it up the protocol stack */
-
- skb->dev = dev;
- skb->mac.raw = skb->data;
- netif_rx(skb);
- dev->last_rx = jiffies;
- }
-
-rx_exit:
- /* Release buffer element and calculate a pointer to the next one */
- rxbuf->opp_flag = 0x00;
- card->u.c.rxmb = ++ rxbuf;
- if((void*)rxbuf > card->u.c.rxbuf_last){
- card->u.c.rxmb = card->u.c.rxbuf_base;
- }
-}
-
-/*============================================================================
- * Timer interrupt handler.
- * The timer interrupt is used for two purposes:
- * 1) Processing udp calls from 'cpipemon'.
- * 2) Reading board-level statistics for updating the proc file system.
- */
-void timer_intr(sdla_t *card)
-{
- struct net_device* dev;
- chdlc_private_area_t* chdlc_priv_area = NULL;
- SHARED_MEMORY_INFO_STRUCT* flags = NULL;
-
- if ((dev = card->wandev.dev)==NULL){
- flags = card->u.c.flags;
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TIMER;
- return;
- }
-
- chdlc_priv_area = dev->priv;
-
- if (chdlc_priv_area->timer_int_enabled & TMR_INT_ENABLED_CONFIG) {
- if (!config_chdlc(card)){
- chdlc_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_CONFIG;
- }
- }
-
- /* process a udp call if pending */
- if(chdlc_priv_area->timer_int_enabled & TMR_INT_ENABLED_UDP) {
- process_udp_mgmt_pkt(card, dev,
- chdlc_priv_area);
- chdlc_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_UDP;
- }
-
- /* read the communications statistics if required */
- if(chdlc_priv_area->timer_int_enabled & TMR_INT_ENABLED_UPDATE) {
- update_comms_stats(card, chdlc_priv_area);
- if(!(-- chdlc_priv_area->update_comms_stats)) {
- chdlc_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_UPDATE;
- }
- }
-
- /* only disable the timer interrupt if there are no udp or statistic */
- /* updates pending */
- if(!chdlc_priv_area->timer_int_enabled) {
- flags = card->u.c.flags;
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TIMER;
- }
-}
-
-/*------------------------------------------------------------------------------
- Miscellaneous Functions
- - set_chdlc_config() used to set configuration options on the board
-------------------------------------------------------------------------------*/
-
-static int set_chdlc_config(sdla_t* card)
-{
- CHDLC_CONFIGURATION_STRUCT cfg;
-
- memset(&cfg, 0, sizeof(CHDLC_CONFIGURATION_STRUCT));
-
- if(card->wandev.clocking){
- cfg.baud_rate = card->wandev.bps;
- }
-
- cfg.line_config_options = (card->wandev.interface == WANOPT_RS232) ?
- INTERFACE_LEVEL_RS232 : INTERFACE_LEVEL_V35;
-
- cfg.modem_config_options = 0;
- cfg.modem_status_timer = 100;
-
- cfg.CHDLC_protocol_options = card->u.c.protocol_options;
-
- if (card->tty_opt){
- cfg.CHDLC_API_options = DISCARD_RX_ERROR_FRAMES;
- }
-
- cfg.percent_data_buffer_for_Tx = (card->u.c.receive_only) ? 0 : 50;
- cfg.CHDLC_statistics_options = (CHDLC_TX_DATA_BYTE_COUNT_STAT |
- CHDLC_RX_DATA_BYTE_COUNT_STAT);
-
- if (card->tty_opt){
- card->wandev.mtu = TTY_CHDLC_MAX_MTU;
- }
- cfg.max_CHDLC_data_field_length = card->wandev.mtu;
- cfg.transmit_keepalive_timer = card->u.c.kpalv_tx;
- cfg.receive_keepalive_timer = card->u.c.kpalv_rx;
- cfg.keepalive_error_tolerance = card->u.c.kpalv_err;
- cfg.SLARP_request_timer = card->u.c.slarp_timer;
-
- if (cfg.SLARP_request_timer) {
- cfg.IP_address = 0;
- cfg.IP_netmask = 0;
-
- }else if (card->wandev.dev){
- struct net_device *dev = card->wandev.dev;
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
-
- struct in_device *in_dev = dev->ip_ptr;
-
- if(in_dev != NULL) {
- struct in_ifaddr *ifa = in_dev->ifa_list;
-
- if (ifa != NULL ) {
- cfg.IP_address = ntohl(ifa->ifa_local);
- cfg.IP_netmask = ntohl(ifa->ifa_mask);
- chdlc_priv_area->IP_address = ntohl(ifa->ifa_local);
- chdlc_priv_area->IP_netmask = ntohl(ifa->ifa_mask);
- }
- }
-
- /* FIXME: We must re-think this message in next release
- if((cfg.IP_address & 0x000000FF) > 2) {
- printk(KERN_WARNING "\n");
- printk(KERN_WARNING " WARNING:%s configured with an\n",
- card->devname);
- printk(KERN_WARNING " invalid local IP address.\n");
- printk(KERN_WARNING " Slarp pragmatics will fail.\n");
- printk(KERN_WARNING " IP address should be of the\n");
- printk(KERN_WARNING " format A.B.C.1 or A.B.C.2.\n");
- }
- */
- }
-
- return chdlc_configure(card, &cfg);
-}
-
-
-/*-----------------------------------------------------------------------------
- set_asy_config() used to set asynchronous configuration options on the board
-------------------------------------------------------------------------------*/
-
-static int set_asy_config(sdla_t* card)
-{
-
- ASY_CONFIGURATION_STRUCT cfg;
- CHDLC_MAILBOX_STRUCT *mailbox = card->mbox;
- int err;
-
- memset(&cfg, 0, sizeof(ASY_CONFIGURATION_STRUCT));
-
- if(card->wandev.clocking)
- cfg.baud_rate = card->wandev.bps;
-
- cfg.line_config_options = (card->wandev.interface == WANOPT_RS232) ?
- INTERFACE_LEVEL_RS232 : INTERFACE_LEVEL_V35;
-
- cfg.modem_config_options = 0;
- cfg.asy_API_options = card->u.c.api_options;
- cfg.asy_protocol_options = card->u.c.protocol_options;
- cfg.Tx_bits_per_char = card->u.c.tx_bits_per_char;
- cfg.Rx_bits_per_char = card->u.c.rx_bits_per_char;
- cfg.stop_bits = card->u.c.stop_bits;
- cfg.parity = card->u.c.parity;
- cfg.break_timer = card->u.c.break_timer;
- cfg.asy_Rx_inter_char_timer = card->u.c.inter_char_timer;
- cfg.asy_Rx_complete_length = card->u.c.rx_complete_length;
- cfg.XON_char = card->u.c.xon_char;
- cfg.XOFF_char = card->u.c.xoff_char;
- cfg.asy_statistics_options = (CHDLC_TX_DATA_BYTE_COUNT_STAT |
- CHDLC_RX_DATA_BYTE_COUNT_STAT);
-
- mailbox->buffer_length = sizeof(ASY_CONFIGURATION_STRUCT);
- memcpy(mailbox->data, &cfg, mailbox->buffer_length);
- mailbox->command = SET_ASY_CONFIGURATION;
- err = sdla_exec(mailbox) ? mailbox->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error (card, err, mailbox);
- return err;
-}
-
-/*============================================================================
- * Enable asynchronous communications.
- */
-
-static int asy_comm_enable (sdla_t* card)
-{
-
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = ENABLE_ASY_COMMUNICATIONS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK && card->wandev.dev)
- chdlc_error(card, err, mb);
-
- if (!err)
- card->u.c.comm_enabled = 1;
-
- return err;
-}
-
-/*============================================================================
- * Process global exception condition
- */
-static int process_global_exception(sdla_t *card)
-{
- CHDLC_MAILBOX_STRUCT* mbox = card->mbox;
- int err;
-
- mbox->buffer_length = 0;
- mbox->command = READ_GLOBAL_EXCEPTION_CONDITION;
- err = sdla_exec(mbox) ? mbox->return_code : CMD_TIMEOUT;
-
- if(err != CMD_TIMEOUT ){
-
- switch(mbox->return_code) {
-
- case EXCEP_MODEM_STATUS_CHANGE:
-
- printk(KERN_INFO "%s: Modem status change\n",
- card->devname);
-
- switch(mbox->data[0] & (DCD_HIGH | CTS_HIGH)) {
- case (DCD_HIGH):
- printk(KERN_INFO "%s: DCD high, CTS low\n",card->devname);
- break;
- case (CTS_HIGH):
- printk(KERN_INFO "%s: DCD low, CTS high\n",card->devname);
- break;
- case ((DCD_HIGH | CTS_HIGH)):
- printk(KERN_INFO "%s: DCD high, CTS high\n",card->devname);
- break;
- default:
- printk(KERN_INFO "%s: DCD low, CTS low\n",card->devname);
- break;
- }
- break;
-
- case EXCEP_TRC_DISABLED:
- printk(KERN_INFO "%s: Line trace disabled\n",
- card->devname);
- break;
-
- case EXCEP_IRQ_TIMEOUT:
- printk(KERN_INFO "%s: IRQ timeout occurred\n",
- card->devname);
- break;
-
- case 0x17:
- if (card->tty_opt){
- if (card->tty && card->tty_open){
- printk(KERN_INFO
- "%s: Modem Hangup Exception: Hanging Up!\n",
- card->devname);
- tty_hangup(card->tty);
- }
- break;
- }
-
- /* If TTY is not used just drop throught */
-
- default:
- printk(KERN_INFO "%s: Global exception %x\n",
- card->devname, mbox->return_code);
- break;
- }
- }
- return 0;
-}
-
-
-/*============================================================================
- * Process chdlc exception condition
- */
-static int process_chdlc_exception(sdla_t *card)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int err;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_EXCEPTION_CONDITION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if(err != CMD_TIMEOUT) {
-
- switch (err) {
-
- case EXCEP_LINK_ACTIVE:
- port_set_state(card, WAN_CONNECTED);
- trigger_chdlc_poll(card->wandev.dev);
- break;
-
- case EXCEP_LINK_INACTIVE_MODEM:
- port_set_state(card, WAN_DISCONNECTED);
- unconfigure_ip(card);
- trigger_chdlc_poll(card->wandev.dev);
- break;
-
- case EXCEP_LINK_INACTIVE_KPALV:
- port_set_state(card, WAN_DISCONNECTED);
- printk(KERN_INFO "%s: Keepalive timer expired.\n",
- card->devname);
- unconfigure_ip(card);
- trigger_chdlc_poll(card->wandev.dev);
- break;
-
- case EXCEP_IP_ADDRESS_DISCOVERED:
- if (configure_ip(card))
- return -1;
- break;
-
- case EXCEP_LOOPBACK_CONDITION:
- printk(KERN_INFO "%s: Loopback Condition Detected.\n",
- card->devname);
- break;
-
- case NO_CHDLC_EXCEP_COND_TO_REPORT:
- printk(KERN_INFO "%s: No exceptions reported.\n",
- card->devname);
- break;
- }
-
- }
- return 0;
-}
-
-
-/*============================================================================
- * Configure IP from SLARP negotiation
- * This adds dynamic routes when SLARP has provided valid addresses
- */
-
-static int configure_ip (sdla_t* card)
-{
- struct net_device *dev = card->wandev.dev;
- chdlc_private_area_t *chdlc_priv_area;
- char err;
-
- if (!dev)
- return 0;
-
- chdlc_priv_area = dev->priv;
-
-
- /* set to discover */
- if(card->u.c.slarp_timer != 0x00) {
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- CHDLC_CONFIGURATION_STRUCT *cfg;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CONFIGURATION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if(err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- return -1;
- }
-
- cfg = (CHDLC_CONFIGURATION_STRUCT *)mb->data;
- chdlc_priv_area->IP_address = cfg->IP_address;
- chdlc_priv_area->IP_netmask = cfg->IP_netmask;
-
- /* Set flag to add route */
- chdlc_priv_area->route_status = ADD_ROUTE;
-
- /* The idea here is to add the route in the poll routine.
- This way, we aren't in interrupt context when adding routes */
- trigger_chdlc_poll(dev);
- }
-
- return 0;
-}
-
-
-/*============================================================================
- * Un-Configure IP negotiated by SLARP
- * This removes dynamic routes when the link becomes inactive.
- */
-
-static int unconfigure_ip (sdla_t* card)
-{
- struct net_device *dev = card->wandev.dev;
- chdlc_private_area_t *chdlc_priv_area;
-
- if (!dev)
- return 0;
-
- chdlc_priv_area= dev->priv;
-
- if (chdlc_priv_area->route_status == ROUTE_ADDED) {
-
- /* Note: If this function is called, the
- * port state has been DISCONNECTED. This state
- * change will trigger a poll_disconnected
- * function, that will check for this condition.
- */
- chdlc_priv_area->route_status = REMOVE_ROUTE;
-
- }
- return 0;
-}
-
-/*============================================================================
- * Routine to add/remove routes
- * Called like a polling routine when Routes are flagged to be added/removed.
- */
-
-static void process_route (sdla_t *card)
-{
- struct net_device *dev = card->wandev.dev;
- unsigned char port_num;
- chdlc_private_area_t *chdlc_priv_area = NULL;
- u32 local_IP_addr = 0;
- u32 remote_IP_addr = 0;
- u32 IP_netmask, IP_addr;
- int err = 0;
- struct in_device *in_dev;
- mm_segment_t fs;
- struct ifreq if_info;
- struct sockaddr_in *if_data1, *if_data2;
-
- chdlc_priv_area = dev->priv;
- port_num = card->u.c.comm_port;
-
- /* Bug Fix Mar 16 2000
- * AND the IP address to the Mask before checking
- * the last two bits. */
-
- if((chdlc_priv_area->route_status == ADD_ROUTE) &&
- ((chdlc_priv_area->IP_address & ~chdlc_priv_area->IP_netmask) > 2)) {
-
- printk(KERN_INFO "%s: Dynamic route failure.\n",card->devname);
-
- if(card->u.c.slarp_timer) {
- u32 addr_net = htonl(chdlc_priv_area->IP_address);
-
- printk(KERN_INFO "%s: Bad IP address %u.%u.%u.%u received\n",
- card->devname,
- NIPQUAD(addr_net));
- printk(KERN_INFO "%s: from remote station.\n",
- card->devname);
-
- }else{
- u32 addr_net = htonl(chdlc_priv_area->IP_address);
-
- printk(KERN_INFO "%s: Bad IP address %u.%u.%u.%u issued\n",
- card->devname,
- NIPQUAD(addr_net));
- printk(KERN_INFO "%s: to remote station. Local\n",
- card->devname);
- printk(KERN_INFO "%s: IP address must be A.B.C.1\n",
- card->devname);
- printk(KERN_INFO "%s: or A.B.C.2.\n",card->devname);
- }
-
- /* remove the route due to the IP address error condition */
- chdlc_priv_area->route_status = REMOVE_ROUTE;
- err = 1;
- }
-
- /* If we are removing a route with bad IP addressing, then use the */
- /* locally configured IP addresses */
- if((chdlc_priv_area->route_status == REMOVE_ROUTE) && err) {
-
- /* do not remove a bad route that has already been removed */
- if(chdlc_priv_area->route_removed) {
- return;
- }
-
- in_dev = dev->ip_ptr;
-
- if(in_dev != NULL) {
- struct in_ifaddr *ifa = in_dev->ifa_list;
- if (ifa != NULL ) {
- local_IP_addr = ifa->ifa_local;
- IP_netmask = ifa->ifa_mask;
- }
- }
- }else{
- /* According to Cisco HDLC, if the point-to-point address is
- A.B.C.1, then we are the opposite (A.B.C.2), and vice-versa.
- */
- IP_netmask = ntohl(chdlc_priv_area->IP_netmask);
- remote_IP_addr = ntohl(chdlc_priv_area->IP_address);
-
-
- /* If Netmask is 255.255.255.255 the local address
- * calculation will fail. Default it back to 255.255.255.0 */
- if (IP_netmask == 0xffffffff)
- IP_netmask &= 0x00ffffff;
-
- /* Bug Fix Mar 16 2000
- * AND the Remote IP address with IP netmask, instead
- * of static netmask of 255.255.255.0 */
- local_IP_addr = (remote_IP_addr & IP_netmask) +
- (~remote_IP_addr & ntohl(0x0003));
-
- if(!card->u.c.slarp_timer) {
- IP_addr = local_IP_addr;
- local_IP_addr = remote_IP_addr;
- remote_IP_addr = IP_addr;
- }
- }
-
- fs = get_fs(); /* Save file system */
- set_fs(get_ds()); /* Get user space block */
-
- /* Setup a structure for adding/removing routes */
- memset(&if_info, 0, sizeof(if_info));
- strcpy(if_info.ifr_name, dev->name);
-
- switch (chdlc_priv_area->route_status) {
-
- case ADD_ROUTE:
-
- if(!card->u.c.slarp_timer) {
- if_data2 = (struct sockaddr_in *)&if_info.ifr_dstaddr;
- if_data2->sin_addr.s_addr = remote_IP_addr;
- if_data2->sin_family = AF_INET;
- err = devinet_ioctl(SIOCSIFDSTADDR, &if_info);
- } else {
- if_data1 = (struct sockaddr_in *)&if_info.ifr_addr;
- if_data1->sin_addr.s_addr = local_IP_addr;
- if_data1->sin_family = AF_INET;
- if(!(err = devinet_ioctl(SIOCSIFADDR, &if_info))){
- if_data2 = (struct sockaddr_in *)&if_info.ifr_dstaddr;
- if_data2->sin_addr.s_addr = remote_IP_addr;
- if_data2->sin_family = AF_INET;
- err = devinet_ioctl(SIOCSIFDSTADDR, &if_info);
- }
- }
-
- if(err) {
- printk(KERN_INFO "%s: Add route %u.%u.%u.%u failed (%d)\n",
- card->devname, NIPQUAD(remote_IP_addr), err);
- } else {
- ((chdlc_private_area_t *)dev->priv)->route_status = ROUTE_ADDED;
- printk(KERN_INFO "%s: Dynamic route added.\n",
- card->devname);
- printk(KERN_INFO "%s: Local IP addr : %u.%u.%u.%u\n",
- card->devname, NIPQUAD(local_IP_addr));
- printk(KERN_INFO "%s: Remote IP addr: %u.%u.%u.%u\n",
- card->devname, NIPQUAD(remote_IP_addr));
- chdlc_priv_area->route_removed = 0;
- }
- break;
-
-
- case REMOVE_ROUTE:
-
- /* Change the local ip address of the interface to 0.
- * This will also delete the destination route.
- */
- if(!card->u.c.slarp_timer) {
- if_data2 = (struct sockaddr_in *)&if_info.ifr_dstaddr;
- if_data2->sin_addr.s_addr = 0;
- if_data2->sin_family = AF_INET;
- err = devinet_ioctl(SIOCSIFDSTADDR, &if_info);
- } else {
- if_data1 = (struct sockaddr_in *)&if_info.ifr_addr;
- if_data1->sin_addr.s_addr = 0;
- if_data1->sin_family = AF_INET;
- err = devinet_ioctl(SIOCSIFADDR,&if_info);
-
- }
- if(err) {
- printk(KERN_INFO
- "%s: Remove route %u.%u.%u.%u failed, (err %d)\n",
- card->devname, NIPQUAD(remote_IP_addr),
- err);
- } else {
- ((chdlc_private_area_t *)dev->priv)->route_status =
- NO_ROUTE;
- printk(KERN_INFO "%s: Dynamic route removed: %u.%u.%u.%u\n",
- card->devname, NIPQUAD(local_IP_addr));
- chdlc_priv_area->route_removed = 1;
- }
- break;
- }
-
- set_fs(fs); /* Restore file system */
-
-}
-
-
-/*=============================================================================
- * Store a UDP management packet for later processing.
- */
-
-static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area)
-{
- int udp_pkt_stored = 0;
-
- if(!chdlc_priv_area->udp_pkt_lgth &&
- (skb->len <= MAX_LGTH_UDP_MGNT_PKT)) {
- chdlc_priv_area->udp_pkt_lgth = skb->len;
- chdlc_priv_area->udp_pkt_src = udp_pkt_src;
- memcpy(chdlc_priv_area->udp_pkt_data, skb->data, skb->len);
- chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UDP;
- udp_pkt_stored = 1;
- }
-
- if(udp_pkt_src == UDP_PKT_FRM_STACK){
- dev_kfree_skb_any(skb);
- }else{
- dev_kfree_skb_any(skb);
- }
-
- return(udp_pkt_stored);
-}
-
-
-/*=============================================================================
- * Process UDP management packet.
- */
-
-static int process_udp_mgmt_pkt(sdla_t* card, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area )
-{
- unsigned char *buf;
- unsigned int frames, len;
- struct sk_buff *new_skb;
- unsigned short buffer_length, real_len;
- unsigned long data_ptr;
- unsigned data_length;
- int udp_mgmt_req_valid = 1;
- CHDLC_MAILBOX_STRUCT *mb = card->mbox;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- chdlc_udp_pkt_t *chdlc_udp_pkt;
- struct timeval tv;
- int err;
- char ut_char;
-
- chdlc_udp_pkt = (chdlc_udp_pkt_t *) chdlc_priv_area->udp_pkt_data;
-
- if(chdlc_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK){
-
- /* Only these commands are support for remote debugging.
- * All others are not */
- switch(chdlc_udp_pkt->cblock.command) {
-
- case READ_GLOBAL_STATISTICS:
- case READ_MODEM_STATUS:
- case READ_CHDLC_LINK_STATUS:
- case CPIPE_ROUTER_UP_TIME:
- case READ_COMMS_ERROR_STATS:
- case READ_CHDLC_OPERATIONAL_STATS:
-
- /* These two commands are executed for
- * each request */
- case READ_CHDLC_CONFIGURATION:
- case READ_CHDLC_CODE_VERSION:
- udp_mgmt_req_valid = 1;
- break;
- default:
- udp_mgmt_req_valid = 0;
- break;
- }
- }
-
- if(!udp_mgmt_req_valid) {
-
- /* set length to 0 */
- chdlc_udp_pkt->cblock.buffer_length = 0;
-
- /* set return code */
- chdlc_udp_pkt->cblock.return_code = 0xCD;
-
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Warning, Illegal UDP command attempted from network: %x\n",
- card->devname,chdlc_udp_pkt->cblock.command);
- }
-
- } else {
- unsigned long trace_status_cfg_addr = 0;
- TRACE_STATUS_EL_CFG_STRUCT trace_cfg_struct;
- TRACE_STATUS_ELEMENT_STRUCT trace_element_struct;
-
- switch(chdlc_udp_pkt->cblock.command) {
-
- case CPIPE_ENABLE_TRACING:
- if (!chdlc_priv_area->TracingEnabled) {
-
- /* OPERATE_DATALINE_MONITOR */
-
- mb->buffer_length = sizeof(LINE_TRACE_CONFIG_STRUCT);
- mb->command = SET_TRACE_CONFIGURATION;
-
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->
- trace_config = TRACE_ACTIVE;
- /* Trace delay mode is not used because it slows
- down transfer and results in a standoff situation
- when there is a lot of data */
-
- /* Configure the Trace based on user inputs */
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->trace_config |=
- chdlc_udp_pkt->data[0];
-
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->
- trace_deactivation_timer = 4000;
-
-
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- card->TracingEnabled = 0;
- chdlc_udp_pkt->cblock.return_code = err;
- mb->buffer_length = 0;
- break;
- }
-
- /* Get the base address of the trace element list */
- mb->buffer_length = 0;
- mb->command = READ_TRACE_CONFIGURATION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if (err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- chdlc_priv_area->TracingEnabled = 0;
- chdlc_udp_pkt->cblock.return_code = err;
- mb->buffer_length = 0;
- break;
- }
-
- trace_status_cfg_addr =((LINE_TRACE_CONFIG_STRUCT *)
- mb->data) -> ptr_trace_stat_el_cfg_struct;
-
- sdla_peek(&card->hw, trace_status_cfg_addr,
- &trace_cfg_struct, sizeof(trace_cfg_struct));
-
- chdlc_priv_area->start_trace_addr = trace_cfg_struct.
- base_addr_trace_status_elements;
-
- chdlc_priv_area->number_trace_elements =
- trace_cfg_struct.number_trace_status_elements;
-
- chdlc_priv_area->end_trace_addr = (unsigned long)
- ((TRACE_STATUS_ELEMENT_STRUCT *)
- chdlc_priv_area->start_trace_addr +
- (chdlc_priv_area->number_trace_elements - 1));
-
- chdlc_priv_area->base_addr_trace_buffer =
- trace_cfg_struct.base_addr_trace_buffer;
-
- chdlc_priv_area->end_addr_trace_buffer =
- trace_cfg_struct.end_addr_trace_buffer;
-
- chdlc_priv_area->curr_trace_addr =
- trace_cfg_struct.next_trace_element_to_use;
-
- chdlc_priv_area->available_buffer_space = 2000 -
- sizeof(ip_pkt_t) -
- sizeof(udp_pkt_t) -
- sizeof(wp_mgmt_t) -
- sizeof(cblock_t) -
- sizeof(trace_info_t);
- }
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- mb->buffer_length = 0;
- chdlc_priv_area->TracingEnabled = 1;
- break;
-
-
- case CPIPE_DISABLE_TRACING:
- if (chdlc_priv_area->TracingEnabled) {
-
- /* OPERATE_DATALINE_MONITOR */
- mb->buffer_length = sizeof(LINE_TRACE_CONFIG_STRUCT);
- mb->command = SET_TRACE_CONFIGURATION;
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->
- trace_config = TRACE_INACTIVE;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- }
-
- chdlc_priv_area->TracingEnabled = 0;
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- mb->buffer_length = 0;
- break;
-
-
- case CPIPE_GET_TRACE_INFO:
-
- if (!chdlc_priv_area->TracingEnabled) {
- chdlc_udp_pkt->cblock.return_code = 1;
- mb->buffer_length = 0;
- break;
- }
-
- chdlc_udp_pkt->trace_info.ismoredata = 0x00;
- buffer_length = 0; /* offset of packet already occupied */
-
- for (frames=0; frames < chdlc_priv_area->number_trace_elements; frames++){
-
- trace_pkt_t *trace_pkt = (trace_pkt_t *)
- &chdlc_udp_pkt->data[buffer_length];
-
- sdla_peek(&card->hw, chdlc_priv_area->curr_trace_addr,
- (unsigned char *)&trace_element_struct,
- sizeof(TRACE_STATUS_ELEMENT_STRUCT));
-
- if (trace_element_struct.opp_flag == 0x00) {
- break;
- }
-
- /* get pointer to real data */
- data_ptr = trace_element_struct.ptr_data_bfr;
-
- /* See if there is actual data on the trace buffer */
- if (data_ptr){
- data_length = trace_element_struct.trace_length;
- }else{
- data_length = 0;
- chdlc_udp_pkt->trace_info.ismoredata = 0x01;
- }
-
- if( (chdlc_priv_area->available_buffer_space - buffer_length)
- < ( sizeof(trace_pkt_t) + data_length) ) {
-
- /* indicate there are more frames on board & exit */
- chdlc_udp_pkt->trace_info.ismoredata = 0x01;
- break;
- }
-
- trace_pkt->status = trace_element_struct.trace_type;
-
- trace_pkt->time_stamp =
- trace_element_struct.trace_time_stamp;
-
- trace_pkt->real_length =
- trace_element_struct.trace_length;
-
- /* see if we can fit the frame into the user buffer */
- real_len = trace_pkt->real_length;
-
- if (data_ptr == 0) {
- trace_pkt->data_avail = 0x00;
- } else {
- unsigned tmp = 0;
-
- /* get the data from circular buffer
- must check for end of buffer */
- trace_pkt->data_avail = 0x01;
-
- if ((data_ptr + real_len) >
- chdlc_priv_area->end_addr_trace_buffer + 1){
-
- tmp = chdlc_priv_area->end_addr_trace_buffer - data_ptr + 1;
- sdla_peek(&card->hw, data_ptr,
- trace_pkt->data,tmp);
- data_ptr = chdlc_priv_area->base_addr_trace_buffer;
- }
-
- sdla_peek(&card->hw, data_ptr,
- &trace_pkt->data[tmp], real_len - tmp);
- }
-
- /* zero the opp flag to show we got the frame */
- ut_char = 0x00;
- sdla_poke(&card->hw, chdlc_priv_area->curr_trace_addr, &ut_char, 1);
-
- /* now move onto the next frame */
- chdlc_priv_area->curr_trace_addr += sizeof(TRACE_STATUS_ELEMENT_STRUCT);
-
- /* check if we went over the last address */
- if ( chdlc_priv_area->curr_trace_addr > chdlc_priv_area->end_trace_addr ) {
- chdlc_priv_area->curr_trace_addr = chdlc_priv_area->start_trace_addr;
- }
-
- if(trace_pkt->data_avail == 0x01) {
- buffer_length += real_len - 1;
- }
-
- /* for the header */
- buffer_length += sizeof(trace_pkt_t);
-
- } /* For Loop */
-
- if (frames == chdlc_priv_area->number_trace_elements){
- chdlc_udp_pkt->trace_info.ismoredata = 0x01;
- }
- chdlc_udp_pkt->trace_info.num_frames = frames;
-
- mb->buffer_length = buffer_length;
- chdlc_udp_pkt->cblock.buffer_length = buffer_length;
-
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
-
- break;
-
-
- case CPIPE_FT1_READ_STATUS:
- ((unsigned char *)chdlc_udp_pkt->data )[0] =
- flags->FT1_info_struct.parallel_port_A_input;
-
- ((unsigned char *)chdlc_udp_pkt->data )[1] =
- flags->FT1_info_struct.parallel_port_B_input;
-
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- chdlc_udp_pkt->cblock.buffer_length = 2;
- mb->buffer_length = 2;
- break;
-
- case CPIPE_ROUTER_UP_TIME:
- do_gettimeofday( &tv );
- chdlc_priv_area->router_up_time = tv.tv_sec -
- chdlc_priv_area->router_start_time;
- *(unsigned long *)&chdlc_udp_pkt->data =
- chdlc_priv_area->router_up_time;
- mb->buffer_length = sizeof(unsigned long);
- chdlc_udp_pkt->cblock.buffer_length = sizeof(unsigned long);
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- break;
-
- case FT1_MONITOR_STATUS_CTRL:
- /* Enable FT1 MONITOR STATUS */
- if ((chdlc_udp_pkt->data[0] & ENABLE_READ_FT1_STATUS) ||
- (chdlc_udp_pkt->data[0] & ENABLE_READ_FT1_OP_STATS)) {
-
- if( rCount++ != 0 ) {
- chdlc_udp_pkt->cblock.
- return_code = COMMAND_OK;
- mb->buffer_length = 1;
- break;
- }
- }
-
- /* Disable FT1 MONITOR STATUS */
- if( chdlc_udp_pkt->data[0] == 0) {
-
- if( --rCount != 0) {
- chdlc_udp_pkt->cblock.
- return_code = COMMAND_OK;
- mb->buffer_length = 1;
- break;
- }
- }
- goto dflt_1;
-
- default:
-dflt_1:
- /* it's a board command */
- mb->command = chdlc_udp_pkt->cblock.command;
- mb->buffer_length = chdlc_udp_pkt->cblock.buffer_length;
- if (mb->buffer_length) {
- memcpy(&mb->data, (unsigned char *) chdlc_udp_pkt->
- data, mb->buffer_length);
- }
- /* run the command on the board */
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK) {
- break;
- }
-
- /* copy the result back to our buffer */
- memcpy(&chdlc_udp_pkt->cblock, mb, sizeof(cblock_t));
-
- if (mb->buffer_length) {
- memcpy(&chdlc_udp_pkt->data, &mb->data,
- mb->buffer_length);
- }
-
- } /* end of switch */
- } /* end of else */
-
- /* Fill UDP TTL */
- chdlc_udp_pkt->ip_pkt.ttl = card->wandev.ttl;
-
- len = reply_udp(chdlc_priv_area->udp_pkt_data, mb->buffer_length);
-
-
- if(chdlc_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK){
-
- /* Must check if we interrupted if_send() routine. The
- * tx buffers might be used. If so drop the packet */
- if (!test_bit(SEND_CRIT,&card->wandev.critical)) {
-
- if(!chdlc_send(card, chdlc_priv_area->udp_pkt_data, len)) {
- ++ card->wandev.stats.tx_packets;
- card->wandev.stats.tx_bytes += len;
- }
- }
- } else {
-
- /* Pass it up the stack
- Allocate socket buffer */
- if ((new_skb = dev_alloc_skb(len)) != NULL) {
- /* copy data into new_skb */
-
- buf = skb_put(new_skb, len);
- memcpy(buf, chdlc_priv_area->udp_pkt_data, len);
-
- /* Decapsulate pkt and pass it up the protocol stack */
- new_skb->protocol = htons(ETH_P_IP);
- new_skb->dev = dev;
- new_skb->mac.raw = new_skb->data;
-
- netif_rx(new_skb);
- dev->last_rx = jiffies;
- } else {
-
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- }
- }
-
- chdlc_priv_area->udp_pkt_lgth = 0;
-
- return 0;
-}
-
-/*============================================================================
- * Initialize Receive and Transmit Buffers.
- */
-
-static void init_chdlc_tx_rx_buff( sdla_t* card)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- CHDLC_TX_STATUS_EL_CFG_STRUCT *tx_config;
- CHDLC_RX_STATUS_EL_CFG_STRUCT *rx_config;
- char err;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CONFIGURATION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if(err != COMMAND_OK) {
- if (card->wandev.dev){
- chdlc_error(card,err,mb);
- }
- return;
- }
-
- if(card->hw.type == SDLA_S514) {
- tx_config = (CHDLC_TX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Tx_stat_el_cfg_struct));
- rx_config = (CHDLC_RX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Rx_stat_el_cfg_struct));
-
- /* Setup Head and Tails for buffers */
- card->u.c.txbuf_base = (void *)(card->hw.dpmbase +
- tx_config->base_addr_Tx_status_elements);
- card->u.c.txbuf_last =
- (CHDLC_DATA_TX_STATUS_EL_STRUCT *)
- card->u.c.txbuf_base +
- (tx_config->number_Tx_status_elements - 1);
-
- card->u.c.rxbuf_base = (void *)(card->hw.dpmbase +
- rx_config->base_addr_Rx_status_elements);
- card->u.c.rxbuf_last =
- (CHDLC_DATA_RX_STATUS_EL_STRUCT *)
- card->u.c.rxbuf_base +
- (rx_config->number_Rx_status_elements - 1);
-
- /* Set up next pointer to be used */
- card->u.c.txbuf = (void *)(card->hw.dpmbase +
- tx_config->next_Tx_status_element_to_use);
- card->u.c.rxmb = (void *)(card->hw.dpmbase +
- rx_config->next_Rx_status_element_to_use);
- }
- else {
- tx_config = (CHDLC_TX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Tx_stat_el_cfg_struct % SDLA_WINDOWSIZE));
-
- rx_config = (CHDLC_RX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Rx_stat_el_cfg_struct % SDLA_WINDOWSIZE));
-
- /* Setup Head and Tails for buffers */
- card->u.c.txbuf_base = (void *)(card->hw.dpmbase +
- (tx_config->base_addr_Tx_status_elements % SDLA_WINDOWSIZE));
- card->u.c.txbuf_last =
- (CHDLC_DATA_TX_STATUS_EL_STRUCT *)card->u.c.txbuf_base
- + (tx_config->number_Tx_status_elements - 1);
- card->u.c.rxbuf_base = (void *)(card->hw.dpmbase +
- (rx_config->base_addr_Rx_status_elements % SDLA_WINDOWSIZE));
- card->u.c.rxbuf_last =
- (CHDLC_DATA_RX_STATUS_EL_STRUCT *)card->u.c.rxbuf_base
- + (rx_config->number_Rx_status_elements - 1);
-
- /* Set up next pointer to be used */
- card->u.c.txbuf = (void *)(card->hw.dpmbase +
- (tx_config->next_Tx_status_element_to_use % SDLA_WINDOWSIZE));
- card->u.c.rxmb = (void *)(card->hw.dpmbase +
- (rx_config->next_Rx_status_element_to_use % SDLA_WINDOWSIZE));
- }
-
- /* Setup Actual Buffer Start and end addresses */
- card->u.c.rx_base = rx_config->base_addr_Rx_buffer;
- card->u.c.rx_top = rx_config->end_addr_Rx_buffer;
-
-}
-
-/*=============================================================================
- * Perform Interrupt Test by running READ_CHDLC_CODE_VERSION command MAX_INTR
- * _TEST_COUNTER times.
- */
-static int intr_test( sdla_t* card)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int err,i;
-
- Intr_test_counter = 0;
-
- err = chdlc_set_intr_mode(card, APP_INT_ON_COMMAND_COMPLETE);
-
- if (err == CMD_OK) {
- for (i = 0; i < MAX_INTR_TEST_COUNTER; i ++) {
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CODE_VERSION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != CMD_OK)
- chdlc_error(card, err, mb);
- }
- }
- else {
- return err;
- }
-
- err = chdlc_set_intr_mode(card, 0);
-
- if (err != CMD_OK)
- return err;
-
- return 0;
-}
-
-/*==============================================================================
- * Determine what type of UDP call it is. CPIPEAB ?
- */
-static int udp_pkt_type(struct sk_buff *skb, sdla_t* card)
-{
- chdlc_udp_pkt_t *chdlc_udp_pkt = (chdlc_udp_pkt_t *)skb->data;
-
-#ifdef _WAN_UDP_DEBUG
- printk(KERN_INFO "SIG %s = %s\n\
- UPP %x = %x\n\
- PRT %x = %x\n\
- REQ %i = %i\n\
- 36 th = %x 37th = %x\n",
- chdlc_udp_pkt->wp_mgmt.signature,
- UDPMGMT_SIGNATURE,
- chdlc_udp_pkt->udp_pkt.udp_dst_port,
- ntohs(card->wandev.udp_port),
- chdlc_udp_pkt->ip_pkt.protocol,
- UDPMGMT_UDP_PROTOCOL,
- chdlc_udp_pkt->wp_mgmt.request_reply,
- UDPMGMT_REQUEST,
- skb->data[36], skb->data[37]);
-#endif
-
- if (!strncmp(chdlc_udp_pkt->wp_mgmt.signature,UDPMGMT_SIGNATURE,8) &&
- (chdlc_udp_pkt->udp_pkt.udp_dst_port == ntohs(card->wandev.udp_port)) &&
- (chdlc_udp_pkt->ip_pkt.protocol == UDPMGMT_UDP_PROTOCOL) &&
- (chdlc_udp_pkt->wp_mgmt.request_reply == UDPMGMT_REQUEST)) {
-
- return UDP_CPIPE_TYPE;
-
- }else{
- return UDP_INVALID_TYPE;
- }
-}
-
-/*============================================================================
- * Set PORT state.
- */
-static void port_set_state (sdla_t *card, int state)
-{
- if (card->u.c.state != state)
- {
- switch (state)
- {
- case WAN_CONNECTED:
- printk (KERN_INFO "%s: Link connected!\n",
- card->devname);
- break;
-
- case WAN_CONNECTING:
- printk (KERN_INFO "%s: Link connecting...\n",
- card->devname);
- break;
-
- case WAN_DISCONNECTED:
- printk (KERN_INFO "%s: Link disconnected!\n",
- card->devname);
- break;
- }
-
- card->wandev.state = card->u.c.state = state;
- if (card->wandev.dev){
- struct net_device *dev = card->wandev.dev;
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
- chdlc_priv_area->common.state = state;
- }
- }
-}
-
-/*===========================================================================
- * config_chdlc
- *
- * Configure the chdlc protocol and enable communications.
- *
- * The if_open() function binds this function to the poll routine.
- * Therefore, this function will run every time the chdlc interface
- * is brought up. We cannot run this function from the if_open
- * because if_open does not have access to the remote IP address.
- *
- * If the communications are not enabled, proceed to configure
- * the card and enable communications.
- *
- * If the communications are enabled, it means that the interface
- * was shutdown by ether the user or driver. In this case, we
- * have to check that the IP addresses have not changed. If
- * the IP addresses have changed, we have to reconfigure the firmware
- * and update the changed IP addresses. Otherwise, just exit.
- *
- */
-
-static int config_chdlc (sdla_t *card)
-{
- struct net_device *dev = card->wandev.dev;
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
-
- if (card->u.c.comm_enabled){
-
- /* Jun 20. 2000: NC
- * IP addresses are not used in the API mode */
-
- if ((chdlc_priv_area->ip_local_tmp != chdlc_priv_area->ip_local ||
- chdlc_priv_area->ip_remote_tmp != chdlc_priv_area->ip_remote) &&
- card->u.c.usedby == WANPIPE) {
-
- /* The IP addersses have changed, we must
- * stop the communications and reconfigure
- * the card. Reason: the firmware must know
- * the local and remote IP addresses. */
- disable_comm(card);
- port_set_state(card, WAN_DISCONNECTED);
- printk(KERN_INFO
- "%s: IP addresses changed!\n",
- card->devname);
- printk(KERN_INFO
- "%s: Restarting communications ...\n",
- card->devname);
- }else{
- /* IP addresses are the same and the link is up,
- * we don't have to do anything here. Therefore, exit */
- return 0;
- }
- }
-
- chdlc_priv_area->ip_local = chdlc_priv_area->ip_local_tmp;
- chdlc_priv_area->ip_remote = chdlc_priv_area->ip_remote_tmp;
-
-
- /* Setup the Board for asynchronous mode */
- if (card->u.c.async_mode){
-
- if (set_asy_config(card)) {
- printk (KERN_INFO "%s: Failed CHDLC Async configuration!\n",
- card->devname);
- return 0;
- }
- }else{
- /* Setup the Board for CHDLC */
- if (set_chdlc_config(card)) {
- printk (KERN_INFO "%s: Failed CHDLC configuration!\n",
- card->devname);
- return 0;
- }
- }
-
- /* Set interrupt mode and mask */
- if (chdlc_set_intr_mode(card, APP_INT_ON_RX_FRAME |
- APP_INT_ON_GLOBAL_EXCEP_COND |
- APP_INT_ON_TX_FRAME |
- APP_INT_ON_CHDLC_EXCEP_COND | APP_INT_ON_TIMER)){
- printk (KERN_INFO "%s: Failed to set interrupt triggers!\n",
- card->devname);
- return 0;
- }
-
-
- /* Mask the Transmit and Timer interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~(APP_INT_ON_TX_FRAME | APP_INT_ON_TIMER);
-
- /* In TTY mode, receive interrupt will be enabled during
- * wanpipe_tty_open() operation */
- if (card->tty_opt){
- flags->interrupt_info_struct.interrupt_permission &= ~APP_INT_ON_RX_FRAME;
- }
-
- /* Enable communications */
- if (card->u.c.async_mode){
- if (asy_comm_enable(card) != 0) {
- printk(KERN_INFO "%s: Failed to enable async commnunication!\n",
- card->devname);
- flags->interrupt_info_struct.interrupt_permission = 0;
- card->u.c.comm_enabled=0;
- chdlc_set_intr_mode(card,0);
- return 0;
- }
- }else{
- if (chdlc_comm_enable(card) != 0) {
- printk(KERN_INFO "%s: Failed to enable chdlc communications!\n",
- card->devname);
- flags->interrupt_info_struct.interrupt_permission = 0;
- card->u.c.comm_enabled=0;
- chdlc_set_intr_mode(card,0);
- return 0;
- }
- }
-
- /* Initialize Rx/Tx buffer control fields */
- init_chdlc_tx_rx_buff(card);
- port_set_state(card, WAN_CONNECTING);
- return 0;
-}
-
-
-/*============================================================
- * chdlc_poll
- *
- * Rationale:
- * We cannot manipulate the routing tables, or
- * ip addresses withing the interrupt. Therefore
- * we must perform such actons outside an interrupt
- * at a later time.
- *
- * Description:
- * CHDLC polling routine, responsible for
- * shutting down interfaces upon disconnect
- * and adding/removing routes.
- *
- * Usage:
- * This function is executed for each CHDLC
- * interface through a tq_schedule bottom half.
- *
- * trigger_chdlc_poll() function is used to kick
- * the chldc_poll routine.
- */
-
-static void chdlc_poll(struct net_device *dev)
-{
- chdlc_private_area_t *chdlc_priv_area;
- sdla_t *card;
- u8 check_gateway=0;
- SHARED_MEMORY_INFO_STRUCT* flags;
-
-
- if (!dev || (chdlc_priv_area=dev->priv) == NULL)
- return;
-
- card = chdlc_priv_area->card;
- flags = card->u.c.flags;
-
- /* (Re)Configuraiton is in progress, stop what you are
- * doing and get out */
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- clear_bit(POLL_CRIT,&card->wandev.critical);
- return;
- }
-
- /* if_open() function has triggered the polling routine
- * to determine the configured IP addresses. Once the
- * addresses are found, trigger the chdlc configuration */
- if (test_bit(0,&chdlc_priv_area->config_chdlc)){
-
- chdlc_priv_area->ip_local_tmp = get_ip_address(dev,WAN_LOCAL_IP);
- chdlc_priv_area->ip_remote_tmp = get_ip_address(dev,WAN_POINTOPOINT_IP);
-
- /* Jun 20. 2000 Bug Fix
- * Only perform this check in WANPIPE mode, since
- * IP addresses are not used in the API mode. */
-
- if (chdlc_priv_area->ip_local_tmp == chdlc_priv_area->ip_remote_tmp &&
- card->u.c.slarp_timer == 0x00 &&
- !card->u.c.backup &&
- card->u.c.usedby == WANPIPE){
-
- if (++chdlc_priv_area->ip_error > MAX_IP_ERRORS){
- printk(KERN_INFO "\n%s: --- WARNING ---\n",
- card->devname);
- printk(KERN_INFO
- "%s: The local IP address is the same as the\n",
- card->devname);
- printk(KERN_INFO
- "%s: Point-to-Point IP address.\n",
- card->devname);
- printk(KERN_INFO "%s: --- WARNING ---\n\n",
- card->devname);
- }else{
- clear_bit(POLL_CRIT,&card->wandev.critical);
- chdlc_priv_area->poll_delay_timer.expires = jiffies+HZ;
- add_timer(&chdlc_priv_area->poll_delay_timer);
- return;
- }
- }
-
- clear_bit(0,&chdlc_priv_area->config_chdlc);
- clear_bit(POLL_CRIT,&card->wandev.critical);
-
- chdlc_priv_area->timer_int_enabled |= TMR_INT_ENABLED_CONFIG;
- flags->interrupt_info_struct.interrupt_permission |= APP_INT_ON_TIMER;
- return;
- }
- /* Dynamic interface implementation, as well as dynamic
- * routing. */
-
- switch (card->u.c.state){
-
- case WAN_DISCONNECTED:
-
- /* If the dynamic interface configuration is on, and interface
- * is up, then bring down the netowrk interface */
-
- if (test_bit(DYN_OPT_ON,&chdlc_priv_area->interface_down) &&
- !test_bit(DEV_DOWN, &chdlc_priv_area->interface_down) &&
- card->wandev.dev->flags & IFF_UP){
-
- printk(KERN_INFO "%s: Interface %s down.\n",
- card->devname,card->wandev.dev->name);
- change_dev_flags(card->wandev.dev,(card->wandev.dev->flags&~IFF_UP));
- set_bit(DEV_DOWN,&chdlc_priv_area->interface_down);
- chdlc_priv_area->route_status = NO_ROUTE;
-
- }else{
- /* We need to check if the local IP address is
- * zero. If it is, we shouldn't try to remove it.
- */
-
- if (card->wandev.dev->flags & IFF_UP &&
- get_ip_address(card->wandev.dev,WAN_LOCAL_IP) &&
- chdlc_priv_area->route_status != NO_ROUTE &&
- card->u.c.slarp_timer){
-
- process_route(card);
- }
- }
- break;
-
- case WAN_CONNECTED:
-
- /* In SMP machine this code can execute before the interface
- * comes up. In this case, we must make sure that we do not
- * try to bring up the interface before dev_open() is finished */
-
-
- /* DEV_DOWN will be set only when we bring down the interface
- * for the very first time. This way we know that it was us
- * that brought the interface down */
-
- if (test_bit(DYN_OPT_ON,&chdlc_priv_area->interface_down) &&
- test_bit(DEV_DOWN, &chdlc_priv_area->interface_down) &&
- !(card->wandev.dev->flags & IFF_UP)){
-
- printk(KERN_INFO "%s: Interface %s up.\n",
- card->devname,card->wandev.dev->name);
- change_dev_flags(card->wandev.dev,(card->wandev.dev->flags|IFF_UP));
- clear_bit(DEV_DOWN,&chdlc_priv_area->interface_down);
- check_gateway=1;
- }
-
- if (chdlc_priv_area->route_status == ADD_ROUTE &&
- card->u.c.slarp_timer){
-
- process_route(card);
- check_gateway=1;
- }
-
- if (chdlc_priv_area->gateway && check_gateway)
- add_gateway(card,dev);
-
- break;
- }
-
- clear_bit(POLL_CRIT,&card->wandev.critical);
-}
-
-/*============================================================
- * trigger_chdlc_poll
- *
- * Description:
- * Add a chdlc_poll() work entry into the keventd work queue
- * for a specific dlci/interface. This will kick
- * the fr_poll() routine at a later time.
- *
- * Usage:
- * Interrupts use this to defer a taks to
- * a polling routine.
- *
- */
-static void trigger_chdlc_poll(struct net_device *dev)
-{
- chdlc_private_area_t *chdlc_priv_area;
- sdla_t *card;
-
- if (!dev)
- return;
-
- if ((chdlc_priv_area = dev->priv)==NULL)
- return;
-
- card = chdlc_priv_area->card;
-
- if (test_and_set_bit(POLL_CRIT,&card->wandev.critical)){
- return;
- }
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- return;
- }
- schedule_work(&chdlc_priv_area->poll_work);
-}
-
-
-static void chdlc_poll_delay (unsigned long dev_ptr)
-{
- struct net_device *dev = (struct net_device *)dev_ptr;
- trigger_chdlc_poll(dev);
-}
-
-
-void s508_lock (sdla_t *card, unsigned long *smp_flags)
-{
- spin_lock_irqsave(&card->wandev.lock, *smp_flags);
- if (card->next){
- spin_lock(&card->next->wandev.lock);
- }
-}
-
-void s508_unlock (sdla_t *card, unsigned long *smp_flags)
-{
- if (card->next){
- spin_unlock(&card->next->wandev.lock);
- }
- spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
-}
-
-//*********** TTY SECTION ****************
-
-static void wanpipe_tty_trigger_tx_irq(sdla_t *card)
-{
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- INTERRUPT_INFORMATION_STRUCT *chdlc_int = &flags->interrupt_info_struct;
- chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME;
-}
-
-static void wanpipe_tty_trigger_poll(sdla_t *card)
-{
- schedule_work(&card->tty_work);
-}
-
-static void tty_poll_work (void* data)
-{
- sdla_t *card = (sdla_t*)data;
- struct tty_struct *tty;
-
- if ((tty=card->tty)==NULL)
- return;
-
- tty_wakeup(tty);
-#if defined(SERIAL_HAVE_POLL_WAIT)
- wake_up_interruptible(&tty->poll_wait);
-#endif
- return;
-}
-
-static void wanpipe_tty_close(struct tty_struct *tty, struct file * filp)
-{
- sdla_t *card;
- unsigned long smp_flags;
-
- if (!tty || !tty->driver_data){
- return;
- }
-
- card = (sdla_t*)tty->driver_data;
-
- if (!card)
- return;
-
- printk(KERN_INFO "%s: Closing TTY Driver!\n",
- card->devname);
-
- /* Sanity Check */
- if (!card->tty_open)
- return;
-
- wanpipe_close(card);
- if (--card->tty_open == 0){
-
- lock_adapter_irq(&card->wandev.lock,&smp_flags);
- card->tty=NULL;
- chdlc_disable_comm_shutdown(card);
- unlock_adapter_irq(&card->wandev.lock,&smp_flags);
-
- kfree(card->tty_buf);
- card->tty_buf = NULL;
- kfree(card->tty_rx);
- card->tty_rx = NULL;
- }
- return;
-}
-static int wanpipe_tty_open(struct tty_struct *tty, struct file * filp)
-{
- unsigned long smp_flags;
- sdla_t *card;
-
- if (!tty){
- return -ENODEV;
- }
-
- if (!tty->driver_data){
- int port;
- port = tty->index;
- if ((port < 0) || (port >= NR_PORTS))
- return -ENODEV;
-
- tty->driver_data = WAN_CARD(port);
- if (!tty->driver_data)
- return -ENODEV;
- }
-
- card = (sdla_t*)tty->driver_data;
-
- if (!card){
- lock_adapter_irq(&card->wandev.lock,&smp_flags);
- card->tty=NULL;
- unlock_adapter_irq(&card->wandev.lock,&smp_flags);
- return -ENODEV;
- }
-
- printk(KERN_INFO "%s: Opening TTY Driver!\n",
- card->devname);
-
- if (card->tty_open == 0){
- lock_adapter_irq(&card->wandev.lock,&smp_flags);
- card->tty=tty;
- unlock_adapter_irq(&card->wandev.lock,&smp_flags);
-
- if (!card->tty_buf){
- card->tty_buf = kmalloc(TTY_CHDLC_MAX_MTU, GFP_KERNEL);
- if (!card->tty_buf){
- card->tty_buf=NULL;
- card->tty=NULL;
- return -ENOMEM;
- }
- }
-
- if (!card->tty_rx){
- card->tty_rx = kmalloc(TTY_CHDLC_MAX_MTU, GFP_KERNEL);
- if (!card->tty_rx){
- /* Free the buffer above */
- kfree(card->tty_buf);
- card->tty_buf=NULL;
- card->tty=NULL;
- return -ENOMEM;
- }
- }
- }
-
- ++card->tty_open;
- wanpipe_open(card);
- return 0;
-}
-
-static int wanpipe_tty_write(struct tty_struct * tty, const unsigned char *buf, int count)
-{
- unsigned long smp_flags=0;
- sdla_t *card=NULL;
-
- if (!tty){
- dbg_printk(KERN_INFO "NO TTY in Write\n");
- return -ENODEV;
- }
-
- card = (sdla_t *)tty->driver_data;
-
- if (!card){
- dbg_printk(KERN_INFO "No Card in TTY Write\n");
- return -ENODEV;
- }
-
- if (count > card->wandev.mtu){
- dbg_printk(KERN_INFO "Frame too big in Write %i Max: %i\n",
- count,card->wandev.mtu);
- return -EINVAL;
- }
-
- if (card->wandev.state != WAN_CONNECTED){
- dbg_printk(KERN_INFO "Card not connected in TTY Write\n");
- return -EINVAL;
- }
-
- /* Lock the 508 Card: SMP is supported */
- if(card->hw.type != SDLA_S514){
- s508_lock(card,&smp_flags);
- }
-
- if (test_and_set_bit(SEND_CRIT,(void*)&card->wandev.critical)){
- printk(KERN_INFO "%s: Critical in TTY Write\n",
- card->devname);
-
- /* Lock the 508 Card: SMP is supported */
- if(card->hw.type != SDLA_S514)
- s508_unlock(card,&smp_flags);
-
- return -EINVAL;
- }
-
- if (chdlc_send(card,(void*)buf,count)){
- dbg_printk(KERN_INFO "%s: Failed to send, retry later: kernel!\n",
- card->devname);
- clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-
- wanpipe_tty_trigger_tx_irq(card);
-
- if(card->hw.type != SDLA_S514)
- s508_unlock(card,&smp_flags);
- return 0;
- }
- dbg_printk(KERN_INFO "%s: Packet sent OK: %i\n",card->devname,count);
- clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-
- if(card->hw.type != SDLA_S514)
- s508_unlock(card,&smp_flags);
-
- return count;
-}
-
-static void wanpipe_tty_receive(sdla_t *card, unsigned addr, unsigned int len)
-{
- unsigned offset=0;
- unsigned olen=len;
- char fp=0;
- struct tty_struct *tty;
- int i;
- struct tty_ldisc *ld;
-
- if (!card->tty_open){
- dbg_printk(KERN_INFO "%s: TTY not open during receive\n",
- card->devname);
- return;
- }
-
- if ((tty=card->tty) == NULL){
- dbg_printk(KERN_INFO "%s: No TTY on receive\n",
- card->devname);
- return;
- }
-
- if (!tty->driver_data){
- dbg_printk(KERN_INFO "%s: No Driver Data, or Flip on receive\n",
- card->devname);
- return;
- }
-
-
- if (card->u.c.async_mode){
- if ((tty->flip.count+len) >= TTY_FLIPBUF_SIZE){
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Received packet size too big: %i bytes, Max: %i!\n",
- card->devname,len,TTY_FLIPBUF_SIZE);
- }
- return;
- }
-
-
- if((addr + len) > card->u.c.rx_top + 1) {
- offset = card->u.c.rx_top - addr + 1;
-
- sdla_peek(&card->hw, addr, tty->flip.char_buf_ptr, offset);
-
- addr = card->u.c.rx_base;
- len -= offset;
-
- tty->flip.char_buf_ptr+=offset;
- tty->flip.count+=offset;
- for (i=0;i<offset;i++){
- *tty->flip.flag_buf_ptr = 0;
- tty->flip.flag_buf_ptr++;
- }
- }
-
- sdla_peek(&card->hw, addr, tty->flip.char_buf_ptr, len);
-
- tty->flip.char_buf_ptr+=len;
- card->tty->flip.count+=len;
- for (i=0;i<len;i++){
- *tty->flip.flag_buf_ptr = 0;
- tty->flip.flag_buf_ptr++;
- }
-
- tty->low_latency=1;
- tty_flip_buffer_push(tty);
- }else{
- if (!card->tty_rx){
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Receive sync buffer not available!\n",
- card->devname);
- }
- return;
- }
-
- if (len > TTY_CHDLC_MAX_MTU){
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Received packet size too big: %i bytes, Max: %i!\n",
- card->devname,len,TTY_FLIPBUF_SIZE);
- }
- return;
- }
-
-
- if((addr + len) > card->u.c.rx_top + 1) {
- offset = card->u.c.rx_top - addr + 1;
-
- sdla_peek(&card->hw, addr, card->tty_rx, offset);
-
- addr = card->u.c.rx_base;
- len -= offset;
- }
- sdla_peek(&card->hw, addr, card->tty_rx+offset, len);
- ld = tty_ldisc_ref(tty);
- if (ld) {
- if (ld->receive_buf)
- ld->receive_buf(tty,card->tty_rx,&fp,olen);
- tty_ldisc_deref(ld);
- }else{
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: NO TTY Sync line discipline!\n",
- card->devname);
- }
- }
- }
-
- dbg_printk(KERN_INFO "%s: Received Data %i\n",card->devname,olen);
- return;
-}
-
-#if 0
-static int wanpipe_tty_ioctl(struct tty_struct *tty, struct file * file,
- unsigned int cmd, unsigned long arg)
-{
- return -ENOIOCTLCMD;
-}
-#endif
-
-static void wanpipe_tty_stop(struct tty_struct *tty)
-{
- return;
-}
-
-static void wanpipe_tty_start(struct tty_struct *tty)
-{
- return;
-}
-
-static int config_tty (sdla_t *card)
-{
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
-
- /* Setup the Board for asynchronous mode */
- if (card->u.c.async_mode){
-
- if (set_asy_config(card)) {
- printk (KERN_INFO "%s: Failed CHDLC Async configuration!\n",
- card->devname);
- return -EINVAL;
- }
- }else{
- /* Setup the Board for CHDLC */
- if (set_chdlc_config(card)) {
- printk (KERN_INFO "%s: Failed CHDLC configuration!\n",
- card->devname);
- return -EINVAL;
- }
- }
-
- /* Set interrupt mode and mask */
- if (chdlc_set_intr_mode(card, APP_INT_ON_RX_FRAME |
- APP_INT_ON_GLOBAL_EXCEP_COND |
- APP_INT_ON_TX_FRAME |
- APP_INT_ON_CHDLC_EXCEP_COND | APP_INT_ON_TIMER)){
- printk (KERN_INFO "%s: Failed to set interrupt triggers!\n",
- card->devname);
- return -EINVAL;
- }
-
-
- /* Mask the Transmit and Timer interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~(APP_INT_ON_TX_FRAME | APP_INT_ON_TIMER);
-
-
- /* Enable communications */
- if (card->u.c.async_mode){
- if (asy_comm_enable(card) != 0) {
- printk(KERN_INFO "%s: Failed to enable async commnunication!\n",
- card->devname);
- flags->interrupt_info_struct.interrupt_permission = 0;
- card->u.c.comm_enabled=0;
- chdlc_set_intr_mode(card,0);
- return -EINVAL;
- }
- }else{
- if (chdlc_comm_enable(card) != 0) {
- printk(KERN_INFO "%s: Failed to enable chdlc communications!\n",
- card->devname);
- flags->interrupt_info_struct.interrupt_permission = 0;
- card->u.c.comm_enabled=0;
- chdlc_set_intr_mode(card,0);
- return -EINVAL;
- }
- }
-
- /* Initialize Rx/Tx buffer control fields */
- init_chdlc_tx_rx_buff(card);
- port_set_state(card, WAN_CONNECTING);
- return 0;
-}
-
-
-static int change_speed(sdla_t *card, struct tty_struct *tty,
- struct termios *old_termios)
-{
- int baud, ret=0;
- unsigned cflag;
- int dbits,sbits,parity,handshaking;
-
- cflag = tty->termios->c_cflag;
-
- /* There is always one stop bit */
- sbits=WANOPT_ONE;
-
- /* Parity is defaulted to NONE */
- parity = WANOPT_NONE;
-
- handshaking=0;
-
- /* byte size and parity */
- switch (cflag & CSIZE) {
- case CS5: dbits = 5; break;
- case CS6: dbits = 6; break;
- case CS7: dbits = 7; break;
- case CS8: dbits = 8; break;
- /* Never happens, but GCC is too dumb to figure it out */
- default: dbits = 8; break;
- }
-
- /* One more stop bit should be supported, thus increment
- * the number of stop bits Max=2 */
- if (cflag & CSTOPB) {
- sbits = WANOPT_TWO;
- }
- if (cflag & PARENB) {
- parity = WANOPT_EVEN;
- }
- if (cflag & PARODD){
- parity = WANOPT_ODD;
- }
-
- /* Determine divisor based on baud rate */
- baud = tty_get_baud_rate(tty);
-
- if (!baud)
- baud = 9600; /* B0 transition handled in rs_set_termios */
-
- if (cflag & CRTSCTS) {
- handshaking|=ASY_RTS_HS_FOR_RX;
- }
-
- if (I_IGNPAR(tty))
- parity = WANOPT_NONE;
-
- if (I_IXOFF(tty)){
- handshaking|=ASY_XON_XOFF_HS_FOR_RX;
- handshaking|=ASY_XON_XOFF_HS_FOR_TX;
- }
-
- if (I_IXON(tty)){
- handshaking|=ASY_XON_XOFF_HS_FOR_RX;
- handshaking|=ASY_XON_XOFF_HS_FOR_TX;
- }
-
- if (card->u.c.async_mode){
- if (card->wandev.bps != baud)
- ret=1;
- card->wandev.bps = baud;
- }
-
- if (card->u.c.async_mode){
- if (card->u.c.protocol_options != handshaking)
- ret=1;
- card->u.c.protocol_options = handshaking;
-
- if (card->u.c.tx_bits_per_char != dbits)
- ret=1;
- card->u.c.tx_bits_per_char = dbits;
-
- if (card->u.c.rx_bits_per_char != dbits)
- ret=1;
- card->u.c.rx_bits_per_char = dbits;
-
- if (card->u.c.stop_bits != sbits)
- ret=1;
- card->u.c.stop_bits = sbits;
-
- if (card->u.c.parity != parity)
- ret=1;
- card->u.c.parity = parity;
-
- card->u.c.break_timer = 50;
- card->u.c.inter_char_timer = 10;
- card->u.c.rx_complete_length = 100;
- card->u.c.xon_char = 0xFE;
- }else{
- card->u.c.protocol_options = HDLC_STREAMING_MODE;
- }
-
- return ret;
-}
-
-
-static void wanpipe_tty_set_termios(struct tty_struct *tty, struct termios *old_termios)
-{
- sdla_t *card;
- int err=1;
-
- if (!tty){
- return;
- }
-
- card = (sdla_t *)tty->driver_data;
-
- if (!card)
- return;
-
- if (change_speed(card, tty, old_termios) || !card->u.c.comm_enabled){
- unsigned long smp_flags;
-
- if (card->u.c.comm_enabled){
- lock_adapter_irq(&card->wandev.lock,&smp_flags);
- chdlc_disable_comm_shutdown(card);
- unlock_adapter_irq(&card->wandev.lock,&smp_flags);
- }
- lock_adapter_irq(&card->wandev.lock,&smp_flags);
- err = config_tty(card);
- unlock_adapter_irq(&card->wandev.lock,&smp_flags);
- if (card->u.c.async_mode){
- printk(KERN_INFO "%s: TTY Async Configuration:\n"
- " Baud =%i\n"
- " Handshaking =%s\n"
- " Tx Dbits =%i\n"
- " Rx Dbits =%i\n"
- " Parity =%s\n"
- " Stop Bits =%i\n",
- card->devname,
- card->wandev.bps,
- opt_decode[card->u.c.protocol_options],
- card->u.c.tx_bits_per_char,
- card->u.c.rx_bits_per_char,
- p_decode[card->u.c.parity] ,
- card->u.c.stop_bits);
- }else{
- printk(KERN_INFO "%s: TTY Sync Configuration:\n"
- " Baud =%i\n"
- " Protocol =HDLC_STREAMING\n",
- card->devname,card->wandev.bps);
- }
- if (!err){
- port_set_state(card,WAN_CONNECTED);
- }else{
- port_set_state(card,WAN_DISCONNECTED);
- }
- }
- return;
-}
-
-static void wanpipe_tty_put_char(struct tty_struct *tty, unsigned char ch)
-{
- sdla_t *card;
- unsigned long smp_flags=0;
-
- if (!tty){
- return;
- }
-
- card = (sdla_t *)tty->driver_data;
-
- if (!card)
- return;
-
- if (card->wandev.state != WAN_CONNECTED)
- return;
-
- if(card->hw.type != SDLA_S514)
- s508_lock(card,&smp_flags);
-
- if (test_and_set_bit(SEND_CRIT,(void*)&card->wandev.critical)){
-
- wanpipe_tty_trigger_tx_irq(card);
-
- if(card->hw.type != SDLA_S514)
- s508_unlock(card,&smp_flags);
- return;
- }
-
- if (chdlc_send(card,(void*)&ch,1)){
- wanpipe_tty_trigger_tx_irq(card);
- dbg_printk("%s: Failed to TX char!\n",card->devname);
- }
-
- dbg_printk("%s: Char TX OK\n",card->devname);
-
- clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-
- if(card->hw.type != SDLA_S514)
- s508_unlock(card,&smp_flags);
-
- return;
-}
-
-static void wanpipe_tty_flush_chars(struct tty_struct *tty)
-{
- return;
-}
-
-static void wanpipe_tty_flush_buffer(struct tty_struct *tty)
-{
- if (!tty)
- return;
-
-#if defined(SERIAL_HAVE_POLL_WAIT)
- wake_up_interruptible(&tty->poll_wait);
-#endif
- tty_wakeup(tty);
- return;
-}
-
-/*
- * This function is used to send a high-priority XON/XOFF character to
- * the device
- */
-static void wanpipe_tty_send_xchar(struct tty_struct *tty, char ch)
-{
- return;
-}
-
-
-static int wanpipe_tty_chars_in_buffer(struct tty_struct *tty)
-{
- return 0;
-}
-
-
-static int wanpipe_tty_write_room(struct tty_struct *tty)
-{
- sdla_t *card;
-
- printk(KERN_INFO "TTY Write Room\n");
-
- if (!tty){
- return 0;
- }
-
- card = (sdla_t *)tty->driver_data;
- if (!card)
- return 0;
-
- if (card->wandev.state != WAN_CONNECTED)
- return 0;
-
- return SEC_MAX_NO_DATA_BYTES_IN_FRAME;
-}
-
-
-static int set_modem_status(sdla_t *card, unsigned char data)
-{
- CHDLC_MAILBOX_STRUCT *mb = card->mbox;
- int err;
-
- mb->buffer_length=1;
- mb->command=SET_MODEM_STATUS;
- mb->data[0]=data;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error (card, err, mb);
-
- return err;
-}
-
-static void wanpipe_tty_hangup(struct tty_struct *tty)
-{
- sdla_t *card;
- unsigned long smp_flags;
-
- printk(KERN_INFO "TTY Hangup!\n");
-
- if (!tty){
- return;
- }
-
- card = (sdla_t *)tty->driver_data;
- if (!card)
- return;
-
- lock_adapter_irq(&card->wandev.lock,&smp_flags);
- set_modem_status(card,0);
- unlock_adapter_irq(&card->wandev.lock,&smp_flags);
- return;
-}
-
-static void wanpipe_tty_break(struct tty_struct *tty, int break_state)
-{
- return;
-}
-
-static void wanpipe_tty_wait_until_sent(struct tty_struct *tty, int timeout)
-{
- return;
-}
-
-static void wanpipe_tty_throttle(struct tty_struct * tty)
-{
- return;
-}
-
-static void wanpipe_tty_unthrottle(struct tty_struct * tty)
-{
- return;
-}
-
-int wanpipe_tty_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- return 0;
-}
-
-/*
- * The serial driver boot-time initialization code!
- */
-int wanpipe_tty_init(sdla_t *card)
-{
- struct serial_state * state;
-
- /* Initialize the tty_driver structure */
-
- if (card->tty_minor < 0 || card->tty_minor > NR_PORTS){
- printk(KERN_INFO "%s: Illegal Minor TTY number (0-4): %i\n",
- card->devname,card->tty_minor);
- return -EINVAL;
- }
-
- if (WAN_CARD(card->tty_minor)){
- printk(KERN_INFO "%s: TTY Minor %i, already in use\n",
- card->devname,card->tty_minor);
- return -EBUSY;
- }
-
- if (tty_init_cnt==0){
-
- printk(KERN_INFO "%s: TTY %s Driver Init: Major %i, Minor Range %i-%i\n",
- card->devname,
- card->u.c.async_mode ? "ASYNC" : "SYNC",
- WAN_TTY_MAJOR,MIN_PORT,MAX_PORT);
-
- tty_driver_mode = card->u.c.async_mode;
-
- memset(&serial_driver, 0, sizeof(struct tty_driver));
- serial_driver.magic = TTY_DRIVER_MAGIC;
- serial_driver.owner = THIS_MODULE;
- serial_driver.driver_name = "wanpipe_tty";
- serial_driver.name = "ttyW";
- serial_driver.major = WAN_TTY_MAJOR;
- serial_driver.minor_start = WAN_TTY_MINOR;
- serial_driver.num = NR_PORTS;
- serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
- serial_driver.subtype = SERIAL_TYPE_NORMAL;
-
- serial_driver.init_termios = tty_std_termios;
- serial_driver.init_termios.c_cflag =
- B9600 | CS8 | CREAD | HUPCL | CLOCAL;
- serial_driver.flags = TTY_DRIVER_REAL_RAW;
-
- serial_driver.refcount = 1; /* !@!@^#^&!! */
-
- serial_driver.open = wanpipe_tty_open;
- serial_driver.close = wanpipe_tty_close;
- serial_driver.write = wanpipe_tty_write;
-
- serial_driver.put_char = wanpipe_tty_put_char;
- serial_driver.flush_chars = wanpipe_tty_flush_chars;
- serial_driver.write_room = wanpipe_tty_write_room;
- serial_driver.chars_in_buffer = wanpipe_tty_chars_in_buffer;
- serial_driver.flush_buffer = wanpipe_tty_flush_buffer;
- //serial_driver.ioctl = wanpipe_tty_ioctl;
- serial_driver.throttle = wanpipe_tty_throttle;
- serial_driver.unthrottle = wanpipe_tty_unthrottle;
- serial_driver.send_xchar = wanpipe_tty_send_xchar;
- serial_driver.set_termios = wanpipe_tty_set_termios;
- serial_driver.stop = wanpipe_tty_stop;
- serial_driver.start = wanpipe_tty_start;
- serial_driver.hangup = wanpipe_tty_hangup;
- serial_driver.break_ctl = wanpipe_tty_break;
- serial_driver.wait_until_sent = wanpipe_tty_wait_until_sent;
- serial_driver.read_proc = wanpipe_tty_read_proc;
-
- if (tty_register_driver(&serial_driver)){
- printk(KERN_INFO "%s: Failed to register serial driver!\n",
- card->devname);
- }
- }
-
-
- /* The subsequent ports must comply to the initial configuration */
- if (tty_driver_mode != card->u.c.async_mode){
- printk(KERN_INFO "%s: Error: TTY Driver operation mode mismatch!\n",
- card->devname);
- printk(KERN_INFO "%s: The TTY driver is configured for %s!\n",
- card->devname, tty_driver_mode ? "ASYNC" : "SYNC");
- return -EINVAL;
- }
-
- tty_init_cnt++;
-
- printk(KERN_INFO "%s: Initializing TTY %s Driver Minor %i\n",
- card->devname,
- tty_driver_mode ? "ASYNC" : "SYNC",
- card->tty_minor);
-
- tty_card_map[card->tty_minor] = card;
- state = &rs_table[card->tty_minor];
-
- state->magic = SSTATE_MAGIC;
- state->line = 0;
- state->type = PORT_UNKNOWN;
- state->custom_divisor = 0;
- state->close_delay = 5*HZ/10;
- state->closing_wait = 30*HZ;
- state->icount.cts = state->icount.dsr =
- state->icount.rng = state->icount.dcd = 0;
- state->icount.rx = state->icount.tx = 0;
- state->icount.frame = state->icount.parity = 0;
- state->icount.overrun = state->icount.brk = 0;
- state->irq = card->wandev.irq;
-
- INIT_WORK(&card->tty_work, tty_poll_work, (void*)card);
- return 0;
-}
-
-
-MODULE_LICENSE("GPL");
-
-/****** End ****************************************************************/
diff --git a/drivers/net/wan/sdla_fr.c b/drivers/net/wan/sdla_fr.c
deleted file mode 100644
index 7f1ce9d4333e8..0000000000000
--- a/drivers/net/wan/sdla_fr.c
+++ /dev/null
@@ -1,5061 +0,0 @@
-/*****************************************************************************
-* sdla_fr.c WANPIPE(tm) Multiprotocol WAN Link Driver. Frame relay module.
-*
-* Author(s): Nenad Corbic <ncorbic@sangoma.com>
-* Gideon Hack
-*
-* Copyright: (c) 1995-2001 Sangoma Technologies 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.
-* ============================================================================
-* Nov 23, 2000 Nenad Corbic o Added support for 2.4.X kernels
-* Nov 15, 2000 David Rokavarg
-* Nenad Corbic o Added frame relay bridging support.
-* Original code from Mark Wells and Kristian Hoffmann has
-* been integrated into the frame relay driver.
-* Nov 13, 2000 Nenad Corbic o Added true interface type encoding option.
-* Tcpdump doesn't support Frame Relay inteface
-* types, to fix this true type option will set
-* the interface type to RAW IP mode.
-* Nov 07, 2000 Nenad Corbic o Added security features for UDP debugging:
-* Deny all and specify allowed requests.
-* Nov 06, 2000 Nenad Corbic o Wanpipe interfaces conform to raw packet interfaces.
-* Moved the if_header into the if_send() routine.
-* The if_header() was breaking the libpcap
-* support. i.e. support for tcpdump, ethereal ...
-* Oct 12. 2000 Nenad Corbic o Added error message in fr_configure
-* Jul 31, 2000 Nenad Corbic o Fixed the Router UP Time.
-* Apr 28, 2000 Nenad Corbic o Added the option to shutdown an interface
-* when the channel gets disconnected.
-* Apr 28, 2000 Nenad Corbic o Added M.Grants patch: disallow duplicate
-* interface setups.
-* Apr 25, 2000 Nenad Corbic o Added M.Grants patch: dynamically add/remove
-* new dlcis/interfaces.
-* Mar 23, 2000 Nenad Corbic o Improved task queue, bh handling.
-* Mar 16, 2000 Nenad Corbic o Added Inverse ARP support
-* Mar 13, 2000 Nenad Corbic o Added new socket API support.
-* Mar 06, 2000 Nenad Corbic o Bug Fix: corrupted mbox recovery.
-* Feb 24, 2000 Nenad Corbic o Fixed up FT1 UDP debugging problem.
-* Dev 15, 1999 Nenad Corbic o Fixed up header files for 2.0.X kernels
-*
-* Nov 08, 1999 Nenad Corbic o Combined all debug UDP calls into one function
-* o Removed the ARP support. This has to be done
-* in the next version.
-* o Only a Node can implement NO signalling.
-* Initialize DLCI during if_open() if NO
-* signalling.
-* o Took out IPX support, implement in next
-* version
-* Sep 29, 1999 Nenad Corbic o Added SMP support and changed the update
-* function to use timer interrupt.
-* o Fixed the CIR bug: Set the value of BC
-* to CIR when the CIR is enabled.
-* o Updated comments, statistics and tracing.
-* Jun 02, 1999 Gideon Hack o Updated for S514 support.
-* Sep 18, 1998 Jaspreet Singh o Updated for 2.2.X kernels.
-* Jul 31, 1998 Jaspreet Singh o Removed wpf_poll routine. The channel/DLCI
-* status is received through an event interrupt.
-* Jul 08, 1998 David Fong o Added inverse ARP support.
-* Mar 26, 1997 Jaspreet Singh o Returning return codes for failed UDP cmds.
-* Jan 28, 1997 Jaspreet Singh o Improved handling of inactive DLCIs.
-* Dec 30, 1997 Jaspreet Singh o Replaced dev_tint() with mark_bh(NET_BH)
-* Dec 16, 1997 Jaspreet Singh o Implemented Multiple IPX support.
-* Nov 26, 1997 Jaspreet Singh o Improved load sharing with multiple boards
-* o Added Cli() to protect enabling of interrupts
-* while polling is called.
-* Nov 24, 1997 Jaspreet Singh o Added counters to avoid enabling of interrupts
-* when they have been disabled by another
-* interface or routine (eg. wpf_poll).
-* Nov 06, 1997 Jaspreet Singh o Added INTR_TEST_MODE to avoid polling
-* routine disable interrupts during interrupt
-* testing.
-* Oct 20, 1997 Jaspreet Singh o Added hooks in for Router UP time.
-* Oct 16, 1997 Jaspreet Singh o The critical flag is used to maintain flow
-* control by avoiding RACE conditions. The
-* cli() and restore_flags() are taken out.
-* The fr_channel structure is appended for
-* Driver Statistics.
-* Oct 15, 1997 Farhan Thawar o updated if_send() and receive for IPX
-* Aug 29, 1997 Farhan Thawar o Removed most of the cli() and sti()
-* o Abstracted the UDP management stuff
-* o Now use tbusy and critical more intelligently
-* Jul 21, 1997 Jaspreet Singh o Can configure T391, T392, N391, N392 & N393
-* through router.conf.
-* o Protected calls to sdla_peek() by adDing
-* save_flags(), cli() and restore_flags().
-* o Added error message for Inactive DLCIs in
-* fr_event() and update_chan_state().
-* o Fixed freeing up of buffers using kfree()
-* when packets are received.
-* Jul 07, 1997 Jaspreet Singh o Added configurable TTL for UDP packets
-* o Added ability to discard multicast and
-* broadcast source addressed packets
-* Jun 27, 1997 Jaspreet Singh o Added FT1 monitor capabilities
-* New case (0x44) statement in if_send routine
-* Added a global variable rCount to keep track
-* of FT1 status enabled on the board.
-* May 29, 1997 Jaspreet Singh o Fixed major Flow Control Problem
-* With multiple boards a problem was seen where
-* the second board always stopped transmitting
-* packet after running for a while. The code
-* got into a stage where the interrupts were
-* disabled and dev->tbusy was set to 1.
-* This caused the If_send() routine to get into
-* the if clause for it(0,dev->tbusy)
-* forever.
-* The code got into this stage due to an
-* interrupt occurring within the if clause for
-* set_bit(0,dev->tbusy). Since an interrupt
-* disables furhter transmit interrupt and
-* makes dev->tbusy = 0, this effect was undone
-* by making dev->tbusy = 1 in the if clause.
-* The Fix checks to see if Transmit interrupts
-* are disabled then do not make dev->tbusy = 1
-* Introduced a global variable: int_occur and
-* added tx_int_enabled in the wan_device
-* structure.
-* May 21, 1997 Jaspreet Singh o Fixed UDP Management for multiple
-* boards.
-*
-* Apr 25, 1997 Farhan Thawar o added UDP Management stuff
-* o fixed bug in if_send() and tx_intr() to
-* sleep and wakeup all devices
-* Mar 11, 1997 Farhan Thawar Version 3.1.1
-* o fixed (+1) bug in fr508_rx_intr()
-* o changed if_send() to return 0 if
-* wandev.critical() is true
-* o free socket buffer in if_send() if
-* returning 0
-* o added tx_intr() routine
-* Jan 30, 1997 Gene Kozin Version 3.1.0
-* o implemented exec() entry point
-* o fixed a bug causing driver configured as
-* a FR switch to be stuck in WAN_
-* mode
-* Jan 02, 1997 Gene Kozin Initial version.
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/workqueue.h>
-#include <linux/if_arp.h> /* ARPHRD_* defines */
-#include <asm/byteorder.h> /* htons(), etc. */
-#include <asm/io.h> /* for inb(), outb(), etc. */
-#include <linux/time.h> /* for do_gettimeofday */
-#include <linux/in.h> /* sockaddr_in */
-#include <linux/jiffies.h> /* time_after() macro */
-#include <asm/errno.h>
-
-#include <linux/ip.h>
-#include <linux/if.h>
-
-#include <linux/if_wanpipe_common.h> /* Wanpipe Socket */
-#include <linux/if_wanpipe.h>
-
-#include <linux/sdla_fr.h> /* frame relay firmware API definitions */
-
-#include <asm/uaccess.h>
-#include <linux/inetdevice.h>
-#include <linux/netdevice.h>
-
-#include <net/route.h> /* Dynamic Route Creation */
-#include <linux/etherdevice.h> /* eth_type_trans() used for bridging */
-#include <linux/random.h>
-
-/****** Defines & Macros ****************************************************/
-
-#define MAX_CMD_RETRY 10 /* max number of firmware retries */
-
-#define FR_HEADER_LEN 8 /* max encapsulation header size */
-#define FR_CHANNEL_MTU 1500 /* unfragmented logical channel MTU */
-
-/* Q.922 frame types */
-#define Q922_UI 0x03 /* Unnumbered Info frame */
-#define Q922_XID 0xAF
-
-/* DLCI configured or not */
-#define DLCI_NOT_CONFIGURED 0x00
-#define DLCI_CONFIG_PENDING 0x01
-#define DLCI_CONFIGURED 0x02
-
-/* CIR enabled or not */
-#define CIR_ENABLED 0x00
-#define CIR_DISABLED 0x01
-
-#define FRAME_RELAY_API 1
-#define MAX_BH_BUFF 10
-
-/* For handle_IPXWAN() */
-#define CVHexToAscii(b) (((unsigned char)(b) > (unsigned char)9) ? ((unsigned char)'A' + ((unsigned char)(b) - (unsigned char)10)) : ((unsigned char)'0' + (unsigned char)(b)))
-
-/****** Data Structures *****************************************************/
-
-/* This is an extention of the 'struct device' we create for each network
- * interface to keep the rest of channel-specific data.
- */
-typedef struct fr_channel
-{
- wanpipe_common_t common;
- char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */
- unsigned dlci_configured ; /* check whether configured or not */
- unsigned cir_status; /* check whether CIR enabled or not */
- unsigned dlci; /* logical channel number */
- unsigned cir; /* committed information rate */
- unsigned bc; /* committed burst size */
- unsigned be; /* excess burst size */
- unsigned mc; /* multicast support on or off */
- unsigned tx_int_status; /* Transmit Interrupt Status */
- unsigned short pkt_length; /* Packet Length */
- unsigned long router_start_time;/* Router start time in seconds */
- unsigned long tick_counter; /* counter for transmit time out */
- char dev_pending_devtint; /* interface pending dev_tint() */
- void *dlci_int_interface; /* pointer to the DLCI Interface */
- unsigned long IB_addr; /* physical address of Interface Byte */
- unsigned long state_tick; /* time of the last state change */
- unsigned char enable_IPX; /* Enable/Disable the use of IPX */
- unsigned long network_number; /* Internal Network Number for IPX*/
- sdla_t *card; /* -> owner */
- unsigned route_flag; /* Add/Rem dest addr in route tables */
- unsigned inarp; /* Inverse Arp Request status */
- long inarp_ready; /* Ready to send requests */
- int inarp_interval; /* Time between InArp Requests */
- unsigned long inarp_tick; /* InArp jiffies tick counter */
- long interface_down; /* Bring interface down on disconnect */
- struct net_device_stats ifstats; /* interface statistics */
- if_send_stat_t drvstats_if_send;
- rx_intr_stat_t drvstats_rx_intr;
- pipe_mgmt_stat_t drvstats_gen;
- unsigned long router_up_time;
-
- unsigned short transmit_length;
- struct sk_buff *delay_skb;
-
- bh_data_t *bh_head; /* Circular buffer for chdlc_bh */
- unsigned long tq_working;
- volatile int bh_write;
- volatile int bh_read;
- atomic_t bh_buff_used;
-
- /* Polling task queue. Each interface
- * has its own task queue, which is used
- * to defer events from the interrupt */
- struct work_struct fr_poll_work;
- struct timer_list fr_arp_timer;
-
- u32 ip_local;
- u32 ip_remote;
- long config_dlci;
- long unconfig_dlci;
-
- /* Whether this interface should be setup as a gateway.
- * Used by dynamic route setup code */
- u8 gateway;
-
- /* True interface type */
- u8 true_if_encoding;
- u8 fr_header[FR_HEADER_LEN];
- char fr_header_len;
-
-} fr_channel_t;
-
-/* Route Flag options */
-#define NO_ROUTE 0x00
-#define ADD_ROUTE 0x01
-#define ROUTE_ADDED 0x02
-#define REMOVE_ROUTE 0x03
-#define ARP_REQ 0x04
-
-/* inarp options */
-#define INARP_NONE 0x00
-#define INARP_REQUEST 0x01
-#define INARP_CONFIGURED 0x02
-
-/* reasons for enabling the timer interrupt on the adapter */
-#define TMR_INT_ENABLED_UDP 0x01
-#define TMR_INT_ENABLED_UPDATE 0x02
-#define TMR_INT_ENABLED_ARP 0x04
-#define TMR_INT_ENABLED_UPDATE_STATE 0x08
-#define TMR_INT_ENABLED_CONFIG 0x10
-#define TMR_INT_ENABLED_UNCONFIG 0x20
-
-
-typedef struct dlci_status
-{
- unsigned short dlci PACKED;
- unsigned char state PACKED;
-} dlci_status_t;
-
-typedef struct dlci_IB_mapping
-{
- unsigned short dlci PACKED;
- unsigned long addr_value PACKED;
-} dlci_IB_mapping_t;
-
-/* This structure is used for DLCI list Tx interrupt mode. It is used to
- enable interrupt bit and set the packet length for transmission
- */
-typedef struct fr_dlci_interface
-{
- unsigned char gen_interrupt PACKED;
- unsigned short packet_length PACKED;
- unsigned char reserved PACKED;
-} fr_dlci_interface_t;
-
-/* variable for keeping track of enabling/disabling FT1 monitor status */
-static int rCount = 0;
-
-extern void disable_irq(unsigned int);
-extern void enable_irq(unsigned int);
-
-/* variable for keeping track of number of interrupts generated during
- * interrupt test routine
- */
-static int Intr_test_counter;
-
-/****** Function Prototypes *************************************************/
-
-/* WAN link driver entry points. These are called by the WAN router module. */
-static int update(struct wan_device *wandev);
-static int new_if(struct wan_device *wandev, struct net_device *dev,
- wanif_conf_t *conf);
-static int del_if(struct wan_device *wandev, struct net_device *dev);
-static void disable_comm (sdla_t *card);
-
-/* WANPIPE-specific entry points */
-static int wpf_exec(struct sdla *card, void *u_cmd, void *u_data);
-
-/* Network device interface */
-static int if_init(struct net_device *dev);
-static int if_open(struct net_device *dev);
-static int if_close(struct net_device *dev);
-
-static void if_tx_timeout(struct net_device *dev);
-
-static int if_rebuild_hdr (struct sk_buff *skb);
-
-static int if_send(struct sk_buff *skb, struct net_device *dev);
-static int chk_bcast_mcast_addr(sdla_t *card, struct net_device* dev,
- struct sk_buff *skb);
-static struct net_device_stats *if_stats(struct net_device *dev);
-
-/* Interrupt handlers */
-static void fr_isr(sdla_t *card);
-static void rx_intr(sdla_t *card);
-static void tx_intr(sdla_t *card);
-static void timer_intr(sdla_t *card);
-static void spur_intr(sdla_t *card);
-
-/* Frame relay firmware interface functions */
-static int fr_read_version(sdla_t *card, char *str);
-static int fr_configure(sdla_t *card, fr_conf_t *conf);
-static int fr_dlci_configure(sdla_t *card, fr_dlc_conf_t *conf, unsigned dlci);
-static int fr_init_dlci (sdla_t *card, fr_channel_t *chan);
-static int fr_set_intr_mode (sdla_t *card, unsigned mode, unsigned mtu, unsigned short timeout);
-static int fr_comm_enable(sdla_t *card);
-static void fr_comm_disable(sdla_t *card);
-static int fr_get_err_stats(sdla_t *card);
-static int fr_get_stats(sdla_t *card);
-static int fr_add_dlci(sdla_t *card, int dlci);
-static int fr_activate_dlci(sdla_t *card, int dlci);
-static int fr_delete_dlci (sdla_t* card, int dlci);
-static int fr_issue_isf(sdla_t *card, int isf);
-static int fr_send(sdla_t *card, int dlci, unsigned char attr, int len,
- void *buf);
-static int fr_send_data_header(sdla_t *card, int dlci, unsigned char attr, int len,
- void *buf,unsigned char hdr_len);
-static unsigned int fr_send_hdr(sdla_t *card, int dlci, unsigned int offset);
-
-static int check_dlci_config (sdla_t *card, fr_channel_t *chan);
-static void initialize_rx_tx_buffers (sdla_t *card);
-
-
-/* Firmware asynchronous event handlers */
-static int fr_event(sdla_t *card, int event, fr_mbox_t *mbox);
-static int fr_modem_failure(sdla_t *card, fr_mbox_t *mbox);
-static int fr_dlci_change(sdla_t *card, fr_mbox_t *mbox);
-
-/* Miscellaneous functions */
-static int update_chan_state(struct net_device *dev);
-static void set_chan_state(struct net_device *dev, int state);
-static struct net_device *find_channel(sdla_t *card, unsigned dlci);
-static int is_tx_ready(sdla_t *card, fr_channel_t *chan);
-static unsigned int dec_to_uint(unsigned char *str, int len);
-static int reply_udp( unsigned char *data, unsigned int mbox_len );
-
-static int intr_test( sdla_t* card );
-static void init_chan_statistics( fr_channel_t* chan );
-static void init_global_statistics( sdla_t* card );
-static void read_DLCI_IB_mapping( sdla_t* card, fr_channel_t* chan );
-static int setup_for_delayed_transmit(struct net_device* dev,
- struct sk_buff *skb);
-
-struct net_device *move_dev_to_next(sdla_t *card, struct net_device *dev);
-static int check_tx_status(sdla_t *card, struct net_device *dev);
-
-/* Frame Relay Socket API */
-static void trigger_fr_bh (fr_channel_t *);
-static void fr_bh(struct net_device *dev);
-static int fr_bh_cleanup(struct net_device *dev);
-static int bh_enqueue(struct net_device *dev, struct sk_buff *skb);
-
-static void trigger_fr_poll(struct net_device *dev);
-static void fr_poll(struct net_device *dev);
-//static void add_gateway(struct net_device *dev);
-
-static void trigger_unconfig_fr(struct net_device *dev);
-static void unconfig_fr (sdla_t *);
-
-static void trigger_config_fr (sdla_t *);
-static void config_fr (sdla_t *);
-
-
-/* Inverse ARP and Dynamic routing functions */
-int process_ARP(arphdr_1490_t *ArpPacket, sdla_t *card, struct net_device *dev);
-int is_arp(void *buf);
-int send_inarp_request(sdla_t *card, struct net_device *dev);
-
-static void trigger_fr_arp(struct net_device *dev);
-static void fr_arp (unsigned long data);
-
-
-/* Udp management functions */
-static int process_udp_mgmt_pkt(sdla_t *card);
-static int udp_pkt_type( struct sk_buff *skb, sdla_t *card );
-static int store_udp_mgmt_pkt(int udp_type, char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, int dlci);
-
-/* IPX functions */
-static void switch_net_numbers(unsigned char *sendpacket,
- unsigned long network_number, unsigned char incoming);
-
-static int handle_IPXWAN(unsigned char *sendpacket, char *devname,
- unsigned char enable_IPX, unsigned long network_number);
-
-/* Lock Functions: SMP supported */
-void s508_s514_unlock(sdla_t *card, unsigned long *smp_flags);
-void s508_s514_lock(sdla_t *card, unsigned long *smp_flags);
-
-unsigned short calc_checksum (char *, int);
-static int setup_fr_header(struct sk_buff *skb,
- struct net_device* dev, char op_mode);
-
-
-/****** Public Functions ****************************************************/
-
-/*============================================================================
- * Frame relay protocol initialization routine.
- *
- * This routine is called by the main WANPIPE module during setup. At this
- * point adapter is completely initialized and firmware is running.
- * o read firmware version (to make sure it's alive)
- * o configure adapter
- * o initialize protocol-specific fields of the adapter data space.
- *
- * Return: 0 o.k.
- * < 0 failure.
- */
-int wpf_init(sdla_t *card, wandev_conf_t *conf)
-{
-
- int err;
- fr508_flags_t* flags;
-
- union
- {
- char str[80];
- fr_conf_t cfg;
- } u;
-
- fr_buf_info_t* buf_info;
- int i;
-
-
- printk(KERN_INFO "\n");
-
- /* Verify configuration ID */
- if (conf->config_id != WANCONFIG_FR) {
-
- printk(KERN_INFO "%s: invalid configuration ID %u!\n",
- card->devname, conf->config_id);
- return -EINVAL;
-
- }
-
- /* Initialize protocol-specific fields of adapter data space */
- switch (card->hw.fwid) {
-
- case SFID_FR508:
- card->mbox = (void*)(card->hw.dpmbase +
- FR508_MBOX_OFFS);
- card->flags = (void*)(card->hw.dpmbase +
- FR508_FLAG_OFFS);
- if(card->hw.type == SDLA_S514) {
- card->mbox += FR_MB_VECTOR;
- card->flags += FR_MB_VECTOR;
- }
- card->isr = &fr_isr;
- break;
-
- default:
- return -EINVAL;
- }
-
- flags = card->flags;
-
- /* Read firmware version. Note that when adapter initializes, it
- * clears the mailbox, so it may appear that the first command was
- * executed successfully when in fact it was merely erased. To work
- * around this, we execute the first command twice.
- */
-
- if (fr_read_version(card, NULL) || fr_read_version(card, u.str))
- return -EIO;
-
- printk(KERN_INFO "%s: running frame relay firmware v%s\n",
- card->devname, u.str);
-
- /* Adjust configuration */
- conf->mtu += FR_HEADER_LEN;
- conf->mtu = (conf->mtu >= MIN_LGTH_FR_DATA_CFG) ?
- min_t(unsigned int, conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) :
- FR_CHANNEL_MTU + FR_HEADER_LEN;
-
- conf->bps = min_t(unsigned int, conf->bps, 2048000);
-
- /* Initialze the configuration structure sent to the board to zero */
- memset(&u.cfg, 0, sizeof(u.cfg));
-
- memset(card->u.f.dlci_to_dev_map, 0, sizeof(card->u.f.dlci_to_dev_map));
-
- /* Configure adapter firmware */
-
- u.cfg.mtu = conf->mtu;
- u.cfg.kbps = conf->bps / 1000;
-
- u.cfg.cir_fwd = u.cfg.cir_bwd = 16;
- u.cfg.bc_fwd = u.cfg.bc_bwd = 16;
-
- u.cfg.options = 0x0000;
- printk(KERN_INFO "%s: Global CIR enabled by Default\n", card->devname);
-
- switch (conf->u.fr.signalling) {
-
- case WANOPT_FR_ANSI:
- u.cfg.options = 0x0000;
- break;
-
- case WANOPT_FR_Q933:
- u.cfg.options |= 0x0200;
- break;
-
- case WANOPT_FR_LMI:
- u.cfg.options |= 0x0400;
- break;
-
- case WANOPT_NO:
- u.cfg.options |= 0x0800;
- break;
- default:
- printk(KERN_INFO "%s: Illegal Signalling option\n",
- card->wandev.name);
- return -EINVAL;
- }
-
-
- card->wandev.signalling = conf->u.fr.signalling;
-
- if (conf->station == WANOPT_CPE) {
-
-
- if (conf->u.fr.signalling == WANOPT_NO){
- printk(KERN_INFO
- "%s: ERROR - For NO signalling, station must be set to Node!",
- card->devname);
- return -EINVAL;
- }
-
- u.cfg.station = 0;
- u.cfg.options |= 0x8000; /* auto config DLCI */
- card->u.f.dlci_num = 0;
-
- } else {
-
- u.cfg.station = 1; /* switch emulation mode */
-
- /* For switch emulation we have to create a list of dlci(s)
- * that will be sent to be global SET_DLCI_CONFIGURATION
- * command in fr_configure() routine.
- */
-
- card->u.f.dlci_num = min_t(unsigned int, max_t(unsigned int, conf->u.fr.dlci_num, 1), 100);
-
- for ( i = 0; i < card->u.f.dlci_num; i++) {
-
- card->u.f.node_dlci[i] = (unsigned short)
- conf->u.fr.dlci[i] ? conf->u.fr.dlci[i] : 16;
-
- }
- }
-
- if (conf->clocking == WANOPT_INTERNAL)
- u.cfg.port |= 0x0001;
-
- if (conf->interface == WANOPT_RS232)
- u.cfg.port |= 0x0002;
-
- if (conf->u.fr.t391)
- u.cfg.t391 = min_t(unsigned int, conf->u.fr.t391, 30);
- else
- u.cfg.t391 = 5;
-
- if (conf->u.fr.t392)
- u.cfg.t392 = min_t(unsigned int, conf->u.fr.t392, 30);
- else
- u.cfg.t392 = 15;
-
- if (conf->u.fr.n391)
- u.cfg.n391 = min_t(unsigned int, conf->u.fr.n391, 255);
- else
- u.cfg.n391 = 2;
-
- if (conf->u.fr.n392)
- u.cfg.n392 = min_t(unsigned int, conf->u.fr.n392, 10);
- else
- u.cfg.n392 = 3;
-
- if (conf->u.fr.n393)
- u.cfg.n393 = min_t(unsigned int, conf->u.fr.n393, 10);
- else
- u.cfg.n393 = 4;
-
- if (fr_configure(card, &u.cfg))
- return -EIO;
-
- if (card->hw.type == SDLA_S514) {
-
- buf_info = (void*)(card->hw.dpmbase + FR_MB_VECTOR +
- FR508_RXBC_OFFS);
-
- card->rxmb = (void*)(buf_info->rse_next + card->hw.dpmbase);
-
- card->u.f.rxmb_base =
- (void*)(buf_info->rse_base + card->hw.dpmbase);
-
- card->u.f.rxmb_last =
- (void*)(buf_info->rse_base +
- (buf_info->rse_num - 1) * sizeof(fr_rx_buf_ctl_t) +
- card->hw.dpmbase);
- }else{
- buf_info = (void*)(card->hw.dpmbase + FR508_RXBC_OFFS);
-
- card->rxmb = (void*)(buf_info->rse_next -
- FR_MB_VECTOR + card->hw.dpmbase);
-
- card->u.f.rxmb_base =
- (void*)(buf_info->rse_base -
- FR_MB_VECTOR + card->hw.dpmbase);
-
- card->u.f.rxmb_last =
- (void*)(buf_info->rse_base +
- (buf_info->rse_num - 1) * sizeof(fr_rx_buf_ctl_t) -
- FR_MB_VECTOR + card->hw.dpmbase);
- }
-
- card->u.f.rx_base = buf_info->buf_base;
- card->u.f.rx_top = buf_info->buf_top;
-
- card->u.f.tx_interrupts_pending = 0;
-
- card->wandev.mtu = conf->mtu;
- card->wandev.bps = conf->bps;
- card->wandev.interface = conf->interface;
- card->wandev.clocking = conf->clocking;
- card->wandev.station = conf->station;
- card->poll = NULL;
- card->exec = &wpf_exec;
- card->wandev.update = &update;
- card->wandev.new_if = &new_if;
- card->wandev.del_if = &del_if;
- card->wandev.state = WAN_DISCONNECTED;
- card->wandev.ttl = conf->ttl;
- card->wandev.udp_port = conf->udp_port;
- card->disable_comm = &disable_comm;
- card->u.f.arp_dev = NULL;
-
- /* Intialize global statistics for a card */
- init_global_statistics( card );
-
- card->TracingEnabled = 0;
-
- /* Interrupt Test */
- Intr_test_counter = 0;
- card->intr_mode = INTR_TEST_MODE;
- err = intr_test( card );
-
- printk(KERN_INFO "%s: End of Interrupt Test rc=0x%x count=%i\n",
- card->devname,err,Intr_test_counter);
-
- if (err || (Intr_test_counter < MAX_INTR_TEST_COUNTER)) {
- printk(KERN_ERR "%s: Interrupt Test Failed, Counter: %i\n",
- card->devname, Intr_test_counter);
- printk(KERN_ERR "Please choose another interrupt\n");
- err = -EIO;
- return err;
- }
-
- printk(KERN_INFO "%s: Interrupt Test Passed, Counter: %i\n",
- card->devname, Intr_test_counter);
-
-
- /* Apr 28 2000. Nenad Corbic
- * Enable commnunications here, not in if_open or new_if, since
- * interfaces come down when the link is disconnected.
- */
-
- /* If you enable comms and then set ints, you get a Tx int as you
- * perform the SET_INT_TRIGGERS command. So, we only set int
- * triggers and then adjust the interrupt mask (to disable Tx ints)
- * before enabling comms.
- */
- if (fr_set_intr_mode(card, (FR_INTR_RXRDY | FR_INTR_TXRDY |
- FR_INTR_DLC | FR_INTR_TIMER | FR_INTR_TX_MULT_DLCIs) ,
- card->wandev.mtu, 0)) {
- return -EIO;
- }
-
- flags->imask &= ~(FR_INTR_TXRDY | FR_INTR_TIMER);
-
- if (fr_comm_enable(card)) {
- return -EIO;
- }
- wanpipe_set_state(card, WAN_CONNECTED);
- spin_lock_init(&card->u.f.if_send_lock);
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-/******* WAN Device Driver Entry Points *************************************/
-
-/*============================================================================
- * Update device status & statistics.
- */
-static int update(struct wan_device* wandev)
-{
- volatile sdla_t* card;
- unsigned long timeout;
- fr508_flags_t* flags;
-
- /* sanity checks */
- if ((wandev == NULL) || (wandev->private == NULL))
- return -EFAULT;
-
- if (wandev->state == WAN_UNCONFIGURED)
- return -ENODEV;
-
- card = wandev->private;
- flags = card->flags;
-
-
- card->u.f.update_comms_stats = 1;
- card->u.f.timer_int_enabled |= TMR_INT_ENABLED_UPDATE;
- flags->imask |= FR_INTR_TIMER;
- timeout = jiffies;
- for(;;) {
- if(card->u.f.update_comms_stats == 0)
- break;
- if (time_after(jiffies, timeout + 1 * HZ)){
- card->u.f.update_comms_stats = 0;
- return -EAGAIN;
- }
- }
-
- return 0;
-}
-
-/*============================================================================
- * Create new logical channel.
- * This routine is called by the router when ROUTER_IFNEW IOCTL is being
- * handled.
- * o parse media- and hardware-specific configuration
- * o make sure that a new channel can be created
- * o allocate resources, if necessary
- * o prepare network device structure for registaration.
- *
- * Return: 0 o.k.
- * < 0 failure (channel will not be created)
- */
-static int new_if(struct wan_device* wandev, struct net_device* dev,
- wanif_conf_t* conf)
-{
- sdla_t* card = wandev->private;
- fr_channel_t* chan;
- int dlci = 0;
- int err = 0;
-
-
- if ((conf->name[0] == '\0') || (strlen(conf->name) > WAN_IFNAME_SZ)) {
-
- printk(KERN_INFO "%s: Invalid interface name!\n",
- card->devname);
- return -EINVAL;
- }
-
- /* allocate and initialize private data */
- chan = kmalloc(sizeof(fr_channel_t), GFP_KERNEL);
-
- if (chan == NULL)
- return -ENOMEM;
-
- memset(chan, 0, sizeof(fr_channel_t));
- strcpy(chan->name, conf->name);
- chan->card = card;
-
- /* verify media address */
- if (isdigit(conf->addr[0])) {
-
- dlci = dec_to_uint(conf->addr, 0);
-
- if (dlci && (dlci <= HIGHEST_VALID_DLCI)) {
-
- chan->dlci = dlci;
-
- } else {
-
- printk(KERN_ERR
- "%s: Invalid DLCI %u on interface %s!\n",
- wandev->name, dlci, chan->name);
- err = -EINVAL;
- }
-
- } else {
- printk(KERN_ERR
- "%s: Invalid media address on interface %s!\n",
- wandev->name, chan->name);
- err = -EINVAL;
- }
-
- if ((chan->true_if_encoding = conf->true_if_encoding) == WANOPT_YES){
- printk(KERN_INFO
- "%s: Enabling, true interface type encoding.\n",
- card->devname);
- }
-
-
-
- /* Setup wanpipe as a router (WANPIPE) even if it is
- * a bridged DLCI, or as an API
- */
- if (strcmp(conf->usedby, "WANPIPE") == 0 ||
- strcmp(conf->usedby, "BRIDGE") == 0 ||
- strcmp(conf->usedby, "BRIDGE_N") == 0){
-
- if(strcmp(conf->usedby, "WANPIPE") == 0){
- chan->common.usedby = WANPIPE;
-
- printk(KERN_INFO "%s: Running in WANPIPE mode.\n",
- card->devname);
-
- }else if(strcmp(conf->usedby, "BRIDGE") == 0){
-
- chan->common.usedby = BRIDGE;
-
- printk(KERN_INFO "%s: Running in WANPIPE (BRIDGE) mode.\n",
- card->devname);
- }else if( strcmp(conf->usedby, "BRIDGE_N") == 0 ){
-
- chan->common.usedby = BRIDGE_NODE;
-
- printk(KERN_INFO "%s: Running in WANPIPE (BRIDGE_NODE) mode.\n",
- card->devname);
- }
-
- if (!err){
- /* Dynamic interface configuration option.
- * On disconnect, if the options is selected,
- * the interface will be brought down */
- if (conf->if_down == WANOPT_YES){
- set_bit(DYN_OPT_ON,&chan->interface_down);
- printk(KERN_INFO
- "%s: Dynamic interface configuration enabled.\n",
- card->devname);
- }
- }
-
- } else if(strcmp(conf->usedby, "API") == 0){
-
- chan->common.usedby = API;
- printk(KERN_INFO "%s: Running in API mode.\n",
- wandev->name);
- }
-
- if (err) {
-
- kfree(chan);
- return err;
- }
-
- /* place cir,be,bc and other channel specific information into the
- * chan structure
- */
- if (conf->cir) {
-
- chan->cir = max_t(unsigned int, 1,
- min_t(unsigned int, conf->cir, 512));
- chan->cir_status = CIR_ENABLED;
-
-
- /* If CIR is enabled, force BC to equal CIR
- * this solves number of potential problems if CIR is
- * set and BC is not
- */
- chan->bc = chan->cir;
-
- if (conf->be){
- chan->be = max_t(unsigned int,
- 0, min_t(unsigned int, conf->be, 511));
- }else{
- conf->be = 0;
- }
-
- printk (KERN_INFO "%s: CIR enabled for DLCI %i \n",
- wandev->name,chan->dlci);
- printk (KERN_INFO "%s: CIR = %i ; BC = %i ; BE = %i\n",
- wandev->name,chan->cir,chan->bc,chan->be);
-
-
- }else{
- chan->cir_status = CIR_DISABLED;
- printk (KERN_INFO "%s: CIR disabled for DLCI %i\n",
- wandev->name,chan->dlci);
- }
-
- chan->mc = conf->mc;
-
- if (conf->inarp == WANOPT_YES){
- printk(KERN_INFO "%s: Inverse ARP Support Enabled\n",card->devname);
- chan->inarp = conf->inarp ? INARP_REQUEST : INARP_NONE;
- chan->inarp_interval = conf->inarp_interval ? conf->inarp_interval : 10;
- }else{
- printk(KERN_INFO "%s: Inverse ARP Support Disabled\n",card->devname);
- chan->inarp = INARP_NONE;
- chan->inarp_interval = 10;
- }
-
-
- chan->dlci_configured = DLCI_NOT_CONFIGURED;
-
-
- /*FIXME: IPX disabled in this WANPIPE version */
- if (conf->enable_IPX == WANOPT_YES){
- printk(KERN_INFO "%s: ERROR - This version of WANPIPE doesn't support IPX\n",
- card->devname);
- kfree(chan);
- return -EINVAL;
- }else{
- chan->enable_IPX = WANOPT_NO;
- }
-
- if (conf->network_number){
- chan->network_number = conf->network_number;
- }else{
- chan->network_number = 0xDEADBEEF;
- }
-
- chan->route_flag = NO_ROUTE;
-
- init_chan_statistics(chan);
-
- chan->transmit_length = 0;
-
- /* prepare network device data space for registration */
- strcpy(dev->name,chan->name);
-
- dev->init = &if_init;
- dev->priv = chan;
-
- /* Initialize FR Polling Task Queue
- * We need a poll routine for each network
- * interface.
- */
- INIT_WORK(&chan->fr_poll_work, (void *)fr_poll, dev);
-
- init_timer(&chan->fr_arp_timer);
- chan->fr_arp_timer.data=(unsigned long)dev;
- chan->fr_arp_timer.function = fr_arp;
-
- wandev->new_if_cnt++;
-
- /* Tells us that if this interface is a
- * gateway or not */
- if ((chan->gateway = conf->gateway) == WANOPT_YES){
- printk(KERN_INFO "%s: Interface %s is set as a gateway.\n",
- card->devname,dev->name);
- }
-
- /* M. Grant Patch Apr 28 2000
- * Disallow duplicate dlci configurations. */
- if (card->u.f.dlci_to_dev_map[chan->dlci] != NULL) {
- kfree(chan);
- return -EBUSY;
- }
-
- /* Configure this dlci at a later date, when
- * the interface comes up. i.e. when if_open()
- * executes */
- set_bit(0,&chan->config_dlci);
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-/*============================================================================
- * Delete logical channel.
- */
-static int del_if(struct wan_device* wandev, struct net_device* dev)
-{
- fr_channel_t* chan = dev->priv;
- unsigned long smp_flags=0;
-
- /* This interface is dead, make sure the
- * ARP timer is stopped */
- del_timer(&chan->fr_arp_timer);
-
- /* If we are a NODE, we must unconfigure this DLCI
- * Trigger an unconfigure command that will
- * be executed in timer interrupt. We must wait
- * for the command to complete. */
- trigger_unconfig_fr(dev);
-
- lock_adapter_irq(&wandev->lock, &smp_flags);
- wandev->new_if_cnt--;
- unlock_adapter_irq(&wandev->lock, &smp_flags);
-
- return 0;
-}
-
-
-/*=====================================================================
- * disable_comm
- *
- * Description:
- * Disable communications.
- * This code runs in shutdown (sdlamain.c)
- * under critical flag. Therefore it is not
- * necessary to set a critical flag here
- *
- * Usage:
- * Commnunications are disabled only on a card
- * shutdown.
- */
-
-static void disable_comm (sdla_t *card)
-{
- printk(KERN_INFO "%s: Disabling Communications!\n",
- card->devname);
- fr_comm_disable(card);
-}
-
-/****** WANPIPE-specific entry points ***************************************/
-
-/*============================================================================
- * Execute adapter interface command.
- */
-static int wpf_exec (struct sdla* card, void* u_cmd, void* u_data)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err, len;
- fr_cmd_t cmd;
-
- if(copy_from_user((void*)&cmd, u_cmd, sizeof(cmd)))
- return -EFAULT;
-
- /* execute command */
- do
- {
- memcpy(&mbox->cmd, &cmd, sizeof(cmd));
-
- if (cmd.length){
- if( copy_from_user((void*)&mbox->data, u_data, cmd.length))
- return -EFAULT;
- }
-
- if (sdla_exec(mbox))
- err = mbox->cmd.result;
-
- else return -EIO;
-
- } while (err && retry-- && fr_event(card, err, mbox));
-
- /* return result */
- if (copy_to_user(u_cmd, (void*)&mbox->cmd, sizeof(fr_cmd_t)))
- return -EFAULT;
-
- len = mbox->cmd.length;
-
- if (len && u_data && !copy_to_user(u_data, (void*)&mbox->data, len))
- return -EFAULT;
- return 0;
-}
-
-/****** Network Device Interface ********************************************/
-
-/*============================================================================
- * Initialize Linux network interface.
- *
- * This routine is called only once for each interface, during Linux network
- * interface registration. Returning anything but zero will fail interface
- * registration.
- */
-static int if_init(struct net_device* dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- struct wan_device* wandev = &card->wandev;
-
- /* Initialize device driver entry points */
- dev->open = &if_open;
- dev->stop = &if_close;
- dev->hard_header = NULL;
- dev->rebuild_header = &if_rebuild_hdr;
- dev->hard_start_xmit = &if_send;
- dev->get_stats = &if_stats;
- dev->tx_timeout = &if_tx_timeout;
- dev->watchdog_timeo = TX_TIMEOUT;
-
- if (chan->common.usedby == WANPIPE || chan->common.usedby == API){
-
- /* Initialize media-specific parameters */
- if (chan->true_if_encoding){
- dev->type = ARPHRD_DLCI; /* This breaks tcpdump */
- }else{
- dev->type = ARPHRD_PPP; /* ARP h/w type */
- }
-
- dev->flags |= IFF_POINTOPOINT;
- dev->flags |= IFF_NOARP;
-
- /* Enable Multicast addressing */
- if (chan->mc == WANOPT_YES){
- dev->flags |= IFF_MULTICAST;
- }
-
- dev->mtu = wandev->mtu - FR_HEADER_LEN;
- /* For an API, the maximum number of bytes that the stack will pass
- to the driver is (dev->mtu + dev->hard_header_len). So, adjust the
- mtu so that a frame of maximum size can be transmitted by the API.
- */
- if(chan->common.usedby == API) {
- dev->mtu += (sizeof(api_tx_hdr_t) - FR_HEADER_LEN);
- }
-
- dev->hard_header_len = FR_HEADER_LEN;/* media header length */
- dev->addr_len = 2; /* hardware address length */
- *(unsigned short*)dev->dev_addr = htons(chan->dlci);
-
- /* Set transmit buffer queue length */
- dev->tx_queue_len = 100;
-
- }else{
-
- /* Setup the interface for Bridging */
- int hw_addr=0;
- ether_setup(dev);
-
- /* Use a random number to generate the MAC address */
- memcpy(dev->dev_addr, "\xFE\xFC\x00\x00\x00\x00", 6);
- get_random_bytes(&hw_addr, sizeof(hw_addr));
- *(int *)(dev->dev_addr + 2) += hw_addr;
- }
-
- /* Initialize hardware parameters (just for reference) */
- dev->irq = wandev->irq;
- dev->dma = wandev->dma;
- dev->base_addr = wandev->ioport;
- dev->mem_start = wandev->maddr;
- dev->mem_end = wandev->maddr + wandev->msize - 1;
- SET_MODULE_OWNER(dev);
-
- return 0;
-}
-
-/*============================================================================
- * Open network interface.
- * o if this is the first open, then enable communications and interrupts.
- * o prevent module from unloading by incrementing use count
- *
- * Return 0 if O.k. or errno.
- */
-static int if_open(struct net_device* dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- int err = 0;
- struct timeval tv;
-
- if (netif_running(dev))
- return -EBUSY;
-
- /* Initialize the task queue */
- chan->tq_working=0;
-
- INIT_WORK(&chan->common.wanpipe_work, (void *)fr_bh, dev);
-
- /* Allocate and initialize BH circular buffer */
- chan->bh_head = kmalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC);
- memset(chan->bh_head,0,(sizeof(bh_data_t)*MAX_BH_BUFF));
- atomic_set(&chan->bh_buff_used, 0);
-
- netif_start_queue(dev);
-
- wanpipe_open(card);
- do_gettimeofday( &tv );
- chan->router_start_time = tv.tv_sec;
-
- if (test_bit(0,&chan->config_dlci)){
- trigger_config_fr (card);
- }else if (chan->inarp == INARP_REQUEST){
- trigger_fr_arp(dev);
- }
-
- return err;
-}
-
-/*============================================================================
- * Close network interface.
- * o if this is the last open, then disable communications and interrupts.
- * o reset flags.
- */
-static int if_close(struct net_device* dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
-
- if (chan->inarp == INARP_CONFIGURED) {
- chan->inarp = INARP_REQUEST;
- }
-
- netif_stop_queue(dev);
- wanpipe_close(card);
-
- return 0;
-}
-
-/*============================================================================
- * Re-build media header.
- *
- * Return: 1 physical address resolved.
- * 0 physical address not resolved
- */
-static int if_rebuild_hdr (struct sk_buff* skb)
-{
- struct net_device *dev = skb->dev;
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
-
- printk(KERN_INFO "%s: rebuild_header() called for interface %s!\n",
- card->devname, dev->name);
- return 1;
-}
-
-/*============================================================================
- * Handle transmit timeout event from netif watchdog
- */
-static void if_tx_timeout(struct net_device *dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
- /* If our device stays busy for at least 5 seconds then we will
- * kick start the device by making dev->tbusy = 0. We expect
- * that our device never stays busy more than 5 seconds. So this
- * is only used as a last resort.
- */
-
- chan->drvstats_if_send.if_send_tbusy++;
- ++chan->ifstats.collisions;
-
- printk (KERN_INFO "%s: Transmit timed out on %s\n",
- card->devname, dev->name);
- chan->drvstats_if_send.if_send_tbusy_timeout++;
- netif_wake_queue (dev);
-
-}
-
-
-/*============================================================================
- * Send a packet on a network interface.
- * o set tbusy flag (marks start of the transmission) to block a timer-based
- * transmit from overlapping.
- * o set critical flag when accessing board.
- * o check link state. If link is not up, then drop the packet.
- * o check channel status. If it's down then initiate a call.
- * o pass a packet to corresponding WAN device.
- * o free socket buffer
- *
- * Return: 0 complete (socket buffer must be freed)
- * non-0 packet may be re-transmitted (tbusy must be set)
- *
- * Notes:
- * 1. This routine is called either by the protocol stack or by the "net
- * bottom half" (with interrupts enabled).
- *
- * 2. Using netif_start_queue() and netif_stop_queue()
- * will inhibit further transmit requests from the protocol stack
- * and can be used for flow control with protocol layer.
- */
-static int if_send(struct sk_buff* skb, struct net_device* dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- int err;
- unsigned char *sendpacket;
- fr508_flags_t* adptr_flags = card->flags;
- int udp_type;
- long delay_tx_queued = 0;
- unsigned long smp_flags=0;
- unsigned char attr = 0;
-
- chan->drvstats_if_send.if_send_entry++;
-
- netif_stop_queue(dev);
-
- if (skb == NULL) {
- /* if we get here, some higher layer thinks we've missed an
- * tx-done interrupt.
- */
- printk(KERN_INFO "%s: interface %s got kicked!\n",
- card->devname, dev->name);
- chan->drvstats_if_send.if_send_skb_null ++;
-
- netif_wake_queue(dev);
- return 0;
- }
-
- /* If a peripheral task is running just drop packets */
- if (test_bit(PERI_CRIT, &card->wandev.critical)){
-
- printk(KERN_INFO "%s: Critical in if_send(): Peripheral running!\n",
- card->devname);
-
- dev_kfree_skb_any(skb);
- netif_start_queue(dev);
- return 0;
- }
-
- /* We must set the 'tbusy' flag if we already have a packet queued for
- transmission in the transmit interrupt handler. However, we must
- ensure that the transmit interrupt does not reset the 'tbusy' flag
- just before we set it, as this will result in a "transmit timeout".
- */
- set_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical);
- if(chan->transmit_length) {
- netif_stop_queue(dev);
- chan->tick_counter = jiffies;
- clear_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical);
- return 1;
- }
- clear_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical);
-
- /* Move the if_header() code to here. By inserting frame
- * relay header in if_header() we would break the
- * tcpdump and other packet sniffers */
- chan->fr_header_len = setup_fr_header(skb,dev,chan->common.usedby);
- if (chan->fr_header_len < 0 ){
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
-
- dev_kfree_skb_any(skb);
- netif_start_queue(dev);
- return 0;
- }
-
- sendpacket = skb->data;
-
- udp_type = udp_pkt_type(skb, card);
-
- if(udp_type != UDP_INVALID_TYPE) {
- if(store_udp_mgmt_pkt(udp_type, UDP_PKT_FRM_STACK, card, skb,
- chan->dlci)) {
- adptr_flags->imask |= FR_INTR_TIMER;
- if (udp_type == UDP_FPIPE_TYPE){
- chan->drvstats_if_send.
- if_send_PIPE_request ++;
- }
- }
- netif_start_queue(dev);
- return 0;
- }
-
- //FIXME: can we do better than sendpacket[2]?
- if ((chan->common.usedby == WANPIPE) && (sendpacket[2] == 0x45)) {
-
- /* check to see if the source IP address is a broadcast or */
- /* multicast IP address */
- if(chk_bcast_mcast_addr(card, dev, skb)){
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- dev_kfree_skb_any(skb);
- netif_start_queue(dev);
- return 0;
- }
- }
-
-
- /* Lock the S514/S508 card: SMP Supported */
- s508_s514_lock(card,&smp_flags);
-
- if (test_and_set_bit(SEND_CRIT, (void*)&card->wandev.critical)) {
-
- chan->drvstats_if_send.if_send_critical_non_ISR ++;
- chan->ifstats.tx_dropped ++;
- printk(KERN_INFO "%s Critical in IF_SEND: if_send() already running!\n",
- card->devname);
- goto if_send_start_and_exit;
- }
-
- /* API packet check: minimum packet size must be greater than
- * 16 byte API header */
- if((chan->common.usedby == API) && (skb->len <= sizeof(api_tx_hdr_t))) {
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
-
-
- goto if_send_start_and_exit;
-
- }else{
- /* During API transmission, get rid of the API header */
- if (chan->common.usedby == API) {
- api_tx_hdr_t* api_tx_hdr;
- api_tx_hdr = (api_tx_hdr_t*)&skb->data[0x00];
- attr = api_tx_hdr->attr;
- skb_pull(skb,sizeof(api_tx_hdr_t));
- }
- }
-
- if (card->wandev.state != WAN_CONNECTED) {
- chan->drvstats_if_send.if_send_wan_disconnected ++;
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
-
- } else if (chan->common.state != WAN_CONNECTED) {
- chan->drvstats_if_send.if_send_dlci_disconnected ++;
-
- /* Update the DLCI state in timer interrupt */
- card->u.f.timer_int_enabled |= TMR_INT_ENABLED_UPDATE_STATE;
- adptr_flags->imask |= FR_INTR_TIMER;
-
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
-
- } else if (!is_tx_ready(card, chan)) {
- /* No tx buffers available, store for delayed transmit */
- if (!setup_for_delayed_transmit(dev, skb)){
- set_bit(1,&delay_tx_queued);
- }
- chan->drvstats_if_send.if_send_no_bfrs++;
-
- } else if (!skb->protocol) {
- /* No protocols drop packet */
- chan->drvstats_if_send.if_send_protocol_error ++;
- ++card->wandev.stats.tx_errors;
-
- } else if (test_bit(ARP_CRIT,&card->wandev.critical)){
- /* We are trying to send an ARP Packet, block IP data until
- * ARP is sent */
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
-
- } else {
- //FIXME: IPX is not implemented in this version of Frame Relay ?
- if((chan->common.usedby == WANPIPE) &&
- sendpacket[1] == 0x00 &&
- sendpacket[2] == 0x80 &&
- sendpacket[6] == 0x81 &&
- sendpacket[7] == 0x37) {
-
- if( chan->enable_IPX ) {
- switch_net_numbers(sendpacket,
- chan->network_number, 0);
- } else {
- //FIXME: Take this out when IPX is fixed
- printk(KERN_INFO
- "%s: WARNING: Unsupported IPX data in send, packet dropped\n",
- card->devname);
- }
-
- }else{
- err = fr_send_data_header(card, chan->dlci, attr, skb->len, skb->data, chan->fr_header_len);
- if (err) {
- switch(err) {
- case FRRES_CIR_OVERFLOW:
- case FRRES_BUFFER_OVERFLOW:
- if (!setup_for_delayed_transmit(dev, skb)){
- set_bit(1,&delay_tx_queued);
- }
- chan->drvstats_if_send.
- if_send_adptr_bfrs_full ++;
- break;
-
- case FRRES_TOO_LONG:
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Error: Frame too long, transmission failed %i\n",
- card->devname, (unsigned int)skb->len);
- }
- /* Drop down to default */
- default:
- chan->drvstats_if_send.
- if_send_dlci_disconnected ++;
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- break;
- }
- } else {
- chan->drvstats_if_send.
- if_send_bfr_passed_to_adptr++;
- ++chan->ifstats.tx_packets;
- ++card->wandev.stats.tx_packets;
-
- chan->ifstats.tx_bytes += skb->len;
- card->wandev.stats.tx_bytes += skb->len;
- dev->trans_start = jiffies;
- }
- }
- }
-
-if_send_start_and_exit:
-
- netif_start_queue(dev);
-
- /* If we queued the packet for transmission, we must not
- * deallocate it. The packet is unlinked from the IP stack
- * not copied. Therefore, we must keep the original packet */
- if (!test_bit(1,&delay_tx_queued)) {
- dev_kfree_skb_any(skb);
- }else{
- adptr_flags->imask |= FR_INTR_TXRDY;
- card->u.f.tx_interrupts_pending ++;
- }
-
- clear_bit(SEND_CRIT, (void*)&card->wandev.critical);
-
- s508_s514_unlock(card,&smp_flags);
-
- return 0;
-}
-
-
-
-/*============================================================================
- * Setup so that a frame can be transmitted on the occurrence of a transmit
- * interrupt.
- */
-static int setup_for_delayed_transmit(struct net_device* dev,
- struct sk_buff *skb)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- fr_dlci_interface_t* dlci_interface;
- int len = skb->len;
-
- /* Check that the dlci is properly configured,
- * before using tx interrupt */
- if (!chan->dlci_int_interface){
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: ERROR on DLCI %i: Not configured properly !\n",
- card->devname, chan->dlci);
- printk(KERN_INFO "%s: Please contact Sangoma Technologies\n",
- card->devname);
- }
- return 1;
- }
-
- dlci_interface = chan->dlci_int_interface;
-
- if(chan->transmit_length) {
- printk(KERN_INFO "%s: Big mess in setup_for_del...\n",
- card->devname);
- return 1;
- }
-
- if(len > FR_MAX_NO_DATA_BYTES_IN_FRAME) {
- //FIXME: increment some statistic */
- return 1;
- }
-
- chan->transmit_length = len;
- chan->delay_skb = skb;
-
- dlci_interface->gen_interrupt |= FR_INTR_TXRDY;
- dlci_interface->packet_length = len;
-
- /* Turn on TX interrupt at the end of if_send */
- return 0;
-}
-
-
-/*============================================================================
- * Check to see if the packet to be transmitted contains a broadcast or
- * multicast source IP address.
- * Return 0 if not broadcast/multicast address, otherwise return 1.
- */
-
-static int chk_bcast_mcast_addr(sdla_t *card, struct net_device* dev,
- struct sk_buff *skb)
-{
- u32 src_ip_addr;
- u32 broadcast_ip_addr = 0;
- struct in_device *in_dev;
- fr_channel_t* chan = dev->priv;
-
- /* read the IP source address from the outgoing packet */
- src_ip_addr = *(u32 *)(skb->data + 14);
-
- /* read the IP broadcast address for the device */
- in_dev = dev->ip_ptr;
- if(in_dev != NULL) {
- struct in_ifaddr *ifa= in_dev->ifa_list;
- if(ifa != NULL)
- broadcast_ip_addr = ifa->ifa_broadcast;
- else
- return 0;
- }
-
- /* check if the IP Source Address is a Broadcast address */
- if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) {
- printk(KERN_INFO
- "%s: Broadcast Source Address silently discarded\n",
- card->devname);
- return 1;
- }
-
- /* check if the IP Source Address is a Multicast address */
- if((chan->mc == WANOPT_NO) && (ntohl(src_ip_addr) >= 0xE0000001) &&
- (ntohl(src_ip_addr) <= 0xFFFFFFFE)) {
- printk(KERN_INFO
- "%s: Multicast Source Address silently discarded\n",
- card->devname);
- return 1;
- }
-
- return 0;
-}
-
-/*============================================================================
- * Reply to UDP Management system.
- * Return nothing.
- */
-static int reply_udp( unsigned char *data, unsigned int mbox_len )
-{
- unsigned short len, udp_length, temp, ip_length;
- unsigned long ip_temp;
- int even_bound = 0;
-
-
- fr_udp_pkt_t *fr_udp_pkt = (fr_udp_pkt_t *)data;
-
- /* Set length of packet */
- len = //sizeof(fr_encap_hdr_t)+
- sizeof(ip_pkt_t)+
- sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- mbox_len;
-
-
- /* fill in UDP reply */
- fr_udp_pkt->wp_mgmt.request_reply = UDPMGMT_REPLY;
-
- /* fill in UDP length */
- udp_length = sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- mbox_len;
-
-
- /* put it on an even boundary */
- if ( udp_length & 0x0001 ) {
- udp_length += 1;
- len += 1;
- even_bound = 1;
- }
-
- temp = (udp_length<<8)|(udp_length>>8);
- fr_udp_pkt->udp_pkt.udp_length = temp;
-
- /* swap UDP ports */
- temp = fr_udp_pkt->udp_pkt.udp_src_port;
- fr_udp_pkt->udp_pkt.udp_src_port =
- fr_udp_pkt->udp_pkt.udp_dst_port;
- fr_udp_pkt->udp_pkt.udp_dst_port = temp;
-
-
-
- /* add UDP pseudo header */
- temp = 0x1100;
- *((unsigned short *)
- (fr_udp_pkt->data+mbox_len+even_bound)) = temp;
- temp = (udp_length<<8)|(udp_length>>8);
- *((unsigned short *)
- (fr_udp_pkt->data+mbox_len+even_bound+2)) = temp;
-
- /* calculate UDP checksum */
- fr_udp_pkt->udp_pkt.udp_checksum = 0;
-
- fr_udp_pkt->udp_pkt.udp_checksum =
- calc_checksum(&data[UDP_OFFSET/*+sizeof(fr_encap_hdr_t)*/],
- udp_length+UDP_OFFSET);
-
- /* fill in IP length */
- ip_length = udp_length + sizeof(ip_pkt_t);
- temp = (ip_length<<8)|(ip_length>>8);
- fr_udp_pkt->ip_pkt.total_length = temp;
-
- /* swap IP addresses */
- ip_temp = fr_udp_pkt->ip_pkt.ip_src_address;
- fr_udp_pkt->ip_pkt.ip_src_address =
- fr_udp_pkt->ip_pkt.ip_dst_address;
- fr_udp_pkt->ip_pkt.ip_dst_address = ip_temp;
-
-
- /* fill in IP checksum */
- fr_udp_pkt->ip_pkt.hdr_checksum = 0;
- fr_udp_pkt->ip_pkt.hdr_checksum =
- calc_checksum(&data[/*sizeof(fr_encap_hdr_t)*/0],
- sizeof(ip_pkt_t));
-
- return len;
-} /* reply_udp */
-
-unsigned short calc_checksum (char *data, int len)
-{
- unsigned short temp;
- unsigned long sum=0;
- int i;
-
- for( i = 0; i <len; i+=2 ) {
- memcpy(&temp,&data[i],2);
- sum += (unsigned long)temp;
- }
-
- while (sum >> 16 ) {
- sum = (sum & 0xffffUL) + (sum >> 16);
- }
-
- temp = (unsigned short)sum;
- temp = ~temp;
-
- if( temp == 0 )
- temp = 0xffff;
-
- return temp;
-}
-
-/*
- If incoming is 0 (outgoing)- if the net numbers is ours make it 0
- if incoming is 1 - if the net number is 0 make it ours
-
-*/
-static void switch_net_numbers(unsigned char *sendpacket, unsigned long network_number, unsigned char incoming)
-{
- unsigned long pnetwork_number;
-
- pnetwork_number = (unsigned long)((sendpacket[14] << 24) +
- (sendpacket[15] << 16) + (sendpacket[16] << 8) +
- sendpacket[17]);
-
- if (!incoming) {
- /* If the destination network number is ours, make it 0 */
- if( pnetwork_number == network_number) {
- sendpacket[14] = sendpacket[15] = sendpacket[16] =
- sendpacket[17] = 0x00;
- }
- } else {
- /* If the incoming network is 0, make it ours */
- if( pnetwork_number == 0) {
- sendpacket[14] = (unsigned char)(network_number >> 24);
- sendpacket[15] = (unsigned char)((network_number &
- 0x00FF0000) >> 16);
- sendpacket[16] = (unsigned char)((network_number &
- 0x0000FF00) >> 8);
- sendpacket[17] = (unsigned char)(network_number &
- 0x000000FF);
- }
- }
-
-
- pnetwork_number = (unsigned long)((sendpacket[26] << 24) +
- (sendpacket[27] << 16) + (sendpacket[28] << 8) +
- sendpacket[29]);
-
- if( !incoming ) {
- /* If the source network is ours, make it 0 */
- if( pnetwork_number == network_number) {
- sendpacket[26] = sendpacket[27] = sendpacket[28] =
- sendpacket[29] = 0x00;
- }
- } else {
- /* If the source network is 0, make it ours */
- if( pnetwork_number == 0 ) {
- sendpacket[26] = (unsigned char)(network_number >> 24);
- sendpacket[27] = (unsigned char)((network_number &
- 0x00FF0000) >> 16);
- sendpacket[28] = (unsigned char)((network_number &
- 0x0000FF00) >> 8);
- sendpacket[29] = (unsigned char)(network_number &
- 0x000000FF);
- }
- }
-} /* switch_net_numbers */
-
-/*============================================================================
- * Get ethernet-style interface statistics.
- * Return a pointer to struct enet_statistics.
- */
-static struct net_device_stats *if_stats(struct net_device *dev)
-{
- fr_channel_t* chan = dev->priv;
-
- if(chan == NULL)
- return NULL;
-
- return &chan->ifstats;
-}
-
-/****** Interrupt Handlers **************************************************/
-
-/*============================================================================
- * fr_isr: S508 frame relay interrupt service routine.
- *
- * Description:
- * Frame relay main interrupt service route. This
- * function check the interrupt type and takes
- * the appropriate action.
- */
-static void fr_isr (sdla_t* card)
-{
- fr508_flags_t* flags = card->flags;
- char *ptr = &flags->iflag;
- int i,err;
- fr_mbox_t* mbox = card->mbox;
-
- /* This flag prevents nesting of interrupts. See sdla_isr() routine
- * in sdlamain.c. */
- card->in_isr = 1;
-
- ++card->statistics.isr_entry;
-
-
- /* All peripheral (configuraiton, re-configuration) events
- * take presidence over the ISR. Thus, retrigger */
- if (test_bit(PERI_CRIT, (void*)&card->wandev.critical)) {
- ++card->statistics.isr_already_critical;
- goto fr_isr_exit;
- }
-
- if(card->hw.type != SDLA_S514) {
- if (test_bit(SEND_CRIT, (void*)&card->wandev.critical)) {
- printk(KERN_INFO "%s: Critical while in ISR: If Send Running!\n",
- card->devname);
- ++card->statistics.isr_already_critical;
- goto fr_isr_exit;
- }
- }
-
- switch (flags->iflag) {
-
- case FR_INTR_RXRDY: /* receive interrupt */
- ++card->statistics.isr_rx;
- rx_intr(card);
- break;
-
-
- case FR_INTR_TXRDY: /* transmit interrupt */
- ++ card->statistics.isr_tx;
- tx_intr(card);
- break;
-
- case FR_INTR_READY:
- Intr_test_counter++;
- ++card->statistics.isr_intr_test;
- break;
-
- case FR_INTR_DLC: /* Event interrupt occurred */
- mbox->cmd.command = FR_READ_STATUS;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err)
- fr_event(card, err, mbox);
- break;
-
- case FR_INTR_TIMER: /* Timer interrupt */
- timer_intr(card);
- break;
-
- default:
- ++card->statistics.isr_spurious;
- spur_intr(card);
- printk(KERN_INFO "%s: Interrupt Type 0x%02X!\n",
- card->devname, flags->iflag);
-
- printk(KERN_INFO "%s: ID Bytes = ",card->devname);
- for(i = 0; i < 8; i ++)
- printk(KERN_INFO "0x%02X ", *(ptr + 0x28 + i));
- printk(KERN_INFO "\n");
-
- break;
- }
-
-fr_isr_exit:
-
- card->in_isr = 0;
- flags->iflag = 0;
- return;
-}
-
-
-
-/*===========================================================
- * rx_intr Receive interrupt handler.
- *
- * Description
- * Upon receiveing an interrupt:
- * 1. Check that the firmware is in sync with
- * the driver.
- * 2. Find an appropriate network interface
- * based on the received dlci number.
- * 3. Check that the netowrk interface exists
- * and that it's setup properly.
- * 4. Copy the data into an skb buffer.
- * 5. Check the packet type and take
- * appropriate acton: UPD, API, ARP or Data.
- */
-
-static void rx_intr (sdla_t* card)
-{
- fr_rx_buf_ctl_t* frbuf = card->rxmb;
- fr508_flags_t* flags = card->flags;
- fr_channel_t* chan;
- char *ptr = &flags->iflag;
- struct sk_buff* skb;
- struct net_device* dev;
- void* buf;
- unsigned dlci, len, offs, len_incl_hdr;
- int i, udp_type;
-
-
- /* Check that firmware buffers are in sync */
- if (frbuf->flag != 0x01) {
-
- printk(KERN_INFO
- "%s: corrupted Rx buffer @ 0x%X, flag = 0x%02X!\n",
- card->devname, (unsigned)frbuf, frbuf->flag);
-
- printk(KERN_INFO "%s: ID Bytes = ",card->devname);
- for(i = 0; i < 8; i ++)
- printk(KERN_INFO "0x%02X ", *(ptr + 0x28 + i));
- printk(KERN_INFO "\n");
-
- ++card->statistics.rx_intr_corrupt_rx_bfr;
-
- /* Bug Fix: Mar 6 2000
- * If we get a corrupted mailbox, it means that driver
- * is out of sync with the firmware. There is no recovery.
- * If we don't turn off all interrupts for this card
- * the machine will crash.
- */
- printk(KERN_INFO "%s: Critical router failure ...!!!\n", card->devname);
- printk(KERN_INFO "Please contact Sangoma Technologies !\n");
- fr_set_intr_mode(card, 0, 0, 0);
- return;
- }
-
- len = frbuf->length;
- dlci = frbuf->dlci;
- offs = frbuf->offset;
-
- /* Find the network interface for this packet */
- dev = find_channel(card, dlci);
-
-
- /* Check that the network interface is active and
- * properly setup */
- if (dev == NULL) {
- if( net_ratelimit()) {
- printk(KERN_INFO "%s: received data on unconfigured DLCI %d!\n",
- card->devname, dlci);
- }
- ++card->statistics.rx_intr_on_orphaned_DLCI;
- ++card->wandev.stats.rx_dropped;
- goto rx_done;
- }
-
- if ((chan = dev->priv) == NULL){
- if( net_ratelimit()) {
- printk(KERN_INFO "%s: received data on unconfigured DLCI %d!\n",
- card->devname, dlci);
- }
- ++card->statistics.rx_intr_on_orphaned_DLCI;
- ++card->wandev.stats.rx_dropped;
- goto rx_done;
- }
-
- skb = dev_alloc_skb(len);
-
- if (!netif_running(dev) || (skb == NULL)){
-
- ++chan->ifstats.rx_dropped;
-
- if(skb == NULL) {
- if (net_ratelimit()) {
- printk(KERN_INFO
- "%s: no socket buffers available!\n",
- card->devname);
- }
- chan->drvstats_rx_intr.rx_intr_no_socket ++;
- }
-
- if (!netif_running(dev)){
- chan->drvstats_rx_intr.
- rx_intr_dev_not_started ++;
- if (skb){
- dev_kfree_skb_any(skb);
- }
- }
- goto rx_done;
- }
-
- /* Copy data from the board into the socket buffer */
- if ((offs + len) > card->u.f.rx_top + 1) {
- unsigned tmp = card->u.f.rx_top - offs + 1;
-
- buf = skb_put(skb, tmp);
- sdla_peek(&card->hw, offs, buf, tmp);
- offs = card->u.f.rx_base;
- len -= tmp;
- }
-
- buf = skb_put(skb, len);
- sdla_peek(&card->hw, offs, buf, len);
-
-
- /* We got the packet from the bard.
- * Check the packet type and take appropriate action */
-
- udp_type = udp_pkt_type( skb, card );
-
- if(udp_type != UDP_INVALID_TYPE) {
-
- /* UDP Debug packet received, store the
- * packet and handle it in timer interrupt */
-
- skb_pull(skb, 1);
- if (wanrouter_type_trans(skb, dev)){
- if(store_udp_mgmt_pkt(udp_type,UDP_PKT_FRM_NETWORK,card,skb,dlci)){
-
- flags->imask |= FR_INTR_TIMER;
-
- if (udp_type == UDP_FPIPE_TYPE){
- ++chan->drvstats_rx_intr.rx_intr_PIPE_request;
- }
- }
- }
-
- }else if (chan->common.usedby == API) {
-
- /* We are in API mode.
- * Add an API header to the RAW packet
- * and queue it into a circular buffer.
- * Then kick the fr_bh() bottom half handler */
-
- api_rx_hdr_t* api_rx_hdr;
- chan->drvstats_rx_intr.rx_intr_bfr_passed_to_stack ++;
- chan->ifstats.rx_packets ++;
- card->wandev.stats.rx_packets ++;
-
- chan->ifstats.rx_bytes += skb->len;
- card->wandev.stats.rx_bytes += skb->len;
-
- skb_push(skb, sizeof(api_rx_hdr_t));
- api_rx_hdr = (api_rx_hdr_t*)&skb->data[0x00];
- api_rx_hdr->attr = frbuf->attr;
- api_rx_hdr->time_stamp = frbuf->tmstamp;
-
- skb->protocol = htons(ETH_P_IP);
- skb->mac.raw = skb->data;
- skb->dev = dev;
- skb->pkt_type = WAN_PACKET_DATA;
-
- bh_enqueue(dev, skb);
-
- trigger_fr_bh(chan);
-
- }else if (handle_IPXWAN(skb->data,chan->name,chan->enable_IPX, chan->network_number)){
-
- //FIXME: Frame Relay IPX is not supported, Yet !
- //if (chan->enable_IPX) {
- // fr_send(card, dlci, 0, skb->len,skb->data);
- //}
- dev_kfree_skb_any(skb);
-
- } else if (is_arp(skb->data)) {
-
- /* ARP support enabled Mar 16 2000
- * Process incoming ARP reply/request, setup
- * dynamic routes. */
-
- if (process_ARP((arphdr_1490_t *)skb->data, card, dev)) {
- if (net_ratelimit()){
- printk (KERN_INFO
- "%s: Error processing ARP Packet.\n",
- card->devname);
- }
- }
- dev_kfree_skb_any(skb);
-
- } else if (skb->data[0] != 0x03) {
-
- if (net_ratelimit()) {
- printk(KERN_INFO "%s: Non IETF packet discarded.\n",
- card->devname);
- }
- dev_kfree_skb_any(skb);
-
- } else {
-
- len_incl_hdr = skb->len;
- /* Decapsulate packet and pass it up the
- protocol stack */
- skb->dev = dev;
-
- if (chan->common.usedby == BRIDGE || chan->common.usedby == BRIDGE_NODE){
-
- /* Make sure it's an Ethernet frame, otherwise drop it */
- if (!memcmp(skb->data, "\x03\x00\x80\x00\x80\xC2\x00\x07", 8)) {
- skb_pull(skb, 8);
- skb->protocol=eth_type_trans(skb,dev);
- }else{
- ++chan->drvstats_rx_intr.rx_intr_bfr_not_passed_to_stack;
- ++chan->ifstats.rx_errors;
- ++card->wandev.stats.rx_errors;
- goto rx_done;
- }
- }else{
-
- /* remove hardware header */
- buf = skb_pull(skb, 1);
-
- if (!wanrouter_type_trans(skb, dev)) {
-
- /* can't decapsulate packet */
- dev_kfree_skb_any(skb);
-
- ++chan->drvstats_rx_intr.rx_intr_bfr_not_passed_to_stack;
- ++chan->ifstats.rx_errors;
- ++card->wandev.stats.rx_errors;
- goto rx_done;
- }
- skb->mac.raw = skb->data;
- }
-
-
- /* Send a packet up the IP stack */
- skb->dev->last_rx = jiffies;
- netif_rx(skb);
- ++chan->drvstats_rx_intr.rx_intr_bfr_passed_to_stack;
- ++chan->ifstats.rx_packets;
- ++card->wandev.stats.rx_packets;
-
- chan->ifstats.rx_bytes += len_incl_hdr;
- card->wandev.stats.rx_bytes += len_incl_hdr;
- }
-
-rx_done:
-
- /* Release buffer element and calculate a pointer to the next one */
- frbuf->flag = 0;
- card->rxmb = ++frbuf;
- if ((void*)frbuf > card->u.f.rxmb_last)
- card->rxmb = card->u.f.rxmb_base;
-
-}
-
-/*==================================================================
- * tx_intr: Transmit interrupt handler.
- *
- * Rationale:
- * If the board is busy transmitting, if_send() will
- * buffers a single packet and turn on
- * the tx interrupt. Tx interrupt will be called
- * by the board, once the firmware can send more
- * data. Thus, no polling is required.
- *
- * Description:
- * Tx interrupt is called for each
- * configured dlci channel. Thus:
- * 1. Obtain the netowrk interface based on the
- * dlci number.
- * 2. Check that network interface is up and
- * properly setup.
- * 3. Check for a buffered packet.
- * 4. Transmit the packet.
- * 5. If we are in WANPIPE mode, mark the
- * NET_BH handler.
- * 6. If we are in API mode, kick
- * the AF_WANPIPE socket for more data.
- *
- */
-static void tx_intr(sdla_t *card)
-{
- fr508_flags_t* flags = card->flags;
- fr_tx_buf_ctl_t* bctl;
- struct net_device* dev;
- fr_channel_t* chan;
-
- if(card->hw.type == SDLA_S514){
- bctl = (void*)(flags->tse_offs + card->hw.dpmbase);
- }else{
- bctl = (void*)(flags->tse_offs - FR_MB_VECTOR +
- card->hw.dpmbase);
- }
-
- /* Find the structure and make it unbusy */
- dev = find_channel(card, flags->dlci);
- if (dev == NULL){
- printk(KERN_INFO "NO DEV IN TX Interrupt\n");
- goto end_of_tx_intr;
- }
-
- if ((chan = dev->priv) == NULL){
- printk(KERN_INFO "NO CHAN IN TX Interrupt\n");
- goto end_of_tx_intr;
- }
-
- if(!chan->transmit_length || !chan->delay_skb) {
- printk(KERN_INFO "%s: tx int error - transmit length zero\n",
- card->wandev.name);
- goto end_of_tx_intr;
- }
-
- /* If the 'if_send()' procedure is currently checking the 'tbusy'
- status, then we cannot transmit. Instead, we configure the microcode
- so as to re-issue this transmit interrupt at a later stage.
- */
- if (test_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical)) {
-
- fr_dlci_interface_t* dlci_interface = chan->dlci_int_interface;
- bctl->flag = 0xA0;
- dlci_interface->gen_interrupt |= FR_INTR_TXRDY;
- return;
-
- }else{
- bctl->dlci = flags->dlci;
- bctl->length = chan->transmit_length+chan->fr_header_len;
- sdla_poke(&card->hw,
- fr_send_hdr(card,bctl->dlci,bctl->offset),
- chan->delay_skb->data,
- chan->delay_skb->len);
- bctl->flag = 0xC0;
-
- ++chan->ifstats.tx_packets;
- ++card->wandev.stats.tx_packets;
- chan->ifstats.tx_bytes += chan->transmit_length;
- card->wandev.stats.tx_bytes += chan->transmit_length;
-
- /* We must free an sk buffer, which we used
- * for delayed transmission; Otherwise, the sock
- * will run out of memory */
- dev_kfree_skb_any(chan->delay_skb);
-
- chan->delay_skb = NULL;
- chan->transmit_length = 0;
-
- dev->trans_start = jiffies;
-
- if (netif_queue_stopped(dev)){
- /* If using API, than wakeup socket BH handler */
- if (chan->common.usedby == API){
- netif_start_queue(dev);
- wakeup_sk_bh(dev);
- }else{
- netif_wake_queue(dev);
- }
- }
- }
-
-end_of_tx_intr:
-
- /* if any other interfaces have transmit interrupts pending,
- * do not disable the global transmit interrupt */
- if(!(-- card->u.f.tx_interrupts_pending))
- flags->imask &= ~FR_INTR_TXRDY;
-
-
-}
-
-
-/*============================================================================
- * timer_intr: Timer interrupt handler.
- *
- * Rationale:
- * All commans must be executed within the timer
- * interrupt since no two commands should execute
- * at the same time.
- *
- * Description:
- * The timer interrupt is used to:
- * 1. Processing udp calls from 'fpipemon'.
- * 2. Processing update calls from /proc file system
- * 3. Reading board-level statistics for
- * updating the proc file system.
- * 4. Sending inverse ARP request packets.
- * 5. Configure a dlci/channel.
- * 6. Unconfigure a dlci/channel. (Node only)
- */
-
-static void timer_intr(sdla_t *card)
-{
- fr508_flags_t* flags = card->flags;
-
- /* UDP Debuging: fpipemon call */
- if (card->u.f.timer_int_enabled & TMR_INT_ENABLED_UDP) {
- if(card->u.f.udp_type == UDP_FPIPE_TYPE) {
- if(process_udp_mgmt_pkt(card)) {
- card->u.f.timer_int_enabled &=
- ~TMR_INT_ENABLED_UDP;
- }
- }
- }
-
- /* /proc update call : triggered from update() */
- if (card->u.f.timer_int_enabled & TMR_INT_ENABLED_UPDATE) {
- fr_get_err_stats(card);
- fr_get_stats(card);
- card->u.f.update_comms_stats = 0;
- card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE;
- }
-
- /* Update the channel state call. This is call is
- * triggered by if_send() function */
- if (card->u.f.timer_int_enabled & TMR_INT_ENABLED_UPDATE_STATE){
- struct net_device *dev;
- if (card->wandev.state == WAN_CONNECTED){
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)){
- fr_channel_t *chan = dev->priv;
- if (chan->common.state != WAN_CONNECTED){
- update_chan_state(dev);
- }
- }
- }
- card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE_STATE;
- }
-
- /* configure a dlci/channel */
- if (card->u.f.timer_int_enabled & TMR_INT_ENABLED_CONFIG){
- config_fr(card);
- card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_CONFIG;
- }
-
- /* unconfigure a dlci/channel */
- if (card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG){
- unconfig_fr(card);
- card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG;
- }
-
-
- /* Transmit ARP packets */
- if (card->u.f.timer_int_enabled & TMR_INT_ENABLED_ARP){
- int i=0;
- struct net_device *dev;
-
- if (card->u.f.arp_dev == NULL)
- card->u.f.arp_dev = card->wandev.dev;
-
- dev = card->u.f.arp_dev;
-
- for (;;){
-
- fr_channel_t *chan = dev->priv;
-
- /* If the interface is brought down cancel sending In-ARPs */
- if (!(dev->flags&IFF_UP)){
- clear_bit(0,&chan->inarp_ready);
- }
-
- if (test_bit(0,&chan->inarp_ready)){
-
- if (check_tx_status(card,dev)){
- set_bit(ARP_CRIT,&card->wandev.critical);
- break;
- }
-
- if (!send_inarp_request(card,dev)){
- trigger_fr_arp(dev);
- chan->inarp_tick = jiffies;
- }
-
- clear_bit(0,&chan->inarp_ready);
- dev = move_dev_to_next(card,dev);
- break;
- }
- dev = move_dev_to_next(card,dev);
-
- if (++i == card->wandev.new_if_cnt){
- card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_ARP;
- break;
- }
- }
- card->u.f.arp_dev = dev;
- }
-
- if(!card->u.f.timer_int_enabled)
- flags->imask &= ~FR_INTR_TIMER;
-}
-
-
-/*============================================================================
- * spur_intr: Spurious interrupt handler.
- *
- * Description:
- * We don't know this interrupt.
- * Print a warning.
- */
-
-static void spur_intr (sdla_t* card)
-{
- if (net_ratelimit()){
- printk(KERN_INFO "%s: spurious interrupt!\n", card->devname);
- }
-}
-
-
-//FIXME: Fix the IPX in next version
-/*===========================================================================
- * Return 0 for non-IPXWAN packet
- * 1 for IPXWAN packet or IPX is not enabled!
- * FIXME: Use a IPX structure here not offsets
- */
-static int handle_IPXWAN(unsigned char *sendpacket,
- char *devname, unsigned char enable_IPX,
- unsigned long network_number)
-{
- int i;
-
- if( sendpacket[1] == 0x00 && sendpacket[2] == 0x80 &&
- sendpacket[6] == 0x81 && sendpacket[7] == 0x37) {
-
- /* It's an IPX packet */
- if (!enable_IPX){
- /* Return 1 so we don't pass it up the stack. */
- //FIXME: Take this out when IPX is fixed
- if (net_ratelimit()){
- printk (KERN_INFO
- "%s: WARNING: Unsupported IPX packet received and dropped\n",
- devname);
- }
- return 1;
- }
- } else {
- /* It's not IPX so return and pass it up the stack. */
- return 0;
- }
-
- if( sendpacket[24] == 0x90 && sendpacket[25] == 0x04){
- /* It's IPXWAN */
-
- if( sendpacket[10] == 0x02 && sendpacket[42] == 0x00){
-
- /* It's a timer request packet */
- printk(KERN_INFO "%s: Received IPXWAN Timer Request packet\n",
- devname);
-
- /* Go through the routing options and answer no to every
- * option except Unnumbered RIP/SAP
- */
- for(i = 49; sendpacket[i] == 0x00; i += 5){
- /* 0x02 is the option for Unnumbered RIP/SAP */
- if( sendpacket[i + 4] != 0x02){
- sendpacket[i + 1] = 0;
- }
- }
-
- /* Skip over the extended Node ID option */
- if( sendpacket[i] == 0x04 ){
- i += 8;
- }
-
- /* We also want to turn off all header compression opt.
- */
- for(; sendpacket[i] == 0x80 ;){
- sendpacket[i + 1] = 0;
- i += (sendpacket[i + 2] << 8) + (sendpacket[i + 3]) + 4;
- }
-
- /* Set the packet type to timer response */
- sendpacket[42] = 0x01;
-
- printk(KERN_INFO "%s: Sending IPXWAN Timer Response\n",
- devname);
-
- } else if( sendpacket[42] == 0x02 ){
-
- /* This is an information request packet */
- printk(KERN_INFO
- "%s: Received IPXWAN Information Request packet\n",
- devname);
-
- /* Set the packet type to information response */
- sendpacket[42] = 0x03;
-
- /* Set the router name */
- sendpacket[59] = 'F';
- sendpacket[60] = 'P';
- sendpacket[61] = 'I';
- sendpacket[62] = 'P';
- sendpacket[63] = 'E';
- sendpacket[64] = '-';
- sendpacket[65] = CVHexToAscii(network_number >> 28);
- sendpacket[66] = CVHexToAscii((network_number & 0x0F000000)>> 24);
- sendpacket[67] = CVHexToAscii((network_number & 0x00F00000)>> 20);
- sendpacket[68] = CVHexToAscii((network_number & 0x000F0000)>> 16);
- sendpacket[69] = CVHexToAscii((network_number & 0x0000F000)>> 12);
- sendpacket[70] = CVHexToAscii((network_number & 0x00000F00)>> 8);
- sendpacket[71] = CVHexToAscii((network_number & 0x000000F0)>> 4);
- sendpacket[72] = CVHexToAscii(network_number & 0x0000000F);
- for(i = 73; i < 107; i+= 1)
- {
- sendpacket[i] = 0;
- }
-
- printk(KERN_INFO "%s: Sending IPXWAN Information Response packet\n",
- devname);
- } else {
-
- printk(KERN_INFO "%s: Unknown IPXWAN packet!\n",devname);
- return 0;
- }
-
- /* Set the WNodeID to our network address */
- sendpacket[43] = (unsigned char)(network_number >> 24);
- sendpacket[44] = (unsigned char)((network_number & 0x00FF0000) >> 16);
- sendpacket[45] = (unsigned char)((network_number & 0x0000FF00) >> 8);
- sendpacket[46] = (unsigned char)(network_number & 0x000000FF);
-
- return 1;
- }
-
- /* If we get here, it's an IPX-data packet so it'll get passed up the
- * stack.
- * switch the network numbers
- */
- switch_net_numbers(sendpacket, network_number ,1);
- return 0;
-}
-/*============================================================================
- * process_route
- *
- * Rationale:
- * If the interface goes down, or we receive an ARP request,
- * we have to change the network interface ip addresses.
- * This cannot be done within the interrupt.
- *
- * Description:
- *
- * This routine is called as a polling routine to dynamically
- * add/delete routes negotiated by inverse ARP. It is in this
- * "task" because we don't want routes to be added while in
- * interrupt context.
- *
- * Usage:
- * This function is called by fr_poll() polling funtion.
- */
-
-static void process_route(struct net_device *dev)
-{
- fr_channel_t *chan = dev->priv;
- sdla_t *card = chan->card;
-
- struct ifreq if_info;
- struct sockaddr_in *if_data;
- mm_segment_t fs = get_fs();
- u32 ip_tmp;
- int err;
-
-
- switch(chan->route_flag){
-
- case ADD_ROUTE:
-
- /* Set remote addresses */
- memset(&if_info, 0, sizeof(if_info));
- strcpy(if_info.ifr_name, dev->name);
-
- set_fs(get_ds()); /* get user space block */
-
- if_data = (struct sockaddr_in *)&if_info.ifr_dstaddr;
- if_data->sin_addr.s_addr = chan->ip_remote;
- if_data->sin_family = AF_INET;
- err = devinet_ioctl( SIOCSIFDSTADDR, &if_info );
-
- set_fs(fs); /* restore old block */
-
- if (err) {
- printk(KERN_INFO
- "%s: Route Add failed. Error: %d\n",
- card->devname,err);
- printk(KERN_INFO "%s: Address: %u.%u.%u.%u\n",
- chan->name, NIPQUAD(chan->ip_remote));
-
- }else {
- printk(KERN_INFO "%s: Route Added Successfully: %u.%u.%u.%u\n",
- card->devname,NIPQUAD(chan->ip_remote));
- chan->route_flag = ROUTE_ADDED;
- }
- break;
-
- case REMOVE_ROUTE:
-
- /* Set remote addresses */
- memset(&if_info, 0, sizeof(if_info));
- strcpy(if_info.ifr_name, dev->name);
-
- ip_tmp = get_ip_address(dev,WAN_POINTOPOINT_IP);
-
- set_fs(get_ds()); /* get user space block */
-
- if_data = (struct sockaddr_in *)&if_info.ifr_dstaddr;
- if_data->sin_addr.s_addr = 0;
- if_data->sin_family = AF_INET;
- err = devinet_ioctl( SIOCSIFDSTADDR, &if_info );
-
- set_fs(fs);
-
- if (err) {
- printk(KERN_INFO
- "%s: Deleting of route failed. Error: %d\n",
- card->devname,err);
- printk(KERN_INFO "%s: Address: %u.%u.%u.%u\n",
- dev->name,NIPQUAD(chan->ip_remote) );
-
- } else {
- printk(KERN_INFO "%s: Route Removed Sucessfuly: %u.%u.%u.%u\n",
- card->devname,NIPQUAD(ip_tmp));
- chan->route_flag = NO_ROUTE;
- }
- break;
-
- } /* Case Statement */
-
-}
-
-
-
-/****** Frame Relay Firmware-Specific Functions *****************************/
-
-/*============================================================================
- * Read firmware code version.
- * o fill string str with firmware version info.
- */
-static int fr_read_version (sdla_t* card, char* str)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- mbox->cmd.command = FR_READ_CODE_VERSION;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if (!err && str) {
- int len = mbox->cmd.length;
- memcpy(str, mbox->data, len);
- str[len] = '\0';
- }
- return err;
-}
-
-/*============================================================================
- * Set global configuration.
- */
-static int fr_configure (sdla_t* card, fr_conf_t *conf)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int dlci_num = card->u.f.dlci_num;
- int err, i;
-
- do
- {
- memcpy(mbox->data, conf, sizeof(fr_conf_t));
-
- if (dlci_num) for (i = 0; i < dlci_num; ++i)
- ((fr_conf_t*)mbox->data)->dlci[i] =
- card->u.f.node_dlci[i];
-
- mbox->cmd.command = FR_SET_CONFIG;
- mbox->cmd.length =
- sizeof(fr_conf_t) + dlci_num * sizeof(short);
-
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- } while (err && retry-- && fr_event(card, err, mbox));
-
- /*NC Oct 12 2000 */
- if (err != CMD_OK){
- printk(KERN_ERR "%s: Frame Relay Configuration Failed: rc=0x%x\n",
- card->devname,err);
- }
-
- return err;
-}
-
-/*============================================================================
- * Set DLCI configuration.
- */
-static int fr_dlci_configure (sdla_t* card, fr_dlc_conf_t *conf, unsigned dlci)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memcpy(mbox->data, conf, sizeof(fr_dlc_conf_t));
- mbox->cmd.dlci = (unsigned short) dlci;
- mbox->cmd.command = FR_SET_CONFIG;
- mbox->cmd.length = sizeof(fr_dlc_conf_t);
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry--);
-
- return err;
-}
-/*============================================================================
- * Set interrupt mode.
- */
-static int fr_set_intr_mode (sdla_t* card, unsigned mode, unsigned mtu,
- unsigned short timeout)
-{
- fr_mbox_t* mbox = card->mbox;
- fr508_intr_ctl_t* ictl = (void*)mbox->data;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(ictl, 0, sizeof(fr508_intr_ctl_t));
- ictl->mode = mode;
- ictl->tx_len = mtu;
- ictl->irq = card->hw.irq;
-
- /* indicate timeout on timer */
- if (mode & 0x20) ictl->timeout = timeout;
-
- mbox->cmd.length = sizeof(fr508_intr_ctl_t);
- mbox->cmd.command = FR_SET_INTR_MODE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- } while (err && retry-- && fr_event(card, err, mbox));
-
- return err;
-}
-
-/*============================================================================
- * Enable communications.
- */
-static int fr_comm_enable (sdla_t* card)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- mbox->cmd.command = FR_COMM_ENABLE;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- return err;
-}
-
-/*============================================================================
- * fr_comm_disable
- *
- * Warning: This functin is called by the shutdown() procedure. It is void
- * since dev->priv are has already been deallocated and no
- * error checking is possible using fr_event() function.
- */
-static void fr_comm_disable (sdla_t* card)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do {
- mbox->cmd.command = FR_SET_MODEM_STATUS;
- mbox->cmd.length = 1;
- mbox->data[0] = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry--);
-
- retry = MAX_CMD_RETRY;
-
- do
- {
- mbox->cmd.command = FR_COMM_DISABLE;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry--);
-
- return;
-}
-
-
-
-/*============================================================================
- * Get communications error statistics.
- */
-static int fr_get_err_stats (sdla_t* card)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
-
- do
- {
- mbox->cmd.command = FR_READ_ERROR_STATS;
- mbox->cmd.length = 0;
- mbox->cmd.dlci = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if (!err) {
- fr_comm_stat_t* stats = (void*)mbox->data;
- card->wandev.stats.rx_over_errors = stats->rx_overruns;
- card->wandev.stats.rx_crc_errors = stats->rx_bad_crc;
- card->wandev.stats.rx_missed_errors = stats->rx_aborts;
- card->wandev.stats.rx_length_errors = stats->rx_too_long;
- card->wandev.stats.tx_aborted_errors = stats->tx_aborts;
-
- }
-
- return err;
-}
-
-/*============================================================================
- * Get statistics.
- */
-static int fr_get_stats (sdla_t* card)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
-
- do
- {
- mbox->cmd.command = FR_READ_STATISTICS;
- mbox->cmd.length = 0;
- mbox->cmd.dlci = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if (!err) {
- fr_link_stat_t* stats = (void*)mbox->data;
- card->wandev.stats.rx_frame_errors = stats->rx_bad_format;
- card->wandev.stats.rx_dropped =
- stats->rx_dropped + stats->rx_dropped2;
- }
-
- return err;
-}
-
-/*============================================================================
- * Add DLCI(s) (Access Node only!).
- * This routine will perform the ADD_DLCIs command for the specified DLCI.
- */
-static int fr_add_dlci (sdla_t* card, int dlci)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- unsigned short* dlci_list = (void*)mbox->data;
-
- mbox->cmd.length = sizeof(short);
- dlci_list[0] = dlci;
- mbox->cmd.command = FR_ADD_DLCI;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- } while (err && retry-- && fr_event(card, err, mbox));
-
- return err;
-}
-
-/*============================================================================
- * Activate DLCI(s) (Access Node only!).
- * This routine will perform the ACTIVATE_DLCIs command with a DLCI number.
- */
-static int fr_activate_dlci (sdla_t* card, int dlci)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- unsigned short* dlci_list = (void*)mbox->data;
-
- mbox->cmd.length = sizeof(short);
- dlci_list[0] = dlci;
- mbox->cmd.command = FR_ACTIVATE_DLCI;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- } while (err && retry-- && fr_event(card, err, mbox));
-
- return err;
-}
-
-/*============================================================================
- * Delete DLCI(s) (Access Node only!).
- * This routine will perform the DELETE_DLCIs command with a DLCI number.
- */
-static int fr_delete_dlci (sdla_t* card, int dlci)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- unsigned short* dlci_list = (void*)mbox->data;
-
- mbox->cmd.length = sizeof(short);
- dlci_list[0] = dlci;
- mbox->cmd.command = FR_DELETE_DLCI;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- } while (err && retry-- && fr_event(card, err, mbox));
-
- return err;
-}
-
-
-
-/*============================================================================
- * Issue in-channel signalling frame.
- */
-static int fr_issue_isf (sdla_t* card, int isf)
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- mbox->data[0] = isf;
- mbox->cmd.length = 1;
- mbox->cmd.command = FR_ISSUE_IS_FRAME;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- return err;
-}
-
-
-static unsigned int fr_send_hdr (sdla_t*card, int dlci, unsigned int offset)
-{
- struct net_device *dev = find_channel(card,dlci);
- fr_channel_t *chan;
-
- if (!dev || !(chan=dev->priv))
- return offset;
-
- if (chan->fr_header_len){
- sdla_poke(&card->hw, offset, chan->fr_header, chan->fr_header_len);
- }
-
- return offset+chan->fr_header_len;
-}
-
-/*============================================================================
- * Send a frame on a selected DLCI.
- */
-static int fr_send_data_header (sdla_t* card, int dlci, unsigned char attr, int len,
- void *buf, unsigned char hdr_len)
-{
- fr_mbox_t* mbox = card->mbox + 0x800;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- mbox->cmd.dlci = dlci;
- mbox->cmd.attr = attr;
- mbox->cmd.length = len+hdr_len;
- mbox->cmd.command = FR_WRITE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if (!err) {
- fr_tx_buf_ctl_t* frbuf;
-
- if(card->hw.type == SDLA_S514)
- frbuf = (void*)(*(unsigned long*)mbox->data +
- card->hw.dpmbase);
- else
- frbuf = (void*)(*(unsigned long*)mbox->data -
- FR_MB_VECTOR + card->hw.dpmbase);
-
- sdla_poke(&card->hw, fr_send_hdr(card,dlci,frbuf->offset), buf, len);
- frbuf->flag = 0x01;
- }
-
- return err;
-}
-
-static int fr_send (sdla_t* card, int dlci, unsigned char attr, int len,
- void *buf)
-{
- fr_mbox_t* mbox = card->mbox + 0x800;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- mbox->cmd.dlci = dlci;
- mbox->cmd.attr = attr;
- mbox->cmd.length = len;
- mbox->cmd.command = FR_WRITE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if (!err) {
- fr_tx_buf_ctl_t* frbuf;
-
- if(card->hw.type == SDLA_S514)
- frbuf = (void*)(*(unsigned long*)mbox->data +
- card->hw.dpmbase);
- else
- frbuf = (void*)(*(unsigned long*)mbox->data -
- FR_MB_VECTOR + card->hw.dpmbase);
-
- sdla_poke(&card->hw, frbuf->offset, buf, len);
- frbuf->flag = 0x01;
- }
-
- return err;
-}
-
-
-/****** Firmware Asynchronous Event Handlers ********************************/
-
-/*============================================================================
- * Main asyncronous event/error handler.
- * This routine is called whenever firmware command returns non-zero
- * return code.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int fr_event (sdla_t *card, int event, fr_mbox_t* mbox)
-{
- fr508_flags_t* flags = card->flags;
- char *ptr = &flags->iflag;
- int i;
-
- switch (event) {
-
- case FRRES_MODEM_FAILURE:
- return fr_modem_failure(card, mbox);
-
- case FRRES_CHANNEL_DOWN: {
- struct net_device *dev;
-
- /* Remove all routes from associated DLCI's */
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)) {
- fr_channel_t *chan = dev->priv;
- if (chan->route_flag == ROUTE_ADDED) {
- chan->route_flag = REMOVE_ROUTE;
- }
-
- if (chan->inarp == INARP_CONFIGURED) {
- chan->inarp = INARP_REQUEST;
- }
-
- /* If the link becomes disconnected then,
- * all channels will be disconnected
- * as well.
- */
- set_chan_state(dev,WAN_DISCONNECTED);
- }
-
- wanpipe_set_state(card, WAN_DISCONNECTED);
- return 1;
- }
-
- case FRRES_CHANNEL_UP: {
- struct net_device *dev;
-
- /* FIXME: Only startup devices that are on the list */
-
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)) {
-
- set_chan_state(dev,WAN_CONNECTED);
- }
-
- wanpipe_set_state(card, WAN_CONNECTED);
- return 1;
- }
-
- case FRRES_DLCI_CHANGE:
- return fr_dlci_change(card, mbox);
-
- case FRRES_DLCI_MISMATCH:
- printk(KERN_INFO "%s: DLCI list mismatch!\n",
- card->devname);
- return 1;
-
- case CMD_TIMEOUT:
- printk(KERN_ERR "%s: command 0x%02X timed out!\n",
- card->devname, mbox->cmd.command);
- printk(KERN_INFO "%s: ID Bytes = ",card->devname);
- for(i = 0; i < 8; i ++)
- printk(KERN_INFO "0x%02X ", *(ptr + 0x18 + i));
- printk(KERN_INFO "\n");
-
- break;
-
- case FRRES_DLCI_INACTIVE:
- break;
-
- case FRRES_CIR_OVERFLOW:
- break;
-
- case FRRES_BUFFER_OVERFLOW:
- break;
-
- default:
- printk(KERN_INFO "%s: command 0x%02X returned 0x%02X!\n"
- , card->devname, mbox->cmd.command, event);
- }
-
- return 0;
-}
-
-/*============================================================================
- * Handle modem error.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int fr_modem_failure (sdla_t *card, fr_mbox_t* mbox)
-{
- printk(KERN_INFO "%s: physical link down! (modem error 0x%02X)\n",
- card->devname, mbox->data[0]);
-
- switch (mbox->cmd.command){
- case FR_WRITE:
-
- case FR_READ:
- return 0;
- }
-
- return 1;
-}
-
-/*============================================================================
- * Handle DLCI status change.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int fr_dlci_change (sdla_t *card, fr_mbox_t* mbox)
-{
- dlci_status_t* status = (void*)mbox->data;
- int cnt = mbox->cmd.length / sizeof(dlci_status_t);
- fr_channel_t *chan;
- struct net_device* dev2;
-
-
- for (; cnt; --cnt, ++status) {
-
- unsigned short dlci= status->dlci;
- struct net_device* dev = find_channel(card, dlci);
-
- if (dev == NULL){
- printk(KERN_INFO
- "%s: CPE contains unconfigured DLCI= %d\n",
- card->devname, dlci);
-
- printk(KERN_INFO
- "%s: unconfigured DLCI %d reported by network\n"
- , card->devname, dlci);
-
- }else{
- if (status->state == FR_LINK_INOPER) {
- printk(KERN_INFO
- "%s: DLCI %u is inactive!\n",
- card->devname, dlci);
-
- if (dev && netif_running(dev))
- set_chan_state(dev, WAN_DISCONNECTED);
- }
-
- if (status->state & FR_DLCI_DELETED) {
-
- printk(KERN_INFO
- "%s: DLCI %u has been deleted!\n",
- card->devname, dlci);
-
- if (dev && netif_running(dev)){
-
- fr_channel_t *chan = dev->priv;
-
- if (chan->route_flag == ROUTE_ADDED) {
- chan->route_flag = REMOVE_ROUTE;
- /* The state change will trigger
- * the fr polling routine */
- }
-
- if (chan->inarp == INARP_CONFIGURED) {
- chan->inarp = INARP_REQUEST;
- }
-
- set_chan_state(dev, WAN_DISCONNECTED);
- }
-
- } else if (status->state & FR_DLCI_ACTIVE) {
-
- chan = dev->priv;
-
- /* This flag is used for configuring specific
- DLCI(s) when they become active.
- */
- chan->dlci_configured = DLCI_CONFIG_PENDING;
-
- set_chan_state(dev, WAN_CONNECTED);
-
- }
- }
- }
-
- for (dev2 = card->wandev.dev; dev2;
- dev2 = *((struct net_device **)dev2->priv)){
-
- chan = dev2->priv;
-
- if (chan->dlci_configured == DLCI_CONFIG_PENDING) {
- if (fr_init_dlci(card, chan)){
- return 1;
- }
- }
-
- }
- return 1;
-}
-
-
-static int fr_init_dlci (sdla_t *card, fr_channel_t *chan)
-{
- fr_dlc_conf_t cfg;
-
- memset(&cfg, 0, sizeof(cfg));
-
- if ( chan->cir_status == CIR_DISABLED) {
-
- cfg.cir_fwd = cfg.cir_bwd = 16;
- cfg.bc_fwd = cfg.bc_bwd = 16;
- cfg.conf_flags = 0x0001;
-
- }else if (chan->cir_status == CIR_ENABLED) {
-
- cfg.cir_fwd = cfg.cir_bwd = chan->cir;
- cfg.bc_fwd = cfg.bc_bwd = chan->bc;
- cfg.be_fwd = cfg.be_bwd = chan->be;
- cfg.conf_flags = 0x0000;
- }
-
- if (fr_dlci_configure( card, &cfg , chan->dlci)){
- printk(KERN_INFO
- "%s: DLCI Configure failed for %d\n",
- card->devname, chan->dlci);
- return 1;
- }
-
- chan->dlci_configured = DLCI_CONFIGURED;
-
- /* Read the interface byte mapping into the channel
- * structure.
- */
- read_DLCI_IB_mapping( card, chan );
-
- return 0;
-}
-/******* Miscellaneous ******************************************************/
-
-/*============================================================================
- * Update channel state.
- */
-static int update_chan_state(struct net_device* dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- mbox->cmd.command = FR_LIST_ACTIVE_DLCI;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if (!err) {
-
- unsigned short* list = (void*)mbox->data;
- int cnt = mbox->cmd.length / sizeof(short);
-
- err=1;
-
- for (; cnt; --cnt, ++list) {
-
- if (*list == chan->dlci) {
- set_chan_state(dev, WAN_CONNECTED);
-
-
- /* May 23 2000. NC
- * When a dlci is added or restarted,
- * the dlci_int_interface pointer must
- * be reinitialized. */
- if (!chan->dlci_int_interface){
- err=fr_init_dlci (card,chan);
- }
- break;
- }
- }
- }
-
- return err;
-}
-
-/*============================================================================
- * Set channel state.
- */
-static void set_chan_state(struct net_device* dev, int state)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
-
- if (chan->common.state != state) {
-
- switch (state) {
-
- case WAN_CONNECTED:
- printk(KERN_INFO
- "%s: Interface %s: DLCI %d connected\n",
- card->devname, dev->name, chan->dlci);
-
- /* If the interface was previoulsy down,
- * bring it up, since the channel is active */
-
- trigger_fr_poll (dev);
- trigger_fr_arp (dev);
- break;
-
- case WAN_CONNECTING:
- printk(KERN_INFO
- "%s: Interface %s: DLCI %d connecting\n",
- card->devname, dev->name, chan->dlci);
- break;
-
- case WAN_DISCONNECTED:
- printk (KERN_INFO
- "%s: Interface %s: DLCI %d disconnected!\n",
- card->devname, dev->name, chan->dlci);
-
- /* If the interface is up, bring it down,
- * since the channel is now disconnected */
- trigger_fr_poll (dev);
- break;
- }
-
- chan->common.state = state;
- }
-
- chan->state_tick = jiffies;
-}
-
-/*============================================================================
- * Find network device by its channel number.
- *
- * We need this critical flag because we change
- * the dlci_to_dev_map outside the interrupt.
- *
- * NOTE: del_if() functions updates this array, it uses
- * the spin locks to avoid corruption.
- */
-static struct net_device* find_channel(sdla_t* card, unsigned dlci)
-{
- if(dlci > HIGHEST_VALID_DLCI)
- return NULL;
-
- return(card->u.f.dlci_to_dev_map[dlci]);
-}
-
-/*============================================================================
- * Check to see if a frame can be sent. If no transmit buffers available,
- * enable transmit interrupts.
- *
- * Return: 1 - Tx buffer(s) available
- * 0 - no buffers available
- */
-static int is_tx_ready (sdla_t* card, fr_channel_t* chan)
-{
- unsigned char sb;
-
- if(card->hw.type == SDLA_S514)
- return 1;
-
- sb = inb(card->hw.port);
- if (sb & 0x02)
- return 1;
-
- return 0;
-}
-
-/*============================================================================
- * Convert decimal string to unsigned integer.
- * If len != 0 then only 'len' characters of the string are converted.
- */
-static unsigned int dec_to_uint (unsigned char* str, int len)
-{
- unsigned val;
-
- if (!len)
- len = strlen(str);
-
- for (val = 0; len && isdigit(*str); ++str, --len)
- val = (val * 10) + (*str - (unsigned)'0');
-
- return val;
-}
-
-
-
-/*=============================================================================
- * Store a UDP management packet for later processing.
- */
-
-static int store_udp_mgmt_pkt(int udp_type, char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, int dlci)
-{
- int udp_pkt_stored = 0;
-
- struct net_device *dev = find_channel(card, dlci);
- fr_channel_t *chan;
-
- if (!dev || !(chan=dev->priv))
- return 1;
-
- if(!card->u.f.udp_pkt_lgth && (skb->len <= MAX_LGTH_UDP_MGNT_PKT)){
- card->u.f.udp_pkt_lgth = skb->len + chan->fr_header_len;
- card->u.f.udp_type = udp_type;
- card->u.f.udp_pkt_src = udp_pkt_src;
- card->u.f.udp_dlci = dlci;
- memcpy(card->u.f.udp_pkt_data, skb->data, skb->len);
- card->u.f.timer_int_enabled |= TMR_INT_ENABLED_UDP;
- udp_pkt_stored = 1;
-
- }else{
- printk(KERN_INFO "ERROR: UDP packet not stored for DLCI %d\n",
- dlci);
- }
-
- if(udp_pkt_src == UDP_PKT_FRM_STACK){
- dev_kfree_skb_any(skb);
- }else{
- dev_kfree_skb_any(skb);
- }
-
- return(udp_pkt_stored);
-}
-
-
-/*==============================================================================
- * Process UDP call of type FPIPE8ND
- */
-static int process_udp_mgmt_pkt(sdla_t* card)
-{
-
- int c_retry = MAX_CMD_RETRY;
- unsigned char *buf;
- unsigned char frames;
- unsigned int len;
- unsigned short buffer_length;
- struct sk_buff *new_skb;
- fr_mbox_t* mbox = card->mbox;
- int err;
- struct timeval tv;
- int udp_mgmt_req_valid = 1;
- struct net_device* dev;
- fr_channel_t* chan;
- fr_udp_pkt_t *fr_udp_pkt;
- unsigned short num_trc_els;
- fr_trc_el_t* ptr_trc_el;
- fr_trc_el_t trc_el;
- fpipemon_trc_t* fpipemon_trc;
-
- char udp_pkt_src = card->u.f.udp_pkt_src;
- int dlci = card->u.f.udp_dlci;
-
- /* Find network interface for this packet */
- dev = find_channel(card, dlci);
- if (!dev){
- card->u.f.udp_pkt_lgth = 0;
- return 1;
- }
- if ((chan = dev->priv) == NULL){
- card->u.f.udp_pkt_lgth = 0;
- return 1;
- }
-
- /* If the UDP packet is from the network, we are going to have to
- transmit a response. Before doing so, we must check to see that
- we are not currently transmitting a frame (in 'if_send()') and
- that we are not already in a 'delayed transmit' state.
- */
- if(udp_pkt_src == UDP_PKT_FRM_NETWORK) {
- if (check_tx_status(card,dev)){
- card->u.f.udp_pkt_lgth = 0;
- return 1;
- }
- }
-
- fr_udp_pkt = (fr_udp_pkt_t *)card->u.f.udp_pkt_data;
-
- if(udp_pkt_src == UDP_PKT_FRM_NETWORK) {
-
- switch(fr_udp_pkt->cblock.command) {
-
- case FR_READ_MODEM_STATUS:
- case FR_READ_STATUS:
- case FPIPE_ROUTER_UP_TIME:
- case FR_READ_ERROR_STATS:
- case FPIPE_DRIVER_STAT_GEN:
- case FR_READ_STATISTICS:
- case FR_READ_ADD_DLC_STATS:
- case FR_READ_CONFIG:
- case FR_READ_CODE_VERSION:
- udp_mgmt_req_valid = 1;
- break;
- default:
- udp_mgmt_req_valid = 0;
- break;
- }
- }
-
- if(!udp_mgmt_req_valid) {
- /* set length to 0 */
- fr_udp_pkt->cblock.length = 0;
- /* set return code */
- fr_udp_pkt->cblock.result = 0xCD;
-
- chan->drvstats_gen.UDP_PIPE_mgmt_direction_err ++;
-
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Warning, Illegal UDP command attempted from network: %x\n",
- card->devname,fr_udp_pkt->cblock.command);
- }
-
- } else {
-
- switch(fr_udp_pkt->cblock.command) {
-
- case FPIPE_ENABLE_TRACING:
- if(!card->TracingEnabled) {
- do {
- mbox->cmd.command = FR_SET_TRACE_CONFIG;
- mbox->cmd.length = 1;
- mbox->cmd.dlci = 0x00;
- mbox->data[0] = fr_udp_pkt->data[0] |
- RESET_TRC;
- err = sdla_exec(mbox) ?
- mbox->cmd.result : CMD_TIMEOUT;
- } while (err && c_retry-- && fr_event(card, err,
- mbox));
-
- if(err) {
- card->TracingEnabled = 0;
- /* set the return code */
- fr_udp_pkt->cblock.result =
- mbox->cmd.result;
- mbox->cmd.length = 0;
- break;
- }
-
- sdla_peek(&card->hw, NO_TRC_ELEMENTS_OFF,
- &num_trc_els, 2);
- sdla_peek(&card->hw, BASE_TRC_ELEMENTS_OFF,
- &card->u.f.trc_el_base, 4);
- card->u.f.curr_trc_el = card->u.f.trc_el_base;
- card->u.f.trc_el_last = card->u.f.curr_trc_el +
- ((num_trc_els - 1) *
- sizeof(fr_trc_el_t));
-
- /* Calculate the maximum trace data area in */
- /* the UDP packet */
- card->u.f.trc_bfr_space=(MAX_LGTH_UDP_MGNT_PKT -
- //sizeof(fr_encap_hdr_t) -
- sizeof(ip_pkt_t) -
- sizeof(udp_pkt_t) -
- sizeof(wp_mgmt_t) -
- sizeof(cblock_t));
-
- /* set return code */
- fr_udp_pkt->cblock.result = 0;
-
- } else {
- /* set return code to line trace already
- enabled */
- fr_udp_pkt->cblock.result = 1;
- }
-
- mbox->cmd.length = 0;
- card->TracingEnabled = 1;
- break;
-
-
- case FPIPE_DISABLE_TRACING:
- if(card->TracingEnabled) {
-
- do {
- mbox->cmd.command = FR_SET_TRACE_CONFIG;
- mbox->cmd.length = 1;
- mbox->cmd.dlci = 0x00;
- mbox->data[0] = ~ACTIVATE_TRC;
- err = sdla_exec(mbox) ?
- mbox->cmd.result : CMD_TIMEOUT;
- } while (err && c_retry-- && fr_event(card, err, mbox));
- }
-
- /* set return code */
- fr_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 0;
- card->TracingEnabled = 0;
- break;
-
- case FPIPE_GET_TRACE_INFO:
-
- /* Line trace cannot be performed on the 502 */
- if(!card->TracingEnabled) {
- /* set return code */
- fr_udp_pkt->cblock.result = 1;
- mbox->cmd.length = 0;
- break;
- }
-
- ptr_trc_el = (void *)card->u.f.curr_trc_el;
-
- buffer_length = 0;
- fr_udp_pkt->data[0x00] = 0x00;
-
- for(frames = 0; frames < MAX_FRMS_TRACED; frames ++) {
-
- sdla_peek(&card->hw, (unsigned long)ptr_trc_el,
- (void *)&trc_el.flag,
- sizeof(fr_trc_el_t));
- if(trc_el.flag == 0x00) {
- break;
- }
- if((card->u.f.trc_bfr_space - buffer_length)
- < sizeof(fpipemon_trc_hdr_t)) {
- fr_udp_pkt->data[0x00] |= MORE_TRC_DATA;
- break;
- }
-
- fpipemon_trc =
- (fpipemon_trc_t *)&fr_udp_pkt->data[buffer_length];
- fpipemon_trc->fpipemon_trc_hdr.status =
- trc_el.attr;
- fpipemon_trc->fpipemon_trc_hdr.tmstamp =
- trc_el.tmstamp;
- fpipemon_trc->fpipemon_trc_hdr.length =
- trc_el.length;
-
- if(!trc_el.offset || !trc_el.length) {
-
- fpipemon_trc->fpipemon_trc_hdr.data_passed = 0x00;
-
- }else if((trc_el.length + sizeof(fpipemon_trc_hdr_t) + 1) >
- (card->u.f.trc_bfr_space - buffer_length)){
-
- fpipemon_trc->fpipemon_trc_hdr.data_passed = 0x00;
- fr_udp_pkt->data[0x00] |= MORE_TRC_DATA;
-
- }else {
- fpipemon_trc->fpipemon_trc_hdr.data_passed = 0x01;
- sdla_peek(&card->hw, trc_el.offset,
- fpipemon_trc->data,
- trc_el.length);
- }
-
- trc_el.flag = 0x00;
- sdla_poke(&card->hw, (unsigned long)ptr_trc_el,
- &trc_el.flag, 1);
-
- ptr_trc_el ++;
- if((void *)ptr_trc_el > card->u.f.trc_el_last)
- ptr_trc_el = (void*)card->u.f.trc_el_base;
-
- buffer_length += sizeof(fpipemon_trc_hdr_t);
- if(fpipemon_trc->fpipemon_trc_hdr.data_passed) {
- buffer_length += trc_el.length;
- }
-
- if(fr_udp_pkt->data[0x00] & MORE_TRC_DATA) {
- break;
- }
- }
-
- if(frames == MAX_FRMS_TRACED) {
- fr_udp_pkt->data[0x00] |= MORE_TRC_DATA;
- }
-
- card->u.f.curr_trc_el = (void *)ptr_trc_el;
-
- /* set the total number of frames passed */
- fr_udp_pkt->data[0x00] |=
- ((frames << 1) & (MAX_FRMS_TRACED << 1));
-
- /* set the data length and return code */
- fr_udp_pkt->cblock.length = mbox->cmd.length = buffer_length;
- fr_udp_pkt->cblock.result = 0;
- break;
-
- case FPIPE_FT1_READ_STATUS:
- sdla_peek(&card->hw, 0xF020,
- &fr_udp_pkt->data[0x00] , 2);
- fr_udp_pkt->cblock.length = mbox->cmd.length = 2;
- fr_udp_pkt->cblock.result = 0;
- break;
-
- case FPIPE_FLUSH_DRIVER_STATS:
- init_chan_statistics(chan);
- init_global_statistics(card);
- mbox->cmd.length = 0;
- break;
-
- case FPIPE_ROUTER_UP_TIME:
- do_gettimeofday(&tv);
- chan->router_up_time = tv.tv_sec -
- chan->router_start_time;
- *(unsigned long *)&fr_udp_pkt->data =
- chan->router_up_time;
- mbox->cmd.length = fr_udp_pkt->cblock.length = 4;
- fr_udp_pkt->cblock.result = 0;
- break;
-
- case FPIPE_DRIVER_STAT_IFSEND:
- memcpy(fr_udp_pkt->data,
- &chan->drvstats_if_send.if_send_entry,
- sizeof(if_send_stat_t));
- mbox->cmd.length = fr_udp_pkt->cblock.length =sizeof(if_send_stat_t);
- fr_udp_pkt->cblock.result = 0;
- break;
-
- case FPIPE_DRIVER_STAT_INTR:
-
- memcpy(fr_udp_pkt->data,
- &card->statistics.isr_entry,
- sizeof(global_stats_t));
-
- memcpy(&fr_udp_pkt->data[sizeof(global_stats_t)],
- &chan->drvstats_rx_intr.rx_intr_no_socket,
- sizeof(rx_intr_stat_t));
-
- mbox->cmd.length = fr_udp_pkt->cblock.length =
- sizeof(global_stats_t) +
- sizeof(rx_intr_stat_t);
- fr_udp_pkt->cblock.result = 0;
- break;
-
- case FPIPE_DRIVER_STAT_GEN:
- memcpy(fr_udp_pkt->data,
- &chan->drvstats_gen.UDP_PIPE_mgmt_kmalloc_err,
- sizeof(pipe_mgmt_stat_t));
-
- memcpy(&fr_udp_pkt->data[sizeof(pipe_mgmt_stat_t)],
- &card->statistics, sizeof(global_stats_t));
-
- mbox->cmd.length = fr_udp_pkt->cblock.length = sizeof(global_stats_t)+
- sizeof(rx_intr_stat_t);
- fr_udp_pkt->cblock.result = 0;
- break;
-
-
- case FR_FT1_STATUS_CTRL:
- if(fr_udp_pkt->data[0] == 1) {
- if(rCount++ != 0 ){
- fr_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 1;
- break;
- }
- }
-
- /* Disable FT1 MONITOR STATUS */
- if(fr_udp_pkt->data[0] == 0) {
- if( --rCount != 0) {
- fr_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 1;
- break;
- }
- }
- goto udp_mgmt_dflt;
-
-
- default:
-udp_mgmt_dflt:
- do {
- memcpy(&mbox->cmd,
- &fr_udp_pkt->cblock.command,
- sizeof(fr_cmd_t));
- if(mbox->cmd.length) {
- memcpy(&mbox->data,
- (char *)fr_udp_pkt->data,
- mbox->cmd.length);
- }
-
- err = sdla_exec(mbox) ? mbox->cmd.result :
- CMD_TIMEOUT;
- } while (err && c_retry-- && fr_event(card, err, mbox));
-
- if(!err)
- chan->drvstats_gen.
- UDP_PIPE_mgmt_adptr_cmnd_OK ++;
- else
- chan->drvstats_gen.
- UDP_PIPE_mgmt_adptr_cmnd_timeout ++;
-
- /* copy the result back to our buffer */
- memcpy(&fr_udp_pkt->cblock.command,
- &mbox->cmd, sizeof(fr_cmd_t));
-
- if(mbox->cmd.length) {
- memcpy(&fr_udp_pkt->data,
- &mbox->data, mbox->cmd.length);
- }
- }
- }
-
- /* Fill UDP TTL */
- fr_udp_pkt->ip_pkt.ttl = card->wandev.ttl;
- len = reply_udp(card->u.f.udp_pkt_data, mbox->cmd.length);
-
- if(udp_pkt_src == UDP_PKT_FRM_NETWORK) {
-
- chan->fr_header_len=2;
- chan->fr_header[0]=Q922_UI;
- chan->fr_header[1]=NLPID_IP;
-
- err = fr_send_data_header(card, dlci, 0, len,
- card->u.f.udp_pkt_data,chan->fr_header_len);
- if (err){
- chan->drvstats_gen.UDP_PIPE_mgmt_adptr_send_passed ++;
- }else{
- chan->drvstats_gen.UDP_PIPE_mgmt_adptr_send_failed ++;
- }
-
- } else {
- /* Allocate socket buffer */
- if((new_skb = dev_alloc_skb(len)) != NULL) {
-
- /* copy data into new_skb */
- buf = skb_put(new_skb, len);
- memcpy(buf, card->u.f.udp_pkt_data, len);
-
- chan->drvstats_gen.
- UDP_PIPE_mgmt_passed_to_stack ++;
- new_skb->dev = dev;
- new_skb->protocol = htons(ETH_P_IP);
- new_skb->mac.raw = new_skb->data;
- netif_rx(new_skb);
-
- } else {
- chan->drvstats_gen.UDP_PIPE_mgmt_no_socket ++;
- printk(KERN_INFO
- "%s: UDP mgmt cmnd, no socket buffers available!\n",
- card->devname);
- }
- }
-
- card->u.f.udp_pkt_lgth = 0;
-
- return 1;
-}
-
-/*==============================================================================
- * Send Inverse ARP Request
- */
-
-int send_inarp_request(sdla_t *card, struct net_device *dev)
-{
- int err=0;
-
- arphdr_1490_t *ArpPacket;
- arphdr_fr_t *arphdr;
- fr_channel_t *chan = dev->priv;
- struct in_device *in_dev;
-
- in_dev = dev->ip_ptr;
-
- if(in_dev != NULL ) {
-
- ArpPacket = kmalloc(sizeof(arphdr_1490_t) + sizeof(arphdr_fr_t), GFP_ATOMIC);
- /* SNAP Header indicating ARP */
- ArpPacket->control = 0x03;
- ArpPacket->pad = 0x00;
- ArpPacket->NLPID = 0x80;
- ArpPacket->OUI[0] = 0;
- ArpPacket->OUI[1] = 0;
- ArpPacket->OUI[2] = 0;
- ArpPacket->PID = 0x0608;
-
- arphdr = (arphdr_fr_t *)(ArpPacket + 1); // Go to ARP Packet
-
- /* InARP request */
- arphdr->ar_hrd = 0x0F00; /* Frame Relay HW type */
- arphdr->ar_pro = 0x0008; /* IP Protocol */
- arphdr->ar_hln = 2; /* HW addr length */
- arphdr->ar_pln = 4; /* IP addr length */
- arphdr->ar_op = htons(0x08); /* InARP Request */
- arphdr->ar_sha = 0; /* src HW DLCI - Doesn't matter */
- if(in_dev->ifa_list != NULL)
- arphdr->ar_sip = in_dev->ifa_list->ifa_local; /* Local Address */else
- arphdr->ar_sip = 0;
- arphdr->ar_tha = 0; /* dst HW DLCI - Doesn't matter */
- arphdr->ar_tip = 0; /* Remote Address -- what we want */
-
- err = fr_send(card, chan->dlci, 0, sizeof(arphdr_1490_t) + sizeof(arphdr_fr_t),
- (void *)ArpPacket);
-
- if (!err){
- printk(KERN_INFO "\n%s: Sending InARP request on DLCI %d.\n",
- card->devname, chan->dlci);
- clear_bit(ARP_CRIT,&card->wandev.critical);
- }
-
- kfree(ArpPacket);
- }else{
- printk(KERN_INFO "%s: INARP ERROR: %s doesn't have a local IP address!\n",
- card->devname,dev->name);
- return 1;
- }
-
- return 0;
-}
-
-
-/*==============================================================================
- * Check packet for ARP Type
- */
-
-int is_arp(void *buf)
-{
- arphdr_1490_t *arphdr = (arphdr_1490_t *)buf;
-
- if (arphdr->pad == 0x00 &&
- arphdr->NLPID == 0x80 &&
- arphdr->PID == 0x0608)
- return 1;
- else return 0;
-}
-
-/*==============================================================================
- * Process ARP Packet Type
- */
-
-int process_ARP(arphdr_1490_t *ArpPacket, sdla_t *card, struct net_device* dev)
-{
-
-
- arphdr_fr_t *arphdr = (arphdr_fr_t *)(ArpPacket + 1); /* Skip header */
- fr_rx_buf_ctl_t* frbuf = card->rxmb;
- struct in_device *in_dev;
- fr_channel_t *chan = dev->priv;
-
- /* Before we transmit ARP packet, we must check
- * to see that we are not currently transmitting a
- * frame (in 'if_send()') and that we are not
- * already in a 'delayed transmit' state. */
- if (check_tx_status(card,dev)){
- if (net_ratelimit()){
- printk(KERN_INFO "%s: Disabling comminication to process ARP\n",
- card->devname);
- }
- set_bit(ARP_CRIT,&card->wandev.critical);
- return 0;
- }
-
- in_dev = dev->ip_ptr;
-
- /* Check that IP addresses exist for our network address */
- if (in_dev == NULL || in_dev->ifa_list == NULL)
- return -1;
-
- switch (ntohs(arphdr->ar_op)) {
-
- case 0x08: // Inverse ARP request -- Send Reply, add route.
-
- /* Check for valid Address */
- printk(KERN_INFO "%s: Recvd PtP addr -InArp Req: %u.%u.%u.%u\n",
- card->devname, NIPQUAD(arphdr->ar_sip));
-
-
- /* Check that the network address is the same as ours, only
- * if the netowrk mask is not 255.255.255.255. Otherwise
- * this check would not make sense */
-
- if (in_dev->ifa_list->ifa_mask != 0xFFFFFFFF &&
- (in_dev->ifa_list->ifa_mask & arphdr->ar_sip) !=
- (in_dev->ifa_list->ifa_mask & in_dev->ifa_list->ifa_local)){
- printk(KERN_INFO
- "%s: Invalid PtP address. %u.%u.%u.%u InARP ignored.\n",
- card->devname,NIPQUAD(arphdr->ar_sip));
-
- printk(KERN_INFO "%s: mask %u.%u.%u.%u\n",
- card->devname, NIPQUAD(in_dev->ifa_list->ifa_mask));
- printk(KERN_INFO "%s: local %u.%u.%u.%u\n",
- card->devname,NIPQUAD(in_dev->ifa_list->ifa_local));
- return -1;
- }
-
- if (in_dev->ifa_list->ifa_local == arphdr->ar_sip){
- printk(KERN_INFO
- "%s: Local addr = PtP addr. InARP ignored.\n",
- card->devname);
- return -1;
- }
-
- arphdr->ar_op = htons(0x09); /* InARP Reply */
-
- /* Set addresses */
- arphdr->ar_tip = arphdr->ar_sip;
- arphdr->ar_sip = in_dev->ifa_list->ifa_local;
-
- chan->ip_local = in_dev->ifa_list->ifa_local;
- chan->ip_remote = arphdr->ar_sip;
-
- fr_send(card, frbuf->dlci, 0, frbuf->length, (void *)ArpPacket);
-
- if (test_bit(ARP_CRIT,&card->wandev.critical)){
- if (net_ratelimit()){
- printk(KERN_INFO "%s: ARP Processed Enabling Communication!\n",
- card->devname);
- }
- }
- clear_bit(ARP_CRIT,&card->wandev.critical);
-
- chan->ip_local = in_dev->ifa_list->ifa_local;
- chan->ip_remote = arphdr->ar_sip;
-
- /* Add Route Flag */
- /* The route will be added in the polling routine so
- that it is not interrupt context. */
-
- chan->route_flag = ADD_ROUTE;
- trigger_fr_poll (dev);
-
- break;
-
- case 0x09: // Inverse ARP reply
-
- /* Check for valid Address */
- printk(KERN_INFO "%s: Recvd PtP addr %u.%u.%u.%u -InArp Reply\n",
- card->devname, NIPQUAD(arphdr->ar_sip));
-
-
- /* Compare network addresses, only if network mask
- * is not 255.255.255.255 It would not make sense
- * to perform this test if the mask was all 1's */
-
- if (in_dev->ifa_list->ifa_mask != 0xffffffff &&
- (in_dev->ifa_list->ifa_mask & arphdr->ar_sip) !=
- (in_dev->ifa_list->ifa_mask & in_dev->ifa_list->ifa_local)) {
-
- printk(KERN_INFO "%s: Invalid PtP address. InARP ignored.\n",
- card->devname);
- return -1;
- }
-
- /* Make sure that the received IP address is not
- * the same as our own local address */
- if (in_dev->ifa_list->ifa_local == arphdr->ar_sip) {
- printk(KERN_INFO "%s: Local addr = PtP addr. InARP ignored.\n",
- card->devname);
- return -1;
- }
-
- chan->ip_local = in_dev->ifa_list->ifa_local;
- chan->ip_remote = arphdr->ar_sip;
-
- /* Add Route Flag */
- /* The route will be added in the polling routine so
- that it is not interrupt context. */
-
- chan->route_flag = ADD_ROUTE;
- chan->inarp = INARP_CONFIGURED;
- trigger_fr_poll(dev);
-
- break;
- default:
- break; // ARP's and RARP's -- Shouldn't happen.
- }
-
- return 0;
-}
-
-
-/*============================================================
- * trigger_fr_arp
- *
- * Description:
- * Add an fr_arp() task into a arp
- * timer handler for a specific dlci/interface.
- * This will kick the fr_arp() routine
- * within the specified time interval.
- *
- * Usage:
- * This timer is used to send ARP requests at
- * certain time intervals.
- * Called by an interrupt to request an action
- * at a later date.
- */
-
-static void trigger_fr_arp(struct net_device *dev)
-{
- fr_channel_t* chan = dev->priv;
-
- mod_timer(&chan->fr_arp_timer, jiffies + chan->inarp_interval * HZ);
- return;
-}
-
-
-
-/*==============================================================================
- * ARP Request Action
- *
- * This funciton is called by timer interrupt to send an arp request
- * to the remote end.
- */
-
-static void fr_arp (unsigned long data)
-{
- struct net_device *dev = (struct net_device *)data;
- fr_channel_t *chan = dev->priv;
- volatile sdla_t *card = chan->card;
- fr508_flags_t* flags = card->flags;
-
- /* Send ARP packets for all devs' until
- * ARP state changes to CONFIGURED */
-
- if (chan->inarp == INARP_REQUEST &&
- chan->common.state == WAN_CONNECTED &&
- card->wandev.state == WAN_CONNECTED){
- set_bit(0,&chan->inarp_ready);
- card->u.f.timer_int_enabled |= TMR_INT_ENABLED_ARP;
- flags->imask |= FR_INTR_TIMER;
- }
-
- return;
-}
-
-
-/*==============================================================================
- * Perform the Interrupt Test by running the READ_CODE_VERSION command MAX_INTR_
- * TEST_COUNTER times.
- */
-static int intr_test( sdla_t* card )
-{
- fr_mbox_t* mb = card->mbox;
- int err,i;
-
- err = fr_set_intr_mode(card, FR_INTR_READY, card->wandev.mtu, 0 );
-
- if (err == CMD_OK) {
-
- for ( i = 0; i < MAX_INTR_TEST_COUNTER; i++ ) {
- /* Run command READ_CODE_VERSION */
- mb->cmd.length = 0;
- mb->cmd.command = FR_READ_CODE_VERSION;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
- if (err != CMD_OK)
- fr_event(card, err, mb);
- }
-
- } else {
- return err;
- }
-
- err = fr_set_intr_mode( card, 0, card->wandev.mtu, 0 );
-
- if( err != CMD_OK )
- return err;
-
- return 0;
-}
-
-/*==============================================================================
- * Determine what type of UDP call it is. FPIPE8ND ?
- */
-static int udp_pkt_type( struct sk_buff *skb, sdla_t* card )
-{
- fr_udp_pkt_t *fr_udp_pkt = (fr_udp_pkt_t *)skb->data;
-
- /* Quick HACK */
-
-
- if((fr_udp_pkt->ip_pkt.protocol == UDPMGMT_UDP_PROTOCOL) &&
- (fr_udp_pkt->ip_pkt.ver_inet_hdr_length == 0x45) &&
- (fr_udp_pkt->udp_pkt.udp_dst_port ==
- ntohs(card->wandev.udp_port)) &&
- (fr_udp_pkt->wp_mgmt.request_reply ==
- UDPMGMT_REQUEST)) {
- if(!strncmp(fr_udp_pkt->wp_mgmt.signature,
- UDPMGMT_FPIPE_SIGNATURE, 8)){
- return UDP_FPIPE_TYPE;
- }
- }
- return UDP_INVALID_TYPE;
-}
-
-
-/*==============================================================================
- * Initializes the Statistics values in the fr_channel structure.
- */
-void init_chan_statistics( fr_channel_t* chan)
-{
- memset(&chan->drvstats_if_send.if_send_entry, 0,
- sizeof(if_send_stat_t));
- memset(&chan->drvstats_rx_intr.rx_intr_no_socket, 0,
- sizeof(rx_intr_stat_t));
- memset(&chan->drvstats_gen.UDP_PIPE_mgmt_kmalloc_err, 0,
- sizeof(pipe_mgmt_stat_t));
-}
-
-/*==============================================================================
- * Initializes the Statistics values in the Sdla_t structure.
- */
-void init_global_statistics( sdla_t* card )
-{
- /* Intialize global statistics for a card */
- memset(&card->statistics.isr_entry, 0, sizeof(global_stats_t));
-}
-
-static void read_DLCI_IB_mapping( sdla_t* card, fr_channel_t* chan )
-{
- fr_mbox_t* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- dlci_IB_mapping_t* result;
- int err, counter, found;
-
- do {
- mbox->cmd.command = FR_READ_DLCI_IB_MAPPING;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && fr_event(card, err, mbox));
-
- if( mbox->cmd.result != 0){
- printk(KERN_INFO "%s: Read DLCI IB Mapping failed\n",
- chan->name);
- }
-
- counter = mbox->cmd.length / sizeof(dlci_IB_mapping_t);
- result = (void *)mbox->data;
-
- found = 0;
- for (; counter; --counter, ++result) {
- if ( result->dlci == chan->dlci ) {
- chan->IB_addr = result->addr_value;
- if(card->hw.type == SDLA_S514){
- chan->dlci_int_interface =
- (void*)(card->hw.dpmbase +
- chan->IB_addr);
- }else{
- chan->dlci_int_interface =
- (void*)(card->hw.dpmbase +
- (chan->IB_addr & 0x00001FFF));
-
- }
- found = 1;
- break;
- }
- }
- if (!found)
- printk( KERN_INFO "%s: DLCI %d not found by IB MAPPING cmd\n",
- card->devname, chan->dlci);
-}
-
-
-
-void s508_s514_lock(sdla_t *card, unsigned long *smp_flags)
-{
- if (card->hw.type != SDLA_S514){
-
- spin_lock_irqsave(&card->wandev.lock, *smp_flags);
- }else{
- spin_lock(&card->u.f.if_send_lock);
- }
- return;
-}
-
-
-void s508_s514_unlock(sdla_t *card, unsigned long *smp_flags)
-{
- if (card->hw.type != SDLA_S514){
-
- spin_unlock_irqrestore (&card->wandev.lock, *smp_flags);
- }else{
- spin_unlock(&card->u.f.if_send_lock);
- }
- return;
-}
-
-
-
-/*----------------------------------------------------------------------
- RECEIVE INTERRUPT: BOTTOM HALF HANDLERS
- ----------------------------------------------------------------------*/
-
-
-/*========================================================
- * bh_enqueue
- *
- * Description:
- * Insert a received packet into a circular
- * rx queue. This packet will be picked up
- * by fr_bh() and sent up the stack to the
- * user.
- *
- * Usage:
- * This function is called by rx interrupt,
- * in API mode.
- *
- */
-
-static int bh_enqueue(struct net_device *dev, struct sk_buff *skb)
-{
- /* Check for full */
- fr_channel_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
-
- if (atomic_read(&chan->bh_buff_used) == MAX_BH_BUFF){
- ++card->wandev.stats.rx_dropped;
- dev_kfree_skb_any(skb);
- return 1;
- }
-
- ((bh_data_t *)&chan->bh_head[chan->bh_write])->skb = skb;
-
- if (chan->bh_write == (MAX_BH_BUFF-1)){
- chan->bh_write=0;
- }else{
- ++chan->bh_write;
- }
-
- atomic_inc(&chan->bh_buff_used);
-
- return 0;
-}
-
-
-/*========================================================
- * trigger_fr_bh
- *
- * Description:
- * Kick the fr_bh() handler
- *
- * Usage:
- * rx interrupt calls this function during
- * the API mode.
- */
-
-static void trigger_fr_bh (fr_channel_t *chan)
-{
- if (!test_and_set_bit(0,&chan->tq_working)){
- wanpipe_queue_work(&chan->common.wanpipe_work);
- }
-}
-
-
-/*========================================================
- * fr_bh
- *
- * Description:
- * Frame relay receive BH handler.
- * Dequeue data from the BH circular
- * buffer and pass it up the API sock.
- *
- * Rationale:
- * This fuction is used to offload the
- * rx_interrupt during API operation mode.
- * The fr_bh() function executes for each
- * dlci/interface.
- *
- * Once receive interrupt copies data from the
- * card into an skb buffer, the skb buffer
- * is appended to a circular BH buffer.
- * Then the interrupt kicks fr_bh() to finish the
- * job at a later time (not within the interrupt).
- *
- * Usage:
- * Interrupts use this to defer a task to
- * a polling routine.
- *
- */
-
-static void fr_bh(struct net_device * dev)
-{
- fr_channel_t* chan = dev->priv;
- sdla_t *card = chan->card;
- struct sk_buff *skb;
-
- if (atomic_read(&chan->bh_buff_used) == 0){
- clear_bit(0, &chan->tq_working);
- return;
- }
-
- while (atomic_read(&chan->bh_buff_used)){
-
- if (chan->common.sk == NULL || chan->common.func == NULL){
- clear_bit(0, &chan->tq_working);
- return;
- }
-
- skb = ((bh_data_t *)&chan->bh_head[chan->bh_read])->skb;
-
- if (skb != NULL){
-
- if (chan->common.sk == NULL || chan->common.func == NULL){
- ++card->wandev.stats.rx_dropped;
- ++chan->ifstats.rx_dropped;
- dev_kfree_skb_any(skb);
- fr_bh_cleanup(dev);
- continue;
- }
-
- if (chan->common.func(skb,dev,chan->common.sk) != 0){
- /* Sock full cannot send, queue us for
- * another try */
- atomic_set(&chan->common.receive_block,1);
- return;
- }else{
- fr_bh_cleanup(dev);
- }
- }else{
- fr_bh_cleanup(dev);
- }
- }
- clear_bit(0, &chan->tq_working);
-
- return;
-}
-
-static int fr_bh_cleanup(struct net_device *dev)
-{
- fr_channel_t* chan = dev->priv;
-
- ((bh_data_t *)&chan->bh_head[chan->bh_read])->skb = NULL;
-
- if (chan->bh_read == (MAX_BH_BUFF-1)){
- chan->bh_read=0;
- }else{
- ++chan->bh_read;
- }
-
- atomic_dec(&chan->bh_buff_used);
- return 0;
-}
-
-
-/*----------------------------------------------------------------------
- POLL BH HANDLERS AND KICK ROUTINES
- ----------------------------------------------------------------------*/
-
-/*============================================================
- * trigger_fr_poll
- *
- * Description:
- * Add a fr_poll() task into a tq_scheduler bh handler
- * for a specific dlci/interface. This will kick
- * the fr_poll() routine at a later time.
- *
- * Usage:
- * Interrupts use this to defer a taks to
- * a polling routine.
- *
- */
-static void trigger_fr_poll(struct net_device *dev)
-{
- fr_channel_t* chan = dev->priv;
- schedule_work(&chan->fr_poll_work);
- return;
-}
-
-
-/*============================================================
- * fr_poll
- *
- * Rationale:
- * We cannot manipulate the routing tables, or
- * ip addresses withing the interrupt. Therefore
- * we must perform such actons outside an interrupt
- * at a later time.
- *
- * Description:
- * Frame relay polling routine, responsible for
- * shutting down interfaces upon disconnect
- * and adding/removing routes.
- *
- * Usage:
- * This function is executed for each frame relay
- * dlci/interface through a tq_schedule bottom half.
- *
- * trigger_fr_poll() function is used to kick
- * the fr_poll routine.
- */
-
-static void fr_poll(struct net_device *dev)
-{
-
- fr_channel_t* chan;
- sdla_t *card;
- u8 check_gateway=0;
-
- if (!dev || (chan = dev->priv) == NULL)
- return;
-
- card = chan->card;
-
- /* (Re)Configuraiton is in progress, stop what you are
- * doing and get out */
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- return;
- }
-
- switch (chan->common.state){
-
- case WAN_DISCONNECTED:
-
- if (test_bit(DYN_OPT_ON,&chan->interface_down) &&
- !test_bit(DEV_DOWN, &chan->interface_down) &&
- dev->flags&IFF_UP){
-
- printk(KERN_INFO "%s: Interface %s is Down.\n",
- card->devname,dev->name);
- change_dev_flags(dev,dev->flags&~IFF_UP);
- set_bit(DEV_DOWN, &chan->interface_down);
- chan->route_flag = NO_ROUTE;
-
- }else{
- if (chan->inarp != INARP_NONE)
- process_route(dev);
- }
- break;
-
- case WAN_CONNECTED:
-
- if (test_bit(DYN_OPT_ON,&chan->interface_down) &&
- test_bit(DEV_DOWN, &chan->interface_down) &&
- !(dev->flags&IFF_UP)){
-
- printk(KERN_INFO "%s: Interface %s is Up.\n",
- card->devname,dev->name);
-
- change_dev_flags(dev,dev->flags|IFF_UP);
- clear_bit(DEV_DOWN, &chan->interface_down);
- check_gateway=1;
- }
-
- if (chan->inarp != INARP_NONE){
- process_route(dev);
- check_gateway=1;
- }
-
- if (chan->gateway && check_gateway)
- add_gateway(card,dev);
-
- break;
-
- }
-
- return;
-}
-
-/*==============================================================
- * check_tx_status
- *
- * Rationale:
- * We cannot transmit from an interrupt while
- * the if_send is transmitting data. Therefore,
- * we must check whether the tx buffers are
- * begin used, before we transmit from an
- * interrupt.
- *
- * Description:
- * Checks whether it's safe to use the transmit
- * buffers.
- *
- * Usage:
- * ARP and UDP handling routines use this function
- * because, they need to transmit data during
- * an interrupt.
- */
-
-static int check_tx_status(sdla_t *card, struct net_device *dev)
-{
-
- if (card->hw.type == SDLA_S514){
- if (test_bit(SEND_CRIT, (void*)&card->wandev.critical) ||
- test_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical)) {
- return 1;
- }
- }
-
- if (netif_queue_stopped(dev) || (card->u.f.tx_interrupts_pending))
- return 1;
-
- return 0;
-}
-
-/*===============================================================
- * move_dev_to_next
- *
- * Description:
- * Move the dev pointer to the next location in the
- * link list. Check if we are at the end of the
- * list, if so start from the begining.
- *
- * Usage:
- * Timer interrupt uses this function to efficiently
- * step through the devices that need to send ARP data.
- *
- */
-
-struct net_device *move_dev_to_next(sdla_t *card, struct net_device *dev)
-{
- if (card->wandev.new_if_cnt != 1){
- if (!*((struct net_device **)dev->priv))
- return card->wandev.dev;
- else
- return *((struct net_device **)dev->priv);
- }
- return dev;
-}
-
-/*==============================================================
- * trigger_config_fr
- *
- * Rationale:
- * All commands must be performed inside of a
- * interrupt.
- *
- * Description:
- * Kick the config_fr() routine throught the
- * timer interrupt.
- */
-
-
-static void trigger_config_fr (sdla_t *card)
-{
- fr508_flags_t* flags = card->flags;
-
- card->u.f.timer_int_enabled |= TMR_INT_ENABLED_CONFIG;
- flags->imask |= FR_INTR_TIMER;
-}
-
-
-/*==============================================================
- * config_fr
- *
- * Rationale:
- * All commands must be performed inside of a
- * interrupt.
- &
- * Description:
- * Configure a DLCI. This function is executed
- * by a timer_interrupt. The if_open() function
- * triggers it.
- *
- * Usage:
- * new_if() collects all data necessary to
- * configure the DLCI. It sets the chan->dlci_ready
- * bit. When the if_open() function is executed
- * it checks this bit, and if its set it triggers
- * the timer interrupt to execute the config_fr()
- * function.
- */
-
-static void config_fr (sdla_t *card)
-{
- struct net_device *dev;
- fr_channel_t *chan;
-
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)) {
-
- if ((chan=dev->priv) == NULL)
- continue;
-
- if (!test_bit(0,&chan->config_dlci))
- continue;
-
- clear_bit(0,&chan->config_dlci);
-
- /* If signalling is set to NO, then setup
- * DLCI addresses right away. Don't have to wait for
- * link to connect.
- */
- if (card->wandev.signalling == WANOPT_NO){
- printk(KERN_INFO "%s: Signalling set to NO: Mapping DLCI's\n",
- card->wandev.name);
- if (fr_init_dlci(card,chan)){
- printk(KERN_INFO "%s: ERROR: Failed to configure DLCI %i !\n",
- card->devname, chan->dlci);
- return;
- }
- }
-
- if (card->wandev.station == WANOPT_CPE) {
-
- update_chan_state(dev);
-
- /* CPE: issue full status enquiry */
- fr_issue_isf(card, FR_ISF_FSE);
-
- } else {
- /* FR switch: activate DLCI(s) */
-
- /* For Switch emulation we have to ADD and ACTIVATE
- * the DLCI(s) that were configured with the SET_DLCI_
- * CONFIGURATION command. Add and Activate will fail if
- * DLCI specified is not included in the list.
- *
- * Also If_open is called once for each interface. But
- * it does not get in here for all the interface. So
- * we have to pass the entire list of DLCI(s) to add
- * activate routines.
- */
-
- if (!check_dlci_config (card, chan)){
- fr_add_dlci(card, chan->dlci);
- fr_activate_dlci(card, chan->dlci);
- }
- }
-
- card->u.f.dlci_to_dev_map[chan->dlci] = dev;
- }
- return;
-}
-
-
-/*==============================================================
- * config_fr
- *
- * Rationale:
- * All commands must be executed during an interrupt.
- *
- * Description:
- * Trigger uncofig_fr() function through
- * the timer interrupt.
- *
- */
-
-static void trigger_unconfig_fr(struct net_device *dev)
-{
- fr_channel_t *chan = dev->priv;
- volatile sdla_t *card = chan->card;
- unsigned long timeout;
- fr508_flags_t* flags = card->flags;
- int reset_critical=0;
-
- if (test_bit(PERI_CRIT,(void*)&card->wandev.critical)){
- clear_bit(PERI_CRIT,(void*)&card->wandev.critical);
- reset_critical=1;
- }
-
- /* run unconfig_dlci() function
- * throught the timer interrupt */
- set_bit(0,(void*)&chan->unconfig_dlci);
- card->u.f.timer_int_enabled |= TMR_INT_ENABLED_UNCONFIG;
- flags->imask |= FR_INTR_TIMER;
-
- /* Wait for the command to complete */
- timeout = jiffies;
- for(;;) {
-
- if(!(card->u.f.timer_int_enabled & TMR_INT_ENABLED_UNCONFIG))
- break;
-
- if (time_after(jiffies, timeout + 1 * HZ)){
- card->u.f.timer_int_enabled &= ~TMR_INT_ENABLED_UNCONFIG;
- printk(KERN_INFO "%s: Failed to delete DLCI %i\n",
- card->devname,chan->dlci);
- break;
- }
- }
-
- if (reset_critical){
- set_bit(PERI_CRIT,(void*)&card->wandev.critical);
- }
-}
-
-/*==============================================================
- * unconfig_fr
- *
- * Rationale:
- * All commands must be executed during an interrupt.
- *
- * Description:
- * Remove the dlci from firmware.
- * This funciton is used in NODE shutdown.
- */
-
-static void unconfig_fr (sdla_t *card)
-{
- struct net_device *dev;
- fr_channel_t *chan;
-
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)){
-
- if ((chan=dev->priv) == NULL)
- continue;
-
- if (!test_bit(0,&chan->unconfig_dlci))
- continue;
-
- clear_bit(0,&chan->unconfig_dlci);
-
- if (card->wandev.station == WANOPT_NODE){
- printk(KERN_INFO "%s: Unconfiguring DLCI %i\n",
- card->devname,chan->dlci);
- fr_delete_dlci(card,chan->dlci);
- }
- card->u.f.dlci_to_dev_map[chan->dlci] = NULL;
- }
-}
-
-static int setup_fr_header(struct sk_buff *skb, struct net_device* dev,
- char op_mode)
-{
- fr_channel_t *chan=dev->priv;
-
- if (op_mode == WANPIPE) {
- chan->fr_header[0]=Q922_UI;
-
- switch (htons(skb->protocol)){
- case ETH_P_IP:
- chan->fr_header[1]=NLPID_IP;
- break;
- default:
- return -EINVAL;
- }
-
- return 2;
- }
-
- /* If we are in bridging mode, we must apply
- * an Ethernet header
- */
- if (op_mode == BRIDGE || op_mode == BRIDGE_NODE) {
- /* Encapsulate the packet as a bridged Ethernet frame. */
-#ifdef DEBUG
- printk(KERN_INFO "%s: encapsulating skb for frame relay\n",
- dev->name);
-#endif
- chan->fr_header[0] = 0x03;
- chan->fr_header[1] = 0x00;
- chan->fr_header[2] = 0x80;
- chan->fr_header[3] = 0x00;
- chan->fr_header[4] = 0x80;
- chan->fr_header[5] = 0xC2;
- chan->fr_header[6] = 0x00;
- chan->fr_header[7] = 0x07;
-
- /* Yuck. */
- skb->protocol = ETH_P_802_3;
- return 8;
- }
-
- return 0;
-}
-
-
-static int check_dlci_config (sdla_t *card, fr_channel_t *chan)
-{
- fr_mbox_t* mbox = card->mbox;
- int err=0;
- fr_conf_t *conf=NULL;
- unsigned short dlci_num = chan->dlci;
- int dlci_offset=0;
- struct net_device *dev = NULL;
-
- mbox->cmd.command = FR_READ_CONFIG;
- mbox->cmd.length = 0;
- mbox->cmd.dlci = dlci_num;
-
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- if (err == CMD_OK){
- return 0;
- }
-
- for (dev = card->wandev.dev; dev;
- dev=*((struct net_device **)dev->priv))
- set_chan_state(dev,WAN_DISCONNECTED);
-
- printk(KERN_INFO "DLCI %i Not configured, configuring\n",dlci_num);
-
- mbox->cmd.command = FR_COMM_DISABLE;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err != CMD_OK){
- fr_event(card, err, mbox);
- return 2;
- }
-
- printk(KERN_INFO "Disabled Communications \n");
-
- mbox->cmd.command = FR_READ_CONFIG;
- mbox->cmd.length = 0;
- mbox->cmd.dlci = 0;
-
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK){
- fr_event(card, err, mbox);
- return 2;
- }
-
- conf = (fr_conf_t *)mbox->data;
-
- dlci_offset=0;
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)) {
- fr_channel_t *chan_tmp = dev->priv;
- conf->dlci[dlci_offset] = chan_tmp->dlci;
- dlci_offset++;
- }
-
- printk(KERN_INFO "Got Fr configuration Buffer Length is %x Dlci %i Dlci Off %i\n",
- mbox->cmd.length,
- mbox->cmd.length > 0x20 ? conf->dlci[0] : -1,
- dlci_offset );
-
- mbox->cmd.length = 0x20 + dlci_offset*2;
-
- mbox->cmd.command = FR_SET_CONFIG;
- mbox->cmd.dlci = 0;
-
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK){
- fr_event(card, err, mbox);
- return 2;
- }
-
- initialize_rx_tx_buffers (card);
-
-
- printk(KERN_INFO "Configuraiton Succeded for new DLCI %i\n",dlci_num);
-
- if (fr_comm_enable (card)){
- return 2;
- }
-
- printk(KERN_INFO "Enabling Communications \n");
-
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)) {
- fr_channel_t *chan_tmp = dev->priv;
- fr_init_dlci(card,chan_tmp);
- fr_add_dlci(card, chan_tmp->dlci);
- fr_activate_dlci(card, chan_tmp->dlci);
- }
-
- printk(KERN_INFO "END OF CONFIGURAITON %i\n",dlci_num);
-
- return 1;
-}
-
-static void initialize_rx_tx_buffers (sdla_t *card)
-{
- fr_buf_info_t* buf_info;
-
- if (card->hw.type == SDLA_S514) {
-
- buf_info = (void*)(card->hw.dpmbase + FR_MB_VECTOR +
- FR508_RXBC_OFFS);
-
- card->rxmb = (void*)(buf_info->rse_next + card->hw.dpmbase);
-
- card->u.f.rxmb_base =
- (void*)(buf_info->rse_base + card->hw.dpmbase);
-
- card->u.f.rxmb_last =
- (void*)(buf_info->rse_base +
- (buf_info->rse_num - 1) * sizeof(fr_rx_buf_ctl_t) +
- card->hw.dpmbase);
- }else{
- buf_info = (void*)(card->hw.dpmbase + FR508_RXBC_OFFS);
-
- card->rxmb = (void*)(buf_info->rse_next -
- FR_MB_VECTOR + card->hw.dpmbase);
-
- card->u.f.rxmb_base =
- (void*)(buf_info->rse_base -
- FR_MB_VECTOR + card->hw.dpmbase);
-
- card->u.f.rxmb_last =
- (void*)(buf_info->rse_base +
- (buf_info->rse_num - 1) * sizeof(fr_rx_buf_ctl_t) -
- FR_MB_VECTOR + card->hw.dpmbase);
- }
-
- card->u.f.rx_base = buf_info->buf_base;
- card->u.f.rx_top = buf_info->buf_top;
-
- card->u.f.tx_interrupts_pending = 0;
-
- return;
-}
-
-
-
-MODULE_LICENSE("GPL");
-
-/****** End *****************************************************************/
diff --git a/drivers/net/wan/sdla_ft1.c b/drivers/net/wan/sdla_ft1.c
deleted file mode 100644
index 9d6528a50f7bf..0000000000000
--- a/drivers/net/wan/sdla_ft1.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*****************************************************************************
-* sdla_chdlc.c WANPIPE(tm) Multiprotocol WAN Link Driver. Cisco HDLC module.
-*
-* Authors: Nenad Corbic <ncorbic@sangoma.com>
-* Gideon Hack
-*
-* Copyright: (c) 1995-1999 Sangoma Technologies 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.
-* ============================================================================
-* Sep 30, 1999 Nenad Corbic Fixed dynamic IP and route setup.
-* Sep 23, 1999 Nenad Corbic Added SMP support, fixed tracing
-* Sep 13, 1999 Nenad Corbic Split up Port 0 and 1 into separate devices.
-* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
-* Oct 30, 1998 Jaspreet Singh Added Support for CHDLC API (HDLC STREAMING).
-* Oct 28, 1998 Jaspreet Singh Added Support for Dual Port CHDLC.
-* Aug 07, 1998 David Fong Initial version.
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/if_arp.h> /* ARPHRD_* defines */
-#include <linux/jiffies.h> /* time_after() macro */
-
-#include <linux/inetdevice.h>
-#include <asm/uaccess.h>
-
-#include <linux/in.h> /* sockaddr_in */
-#include <linux/inet.h>
-#include <linux/if.h>
-#include <asm/byteorder.h> /* htons(), etc. */
-#include <linux/sdlapci.h>
-#include <asm/io.h>
-
-#include <linux/sdla_chdlc.h> /* CHDLC firmware API definitions */
-
-/****** Defines & Macros ****************************************************/
-
-/* reasons for enabling the timer interrupt on the adapter */
-#define TMR_INT_ENABLED_UDP 0x0001
-#define TMR_INT_ENABLED_UPDATE 0x0002
-
-#define CHDLC_DFLT_DATA_LEN 1500 /* default MTU */
-#define CHDLC_HDR_LEN 1
-
-#define IFF_POINTTOPOINT 0x10
-
-#define WANPIPE 0x00
-#define API 0x01
-#define CHDLC_API 0x01
-
-#define PORT(x) (x == 0 ? "PRIMARY" : "SECONDARY" )
-
-
-/******Data Structures*****************************************************/
-
-/* This structure is placed in the private data area of the device structure.
- * The card structure used to occupy the private area but now the following
- * structure will incorporate the card structure along with CHDLC specific data
- */
-
-typedef struct chdlc_private_area
-{
- struct net_device *slave;
- sdla_t *card;
- int TracingEnabled; /* For enabling Tracing */
- unsigned long curr_trace_addr; /* Used for Tracing */
- unsigned long start_trace_addr;
- unsigned long end_trace_addr;
- unsigned long base_addr_trace_buffer;
- unsigned long end_addr_trace_buffer;
- unsigned short number_trace_elements;
- unsigned available_buffer_space;
- unsigned long router_start_time;
- unsigned char route_status;
- unsigned char route_removed;
- unsigned long tick_counter; /* For 5s timeout counter */
- unsigned long router_up_time;
- u32 IP_address; /* IP addressing */
- u32 IP_netmask;
- unsigned char mc; /* Mulitcast support on/off */
- unsigned short udp_pkt_lgth; /* udp packet processing */
- char udp_pkt_src;
- char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
- unsigned short timer_int_enabled;
- char update_comms_stats; /* updating comms stats */
- //FIXME: add driver stats as per frame relay!
-
-} chdlc_private_area_t;
-
-/* Route Status options */
-#define NO_ROUTE 0x00
-#define ADD_ROUTE 0x01
-#define ROUTE_ADDED 0x02
-#define REMOVE_ROUTE 0x03
-
-
-/****** Function Prototypes *************************************************/
-/* WAN link driver entry points. These are called by the WAN router module. */
-static int wpft1_exec (struct sdla *card, void *u_cmd, void *u_data);
-static int chdlc_read_version (sdla_t* card, char* str);
-static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb);
-
-/****** Public Functions ****************************************************/
-
-/*============================================================================
- * Cisco HDLC protocol initialization routine.
- *
- * This routine is called by the main WANPIPE module during setup. At this
- * point adapter is completely initialized and firmware is running.
- * o read firmware version (to make sure it's alive)
- * o configure adapter
- * o initialize protocol-specific fields of the adapter data space.
- *
- * Return: 0 o.k.
- * < 0 failure.
- */
-int wpft1_init (sdla_t* card, wandev_conf_t* conf)
-{
- unsigned char port_num;
- int err;
-
- union
- {
- char str[80];
- } u;
- volatile CHDLC_MAILBOX_STRUCT* mb;
- CHDLC_MAILBOX_STRUCT* mb1;
- unsigned long timeout;
-
- /* Verify configuration ID */
- if (conf->config_id != WANCONFIG_CHDLC) {
- printk(KERN_INFO "%s: invalid configuration ID %u!\n",
- card->devname, conf->config_id);
- return -EINVAL;
- }
-
- /* Use primary port */
- card->u.c.comm_port = 0;
-
-
- /* Initialize protocol-specific fields */
- if(card->hw.type != SDLA_S514){
- card->mbox = (void *) card->hw.dpmbase;
- }else{
- card->mbox = (void *) card->hw.dpmbase + PRI_BASE_ADDR_MB_STRUCT;
- }
-
- mb = mb1 = card->mbox;
-
- if (!card->configured){
-
- /* The board will place an 'I' in the return code to indicate that it is
- ready to accept commands. We expect this to be completed in less
- than 1 second. */
-
- timeout = jiffies;
- while (mb->return_code != 'I') /* Wait 1s for board to initialize */
- if (time_after(jiffies, timeout + 1*HZ)) break;
-
- if (mb->return_code != 'I') {
- printk(KERN_INFO
- "%s: Initialization not completed by adapter\n",
- card->devname);
- printk(KERN_INFO "Please contact Sangoma representative.\n");
- return -EIO;
- }
- }
-
- /* Read firmware version. Note that when adapter initializes, it
- * clears the mailbox, so it may appear that the first command was
- * executed successfully when in fact it was merely erased. To work
- * around this, we execute the first command twice.
- */
-
- if (chdlc_read_version(card, u.str))
- return -EIO;
-
- printk(KERN_INFO "%s: Running FT1 Configuration firmware v%s\n",
- card->devname, u.str);
-
- card->isr = NULL;
- card->poll = NULL;
- card->exec = &wpft1_exec;
- card->wandev.update = NULL;
- card->wandev.new_if = NULL;
- card->wandev.del_if = NULL;
- card->wandev.state = WAN_DUALPORT;
- card->wandev.udp_port = conf->udp_port;
-
- card->wandev.new_if_cnt = 0;
-
- /* This is for the ports link state */
- card->u.c.state = WAN_DISCONNECTED;
-
- /* reset the number of times the 'update()' proc has been called */
- card->u.c.update_call_count = 0;
-
- card->wandev.ttl = 0x7F;
- card->wandev.interface = 0;
-
- card->wandev.clocking = 0;
-
- port_num = card->u.c.comm_port;
-
- /* Setup Port Bps */
-
- card->wandev.bps = 0;
-
- card->wandev.mtu = MIN_LGTH_CHDLC_DATA_CFG;
-
- /* Set up the interrupt status area */
- /* Read the CHDLC Configuration and obtain:
- * Ptr to shared memory infor struct
- * Use this pointer to calculate the value of card->u.c.flags !
- */
- mb1->buffer_length = 0;
- mb1->command = READ_CHDLC_CONFIGURATION;
- err = sdla_exec(mb1) ? mb1->return_code : CMD_TIMEOUT;
- if(err != COMMAND_OK) {
- chdlc_error(card, err, mb1);
- return -EIO;
- }
-
- if(card->hw.type == SDLA_S514){
- card->u.c.flags = (void *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb1->data)->
- ptr_shared_mem_info_struct));
- }else{
- card->u.c.flags = (void *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb1->data)->
- ptr_shared_mem_info_struct % SDLA_WINDOWSIZE));
- }
-
- card->wandev.state = WAN_FT1_READY;
- printk(KERN_INFO "%s: FT1 Config Ready !\n",card->devname);
-
- return 0;
-}
-
-static int wpft1_exec(sdla_t *card, void *u_cmd, void *u_data)
-{
- CHDLC_MAILBOX_STRUCT* mbox = card->mbox;
- int len;
-
- if (copy_from_user((void*)&mbox->command, u_cmd, sizeof(ft1_exec_cmd_t))){
- return -EFAULT;
- }
-
- len = mbox->buffer_length;
-
- if (len) {
- if( copy_from_user((void*)&mbox->data, u_data, len)){
- return -EFAULT;
- }
- }
-
- /* execute command */
- if (!sdla_exec(mbox)){
- return -EIO;
- }
-
- /* return result */
- if( copy_to_user(u_cmd, (void*)&mbox->command, sizeof(ft1_exec_cmd_t))){
- return -EFAULT;
- }
-
- len = mbox->buffer_length;
-
- if (len && u_data && copy_to_user(u_data, (void*)&mbox->data, len)){
- return -EFAULT;
- }
-
- return 0;
-
-}
-
-/*============================================================================
- * Read firmware code version.
- * Put code version as ASCII string in str.
- */
-static int chdlc_read_version (sdla_t* card, char* str)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int len;
- char err;
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CODE_VERSION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if(err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- }
- else if (str) { /* is not null */
- len = mb->buffer_length;
- memcpy(str, mb->data, len);
- str[len] = '\0';
- }
- return (err);
-}
-
-/*============================================================================
- * Firmware error handler.
- * This routine is called whenever firmware command returns non-zero
- * return code.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb)
-{
- unsigned cmd = mb->command;
-
- switch (err) {
-
- case CMD_TIMEOUT:
- printk(KERN_ERR "%s: command 0x%02X timed out!\n",
- card->devname, cmd);
- break;
-
- case S514_BOTH_PORTS_SAME_CLK_MODE:
- if(cmd == SET_CHDLC_CONFIGURATION) {
- printk(KERN_INFO
- "%s: Configure both ports for the same clock source\n",
- card->devname);
- break;
- }
-
- default:
- printk(KERN_INFO "%s: command 0x%02X returned 0x%02X!\n",
- card->devname, cmd, err);
- }
-
- return 0;
-}
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/net/wan/sdla_ppp.c b/drivers/net/wan/sdla_ppp.c
deleted file mode 100644
index a4b489cccbbf5..0000000000000
--- a/drivers/net/wan/sdla_ppp.c
+++ /dev/null
@@ -1,3430 +0,0 @@
-/*****************************************************************************
-* sdla_ppp.c WANPIPE(tm) Multiprotocol WAN Link Driver. PPP module.
-*
-* Author: Nenad Corbic <ncorbic@sangoma.com>
-*
-* Copyright: (c) 1995-2001 Sangoma Technologies 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.
-* ============================================================================
-* Feb 28, 2001 Nenad Corbic o Updated if_tx_timeout() routine for
-* 2.4.X kernels.
-* Nov 29, 2000 Nenad Corbic o Added the 2.4.x kernel support:
-* get_ip_address() function has moved
-* into the ppp_poll() routine. It cannot
-* be called from an interrupt.
-* Nov 07, 2000 Nenad Corbic o Added security features for UDP debugging:
-* Deny all and specify allowed requests.
-* May 02, 2000 Nenad Corbic o Added the dynamic interface shutdown
-* option. When the link goes down, the
-* network interface IFF_UP flag is reset.
-* Mar 06, 2000 Nenad Corbic o Bug Fix: corrupted mbox recovery.
-* Feb 25, 2000 Nenad Corbic o Fixed the FT1 UDP debugger problem.
-* Feb 09, 2000 Nenad Coribc o Shutdown bug fix. update() was called
-* with NULL dev pointer: no check.
-* Jan 24, 2000 Nenad Corbic o Disabled use of CMD complete inter.
-* Dev 15, 1999 Nenad Corbic o Fixed up header files for 2.0.X kernels
-* Oct 25, 1999 Nenad Corbic o Support for 2.0.X kernels
-* Moved dynamic route processing into
-* a polling routine.
-* Oct 07, 1999 Nenad Corbic o Support for S514 PCI card.
-* Gideon Hack o UPD and Updates executed using timer interrupt
-* Sep 10, 1999 Nenad Corbic o Fixed up the /proc statistics
-* Jul 20, 1999 Nenad Corbic o Remove the polling routines and use
-* interrupts instead.
-* Sep 17, 1998 Jaspreet Singh o Updates for 2.2.X Kernels.
-* Aug 13, 1998 Jaspreet Singh o Improved Line Tracing.
-* Jun 22, 1998 David Fong o Added remote IP address assignment
-* Mar 15, 1998 Alan Cox o 2.1.8x basic port.
-* Apr 16, 1998 Jaspreet Singh o using htons() for the IPX protocol.
-* Dec 09, 1997 Jaspreet Singh o Added PAP and CHAP.
-* o Implemented new routines like
-* ppp_set_inbnd_auth(), ppp_set_outbnd_auth(),
-* tokenize() and strstrip().
-* Nov 27, 1997 Jaspreet Singh o Added protection against enabling of irqs
-* while they have been disabled.
-* Nov 24, 1997 Jaspreet Singh o Fixed another RACE condition caused by
-* disabling and enabling of irqs.
-* o Added new counters for stats on disable/enable
-* IRQs.
-* Nov 10, 1997 Jaspreet Singh o Initialized 'skb->mac.raw' to 'skb->data'
-* before every netif_rx().
-* o Free up the device structure in del_if().
-* Nov 07, 1997 Jaspreet Singh o Changed the delay to zero for Line tracing
-* command.
-* Oct 20, 1997 Jaspreet Singh o Added hooks in for Router UP time.
-* Oct 16, 1997 Jaspreet Singh o The critical flag is used to maintain flow
-* control by avoiding RACE conditions. The
-* cli() and restore_flags() are taken out.
-* A new structure, "ppp_private_area", is added
-* to provide Driver Statistics.
-* Jul 21, 1997 Jaspreet Singh o Protected calls to sdla_peek() by adding
-* save_flags(), cli() and restore_flags().
-* Jul 07, 1997 Jaspreet Singh o Added configurable TTL for UDP packets
-* o Added ability to discard mulitcast and
-* broacast source addressed packets.
-* Jun 27, 1997 Jaspreet Singh o Added FT1 monitor capabilities
-* New case (0x25) statement in if_send routine.
-* Added a global variable rCount to keep track
-* of FT1 status enabled on the board.
-* May 22, 1997 Jaspreet Singh o Added change in the PPP_SET_CONFIG command for
-* 508 card to reflect changes in the new
-* ppp508.sfm for supporting:continous transmission
-* of Configure-Request packets without receiving a
-* reply
-* OR-ed 0x300 to conf_flags
-* o Changed connect_tmout from 900 to 0
-* May 21, 1997 Jaspreet Singh o Fixed UDP Management for multiple boards
-* Apr 25, 1997 Farhan Thawar o added UDP Management stuff
-* Mar 11, 1997 Farhan Thawar Version 3.1.1
-* o fixed (+1) bug in rx_intr()
-* o changed if_send() to return 0 if
-* wandev.critical() is true
-* o free socket buffer in if_send() if
-* returning 0
-* Jan 15, 1997 Gene Kozin Version 3.1.0
-* o implemented exec() entry point
-* Jan 06, 1997 Gene Kozin Initial version.
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/if_arp.h> /* ARPHRD_* defines */
-#include <asm/byteorder.h> /* htons(), etc. */
-#include <linux/in.h> /* sockaddr_in */
-#include <linux/jiffies.h> /* time_after() macro */
-
-
-#include <asm/uaccess.h>
-#include <linux/inetdevice.h>
-#include <linux/netdevice.h>
-
-#include <linux/if.h>
-#include <linux/sdla_ppp.h> /* PPP firmware API definitions */
-#include <linux/sdlasfm.h> /* S514 Type Definition */
-/****** Defines & Macros ****************************************************/
-
-#define PPP_DFLT_MTU 1500 /* default MTU */
-#define PPP_MAX_MTU 4000 /* maximum MTU */
-#define PPP_HDR_LEN 1
-
-#define MAX_IP_ERRORS 100
-
-#define CONNECT_TIMEOUT (90*HZ) /* link connection timeout */
-#define HOLD_DOWN_TIME (5*HZ) /* link hold down time : Changed from 30 to 5 */
-
-/* For handle_IPXWAN() */
-#define CVHexToAscii(b) (((unsigned char)(b) > (unsigned char)9) ? ((unsigned char)'A' + ((unsigned char)(b) - (unsigned char)10)) : ((unsigned char)'0' + (unsigned char)(b)))
-
-/* Macro for enabling/disabling debugging comments */
-//#define NEX_DEBUG
-#ifdef NEX_DEBUG
-#define NEX_PRINTK(format, a...) printk(format, ## a)
-#else
-#define NEX_PRINTK(format, a...)
-#endif /* NEX_DEBUG */
-
-#define DCD(a) ( a & 0x08 ? "HIGH" : "LOW" )
-#define CTS(a) ( a & 0x20 ? "HIGH" : "LOW" )
-#define LCP(a) ( a == 0x09 ? "OPEN" : "CLOSED" )
-#define IP(a) ( a == 0x09 ? "ENABLED" : "DISABLED" )
-
-#define TMR_INT_ENABLED_UPDATE 0x01
-#define TMR_INT_ENABLED_PPP_EVENT 0x02
-#define TMR_INT_ENABLED_UDP 0x04
-#define TMR_INT_ENABLED_CONFIG 0x20
-
-/* Set Configuraton Command Definitions */
-#define PERCENT_TX_BUFF 60
-#define TIME_BETWEEN_CONF_REQ 30
-#define TIME_BETWEEN_PAP_CHAP_REQ 30
-#define WAIT_PAP_CHAP_WITHOUT_REPLY 300
-#define WAIT_AFTER_DCD_CTS_LOW 5
-#define TIME_DCD_CTS_LOW_AFTER_LNK_DOWN 10
-#define WAIT_DCD_HIGH_AFTER_ENABLE_COMM 900
-#define MAX_CONF_REQ_WITHOUT_REPLY 10
-#define MAX_TERM_REQ_WITHOUT_REPLY 2
-#define NUM_CONF_NAK_WITHOUT_REPLY 5
-#define NUM_AUTH_REQ_WITHOUT_REPLY 10
-
-#define END_OFFSET 0x1F0
-
-
-/******Data Structures*****************************************************/
-
-/* This structure is placed in the private data area of the device structure.
- * The card structure used to occupy the private area but now the following
- * structure will incorporate the card structure along with PPP specific data
- */
-
-typedef struct ppp_private_area
-{
- struct net_device *slave;
- sdla_t* card;
- unsigned long router_start_time; /*router start time in sec */
- unsigned long tick_counter; /*used for 5 second counter*/
- unsigned mc; /*multicast support on or off*/
- unsigned char enable_IPX;
- unsigned long network_number;
- unsigned char pap;
- unsigned char chap;
- unsigned char sysname[31]; /* system name for in-bnd auth*/
- unsigned char userid[511]; /* list of user ids */
- unsigned char passwd[511]; /* list of passwords */
- unsigned protocol; /* SKB Protocol */
- u32 ip_local; /* Local IP Address */
- u32 ip_remote; /* remote IP Address */
-
- u32 ip_local_tmp;
- u32 ip_remote_tmp;
-
- unsigned char timer_int_enabled; /* Who enabled the timer inter*/
- unsigned char update_comms_stats; /* Used by update function */
- unsigned long curr_trace_addr; /* Trace information */
- unsigned long start_trace_addr;
- unsigned long end_trace_addr;
-
- unsigned char interface_down; /* Brind down interface when channel
- goes down */
- unsigned long config_wait_timeout; /* After if_open() if in dynamic if mode,
- wait a few seconds before configuring */
-
- unsigned short udp_pkt_lgth;
- char udp_pkt_src;
- char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
-
- /* PPP specific statistics */
-
- if_send_stat_t if_send_stat;
- rx_intr_stat_t rx_intr_stat;
- pipe_mgmt_stat_t pipe_mgmt_stat;
-
- unsigned long router_up_time;
-
- /* Polling work queue entry. Each interface
- * has its own work queue entry, which is used
- * to defer events from the interrupt */
- struct work_struct poll_work;
- struct timer_list poll_delay_timer;
-
- u8 gateway;
- u8 config_ppp;
- u8 ip_error;
-
-}ppp_private_area_t;
-
-/* variable for keeping track of enabling/disabling FT1 monitor status */
-static int rCount = 0;
-
-extern void disable_irq(unsigned int);
-extern void enable_irq(unsigned int);
-
-/****** Function Prototypes *************************************************/
-
-/* WAN link driver entry points. These are called by the WAN router module. */
-static int update(struct wan_device *wandev);
-static int new_if(struct wan_device *wandev, struct net_device *dev,
- wanif_conf_t *conf);
-static int del_if(struct wan_device *wandev, struct net_device *dev);
-
-/* WANPIPE-specific entry points */
-static int wpp_exec (struct sdla *card, void *u_cmd, void *u_data);
-
-/* Network device interface */
-static int if_init(struct net_device *dev);
-static int if_open(struct net_device *dev);
-static int if_close(struct net_device *dev);
-static int if_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type,
- void *daddr, void *saddr, unsigned len);
-
-static void if_tx_timeout(struct net_device *dev);
-
-static int if_rebuild_hdr(struct sk_buff *skb);
-static struct net_device_stats *if_stats(struct net_device *dev);
-static int if_send(struct sk_buff *skb, struct net_device *dev);
-
-
-/* PPP firmware interface functions */
-static int ppp_read_version(sdla_t *card, char *str);
-static int ppp_set_outbnd_auth(sdla_t *card, ppp_private_area_t *ppp_priv_area);
-static int ppp_set_inbnd_auth(sdla_t *card, ppp_private_area_t *ppp_priv_area);
-static int ppp_configure(sdla_t *card, void *data);
-static int ppp_set_intr_mode(sdla_t *card, unsigned char mode);
-static int ppp_comm_enable(sdla_t *card);
-static int ppp_comm_disable(sdla_t *card);
-static int ppp_comm_disable_shutdown(sdla_t *card);
-static int ppp_get_err_stats(sdla_t *card);
-static int ppp_send(sdla_t *card, void *data, unsigned len, unsigned proto);
-static int ppp_error(sdla_t *card, int err, ppp_mbox_t *mb);
-
-static void wpp_isr(sdla_t *card);
-static void rx_intr(sdla_t *card);
-static void event_intr(sdla_t *card);
-static void timer_intr(sdla_t *card);
-
-/* Background polling routines */
-static void process_route(sdla_t *card);
-static void retrigger_comm(sdla_t *card);
-
-/* Miscellaneous functions */
-static int read_info( sdla_t *card );
-static int read_connection_info (sdla_t *card);
-static void remove_route( sdla_t *card );
-static int config508(struct net_device *dev, sdla_t *card);
-static void show_disc_cause(sdla_t * card, unsigned cause);
-static int reply_udp( unsigned char *data, unsigned int mbox_len );
-static void process_udp_mgmt_pkt(sdla_t *card, struct net_device *dev,
- ppp_private_area_t *ppp_priv_area);
-static void init_ppp_tx_rx_buff( sdla_t *card );
-static int intr_test( sdla_t *card );
-static int udp_pkt_type( struct sk_buff *skb , sdla_t *card);
-static void init_ppp_priv_struct( ppp_private_area_t *ppp_priv_area);
-static void init_global_statistics( sdla_t *card );
-static int tokenize(char *str, char **tokens);
-static char* strstrip(char *str, char *s);
-static int chk_bcast_mcast_addr(sdla_t* card, struct net_device* dev,
- struct sk_buff *skb);
-
-static int config_ppp (sdla_t *);
-static void ppp_poll(struct net_device *dev);
-static void trigger_ppp_poll(struct net_device *dev);
-static void ppp_poll_delay (unsigned long dev_ptr);
-
-
-static int Read_connection_info;
-static int Intr_test_counter;
-static unsigned short available_buffer_space;
-
-
-/* IPX functions */
-static void switch_net_numbers(unsigned char *sendpacket, unsigned long network_number,
- unsigned char incoming);
-static int handle_IPXWAN(unsigned char *sendpacket, char *devname, unsigned char enable_PX,
- unsigned long network_number, unsigned short proto);
-
-/* Lock Functions */
-static void s508_lock (sdla_t *card, unsigned long *smp_flags);
-static void s508_unlock (sdla_t *card, unsigned long *smp_flags);
-
-static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, struct net_device* dev,
- ppp_private_area_t* ppp_priv_area );
-static unsigned short calc_checksum (char *data, int len);
-static void disable_comm (sdla_t *card);
-static int detect_and_fix_tx_bug (sdla_t *card);
-
-/****** Public Functions ****************************************************/
-
-/*============================================================================
- * PPP protocol initialization routine.
- *
- * This routine is called by the main WANPIPE module during setup. At this
- * point adapter is completely initialized and firmware is running.
- * o read firmware version (to make sure it's alive)
- * o configure adapter
- * o initialize protocol-specific fields of the adapter data space.
- *
- * Return: 0 o.k.
- * < 0 failure.
- */
-int wpp_init(sdla_t *card, wandev_conf_t *conf)
-{
- ppp_flags_t *flags;
- union
- {
- char str[80];
- } u;
-
- /* Verify configuration ID */
- if (conf->config_id != WANCONFIG_PPP) {
-
- printk(KERN_INFO "%s: invalid configuration ID %u!\n",
- card->devname, conf->config_id);
- return -EINVAL;
-
- }
-
- /* Initialize miscellaneous pointers to structures on the adapter */
- switch (card->hw.type) {
-
- case SDLA_S508:
- card->mbox =(void*)(card->hw.dpmbase + PPP508_MB_OFFS);
- card->flags=(void*)(card->hw.dpmbase + PPP508_FLG_OFFS);
- break;
-
- case SDLA_S514:
- card->mbox =(void*)(card->hw.dpmbase + PPP514_MB_OFFS);
- card->flags=(void*)(card->hw.dpmbase + PPP514_FLG_OFFS);
- break;
-
- default:
- return -EINVAL;
-
- }
- flags = card->flags;
-
- /* Read firmware version. Note that when adapter initializes, it
- * clears the mailbox, so it may appear that the first command was
- * executed successfully when in fact it was merely erased. To work
- * around this, we execute the first command twice.
- */
- if (ppp_read_version(card, NULL) || ppp_read_version(card, u.str))
- return -EIO;
-
- printk(KERN_INFO "%s: running PPP firmware v%s\n",card->devname, u.str);
- /* Adjust configuration and set defaults */
- card->wandev.mtu = (conf->mtu) ?
- min_t(unsigned int, conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU;
-
- card->wandev.bps = conf->bps;
- card->wandev.interface = conf->interface;
- card->wandev.clocking = conf->clocking;
- card->wandev.station = conf->station;
- card->isr = &wpp_isr;
- card->poll = NULL;
- card->exec = &wpp_exec;
- card->wandev.update = &update;
- card->wandev.new_if = &new_if;
- card->wandev.del_if = &del_if;
- card->wandev.udp_port = conf->udp_port;
- card->wandev.ttl = conf->ttl;
- card->wandev.state = WAN_DISCONNECTED;
- card->disable_comm = &disable_comm;
- card->irq_dis_if_send_count = 0;
- card->irq_dis_poll_count = 0;
- card->u.p.authenticator = conf->u.ppp.authenticator;
- card->u.p.ip_mode = conf->u.ppp.ip_mode ?
- conf->u.ppp.ip_mode : WANOPT_PPP_STATIC;
- card->TracingEnabled = 0;
- Read_connection_info = 1;
-
- /* initialize global statistics */
- init_global_statistics( card );
-
-
-
- if (!card->configured){
- int err;
-
- Intr_test_counter = 0;
- err = intr_test(card);
-
- if(err || (Intr_test_counter < MAX_INTR_TEST_COUNTER)) {
- printk("%s: Interrupt Test Failed, Counter: %i\n",
- card->devname, Intr_test_counter);
- printk( "%s: Please choose another interrupt\n",card->devname);
- return -EIO;
- }
-
- printk(KERN_INFO "%s: Interrupt Test Passed, Counter: %i\n",
- card->devname, Intr_test_counter);
- card->configured = 1;
- }
-
- ppp_set_intr_mode(card, PPP_INTR_TIMER);
-
- /* Turn off the transmit and timer interrupt */
- flags->imask &= ~PPP_INTR_TIMER;
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-/******* WAN Device Driver Entry Points *************************************/
-
-/*============================================================================
- * Update device status & statistics.
- */
-static int update(struct wan_device *wandev)
-{
- sdla_t* card = wandev->private;
- struct net_device* dev;
- volatile ppp_private_area_t *ppp_priv_area;
- ppp_flags_t *flags = card->flags;
- unsigned long timeout;
-
- /* sanity checks */
- if ((wandev == NULL) || (wandev->private == NULL))
- return -EFAULT;
-
- if (wandev->state == WAN_UNCONFIGURED)
- return -ENODEV;
-
- /* Shutdown bug fix. This function can be
- * called with NULL dev pointer during
- * shutdown
- */
- if ((dev=card->wandev.dev) == NULL){
- return -ENODEV;
- }
-
- if ((ppp_priv_area=dev->priv) == NULL){
- return -ENODEV;
- }
-
- ppp_priv_area->update_comms_stats = 2;
- ppp_priv_area->timer_int_enabled |= TMR_INT_ENABLED_UPDATE;
- flags->imask |= PPP_INTR_TIMER;
-
- /* wait a maximum of 1 second for the statistics to be updated */
- timeout = jiffies;
- for(;;) {
- if(ppp_priv_area->update_comms_stats == 0){
- break;
- }
- if (time_after(jiffies, timeout + 1 * HZ)){
- ppp_priv_area->update_comms_stats = 0;
- ppp_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_UPDATE;
- return -EAGAIN;
- }
- }
-
- return 0;
-}
-
-/*============================================================================
- * Create new logical channel.
- * This routine is called by the router when ROUTER_IFNEW IOCTL is being
- * handled.
- * o parse media- and hardware-specific configuration
- * o make sure that a new channel can be created
- * o allocate resources, if necessary
- * o prepare network device structure for registaration.
- *
- * Return: 0 o.k.
- * < 0 failure (channel will not be created)
- */
-static int new_if(struct wan_device *wandev, struct net_device *dev,
- wanif_conf_t *conf)
-{
- sdla_t *card = wandev->private;
- ppp_private_area_t *ppp_priv_area;
-
- if (wandev->ndev)
- return -EEXIST;
-
-
- printk(KERN_INFO "%s: Configuring Interface: %s\n",
- card->devname, conf->name);
-
- if ((conf->name[0] == '\0') || (strlen(conf->name) > WAN_IFNAME_SZ)) {
-
- printk(KERN_INFO "%s: Invalid interface name!\n",
- card->devname);
- return -EINVAL;
-
- }
-
- /* allocate and initialize private data */
- ppp_priv_area = kmalloc(sizeof(ppp_private_area_t), GFP_KERNEL);
-
- if( ppp_priv_area == NULL )
- return -ENOMEM;
-
- memset(ppp_priv_area, 0, sizeof(ppp_private_area_t));
-
- ppp_priv_area->card = card;
-
- /* initialize data */
- strcpy(card->u.p.if_name, conf->name);
-
- /* initialize data in ppp_private_area structure */
-
- init_ppp_priv_struct( ppp_priv_area );
-
- ppp_priv_area->mc = conf->mc;
- ppp_priv_area->pap = conf->pap;
- ppp_priv_area->chap = conf->chap;
-
- /* Option to bring down the interface when
- * the link goes down */
- if (conf->if_down){
- set_bit(DYN_OPT_ON,&ppp_priv_area->interface_down);
- printk("%s: Dynamic interface configuration enabled\n",
- card->devname);
- }
-
- /* If no user ids are specified */
- if(!strlen(conf->userid) && (ppp_priv_area->pap||ppp_priv_area->chap)){
- kfree(ppp_priv_area);
- return -EINVAL;
- }
-
- /* If no passwords are specified */
- if(!strlen(conf->passwd) && (ppp_priv_area->pap||ppp_priv_area->chap)){
- kfree(ppp_priv_area);
- return -EINVAL;
- }
-
- if(strlen(conf->sysname) > 31){
- kfree(ppp_priv_area);
- return -EINVAL;
- }
-
- /* If no system name is specified */
- if(!strlen(conf->sysname) && (card->u.p.authenticator)){
- kfree(ppp_priv_area);
- return -EINVAL;
- }
-
- /* copy the data into the ppp private structure */
- memcpy(ppp_priv_area->userid, conf->userid, strlen(conf->userid));
- memcpy(ppp_priv_area->passwd, conf->passwd, strlen(conf->passwd));
- memcpy(ppp_priv_area->sysname, conf->sysname, strlen(conf->sysname));
-
-
- ppp_priv_area->enable_IPX = conf->enable_IPX;
- if (conf->network_number){
- ppp_priv_area->network_number = conf->network_number;
- }else{
- ppp_priv_area->network_number = 0xDEADBEEF;
- }
-
- /* Tells us that if this interface is a
- * gateway or not */
- if ((ppp_priv_area->gateway = conf->gateway) == WANOPT_YES){
- printk(KERN_INFO "%s: Interface %s is set as a gateway.\n",
- card->devname,card->u.p.if_name);
- }
-
- /* prepare network device data space for registration */
- strcpy(dev->name,card->u.p.if_name);
-
- dev->init = &if_init;
- dev->priv = ppp_priv_area;
- dev->mtu = min_t(unsigned int, dev->mtu, card->wandev.mtu);
-
- /* Initialize the polling work routine */
- INIT_WORK(&ppp_priv_area->poll_work, (void*)(void*)ppp_poll, dev);
-
- /* Initialize the polling delay timer */
- init_timer(&ppp_priv_area->poll_delay_timer);
- ppp_priv_area->poll_delay_timer.data = (unsigned long)dev;
- ppp_priv_area->poll_delay_timer.function = ppp_poll_delay;
-
-
- /* Since we start with dummy IP addresses we can say
- * that route exists */
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-/*============================================================================
- * Delete logical channel.
- */
-static int del_if(struct wan_device *wandev, struct net_device *dev)
-{
- return 0;
-}
-
-static void disable_comm (sdla_t *card)
-{
- ppp_comm_disable_shutdown(card);
- return;
-}
-
-/****** WANPIPE-specific entry points ***************************************/
-
-/*============================================================================
- * Execute adapter interface command.
- */
-
-//FIXME: Why do we need this ????
-static int wpp_exec(struct sdla *card, void *u_cmd, void *u_data)
-{
- ppp_mbox_t *mbox = card->mbox;
- int len;
-
- if (copy_from_user((void*)&mbox->cmd, u_cmd, sizeof(ppp_cmd_t)))
- return -EFAULT;
-
- len = mbox->cmd.length;
-
- if (len) {
-
- if( copy_from_user((void*)&mbox->data, u_data, len))
- return -EFAULT;
-
- }
-
- /* execute command */
- if (!sdla_exec(mbox))
- return -EIO;
-
- /* return result */
- if( copy_to_user(u_cmd, (void*)&mbox->cmd, sizeof(ppp_cmd_t)))
- return -EFAULT;
- len = mbox->cmd.length;
-
- if (len && u_data && copy_to_user(u_data, (void*)&mbox->data, len))
- return -EFAULT;
-
- return 0;
-}
-
-/****** Network Device Interface ********************************************/
-
-/*============================================================================
- * Initialize Linux network interface.
- *
- * This routine is called only once for each interface, during Linux network
- * interface registration. Returning anything but zero will fail interface
- * registration.
- */
-static int if_init(struct net_device *dev)
-{
- ppp_private_area_t *ppp_priv_area = dev->priv;
- sdla_t *card = ppp_priv_area->card;
- struct wan_device *wandev = &card->wandev;
-
- /* Initialize device driver entry points */
- dev->open = &if_open;
- dev->stop = &if_close;
- dev->hard_header = &if_header;
- dev->rebuild_header = &if_rebuild_hdr;
- dev->hard_start_xmit = &if_send;
- dev->get_stats = &if_stats;
- dev->tx_timeout = &if_tx_timeout;
- dev->watchdog_timeo = TX_TIMEOUT;
-
- /* Initialize media-specific parameters */
- dev->type = ARPHRD_PPP; /* ARP h/w type */
- dev->flags |= IFF_POINTOPOINT;
- dev->flags |= IFF_NOARP;
-
- /* Enable Mulitcasting if specified by user*/
- if (ppp_priv_area->mc == WANOPT_YES){
- dev->flags |= IFF_MULTICAST;
- }
-
- dev->mtu = wandev->mtu;
- dev->hard_header_len = PPP_HDR_LEN; /* media header length */
-
- /* Initialize hardware parameters (just for reference) */
- dev->irq = wandev->irq;
- dev->dma = wandev->dma;
- dev->base_addr = wandev->ioport;
- dev->mem_start = wandev->maddr;
- dev->mem_end = wandev->maddr + wandev->msize - 1;
-
- /* Set transmit buffer queue length */
- dev->tx_queue_len = 100;
- SET_MODULE_OWNER(dev);
-
- return 0;
-}
-
-/*============================================================================
- * Open network interface.
- * o enable communications and interrupts.
- * o prevent module from unloading by incrementing use count
- *
- * Return 0 if O.k. or errno.
- */
-static int if_open(struct net_device *dev)
-{
- ppp_private_area_t *ppp_priv_area = dev->priv;
- sdla_t *card = ppp_priv_area->card;
- struct timeval tv;
- //unsigned long smp_flags;
-
- if (netif_running(dev))
- return -EBUSY;
-
- wanpipe_open(card);
-
- netif_start_queue(dev);
-
- do_gettimeofday( &tv );
- ppp_priv_area->router_start_time = tv.tv_sec;
-
- /* We cannot configure the card here because we don't
- * have access to the interface IP addresses.
- * Once the interface initilization is complete, we will be
- * able to access the IP addresses. Therefore,
- * configure the ppp link in the poll routine */
- set_bit(0,&ppp_priv_area->config_ppp);
- ppp_priv_area->config_wait_timeout=jiffies;
-
- /* Start the PPP configuration after 1sec delay.
- * This will give the interface initilization time
- * to finish its configuration */
- mod_timer(&ppp_priv_area->poll_delay_timer, jiffies + HZ);
- return 0;
-}
-
-/*============================================================================
- * Close network interface.
- * o if this is the last open, then disable communications and interrupts.
- * o reset flags.
- */
-static int if_close(struct net_device *dev)
-{
- ppp_private_area_t *ppp_priv_area = dev->priv;
- sdla_t *card = ppp_priv_area->card;
-
- netif_stop_queue(dev);
- wanpipe_close(card);
-
- del_timer (&ppp_priv_area->poll_delay_timer);
- return 0;
-}
-
-/*============================================================================
- * Build media header.
- *
- * The trick here is to put packet type (Ethertype) into 'protocol' field of
- * the socket buffer, so that we don't forget it. If packet type is not
- * supported, set skb->protocol to 0 and discard packet later.
- *
- * Return: media header length.
- */
-static int if_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr, void *saddr, unsigned len)
-{
- switch (type)
- {
- case ETH_P_IP:
- case ETH_P_IPX:
- skb->protocol = htons(type);
- break;
-
- default:
- skb->protocol = 0;
- }
-
- return PPP_HDR_LEN;
-}
-
-/*============================================================================
- * Re-build media header.
- *
- * Return: 1 physical address resolved.
- * 0 physical address not resolved
- */
-static int if_rebuild_hdr (struct sk_buff *skb)
-{
- struct net_device *dev = skb->dev;
- ppp_private_area_t *ppp_priv_area = dev->priv;
- sdla_t *card = ppp_priv_area->card;
-
- printk(KERN_INFO "%s: rebuild_header() called for interface %s!\n",
- card->devname, dev->name);
- return 1;
-}
-
-/*============================================================================
- * Handle transmit timeout event from netif watchdog
- */
-static void if_tx_timeout(struct net_device *dev)
-{
- ppp_private_area_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
- /* If our device stays busy for at least 5 seconds then we will
- * kick start the device by making dev->tbusy = 0. We expect
- * that our device never stays busy more than 5 seconds. So this
- * is only used as a last resort.
- */
-
- ++ chan->if_send_stat.if_send_tbusy;
- ++card->wandev.stats.collisions;
-
- printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name);
- ++chan->if_send_stat.if_send_tbusy_timeout;
- netif_wake_queue (dev);
-}
-
-
-
-/*============================================================================
- * Send a packet on a network interface.
- * o set tbusy flag (marks start of the transmission) to block a timer-based
- * transmit from overlapping.
- * o check link state. If link is not up, then drop the packet.
- * o execute adapter send command.
- * o free socket buffer
- *
- * Return: 0 complete (socket buffer must be freed)
- * non-0 packet may be re-transmitted (tbusy must be set)
- *
- * Notes:
- * 1. This routine is called either by the protocol stack or by the "net
- * bottom half" (with interrupts enabled).
- * 2. Setting tbusy flag will inhibit further transmit requests from the
- * protocol stack and can be used for flow control with protocol layer.
- */
-static int if_send (struct sk_buff *skb, struct net_device *dev)
-{
- ppp_private_area_t *ppp_priv_area = dev->priv;
- sdla_t *card = ppp_priv_area->card;
- unsigned char *sendpacket;
- unsigned long smp_flags;
- ppp_flags_t *flags = card->flags;
- int udp_type;
- int err=0;
-
- ++ppp_priv_area->if_send_stat.if_send_entry;
-
- netif_stop_queue(dev);
-
- if (skb == NULL) {
-
- /* If we get here, some higher layer thinks we've missed an
- * tx-done interrupt.
- */
- printk(KERN_INFO "%s: interface %s got kicked!\n",
- card->devname, dev->name);
-
- ++ppp_priv_area->if_send_stat.if_send_skb_null;
-
- netif_wake_queue(dev);
- return 0;
- }
-
- sendpacket = skb->data;
-
- udp_type = udp_pkt_type( skb, card );
-
-
- if (udp_type == UDP_PTPIPE_TYPE){
- if(store_udp_mgmt_pkt(UDP_PKT_FRM_STACK, card, skb, dev,
- ppp_priv_area)){
- flags->imask |= PPP_INTR_TIMER;
- }
- ++ppp_priv_area->if_send_stat.if_send_PIPE_request;
- netif_start_queue(dev);
- return 0;
- }
-
- /* Check for broadcast and multicast addresses
- * If found, drop (deallocate) a packet and return.
- */
- if(chk_bcast_mcast_addr(card, dev, skb)){
- ++card->wandev.stats.tx_dropped;
- dev_kfree_skb_any(skb);
- netif_start_queue(dev);
- return 0;
- }
-
-
- if(card->hw.type != SDLA_S514){
- s508_lock(card,&smp_flags);
- }
-
- if (test_and_set_bit(SEND_CRIT, (void*)&card->wandev.critical)) {
-
- printk(KERN_INFO "%s: Critical in if_send: %lx\n",
- card->wandev.name,card->wandev.critical);
-
- ++card->wandev.stats.tx_dropped;
- ++ppp_priv_area->if_send_stat.if_send_critical_non_ISR;
- netif_start_queue(dev);
- goto if_send_exit_crit;
- }
-
- if (card->wandev.state != WAN_CONNECTED) {
-
- ++ppp_priv_area->if_send_stat.if_send_wan_disconnected;
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
-
- } else if (!skb->protocol) {
- ++ppp_priv_area->if_send_stat.if_send_protocol_error;
- ++card->wandev.stats.tx_errors;
- netif_start_queue(dev);
-
- } else {
-
- /*If it's IPX change the network numbers to 0 if they're ours.*/
- if( skb->protocol == htons(ETH_P_IPX) ) {
- if(ppp_priv_area->enable_IPX) {
- switch_net_numbers( skb->data,
- ppp_priv_area->network_number, 0);
- } else {
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
- goto if_send_exit_crit;
- }
- }
-
- if (ppp_send(card, skb->data, skb->len, skb->protocol)) {
- netif_stop_queue(dev);
- ++ppp_priv_area->if_send_stat.if_send_adptr_bfrs_full;
- ++ppp_priv_area->if_send_stat.if_send_tx_int_enabled;
- } else {
- ++ppp_priv_area->if_send_stat.if_send_bfr_passed_to_adptr;
- ++card->wandev.stats.tx_packets;
- card->wandev.stats.tx_bytes += skb->len;
- netif_start_queue(dev);
- dev->trans_start = jiffies;
- }
- }
-
-if_send_exit_crit:
-
- if (!(err=netif_queue_stopped(dev))){
- dev_kfree_skb_any(skb);
- }else{
- ppp_priv_area->tick_counter = jiffies;
- flags->imask |= PPP_INTR_TXRDY; /* unmask Tx interrupts */
- }
-
- clear_bit(SEND_CRIT,&card->wandev.critical);
- if(card->hw.type != SDLA_S514){
- s508_unlock(card,&smp_flags);
- }
-
- return err;
-}
-
-
-/*=============================================================================
- * Store a UDP management packet for later processing.
- */
-
-static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, struct net_device* dev,
- ppp_private_area_t* ppp_priv_area )
-{
- int udp_pkt_stored = 0;
-
- if(!ppp_priv_area->udp_pkt_lgth && (skb->len<=MAX_LGTH_UDP_MGNT_PKT)){
- ppp_priv_area->udp_pkt_lgth = skb->len;
- ppp_priv_area->udp_pkt_src = udp_pkt_src;
- memcpy(ppp_priv_area->udp_pkt_data, skb->data, skb->len);
- ppp_priv_area->timer_int_enabled |= TMR_INT_ENABLED_UDP;
- ppp_priv_area->protocol = skb->protocol;
- udp_pkt_stored = 1;
- }else{
- if (skb->len > MAX_LGTH_UDP_MGNT_PKT){
- printk(KERN_INFO "%s: PIPEMON UDP request too long : %i\n",
- card->devname, skb->len);
- }else{
- printk(KERN_INFO "%s: PIPEMON UPD request already pending\n",
- card->devname);
- }
- ppp_priv_area->udp_pkt_lgth = 0;
- }
-
- if(udp_pkt_src == UDP_PKT_FRM_STACK){
- dev_kfree_skb_any(skb);
- }else{
- dev_kfree_skb_any(skb);
- }
-
- return(udp_pkt_stored);
-}
-
-
-
-/*============================================================================
- * Reply to UDP Management system.
- * Return length of reply.
- */
-static int reply_udp( unsigned char *data, unsigned int mbox_len )
-{
- unsigned short len, udp_length, temp, ip_length;
- unsigned long ip_temp;
- int even_bound = 0;
- ppp_udp_pkt_t *p_udp_pkt = (ppp_udp_pkt_t *)data;
-
- /* Set length of packet */
- len = sizeof(ip_pkt_t)+
- sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- mbox_len;
-
- /* fill in UDP reply */
- p_udp_pkt->wp_mgmt.request_reply = UDPMGMT_REPLY;
-
- /* fill in UDP length */
- udp_length = sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- mbox_len;
-
-
- /* put it on an even boundary */
- if ( udp_length & 0x0001 ) {
- udp_length += 1;
- len += 1;
- even_bound=1;
- }
-
- temp = (udp_length<<8)|(udp_length>>8);
- p_udp_pkt->udp_pkt.udp_length = temp;
-
-
- /* swap UDP ports */
- temp = p_udp_pkt->udp_pkt.udp_src_port;
- p_udp_pkt->udp_pkt.udp_src_port =
- p_udp_pkt->udp_pkt.udp_dst_port;
- p_udp_pkt->udp_pkt.udp_dst_port = temp;
-
-
- /* add UDP pseudo header */
- temp = 0x1100;
- *((unsigned short *)(p_udp_pkt->data+mbox_len+even_bound)) = temp;
- temp = (udp_length<<8)|(udp_length>>8);
- *((unsigned short *)(p_udp_pkt->data+mbox_len+even_bound+2)) = temp;
-
- /* calculate UDP checksum */
- p_udp_pkt->udp_pkt.udp_checksum = 0;
- p_udp_pkt->udp_pkt.udp_checksum =
- calc_checksum(&data[UDP_OFFSET],udp_length+UDP_OFFSET);
-
- /* fill in IP length */
- ip_length = udp_length + sizeof(ip_pkt_t);
- temp = (ip_length<<8)|(ip_length>>8);
- p_udp_pkt->ip_pkt.total_length = temp;
-
- /* swap IP addresses */
- ip_temp = p_udp_pkt->ip_pkt.ip_src_address;
- p_udp_pkt->ip_pkt.ip_src_address = p_udp_pkt->ip_pkt.ip_dst_address;
- p_udp_pkt->ip_pkt.ip_dst_address = ip_temp;
-
- /* fill in IP checksum */
- p_udp_pkt->ip_pkt.hdr_checksum = 0;
- p_udp_pkt->ip_pkt.hdr_checksum = calc_checksum(data,sizeof(ip_pkt_t));
-
- return len;
-
-} /* reply_udp */
-
-unsigned short calc_checksum (char *data, int len)
-{
- unsigned short temp;
- unsigned long sum=0;
- int i;
-
- for( i = 0; i <len; i+=2 ) {
- memcpy(&temp,&data[i],2);
- sum += (unsigned long)temp;
- }
-
- while (sum >> 16 ) {
- sum = (sum & 0xffffUL) + (sum >> 16);
- }
-
- temp = (unsigned short)sum;
- temp = ~temp;
-
- if( temp == 0 )
- temp = 0xffff;
-
- return temp;
-}
-
-/*
- If incoming is 0 (outgoing)- if the net numbers is ours make it 0
- if incoming is 1 - if the net number is 0 make it ours
-
-*/
-static void switch_net_numbers(unsigned char *sendpacket, unsigned long network_number, unsigned char incoming)
-{
- unsigned long pnetwork_number;
-
- pnetwork_number = (unsigned long)((sendpacket[6] << 24) +
- (sendpacket[7] << 16) + (sendpacket[8] << 8) +
- sendpacket[9]);
-
- if (!incoming) {
- //If the destination network number is ours, make it 0
- if( pnetwork_number == network_number) {
- sendpacket[6] = sendpacket[7] = sendpacket[8] =
- sendpacket[9] = 0x00;
- }
- } else {
- //If the incoming network is 0, make it ours
- if( pnetwork_number == 0) {
- sendpacket[6] = (unsigned char)(network_number >> 24);
- sendpacket[7] = (unsigned char)((network_number &
- 0x00FF0000) >> 16);
- sendpacket[8] = (unsigned char)((network_number &
- 0x0000FF00) >> 8);
- sendpacket[9] = (unsigned char)(network_number &
- 0x000000FF);
- }
- }
-
-
- pnetwork_number = (unsigned long)((sendpacket[18] << 24) +
- (sendpacket[19] << 16) + (sendpacket[20] << 8) +
- sendpacket[21]);
-
- if( !incoming ) {
- //If the source network is ours, make it 0
- if( pnetwork_number == network_number) {
- sendpacket[18] = sendpacket[19] = sendpacket[20] =
- sendpacket[21] = 0x00;
- }
- } else {
- //If the source network is 0, make it ours
- if( pnetwork_number == 0 ) {
- sendpacket[18] = (unsigned char)(network_number >> 24);
- sendpacket[19] = (unsigned char)((network_number &
- 0x00FF0000) >> 16);
- sendpacket[20] = (unsigned char)((network_number &
- 0x0000FF00) >> 8);
- sendpacket[21] = (unsigned char)(network_number &
- 0x000000FF);
- }
- }
-} /* switch_net_numbers */
-
-/*============================================================================
- * Get ethernet-style interface statistics.
- * Return a pointer to struct net_device_stats.
- */
-static struct net_device_stats *if_stats(struct net_device *dev)
-{
-
- ppp_private_area_t *ppp_priv_area = dev->priv;
- sdla_t* card;
-
- if( ppp_priv_area == NULL )
- return NULL;
-
- card = ppp_priv_area->card;
- return &card->wandev.stats;
-}
-
-/****** PPP Firmware Interface Functions ************************************/
-
-/*============================================================================
- * Read firmware code version.
- * Put code version as ASCII string in str.
- */
-static int ppp_read_version(sdla_t *card, char *str)
-{
- ppp_mbox_t *mb = card->mbox;
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.command = PPP_READ_CODE_VERSION;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK)
-
- ppp_error(card, err, mb);
-
- else if (str) {
-
- int len = mb->cmd.length;
-
- memcpy(str, mb->data, len);
- str[len] = '\0';
-
- }
-
- return err;
-}
-/*===========================================================================
- * Set Out-Bound Authentication.
-*/
-static int ppp_set_outbnd_auth (sdla_t *card, ppp_private_area_t *ppp_priv_area)
-{
- ppp_mbox_t *mb = card->mbox;
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- memset(&mb->data, 0, (strlen(ppp_priv_area->userid) +
- strlen(ppp_priv_area->passwd) + 2 ) );
- memcpy(mb->data, ppp_priv_area->userid, strlen(ppp_priv_area->userid));
- memcpy((mb->data + strlen(ppp_priv_area->userid) + 1),
- ppp_priv_area->passwd, strlen(ppp_priv_area->passwd));
-
- mb->cmd.length = strlen(ppp_priv_area->userid) +
- strlen(ppp_priv_area->passwd) + 2 ;
-
- mb->cmd.command = PPP_SET_OUTBOUND_AUTH;
-
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK)
- ppp_error(card, err, mb);
-
- return err;
-}
-
-/*===========================================================================
- * Set In-Bound Authentication.
-*/
-static int ppp_set_inbnd_auth (sdla_t *card, ppp_private_area_t *ppp_priv_area)
-{
- ppp_mbox_t *mb = card->mbox;
- int err, i;
- char* user_tokens[32];
- char* pass_tokens[32];
- int userids, passwds;
- int add_ptr;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- memset(&mb->data, 0, 1008);
- memcpy(mb->data, ppp_priv_area->sysname,
- strlen(ppp_priv_area->sysname));
-
- /* Parse the userid string and the password string and build a string
- to copy it to the data area of the command structure. The string
- will look like "SYS_NAME<NULL>USER1<NULL>PASS1<NULL>USER2<NULL>PASS2
- ....<NULL> "
- */
- userids = tokenize( ppp_priv_area->userid, user_tokens);
- passwds = tokenize( ppp_priv_area->passwd, pass_tokens);
-
- if (userids != passwds){
- printk(KERN_INFO "%s: Number of passwords does not equal the number of user ids\n", card->devname);
- return 1;
- }
-
- add_ptr = strlen(ppp_priv_area->sysname) + 1;
- for (i=0; i<userids; i++){
- memcpy((mb->data + add_ptr), user_tokens[i],
- strlen(user_tokens[i]));
- memcpy((mb->data + add_ptr + strlen(user_tokens[i]) + 1),
- pass_tokens[i], strlen(pass_tokens[i]));
- add_ptr = add_ptr + strlen(user_tokens[i]) + 1 +
- strlen(pass_tokens[i]) + 1;
- }
-
- mb->cmd.length = add_ptr + 1;
- mb->cmd.command = PPP_SET_INBOUND_AUTH;
-
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK)
- ppp_error(card, err, mb);
-
- return err;
-}
-
-
-/*============================================================================
- * Tokenize string.
- * Parse a string of the following syntax:
- * <arg1>,<arg2>,...
- * and fill array of tokens with pointers to string elements.
- *
- */
-static int tokenize (char *str, char **tokens)
-{
- int cnt = 0;
-
- tokens[0] = strsep(&str, "/");
- while (tokens[cnt] && (cnt < 32 - 1))
- {
- tokens[cnt] = strstrip(tokens[cnt], " \t");
- tokens[++cnt] = strsep(&str, "/");
- }
- return cnt;
-}
-
-/*============================================================================
- * Strip leading and trailing spaces off the string str.
- */
-static char* strstrip (char *str, char* s)
-{
- char *eos = str + strlen(str); /* -> end of string */
-
- while (*str && strchr(s, *str))
- ++str /* strip leading spaces */
- ;
- while ((eos > str) && strchr(s, *(eos - 1)))
- --eos /* strip trailing spaces */
- ;
- *eos = '\0';
- return str;
-}
-/*============================================================================
- * Configure PPP firmware.
- */
-static int ppp_configure(sdla_t *card, void *data)
-{
- ppp_mbox_t *mb = card->mbox;
- int data_len = sizeof(ppp508_conf_t);
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- memcpy(mb->data, data, data_len);
- mb->cmd.length = data_len;
- mb->cmd.command = PPP_SET_CONFIG;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK)
- ppp_error(card, err, mb);
-
- return err;
-}
-
-/*============================================================================
- * Set interrupt mode.
- */
-static int ppp_set_intr_mode(sdla_t *card, unsigned char mode)
-{
- ppp_mbox_t *mb = card->mbox;
- ppp_intr_info_t *ppp_intr_data = (ppp_intr_info_t *) &mb->data[0];
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- ppp_intr_data->i_enable = mode;
-
- ppp_intr_data->irq = card->hw.irq;
- mb->cmd.length = 2;
-
- /* If timer has been enabled, set the timer delay to 1sec */
- if (mode & 0x80){
- ppp_intr_data->timer_len = 250; //5;//100; //250;
- mb->cmd.length = 4;
- }
-
- mb->cmd.command = PPP_SET_INTR_FLAGS;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK)
- ppp_error(card, err, mb);
-
-
- return err;
-}
-
-/*============================================================================
- * Enable communications.
- */
-static int ppp_comm_enable(sdla_t *card)
-{
- ppp_mbox_t *mb = card->mbox;
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.command = PPP_COMM_ENABLE;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK)
- ppp_error(card, err, mb);
- else
- card->u.p.comm_enabled = 1;
-
- return err;
-}
-
-/*============================================================================
- * Disable communications.
- */
-static int ppp_comm_disable(sdla_t *card)
-{
- ppp_mbox_t *mb = card->mbox;
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.command = PPP_COMM_DISABLE;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
- if (err != CMD_OK)
- ppp_error(card, err, mb);
- else
- card->u.p.comm_enabled = 0;
-
- return err;
-}
-
-static int ppp_comm_disable_shutdown(sdla_t *card)
-{
- ppp_mbox_t *mb = card->mbox;
- ppp_intr_info_t *ppp_intr_data;
- int err;
-
- if (!mb){
- return 1;
- }
-
- ppp_intr_data = (ppp_intr_info_t *) &mb->data[0];
-
- /* Disable all interrupts */
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- ppp_intr_data->i_enable = 0;
-
- ppp_intr_data->irq = card->hw.irq;
- mb->cmd.length = 2;
-
- mb->cmd.command = PPP_SET_INTR_FLAGS;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- /* Disable communicatinons */
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.command = PPP_COMM_DISABLE;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- card->u.p.comm_enabled = 0;
-
- return 0;
-}
-
-
-
-/*============================================================================
- * Get communications error statistics.
- */
-static int ppp_get_err_stats(sdla_t *card)
-{
- ppp_mbox_t *mb = card->mbox;
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.command = PPP_READ_ERROR_STATS;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err == CMD_OK) {
-
- ppp_err_stats_t* stats = (void*)mb->data;
- card->wandev.stats.rx_over_errors = stats->rx_overrun;
- card->wandev.stats.rx_crc_errors = stats->rx_bad_crc;
- card->wandev.stats.rx_missed_errors = stats->rx_abort;
- card->wandev.stats.rx_length_errors = stats->rx_lost;
- card->wandev.stats.tx_aborted_errors = stats->tx_abort;
-
- } else
- ppp_error(card, err, mb);
-
- return err;
-}
-
-/*============================================================================
- * Send packet.
- * Return: 0 - o.k.
- * 1 - no transmit buffers available
- */
-static int ppp_send (sdla_t *card, void *data, unsigned len, unsigned proto)
-{
- ppp_buf_ctl_t *txbuf = card->u.p.txbuf;
-
- if (txbuf->flag)
- return 1;
-
- sdla_poke(&card->hw, txbuf->buf.ptr, data, len);
-
- txbuf->length = len; /* frame length */
-
- if (proto == htons(ETH_P_IPX))
- txbuf->proto = 0x01; /* protocol ID */
- else
- txbuf->proto = 0x00; /* protocol ID */
-
- txbuf->flag = 1; /* start transmission */
-
- /* Update transmit buffer control fields */
- card->u.p.txbuf = ++txbuf;
-
- if ((void*)txbuf > card->u.p.txbuf_last)
- card->u.p.txbuf = card->u.p.txbuf_base;
-
- return 0;
-}
-
-/****** Firmware Error Handler **********************************************/
-
-/*============================================================================
- * Firmware error handler.
- * This routine is called whenever firmware command returns non-zero
- * return code.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int ppp_error(sdla_t *card, int err, ppp_mbox_t *mb)
-{
- unsigned cmd = mb->cmd.command;
-
- switch (err) {
-
- case CMD_TIMEOUT:
- printk(KERN_ERR "%s: command 0x%02X timed out!\n",
- card->devname, cmd);
- break;
-
- default:
- printk(KERN_INFO "%s: command 0x%02X returned 0x%02X!\n"
- , card->devname, cmd, err);
- }
-
- return 0;
-}
-
-/****** Interrupt Handlers **************************************************/
-
-/*============================================================================
- * PPP interrupt service routine.
- */
-static void wpp_isr (sdla_t *card)
-{
- ppp_flags_t *flags = card->flags;
- char *ptr = &flags->iflag;
- struct net_device *dev = card->wandev.dev;
- int i;
-
- card->in_isr = 1;
- ++card->statistics.isr_entry;
-
- if (!dev && flags->iflag != PPP_INTR_CMD){
- card->in_isr = 0;
- flags->iflag = 0;
- return;
- }
-
- if (test_bit(PERI_CRIT, (void*)&card->wandev.critical)) {
- card->in_isr = 0;
- flags->iflag = 0;
- return;
- }
-
-
- if(card->hw.type != SDLA_S514){
- if (test_bit(SEND_CRIT, (void*)&card->wandev.critical)) {
- ++card->statistics.isr_already_critical;
- printk (KERN_INFO "%s: Critical while in ISR!\n",
- card->devname);
- card->in_isr = 0;
- flags->iflag = 0;
- return;
- }
- }
-
- switch (flags->iflag) {
-
- case PPP_INTR_RXRDY: /* receive interrupt 0x01 (bit 0)*/
- ++card->statistics.isr_rx;
- rx_intr(card);
- break;
-
- case PPP_INTR_TXRDY: /* transmit interrupt 0x02 (bit 1)*/
- ++card->statistics.isr_tx;
- flags->imask &= ~PPP_INTR_TXRDY;
- netif_wake_queue(dev);
- break;
-
- case PPP_INTR_CMD: /* interface command completed */
- ++Intr_test_counter;
- ++card->statistics.isr_intr_test;
- break;
-
- case PPP_INTR_MODEM: /* modem status change (DCD, CTS) 0x04 (bit 2)*/
- case PPP_INTR_DISC: /* Data link disconnected 0x10 (bit 4)*/
- case PPP_INTR_OPEN: /* Data link open 0x20 (bit 5)*/
- case PPP_INTR_DROP_DTR: /* DTR drop timeout expired 0x40 bit 6 */
- event_intr(card);
- break;
-
- case PPP_INTR_TIMER:
- timer_intr(card);
- break;
-
- default: /* unexpected interrupt */
- ++card->statistics.isr_spurious;
- printk(KERN_INFO "%s: spurious interrupt 0x%02X!\n",
- card->devname, flags->iflag);
- printk(KERN_INFO "%s: ID Bytes = ",card->devname);
- for(i = 0; i < 8; i ++)
- printk(KERN_INFO "0x%02X ", *(ptr + 0x28 + i));
- printk(KERN_INFO "\n");
- }
-
- card->in_isr = 0;
- flags->iflag = 0;
- return;
-}
-
-/*============================================================================
- * Receive interrupt handler.
- */
-static void rx_intr(sdla_t *card)
-{
- ppp_buf_ctl_t *rxbuf = card->rxmb;
- struct net_device *dev = card->wandev.dev;
- ppp_private_area_t *ppp_priv_area;
- struct sk_buff *skb;
- unsigned len;
- void *buf;
- int i;
- ppp_flags_t *flags = card->flags;
- char *ptr = &flags->iflag;
- int udp_type;
-
-
- if (rxbuf->flag != 0x01) {
-
- printk(KERN_INFO
- "%s: corrupted Rx buffer @ 0x%X, flag = 0x%02X!\n",
- card->devname, (unsigned)rxbuf, rxbuf->flag);
-
- printk(KERN_INFO "%s: ID Bytes = ",card->devname);
-
- for(i = 0; i < 8; i ++)
- printk(KERN_INFO "0x%02X ", *(ptr + 0x28 + i));
- printk(KERN_INFO "\n");
-
- ++card->statistics.rx_intr_corrupt_rx_bfr;
-
-
- /* Bug Fix: Mar 6 2000
- * If we get a corrupted mailbox, it means that driver
- * is out of sync with the firmware. There is no recovery.
- * If we don't turn off all interrupts for this card
- * the machine will crash.
- */
- printk(KERN_INFO "%s: Critical router failure ...!!!\n", card->devname);
- printk(KERN_INFO "Please contact Sangoma Technologies !\n");
- ppp_set_intr_mode(card,0);
- return;
- }
-
- if (dev && netif_running(dev) && dev->priv){
-
- len = rxbuf->length;
- ppp_priv_area = dev->priv;
-
- /* Allocate socket buffer */
- skb = dev_alloc_skb(len);
-
- if (skb != NULL) {
-
- /* Copy data to the socket buffer */
- unsigned addr = rxbuf->buf.ptr;
-
- if ((addr + len) > card->u.p.rx_top + 1) {
-
- unsigned tmp = card->u.p.rx_top - addr + 1;
- buf = skb_put(skb, tmp);
- sdla_peek(&card->hw, addr, buf, tmp);
- addr = card->u.p.rx_base;
- len -= tmp;
- }
- buf = skb_put(skb, len);
- sdla_peek(&card->hw, addr, buf, len);
-
- /* Decapsulate packet */
- switch (rxbuf->proto) {
-
- case 0x00:
- skb->protocol = htons(ETH_P_IP);
- break;
-
- case 0x01:
- skb->protocol = htons(ETH_P_IPX);
- break;
- }
-
- udp_type = udp_pkt_type( skb, card );
-
- if (udp_type == UDP_PTPIPE_TYPE){
-
- /* Handle a UDP Request in Timer Interrupt */
- if(store_udp_mgmt_pkt(UDP_PKT_FRM_NETWORK, card, skb, dev,
- ppp_priv_area)){
- flags->imask |= PPP_INTR_TIMER;
- }
- ++ppp_priv_area->rx_intr_stat.rx_intr_PIPE_request;
-
-
- } else if (handle_IPXWAN(skb->data,card->devname,
- ppp_priv_area->enable_IPX,
- ppp_priv_area->network_number,
- skb->protocol)) {
-
- /* Handle an IPXWAN packet */
- if( ppp_priv_area->enable_IPX) {
-
- /* Make sure we are not already sending */
- if (!test_bit(SEND_CRIT, &card->wandev.critical)){
- ppp_send(card, skb->data, skb->len, htons(ETH_P_IPX));
- }
- dev_kfree_skb_any(skb);
-
- } else {
- ++card->wandev.stats.rx_dropped;
- }
- } else {
- /* Pass data up the protocol stack */
- skb->dev = dev;
- skb->mac.raw = skb->data;
-
- ++card->wandev.stats.rx_packets;
- card->wandev.stats.rx_bytes += skb->len;
- ++ppp_priv_area->rx_intr_stat.rx_intr_bfr_passed_to_stack;
- netif_rx(skb);
- dev->last_rx = jiffies;
- }
-
- } else {
-
- if (net_ratelimit()){
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- }
- ++card->wandev.stats.rx_dropped;
- ++ppp_priv_area->rx_intr_stat.rx_intr_no_socket;
- }
-
- } else {
- ++card->statistics.rx_intr_dev_not_started;
- }
-
- /* Release buffer element and calculate a pointer to the next one */
- rxbuf->flag = 0x00;
- card->rxmb = ++rxbuf;
- if ((void*)rxbuf > card->u.p.rxbuf_last)
- card->rxmb = card->u.p.rxbuf_base;
-}
-
-
-void event_intr (sdla_t *card)
-{
-
- struct net_device* dev = card->wandev.dev;
- ppp_private_area_t* ppp_priv_area = dev->priv;
- volatile ppp_flags_t *flags = card->flags;
-
- switch (flags->iflag){
-
- case PPP_INTR_MODEM: /* modem status change (DCD, CTS) 0x04 (bit 2)*/
-
- if (net_ratelimit()){
- printk (KERN_INFO "%s: Modem status: DCD=%s CTS=%s\n",
- card->devname, DCD(flags->mstatus), CTS(flags->mstatus));
- }
- break;
-
- case PPP_INTR_DISC: /* Data link disconnected 0x10 (bit 4)*/
-
- NEX_PRINTK (KERN_INFO "Data link disconnected intr Cause %X\n",
- flags->disc_cause);
-
- if (flags->disc_cause &
- (PPP_LOCAL_TERMINATION | PPP_DCD_CTS_DROP |
- PPP_REMOTE_TERMINATION)) {
-
- if (card->u.p.ip_mode == WANOPT_PPP_PEER) {
- set_bit(0,&Read_connection_info);
- }
- wanpipe_set_state(card, WAN_DISCONNECTED);
-
- show_disc_cause(card, flags->disc_cause);
- ppp_priv_area->timer_int_enabled |= TMR_INT_ENABLED_PPP_EVENT;
- flags->imask |= PPP_INTR_TIMER;
- trigger_ppp_poll(dev);
- }
- break;
-
- case PPP_INTR_OPEN: /* Data link open 0x20 (bit 5)*/
-
- NEX_PRINTK (KERN_INFO "%s: PPP Link Open, LCP=%s IP=%s\n",
- card->devname,LCP(flags->lcp_state),
- IP(flags->ip_state));
-
- if (flags->lcp_state == 0x09 &&
- (flags->ip_state == 0x09 || flags->ipx_state == 0x09)){
-
- /* Initialize the polling timer and set the state
- * to WAN_CONNNECTED */
-
-
- /* BUG FIX: When the protocol restarts, during heavy
- * traffic, board tx buffers and driver tx buffers
- * can go out of sync. This checks the condition
- * and if the tx buffers are out of sync, the
- * protocols are restarted.
- * I don't know why the board tx buffer is out
- * of sync. It could be that a packets is tx
- * while the link is down, but that is not
- * possible. The other possiblility is that the
- * firmware doesn't reinitialize properly.
- * FIXME: A better fix should be found.
- */
- if (detect_and_fix_tx_bug(card)){
-
- ppp_comm_disable(card);
-
- wanpipe_set_state(card, WAN_DISCONNECTED);
-
- ppp_priv_area->timer_int_enabled |=
- TMR_INT_ENABLED_PPP_EVENT;
- flags->imask |= PPP_INTR_TIMER;
- break;
- }
-
- card->state_tick = jiffies;
- wanpipe_set_state(card, WAN_CONNECTED);
-
- NEX_PRINTK(KERN_INFO "CON: L Tx: %lx B Tx: %lx || L Rx %lx B Rx %lx\n",
- (unsigned long)card->u.p.txbuf, *card->u.p.txbuf_next,
- (unsigned long)card->rxmb, *card->u.p.rxbuf_next);
-
- /* Tell timer interrupt that PPP event occurred */
- ppp_priv_area->timer_int_enabled |= TMR_INT_ENABLED_PPP_EVENT;
- flags->imask |= PPP_INTR_TIMER;
-
- /* If we are in PEER mode, we must first obtain the
- * IP information and then go into the poll routine */
- if (card->u.p.ip_mode != WANOPT_PPP_PEER){
- trigger_ppp_poll(dev);
- }
- }
- break;
-
- case PPP_INTR_DROP_DTR: /* DTR drop timeout expired 0x40 bit 6 */
-
- NEX_PRINTK(KERN_INFO "DTR Drop Timeout Interrrupt \n");
-
- if (card->u.p.ip_mode == WANOPT_PPP_PEER) {
- set_bit(0,&Read_connection_info);
- }
-
- wanpipe_set_state(card, WAN_DISCONNECTED);
-
- show_disc_cause(card, flags->disc_cause);
- ppp_priv_area->timer_int_enabled |= TMR_INT_ENABLED_PPP_EVENT;
- flags->imask |= PPP_INTR_TIMER;
- trigger_ppp_poll(dev);
- break;
-
- default:
- printk(KERN_INFO "%s: Error, Invalid PPP Event\n",card->devname);
- }
-}
-
-
-
-/* TIMER INTERRUPT */
-
-void timer_intr (sdla_t *card)
-{
-
- struct net_device* dev = card->wandev.dev;
- ppp_private_area_t* ppp_priv_area = dev->priv;
- ppp_flags_t *flags = card->flags;
-
-
- if (ppp_priv_area->timer_int_enabled & TMR_INT_ENABLED_CONFIG){
- if (!config_ppp(card)){
- ppp_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_CONFIG;
- }
- }
-
- /* Update statistics */
- if (ppp_priv_area->timer_int_enabled & TMR_INT_ENABLED_UPDATE){
- ppp_get_err_stats(card);
- if(!(--ppp_priv_area->update_comms_stats)){
- ppp_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_UPDATE;
- }
- }
-
- /* PPIPEMON UDP request */
-
- if (ppp_priv_area->timer_int_enabled & TMR_INT_ENABLED_UDP){
- process_udp_mgmt_pkt(card,dev, ppp_priv_area);
- ppp_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_UDP;
- }
-
- /* PPP Event */
- if (ppp_priv_area->timer_int_enabled & TMR_INT_ENABLED_PPP_EVENT){
-
- if (card->wandev.state == WAN_DISCONNECTED){
- retrigger_comm(card);
- }
-
- /* If the state is CONNECTING, it means that communicatins were
- * enabled. When the remote side enables its comminication we
- * should get an interrupt PPP_INTR_OPEN, thus turn off polling
- */
-
- else if (card->wandev.state == WAN_CONNECTING){
- /* Turn off the timer interrupt */
- ppp_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_PPP_EVENT;
- }
-
- /* If state is connected and we are in PEER mode
- * poll for an IP address which will be provided by remote end.
- */
- else if ((card->wandev.state == WAN_CONNECTED &&
- card->u.p.ip_mode == WANOPT_PPP_PEER) &&
- test_bit(0,&Read_connection_info)){
-
- card->state_tick = jiffies;
- if (read_connection_info (card)){
- printk(KERN_INFO "%s: Failed to read PEER IP Addresses\n",
- card->devname);
- }else{
- clear_bit(0,&Read_connection_info);
- set_bit(1,&Read_connection_info);
- trigger_ppp_poll(dev);
- }
- }else{
- //FIXME Put the comment back int
- ppp_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_PPP_EVENT;
- }
-
- }/* End of PPP_EVENT */
-
-
- /* Only disable the timer interrupt if there are no udp, statistic */
- /* updates or events pending */
- if(!ppp_priv_area->timer_int_enabled) {
- flags->imask &= ~PPP_INTR_TIMER;
- }
-}
-
-
-static int handle_IPXWAN(unsigned char *sendpacket, char *devname, unsigned char enable_IPX, unsigned long network_number, unsigned short proto)
-{
- int i;
-
- if( proto == htons(ETH_P_IPX) ) {
- //It's an IPX packet
- if(!enable_IPX) {
- //Return 1 so we don't pass it up the stack.
- return 1;
- }
- } else {
- //It's not IPX so pass it up the stack.
- return 0;
- }
-
- if( sendpacket[16] == 0x90 &&
- sendpacket[17] == 0x04)
- {
- //It's IPXWAN
-
- if( sendpacket[2] == 0x02 &&
- sendpacket[34] == 0x00)
- {
- //It's a timer request packet
- printk(KERN_INFO "%s: Received IPXWAN Timer Request packet\n",devname);
-
- //Go through the routing options and answer no to every
- //option except Unnumbered RIP/SAP
- for(i = 41; sendpacket[i] == 0x00; i += 5)
- {
- //0x02 is the option for Unnumbered RIP/SAP
- if( sendpacket[i + 4] != 0x02)
- {
- sendpacket[i + 1] = 0;
- }
- }
-
- //Skip over the extended Node ID option
- if( sendpacket[i] == 0x04 )
- {
- i += 8;
- }
-
- //We also want to turn off all header compression opt.
- for(; sendpacket[i] == 0x80 ;)
- {
- sendpacket[i + 1] = 0;
- i += (sendpacket[i + 2] << 8) + (sendpacket[i + 3]) + 4;
- }
-
- //Set the packet type to timer response
- sendpacket[34] = 0x01;
-
- printk(KERN_INFO "%s: Sending IPXWAN Timer Response\n",devname);
- }
- else if( sendpacket[34] == 0x02 )
- {
- //This is an information request packet
- printk(KERN_INFO "%s: Received IPXWAN Information Request packet\n",devname);
-
- //Set the packet type to information response
- sendpacket[34] = 0x03;
-
- //Set the router name
- sendpacket[51] = 'P';
- sendpacket[52] = 'T';
- sendpacket[53] = 'P';
- sendpacket[54] = 'I';
- sendpacket[55] = 'P';
- sendpacket[56] = 'E';
- sendpacket[57] = '-';
- sendpacket[58] = CVHexToAscii(network_number >> 28);
- sendpacket[59] = CVHexToAscii((network_number & 0x0F000000)>> 24);
- sendpacket[60] = CVHexToAscii((network_number & 0x00F00000)>> 20);
- sendpacket[61] = CVHexToAscii((network_number & 0x000F0000)>> 16);
- sendpacket[62] = CVHexToAscii((network_number & 0x0000F000)>> 12);
- sendpacket[63] = CVHexToAscii((network_number & 0x00000F00)>> 8);
- sendpacket[64] = CVHexToAscii((network_number & 0x000000F0)>> 4);
- sendpacket[65] = CVHexToAscii(network_number & 0x0000000F);
- for(i = 66; i < 99; i+= 1)
- {
- sendpacket[i] = 0;
- }
-
- printk(KERN_INFO "%s: Sending IPXWAN Information Response packet\n",devname);
- }
- else
- {
- printk(KERN_INFO "%s: Unknown IPXWAN packet!\n",devname);
- return 0;
- }
-
- //Set the WNodeID to our network address
- sendpacket[35] = (unsigned char)(network_number >> 24);
- sendpacket[36] = (unsigned char)((network_number & 0x00FF0000) >> 16);
- sendpacket[37] = (unsigned char)((network_number & 0x0000FF00) >> 8);
- sendpacket[38] = (unsigned char)(network_number & 0x000000FF);
-
- return 1;
- } else {
- //If we get here it's an IPX-data packet, so it'll get passed up the stack.
-
- //switch the network numbers
- switch_net_numbers(sendpacket, network_number, 1);
- return 0;
- }
-}
-
-/****** Background Polling Routines ****************************************/
-
-/* All polling functions are invoked by the TIMER interrupt in the wpp_isr
- * routine.
- */
-
-/*============================================================================
- * Monitor active link phase.
- */
-static void process_route (sdla_t *card)
-{
- ppp_flags_t *flags = card->flags;
- struct net_device *dev = card->wandev.dev;
- ppp_private_area_t *ppp_priv_area = dev->priv;
-
- if ((card->u.p.ip_mode == WANOPT_PPP_PEER) &&
- (flags->ip_state == 0x09)){
-
- /* We get ip_local from the firmware in PEER mode.
- * Therefore, if ip_local is 0, we failed to obtain
- * the remote IP address. */
- if (ppp_priv_area->ip_local == 0)
- return;
-
- printk(KERN_INFO "%s: IPCP State Opened.\n", card->devname);
- if (read_info( card )) {
- printk(KERN_INFO
- "%s: An error occurred in IP assignment.\n",
- card->devname);
- } else {
- struct in_device *in_dev = dev->ip_ptr;
- if (in_dev != NULL ) {
- struct in_ifaddr *ifa = in_dev->ifa_list;
-
- printk(KERN_INFO "%s: Assigned Lcl. Addr: %u.%u.%u.%u\n",
- card->devname, NIPQUAD(ifa->ifa_local));
- printk(KERN_INFO "%s: Assigned Rmt. Addr: %u.%u.%u.%u\n",
- card->devname, NIPQUAD(ifa->ifa_address));
- }else{
- printk(KERN_INFO
- "%s: Error: Failed to add a route for PPP interface %s\n",
- card->devname,dev->name);
- }
- }
- }
-}
-
-/*============================================================================
- * Monitor physical link disconnected phase.
- * o if interface is up and the hold-down timeout has expired, then retry
- * connection.
- */
-static void retrigger_comm(sdla_t *card)
-{
- struct net_device *dev = card->wandev.dev;
-
- if (dev && ((jiffies - card->state_tick) > HOLD_DOWN_TIME)) {
-
- wanpipe_set_state(card, WAN_CONNECTING);
-
- if(ppp_comm_enable(card) == CMD_OK){
- init_ppp_tx_rx_buff( card );
- }
- }
-}
-
-/****** Miscellaneous Functions *********************************************/
-
-/*============================================================================
- * Configure S508 adapter.
- */
-static int config508(struct net_device *dev, sdla_t *card)
-{
- ppp508_conf_t cfg;
- struct in_device *in_dev = dev->ip_ptr;
- ppp_private_area_t *ppp_priv_area = dev->priv;
-
- /* Prepare PPP configuration structure */
- memset(&cfg, 0, sizeof(ppp508_conf_t));
-
- if (card->wandev.clocking)
- cfg.line_speed = card->wandev.bps;
-
- if (card->wandev.interface == WANOPT_RS232)
- cfg.conf_flags |= INTERFACE_LEVEL_RS232;
-
-
- cfg.conf_flags |= DONT_TERMINATE_LNK_MAX_CONFIG; /*send Configure-Request packets forever*/
- cfg.txbuf_percent = PERCENT_TX_BUFF; /* % of Tx bufs */
- cfg.mtu_local = card->wandev.mtu;
- cfg.mtu_remote = card->wandev.mtu; /* Default */
- cfg.restart_tmr = TIME_BETWEEN_CONF_REQ; /* 30 = 3sec */
- cfg.auth_rsrt_tmr = TIME_BETWEEN_PAP_CHAP_REQ; /* 30 = 3sec */
- cfg.auth_wait_tmr = WAIT_PAP_CHAP_WITHOUT_REPLY; /* 300 = 30s */
- cfg.mdm_fail_tmr = WAIT_AFTER_DCD_CTS_LOW; /* 5 = 0.5s */
- cfg.dtr_drop_tmr = TIME_DCD_CTS_LOW_AFTER_LNK_DOWN; /* 10 = 1s */
- cfg.connect_tmout = WAIT_DCD_HIGH_AFTER_ENABLE_COMM; /* 900 = 90s */
- cfg.conf_retry = MAX_CONF_REQ_WITHOUT_REPLY; /* 10 = 1s */
- cfg.term_retry = MAX_TERM_REQ_WITHOUT_REPLY; /* 2 times */
- cfg.fail_retry = NUM_CONF_NAK_WITHOUT_REPLY; /* 5 times */
- cfg.auth_retry = NUM_AUTH_REQ_WITHOUT_REPLY; /* 10 times */
-
-
- if( !card->u.p.authenticator ) {
- printk(KERN_INFO "%s: Device is not configured as an authenticator\n",
- card->devname);
- cfg.auth_options = NO_AUTHENTICATION;
- }else{
- printk(KERN_INFO "%s: Device is configured as an authenticator\n",
- card->devname);
- cfg.auth_options = INBOUND_AUTH;
- }
-
- if( ppp_priv_area->pap == WANOPT_YES){
- cfg.auth_options |=PAP_AUTH;
- printk(KERN_INFO "%s: Pap enabled\n", card->devname);
- }
- if( ppp_priv_area->chap == WANOPT_YES){
- cfg.auth_options |= CHAP_AUTH;
- printk(KERN_INFO "%s: Chap enabled\n", card->devname);
- }
-
-
- if (ppp_priv_area->enable_IPX == WANOPT_YES){
- printk(KERN_INFO "%s: Enabling IPX Protocol\n",card->devname);
- cfg.ipx_options = ENABLE_IPX | ROUTING_PROT_DEFAULT;
- }else{
- cfg.ipx_options = DISABLE_IPX;
- }
-
- switch (card->u.p.ip_mode) {
-
- case WANOPT_PPP_STATIC:
-
- printk(KERN_INFO "%s: PPP IP Mode: STATIC\n",card->devname);
- cfg.ip_options = L_AND_R_IP_NO_ASSIG |
- ENABLE_IP;
- cfg.ip_local = in_dev->ifa_list->ifa_local;
- cfg.ip_remote = in_dev->ifa_list->ifa_address;
- /* Debugging code used to check that IP addresses
- * obtained from the kernel are correct */
-
- NEX_PRINTK(KERN_INFO "Local %u.%u.%u.%u Remote %u.%u.%u.%u Name %s\n",
- NIPQUAD(ip_local),NIPQUAD(ip_remote), dev->name);
- break;
-
- case WANOPT_PPP_HOST:
-
- printk(KERN_INFO "%s: PPP IP Mode: HOST\n",card->devname);
- cfg.ip_options = L_IP_LOCAL_ASSIG |
- R_IP_LOCAL_ASSIG |
- ENABLE_IP;
- cfg.ip_local = in_dev->ifa_list->ifa_local;
- cfg.ip_remote = in_dev->ifa_list->ifa_address;
- /* Debugging code used to check that IP addresses
- * obtained from the kernel are correct */
- NEX_PRINTK (KERN_INFO "Local %u.%u.%u.%u Remote %u.%u.%u.%u Name %s\n",
- NIPQUAD(ip_local),NIPQUAD(ip_remote), dev->name);
-
- break;
-
- case WANOPT_PPP_PEER:
-
- printk(KERN_INFO "%s: PPP IP Mode: PEER\n",card->devname);
- cfg.ip_options = L_IP_REMOTE_ASSIG |
- R_IP_REMOTE_ASSIG |
- ENABLE_IP;
- cfg.ip_local = 0x00;
- cfg.ip_remote = 0x00;
- break;
-
- default:
- printk(KERN_INFO "%s: ERROR: Unsupported PPP Mode Selected\n",
- card->devname);
- printk(KERN_INFO "%s: PPP IP Modes: STATIC, PEER or HOST\n",
- card->devname);
- return 1;
- }
-
- return ppp_configure(card, &cfg);
-}
-
-/*============================================================================
- * Show disconnection cause.
- */
-static void show_disc_cause(sdla_t *card, unsigned cause)
-{
- if (cause & 0x0802)
-
- printk(KERN_INFO "%s: link terminated by peer\n",
- card->devname);
-
- else if (cause & 0x0004)
-
- printk(KERN_INFO "%s: link terminated by user\n",
- card->devname);
-
- else if (cause & 0x0008)
-
- printk(KERN_INFO "%s: authentication failed\n", card->devname);
-
- else if (cause & 0x0010)
-
- printk(KERN_INFO
- "%s: authentication protocol negotiation failed\n",
- card->devname);
-
- else if (cause & 0x0020)
-
- printk(KERN_INFO
- "%s: peer's request for authentication rejected\n",
- card->devname);
-
- else if (cause & 0x0040)
-
- printk(KERN_INFO "%s: MRU option rejected by peer\n",
- card->devname);
-
- else if (cause & 0x0080)
-
- printk(KERN_INFO "%s: peer's MRU was too small\n",
- card->devname);
-
- else if (cause & 0x0100)
-
- printk(KERN_INFO "%s: failed to negotiate peer's LCP options\n",
- card->devname);
-
- else if (cause & 0x0200)
-
- printk(KERN_INFO "%s: failed to negotiate peer's IPCP options\n"
- , card->devname);
-
- else if (cause & 0x0400)
-
- printk(KERN_INFO
- "%s: failed to negotiate peer's IPXCP options\n",
- card->devname);
-}
-
-/*=============================================================================
- * Process UDP call of type PTPIPEAB.
- */
-static void process_udp_mgmt_pkt(sdla_t *card, struct net_device *dev,
- ppp_private_area_t *ppp_priv_area )
-{
- unsigned char buf2[5];
- unsigned char *buf;
- unsigned int frames, len;
- struct sk_buff *new_skb;
- unsigned short data_length, buffer_length, real_len;
- unsigned long data_ptr;
- int udp_mgmt_req_valid = 1;
- ppp_mbox_t *mbox = card->mbox;
- struct timeval tv;
- int err;
- ppp_udp_pkt_t *ppp_udp_pkt = (ppp_udp_pkt_t*)&ppp_priv_area->udp_pkt_data;
-
- memcpy(&buf2, &card->wandev.udp_port, 2 );
-
-
- if(ppp_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK) {
-
- switch(ppp_udp_pkt->cblock.command) {
-
- case PPIPE_GET_IBA_DATA:
- case PPP_READ_CONFIG:
- case PPP_GET_CONNECTION_INFO:
- case PPIPE_ROUTER_UP_TIME:
- case PPP_READ_STATISTICS:
- case PPP_READ_ERROR_STATS:
- case PPP_READ_PACKET_STATS:
- case PPP_READ_LCP_STATS:
- case PPP_READ_IPCP_STATS:
- case PPP_READ_IPXCP_STATS:
- case PPP_READ_PAP_STATS:
- case PPP_READ_CHAP_STATS:
- case PPP_READ_CODE_VERSION:
- udp_mgmt_req_valid = 1;
- break;
-
- default:
- udp_mgmt_req_valid = 0;
- break;
- }
- }
-
- if(!udp_mgmt_req_valid) {
-
- /* set length to 0 */
- ppp_udp_pkt->cblock.length = 0x00;
-
- /* set return code */
- ppp_udp_pkt->cblock.result = 0xCD;
- ++ppp_priv_area->pipe_mgmt_stat.UDP_PIPE_mgmt_direction_err;
-
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Warning, Illegal UDP command attempted from network: %x\n",
- card->devname,ppp_udp_pkt->cblock.command);
- }
- } else {
- /* Initialize the trace element */
- trace_element_t trace_element;
-
- switch (ppp_udp_pkt->cblock.command){
-
- /* PPIPE_ENABLE_TRACING */
- case PPIPE_ENABLE_TRACING:
- if (!card->TracingEnabled) {
-
- /* OPERATE_DATALINE_MONITOR */
- mbox->cmd.command = PPP_DATALINE_MONITOR;
- mbox->cmd.length = 0x01;
- mbox->data[0] = ppp_udp_pkt->data[0];
- err = sdla_exec(mbox) ?
- mbox->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK) {
-
- ppp_error(card, err, mbox);
- card->TracingEnabled = 0;
-
- /* set the return code */
-
- ppp_udp_pkt->cblock.result = mbox->cmd.result;
- mbox->cmd.length = 0;
- break;
- }
-
- sdla_peek(&card->hw, 0xC000, &buf2, 2);
-
- ppp_priv_area->curr_trace_addr = 0;
- memcpy(&ppp_priv_area->curr_trace_addr, &buf2, 2);
- ppp_priv_area->start_trace_addr =
- ppp_priv_area->curr_trace_addr;
- ppp_priv_area->end_trace_addr =
- ppp_priv_area->start_trace_addr + END_OFFSET;
-
- /* MAX_SEND_BUFFER_SIZE - 28 (IP header)
- - 32 (ppipemon CBLOCK) */
- available_buffer_space = MAX_LGTH_UDP_MGNT_PKT -
- sizeof(ip_pkt_t)-
- sizeof(udp_pkt_t)-
- sizeof(wp_mgmt_t)-
- sizeof(cblock_t);
- }
- ppp_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 0;
- card->TracingEnabled = 1;
- break;
-
- /* PPIPE_DISABLE_TRACING */
- case PPIPE_DISABLE_TRACING:
-
- if(card->TracingEnabled) {
-
- /* OPERATE_DATALINE_MONITOR */
- mbox->cmd.command = 0x33;
- mbox->cmd.length = 1;
- mbox->data[0] = 0x00;
- err = sdla_exec(mbox) ?
- mbox->cmd.result : CMD_TIMEOUT;
-
- }
-
- /*set return code*/
- ppp_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 0;
- card->TracingEnabled = 0;
- break;
-
- /* PPIPE_GET_TRACE_INFO */
- case PPIPE_GET_TRACE_INFO:
-
- if(!card->TracingEnabled) {
- /* set return code */
- ppp_udp_pkt->cblock.result = 1;
- mbox->cmd.length = 0;
- }
-
- buffer_length = 0;
-
- /* frames < 62, where 62 is the number of trace
- information elements. There is in total 496
- bytes of space and each trace information
- element is 8 bytes.
- */
- for ( frames=0; frames<62; frames++) {
-
- trace_pkt_t *trace_pkt = (trace_pkt_t *)
- &ppp_udp_pkt->data[buffer_length];
-
- /* Read the whole trace packet */
- sdla_peek(&card->hw, ppp_priv_area->curr_trace_addr,
- &trace_element, sizeof(trace_element_t));
-
- /* no data on board so exit */
- if( trace_element.opp_flag == 0x00 )
- break;
-
- data_ptr = trace_element.trace_data_ptr;
-
- /* See if there is actual data on the trace buffer */
- if (data_ptr){
- data_length = trace_element.trace_length;
- }else{
- data_length = 0;
- ppp_udp_pkt->data[0] |= 0x02;
- }
-
- //FIXME: Do we need this check
- if ((available_buffer_space - buffer_length)
- < (sizeof(trace_element_t)+1)){
-
- /*indicate we have more frames
- * on board and exit
- */
- ppp_udp_pkt->data[0] |= 0x02;
- break;
- }
-
- trace_pkt->status = trace_element.trace_type;
- trace_pkt->time_stamp = trace_element.trace_time_stamp;
- trace_pkt->real_length = trace_element.trace_length;
-
- real_len = trace_element.trace_length;
-
- if(data_ptr == 0){
- trace_pkt->data_avail = 0x00;
- }else{
- /* we can take it next time */
- if ((available_buffer_space - buffer_length)<
- (real_len + sizeof(trace_pkt_t))){
-
- ppp_udp_pkt->data[0] |= 0x02;
- break;
- }
- trace_pkt->data_avail = 0x01;
-
- /* get the data */
- sdla_peek(&card->hw, data_ptr,
- &trace_pkt->data,
- real_len);
- }
- /* zero the opp flag to
- show we got the frame */
- buf2[0] = 0x00;
- sdla_poke(&card->hw, ppp_priv_area->curr_trace_addr,
- &buf2, 1);
-
- /* now move onto the next
- frame */
- ppp_priv_area->curr_trace_addr += 8;
-
- /* check if we passed the last address */
- if ( ppp_priv_area->curr_trace_addr >=
- ppp_priv_area->end_trace_addr){
-
- ppp_priv_area->curr_trace_addr =
- ppp_priv_area->start_trace_addr;
- }
-
- /* update buffer length and make sure its even */
-
- if ( trace_pkt->data_avail == 0x01 ) {
- buffer_length += real_len - 1;
- }
-
- /* for the header */
- buffer_length += 8;
-
- if( buffer_length & 0x0001 )
- buffer_length += 1;
- }
-
- /* ok now set the total number of frames passed
- in the high 5 bits */
- ppp_udp_pkt->data[0] |= (frames << 2);
-
- /* set the data length */
- mbox->cmd.length = buffer_length;
- ppp_udp_pkt->cblock.length = buffer_length;
-
- /* set return code */
- ppp_udp_pkt->cblock.result = 0;
- break;
-
- /* PPIPE_GET_IBA_DATA */
- case PPIPE_GET_IBA_DATA:
-
- mbox->cmd.length = 0x09;
-
- sdla_peek(&card->hw, 0xF003, &ppp_udp_pkt->data,
- mbox->cmd.length);
-
- /* set the length of the data */
- ppp_udp_pkt->cblock.length = 0x09;
-
- /* set return code */
- ppp_udp_pkt->cblock.result = 0x00;
- ppp_udp_pkt->cblock.result = 0;
- break;
-
- /* PPIPE_FT1_READ_STATUS */
- case PPIPE_FT1_READ_STATUS:
- sdla_peek(&card->hw, 0xF020, &ppp_udp_pkt->data[0], 2);
- ppp_udp_pkt->cblock.length = mbox->cmd.length = 2;
- ppp_udp_pkt->cblock.result = 0;
- break;
-
- case PPIPE_FLUSH_DRIVER_STATS:
- init_ppp_priv_struct( ppp_priv_area );
- init_global_statistics( card );
- mbox->cmd.length = 0;
- ppp_udp_pkt->cblock.result = 0;
- break;
-
-
- case PPIPE_ROUTER_UP_TIME:
-
- do_gettimeofday( &tv );
- ppp_priv_area->router_up_time = tv.tv_sec -
- ppp_priv_area->router_start_time;
- *(unsigned long *)&ppp_udp_pkt->data = ppp_priv_area->router_up_time;
- mbox->cmd.length = 4;
- ppp_udp_pkt->cblock.result = 0;
- break;
-
- /* PPIPE_DRIVER_STATISTICS */
- case PPIPE_DRIVER_STAT_IFSEND:
- memcpy(&ppp_udp_pkt->data, &ppp_priv_area->if_send_stat,
- sizeof(if_send_stat_t));
-
-
- ppp_udp_pkt->cblock.result = 0;
- ppp_udp_pkt->cblock.length = sizeof(if_send_stat_t);
- mbox->cmd.length = sizeof(if_send_stat_t);
- break;
-
- case PPIPE_DRIVER_STAT_INTR:
- memcpy(&ppp_udp_pkt->data, &card->statistics,
- sizeof(global_stats_t));
-
- memcpy(&ppp_udp_pkt->data+sizeof(global_stats_t),
- &ppp_priv_area->rx_intr_stat,
- sizeof(rx_intr_stat_t));
-
- ppp_udp_pkt->cblock.result = 0;
- ppp_udp_pkt->cblock.length = sizeof(global_stats_t)+
- sizeof(rx_intr_stat_t);
- mbox->cmd.length = ppp_udp_pkt->cblock.length;
- break;
-
- case PPIPE_DRIVER_STAT_GEN:
- memcpy( &ppp_udp_pkt->data,
- &ppp_priv_area->pipe_mgmt_stat,
- sizeof(pipe_mgmt_stat_t));
-
- memcpy(&ppp_udp_pkt->data+sizeof(pipe_mgmt_stat_t),
- &card->statistics, sizeof(global_stats_t));
-
- ppp_udp_pkt->cblock.result = 0;
- ppp_udp_pkt->cblock.length = sizeof(global_stats_t)+
- sizeof(rx_intr_stat_t);
- mbox->cmd.length = ppp_udp_pkt->cblock.length;
- break;
-
-
- /* FT1 MONITOR STATUS */
- case FT1_MONITOR_STATUS_CTRL:
-
- /* Enable FT1 MONITOR STATUS */
- if( ppp_udp_pkt->data[0] == 1) {
-
- if( rCount++ != 0 ) {
- ppp_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 1;
- break;
- }
- }
-
- /* Disable FT1 MONITOR STATUS */
- if( ppp_udp_pkt->data[0] == 0) {
-
- if( --rCount != 0) {
- ppp_udp_pkt->cblock.result = 0;
- mbox->cmd.length = 1;
- break;
- }
- }
- goto udp_dflt_cmd;
-
- /* WARNING: FIXME: This should be fixed.
- * The FT1 Status Ctrl doesn't have a break
- * statment. Thus, no code must be inserted
- * HERE: between default and above case statement */
-
- default:
-udp_dflt_cmd:
-
- /* it's a board command */
- mbox->cmd.command = ppp_udp_pkt->cblock.command;
- mbox->cmd.length = ppp_udp_pkt->cblock.length;
-
- if(mbox->cmd.length) {
- memcpy(&mbox->data,(unsigned char *)ppp_udp_pkt->data,
- mbox->cmd.length);
- }
-
- /* run the command on the board */
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK) {
-
- ppp_error(card, err, mbox);
- ++ppp_priv_area->pipe_mgmt_stat.
- UDP_PIPE_mgmt_adptr_cmnd_timeout;
- break;
- }
-
- ++ppp_priv_area->pipe_mgmt_stat.UDP_PIPE_mgmt_adptr_cmnd_OK;
-
- /* copy the result back to our buffer */
- memcpy(&ppp_udp_pkt->cblock,mbox, sizeof(cblock_t));
-
- if(mbox->cmd.length) {
- memcpy(&ppp_udp_pkt->data,&mbox->data,mbox->cmd.length);
- }
-
- } /* end of switch */
- } /* end of else */
-
- /* Fill UDP TTL */
- ppp_udp_pkt->ip_pkt.ttl = card->wandev.ttl;
- len = reply_udp(ppp_priv_area->udp_pkt_data, mbox->cmd.length);
-
- if (ppp_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK) {
-
- /* Make sure we are not already sending */
- if (!test_bit(SEND_CRIT,&card->wandev.critical)){
- ++ppp_priv_area->pipe_mgmt_stat.UDP_PIPE_mgmt_passed_to_adptr;
- ppp_send(card,ppp_priv_area->udp_pkt_data,len,ppp_priv_area->protocol);
- }
-
- } else {
-
- /* Pass it up the stack
- Allocate socket buffer */
- if ((new_skb = dev_alloc_skb(len)) != NULL) {
-
- /* copy data into new_skb */
-
- buf = skb_put(new_skb, len);
- memcpy(buf,ppp_priv_area->udp_pkt_data, len);
-
- ++ppp_priv_area->pipe_mgmt_stat.UDP_PIPE_mgmt_passed_to_stack;
-
- /* Decapsulate packet and pass it up the protocol
- stack */
- new_skb->protocol = htons(ETH_P_IP);
- new_skb->dev = dev;
- new_skb->mac.raw = new_skb->data;
- netif_rx(new_skb);
- dev->last_rx = jiffies;
-
- } else {
-
- ++ppp_priv_area->pipe_mgmt_stat.UDP_PIPE_mgmt_no_socket;
- printk(KERN_INFO "no socket buffers available!\n");
- }
- }
-
- ppp_priv_area->udp_pkt_lgth = 0;
-
- return;
-}
-
-/*=============================================================================
- * Initial the ppp_private_area structure.
- */
-static void init_ppp_priv_struct( ppp_private_area_t *ppp_priv_area )
-{
-
- memset(&ppp_priv_area->if_send_stat, 0, sizeof(if_send_stat_t));
- memset(&ppp_priv_area->rx_intr_stat, 0, sizeof(rx_intr_stat_t));
- memset(&ppp_priv_area->pipe_mgmt_stat, 0, sizeof(pipe_mgmt_stat_t));
-}
-
-/*============================================================================
- * Initialize Global Statistics
- */
-static void init_global_statistics( sdla_t *card )
-{
- memset(&card->statistics, 0, sizeof(global_stats_t));
-}
-
-/*============================================================================
- * Initialize Receive and Transmit Buffers.
- */
-static void init_ppp_tx_rx_buff( sdla_t *card )
-{
- ppp508_buf_info_t* info;
-
- if (card->hw.type == SDLA_S514) {
-
- info = (void*)(card->hw.dpmbase + PPP514_BUF_OFFS);
-
- card->u.p.txbuf_base = (void*)(card->hw.dpmbase +
- info->txb_ptr);
-
- card->u.p.txbuf_last = (ppp_buf_ctl_t*)card->u.p.txbuf_base +
- (info->txb_num - 1);
-
- card->u.p.rxbuf_base = (void*)(card->hw.dpmbase +
- info->rxb_ptr);
-
- card->u.p.rxbuf_last = (ppp_buf_ctl_t*)card->u.p.rxbuf_base +
- (info->rxb_num - 1);
-
- } else {
-
- info = (void*)(card->hw.dpmbase + PPP508_BUF_OFFS);
-
- card->u.p.txbuf_base = (void*)(card->hw.dpmbase +
- (info->txb_ptr - PPP508_MB_VECT));
-
- card->u.p.txbuf_last = (ppp_buf_ctl_t*)card->u.p.txbuf_base +
- (info->txb_num - 1);
-
- card->u.p.rxbuf_base = (void*)(card->hw.dpmbase +
- (info->rxb_ptr - PPP508_MB_VECT));
-
- card->u.p.rxbuf_last = (ppp_buf_ctl_t*)card->u.p.rxbuf_base +
- (info->rxb_num - 1);
- }
-
- card->u.p.txbuf_next = (unsigned long*)&info->txb_nxt;
- card->u.p.rxbuf_next = (unsigned long*)&info->rxb1_ptr;
-
- card->u.p.rx_base = info->rxb_base;
- card->u.p.rx_top = info->rxb_end;
-
- card->u.p.txbuf = card->u.p.txbuf_base;
- card->rxmb = card->u.p.rxbuf_base;
-
-}
-
-/*=============================================================================
- * Read Connection Information (ie for Remote IP address assginment).
- * Called when ppp interface connected.
- */
-static int read_info( sdla_t *card )
-{
- struct net_device *dev = card->wandev.dev;
- ppp_private_area_t *ppp_priv_area = dev->priv;
- int err;
-
- struct ifreq if_info;
- struct sockaddr_in *if_data1, *if_data2;
- mm_segment_t fs;
-
- /* Set Local and remote addresses */
- memset(&if_info, 0, sizeof(if_info));
- strcpy(if_info.ifr_name, dev->name);
-
-
- fs = get_fs();
- set_fs(get_ds()); /* get user space block */
-
- /* Change the local and remote ip address of the interface.
- * This will also add in the destination route.
- */
- if_data1 = (struct sockaddr_in *)&if_info.ifr_addr;
- if_data1->sin_addr.s_addr = ppp_priv_area->ip_local;
- if_data1->sin_family = AF_INET;
- err = devinet_ioctl( SIOCSIFADDR, &if_info );
- if_data2 = (struct sockaddr_in *)&if_info.ifr_dstaddr;
- if_data2->sin_addr.s_addr = ppp_priv_area->ip_remote;
- if_data2->sin_family = AF_INET;
- err = devinet_ioctl( SIOCSIFDSTADDR, &if_info );
-
- set_fs(fs); /* restore old block */
-
- if (err) {
- printk (KERN_INFO "%s: Adding of route failed: %i\n",
- card->devname,err);
- printk (KERN_INFO "%s: Local : %u.%u.%u.%u\n",
- card->devname,NIPQUAD(ppp_priv_area->ip_local));
- printk (KERN_INFO "%s: Remote: %u.%u.%u.%u\n",
- card->devname,NIPQUAD(ppp_priv_area->ip_remote));
- }
- return err;
-}
-
-/*=============================================================================
- * Remove Dynamic Route.
- * Called when ppp interface disconnected.
- */
-
-static void remove_route( sdla_t *card )
-{
-
- struct net_device *dev = card->wandev.dev;
- long ip_addr;
- int err;
-
- mm_segment_t fs;
- struct ifreq if_info;
- struct sockaddr_in *if_data1;
- struct in_device *in_dev = dev->ip_ptr;
- struct in_ifaddr *ifa = in_dev->ifa_list;
-
- ip_addr = ifa->ifa_local;
-
- /* Set Local and remote addresses */
- memset(&if_info, 0, sizeof(if_info));
- strcpy(if_info.ifr_name, dev->name);
-
- fs = get_fs();
- set_fs(get_ds()); /* get user space block */
-
- /* Change the local ip address of the interface to 0.
- * This will also delete the destination route.
- */
- if_data1 = (struct sockaddr_in *)&if_info.ifr_addr;
- if_data1->sin_addr.s_addr = 0;
- if_data1->sin_family = AF_INET;
- err = devinet_ioctl( SIOCSIFADDR, &if_info );
-
- set_fs(fs); /* restore old block */
-
-
- if (err) {
- printk (KERN_INFO "%s: Deleting dynamic route failed %d!\n",
- card->devname, err);
- return;
- }else{
- printk (KERN_INFO "%s: PPP Deleting dynamic route %u.%u.%u.%u successfuly\n",
- card->devname, NIPQUAD(ip_addr));
- }
- return;
-}
-
-/*=============================================================================
- * Perform the Interrupt Test by running the READ_CODE_VERSION command MAX_INTR
- * _TEST_COUNTER times.
- */
-static int intr_test( sdla_t *card )
-{
- ppp_mbox_t *mb = card->mbox;
- int err,i;
-
- err = ppp_set_intr_mode( card, 0x08 );
-
- if (err == CMD_OK) {
-
- for (i = 0; i < MAX_INTR_TEST_COUNTER; i ++) {
- /* Run command READ_CODE_VERSION */
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.length = 0;
- mb->cmd.command = PPP_READ_CODE_VERSION;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
- if (err != CMD_OK)
- ppp_error(card, err, mb);
- }
- }
- else return err;
-
- err = ppp_set_intr_mode( card, 0 );
- if (err != CMD_OK)
- return err;
-
- return 0;
-}
-
-/*==============================================================================
- * Determine what type of UDP call it is. DRVSTATS or PTPIPEAB ?
- */
-static int udp_pkt_type( struct sk_buff *skb, sdla_t *card )
-{
- unsigned char *sendpacket;
- unsigned char buf2[5];
- ppp_udp_pkt_t *ppp_udp_pkt = (ppp_udp_pkt_t *)skb->data;
-
- sendpacket = skb->data;
- memcpy(&buf2, &card->wandev.udp_port, 2);
-
- if( ppp_udp_pkt->ip_pkt.ver_inet_hdr_length == 0x45 && /* IP packet */
- sendpacket[9] == 0x11 && /* UDP packet */
- sendpacket[22] == buf2[1] && /* UDP Port */
- sendpacket[23] == buf2[0] &&
- sendpacket[36] == 0x01 ) {
-
- if ( sendpacket[28] == 0x50 && /* PTPIPEAB: Signature */
- sendpacket[29] == 0x54 &&
- sendpacket[30] == 0x50 &&
- sendpacket[31] == 0x49 &&
- sendpacket[32] == 0x50 &&
- sendpacket[33] == 0x45 &&
- sendpacket[34] == 0x41 &&
- sendpacket[35] == 0x42 ){
-
- return UDP_PTPIPE_TYPE;
-
- } else if(sendpacket[28] == 0x44 && /* DRVSTATS: Signature */
- sendpacket[29] == 0x52 &&
- sendpacket[30] == 0x56 &&
- sendpacket[31] == 0x53 &&
- sendpacket[32] == 0x54 &&
- sendpacket[33] == 0x41 &&
- sendpacket[34] == 0x54 &&
- sendpacket[35] == 0x53 ){
-
- return UDP_DRVSTATS_TYPE;
-
- } else
- return UDP_INVALID_TYPE;
-
- } else
- return UDP_INVALID_TYPE;
-
-}
-
-/*============================================================================
- * Check to see if the packet to be transmitted contains a broadcast or
- * multicast source IP address.
- */
-
-static int chk_bcast_mcast_addr(sdla_t *card, struct net_device* dev,
- struct sk_buff *skb)
-{
- u32 src_ip_addr;
- u32 broadcast_ip_addr = 0;
- struct in_device *in_dev;
-
- /* read the IP source address from the outgoing packet */
- src_ip_addr = *(u32 *)(skb->data + 12);
-
- /* read the IP broadcast address for the device */
- in_dev = dev->ip_ptr;
- if(in_dev != NULL) {
- struct in_ifaddr *ifa= in_dev->ifa_list;
- if(ifa != NULL)
- broadcast_ip_addr = ifa->ifa_broadcast;
- else
- return 0;
- }
-
- /* check if the IP Source Address is a Broadcast address */
- if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) {
- printk(KERN_INFO "%s: Broadcast Source Address silently discarded\n",
- card->devname);
- return 1;
- }
-
- /* check if the IP Source Address is a Multicast address */
- if((ntohl(src_ip_addr) >= 0xE0000001) &&
- (ntohl(src_ip_addr) <= 0xFFFFFFFE)) {
- printk(KERN_INFO "%s: Multicast Source Address silently discarded\n",
- card->devname);
- return 1;
- }
-
- return 0;
-}
-
-void s508_lock (sdla_t *card, unsigned long *smp_flags)
-{
- spin_lock_irqsave(&card->wandev.lock, *smp_flags);
-}
-
-void s508_unlock (sdla_t *card, unsigned long *smp_flags)
-{
- spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
-}
-
-static int read_connection_info (sdla_t *card)
-{
- ppp_mbox_t *mb = card->mbox;
- struct net_device *dev = card->wandev.dev;
- ppp_private_area_t *ppp_priv_area = dev->priv;
- ppp508_connect_info_t *ppp508_connect_info;
- int err;
-
- memset(&mb->cmd, 0, sizeof(ppp_cmd_t));
- mb->cmd.length = 0;
- mb->cmd.command = PPP_GET_CONNECTION_INFO;
- err = sdla_exec(mb) ? mb->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK) {
- ppp_error(card, err, mb);
- ppp_priv_area->ip_remote = 0;
- ppp_priv_area->ip_local = 0;
- }
- else {
- ppp508_connect_info = (ppp508_connect_info_t *)mb->data;
- ppp_priv_area->ip_remote = ppp508_connect_info->ip_remote;
- ppp_priv_area->ip_local = ppp508_connect_info->ip_local;
-
- NEX_PRINTK(KERN_INFO "READ CONNECTION GOT IP ADDRESS %x, %x\n",
- ppp_priv_area->ip_remote,
- ppp_priv_area->ip_local);
- }
-
- return err;
-}
-
-/*===============================================================================
- * config_ppp
- *
- * Configure the ppp protocol and enable communications.
- *
- * The if_open function binds this function to the poll routine.
- * Therefore, this function will run every time the ppp interface
- * is brought up.
- *
- * If the communications are not enabled, proceed to configure
- * the card and enable communications.
- *
- * If the communications are enabled, it means that the interface
- * was shutdown by ether the user or driver. In this case, we
- * have to check that the IP addresses have not changed. If
- * the IP addresses changed, we have to reconfigure the firmware
- * and update the changed IP addresses. Otherwise, just exit.
- */
-static int config_ppp (sdla_t *card)
-{
-
- struct net_device *dev = card->wandev.dev;
- ppp_flags_t *flags = card->flags;
- ppp_private_area_t *ppp_priv_area = dev->priv;
-
- if (card->u.p.comm_enabled){
-
- if (ppp_priv_area->ip_local_tmp != ppp_priv_area->ip_local ||
- ppp_priv_area->ip_remote_tmp != ppp_priv_area->ip_remote){
-
- /* The IP addersses have changed, we must
- * stop the communications and reconfigure
- * the card. Reason: the firmware must know
- * the local and remote IP addresses. */
- disable_comm(card);
- wanpipe_set_state(card, WAN_DISCONNECTED);
- printk(KERN_INFO
- "%s: IP addresses changed!\n",
- card->devname);
- printk(KERN_INFO "%s: Restarting communications ...\n",
- card->devname);
- }else{
- /* IP addresses are the same and the link is up,
- * we don't have to do anything here. Therefore, exit */
- return 0;
- }
- }
-
- /* Record the new IP addreses */
- ppp_priv_area->ip_local = ppp_priv_area->ip_local_tmp;
- ppp_priv_area->ip_remote = ppp_priv_area->ip_remote_tmp;
-
- if (config508(dev, card)){
- printk(KERN_INFO "%s: Failed to configure PPP device\n",
- card->devname);
- return 0;
- }
-
- if (ppp_set_intr_mode(card, PPP_INTR_RXRDY|
- PPP_INTR_TXRDY|
- PPP_INTR_MODEM|
- PPP_INTR_DISC |
- PPP_INTR_OPEN |
- PPP_INTR_DROP_DTR |
- PPP_INTR_TIMER)) {
-
- printk(KERN_INFO "%s: Failed to configure board interrupts !\n",
- card->devname);
- return 0;
- }
-
- /* Turn off the transmit and timer interrupt */
- flags->imask &= ~(PPP_INTR_TXRDY | PPP_INTR_TIMER) ;
-
-
- /* If you are not the authenticator and any one of the protocol is
- * enabled then we call the set_out_bound_authentication.
- */
- if ( !card->u.p.authenticator && (ppp_priv_area->pap || ppp_priv_area->chap)) {
- if ( ppp_set_outbnd_auth(card, ppp_priv_area) ){
- printk(KERN_INFO "%s: Outbound authentication failed !\n",
- card->devname);
- return 0;
- }
- }
-
- /* If you are the authenticator and any one of the protocol is enabled
- * then we call the set_in_bound_authentication.
- */
- if (card->u.p.authenticator && (ppp_priv_area->pap || ppp_priv_area->chap)){
- if (ppp_set_inbnd_auth(card, ppp_priv_area)){
- printk(KERN_INFO "%s: Inbound authentication failed !\n",
- card->devname);
- return 0;
- }
- }
-
- /* If we fail to enable communications here it's OK,
- * since the DTR timer will cause a disconnected, which
- * will retrigger communication in timer_intr() */
- if (ppp_comm_enable(card) == CMD_OK) {
- wanpipe_set_state(card, WAN_CONNECTING);
- init_ppp_tx_rx_buff(card);
- }
-
- return 0;
-}
-
-/*============================================================
- * ppp_poll
- *
- * Rationale:
- * We cannot manipulate the routing tables, or
- * ip addresses withing the interrupt. Therefore
- * we must perform such actons outside an interrupt
- * at a later time.
- *
- * Description:
- * PPP polling routine, responsible for
- * shutting down interfaces upon disconnect
- * and adding/removing routes.
- *
- * Usage:
- * This function is executed for each ppp
- * interface through a tq_schedule bottom half.
- *
- * trigger_ppp_poll() function is used to kick
- * the ppp_poll routine.
- */
-static void ppp_poll(struct net_device *dev)
-{
- ppp_private_area_t *ppp_priv_area;
- sdla_t *card;
- u8 check_gateway=0;
- ppp_flags_t *flags;
-
- if (!dev || (ppp_priv_area = dev->priv) == NULL)
- return;
-
- card = ppp_priv_area->card;
- flags = card->flags;
-
- /* Shutdown is in progress, stop what you are
- * doing and get out */
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- clear_bit(POLL_CRIT,&card->wandev.critical);
- return;
- }
-
- /* if_open() function has triggered the polling routine
- * to determine the configured IP addresses. Once the
- * addresses are found, trigger the chdlc configuration */
- if (test_bit(0,&ppp_priv_area->config_ppp)){
-
- ppp_priv_area->ip_local_tmp = get_ip_address(dev,WAN_LOCAL_IP);
- ppp_priv_area->ip_remote_tmp = get_ip_address(dev,WAN_POINTOPOINT_IP);
-
- if (ppp_priv_area->ip_local_tmp == ppp_priv_area->ip_remote_tmp &&
- card->u.p.ip_mode == WANOPT_PPP_HOST){
-
- if (++ppp_priv_area->ip_error > MAX_IP_ERRORS){
- printk(KERN_INFO "\n%s: --- WARNING ---\n",
- card->devname);
- printk(KERN_INFO "%s: The local IP address is the same as the\n",
- card->devname);
- printk(KERN_INFO "%s: Point-to-Point IP address.\n",
- card->devname);
- printk(KERN_INFO "%s: --- WARNING ---\n\n",
- card->devname);
- }else{
- clear_bit(POLL_CRIT,&card->wandev.critical);
- ppp_priv_area->poll_delay_timer.expires = jiffies+HZ;
- add_timer(&ppp_priv_area->poll_delay_timer);
- return;
- }
- }
-
- ppp_priv_area->timer_int_enabled |= TMR_INT_ENABLED_CONFIG;
- flags->imask |= PPP_INTR_TIMER;
- ppp_priv_area->ip_error=0;
-
- clear_bit(0,&ppp_priv_area->config_ppp);
- clear_bit(POLL_CRIT,&card->wandev.critical);
- return;
- }
-
- /* Dynamic interface implementation, as well as dynamic
- * routing. */
-
- switch (card->wandev.state) {
-
- case WAN_DISCONNECTED:
-
- /* If the dynamic interface configuration is on, and interface
- * is up, then bring down the netowrk interface */
-
- if (test_bit(DYN_OPT_ON,&ppp_priv_area->interface_down) &&
- !test_bit(DEV_DOWN,&ppp_priv_area->interface_down) &&
- card->wandev.dev->flags & IFF_UP){
-
- printk(KERN_INFO "%s: Interface %s down.\n",
- card->devname,card->wandev.dev->name);
- change_dev_flags(card->wandev.dev,
- (card->wandev.dev->flags&~IFF_UP));
- set_bit(DEV_DOWN,&ppp_priv_area->interface_down);
- }else{
- /* We need to check if the local IP address is
- * zero. If it is, we shouldn't try to remove it.
- * For some reason the kernel crashes badly if
- * we try to remove the route twice */
-
- if (card->wandev.dev->flags & IFF_UP &&
- get_ip_address(card->wandev.dev,WAN_LOCAL_IP) &&
- card->u.p.ip_mode == WANOPT_PPP_PEER){
-
- remove_route(card);
- }
- }
- break;
-
- case WAN_CONNECTED:
-
- /* In SMP machine this code can execute before the interface
- * comes up. In this case, we must make sure that we do not
- * try to bring up the interface before dev_open() is finished */
-
-
- /* DEV_DOWN will be set only when we bring down the interface
- * for the very first time. This way we know that it was us
- * that brought the interface down */
-
- if (test_bit(DYN_OPT_ON,&ppp_priv_area->interface_down) &&
- test_bit(DEV_DOWN, &ppp_priv_area->interface_down) &&
- !(card->wandev.dev->flags & IFF_UP)){
-
- printk(KERN_INFO "%s: Interface %s up.\n",
- card->devname,card->wandev.dev->name);
-
- change_dev_flags(card->wandev.dev,(card->wandev.dev->flags|IFF_UP));
- clear_bit(DEV_DOWN,&ppp_priv_area->interface_down);
- check_gateway=1;
- }
-
- if ((card->u.p.ip_mode == WANOPT_PPP_PEER) &&
- test_bit(1,&Read_connection_info)) {
-
- process_route(card);
- clear_bit(1,&Read_connection_info);
- check_gateway=1;
- }
-
- if (ppp_priv_area->gateway && check_gateway)
- add_gateway(card,dev);
-
- break;
- }
- clear_bit(POLL_CRIT,&card->wandev.critical);
- return;
-}
-
-/*============================================================
- * trigger_ppp_poll
- *
- * Description:
- * Add a ppp_poll() task into a tq_scheduler bh handler
- * for a specific interface. This will kick
- * the ppp_poll() routine at a later time.
- *
- * Usage:
- * Interrupts use this to defer a taks to
- * a polling routine.
- *
- */
-
-static void trigger_ppp_poll(struct net_device *dev)
-{
- ppp_private_area_t *ppp_priv_area;
- if ((ppp_priv_area=dev->priv) != NULL){
-
- sdla_t *card = ppp_priv_area->card;
-
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- return;
- }
-
- if (test_and_set_bit(POLL_CRIT,&card->wandev.critical)){
- return;
- }
-
- schedule_work(&ppp_priv_area->poll_work);
- }
- return;
-}
-
-static void ppp_poll_delay (unsigned long dev_ptr)
-{
- struct net_device *dev = (struct net_device *)dev_ptr;
- trigger_ppp_poll(dev);
-}
-
-/*============================================================
- * detect_and_fix_tx_bug
- *
- * Description:
- * On connect, if the board tx buffer ptr is not the same
- * as the driver tx buffer ptr, we found a firmware bug.
- * Report the bug to the above layer. To fix the
- * error restart communications again.
- *
- * Usage:
- *
- */
-
-static int detect_and_fix_tx_bug (sdla_t *card)
-{
- if (((unsigned long)card->u.p.txbuf_base&0xFFF) != ((*card->u.p.txbuf_next)&0xFFF)){
- NEX_PRINTK(KERN_INFO "Major Error, Fix the bug\n");
- return 1;
- }
- return 0;
-}
-
-MODULE_LICENSE("GPL");
-
-/****** End *****************************************************************/
diff --git a/drivers/net/wan/sdla_x25.c b/drivers/net/wan/sdla_x25.c
deleted file mode 100644
index 63f846d6f3a6d..0000000000000
--- a/drivers/net/wan/sdla_x25.c
+++ /dev/null
@@ -1,5497 +0,0 @@
-/*****************************************************************************
-* sdla_x25.c WANPIPE(tm) Multiprotocol WAN Link Driver. X.25 module.
-*
-* Author: Nenad Corbic <ncorbic@sangoma.com>
-*
-* Copyright: (c) 1995-2001 Sangoma Technologies 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.
-* ============================================================================
-* Apr 03, 2001 Nenad Corbic o Fixed the rx_skb=NULL bug in x25 in rx_intr().
-* Dec 26, 2000 Nenad Corbic o Added a new polling routine, that uses
-* a kernel timer (more efficient).
-* Dec 25, 2000 Nenad Corbic o Updated for 2.4.X kernel
-* Jul 26, 2000 Nenad Corbic o Increased the local packet buffering
-* for API to 4096+header_size.
-* Jul 17, 2000 Nenad Corbic o Fixed the x25 startup bug. Enable
-* communications only after all interfaces
-* come up. HIGH SVC/PVC is used to calculate
-* the number of channels.
-* Enable protocol only after all interfaces
-* are enabled.
-* Jul 10, 2000 Nenad Corbic o Fixed the M_BIT bug.
-* Apr 25, 2000 Nenad Corbic o Pass Modem messages to the API.
-* Disable idle timeout in X25 API.
-* Apr 14, 2000 Nenad Corbic o Fixed: Large LCN number support.
-* Maximum LCN number is 4095.
-* Maximum number of X25 channels is 255.
-* Apr 06, 2000 Nenad Corbic o Added SMP Support.
-* Mar 29, 2000 Nenad Corbic o Added support for S514 PCI Card
-* Mar 23, 2000 Nenad Corbic o Improved task queue, BH handling.
-* Mar 14, 2000 Nenad Corbic o Updated Protocol Violation handling
-* routines. Bug Fix.
-* Mar 10, 2000 Nenad Corbic o Bug Fix: corrupted mbox recovery.
-* Mar 09, 2000 Nenad Corbic o Fixed the auto HDLC bug.
-* Mar 08, 2000 Nenad Corbic o Fixed LAPB HDLC startup problems.
-* Application must bring the link up
-* before tx/rx, and bring the
-* link down on close().
-* Mar 06, 2000 Nenad Corbic o Added an option for logging call setup
-* information.
-* Feb 29, 2000 Nenad Corbic o Added support for LAPB HDLC API
-* Feb 25, 2000 Nenad Corbic o Fixed the modem failure handling.
-* No Modem OOB message will be passed
-* to the user.
-* Feb 21, 2000 Nenad Corbic o Added Xpipemon Debug Support
-* Dec 30, 1999 Nenad Corbic o Socket based X25API
-* Sep 17, 1998 Jaspreet Singh o Updates for 2.2.X kernel
-* Mar 15, 1998 Alan Cox o 2.1.x porting
-* Dec 19, 1997 Jaspreet Singh o Added multi-channel IPX support
-* Nov 27, 1997 Jaspreet Singh o Added protection against enabling of irqs
-* when they are disabled.
-* Nov 17, 1997 Farhan Thawar o Added IPX support
-* o Changed if_send() to now buffer packets when
-* the board is busy
-* o Removed queueing of packets via the polling
-* routing
-* o Changed if_send() critical flags to properly
-* handle race conditions
-* Nov 06, 1997 Farhan Thawar o Added support for SVC timeouts
-* o Changed PVC encapsulation to ETH_P_IP
-* Jul 21, 1997 Jaspreet Singh o Fixed freeing up of buffers using kfree()
-* when packets are received.
-* Mar 11, 1997 Farhan Thawar Version 3.1.1
-* o added support for V35
-* o changed if_send() to return 0 if
-* wandev.critical() is true
-* o free socket buffer in if_send() if
-* returning 0
-* o added support for single '@' address to
-* accept all incoming calls
-* o fixed bug in set_chan_state() to disconnect
-* Jan 15, 1997 Gene Kozin Version 3.1.0
-* o implemented exec() entry point
-* Jan 07, 1997 Gene Kozin Initial version.
-*****************************************************************************/
-
-/*======================================================
- * Includes
- *=====================================================*/
-
-#include <linux/module.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/ctype.h>
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/workqueue.h>
-#include <linux/jiffies.h> /* time_after() macro */
-#include <asm/byteorder.h> /* htons(), etc. */
-#include <asm/atomic.h>
-#include <linux/delay.h> /* Experimental delay */
-
-#include <asm/uaccess.h>
-
-#include <linux/if.h>
-#include <linux/if_arp.h>
-#include <linux/sdla_x25.h> /* X.25 firmware API definitions */
-#include <linux/if_wanpipe_common.h>
-#include <linux/if_wanpipe.h>
-
-
-/*======================================================
- * Defines & Macros
- *=====================================================*/
-
-
-#define CMD_OK 0 /* normal firmware return code */
-#define CMD_TIMEOUT 0xFF /* firmware command timed out */
-#define MAX_CMD_RETRY 10 /* max number of firmware retries */
-
-#define X25_CHAN_MTU 4096 /* unfragmented logical channel MTU */
-#define X25_HRDHDR_SZ 7 /* max encapsulation header size */
-#define X25_CONCT_TMOUT (90*HZ) /* link connection timeout */
-#define X25_RECON_TMOUT (10*HZ) /* link connection timeout */
-#define CONNECT_TIMEOUT (90*HZ) /* link connection timeout */
-#define HOLD_DOWN_TIME (30*HZ) /* link hold down time */
-#define MAX_BH_BUFF 10
-#define M_BIT 0x01
-
-//#define PRINT_DEBUG 1
-#ifdef PRINT_DEBUG
-#define DBG_PRINTK(format, a...) printk(format, ## a)
-#else
-#define DBG_PRINTK(format, a...)
-#endif
-
-#define TMR_INT_ENABLED_POLL_ACTIVE 0x01
-#define TMR_INT_ENABLED_POLL_CONNECT_ON 0x02
-#define TMR_INT_ENABLED_POLL_CONNECT_OFF 0x04
-#define TMR_INT_ENABLED_POLL_DISCONNECT 0x08
-#define TMR_INT_ENABLED_CMD_EXEC 0x10
-#define TMR_INT_ENABLED_UPDATE 0x20
-#define TMR_INT_ENABLED_UDP_PKT 0x40
-
-#define MAX_X25_ADDR_SIZE 16
-#define MAX_X25_DATA_SIZE 129
-#define MAX_X25_FACL_SIZE 110
-
-#define TRY_CMD_AGAIN 2
-#define DELAY_RESULT 1
-#define RETURN_RESULT 0
-
-#define DCD(x) (x & 0x03 ? "HIGH" : "LOW")
-#define CTS(x) (x & 0x05 ? "HIGH" : "LOW")
-
-
-/* Driver will not write log messages about
- * modem status if defined.*/
-#define MODEM_NOT_LOG 1
-
-/*====================================================
- * For IPXWAN
- *===================================================*/
-
-#define CVHexToAscii(b) (((unsigned char)(b) > (unsigned char)9) ? ((unsigned char)'A' + ((unsigned char)(b) - (unsigned char)10)) : ((unsigned char)'0' + (unsigned char)(b)))
-
-
-/*====================================================
- * MEMORY DEBUGGING FUNCTION
- *====================================================
-
-#define KMEM_SAFETYZONE 8
-
-static void * dbg_kmalloc(unsigned int size, int prio, int line) {
- int i = 0;
- void * v = kmalloc(size+sizeof(unsigned int)+2*KMEM_SAFETYZONE*8,prio);
- char * c1 = v;
- c1 += sizeof(unsigned int);
- *((unsigned int *)v) = size;
-
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- c1[0] = 'D'; c1[1] = 'E'; c1[2] = 'A'; c1[3] = 'D';
- c1[4] = 'B'; c1[5] = 'E'; c1[6] = 'E'; c1[7] = 'F';
- c1 += 8;
- }
- c1 += size;
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- c1[0] = 'M'; c1[1] = 'U'; c1[2] = 'N'; c1[3] = 'G';
- c1[4] = 'W'; c1[5] = 'A'; c1[6] = 'L'; c1[7] = 'L';
- c1 += 8;
- }
- v = ((char *)v) + sizeof(unsigned int) + KMEM_SAFETYZONE*8;
- printk(KERN_INFO "line %d kmalloc(%d,%d) = %p\n",line,size,prio,v);
- return v;
-}
-static void dbg_kfree(void * v, int line) {
- unsigned int * sp = (unsigned int *)(((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8));
- unsigned int size = *sp;
- char * c1 = ((char *)v) - KMEM_SAFETYZONE*8;
- int i = 0;
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- if ( c1[0] != 'D' || c1[1] != 'E' || c1[2] != 'A' || c1[3] != 'D'
- || c1[4] != 'B' || c1[5] != 'E' || c1[6] != 'E' || c1[7] != 'F') {
- printk(KERN_INFO "kmalloced block at %p has been corrupted (underrun)!\n",v);
- printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
- c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
- }
- c1 += 8;
- }
- c1 += size;
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- if ( c1[0] != 'M' || c1[1] != 'U' || c1[2] != 'N' || c1[3] != 'G'
- || c1[4] != 'W' || c1[5] != 'A' || c1[6] != 'L' || c1[7] != 'L'
- ) {
- printk(KERN_INFO "kmalloced block at %p has been corrupted (overrun):\n",v);
- printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
- c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
- }
- c1 += 8;
- }
- printk(KERN_INFO "line %d kfree(%p)\n",line,v);
- v = ((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8);
- kfree(v);
-}
-
-#define kmalloc(x,y) dbg_kmalloc(x,y,__LINE__)
-#define kfree(x) dbg_kfree(x,__LINE__)
-
-==============================================================*/
-
-
-
-/*===============================================
- * Data Structures
- *===============================================*/
-
-
-/*========================================================
- * Name: x25_channel
- *
- * Purpose: To hold private informaton for each
- * logical channel.
- *
- * Rationale: Per-channel debugging is possible if each
- * channel has its own private area.
- *
- * Assumptions:
- *
- * Description: This is an extention of the struct net_device
- * we create for each network interface to keep
- * the rest of X.25 channel-specific data.
- *
- * Construct: Typedef
- */
-typedef struct x25_channel
-{
- wanpipe_common_t common; /* common area for x25api and socket */
- char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */
- char addr[WAN_ADDRESS_SZ+1]; /* media address, ASCIIZ */
- unsigned tx_pkt_size;
- unsigned short protocol; /* ethertype, 0 - multiplexed */
- char drop_sequence; /* mark sequence for dropping */
- unsigned long state_tick; /* time of the last state change */
- unsigned idle_timeout; /* sec, before disconnecting */
- unsigned long i_timeout_sofar; /* # of sec's we've been idle */
- unsigned hold_timeout; /* sec, before re-connecting */
- unsigned long tick_counter; /* counter for transmit time out */
- char devtint; /* Weather we should dev_tint() */
- struct sk_buff* rx_skb; /* receive socket buffer */
- struct sk_buff* tx_skb; /* transmit socket buffer */
-
- bh_data_t *bh_head; /* Circular buffer for x25api_bh */
- unsigned long tq_working;
- volatile int bh_write;
- volatile int bh_read;
- atomic_t bh_buff_used;
-
- sdla_t* card; /* -> owner */
- struct net_device *dev; /* -> bound devce */
-
- int ch_idx;
- unsigned char enable_IPX;
- unsigned long network_number;
- struct net_device_stats ifstats; /* interface statistics */
- unsigned short transmit_length;
- unsigned short tx_offset;
- char transmit_buffer[X25_CHAN_MTU+sizeof(x25api_hdr_t)];
-
- if_send_stat_t if_send_stat;
- rx_intr_stat_t rx_intr_stat;
- pipe_mgmt_stat_t pipe_mgmt_stat;
-
- unsigned long router_start_time; /* Router start time in seconds */
- unsigned long router_up_time;
-
-} x25_channel_t;
-
-/* FIXME Take this out */
-
-#ifdef NEX_OLD_CALL_INFO
-typedef struct x25_call_info
-{
- char dest[17]; PACKED;/* ASCIIZ destination address */
- char src[17]; PACKED;/* ASCIIZ source address */
- char nuser; PACKED;/* number of user data bytes */
- unsigned char user[127]; PACKED;/* user data */
- char nfacil; PACKED;/* number of facilities */
- struct
- {
- unsigned char code; PACKED;
- unsigned char parm; PACKED;
- } facil[64]; /* facilities */
-} x25_call_info_t;
-#else
-typedef struct x25_call_info
-{
- char dest[MAX_X25_ADDR_SIZE] PACKED;/* ASCIIZ destination address */
- char src[MAX_X25_ADDR_SIZE] PACKED;/* ASCIIZ source address */
- unsigned char nuser PACKED;
- unsigned char user[MAX_X25_DATA_SIZE] PACKED;/* user data */
- unsigned char nfacil PACKED;
- unsigned char facil[MAX_X25_FACL_SIZE] PACKED;
- unsigned short lcn PACKED;
-} x25_call_info_t;
-#endif
-
-
-
-/*===============================================
- * Private Function Prototypes
- *==============================================*/
-
-
-/*=================================================
- * WAN link driver entry points. These are
- * called by the WAN router module.
- */
-static int update(struct wan_device* wandev);
-static int new_if(struct wan_device* wandev, struct net_device* dev,
- wanif_conf_t* conf);
-static int del_if(struct wan_device* wandev, struct net_device* dev);
-static void disable_comm (sdla_t* card);
-static void disable_comm_shutdown(sdla_t *card);
-
-
-
-/*=================================================
- * WANPIPE-specific entry points
- */
-static int wpx_exec (struct sdla* card, void* u_cmd, void* u_data);
-static void x25api_bh(struct net_device *dev);
-static int x25api_bh_cleanup(struct net_device *dev);
-static int bh_enqueue(struct net_device *dev, struct sk_buff *skb);
-
-
-/*=================================================
- * Network device interface
- */
-static int if_init(struct net_device* dev);
-static int if_open(struct net_device* dev);
-static int if_close(struct net_device* dev);
-static int if_header(struct sk_buff* skb, struct net_device* dev,
- unsigned short type, void* daddr, void* saddr, unsigned len);
-static int if_rebuild_hdr (struct sk_buff* skb);
-static int if_send(struct sk_buff* skb, struct net_device* dev);
-static struct net_device_stats *if_stats(struct net_device* dev);
-
-static void if_tx_timeout(struct net_device *dev);
-
-/*=================================================
- * Interrupt handlers
- */
-static void wpx_isr (sdla_t *);
-static void rx_intr (sdla_t *);
-static void tx_intr (sdla_t *);
-static void status_intr (sdla_t *);
-static void event_intr (sdla_t *);
-static void spur_intr (sdla_t *);
-static void timer_intr (sdla_t *);
-
-static int tx_intr_send(sdla_t *card, struct net_device *dev);
-static struct net_device *move_dev_to_next(sdla_t *card,
- struct net_device *dev);
-
-/*=================================================
- * Background polling routines
- */
-static void wpx_poll (sdla_t* card);
-static void poll_disconnected (sdla_t* card);
-static void poll_connecting (sdla_t* card);
-static void poll_active (sdla_t* card);
-static void trigger_x25_poll(sdla_t *card);
-static void x25_timer_routine(unsigned long data);
-
-
-
-/*=================================================
- * X.25 firmware interface functions
- */
-static int x25_get_version (sdla_t* card, char* str);
-static int x25_configure (sdla_t* card, TX25Config* conf);
-static int hdlc_configure (sdla_t* card, TX25Config* conf);
-static int set_hdlc_level (sdla_t* card);
-static int x25_get_err_stats (sdla_t* card);
-static int x25_get_stats (sdla_t* card);
-static int x25_set_intr_mode (sdla_t* card, int mode);
-static int x25_close_hdlc (sdla_t* card);
-static int x25_open_hdlc (sdla_t* card);
-static int x25_setup_hdlc (sdla_t* card);
-static int x25_set_dtr (sdla_t* card, int dtr);
-static int x25_get_chan_conf (sdla_t* card, x25_channel_t* chan);
-static int x25_place_call (sdla_t* card, x25_channel_t* chan);
-static int x25_accept_call (sdla_t* card, int lcn, int qdm);
-static int x25_clear_call (sdla_t* card, int lcn, int cause, int diagn);
-static int x25_send (sdla_t* card, int lcn, int qdm, int len, void* buf);
-static int x25_fetch_events (sdla_t* card);
-static int x25_error (sdla_t* card, int err, int cmd, int lcn);
-
-/*=================================================
- * X.25 asynchronous event handlers
- */
-static int incoming_call (sdla_t* card, int cmd, int lcn, TX25Mbox* mb);
-static int call_accepted (sdla_t* card, int cmd, int lcn, TX25Mbox* mb);
-static int call_cleared (sdla_t* card, int cmd, int lcn, TX25Mbox* mb);
-static int timeout_event (sdla_t* card, int cmd, int lcn, TX25Mbox* mb);
-static int restart_event (sdla_t* card, int cmd, int lcn, TX25Mbox* mb);
-
-
-/*=================================================
- * Miscellaneous functions
- */
-static int connect (sdla_t* card);
-static int disconnect (sdla_t* card);
-static struct net_device* get_dev_by_lcn(struct wan_device* wandev,
- unsigned lcn);
-static int chan_connect(struct net_device* dev);
-static int chan_disc(struct net_device* dev);
-static void set_chan_state(struct net_device* dev, int state);
-static int chan_send(struct net_device *dev, void* buff, unsigned data_len,
- unsigned char tx_intr);
-static unsigned char bps_to_speed_code (unsigned long bps);
-static unsigned int dec_to_uint (unsigned char* str, int len);
-static unsigned int hex_to_uint (unsigned char*, int);
-static void parse_call_info (unsigned char*, x25_call_info_t*);
-static struct net_device *find_channel(sdla_t *card, unsigned lcn);
-static void bind_lcn_to_dev(sdla_t *card, struct net_device *dev, unsigned lcn);
-static void setup_for_delayed_transmit(struct net_device *dev,
- void *buf, unsigned len);
-
-
-/*=================================================
- * X25 API Functions
- */
-static int wanpipe_pull_data_in_skb(sdla_t *card, struct net_device *dev,
- struct sk_buff **);
-static void timer_intr_exec(sdla_t *, unsigned char);
-static int execute_delayed_cmd(sdla_t *card, struct net_device *dev,
- mbox_cmd_t *usr_cmd, char bad_cmd);
-static int api_incoming_call (sdla_t*, TX25Mbox *, int);
-static int alloc_and_init_skb_buf (sdla_t *,struct sk_buff **, int);
-static void send_delayed_cmd_result(sdla_t *card, struct net_device *dev,
- TX25Mbox* mbox);
-static int clear_confirm_event (sdla_t *, TX25Mbox*);
-static void send_oob_msg (sdla_t *card, struct net_device *dev, TX25Mbox *mbox);
-static int timer_intr_cmd_exec(sdla_t *card);
-static void api_oob_event (sdla_t *card,TX25Mbox *mbox);
-static int check_bad_command(sdla_t *card, struct net_device *dev);
-static int channel_disconnect(sdla_t* card, struct net_device *dev);
-static void hdlc_link_down (sdla_t*);
-
-/*=================================================
- * XPIPEMON Functions
- */
-static int process_udp_mgmt_pkt(sdla_t *);
-static int udp_pkt_type( struct sk_buff *, sdla_t*);
-static int reply_udp( unsigned char *, unsigned int);
-static void init_x25_channel_struct( x25_channel_t *);
-static void init_global_statistics( sdla_t *);
-static int store_udp_mgmt_pkt(int udp_type, char udp_pkt_src, sdla_t *card,
- struct net_device *dev,
- struct sk_buff *skb, int lcn);
-static unsigned short calc_checksum (char *, int);
-
-
-
-/*=================================================
- * IPX functions
- */
-static void switch_net_numbers(unsigned char *, unsigned long, unsigned char);
-static int handle_IPXWAN(unsigned char *, char *, unsigned char ,
- unsigned long , unsigned short );
-
-extern void disable_irq(unsigned int);
-extern void enable_irq(unsigned int);
-
-static void S508_S514_lock(sdla_t *, unsigned long *);
-static void S508_S514_unlock(sdla_t *, unsigned long *);
-
-
-/*=================================================
- * Global Variables
- *=================================================*/
-
-
-
-/*=================================================
- * Public Functions
- *=================================================*/
-
-
-
-
-/*===================================================================
- * wpx_init: X.25 Protocol Initialization routine.
- *
- * Purpose: To initialize the protocol/firmware.
- *
- * Rationale: This function is called by setup() function, in
- * sdlamain.c, to dynamically setup the x25 protocol.
- * This is the first protocol specific function, which
- * executes once on startup.
- *
- * Description: This procedure initializes the x25 firmware and
- * sets up the mailbox, transmit and receive buffer
- * pointers. It also initializes all debugging structures
- * and sets up the X25 environment.
- *
- * Sets up hardware options defined by user in [wanpipe#]
- * section of wanpipe#.conf configuration file.
- *
- * At this point adapter is completely initialized
- * and X.25 firmware is running.
- * o read firmware version (to make sure it's alive)
- * o configure adapter
- * o initialize protocol-specific fields of the
- * adapter data space.
- *
- * Called by: setup() function in sdlamain.c
- *
- * Assumptions: None
- *
- * Warnings: None
- *
- * Return: 0 o.k.
- * < 0 failure.
- */
-
-int wpx_init (sdla_t* card, wandev_conf_t* conf)
-{
- union{
- char str[80];
- TX25Config cfg;
- } u;
-
- /* Verify configuration ID */
- if (conf->config_id != WANCONFIG_X25){
- printk(KERN_INFO "%s: invalid configuration ID %u!\n",
- card->devname, conf->config_id)
- ;
- return -EINVAL;
- }
-
- /* Initialize protocol-specific fields */
- card->mbox = (void*)(card->hw.dpmbase + X25_MBOX_OFFS);
- card->rxmb = (void*)(card->hw.dpmbase + X25_RXMBOX_OFFS);
- card->flags = (void*)(card->hw.dpmbase + X25_STATUS_OFFS);
-
- /* Initialize for S514 Card */
- if(card->hw.type == SDLA_S514) {
- card->mbox += X25_MB_VECTOR;
- card->flags += X25_MB_VECTOR;
- card->rxmb += X25_MB_VECTOR;
- }
-
-
- /* Read firmware version. Note that when adapter initializes, it
- * clears the mailbox, so it may appear that the first command was
- * executed successfully when in fact it was merely erased. To work
- * around this, we execute the first command twice.
- */
- if (x25_get_version(card, NULL) || x25_get_version(card, u.str))
- return -EIO;
-
-
- /* X25 firmware can run ether in X25 or LAPB HDLC mode.
- * Check the user defined option and configure accordingly */
- if (conf->u.x25.LAPB_hdlc_only == WANOPT_YES){
- if (set_hdlc_level(card) != CMD_OK){
- return -EIO;
- }else{
- printk(KERN_INFO "%s: running LAP_B HDLC firmware v%s\n",
- card->devname, u.str);
- }
- card->u.x.LAPB_hdlc = 1;
- }else{
- printk(KERN_INFO "%s: running X.25 firmware v%s\n",
- card->devname, u.str);
- card->u.x.LAPB_hdlc = 0;
- }
-
- /* Configure adapter. Here we set resonable defaults, then parse
- * device configuration structure and set configuration options.
- * Most configuration options are verified and corrected (if
- * necessary) since we can't rely on the adapter to do so.
- */
- memset(&u.cfg, 0, sizeof(u.cfg));
- u.cfg.t1 = 3;
- u.cfg.n2 = 10;
- u.cfg.autoHdlc = 1; /* automatic HDLC connection */
- u.cfg.hdlcWindow = 7;
- u.cfg.pktWindow = 2;
- u.cfg.station = 1; /* DTE */
- u.cfg.options = 0x0090; /* disable D-bit pragmatics */
- u.cfg.ccittCompat = 1988;
- u.cfg.t10t20 = 30;
- u.cfg.t11t21 = 30;
- u.cfg.t12t22 = 30;
- u.cfg.t13t23 = 30;
- u.cfg.t16t26 = 30;
- u.cfg.t28 = 30;
- u.cfg.r10r20 = 5;
- u.cfg.r12r22 = 5;
- u.cfg.r13r23 = 5;
- u.cfg.responseOpt = 1; /* RR's after every packet */
-
- if (card->u.x.LAPB_hdlc){
- u.cfg.hdlcMTU = 1027;
- }
-
- if (conf->u.x25.x25_conf_opt){
- u.cfg.options = conf->u.x25.x25_conf_opt;
- }
-
- if (conf->clocking != WANOPT_EXTERNAL)
- u.cfg.baudRate = bps_to_speed_code(conf->bps);
-
- if (conf->station != WANOPT_DTE){
- u.cfg.station = 0; /* DCE mode */
- }
-
- if (conf->interface != WANOPT_RS232 ){
- u.cfg.hdlcOptions |= 0x80; /* V35 mode */
- }
-
- /* adjust MTU */
- if (!conf->mtu || (conf->mtu >= 1024))
- card->wandev.mtu = 1024;
- else if (conf->mtu >= 512)
- card->wandev.mtu = 512;
- else if (conf->mtu >= 256)
- card->wandev.mtu = 256;
- else if (conf->mtu >= 128)
- card->wandev.mtu = 128;
- else
- card->wandev.mtu = 64;
-
- u.cfg.defPktSize = u.cfg.pktMTU = card->wandev.mtu;
-
- if (conf->u.x25.hi_pvc){
- card->u.x.hi_pvc = min_t(unsigned int, conf->u.x25.hi_pvc, MAX_LCN_NUM);
- card->u.x.lo_pvc = min_t(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc);
- }
-
- if (conf->u.x25.hi_svc){
- card->u.x.hi_svc = min_t(unsigned int, conf->u.x25.hi_svc, MAX_LCN_NUM);
- card->u.x.lo_svc = min_t(unsigned int, conf->u.x25.lo_svc, card->u.x.hi_svc);
- }
-
- /* Figure out the total number of channels to configure */
- card->u.x.num_of_ch = 0;
- if (card->u.x.hi_svc != 0){
- card->u.x.num_of_ch = (card->u.x.hi_svc - card->u.x.lo_svc) + 1;
- }
- if (card->u.x.hi_pvc != 0){
- card->u.x.num_of_ch += (card->u.x.hi_pvc - card->u.x.lo_pvc) + 1;
- }
-
- if (card->u.x.num_of_ch == 0){
- printk(KERN_INFO "%s: ERROR, Minimum number of PVC/SVC channels is 1 !\n"
- "%s: Please set the Lowest/Highest PVC/SVC values !\n",
- card->devname,card->devname);
- return -ECHRNG;
- }
-
- u.cfg.loPVC = card->u.x.lo_pvc;
- u.cfg.hiPVC = card->u.x.hi_pvc;
- u.cfg.loTwoWaySVC = card->u.x.lo_svc;
- u.cfg.hiTwoWaySVC = card->u.x.hi_svc;
-
- if (conf->u.x25.hdlc_window)
- u.cfg.hdlcWindow = min_t(unsigned int, conf->u.x25.hdlc_window, 7);
- if (conf->u.x25.pkt_window)
- u.cfg.pktWindow = min_t(unsigned int, conf->u.x25.pkt_window, 7);
-
- if (conf->u.x25.t1)
- u.cfg.t1 = min_t(unsigned int, conf->u.x25.t1, 30);
- if (conf->u.x25.t2)
- u.cfg.t2 = min_t(unsigned int, conf->u.x25.t2, 29);
- if (conf->u.x25.t4)
- u.cfg.t4 = min_t(unsigned int, conf->u.x25.t4, 240);
- if (conf->u.x25.n2)
- u.cfg.n2 = min_t(unsigned int, conf->u.x25.n2, 30);
-
- if (conf->u.x25.t10_t20)
- u.cfg.t10t20 = min_t(unsigned int, conf->u.x25.t10_t20,255);
- if (conf->u.x25.t11_t21)
- u.cfg.t11t21 = min_t(unsigned int, conf->u.x25.t11_t21,255);
- if (conf->u.x25.t12_t22)
- u.cfg.t12t22 = min_t(unsigned int, conf->u.x25.t12_t22,255);
- if (conf->u.x25.t13_t23)
- u.cfg.t13t23 = min_t(unsigned int, conf->u.x25.t13_t23,255);
- if (conf->u.x25.t16_t26)
- u.cfg.t16t26 = min_t(unsigned int, conf->u.x25.t16_t26, 255);
- if (conf->u.x25.t28)
- u.cfg.t28 = min_t(unsigned int, conf->u.x25.t28, 255);
-
- if (conf->u.x25.r10_r20)
- u.cfg.r10r20 = min_t(unsigned int, conf->u.x25.r10_r20,250);
- if (conf->u.x25.r12_r22)
- u.cfg.r12r22 = min_t(unsigned int, conf->u.x25.r12_r22,250);
- if (conf->u.x25.r13_r23)
- u.cfg.r13r23 = min_t(unsigned int, conf->u.x25.r13_r23,250);
-
-
- if (conf->u.x25.ccitt_compat)
- u.cfg.ccittCompat = conf->u.x25.ccitt_compat;
-
- /* initialize adapter */
- if (card->u.x.LAPB_hdlc){
- if (hdlc_configure(card, &u.cfg) != CMD_OK)
- return -EIO;
- }else{
- if (x25_configure(card, &u.cfg) != CMD_OK)
- return -EIO;
- }
-
- if ((x25_close_hdlc(card) != CMD_OK) || /* close HDLC link */
- (x25_set_dtr(card, 0) != CMD_OK)) /* drop DTR */
- return -EIO;
-
- /* Initialize protocol-specific fields of adapter data space */
- card->wandev.bps = conf->bps;
- card->wandev.interface = conf->interface;
- card->wandev.clocking = conf->clocking;
- card->wandev.station = conf->station;
- card->isr = &wpx_isr;
- card->poll = NULL; //&wpx_poll;
- card->disable_comm = &disable_comm;
- card->exec = &wpx_exec;
- card->wandev.update = &update;
- card->wandev.new_if = &new_if;
- card->wandev.del_if = &del_if;
-
- /* WARNING: This function cannot exit with an error
- * after the change of state */
- card->wandev.state = WAN_DISCONNECTED;
-
- card->wandev.enable_tx_int = 0;
- card->irq_dis_if_send_count = 0;
- card->irq_dis_poll_count = 0;
- card->u.x.tx_dev = NULL;
- card->u.x.no_dev = 0;
-
-
- /* Configure for S514 PCI Card */
- if (card->hw.type == SDLA_S514) {
- card->u.x.hdlc_buf_status =
- (volatile unsigned char *)
- (card->hw.dpmbase + X25_MB_VECTOR+ X25_MISC_HDLC_BITS);
- }else{
- card->u.x.hdlc_buf_status =
- (volatile unsigned char *)(card->hw.dpmbase + X25_MISC_HDLC_BITS);
- }
-
- card->u.x.poll_device=NULL;
- card->wandev.udp_port = conf->udp_port;
-
- /* Enable or disable call setup logging */
- if (conf->u.x25.logging == WANOPT_YES){
- printk(KERN_INFO "%s: Enabling Call Logging.\n",
- card->devname);
- card->u.x.logging = 1;
- }else{
- card->u.x.logging = 0;
- }
-
- /* Enable or disable modem status reporting */
- if (conf->u.x25.oob_on_modem == WANOPT_YES){
- printk(KERN_INFO "%s: Enabling OOB on Modem change.\n",
- card->devname);
- card->u.x.oob_on_modem = 1;
- }else{
- card->u.x.oob_on_modem = 0;
- }
-
- init_global_statistics(card);
-
- INIT_WORK(&card->u.x.x25_poll_work, (void *)wpx_poll, card);
-
- init_timer(&card->u.x.x25_timer);
- card->u.x.x25_timer.data = (unsigned long)card;
- card->u.x.x25_timer.function = x25_timer_routine;
-
- return 0;
-}
-
-/*=========================================================
- * WAN Device Driver Entry Points
- *========================================================*/
-
-/*============================================================
- * Name: update(), Update device status & statistics.
- *
- * Purpose: To provide debugging and statitical
- * information to the /proc file system.
- * /proc/net/wanrouter/wanpipe#
- *
- * Rationale: The /proc file system is used to collect
- * information about the kernel and drivers.
- * Using the /proc file system the user
- * can see exactly what the sangoma drivers are
- * doing. And in what state they are in.
- *
- * Description: Collect all driver statistical information
- * and pass it to the top laywer.
- *
- * Since we have to execute a debugging command,
- * to obtain firmware statitics, we trigger a
- * UPDATE function within the timer interrtup.
- * We wait until the timer update is complete.
- * Once complete return the appropriate return
- * code to indicate that the update was successful.
- *
- * Called by: device_stat() in wanmain.c
- *
- * Assumptions:
- *
- * Warnings: This function will degrade the performance
- * of the router, since it uses the mailbox.
- *
- * Return: 0 OK
- * <0 Failed (or busy).
- */
-
-static int update(struct wan_device* wandev)
-{
- volatile sdla_t* card;
- TX25Status* status;
- unsigned long timeout;
-
- /* sanity checks */
- if ((wandev == NULL) || (wandev->private == NULL))
- return -EFAULT;
-
- if (wandev->state == WAN_UNCONFIGURED)
- return -ENODEV;
-
- if (test_bit(SEND_CRIT, (void*)&wandev->critical))
- return -EAGAIN;
-
- if (!wandev->dev)
- return -ENODEV;
-
- card = wandev->private;
- status = card->flags;
-
- card->u.x.timer_int_enabled |= TMR_INT_ENABLED_UPDATE;
- status->imask |= INTR_ON_TIMER;
- timeout = jiffies;
-
- for (;;){
- if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE)){
- break;
- }
- if (time_after(jiffies, timeout + 1*HZ)){
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE;
- return -EAGAIN;
- }
- }
- return 0;
-}
-
-
-/*===================================================================
- * Name: new_if
- *
- * Purpose: To allocate and initialize resources for a
- * new logical channel.
- *
- * Rationale: A new channel can be added dynamically via
- * ioctl call.
- *
- * Description: Allocate a private channel structure, x25_channel_t.
- * Parse the user interface options from wanpipe#.conf
- * configuration file.
- * Bind the private are into the network device private
- * area pointer (dev->priv).
- * Prepare the network device structure for registration.
- *
- * Called by: ROUTER_IFNEW Ioctl call, from wanrouter_ioctl()
- * (wanmain.c)
- *
- * Assumptions: None
- *
- * Warnings: None
- *
- * Return: 0 Ok
- * <0 Failed (channel will not be created)
- */
-static int new_if(struct wan_device* wandev, struct net_device* dev,
- wanif_conf_t* conf)
-{
- sdla_t* card = wandev->private;
- x25_channel_t* chan;
- int err = 0;
-
- if ((conf->name[0] == '\0') || (strlen(conf->name) > WAN_IFNAME_SZ)){
- printk(KERN_INFO "%s: invalid interface name!\n",
- card->devname);
- return -EINVAL;
- }
-
- if(card->wandev.new_if_cnt++ > 0 && card->u.x.LAPB_hdlc) {
- printk(KERN_INFO "%s: Error: Running LAPB HDLC Mode !\n",
- card->devname);
- printk(KERN_INFO
- "%s: Maximum number of network interfaces must be one !\n",
- card->devname);
- return -EEXIST;
- }
-
- /* allocate and initialize private data */
- chan = kmalloc(sizeof(x25_channel_t), GFP_ATOMIC);
- if (chan == NULL){
- return -ENOMEM;
- }
-
- memset(chan, 0, sizeof(x25_channel_t));
-
- /* Bug Fix: Seg Err on PVC startup
- * It must be here since bind_lcn_to_dev expects
- * it bellow */
- dev->priv = chan;
-
- strcpy(chan->name, conf->name);
- chan->card = card;
- chan->dev = dev;
- chan->common.sk = NULL;
- chan->common.func = NULL;
- chan->common.rw_bind = 0;
- chan->tx_skb = chan->rx_skb = NULL;
-
- /* verify media address */
- if (conf->addr[0] == '@'){ /* SVC */
- chan->common.svc = 1;
- strncpy(chan->addr, &conf->addr[1], WAN_ADDRESS_SZ);
-
- /* Set channel timeouts (default if not specified) */
- chan->idle_timeout = (conf->idle_timeout) ?
- conf->idle_timeout : 90;
- chan->hold_timeout = (conf->hold_timeout) ?
- conf->hold_timeout : 10;
-
- }else if (isdigit(conf->addr[0])){ /* PVC */
- int lcn = dec_to_uint(conf->addr, 0);
-
- if ((lcn >= card->u.x.lo_pvc) && (lcn <= card->u.x.hi_pvc)){
- bind_lcn_to_dev (card, dev, lcn);
- }else{
- printk(KERN_ERR
- "%s: PVC %u is out of range on interface %s!\n",
- wandev->name, lcn, chan->name);
- err = -EINVAL;
- }
- }else{
- printk(KERN_ERR
- "%s: invalid media address on interface %s!\n",
- wandev->name, chan->name);
- err = -EINVAL;
- }
-
- if(strcmp(conf->usedby, "WANPIPE") == 0){
- printk(KERN_INFO "%s: Running in WANPIPE mode %s\n",
- wandev->name, chan->name);
- chan->common.usedby = WANPIPE;
- chan->protocol = htons(ETH_P_IP);
-
- }else if(strcmp(conf->usedby, "API") == 0){
- chan->common.usedby = API;
- printk(KERN_INFO "%s: Running in API mode %s\n",
- wandev->name, chan->name);
- chan->protocol = htons(X25_PROT);
- }
-
-
- if (err){
- kfree(chan);
- dev->priv = NULL;
- return err;
- }
-
- chan->enable_IPX = conf->enable_IPX;
-
- if (chan->enable_IPX)
- chan->protocol = htons(ETH_P_IPX);
-
- if (conf->network_number)
- chan->network_number = conf->network_number;
- else
- chan->network_number = 0xDEADBEEF;
-
- /* prepare network device data space for registration */
- strcpy(dev->name,chan->name);
-
- dev->init = &if_init;
-
- init_x25_channel_struct(chan);
-
- return 0;
-}
-
-/*===================================================================
- * Name: del_if(), Remove a logical channel.
- *
- * Purpose: To dynamically remove a logical channel.
- *
- * Rationale: Each logical channel should be dynamically
- * removable. This functin is called by an
- * IOCTL_IFDEL ioctl call or shutdown().
- *
- * Description: Do nothing.
- *
- * Called by: IOCTL_IFDEL : wanrouter_ioctl() from wanmain.c
- * shutdown() from sdlamain.c
- *
- * Assumptions:
- *
- * Warnings:
- *
- * Return: 0 Ok. Void function.
- */
-
-//FIXME Del IF Should be taken out now.
-
-static int del_if(struct wan_device* wandev, struct net_device* dev)
-{
- return 0;
-}
-
-
-/*============================================================
- * Name: wpx_exec
- *
- * Description: Execute adapter interface command.
- * This option is currently dissabled.
- *===========================================================*/
-
-static int wpx_exec (struct sdla* card, void* u_cmd, void* u_data)
-{
- return 0;
-}
-
-/*============================================================
- * Name: disable_comm
- *
- * Description: Disable communications during shutdown.
- * Dont check return code because there is
- * nothing we can do about it.
- *
- * Warning: Dev and private areas are gone at this point.
- *===========================================================*/
-
-static void disable_comm(sdla_t* card)
-{
- disable_comm_shutdown(card);
- del_timer(&card->u.x.x25_timer);
- return;
-}
-
-
-/*============================================================
- * Network Device Interface
- *===========================================================*/
-
-/*===================================================================
- * Name: if_init(), Netowrk Interface Initialization
- *
- * Purpose: To initialize a network interface device structure.
- *
- * Rationale: During network interface startup, the if_init
- * is called by the kernel to initialize the
- * netowrk device structure. Thus a driver
- * can customze a network device.
- *
- * Description: Initialize the netowrk device call back
- * routines. This is where we tell the kernel
- * which function to use when it wants to send
- * via our interface.
- * Furthermore, we initialize the device flags,
- * MTU and physical address of the board.
- *
- * Called by: Kernel (/usr/src/linux/net/core/dev.c)
- * (dev->init())
- *
- * Assumptions: None
- *
- * Warnings: None
- *
- * Return: 0 Ok : Void function.
- */
-static int if_init(struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- struct wan_device* wandev = &card->wandev;
-
- /* Initialize device driver entry points */
- dev->open = &if_open;
- dev->stop = &if_close;
- dev->hard_header = &if_header;
- dev->rebuild_header = &if_rebuild_hdr;
- dev->hard_start_xmit = &if_send;
- dev->get_stats = &if_stats;
- dev->tx_timeout = &if_tx_timeout;
- dev->watchdog_timeo = TX_TIMEOUT;
-
- /* Initialize media-specific parameters */
- dev->type = ARPHRD_PPP; /* ARP h/w type */
- dev->flags |= IFF_POINTOPOINT;
- dev->flags |= IFF_NOARP;
-
- if (chan->common.usedby == API){
- dev->mtu = X25_CHAN_MTU+sizeof(x25api_hdr_t);
- }else{
- dev->mtu = card->wandev.mtu;
- }
-
- dev->hard_header_len = X25_HRDHDR_SZ; /* media header length */
- dev->addr_len = 2; /* hardware address length */
-
- if (!chan->common.svc){
- *(unsigned short*)dev->dev_addr = htons(chan->common.lcn);
- }
-
- /* Initialize hardware parameters (just for reference) */
- dev->irq = wandev->irq;
- dev->dma = wandev->dma;
- dev->base_addr = wandev->ioport;
- dev->mem_start = (unsigned long)wandev->maddr;
- dev->mem_end = wandev->maddr + wandev->msize - 1;
-
- /* Set transmit buffer queue length */
- dev->tx_queue_len = 100;
- SET_MODULE_OWNER(dev);
-
- /* FIXME Why are we doing this */
- set_chan_state(dev, WAN_DISCONNECTED);
- return 0;
-}
-
-
-/*===================================================================
- * Name: if_open(), Open/Bring up the Netowrk Interface
- *
- * Purpose: To bring up a network interface.
- *
- * Rationale:
- *
- * Description: Open network interface.
- * o prevent module from unloading by incrementing use count
- * o if link is disconnected then initiate connection
- *
- * Called by: Kernel (/usr/src/linux/net/core/dev.c)
- * (dev->open())
- *
- * Assumptions: None
- *
- * Warnings: None
- *
- * Return: 0 Ok
- * <0 Failure: Interface will not come up.
- */
-
-static int if_open(struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- struct timeval tv;
- unsigned long smp_flags;
-
- if (netif_running(dev))
- return -EBUSY;
-
- chan->tq_working = 0;
-
- /* Initialize the workqueue */
- INIT_WORK(&chan->common.wanpipe_work, (void *)x25api_bh, dev);
-
- /* Allocate and initialize BH circular buffer */
- /* Add 1 to MAX_BH_BUFF so we don't have test with (MAX_BH_BUFF-1) */
- chan->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
-
- if (chan->bh_head == NULL){
- printk(KERN_INFO "%s: ERROR, failed to allocate memory ! BH_BUFFERS !\n",
- card->devname);
-
- return -ENOBUFS;
- }
- memset(chan->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1)));
- atomic_set(&chan->bh_buff_used, 0);
-
- /* Increment the number of interfaces */
- ++card->u.x.no_dev;
-
- wanpipe_open(card);
-
- /* LAPB protocol only uses one interface, thus
- * start the protocol after it comes up. */
- if (card->u.x.LAPB_hdlc){
- if (card->open_cnt == 1){
- TX25Status* status = card->flags;
- S508_S514_lock(card, &smp_flags);
- x25_set_intr_mode(card, INTR_ON_TIMER);
- status->imask &= ~INTR_ON_TIMER;
- S508_S514_unlock(card, &smp_flags);
- }
- }else{
- /* X25 can have multiple interfaces thus, start the
- * protocol once all interfaces are up */
-
- //FIXME: There is a bug here. If interface is
- //brought down and up, it will try to enable comm.
- if (card->open_cnt == card->u.x.num_of_ch){
-
- S508_S514_lock(card, &smp_flags);
- connect(card);
- S508_S514_unlock(card, &smp_flags);
-
- mod_timer(&card->u.x.x25_timer, jiffies + HZ);
- }
- }
- /* Device is not up until the we are in connected state */
- do_gettimeofday( &tv );
- chan->router_start_time = tv.tv_sec;
-
- netif_start_queue(dev);
-
- return 0;
-}
-
-/*===================================================================
- * Name: if_close(), Close/Bring down the Netowrk Interface
- *
- * Purpose: To bring down a network interface.
- *
- * Rationale:
- *
- * Description: Close network interface.
- * o decrement use module use count
- *
- * Called by: Kernel (/usr/src/linux/net/core/dev.c)
- * (dev->close())
- * ifconfig <name> down: will trigger the kernel
- * which will call this function.
- *
- * Assumptions: None
- *
- * Warnings: None
- *
- * Return: 0 Ok
- * <0 Failure: Interface will not exit properly.
- */
-static int if_close(struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- unsigned long smp_flags;
-
- netif_stop_queue(dev);
-
- if ((chan->common.state == WAN_CONNECTED) ||
- (chan->common.state == WAN_CONNECTING)){
- S508_S514_lock(card, &smp_flags);
- chan_disc(dev);
- S508_S514_unlock(card, &smp_flags);
- }
-
- wanpipe_close(card);
-
- S508_S514_lock(card, &smp_flags);
- if (chan->bh_head){
- int i;
- struct sk_buff *skb;
-
- for (i=0; i<(MAX_BH_BUFF+1); i++){
- skb = ((bh_data_t *)&chan->bh_head[i])->skb;
- if (skb != NULL){
- dev_kfree_skb_any(skb);
- }
- }
- kfree(chan->bh_head);
- chan->bh_head=NULL;
- }
- S508_S514_unlock(card, &smp_flags);
-
- /* If this is the last close, disconnect physical link */
- if (!card->open_cnt){
- S508_S514_lock(card, &smp_flags);
- disconnect(card);
- x25_set_intr_mode(card, 0);
- S508_S514_unlock(card, &smp_flags);
- }
-
- /* Decrement the number of interfaces */
- --card->u.x.no_dev;
- return 0;
-}
-
-/*======================================================================
- * Build media header.
- * o encapsulate packet according to encapsulation type.
- *
- * The trick here is to put packet type (Ethertype) into 'protocol'
- * field of the socket buffer, so that we don't forget it.
- * If encapsulation fails, set skb->protocol to 0 and discard
- * packet later.
- *
- * Return: media header length.
- *======================================================================*/
-
-static int if_header(struct sk_buff* skb, struct net_device* dev,
- unsigned short type, void* daddr, void* saddr,
- unsigned len)
-{
- x25_channel_t* chan = dev->priv;
- int hdr_len = dev->hard_header_len;
-
- skb->protocol = htons(type);
- if (!chan->protocol){
- hdr_len = wanrouter_encapsulate(skb, dev, type);
- if (hdr_len < 0){
- hdr_len = 0;
- skb->protocol = htons(0);
- }
- }
- return hdr_len;
-}
-
-/*===============================================================
- * Re-build media header.
- *
- * Return: 1 physical address resolved.
- * 0 physical address not resolved
- *==============================================================*/
-
-static int if_rebuild_hdr (struct sk_buff* skb)
-{
- struct net_device *dev = skb->dev;
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
-
- printk(KERN_INFO "%s: rebuild_header() called for interface %s!\n",
- card->devname, dev->name);
- return 1;
-}
-
-
-/*============================================================================
- * Handle transmit timeout event from netif watchdog
- */
-static void if_tx_timeout(struct net_device *dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
- /* If our device stays busy for at least 5 seconds then we will
- * kick start the device by making dev->tbusy = 0. We expect
- * that our device never stays busy more than 5 seconds. So this
- * is only used as a last resort.
- */
-
- ++chan->if_send_stat.if_send_tbusy_timeout;
- printk (KERN_INFO "%s: Transmit timed out on %s\n",
- card->devname, dev->name);
- netif_wake_queue (dev);
-}
-
-
-/*=========================================================================
- * Send a packet on a network interface.
- * o set tbusy flag (marks start of the transmission).
- * o check link state. If link is not up, then drop the packet.
- * o check channel status. If it's down then initiate a call.
- * o pass a packet to corresponding WAN device.
- * o free socket buffer
- *
- * Return: 0 complete (socket buffer must be freed)
- * non-0 packet may be re-transmitted (tbusy must be set)
- *
- * Notes:
- * 1. This routine is called either by the protocol stack or by the "net
- * bottom half" (with interrupts enabled).
- * 2. Setting tbusy flag will inhibit further transmit requests from the
- * protocol stack and can be used for flow control with protocol layer.
- *
- *========================================================================*/
-
-static int if_send(struct sk_buff* skb, struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- TX25Status* status = card->flags;
- int udp_type;
- unsigned long smp_flags=0;
-
- ++chan->if_send_stat.if_send_entry;
-
- netif_stop_queue(dev);
-
- /* No need to check frame length, since socket code
- * will perform the check for us */
-
- chan->tick_counter = jiffies;
-
- /* Critical region starts here */
- S508_S514_lock(card, &smp_flags);
-
- if (test_and_set_bit(SEND_CRIT, (void*)&card->wandev.critical)){
- printk(KERN_INFO "Hit critical in if_send()! %lx\n",card->wandev.critical);
- goto if_send_crit_exit;
- }
-
- udp_type = udp_pkt_type(skb, card);
-
- if(udp_type != UDP_INVALID_TYPE) {
-
- if(store_udp_mgmt_pkt(udp_type, UDP_PKT_FRM_STACK, card, dev, skb,
- chan->common.lcn)) {
-
- status->imask |= INTR_ON_TIMER;
- if (udp_type == UDP_XPIPE_TYPE){
- chan->if_send_stat.if_send_PIPE_request++;
- }
- }
- netif_start_queue(dev);
- clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
- S508_S514_unlock(card, &smp_flags);
- return 0;
- }
-
- if (chan->transmit_length){
- //FIXME: This check doesn't make sense any more
- if (chan->common.state != WAN_CONNECTED){
- chan->transmit_length=0;
- atomic_set(&chan->common.driver_busy,0);
- }else{
- netif_stop_queue(dev);
- ++card->u.x.tx_interrupts_pending;
- status->imask |= INTR_ON_TX_FRAME;
- clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
- S508_S514_unlock(card, &smp_flags);
- return 1;
- }
- }
-
- if (card->wandev.state != WAN_CONNECTED){
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- ++chan->if_send_stat.if_send_wan_disconnected;
-
- }else if ( chan->protocol && (chan->protocol != skb->protocol)){
- printk(KERN_INFO
- "%s: unsupported Ethertype 0x%04X on interface %s!\n",
- chan->name, htons(skb->protocol), dev->name);
-
- printk(KERN_INFO "PROTO %Xn", htons(chan->protocol));
- ++chan->ifstats.tx_errors;
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- ++chan->if_send_stat.if_send_protocol_error;
-
- }else switch (chan->common.state){
-
- case WAN_DISCONNECTED:
- /* Try to establish connection. If succeded, then start
- * transmission, else drop a packet.
- */
- if (chan->common.usedby == API){
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- break;
- }else{
- if (chan_connect(dev) != 0){
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- break;
- }
- }
- /* fall through */
-
- case WAN_CONNECTED:
- if( skb->protocol == htons(ETH_P_IPX)) {
- if(chan->enable_IPX) {
- switch_net_numbers( skb->data,
- chan->network_number, 0);
- } else {
- ++card->wandev.stats.tx_dropped;
- ++chan->ifstats.tx_dropped;
- ++chan->if_send_stat.if_send_protocol_error;
- goto if_send_crit_exit;
- }
- }
- /* We never drop here, if cannot send than, copy
- * a packet into a transmit buffer
- */
- chan_send(dev, skb->data, skb->len, 0);
- break;
-
- default:
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- break;
- }
-
-
-if_send_crit_exit:
-
- dev_kfree_skb_any(skb);
-
- netif_start_queue(dev);
- clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
- S508_S514_unlock(card, &smp_flags);
- return 0;
-}
-
-/*============================================================================
- * Setup so that a frame can be transmitted on the occurrence of a transmit
- * interrupt.
- *===========================================================================*/
-
-static void setup_for_delayed_transmit(struct net_device* dev, void* buf,
- unsigned len)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- TX25Status* status = card->flags;
-
- ++chan->if_send_stat.if_send_adptr_bfrs_full;
-
- if(chan->transmit_length) {
- printk(KERN_INFO "%s: Error, transmit length set in delayed transmit!\n",
- card->devname);
- return;
- }
-
- if (chan->common.usedby == API){
- if (len > X25_CHAN_MTU+sizeof(x25api_hdr_t)) {
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- printk(KERN_INFO "%s: Length is too big for delayed transmit\n",
- card->devname);
- return;
- }
- }else{
- if (len > X25_MAX_DATA) {
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- printk(KERN_INFO "%s: Length is too big for delayed transmit\n",
- card->devname);
- return;
- }
- }
-
- chan->transmit_length = len;
- atomic_set(&chan->common.driver_busy,1);
- memcpy(chan->transmit_buffer, buf, len);
-
- ++chan->if_send_stat.if_send_tx_int_enabled;
-
- /* Enable Transmit Interrupt */
- ++card->u.x.tx_interrupts_pending;
- status->imask |= INTR_ON_TX_FRAME;
-}
-
-
-/*===============================================================
- * net_device_stats
- *
- * Get ethernet-style interface statistics.
- * Return a pointer to struct enet_statistics.
- *
- *==============================================================*/
-static struct net_device_stats *if_stats(struct net_device* dev)
-{
- x25_channel_t *chan = dev->priv;
-
- if(chan == NULL)
- return NULL;
-
- return &chan->ifstats;
-}
-
-
-/*
- * Interrupt Handlers
- */
-
-/*
- * X.25 Interrupt Service Routine.
- */
-
-static void wpx_isr (sdla_t* card)
-{
- TX25Status* status = card->flags;
-
- card->in_isr = 1;
- ++card->statistics.isr_entry;
-
- if (test_bit(PERI_CRIT,(void*)&card->wandev.critical)){
- card->in_isr=0;
- status->iflags = 0;
- return;
- }
-
- if (test_bit(SEND_CRIT, (void*)&card->wandev.critical)){
-
- printk(KERN_INFO "%s: wpx_isr: wandev.critical set to 0x%02lx, int type = 0x%02x\n",
- card->devname, card->wandev.critical, status->iflags);
- card->in_isr = 0;
- status->iflags = 0;
- return;
- }
-
- /* For all interrupts set the critical flag to CRITICAL_RX_INTR.
- * If the if_send routine is called with this flag set it will set
- * the enable transmit flag to 1. (for a delayed interrupt)
- */
- switch (status->iflags){
-
- case RX_INTR_PENDING: /* receive interrupt */
- rx_intr(card);
- break;
-
- case TX_INTR_PENDING: /* transmit interrupt */
- tx_intr(card);
- break;
-
- case MODEM_INTR_PENDING: /* modem status interrupt */
- status_intr(card);
- break;
-
- case X25_ASY_TRANS_INTR_PENDING: /* network event interrupt */
- event_intr(card);
- break;
-
- case TIMER_INTR_PENDING:
- timer_intr(card);
- break;
-
- default: /* unwanted interrupt */
- spur_intr(card);
- }
-
- card->in_isr = 0;
- status->iflags = 0; /* clear interrupt condition */
-}
-
-/*
- * Receive interrupt handler.
- * This routine handles fragmented IP packets using M-bit according to the
- * RFC1356.
- * o map ligical channel number to network interface.
- * o allocate socket buffer or append received packet to the existing one.
- * o if M-bit is reset (i.e. it's the last packet in a sequence) then
- * decapsulate packet and pass socket buffer to the protocol stack.
- *
- * Notes:
- * 1. When allocating a socket buffer, if M-bit is set then more data is
- * coming and we have to allocate buffer for the maximum IP packet size
- * expected on this channel.
- * 2. If something goes wrong and X.25 packet has to be dropped (e.g. no
- * socket buffers available) the whole packet sequence must be discarded.
- */
-
-static void rx_intr (sdla_t* card)
-{
- TX25Mbox* rxmb = card->rxmb;
- unsigned lcn = rxmb->cmd.lcn;
- struct net_device* dev = find_channel(card,lcn);
- x25_channel_t* chan;
- struct sk_buff* skb=NULL;
-
- if (dev == NULL){
- /* Invalid channel, discard packet */
- printk(KERN_INFO "%s: receiving on orphaned LCN %d!\n",
- card->devname, lcn);
- return;
- }
-
- chan = dev->priv;
- chan->i_timeout_sofar = jiffies;
-
-
- /* Copy the data from the board, into an
- * skb buffer
- */
- if (wanpipe_pull_data_in_skb(card,dev,&skb)){
- ++chan->ifstats.rx_dropped;
- ++card->wandev.stats.rx_dropped;
- ++chan->rx_intr_stat.rx_intr_no_socket;
- ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
- return;
- }
-
- dev->last_rx = jiffies; /* timestamp */
-
-
- /* ------------ API ----------------*/
-
- if (chan->common.usedby == API){
-
- if (bh_enqueue(dev, skb)){
- ++chan->ifstats.rx_dropped;
- ++card->wandev.stats.rx_dropped;
- ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
- dev_kfree_skb_any(skb);
- return;
- }
-
- ++chan->ifstats.rx_packets;
- chan->ifstats.rx_bytes += skb->len;
-
-
- chan->rx_skb = NULL;
- if (!test_and_set_bit(0, &chan->tq_working)){
- wanpipe_queue_work(&chan->common.wanpipe_work);
- }
- return;
- }
-
-
- /* ------------- WANPIPE -------------------*/
-
- /* set rx_skb to NULL so we won't access it later when kernel already owns it */
- chan->rx_skb=NULL;
-
- /* Decapsulate packet, if necessary */
- if (!skb->protocol && !wanrouter_type_trans(skb, dev)){
- /* can't decapsulate packet */
- dev_kfree_skb_any(skb);
- ++chan->ifstats.rx_errors;
- ++chan->ifstats.rx_dropped;
- ++card->wandev.stats.rx_dropped;
- ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
-
- }else{
- if( handle_IPXWAN(skb->data, chan->name,
- chan->enable_IPX, chan->network_number,
- skb->protocol)){
-
- if( chan->enable_IPX ){
- if(chan_send(dev, skb->data, skb->len,0)){
- chan->tx_skb = skb;
- }else{
- dev_kfree_skb_any(skb);
- ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
- }
- }else{
- /* increment IPX packet dropped statistic */
- ++chan->ifstats.rx_dropped;
- ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
- }
- }else{
- skb->mac.raw = skb->data;
- chan->ifstats.rx_bytes += skb->len;
- ++chan->ifstats.rx_packets;
- ++chan->rx_intr_stat.rx_intr_bfr_passed_to_stack;
- netif_rx(skb);
- }
- }
-
- return;
-}
-
-
-static int wanpipe_pull_data_in_skb(sdla_t *card, struct net_device *dev,
- struct sk_buff **skb)
-{
- void *bufptr;
- TX25Mbox* rxmb = card->rxmb;
- unsigned len = rxmb->cmd.length; /* packet length */
- unsigned qdm = rxmb->cmd.qdm; /* Q,D and M bits */
- x25_channel_t *chan = dev->priv;
- struct sk_buff *new_skb = *skb;
-
- if (chan->common.usedby == WANPIPE){
- if (chan->drop_sequence){
- if (!(qdm & 0x01)){
- chan->drop_sequence = 0;
- }
- return 1;
- }
- new_skb = chan->rx_skb;
- }else{
- /* Add on the API header to the received
- * data
- */
- len += sizeof(x25api_hdr_t);
- }
-
- if (new_skb == NULL){
- int bufsize;
-
- if (chan->common.usedby == WANPIPE){
- bufsize = (qdm & 0x01) ? dev->mtu : len;
- }else{
- bufsize = len;
- }
-
- /* Allocate new socket buffer */
- new_skb = dev_alloc_skb(bufsize + dev->hard_header_len);
- if (new_skb == NULL){
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- chan->drop_sequence = 1; /* set flag */
- ++chan->ifstats.rx_dropped;
- return 1;
- }
- }
-
- if (skb_tailroom(new_skb) < len){
- /* No room for the packet. Call off the whole thing! */
- dev_kfree_skb_any(new_skb);
- if (chan->common.usedby == WANPIPE){
- chan->rx_skb = NULL;
- if (qdm & 0x01){
- chan->drop_sequence = 1;
- }
- }
-
- printk(KERN_INFO "%s: unexpectedly long packet sequence "
- "on interface %s!\n", card->devname, dev->name);
- ++chan->ifstats.rx_length_errors;
- return 1;
- }
-
- bufptr = skb_put(new_skb,len);
-
-
- if (chan->common.usedby == API){
- /* Fill in the x25api header
- */
- x25api_t * api_data = (x25api_t*)bufptr;
- api_data->hdr.qdm = rxmb->cmd.qdm;
- api_data->hdr.cause = rxmb->cmd.cause;
- api_data->hdr.diagn = rxmb->cmd.diagn;
- api_data->hdr.length = rxmb->cmd.length;
- memcpy(api_data->data, rxmb->data, rxmb->cmd.length);
- }else{
- memcpy(bufptr, rxmb->data, len);
- }
-
- new_skb->dev = dev;
-
- if (chan->common.usedby == API){
- new_skb->mac.raw = new_skb->data;
- new_skb->protocol = htons(X25_PROT);
- new_skb->pkt_type = WAN_PACKET_DATA;
- }else{
- new_skb->protocol = chan->protocol;
- chan->rx_skb = new_skb;
- }
-
- /* If qdm bit is set, more data is coming
- * thus, exit and wait for more data before
- * sending the packet up. (Used by router only)
- */
- if ((qdm & 0x01) && (chan->common.usedby == WANPIPE))
- return 1;
-
- *skb = new_skb;
-
- return 0;
-}
-
-/*===============================================================
- * tx_intr
- *
- * Transmit interrupt handler.
- * For each dev, check that there is something to send.
- * If data available, transmit.
- *
- *===============================================================*/
-
-static void tx_intr (sdla_t* card)
-{
- struct net_device *dev;
- TX25Status* status = card->flags;
- unsigned char more_to_tx=0;
- x25_channel_t *chan=NULL;
- int i=0;
-
- if (card->u.x.tx_dev == NULL){
- card->u.x.tx_dev = card->wandev.dev;
- }
-
- dev = card->u.x.tx_dev;
-
- for (;;){
-
- chan = dev->priv;
- if (chan->transmit_length){
- /* Device was set to transmit, check if the TX
- * buffers are available
- */
- if (chan->common.state != WAN_CONNECTED){
- chan->transmit_length = 0;
- atomic_set(&chan->common.driver_busy,0);
- chan->tx_offset=0;
- if (netif_queue_stopped(dev)){
- if (chan->common.usedby == API){
- netif_start_queue(dev);
- wakeup_sk_bh(dev);
- }else{
- netif_wake_queue(dev);
- }
- }
- dev = move_dev_to_next(card,dev);
- break;
- }
-
- if ((status->cflags[chan->ch_idx] & 0x40 || card->u.x.LAPB_hdlc) &&
- (*card->u.x.hdlc_buf_status & 0x40) ){
- /* Tx buffer available, we can send */
-
- if (tx_intr_send(card, dev)){
- more_to_tx=1;
- }
-
- /* If more than one interface present, move the
- * device pointer to the next interface, so on the
- * next TX interrupt we will try sending from it.
- */
- dev = move_dev_to_next(card,dev);
- break;
- }else{
- /* Tx buffers not available, but device set
- * the TX interrupt. Set more_to_tx and try
- * to transmit for other devices.
- */
- more_to_tx=1;
- dev = move_dev_to_next(card,dev);
- }
-
- }else{
- /* This device was not set to transmit,
- * go to next
- */
- dev = move_dev_to_next(card,dev);
- }
-
- if (++i == card->u.x.no_dev){
- if (!more_to_tx){
- DBG_PRINTK(KERN_INFO "%s: Nothing to Send in TX INTR\n",
- card->devname);
- }
- break;
- }
-
- } //End of FOR
-
- card->u.x.tx_dev = dev;
-
- if (!more_to_tx){
- /* if any other interfaces have transmit interrupts pending, */
- /* do not disable the global transmit interrupt */
- if (!(--card->u.x.tx_interrupts_pending)){
- status->imask &= ~INTR_ON_TX_FRAME;
- }
- }
- return;
-}
-
-/*===============================================================
- * move_dev_to_next
- *
- *
- *===============================================================*/
-
-
-struct net_device *move_dev_to_next(sdla_t *card, struct net_device *dev)
-{
- if (card->u.x.no_dev != 1){
- if (!*((struct net_device **)dev->priv))
- return card->wandev.dev;
- else
- return *((struct net_device **)dev->priv);
- }
- return dev;
-}
-
-/*===============================================================
- * tx_intr_send
- *
- *
- *===============================================================*/
-
-static int tx_intr_send(sdla_t *card, struct net_device *dev)
-{
- x25_channel_t* chan = dev->priv;
-
- if (chan_send (dev,chan->transmit_buffer,chan->transmit_length,1)){
-
- /* Packet was split up due to its size, do not disable
- * tx_intr
- */
- return 1;
- }
-
- chan->transmit_length=0;
- atomic_set(&chan->common.driver_busy,0);
- chan->tx_offset=0;
-
- /* If we are in API mode, wakeup the
- * sock BH handler, not the NET_BH */
- if (netif_queue_stopped(dev)){
- if (chan->common.usedby == API){
- netif_start_queue(dev);
- wakeup_sk_bh(dev);
- }else{
- netif_wake_queue(dev);
- }
- }
- return 0;
-}
-
-
-/*===============================================================
- * timer_intr
- *
- * Timer interrupt handler.
- * Check who called the timer interrupt and perform
- * action accordingly.
- *
- *===============================================================*/
-
-static void timer_intr (sdla_t *card)
-{
- TX25Status* status = card->flags;
-
- if (card->u.x.timer_int_enabled & TMR_INT_ENABLED_CMD_EXEC){
-
- if (timer_intr_cmd_exec(card) == 0){
- card->u.x.timer_int_enabled &=
- ~TMR_INT_ENABLED_CMD_EXEC;
- }
-
- }else if(card->u.x.timer_int_enabled & TMR_INT_ENABLED_UDP_PKT) {
-
- if ((*card->u.x.hdlc_buf_status & 0x40) &&
- card->u.x.udp_type == UDP_XPIPE_TYPE){
-
- if(process_udp_mgmt_pkt(card)) {
- card->u.x.timer_int_enabled &=
- ~TMR_INT_ENABLED_UDP_PKT;
- }
- }
-
- }else if (card->u.x.timer_int_enabled & TMR_INT_ENABLED_POLL_ACTIVE) {
-
- struct net_device *dev = card->u.x.poll_device;
- x25_channel_t *chan = NULL;
-
- if (!dev){
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_POLL_ACTIVE;
- return;
- }
- chan = dev->priv;
-
- printk(KERN_INFO
- "%s: Closing down Idle link %s on LCN %d\n",
- card->devname,chan->name,chan->common.lcn);
- chan->i_timeout_sofar = jiffies;
- chan_disc(dev);
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_POLL_ACTIVE;
- card->u.x.poll_device=NULL;
-
- }else if (card->u.x.timer_int_enabled & TMR_INT_ENABLED_POLL_CONNECT_ON) {
-
- wanpipe_set_state(card, WAN_CONNECTED);
- if (card->u.x.LAPB_hdlc){
- struct net_device *dev = card->wandev.dev;
- set_chan_state(dev,WAN_CONNECTED);
- send_delayed_cmd_result(card,dev,card->mbox);
- }
-
- /* 0x8F enable all interrupts */
- x25_set_intr_mode(card, INTR_ON_RX_FRAME|
- INTR_ON_TX_FRAME|
- INTR_ON_MODEM_STATUS_CHANGE|
- //INTR_ON_COMMAND_COMPLETE|
- X25_ASY_TRANS_INTR_PENDING |
- INTR_ON_TIMER |
- DIRECT_RX_INTR_USAGE
- );
-
- status->imask &= ~INTR_ON_TX_FRAME; /* mask Tx interrupts */
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_POLL_CONNECT_ON;
-
- }else if (card->u.x.timer_int_enabled & TMR_INT_ENABLED_POLL_CONNECT_OFF) {
-
- //printk(KERN_INFO "Poll connect, Turning OFF\n");
- disconnect(card);
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_POLL_CONNECT_OFF;
-
- }else if (card->u.x.timer_int_enabled & TMR_INT_ENABLED_POLL_DISCONNECT) {
-
- //printk(KERN_INFO "POll disconnect, trying to connect\n");
- connect(card);
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_POLL_DISCONNECT;
-
- }else if (card->u.x.timer_int_enabled & TMR_INT_ENABLED_UPDATE){
-
- if (*card->u.x.hdlc_buf_status & 0x40){
- x25_get_err_stats(card);
- x25_get_stats(card);
- card->u.x.timer_int_enabled &= ~TMR_INT_ENABLED_UPDATE;
- }
- }
-
- if(!card->u.x.timer_int_enabled){
- //printk(KERN_INFO "Turning Timer Off \n");
- status->imask &= ~INTR_ON_TIMER;
- }
-}
-
-/*====================================================================
- * Modem status interrupt handler.
- *===================================================================*/
-static void status_intr (sdla_t* card)
-{
-
- /* Added to avoid Modem status message flooding */
- static TX25ModemStatus last_stat;
-
- TX25Mbox* mbox = card->mbox;
- TX25ModemStatus *modem_status;
- struct net_device *dev;
- x25_channel_t *chan;
- int err;
-
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_READ_MODEM_STATUS;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err){
- x25_error(card, err, X25_READ_MODEM_STATUS, 0);
- }else{
-
- modem_status = (TX25ModemStatus*)mbox->data;
-
- /* Check if the last status was the same
- * if it was, do NOT print message again */
-
- if (last_stat.status != modem_status->status){
-
- printk(KERN_INFO "%s: Modem Status Change: DCD=%s, CTS=%s\n",
- card->devname,DCD(modem_status->status),CTS(modem_status->status));
-
- last_stat.status = modem_status->status;
-
- if (card->u.x.oob_on_modem){
-
- mbox->cmd.pktType = mbox->cmd.command;
- mbox->cmd.result = 0x08;
-
- /* Send a OOB to all connected sockets */
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device**)dev->priv)) {
- chan=dev->priv;
- if (chan->common.usedby == API){
- send_oob_msg(card,dev,mbox);
- }
- }
-
- /* The modem OOB message will probably kill the
- * the link. If we don't clear the flag here,
- * a deadlock could occur */
- if (atomic_read(&card->u.x.command_busy)){
- atomic_set(&card->u.x.command_busy,0);
- }
- }
- }
- }
-
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_HDLC_LINK_STATUS;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err){
- x25_error(card, err, X25_HDLC_LINK_STATUS, 0);
- }
-
-}
-
-/*====================================================================
- * Network event interrupt handler.
- *===================================================================*/
-static void event_intr (sdla_t* card)
-{
- x25_fetch_events(card);
-}
-
-/*====================================================================
- * Spurious interrupt handler.
- * o print a warning
- * o
- *====================================================================*/
-
-static void spur_intr (sdla_t* card)
-{
- printk(KERN_INFO "%s: spurious interrupt!\n", card->devname);
-}
-
-
-/*
- * Background Polling Routines
- */
-
-/*====================================================================
- * Main polling routine.
- * This routine is repeatedly called by the WANPIPE 'thread' to allow for
- * time-dependent housekeeping work.
- *
- * Notes:
- * 1. This routine may be called on interrupt context with all interrupts
- * enabled. Beware!
- *====================================================================*/
-
-static void wpx_poll (sdla_t *card)
-{
- if (!card->wandev.dev){
- goto wpx_poll_exit;
- }
-
- if (card->open_cnt != card->u.x.num_of_ch){
- goto wpx_poll_exit;
- }
-
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- goto wpx_poll_exit;
- }
-
- if (test_bit(SEND_CRIT,&card->wandev.critical)){
- goto wpx_poll_exit;
- }
-
- switch(card->wandev.state){
- case WAN_CONNECTED:
- poll_active(card);
- break;
-
- case WAN_CONNECTING:
- poll_connecting(card);
- break;
-
- case WAN_DISCONNECTED:
- poll_disconnected(card);
- break;
- }
-
-wpx_poll_exit:
- clear_bit(POLL_CRIT,&card->wandev.critical);
- return;
-}
-
-static void trigger_x25_poll(sdla_t *card)
-{
- schedule_work(&card->u.x.x25_poll_work);
-}
-
-/*====================================================================
- * Handle physical link establishment phase.
- * o if connection timed out, disconnect the link.
- *===================================================================*/
-
-static void poll_connecting (sdla_t* card)
-{
- volatile TX25Status* status = card->flags;
-
- if (status->gflags & X25_HDLC_ABM){
-
- timer_intr_exec (card, TMR_INT_ENABLED_POLL_CONNECT_ON);
-
- }else if ((jiffies - card->state_tick) > CONNECT_TIMEOUT){
-
- timer_intr_exec (card, TMR_INT_ENABLED_POLL_CONNECT_OFF);
-
- }
-}
-
-/*====================================================================
- * Handle physical link disconnected phase.
- * o if hold-down timeout has expired and there are open interfaces,
- * connect link.
- *===================================================================*/
-
-static void poll_disconnected (sdla_t* card)
-{
- struct net_device *dev;
- x25_channel_t *chan;
- TX25Status* status = card->flags;
-
- if (!card->u.x.LAPB_hdlc && card->open_cnt &&
- ((jiffies - card->state_tick) > HOLD_DOWN_TIME)){
- timer_intr_exec(card, TMR_INT_ENABLED_POLL_DISCONNECT);
- }
-
-
- if ((dev=card->wandev.dev) == NULL)
- return;
-
- if ((chan=dev->priv) == NULL)
- return;
-
- if (chan->common.usedby == API &&
- atomic_read(&chan->common.command) &&
- card->u.x.LAPB_hdlc){
-
- if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_CMD_EXEC))
- card->u.x.timer_int_enabled |= TMR_INT_ENABLED_CMD_EXEC;
-
- if (!(status->imask & INTR_ON_TIMER))
- status->imask |= INTR_ON_TIMER;
- }
-
-}
-
-/*====================================================================
- * Handle active link phase.
- * o fetch X.25 asynchronous events.
- * o kick off transmission on all interfaces.
- *===================================================================*/
-
-static void poll_active (sdla_t* card)
-{
- struct net_device* dev;
- TX25Status* status = card->flags;
-
- for (dev = card->wandev.dev; dev;
- dev = *((struct net_device **)dev->priv)){
- x25_channel_t* chan = dev->priv;
-
- /* If SVC has been idle long enough, close virtual circuit */
- if ( chan->common.svc &&
- chan->common.state == WAN_CONNECTED &&
- chan->common.usedby == WANPIPE ){
-
- if( (jiffies - chan->i_timeout_sofar) / HZ > chan->idle_timeout ){
- /* Close svc */
- card->u.x.poll_device=dev;
- timer_intr_exec (card, TMR_INT_ENABLED_POLL_ACTIVE);
- }
- }
-
-#ifdef PRINT_DEBUG
- chan->ifstats.tx_compressed = atomic_read(&chan->common.command);
- chan->ifstats.tx_errors = chan->common.state;
- chan->ifstats.rx_fifo_errors = atomic_read(&card->u.x.command_busy);
- ++chan->ifstats.tx_bytes;
-
- chan->ifstats.rx_fifo_errors=atomic_read(&chan->common.disconnect);
- chan->ifstats.multicast=atomic_read(&chan->bh_buff_used);
- chan->ifstats.rx_length_errors=*card->u.x.hdlc_buf_status;
-#endif
-
- if (chan->common.usedby == API &&
- atomic_read(&chan->common.command) &&
- !card->u.x.LAPB_hdlc){
-
- if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_CMD_EXEC))
- card->u.x.timer_int_enabled |= TMR_INT_ENABLED_CMD_EXEC;
-
- if (!(status->imask & INTR_ON_TIMER))
- status->imask |= INTR_ON_TIMER;
- }
-
- if ((chan->common.usedby == API) &&
- atomic_read(&chan->common.disconnect)){
-
- if (chan->common.state == WAN_DISCONNECTED){
- atomic_set(&chan->common.disconnect,0);
- return;
- }
-
- atomic_set(&chan->common.command,X25_CLEAR_CALL);
- if (!(card->u.x.timer_int_enabled & TMR_INT_ENABLED_CMD_EXEC))
- card->u.x.timer_int_enabled |= TMR_INT_ENABLED_CMD_EXEC;
-
- if (!(status->imask & INTR_ON_TIMER))
- status->imask |= INTR_ON_TIMER;
- }
- }
-}
-
-static void timer_intr_exec(sdla_t *card, unsigned char TYPE)
-{
- TX25Status* status = card->flags;
- card->u.x.timer_int_enabled |= TYPE;
- if (!(status->imask & INTR_ON_TIMER))
- status->imask |= INTR_ON_TIMER;
-}
-
-
-/*====================================================================
- * SDLA Firmware-Specific Functions
- *
- * Almost all X.25 commands can unexpetedly fail due to so called 'X.25
- * asynchronous events' such as restart, interrupt, incoming call request,
- * call clear request, etc. They can't be ignored and have to be delt with
- * immediately. To tackle with this problem we execute each interface
- * command in a loop until good return code is received or maximum number
- * of retries is reached. Each interface command returns non-zero return
- * code, an asynchronous event/error handler x25_error() is called.
- *====================================================================*/
-
-/*====================================================================
- * Read X.25 firmware version.
- * Put code version as ASCII string in str.
- *===================================================================*/
-
-static int x25_get_version (sdla_t* card, char* str)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_READ_CODE_VERSION;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- &&
- x25_error(card, err, X25_READ_CODE_VERSION, 0));
-
- if (!err && str)
- {
- int len = mbox->cmd.length;
-
- memcpy(str, mbox->data, len);
- str[len] = '\0';
- }
- return err;
-}
-
-/*====================================================================
- * Configure adapter.
- *===================================================================*/
-
-static int x25_configure (sdla_t* card, TX25Config* conf)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do{
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- memcpy(mbox->data, (void*)conf, sizeof(TX25Config));
- mbox->cmd.length = sizeof(TX25Config);
- mbox->cmd.command = X25_SET_CONFIGURATION;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_SET_CONFIGURATION, 0));
- return err;
-}
-
-/*====================================================================
- * Configure adapter for HDLC only.
- *===================================================================*/
-
-static int hdlc_configure (sdla_t* card, TX25Config* conf)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do{
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- memcpy(mbox->data, (void*)conf, sizeof(TX25Config));
- mbox->cmd.length = sizeof(TX25Config);
- mbox->cmd.command = X25_HDLC_SET_CONFIG;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_SET_CONFIGURATION, 0));
-
- return err;
-}
-
-static int set_hdlc_level (sdla_t* card)
-{
-
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do{
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = SET_PROTOCOL_LEVEL;
- mbox->cmd.length = 1;
- mbox->data[0] = HDLC_LEVEL; //| DO_HDLC_LEVEL_ERROR_CHECKING;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, SET_PROTOCOL_LEVEL, 0));
-
- return err;
-}
-
-
-
-/*====================================================================
- * Get communications error statistics.
- *====================================================================*/
-
-static int x25_get_err_stats (sdla_t* card)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_HDLC_READ_COMM_ERR;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_HDLC_READ_COMM_ERR, 0));
-
- if (!err)
- {
- THdlcCommErr* stats = (void*)mbox->data;
-
- card->wandev.stats.rx_over_errors = stats->rxOverrun;
- card->wandev.stats.rx_crc_errors = stats->rxBadCrc;
- card->wandev.stats.rx_missed_errors = stats->rxAborted;
- card->wandev.stats.tx_aborted_errors = stats->txAborted;
- }
- return err;
-}
-
-/*====================================================================
- * Get protocol statistics.
- *===================================================================*/
-
-static int x25_get_stats (sdla_t* card)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_READ_STATISTICS;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_READ_STATISTICS, 0)) ;
-
- if (!err)
- {
- TX25Stats* stats = (void*)mbox->data;
-
- card->wandev.stats.rx_packets = stats->rxData;
- card->wandev.stats.tx_packets = stats->txData;
- }
- return err;
-}
-
-/*====================================================================
- * Close HDLC link.
- *===================================================================*/
-
-static int x25_close_hdlc (sdla_t* card)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_HDLC_LINK_CLOSE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_HDLC_LINK_CLOSE, 0));
-
- return err;
-}
-
-
-/*====================================================================
- * Open HDLC link.
- *===================================================================*/
-
-static int x25_open_hdlc (sdla_t* card)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_HDLC_LINK_OPEN;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_HDLC_LINK_OPEN, 0));
-
- return err;
-}
-
-/*=====================================================================
- * Setup HDLC link.
- *====================================================================*/
-static int x25_setup_hdlc (sdla_t* card)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_HDLC_LINK_SETUP;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_HDLC_LINK_SETUP, 0));
-
- return err;
-}
-
-/*====================================================================
- * Set (raise/drop) DTR.
- *===================================================================*/
-
-static int x25_set_dtr (sdla_t* card, int dtr)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->data[0] = 0;
- mbox->data[2] = 0;
- mbox->data[1] = dtr ? 0x02 : 0x01;
- mbox->cmd.length = 3;
- mbox->cmd.command = X25_SET_GLOBAL_VARS;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_SET_GLOBAL_VARS, 0));
-
- return err;
-}
-
-/*====================================================================
- * Set interrupt mode.
- *===================================================================*/
-
-static int x25_set_intr_mode (sdla_t* card, int mode)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->data[0] = mode;
- if (card->hw.fwid == SFID_X25_508){
- mbox->data[1] = card->hw.irq;
- mbox->data[2] = 2;
- mbox->cmd.length = 3;
- }else {
- mbox->cmd.length = 1;
- }
- mbox->cmd.command = X25_SET_INTERRUPT_MODE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_SET_INTERRUPT_MODE, 0));
-
- return err;
-}
-
-/*====================================================================
- * Read X.25 channel configuration.
- *===================================================================*/
-
-static int x25_get_chan_conf (sdla_t* card, x25_channel_t* chan)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int lcn = chan->common.lcn;
- int err;
-
- do{
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.lcn = lcn;
- mbox->cmd.command = X25_READ_CHANNEL_CONFIG;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_READ_CHANNEL_CONFIG, lcn));
-
- if (!err)
- {
- TX25Status* status = card->flags;
-
- /* calculate an offset into the array of status bytes */
- if (card->u.x.hi_svc <= X25_MAX_CHAN){
-
- chan->ch_idx = lcn - 1;
-
- }else{
- int offset;
-
- /* FIX: Apr 14 2000 : Nenad Corbic
- * The data field was being compared to 0x1F using
- * '&&' instead of '&'.
- * This caused X25API to fail for LCNs greater than 255.
- */
- switch (mbox->data[0] & 0x1F)
- {
- case 0x01:
- offset = status->pvc_map; break;
- case 0x03:
- offset = status->icc_map; break;
- case 0x07:
- offset = status->twc_map; break;
- case 0x0B:
- offset = status->ogc_map; break;
- default:
- offset = 0;
- }
- chan->ch_idx = lcn - 1 - offset;
- }
-
- /* get actual transmit packet size on this channel */
- switch(mbox->data[1] & 0x38)
- {
- case 0x00:
- chan->tx_pkt_size = 16;
- break;
- case 0x08:
- chan->tx_pkt_size = 32;
- break;
- case 0x10:
- chan->tx_pkt_size = 64;
- break;
- case 0x18:
- chan->tx_pkt_size = 128;
- break;
- case 0x20:
- chan->tx_pkt_size = 256;
- break;
- case 0x28:
- chan->tx_pkt_size = 512;
- break;
- case 0x30:
- chan->tx_pkt_size = 1024;
- break;
- }
- if (card->u.x.logging)
- printk(KERN_INFO "%s: X.25 packet size on LCN %d is %d.\n",
- card->devname, lcn, chan->tx_pkt_size);
- }
- return err;
-}
-
-/*====================================================================
- * Place X.25 call.
- *====================================================================*/
-
-static int x25_place_call (sdla_t* card, x25_channel_t* chan)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
- char str[64];
-
-
- if (chan->protocol == htons(ETH_P_IP)){
- sprintf(str, "-d%s -uCC", chan->addr);
-
- }else if (chan->protocol == htons(ETH_P_IPX)){
- sprintf(str, "-d%s -u800000008137", chan->addr);
-
- }
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- strcpy(mbox->data, str);
- mbox->cmd.length = strlen(str);
- mbox->cmd.command = X25_PLACE_CALL;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_PLACE_CALL, 0));
-
- if (!err){
- bind_lcn_to_dev (card, chan->dev, mbox->cmd.lcn);
- }
- return err;
-}
-
-/*====================================================================
- * Accept X.25 call.
- *====================================================================*/
-
-static int x25_accept_call (sdla_t* card, int lcn, int qdm)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.lcn = lcn;
- mbox->cmd.qdm = qdm;
- mbox->cmd.command = X25_ACCEPT_CALL;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_ACCEPT_CALL, lcn));
-
- return err;
-}
-
-/*====================================================================
- * Clear X.25 call.
- *====================================================================*/
-
-static int x25_clear_call (sdla_t* card, int lcn, int cause, int diagn)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.lcn = lcn;
- mbox->cmd.cause = cause;
- mbox->cmd.diagn = diagn;
- mbox->cmd.command = X25_CLEAR_CALL;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, X25_CLEAR_CALL, lcn));
-
- return err;
-}
-
-/*====================================================================
- * Send X.25 data packet.
- *====================================================================*/
-
-static int x25_send (sdla_t* card, int lcn, int qdm, int len, void* buf)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = MAX_CMD_RETRY;
- int err;
- unsigned char cmd;
-
- if (card->u.x.LAPB_hdlc)
- cmd = X25_HDLC_WRITE;
- else
- cmd = X25_WRITE;
-
- do
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- memcpy(mbox->data, buf, len);
- mbox->cmd.length = len;
- mbox->cmd.lcn = lcn;
-
- if (card->u.x.LAPB_hdlc){
- mbox->cmd.pf = qdm;
- }else{
- mbox->cmd.qdm = qdm;
- }
-
- mbox->cmd.command = cmd;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && retry-- && x25_error(card, err, cmd , lcn));
-
-
- /* If buffers are busy the return code for LAPB HDLC is
- * 1. The above functions are looking for return code
- * of X25RES_NOT_READY if busy. */
-
- if (card->u.x.LAPB_hdlc && err == 1){
- err = X25RES_NOT_READY;
- }
-
- return err;
-}
-
-/*====================================================================
- * Fetch X.25 asynchronous events.
- *===================================================================*/
-
-static int x25_fetch_events (sdla_t* card)
-{
- TX25Status* status = card->flags;
- TX25Mbox* mbox = card->mbox;
- int err = 0;
-
- if (status->gflags & 0x20)
- {
- memset(&mbox->cmd, 0, sizeof(TX25Cmd));
- mbox->cmd.command = X25_IS_DATA_AVAILABLE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err) x25_error(card, err, X25_IS_DATA_AVAILABLE, 0);
- }
- return err;
-}
-
-/*====================================================================
- * X.25 asynchronous event/error handler.
- * This routine is called each time interface command returns
- * non-zero return code to handle X.25 asynchronous events and
- * common errors. Return non-zero to repeat command or zero to
- * cancel it.
- *
- * Notes:
- * 1. This function may be called recursively, as handling some of the
- * asynchronous events (e.g. call request) requires execution of the
- * interface command(s) that, in turn, may also return asynchronous
- * events. To avoid re-entrancy problems we copy mailbox to dynamically
- * allocated memory before processing events.
- *====================================================================*/
-
-static int x25_error (sdla_t* card, int err, int cmd, int lcn)
-{
- int retry = 1;
- unsigned dlen = ((TX25Mbox*)card->mbox)->cmd.length;
- TX25Mbox* mb;
-
- mb = kmalloc(sizeof(TX25Mbox) + dlen, GFP_ATOMIC);
- if (mb == NULL)
- {
- printk(KERN_ERR "%s: x25_error() out of memory!\n",
- card->devname);
- return 0;
- }
- memcpy(mb, card->mbox, sizeof(TX25Mbox) + dlen);
- switch (err){
-
- case X25RES_ASYNC_PACKET: /* X.25 asynchronous packet was received */
-
- mb->data[dlen] = '\0';
-
- switch (mb->cmd.pktType & 0x7F){
-
- case ASE_CALL_RQST: /* incoming call */
- retry = incoming_call(card, cmd, lcn, mb);
- break;
-
- case ASE_CALL_ACCEPTED: /* connected */
- retry = call_accepted(card, cmd, lcn, mb);
- break;
-
- case ASE_CLEAR_RQST: /* call clear request */
- retry = call_cleared(card, cmd, lcn, mb);
- break;
-
- case ASE_RESET_RQST: /* reset request */
- printk(KERN_INFO "%s: X.25 reset request on LCN %d! "
- "Cause:0x%02X Diagn:0x%02X\n",
- card->devname, mb->cmd.lcn, mb->cmd.cause,
- mb->cmd.diagn);
- api_oob_event (card,mb);
- break;
-
- case ASE_RESTART_RQST: /* restart request */
- retry = restart_event(card, cmd, lcn, mb);
- break;
-
- case ASE_CLEAR_CONFRM:
- if (clear_confirm_event (card,mb))
- break;
-
- /* I use the goto statement here so if
- * somebody inserts code between the
- * case and default, we will not have
- * ghost problems */
-
- goto dflt_1;
-
- default:
-dflt_1:
- printk(KERN_INFO "%s: X.25 event 0x%02X on LCN %d! "
- "Cause:0x%02X Diagn:0x%02X\n",
- card->devname, mb->cmd.pktType,
- mb->cmd.lcn, mb->cmd.cause, mb->cmd.diagn);
- }
- break;
-
- case X25RES_PROTO_VIOLATION: /* X.25 protocol violation indication */
-
- /* Bug Fix: Mar 14 2000
- * The Protocol violation error conditions were
- * not handled previously */
-
- switch (mb->cmd.pktType & 0x7F){
-
- case PVE_CLEAR_RQST: /* Clear request */
- retry = call_cleared(card, cmd, lcn, mb);
- break;
-
- case PVE_RESET_RQST: /* Reset request */
- printk(KERN_INFO "%s: X.25 reset request on LCN %d! "
- "Cause:0x%02X Diagn:0x%02X\n",
- card->devname, mb->cmd.lcn, mb->cmd.cause,
- mb->cmd.diagn);
- api_oob_event (card,mb);
- break;
-
- case PVE_RESTART_RQST: /* Restart request */
- retry = restart_event(card, cmd, lcn, mb);
- break;
-
- default :
- printk(KERN_INFO
- "%s: X.25 protocol violation on LCN %d! "
- "Packet:0x%02X Cause:0x%02X Diagn:0x%02X\n",
- card->devname, mb->cmd.lcn,
- mb->cmd.pktType & 0x7F, mb->cmd.cause, mb->cmd.diagn);
- api_oob_event(card,mb);
- }
- break;
-
- case 0x42: /* X.25 timeout */
- retry = timeout_event(card, cmd, lcn, mb);
- break;
-
- case 0x43: /* X.25 retry limit exceeded */
- printk(KERN_INFO
- "%s: exceeded X.25 retry limit on LCN %d! "
- "Packet:0x%02X Diagn:0x%02X\n", card->devname,
- mb->cmd.lcn, mb->cmd.pktType, mb->cmd.diagn)
- ;
- break;
-
- case 0x08: /* modem failure */
-#ifndef MODEM_NOT_LOG
- printk(KERN_INFO "%s: modem failure!\n", card->devname);
-#endif /* MODEM_NOT_LOG */
- api_oob_event(card,mb);
- break;
-
- case 0x09: /* N2 retry limit */
- printk(KERN_INFO "%s: exceeded HDLC retry limit!\n",
- card->devname);
- api_oob_event(card,mb);
- break;
-
- case 0x06: /* unnumbered frame was received while in ABM */
- printk(KERN_INFO "%s: received Unnumbered frame 0x%02X!\n",
- card->devname, mb->data[0]);
- api_oob_event(card,mb);
- break;
-
- case CMD_TIMEOUT:
- printk(KERN_ERR "%s: command 0x%02X timed out!\n",
- card->devname, cmd)
- ;
- retry = 0; /* abort command */
- break;
-
- case X25RES_NOT_READY:
- retry = 1;
- break;
-
- case 0x01:
- if (card->u.x.LAPB_hdlc)
- break;
-
- if (mb->cmd.command == 0x16)
- break;
- /* I use the goto statement here so if
- * somebody inserts code between the
- * case and default, we will not have
- * ghost problems */
- goto dflt_2;
-
- default:
-dflt_2:
- printk(KERN_INFO "%s: command 0x%02X returned 0x%02X! Lcn %i\n",
- card->devname, cmd, err, mb->cmd.lcn)
- ;
- retry = 0; /* abort command */
- }
- kfree(mb);
- return retry;
-}
-
-/*====================================================================
- * X.25 Asynchronous Event Handlers
- * These functions are called by the x25_error() and should return 0, if
- * the command resulting in the asynchronous event must be aborted.
- *====================================================================*/
-
-
-
-/*====================================================================
- *Handle X.25 incoming call request.
- * RFC 1356 establishes the following rules:
- * 1. The first octet in the Call User Data (CUD) field of the call
- * request packet contains NLPID identifying protocol encapsulation
- * 2. Calls MUST NOT be accepted unless router supports requested
- * protocol encapsulation.
- * 3. A diagnostic code 249 defined by ISO/IEC 8208 may be used
- * when clearing a call because protocol encapsulation is not
- * supported.
- * 4. If an incoming call is received while a call request is
- * pending (i.e. call collision has occurred), the incoming call
- * shall be rejected and call request shall be retried.
- *====================================================================*/
-
-static int incoming_call (sdla_t* card, int cmd, int lcn, TX25Mbox* mb)
-{
- struct wan_device* wandev = &card->wandev;
- int new_lcn = mb->cmd.lcn;
- struct net_device* dev = get_dev_by_lcn(wandev, new_lcn);
- x25_channel_t* chan = NULL;
- int accept = 0; /* set to '1' if o.k. to accept call */
- unsigned int user_data;
- x25_call_info_t* info;
-
- /* Make sure there is no call collision */
- if (dev != NULL)
- {
- printk(KERN_INFO
- "%s: X.25 incoming call collision on LCN %d!\n",
- card->devname, new_lcn);
-
- x25_clear_call(card, new_lcn, 0, 0);
- return 1;
- }
-
- /* Make sure D bit is not set in call request */
-//FIXME: THIS IS NOT TURE !!!! TAKE IT OUT
-// if (mb->cmd.qdm & 0x02)
-// {
-// printk(KERN_INFO
-// "%s: X.25 incoming call on LCN %d with D-bit set!\n",
-// card->devname, new_lcn);
-//
-// x25_clear_call(card, new_lcn, 0, 0);
-// return 1;
-// }
-
- /* Parse call request data */
- info = kmalloc(sizeof(x25_call_info_t), GFP_ATOMIC);
- if (info == NULL)
- {
- printk(KERN_ERR
- "%s: not enough memory to parse X.25 incoming call "
- "on LCN %d!\n", card->devname, new_lcn);
- x25_clear_call(card, new_lcn, 0, 0);
- return 1;
- }
-
- parse_call_info(mb->data, info);
-
- if (card->u.x.logging)
- printk(KERN_INFO "\n%s: X.25 incoming call on LCN %d!\n",
- card->devname, new_lcn);
-
- /* Conver the first two ASCII characters into an
- * interger. Used to check the incoming protocol
- */
- user_data = hex_to_uint(info->user,2);
-
- /* Find available channel */
- for (dev = wandev->dev; dev; dev = *((struct net_device **)dev->priv)) {
- chan = dev->priv;
-
- if (chan->common.usedby == API)
- continue;
-
- if (!chan->common.svc || (chan->common.state != WAN_DISCONNECTED))
- continue;
-
- if (user_data == NLPID_IP && chan->protocol != htons(ETH_P_IP)){
- printk(KERN_INFO "IP packet but configured for IPX : %x, %x\n",
- htons(chan->protocol), info->user[0]);
- continue;
- }
-
- if (user_data == NLPID_SNAP && chan->protocol != htons(ETH_P_IPX)){
- printk(KERN_INFO "IPX packet but configured for IP: %x\n",
- htons(chan->protocol));
- continue;
- }
- if (strcmp(info->src, chan->addr) == 0)
- break;
-
- /* If just an '@' is specified, accept all incoming calls */
- if (strcmp(chan->addr, "") == 0)
- break;
- }
-
- if (dev == NULL){
-
- /* If the call is not for any WANPIPE interfaces
- * check to see if there is an API listening queue
- * waiting for data. If there is send the packet
- * up the stack.
- */
- if (card->sk != NULL && card->func != NULL){
- if (api_incoming_call(card,mb,new_lcn)){
- x25_clear_call(card, new_lcn, 0, 0);
- }
- accept = 0;
- }else{
- printk(KERN_INFO "%s: no channels available!\n",
- card->devname);
-
- x25_clear_call(card, new_lcn, 0, 0);
- }
-
- }else if (info->nuser == 0){
-
- printk(KERN_INFO
- "%s: no user data in incoming call on LCN %d!\n",
- card->devname, new_lcn)
- ;
- x25_clear_call(card, new_lcn, 0, 0);
-
- }else switch (info->user[0]){
-
- case 0: /* multiplexed */
- chan->protocol = htons(0);
- accept = 1;
- break;
-
- case NLPID_IP: /* IP datagrams */
- accept = 1;
- break;
-
- case NLPID_SNAP: /* IPX datagrams */
- accept = 1;
- break;
-
- default:
- printk(KERN_INFO
- "%s: unsupported NLPID 0x%02X in incoming call "
- "on LCN %d!\n", card->devname, info->user[0], new_lcn);
- x25_clear_call(card, new_lcn, 0, 249);
- }
-
- if (accept && (x25_accept_call(card, new_lcn, 0) == CMD_OK)){
-
- bind_lcn_to_dev (card, chan->dev, new_lcn);
-
- if (x25_get_chan_conf(card, chan) == CMD_OK)
- set_chan_state(dev, WAN_CONNECTED);
- else
- x25_clear_call(card, new_lcn, 0, 0);
- }
- kfree(info);
- return 1;
-}
-
-/*====================================================================
- * Handle accepted call.
- *====================================================================*/
-
-static int call_accepted (sdla_t* card, int cmd, int lcn, TX25Mbox* mb)
-{
- unsigned new_lcn = mb->cmd.lcn;
- struct net_device* dev = find_channel(card, new_lcn);
- x25_channel_t* chan;
-
- if (dev == NULL){
- printk(KERN_INFO
- "%s: clearing orphaned connection on LCN %d!\n",
- card->devname, new_lcn);
- x25_clear_call(card, new_lcn, 0, 0);
- return 1;
- }
-
- if (card->u.x.logging)
- printk(KERN_INFO "%s: X.25 call accepted on Dev %s and LCN %d!\n",
- card->devname, dev->name, new_lcn);
-
- /* Get channel configuration and notify router */
- chan = dev->priv;
- if (x25_get_chan_conf(card, chan) != CMD_OK)
- {
- x25_clear_call(card, new_lcn, 0, 0);
- return 1;
- }
-
- set_chan_state(dev, WAN_CONNECTED);
-
- if (chan->common.usedby == API){
- send_delayed_cmd_result(card,dev,mb);
- bind_lcn_to_dev (card, dev, new_lcn);
- }
-
- return 1;
-}
-
-/*====================================================================
- * Handle cleared call.
- *====================================================================*/
-
-static int call_cleared (sdla_t* card, int cmd, int lcn, TX25Mbox* mb)
-{
- unsigned new_lcn = mb->cmd.lcn;
- struct net_device* dev = find_channel(card, new_lcn);
- x25_channel_t *chan;
- unsigned char old_state;
-
- if (card->u.x.logging){
- printk(KERN_INFO "%s: X.25 clear request on LCN %d! Cause:0x%02X "
- "Diagn:0x%02X\n",
- card->devname, new_lcn, mb->cmd.cause, mb->cmd.diagn);
- }
-
- if (dev == NULL){
- printk(KERN_INFO "%s: X.25 clear request : No device for clear\n",
- card->devname);
- return 1;
- }
-
- chan=dev->priv;
-
- old_state = chan->common.state;
-
- set_chan_state(dev, WAN_DISCONNECTED);
-
- if (chan->common.usedby == API){
-
- switch (old_state){
-
- case WAN_CONNECTING:
- send_delayed_cmd_result(card,dev,mb);
- break;
- case WAN_CONNECTED:
- send_oob_msg(card,dev,mb);
- break;
- }
- }
-
- return ((cmd == X25_WRITE) && (lcn == new_lcn)) ? 0 : 1;
-}
-
-/*====================================================================
- * Handle X.25 restart event.
- *====================================================================*/
-
-static int restart_event (sdla_t* card, int cmd, int lcn, TX25Mbox* mb)
-{
- struct wan_device* wandev = &card->wandev;
- struct net_device* dev;
- x25_channel_t *chan;
- unsigned char old_state;
-
- printk(KERN_INFO
- "%s: X.25 restart request! Cause:0x%02X Diagn:0x%02X\n",
- card->devname, mb->cmd.cause, mb->cmd.diagn);
-
- /* down all logical channels */
- for (dev = wandev->dev; dev; dev = *((struct net_device **)dev->priv)) {
- chan=dev->priv;
- old_state = chan->common.state;
-
- set_chan_state(dev, WAN_DISCONNECTED);
-
- if (chan->common.usedby == API){
- switch (old_state){
-
- case WAN_CONNECTING:
- send_delayed_cmd_result(card,dev,mb);
- break;
- case WAN_CONNECTED:
- send_oob_msg(card,dev,mb);
- break;
- }
- }
- }
- return (cmd == X25_WRITE) ? 0 : 1;
-}
-
-/*====================================================================
- * Handle timeout event.
- *====================================================================*/
-
-static int timeout_event (sdla_t* card, int cmd, int lcn, TX25Mbox* mb)
-{
- unsigned new_lcn = mb->cmd.lcn;
-
- if (mb->cmd.pktType == 0x05) /* call request time out */
- {
- struct net_device* dev = find_channel(card,new_lcn);
-
- printk(KERN_INFO "%s: X.25 call timed timeout on LCN %d!\n",
- card->devname, new_lcn);
-
- if (dev){
- x25_channel_t *chan = dev->priv;
- set_chan_state(dev, WAN_DISCONNECTED);
-
- if (chan->common.usedby == API){
- send_delayed_cmd_result(card,dev,card->mbox);
- }
- }
- }else{
- printk(KERN_INFO "%s: X.25 packet 0x%02X timeout on LCN %d!\n",
- card->devname, mb->cmd.pktType, new_lcn);
- }
- return 1;
-}
-
-/*
- * Miscellaneous
- */
-
-/*====================================================================
- * Establish physical connection.
- * o open HDLC and raise DTR
- *
- * Return: 0 connection established
- * 1 connection is in progress
- * <0 error
- *===================================================================*/
-
-static int connect (sdla_t* card)
-{
- TX25Status* status = card->flags;
-
- if (x25_open_hdlc(card) || x25_setup_hdlc(card))
- return -EIO;
-
- wanpipe_set_state(card, WAN_CONNECTING);
-
- x25_set_intr_mode(card, INTR_ON_TIMER);
- status->imask &= ~INTR_ON_TIMER;
-
- return 1;
-}
-
-/*
- * Tear down physical connection.
- * o close HDLC link
- * o drop DTR
- *
- * Return: 0
- * <0 error
- */
-
-static int disconnect (sdla_t* card)
-{
- wanpipe_set_state(card, WAN_DISCONNECTED);
- x25_set_intr_mode(card, INTR_ON_TIMER); /* disable all interrupt except timer */
- x25_close_hdlc(card); /* close HDLC link */
- x25_set_dtr(card, 0); /* drop DTR */
- return 0;
-}
-
-/*
- * Find network device by its channel number.
- */
-
-static struct net_device* get_dev_by_lcn(struct wan_device* wandev,
- unsigned lcn)
-{
- struct net_device* dev;
-
- for (dev = wandev->dev; dev; dev = *((struct net_device **)dev->priv))
- if (((x25_channel_t*)dev->priv)->common.lcn == lcn)
- break;
- return dev;
-}
-
-/*
- * Initiate connection on the logical channel.
- * o for PVC we just get channel configuration
- * o for SVCs place an X.25 call
- *
- * Return: 0 connected
- * >0 connection in progress
- * <0 failure
- */
-
-static int chan_connect(struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
-
- if (chan->common.svc && chan->common.usedby == WANPIPE){
- if (!chan->addr[0]){
- printk(KERN_INFO "%s: No Destination Address\n",
- card->devname);
- return -EINVAL; /* no destination address */
- }
- printk(KERN_INFO "%s: placing X.25 call to %s ...\n",
- card->devname, chan->addr);
-
- if (x25_place_call(card, chan) != CMD_OK)
- return -EIO;
-
- set_chan_state(dev, WAN_CONNECTING);
- return 1;
- }else{
- if (x25_get_chan_conf(card, chan) != CMD_OK)
- return -EIO;
-
- set_chan_state(dev, WAN_CONNECTED);
- }
- return 0;
-}
-
-/*
- * Disconnect logical channel.
- * o if SVC then clear X.25 call
- */
-
-static int chan_disc(struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
-
- if (chan->common.svc){
- x25_clear_call(chan->card, chan->common.lcn, 0, 0);
-
- /* For API we disconnect on clear
- * confirmation.
- */
- if (chan->common.usedby == API)
- return 0;
- }
-
- set_chan_state(dev, WAN_DISCONNECTED);
-
- return 0;
-}
-
-/*
- * Set logical channel state.
- */
-
-static void set_chan_state(struct net_device* dev, int state)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- unsigned long flags;
-
- save_flags(flags);
- cli();
- if (chan->common.state != state)
- {
- switch (state)
- {
- case WAN_CONNECTED:
- if (card->u.x.logging){
- printk (KERN_INFO
- "%s: interface %s connected, lcn %i !\n",
- card->devname, dev->name,chan->common.lcn);
- }
- *(unsigned short*)dev->dev_addr = htons(chan->common.lcn);
- chan->i_timeout_sofar = jiffies;
-
- /* LAPB is PVC Based */
- if (card->u.x.LAPB_hdlc)
- chan->common.svc=0;
- break;
-
- case WAN_CONNECTING:
- if (card->u.x.logging){
- printk (KERN_INFO
- "%s: interface %s connecting, lcn %i ...\n",
- card->devname, dev->name, chan->common.lcn);
- }
- break;
-
- case WAN_DISCONNECTED:
- if (card->u.x.logging){
- printk (KERN_INFO
- "%s: interface %s disconnected, lcn %i !\n",
- card->devname, dev->name,chan->common.lcn);
- }
- atomic_set(&chan->common.disconnect,0);
-
- if (chan->common.svc) {
- *(unsigned short*)dev->dev_addr = 0;
- card->u.x.svc_to_dev_map[(chan->common.lcn%X25_MAX_CHAN)]=NULL;
- chan->common.lcn = 0;
- }
-
- if (chan->transmit_length){
- chan->transmit_length=0;
- atomic_set(&chan->common.driver_busy,0);
- chan->tx_offset=0;
- if (netif_queue_stopped(dev)){
- netif_wake_queue(dev);
- }
- }
- atomic_set(&chan->common.command,0);
- break;
-
- case WAN_DISCONNECTING:
- if (card->u.x.logging){
- printk (KERN_INFO
- "\n%s: interface %s disconnecting, lcn %i ...\n",
- card->devname, dev->name,chan->common.lcn);
- }
- atomic_set(&chan->common.disconnect,0);
- break;
- }
- chan->common.state = state;
- }
- chan->state_tick = jiffies;
- restore_flags(flags);
-}
-
-/*
- * Send packet on a logical channel.
- * When this function is called, tx_skb field of the channel data
- * space points to the transmit socket buffer. When transmission
- * is complete, release socket buffer and reset 'tbusy' flag.
- *
- * Return: 0 - transmission complete
- * 1 - busy
- *
- * Notes:
- * 1. If packet length is greater than MTU for this channel, we'll fragment
- * the packet into 'complete sequence' using M-bit.
- * 2. When transmission is complete, an event notification should be issued
- * to the router.
- */
-
-static int chan_send(struct net_device* dev, void* buff, unsigned data_len,
- unsigned char tx_intr)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- TX25Status* status = card->flags;
- unsigned len=0, qdm=0, res=0, orig_len = 0;
- void *data;
-
- /* Check to see if channel is ready */
- if ((!(status->cflags[chan->ch_idx] & 0x40) && !card->u.x.LAPB_hdlc) ||
- !(*card->u.x.hdlc_buf_status & 0x40)){
-
- if (!tx_intr){
- setup_for_delayed_transmit (dev, buff, data_len);
- return 0;
- }else{
- /* By returning 0 to tx_intr the packet will be dropped */
- ++card->wandev.stats.tx_dropped;
- ++chan->ifstats.tx_dropped;
- printk(KERN_INFO "%s: ERROR, Tx intr could not send, dropping %s:\n",
- card->devname,dev->name);
- ++chan->if_send_stat.if_send_bfr_not_passed_to_adptr;
- return 0;
- }
- }
-
- if (chan->common.usedby == API){
- /* Remove the API Header */
- x25api_hdr_t *api_data = (x25api_hdr_t *)buff;
-
- /* Set the qdm bits from the packet header
- * User has the option to set the qdm bits
- */
- qdm = api_data->qdm;
-
- orig_len = len = data_len - sizeof(x25api_hdr_t);
- data = (unsigned char*)buff + sizeof(x25api_hdr_t);
- }else{
- data = buff;
- orig_len = len = data_len;
- }
-
- if (tx_intr){
- /* We are in tx_intr, minus the tx_offset from
- * the total length. The tx_offset part of the
- * data has already been sent. Also, move the
- * data pointer to proper offset location.
- */
- len -= chan->tx_offset;
- data = (unsigned char*)data + chan->tx_offset;
- }
-
- /* Check if the packet length is greater than MTU
- * If YES: Cut the len to MTU and set the M bit
- */
- if (len > chan->tx_pkt_size && !card->u.x.LAPB_hdlc){
- len = chan->tx_pkt_size;
- qdm |= M_BIT;
- }
-
-
- /* Pass only first three bits of the qdm byte to the send
- * routine. In case user sets any other bit which might
- * cause errors.
- */
-
- switch(x25_send(card, chan->common.lcn, (qdm&0x07), len, data)){
- case 0x00: /* success */
- chan->i_timeout_sofar = jiffies;
-
- dev->trans_start=jiffies;
-
- if ((qdm & M_BIT) && !card->u.x.LAPB_hdlc){
- if (!tx_intr){
- /* The M bit was set, which means that part of the
- * packet has been sent. Copy the packet into a buffer
- * and set the offset to len, so on next tx_inter
- * the packet will be sent using the below offset.
- */
- chan->tx_offset += len;
-
- ++chan->ifstats.tx_packets;
- chan->ifstats.tx_bytes += len;
-
- if (chan->tx_offset < orig_len){
- setup_for_delayed_transmit (dev, buff, data_len);
- }
- res=0;
- }else{
- /* We are already in tx_inter, thus data is already
- * in the buffer. Update the offset and wait for
- * next tx_intr. We add on to the offset, since data can
- * be X number of times larger than max data size.
- */
- ++chan->ifstats.tx_packets;
- chan->ifstats.tx_bytes += len;
-
- ++chan->if_send_stat.if_send_bfr_passed_to_adptr;
- chan->tx_offset += len;
-
- /* The user can set the qdm bit as well.
- * If the entire packet was sent and qdm is still
- * set, than it's the user who has set the M bit. In that,
- * case indicate that the packet was send by returning
- * 0 and wait for a new packet. Otherwise, wait for next
- * tx interrupt to send the rest of the packet */
-
- if (chan->tx_offset < orig_len){
- res=1;
- }else{
- res=0;
- }
- }
- }else{
- ++chan->ifstats.tx_packets;
- chan->ifstats.tx_bytes += len;
- ++chan->if_send_stat.if_send_bfr_passed_to_adptr;
- res=0;
- }
- break;
-
- case 0x33: /* Tx busy */
- if (tx_intr){
- printk(KERN_INFO "%s: Tx_intr: Big Error dropping packet %s\n",
- card->devname,dev->name);
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- ++chan->if_send_stat.if_send_bfr_not_passed_to_adptr;
- res=0;
- }else{
- DBG_PRINTK(KERN_INFO
- "%s: Send: Big Error should have tx: storring %s\n",
- card->devname,dev->name);
- setup_for_delayed_transmit (dev, buff, data_len);
- res=1;
- }
- break;
-
- default: /* failure */
- ++chan->ifstats.tx_errors;
- if (tx_intr){
- printk(KERN_INFO "%s: Tx_intr: Failure to send, dropping %s\n",
- card->devname,dev->name);
- ++chan->ifstats.tx_dropped;
- ++card->wandev.stats.tx_dropped;
- ++chan->if_send_stat.if_send_bfr_not_passed_to_adptr;
- res=0;
- }else{
- DBG_PRINTK(KERN_INFO "%s: Send: Failure to send !!!, storing %s\n",
- card->devname,dev->name);
- setup_for_delayed_transmit (dev, buff, data_len);
- res=1;
- }
- break;
- }
- return res;
-}
-
-
-/*
- * Parse X.25 call request data and fill x25_call_info_t structure.
- */
-
-static void parse_call_info (unsigned char* str, x25_call_info_t* info)
-{
- memset(info, 0, sizeof(x25_call_info_t));
- for (; *str; ++str)
- {
- int i;
- unsigned char ch;
-
- if (*str == '-') switch (str[1]) {
-
- /* Take minus 2 off the maximum size so that
- * last byte is 0. This way we can use string
- * manipulaton functions on call information.
- */
-
- case 'd': /* destination address */
- for (i = 0; i < (MAX_X25_ADDR_SIZE-2); ++i){
- ch = str[2+i];
- if (isspace(ch)) break;
- info->dest[i] = ch;
- }
- break;
-
- case 's': /* source address */
- for (i = 0; i < (MAX_X25_ADDR_SIZE-2); ++i){
- ch = str[2+i];
- if (isspace(ch)) break;
- info->src[i] = ch;
- }
- break;
-
- case 'u': /* user data */
- for (i = 0; i < (MAX_X25_DATA_SIZE-2); ++i){
- ch = str[2+i];
- if (isspace(ch)) break;
- info->user[i] = ch;
- }
- info->nuser = i;
- break;
-
- case 'f': /* facilities */
- for (i = 0; i < (MAX_X25_FACL_SIZE-2); ++i){
- ch = str[2+i];
- if (isspace(ch)) break;
- info->facil[i] = ch;
- }
- info->nfacil = i;
- break;
- }
- }
-}
-
-/*
- * Convert line speed in bps to a number used by S502 code.
- */
-
-static unsigned char bps_to_speed_code (unsigned long bps)
-{
- unsigned char number;
-
- if (bps <= 1200) number = 0x01;
- else if (bps <= 2400) number = 0x02;
- else if (bps <= 4800) number = 0x03;
- else if (bps <= 9600) number = 0x04;
- else if (bps <= 19200) number = 0x05;
- else if (bps <= 38400) number = 0x06;
- else if (bps <= 45000) number = 0x07;
- else if (bps <= 56000) number = 0x08;
- else if (bps <= 64000) number = 0x09;
- else if (bps <= 74000) number = 0x0A;
- else if (bps <= 112000) number = 0x0B;
- else if (bps <= 128000) number = 0x0C;
- else number = 0x0D;
-
- return number;
-}
-
-/*
- * Convert decimal string to unsigned integer.
- * If len != 0 then only 'len' characters of the string are converted.
- */
-
-static unsigned int dec_to_uint (unsigned char* str, int len)
-{
- unsigned val;
-
- if (!len)
- len = strlen(str);
-
- for (val = 0; len && isdigit(*str); ++str, --len)
- val = (val * 10) + (*str - (unsigned)'0');
-
- return val;
-}
-
-/*
- * Convert hex string to unsigned integer.
- * If len != 0 then only 'len' characters of the string are conferted.
- */
-
-static unsigned int hex_to_uint (unsigned char* str, int len)
-{
- unsigned val, ch;
-
- if (!len)
- len = strlen(str);
-
- for (val = 0; len; ++str, --len)
- {
- ch = *str;
- if (isdigit(ch))
- val = (val << 4) + (ch - (unsigned)'0');
- else if (isxdigit(ch))
- val = (val << 4) + ((ch & 0xDF) - (unsigned)'A' + 10);
- else break;
- }
- return val;
-}
-
-
-static int handle_IPXWAN(unsigned char *sendpacket, char *devname, unsigned char enable_IPX, unsigned long network_number, unsigned short proto)
-{
- int i;
-
- if( proto == ETH_P_IPX) {
- /* It's an IPX packet */
- if(!enable_IPX) {
- /* Return 1 so we don't pass it up the stack. */
- return 1;
- }
- } else {
- /* It's not IPX so pass it up the stack.*/
- return 0;
- }
-
- if( sendpacket[16] == 0x90 &&
- sendpacket[17] == 0x04)
- {
- /* It's IPXWAN */
-
- if( sendpacket[2] == 0x02 &&
- sendpacket[34] == 0x00)
- {
- /* It's a timer request packet */
- printk(KERN_INFO "%s: Received IPXWAN Timer Request packet\n",devname);
-
- /* Go through the routing options and answer no to every
- * option except Unnumbered RIP/SAP
- */
- for(i = 41; sendpacket[i] == 0x00; i += 5)
- {
- /* 0x02 is the option for Unnumbered RIP/SAP */
- if( sendpacket[i + 4] != 0x02)
- {
- sendpacket[i + 1] = 0;
- }
- }
-
- /* Skip over the extended Node ID option */
- if( sendpacket[i] == 0x04 )
- {
- i += 8;
- }
-
- /* We also want to turn off all header compression opt. */
- for(; sendpacket[i] == 0x80 ;)
- {
- sendpacket[i + 1] = 0;
- i += (sendpacket[i + 2] << 8) + (sendpacket[i + 3]) + 4;
- }
-
- /* Set the packet type to timer response */
- sendpacket[34] = 0x01;
-
- printk(KERN_INFO "%s: Sending IPXWAN Timer Response\n",devname);
- }
- else if( sendpacket[34] == 0x02 )
- {
- /* This is an information request packet */
- printk(KERN_INFO "%s: Received IPXWAN Information Request packet\n",devname);
-
- /* Set the packet type to information response */
- sendpacket[34] = 0x03;
-
- /* Set the router name */
- sendpacket[51] = 'X';
- sendpacket[52] = 'T';
- sendpacket[53] = 'P';
- sendpacket[54] = 'I';
- sendpacket[55] = 'P';
- sendpacket[56] = 'E';
- sendpacket[57] = '-';
- sendpacket[58] = CVHexToAscii(network_number >> 28);
- sendpacket[59] = CVHexToAscii((network_number & 0x0F000000)>> 24);
- sendpacket[60] = CVHexToAscii((network_number & 0x00F00000)>> 20);
- sendpacket[61] = CVHexToAscii((network_number & 0x000F0000)>> 16);
- sendpacket[62] = CVHexToAscii((network_number & 0x0000F000)>> 12);
- sendpacket[63] = CVHexToAscii((network_number & 0x00000F00)>> 8);
- sendpacket[64] = CVHexToAscii((network_number & 0x000000F0)>> 4);
- sendpacket[65] = CVHexToAscii(network_number & 0x0000000F);
- for(i = 66; i < 99; i+= 1)
- {
- sendpacket[i] = 0;
- }
-
- printk(KERN_INFO "%s: Sending IPXWAN Information Response packet\n",devname);
- }
- else
- {
- printk(KERN_INFO "%s: Unknown IPXWAN packet!\n",devname);
- return 0;
- }
-
- /* Set the WNodeID to our network address */
- sendpacket[35] = (unsigned char)(network_number >> 24);
- sendpacket[36] = (unsigned char)((network_number & 0x00FF0000) >> 16);
- sendpacket[37] = (unsigned char)((network_number & 0x0000FF00) >> 8);
- sendpacket[38] = (unsigned char)(network_number & 0x000000FF);
-
- return 1;
- } else {
- /*If we get here it's an IPX-data packet, so it'll get passed up the stack.
- */
- /* switch the network numbers */
- switch_net_numbers(sendpacket, network_number, 1);
- return 0;
- }
-}
-
-/*
- * If incoming is 0 (outgoing)- if the net numbers is ours make it 0
- * if incoming is 1 - if the net number is 0 make it ours
- */
-
-static void switch_net_numbers(unsigned char *sendpacket, unsigned long network_number, unsigned char incoming)
-{
- unsigned long pnetwork_number;
-
- pnetwork_number = (unsigned long)((sendpacket[6] << 24) +
- (sendpacket[7] << 16) + (sendpacket[8] << 8) +
- sendpacket[9]);
-
-
- if (!incoming) {
- /*If the destination network number is ours, make it 0 */
- if( pnetwork_number == network_number) {
- sendpacket[6] = sendpacket[7] = sendpacket[8] =
- sendpacket[9] = 0x00;
- }
- } else {
- /* If the incoming network is 0, make it ours */
- if( pnetwork_number == 0) {
- sendpacket[6] = (unsigned char)(network_number >> 24);
- sendpacket[7] = (unsigned char)((network_number &
- 0x00FF0000) >> 16);
- sendpacket[8] = (unsigned char)((network_number &
- 0x0000FF00) >> 8);
- sendpacket[9] = (unsigned char)(network_number &
- 0x000000FF);
- }
- }
-
-
- pnetwork_number = (unsigned long)((sendpacket[18] << 24) +
- (sendpacket[19] << 16) + (sendpacket[20] << 8) +
- sendpacket[21]);
-
-
- if( !incoming ) {
- /* If the source network is ours, make it 0 */
- if( pnetwork_number == network_number) {
- sendpacket[18] = sendpacket[19] = sendpacket[20] =
- sendpacket[21] = 0x00;
- }
- } else {
- /* If the source network is 0, make it ours */
- if( pnetwork_number == 0 ) {
- sendpacket[18] = (unsigned char)(network_number >> 24);
- sendpacket[19] = (unsigned char)((network_number &
- 0x00FF0000) >> 16);
- sendpacket[20] = (unsigned char)((network_number &
- 0x0000FF00) >> 8);
- sendpacket[21] = (unsigned char)(network_number &
- 0x000000FF);
- }
- }
-} /* switch_net_numbers */
-
-
-
-
-/********************* X25API SPECIFIC FUNCTIONS ****************/
-
-
-/*===============================================================
- * find_channel
- *
- * Manages the lcn to device map. It increases performance
- * because it eliminates the need to search through the link
- * list for a device which is bounded to a specific lcn.
- *
- *===============================================================*/
-
-
-struct net_device *find_channel(sdla_t *card, unsigned lcn)
-{
- if (card->u.x.LAPB_hdlc){
-
- return card->wandev.dev;
-
- }else{
- /* We don't know whether the incoming lcn
- * is a PVC or an SVC channel. But we do know that
- * the lcn cannot be for both the PVC and the SVC
- * channel.
-
- * If the lcn number is greater or equal to 255,
- * take the modulo 255 of that number. We only have
- * 255 locations, thus higher numbers must be mapped
- * to a number between 0 and 245.
-
- * We must separate pvc's and svc's since two don't
- * have to be contiguous. Meaning pvc's can start
- * from 1 to 10 and svc's can start from 256 to 266.
- * But 256%255 is 1, i.e. CONFLICT.
- */
-
-
- /* Highest LCN number must be less or equal to 4096 */
- if ((lcn <= MAX_LCN_NUM) && (lcn > 0)){
-
- if (lcn < X25_MAX_CHAN){
- if (card->u.x.svc_to_dev_map[lcn])
- return card->u.x.svc_to_dev_map[lcn];
-
- if (card->u.x.pvc_to_dev_map[lcn])
- return card->u.x.pvc_to_dev_map[lcn];
-
- }else{
- int new_lcn = lcn%X25_MAX_CHAN;
- if (card->u.x.svc_to_dev_map[new_lcn])
- return card->u.x.svc_to_dev_map[new_lcn];
-
- if (card->u.x.pvc_to_dev_map[new_lcn])
- return card->u.x.pvc_to_dev_map[new_lcn];
- }
- }
- return NULL;
- }
-}
-
-void bind_lcn_to_dev(sdla_t *card, struct net_device *dev, unsigned lcn)
-{
- x25_channel_t *chan = dev->priv;
-
- /* Modulo the lcn number by X25_MAX_CHAN (255)
- * because the lcn number can be greater than 255
- *
- * We need to split svc and pvc since they don't have
- * to be contigous.
- */
-
- if (chan->common.svc){
- card->u.x.svc_to_dev_map[(lcn % X25_MAX_CHAN)] = dev;
- }else{
- card->u.x.pvc_to_dev_map[(lcn % X25_MAX_CHAN)] = dev;
- }
- chan->common.lcn = lcn;
-}
-
-
-
-/*===============================================================
- * x25api_bh
- *
- *
- *==============================================================*/
-
-static void x25api_bh(struct net_device* dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t* card = chan->card;
- struct sk_buff *skb;
-
- if (atomic_read(&chan->bh_buff_used) == 0){
- printk(KERN_INFO "%s: BH Buffer Empty in BH\n",
- card->devname);
- clear_bit(0, &chan->tq_working);
- return;
- }
-
- while (atomic_read(&chan->bh_buff_used)){
-
- /* If the sock is in the process of unlinking the
- * driver from the socket, we must get out.
- * This never happends but is a sanity check. */
- if (test_bit(0,&chan->common.common_critical)){
- clear_bit(0, &chan->tq_working);
- return;
- }
-
- /* If LAPB HDLC, do not drop packets if socket is
- * not connected. Let the buffer fill up and
- * turn off rx interrupt */
- if (card->u.x.LAPB_hdlc){
- if (chan->common.sk == NULL || chan->common.func == NULL){
- clear_bit(0, &chan->tq_working);
- return;
- }
- }
-
- skb = ((bh_data_t *)&chan->bh_head[chan->bh_read])->skb;
-
- if (skb == NULL){
- printk(KERN_INFO "%s: BH Skb empty for read %i\n",
- card->devname,chan->bh_read);
- }else{
-
- if (chan->common.sk == NULL || chan->common.func == NULL){
- printk(KERN_INFO "%s: BH: Socket disconnected, dropping\n",
- card->devname);
- dev_kfree_skb_any(skb);
- x25api_bh_cleanup(dev);
- ++chan->ifstats.rx_dropped;
- ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack;
- continue;
- }
-
-
- if (chan->common.func(skb,dev,chan->common.sk) != 0){
- /* Sock full cannot send, queue us for another
- * try
- */
- printk(KERN_INFO "%s: BH: !!! Packet failed to send !!!!! \n",
- card->devname);
- atomic_set(&chan->common.receive_block,1);
- return;
- }else{
- x25api_bh_cleanup(dev);
- ++chan->rx_intr_stat.rx_intr_bfr_passed_to_stack;
- }
- }
- }
- clear_bit(0, &chan->tq_working);
-
- return;
-}
-
-/*===============================================================
- * x25api_bh_cleanup
- *
- *
- *==============================================================*/
-
-static int x25api_bh_cleanup(struct net_device *dev)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t *card = chan->card;
- TX25Status* status = card->flags;
-
-
- ((bh_data_t *)&chan->bh_head[chan->bh_read])->skb = NULL;
-
- if (chan->bh_read == MAX_BH_BUFF){
- chan->bh_read=0;
- }else{
- ++chan->bh_read;
- }
-
- /* If the Receive interrupt was off, it means
- * that we filled up our circular buffer. Check
- * that we have space in the buffer. If so
- * turn the RX interrupt back on.
- */
- if (!(status->imask & INTR_ON_RX_FRAME)){
- if (atomic_read(&chan->bh_buff_used) < (MAX_BH_BUFF+1)){
- printk(KERN_INFO "%s: BH: Turning on the interrupt\n",
- card->devname);
- status->imask |= INTR_ON_RX_FRAME;
- }
- }
-
- atomic_dec(&chan->bh_buff_used);
- return 0;
-}
-
-
-/*===============================================================
- * bh_enqueue
- *
- *
- *==============================================================*/
-
-static int bh_enqueue(struct net_device *dev, struct sk_buff *skb)
-{
- x25_channel_t* chan = dev->priv;
- sdla_t *card = chan->card;
- TX25Status* status = card->flags;
-
- if (atomic_read(&chan->bh_buff_used) == (MAX_BH_BUFF+1)){
- printk(KERN_INFO "%s: Bottom half buffer FULL\n",
- card->devname);
- return 1;
- }
-
- ((bh_data_t *)&chan->bh_head[chan->bh_write])->skb = skb;
-
- if (chan->bh_write == MAX_BH_BUFF){
- chan->bh_write=0;
- }else{
- ++chan->bh_write;
- }
-
- atomic_inc(&chan->bh_buff_used);
-
- if (atomic_read(&chan->bh_buff_used) == (MAX_BH_BUFF+1)){
- printk(KERN_INFO "%s: Buffer is now full, Turning off RX Intr\n",
- card->devname);
- status->imask &= ~INTR_ON_RX_FRAME;
- }
-
- return 0;
-}
-
-
-/*===============================================================
- * timer_intr_cmd_exec
- *
- * Called by timer interrupt to execute a command
- *===============================================================*/
-
-static int timer_intr_cmd_exec (sdla_t* card)
-{
- struct net_device *dev;
- unsigned char more_to_exec=0;
- volatile x25_channel_t *chan=NULL;
- int i=0,bad_cmd=0,err=0;
-
- if (card->u.x.cmd_dev == NULL){
- card->u.x.cmd_dev = card->wandev.dev;
- }
-
- dev = card->u.x.cmd_dev;
-
- for (;;){
-
- chan = dev->priv;
-
- if (atomic_read(&chan->common.command)){
-
- bad_cmd = check_bad_command(card,dev);
-
- if ((!chan->common.mbox || atomic_read(&chan->common.disconnect)) &&
- !bad_cmd){
-
- /* Socket has died or exited, We must bring the
- * channel down before anybody else tries to
- * use it */
- err = channel_disconnect(card,dev);
- }else{
- err = execute_delayed_cmd(card, dev,
- (mbox_cmd_t*)chan->common.mbox,
- bad_cmd);
- }
-
- switch (err){
-
- case RETURN_RESULT:
-
- /* Return the result to the socket without
- * delay. NO_WAIT Command */
- atomic_set(&chan->common.command,0);
- if (atomic_read(&card->u.x.command_busy))
- atomic_set(&card->u.x.command_busy,0);
-
- send_delayed_cmd_result(card,dev,card->mbox);
-
- more_to_exec=0;
- break;
- case DELAY_RESULT:
-
- /* Wait for the remote to respond, before
- * sending the result up to the socket.
- * WAIT command */
- if (atomic_read(&card->u.x.command_busy))
- atomic_set(&card->u.x.command_busy,0);
-
- atomic_set(&chan->common.command,0);
- more_to_exec=0;
- break;
- default:
-
- /* If command could not be executed for
- * some reason (i.e return code 0x33 busy)
- * set the more_to_exec bit which will
- * indicate that this command must be exectued
- * again during next timer interrupt
- */
- more_to_exec=1;
- if (atomic_read(&card->u.x.command_busy) == 0)
- atomic_set(&card->u.x.command_busy,1);
- break;
- }
-
- bad_cmd=0;
-
- /* If flags is set, there are no hdlc buffers,
- * thus, wait for the next pass and try the
- * same command again. Otherwise, start searching
- * from next device on the next pass.
- */
- if (!more_to_exec){
- dev = move_dev_to_next(card,dev);
- }
- break;
- }else{
- /* This device has nothing to execute,
- * go to next.
- */
- if (atomic_read(&card->u.x.command_busy))
- atomic_set(&card->u.x.command_busy,0);
- dev = move_dev_to_next(card,dev);
- }
-
- if (++i == card->u.x.no_dev){
- if (!more_to_exec){
- DBG_PRINTK(KERN_INFO "%s: Nothing to execute in Timer\n",
- card->devname);
- if (atomic_read(&card->u.x.command_busy)){
- atomic_set(&card->u.x.command_busy,0);
- }
- }
- break;
- }
-
- } //End of FOR
-
- card->u.x.cmd_dev = dev;
-
- if (more_to_exec){
- /* If more commands are pending, do not turn off timer
- * interrupt */
- return 1;
- }else{
- /* No more commands, turn off timer interrupt */
- return 0;
- }
-}
-
-/*===============================================================
- * execute_delayed_cmd
- *
- * Execute an API command which was passed down from the
- * sock. Sock is very limited in which commands it can
- * execute. Wait and No Wait commands are supported.
- * Place Call, Clear Call and Reset wait commands, where
- * Accept Call is a no_wait command.
- *
- *===============================================================*/
-
-static int execute_delayed_cmd(sdla_t* card, struct net_device *dev,
- mbox_cmd_t *usr_cmd, char bad_cmd)
-{
- TX25Mbox* mbox = card->mbox;
- int err;
- x25_channel_t *chan = dev->priv;
- int delay=RETURN_RESULT;
-
- if (!(*card->u.x.hdlc_buf_status & 0x40) && !bad_cmd){
- return TRY_CMD_AGAIN;
- }
-
- /* This way a command is guaranteed to be executed for
- * a specific lcn, the network interface is bound to. */
- usr_cmd->cmd.lcn = chan->common.lcn;
-
-
- /* If channel is pvc, instead of place call
- * run x25_channel configuration. If running LAPB HDLC
- * enable communications.
- */
- if ((!chan->common.svc) && (usr_cmd->cmd.command == X25_PLACE_CALL)){
-
- if (card->u.x.LAPB_hdlc){
- DBG_PRINTK(KERN_INFO "LAPB: Connecting\n");
- connect(card);
- set_chan_state(dev,WAN_CONNECTING);
- return DELAY_RESULT;
- }else{
- DBG_PRINTK(KERN_INFO "%s: PVC is CONNECTING\n",card->devname);
- if (x25_get_chan_conf(card, chan) == CMD_OK){
- set_chan_state(dev, WAN_CONNECTED);
- }else{
- set_chan_state(dev, WAN_DISCONNECTED);
- }
- return RETURN_RESULT;
- }
- }
-
- /* Copy the socket mbox command onto the board */
-
- memcpy(&mbox->cmd, &usr_cmd->cmd, sizeof(TX25Cmd));
- if (usr_cmd->cmd.length){
- memcpy(mbox->data, usr_cmd->data, usr_cmd->cmd.length);
- }
-
- /* Check if command is bad. We need to copy the cmd into
- * the buffer regardless since we return the, mbox to
- * the user */
- if (bad_cmd){
- mbox->cmd.result=0x01;
- return RETURN_RESULT;
- }
-
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- if (err != CMD_OK && err != X25RES_NOT_READY)
- x25_error(card, err, usr_cmd->cmd.command, usr_cmd->cmd.lcn);
-
- if (mbox->cmd.result == X25RES_NOT_READY){
- return TRY_CMD_AGAIN;
- }
-
- switch (mbox->cmd.command){
-
- case X25_PLACE_CALL:
-
- switch (mbox->cmd.result){
-
- case CMD_OK:
-
- /* Check if Place call is a wait command or a
- * no wait command */
- if (atomic_read(&chan->common.command) & 0x80)
- delay=RETURN_RESULT;
- else
- delay=DELAY_RESULT;
-
-
- DBG_PRINTK(KERN_INFO "\n%s: PLACE CALL Binding dev %s to lcn %i\n",
- card->devname,dev->name, mbox->cmd.lcn);
-
- bind_lcn_to_dev (card, dev, mbox->cmd.lcn);
- set_chan_state(dev, WAN_CONNECTING);
- break;
-
-
- default:
- delay=RETURN_RESULT;
- set_chan_state(dev, WAN_DISCONNECTED);
- break;
- }
- break;
-
- case X25_ACCEPT_CALL:
-
- switch (mbox->cmd.result){
-
- case CMD_OK:
-
- DBG_PRINTK(KERN_INFO "\n%s: ACCEPT Binding dev %s to lcn %i\n",
- card->devname,dev->name,mbox->cmd.lcn);
-
- bind_lcn_to_dev (card, dev, mbox->cmd.lcn);
-
- if (x25_get_chan_conf(card, chan) == CMD_OK){
-
- set_chan_state(dev, WAN_CONNECTED);
- delay=RETURN_RESULT;
-
- }else{
- if (x25_clear_call(card, usr_cmd->cmd.lcn, 0, 0) == CMD_OK){
- /* if clear is successful, wait for clear confirm
- */
- delay=DELAY_RESULT;
- }else{
- /* Do not change the state here. If we fail
- * the accept the return code is send up
- *the stack, which will ether retry
- * or clear the call
- */
- DBG_PRINTK(KERN_INFO
- "%s: ACCEPT: STATE MAY BE CURRUPTED 2 !!!!!\n",
- card->devname);
- delay=RETURN_RESULT;
- }
- }
- break;
-
-
- case X25RES_ASYNC_PACKET:
- delay=TRY_CMD_AGAIN;
- break;
-
- default:
- DBG_PRINTK(KERN_INFO "%s: ACCEPT FAILED\n",card->devname);
- if (x25_clear_call(card, usr_cmd->cmd.lcn, 0, 0) == CMD_OK){
- delay=DELAY_RESULT;
- }else{
- /* Do not change the state here. If we fail the accept. The
- * return code is send up the stack, which will ether retry
- * or clear the call */
- DBG_PRINTK(KERN_INFO
- "%s: ACCEPT: STATE MAY BE CORRUPTED 1 !!!!!\n",
- card->devname);
- delay=RETURN_RESULT;
- }
- }
- break;
-
- case X25_CLEAR_CALL:
-
- switch (mbox->cmd.result){
-
- case CMD_OK:
- DBG_PRINTK(KERN_INFO
- "CALL CLEAR OK: Dev %s Mbox Lcn %i Chan Lcn %i\n",
- dev->name,mbox->cmd.lcn,chan->common.lcn);
- set_chan_state(dev, WAN_DISCONNECTING);
- delay = DELAY_RESULT;
- break;
-
- case X25RES_CHANNEL_IN_USE:
- case X25RES_ASYNC_PACKET:
- delay = TRY_CMD_AGAIN;
- break;
-
- case X25RES_LINK_NOT_IN_ABM:
- case X25RES_INVAL_LCN:
- case X25RES_INVAL_STATE:
- set_chan_state(dev, WAN_DISCONNECTED);
- delay = RETURN_RESULT;
- break;
-
- default:
- /* If command did not execute because of user
- * fault, do not change the state. This will
- * signal the socket that clear command failed.
- * User can retry or close the socket.
- * When socket gets killed, it will set the
- * chan->disconnect which will signal
- * driver to clear the call */
- printk(KERN_INFO "%s: Clear Command Failed, Rc %x\n",
- card->devname,mbox->cmd.command);
- delay = RETURN_RESULT;
- }
- break;
- }
-
- return delay;
-}
-
-/*===============================================================
- * api_incoming_call
- *
- * Pass an incoming call request up the listening
- * sock. If the API sock is not listening reject the
- * call.
- *
- *===============================================================*/
-
-static int api_incoming_call (sdla_t* card, TX25Mbox *mbox, int lcn)
-{
- struct sk_buff *skb;
- int len = sizeof(TX25Cmd)+mbox->cmd.length;
-
- if (alloc_and_init_skb_buf(card, &skb, len)){
- printk(KERN_INFO "%s: API incoming call, no memory\n",card->devname);
- return 1;
- }
-
- memcpy(skb_put(skb,len),&mbox->cmd,len);
-
- skb->mac.raw = skb->data;
- skb->protocol = htons(X25_PROT);
- skb->pkt_type = WAN_PACKET_ASYNC;
-
- if (card->func(skb,card->sk) < 0){
- printk(KERN_INFO "%s: MAJOR ERROR: Failed to send up place call \n",card->devname);
- dev_kfree_skb_any(skb);
- return 1;
- }
-
- return 0;
-}
-
-/*===============================================================
- * send_delayed_cmd_result
- *
- * Wait commands like PLEACE CALL or CLEAR CALL must wait
- * until the result arrives. This function passes
- * the result to a waiting sock.
- *
- *===============================================================*/
-static void send_delayed_cmd_result(sdla_t *card, struct net_device *dev,
- TX25Mbox* mbox)
-{
- x25_channel_t *chan = dev->priv;
- mbox_cmd_t *usr_cmd = (mbox_cmd_t *)chan->common.mbox;
- struct sk_buff *skb;
- int len=sizeof(unsigned char);
-
- atomic_set(&chan->common.command,0);
-
- /* If the sock is in the process of unlinking the
- * driver from the socket, we must get out.
- * This never happends but is a sanity check. */
- if (test_bit(0,&chan->common.common_critical)){
- return;
- }
-
- if (!usr_cmd || !chan->common.sk || !chan->common.func){
- DBG_PRINTK(KERN_INFO "Delay result: Sock not bounded sk: %u, func: %u, mbox: %u\n",
- (unsigned int)chan->common.sk,
- (unsigned int)chan->common.func,
- (unsigned int)usr_cmd);
- return;
- }
-
- memcpy(&usr_cmd->cmd, &mbox->cmd, sizeof(TX25Cmd));
- if (mbox->cmd.length > 0){
- memcpy(usr_cmd->data, mbox->data, mbox->cmd.length);
- }
-
- if (alloc_and_init_skb_buf(card,&skb,len)){
- printk(KERN_INFO "Delay result: No sock buffers\n");
- return;
- }
-
- memcpy(skb_put(skb,len),&mbox->cmd.command,len);
-
- skb->mac.raw = skb->data;
- skb->pkt_type = WAN_PACKET_CMD;
-
- chan->common.func(skb,dev,chan->common.sk);
-}
-
-/*===============================================================
- * clear_confirm_event
- *
- * Pass the clear confirmation event up the sock. The
- * API will disconnect only after the clear confirmation
- * has been received.
- *
- * Depending on the state, clear confirmation could
- * be an OOB event, or a result of an API command.
- *===============================================================*/
-
-static int clear_confirm_event (sdla_t *card, TX25Mbox* mb)
-{
- struct net_device *dev;
- x25_channel_t *chan;
- unsigned char old_state;
-
- dev = find_channel(card,mb->cmd.lcn);
- if (!dev){
- DBG_PRINTK(KERN_INFO "%s: *** GOT CLEAR BUT NO DEV %i\n",
- card->devname,mb->cmd.lcn);
- return 0;
- }
-
- chan=dev->priv;
- DBG_PRINTK(KERN_INFO "%s: GOT CLEAR CONFIRM %s: Mbox lcn %i Chan lcn %i\n",
- card->devname, dev->name, mb->cmd.lcn, chan->common.lcn);
-
- /* If not API fall through to default.
- * If API, send the result to a waiting
- * socket.
- */
-
- old_state = chan->common.state;
- set_chan_state(dev, WAN_DISCONNECTED);
-
- if (chan->common.usedby == API){
- switch (old_state) {
-
- case WAN_DISCONNECTING:
- case WAN_CONNECTING:
- send_delayed_cmd_result(card,dev,mb);
- break;
- case WAN_CONNECTED:
- send_oob_msg(card,dev,mb);
- break;
- }
- return 1;
- }
-
- return 0;
-}
-
-/*===============================================================
- * send_oob_msg
- *
- * Construct an NEM Message and pass it up the connected
- * sock. If the sock is not bounded discard the NEM.
- *
- *===============================================================*/
-
-static void send_oob_msg(sdla_t *card, struct net_device *dev, TX25Mbox *mbox)
-{
- x25_channel_t *chan = dev->priv;
- mbox_cmd_t *usr_cmd = (mbox_cmd_t *)chan->common.mbox;
- struct sk_buff *skb;
- int len=sizeof(x25api_hdr_t)+mbox->cmd.length;
- x25api_t *api_hdr;
-
- /* If the sock is in the process of unlinking the
- * driver from the socket, we must get out.
- * This never happends but is a sanity check. */
- if (test_bit(0,&chan->common.common_critical)){
- return;
- }
-
- if (!usr_cmd || !chan->common.sk || !chan->common.func){
- DBG_PRINTK(KERN_INFO "OOB MSG: Sock not bounded\n");
- return;
- }
-
- memcpy(&usr_cmd->cmd, &mbox->cmd, sizeof(TX25Cmd));
- if (mbox->cmd.length > 0){
- memcpy(usr_cmd->data, mbox->data, mbox->cmd.length);
- }
-
- if (alloc_and_init_skb_buf(card,&skb,len)){
- printk(KERN_INFO "%s: OOB MSG: No sock buffers\n",card->devname);
- return;
- }
-
- api_hdr = (x25api_t*)skb_put(skb,len);
- api_hdr->hdr.pktType = mbox->cmd.pktType & 0x7F;
- api_hdr->hdr.qdm = mbox->cmd.qdm;
- api_hdr->hdr.cause = mbox->cmd.cause;
- api_hdr->hdr.diagn = mbox->cmd.diagn;
- api_hdr->hdr.length = mbox->cmd.length;
- api_hdr->hdr.result = mbox->cmd.result;
- api_hdr->hdr.lcn = mbox->cmd.lcn;
-
- if (mbox->cmd.length > 0){
- memcpy(api_hdr->data,mbox->data,mbox->cmd.length);
- }
-
- skb->mac.raw = skb->data;
- skb->pkt_type = WAN_PACKET_ERR;
-
- if (chan->common.func(skb,dev,chan->common.sk) < 0){
- if (bh_enqueue(dev,skb)){
- printk(KERN_INFO "%s: Dropping OOB MSG\n",card->devname);
- dev_kfree_skb_any(skb);
- }
- }
-
- DBG_PRINTK(KERN_INFO "%s: OOB MSG OK, %s, lcn %i\n",
- card->devname, dev->name, mbox->cmd.lcn);
-}
-
-/*===============================================================
- * alloc_and_init_skb_buf
- *
- * Allocate and initialize an skb buffer.
- *
- *===============================================================*/
-
-static int alloc_and_init_skb_buf (sdla_t *card, struct sk_buff **skb, int len)
-{
- struct sk_buff *new_skb = *skb;
-
- new_skb = dev_alloc_skb(len + X25_HRDHDR_SZ);
- if (new_skb == NULL){
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- return 1;
- }
-
- if (skb_tailroom(new_skb) < len){
- /* No room for the packet. Call off the whole thing! */
- dev_kfree_skb_any(new_skb);
- printk(KERN_INFO "%s: Listen: unexpectedly long packet sequence\n"
- ,card->devname);
- *skb = NULL;
- return 1;
- }
-
- *skb = new_skb;
- return 0;
-
-}
-
-/*===============================================================
- * api_oob_event
- *
- * Send an OOB event up to the sock
- *
- *===============================================================*/
-
-static void api_oob_event (sdla_t *card,TX25Mbox *mbox)
-{
- struct net_device *dev = find_channel(card, mbox->cmd.lcn);
- x25_channel_t *chan;
-
- if (!dev)
- return;
-
- chan=dev->priv;
-
- if (chan->common.usedby == API)
- send_oob_msg(card,dev,mbox);
-
-}
-
-
-
-
-static int channel_disconnect(sdla_t* card, struct net_device *dev)
-{
-
- int err;
- x25_channel_t *chan = dev->priv;
-
- DBG_PRINTK(KERN_INFO "%s: TIMER: %s, Device down disconnecting\n",
- card->devname,dev->name);
-
- if (chan->common.svc){
- err = x25_clear_call(card,chan->common.lcn,0,0);
- }else{
- /* If channel is PVC or LAPB HDLC, there is no call
- * to be cleared, thus drop down to the default
- * area
- */
- err = 1;
- }
-
- switch (err){
-
- case X25RES_CHANNEL_IN_USE:
- case X25RES_NOT_READY:
- err = TRY_CMD_AGAIN;
- break;
- case CMD_OK:
- DBG_PRINTK(KERN_INFO "CALL CLEAR OK: Dev %s Chan Lcn %i\n",
- dev->name,chan->common.lcn);
-
- set_chan_state(dev,WAN_DISCONNECTING);
- atomic_set(&chan->common.command,0);
- err = DELAY_RESULT;
- break;
- default:
- /* If LAPB HDLC protocol, bring the whole link down
- * once the application terminates
- */
-
- set_chan_state(dev,WAN_DISCONNECTED);
-
- if (card->u.x.LAPB_hdlc){
- DBG_PRINTK(KERN_INFO "LAPB: Disconnecting Link\n");
- hdlc_link_down (card);
- }
- atomic_set(&chan->common.command,0);
- err = RETURN_RESULT;
- break;
- }
-
- return err;
-}
-
-static void hdlc_link_down (sdla_t *card)
-{
- TX25Mbox* mbox = card->mbox;
- int retry = 5;
- int err=0;
-
- do {
- memset(mbox,0,sizeof(TX25Mbox));
- mbox->cmd.command = X25_HDLC_LINK_DISC;
- mbox->cmd.length = 1;
- mbox->data[0]=0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
-
- } while (err && retry-- && x25_error(card, err, X25_HDLC_LINK_DISC, 0));
-
- if (err)
- printk(KERN_INFO "%s: Hdlc Link Down Failed %x\n",card->devname,err);
-
- disconnect (card);
-
-}
-
-static int check_bad_command(sdla_t* card, struct net_device *dev)
-{
- x25_channel_t *chan = dev->priv;
- int bad_cmd = 0;
-
- switch (atomic_read(&chan->common.command)&0x7F){
-
- case X25_PLACE_CALL:
- if (chan->common.state != WAN_DISCONNECTED)
- bad_cmd=1;
- break;
- case X25_CLEAR_CALL:
- if (chan->common.state == WAN_DISCONNECTED)
- bad_cmd=1;
- break;
- case X25_ACCEPT_CALL:
- if (chan->common.state != WAN_CONNECTING)
- bad_cmd=1;
- break;
- case X25_RESET:
- if (chan->common.state != WAN_CONNECTED)
- bad_cmd=1;
- break;
- default:
- bad_cmd=1;
- break;
- }
-
- if (bad_cmd){
- printk(KERN_INFO "%s: Invalid State, BAD Command %x, dev %s, lcn %i, st %i\n",
- card->devname,atomic_read(&chan->common.command),dev->name,
- chan->common.lcn, chan->common.state);
- }
-
- return bad_cmd;
-}
-
-
-
-/*************************** XPIPEMON FUNCTIONS **************************/
-
-/*==============================================================================
- * Process UDP call of type XPIPE
- */
-
-static int process_udp_mgmt_pkt(sdla_t *card)
-{
- int c_retry = MAX_CMD_RETRY;
- unsigned int len;
- struct sk_buff *new_skb;
- TX25Mbox *mbox = card->mbox;
- int err;
- int udp_mgmt_req_valid = 1;
- struct net_device *dev;
- x25_channel_t *chan;
- unsigned short lcn;
- struct timeval tv;
-
-
- x25_udp_pkt_t *x25_udp_pkt;
- x25_udp_pkt = (x25_udp_pkt_t *)card->u.x.udp_pkt_data;
-
- dev = card->u.x.udp_dev;
- chan = dev->priv;
- lcn = chan->common.lcn;
-
- switch(x25_udp_pkt->cblock.command) {
-
- /* XPIPE_ENABLE_TRACE */
- case XPIPE_ENABLE_TRACING:
-
- /* XPIPE_GET_TRACE_INFO */
- case XPIPE_GET_TRACE_INFO:
-
- /* SET FT1 MODE */
- case XPIPE_SET_FT1_MODE:
-
- if(card->u.x.udp_pkt_src == UDP_PKT_FRM_NETWORK) {
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_direction_err;
- udp_mgmt_req_valid = 0;
- break;
- }
-
- /* XPIPE_FT1_READ_STATUS */
- case XPIPE_FT1_READ_STATUS:
-
- /* FT1 MONITOR STATUS */
- case XPIPE_FT1_STATUS_CTRL:
- if(card->hw.fwid != SFID_X25_508) {
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_adptr_type_err;
- udp_mgmt_req_valid = 0;
- break;
- }
- default:
- break;
- }
-
- if(!udp_mgmt_req_valid) {
- /* set length to 0 */
- x25_udp_pkt->cblock.length = 0;
- /* set return code */
- x25_udp_pkt->cblock.result = (card->hw.fwid != SFID_X25_508) ? 0x1F : 0xCD;
-
- } else {
-
- switch (x25_udp_pkt->cblock.command) {
-
-
- case XPIPE_FLUSH_DRIVER_STATS:
- init_x25_channel_struct(chan);
- init_global_statistics(card);
- mbox->cmd.length = 0;
- break;
-
-
- case XPIPE_DRIVER_STAT_IFSEND:
- memcpy(x25_udp_pkt->data, &chan->if_send_stat, sizeof(if_send_stat_t));
- mbox->cmd.length = sizeof(if_send_stat_t);
- x25_udp_pkt->cblock.length = mbox->cmd.length;
- break;
-
- case XPIPE_DRIVER_STAT_INTR:
- memcpy(&x25_udp_pkt->data[0], &card->statistics, sizeof(global_stats_t));
- memcpy(&x25_udp_pkt->data[sizeof(global_stats_t)],
- &chan->rx_intr_stat, sizeof(rx_intr_stat_t));
-
- mbox->cmd.length = sizeof(global_stats_t) +
- sizeof(rx_intr_stat_t);
- x25_udp_pkt->cblock.length = mbox->cmd.length;
- break;
-
- case XPIPE_DRIVER_STAT_GEN:
- memcpy(x25_udp_pkt->data,
- &chan->pipe_mgmt_stat.UDP_PIPE_mgmt_kmalloc_err,
- sizeof(pipe_mgmt_stat_t));
-
- memcpy(&x25_udp_pkt->data[sizeof(pipe_mgmt_stat_t)],
- &card->statistics, sizeof(global_stats_t));
-
- x25_udp_pkt->cblock.result = 0;
- x25_udp_pkt->cblock.length = sizeof(global_stats_t)+
- sizeof(rx_intr_stat_t);
- mbox->cmd.length = x25_udp_pkt->cblock.length;
- break;
-
- case XPIPE_ROUTER_UP_TIME:
- do_gettimeofday(&tv);
- chan->router_up_time = tv.tv_sec - chan->router_start_time;
- *(unsigned long *)&x25_udp_pkt->data = chan->router_up_time;
- x25_udp_pkt->cblock.length = mbox->cmd.length = 4;
- x25_udp_pkt->cblock.result = 0;
- break;
-
- default :
-
- do {
- memcpy(&mbox->cmd, &x25_udp_pkt->cblock.command, sizeof(TX25Cmd));
- if(mbox->cmd.length){
- memcpy(&mbox->data,
- (char *)x25_udp_pkt->data,
- mbox->cmd.length);
- }
-
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- } while (err && c_retry-- && x25_error(card, err, mbox->cmd.command, 0));
-
-
- if ( err == CMD_OK ||
- (err == 1 &&
- (mbox->cmd.command == 0x06 ||
- mbox->cmd.command == 0x16) ) ){
-
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_adptr_cmnd_OK;
- } else {
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_adptr_cmnd_timeout;
- }
-
- /* copy the result back to our buffer */
- memcpy(&x25_udp_pkt->cblock.command, &mbox->cmd, sizeof(TX25Cmd));
-
- if(mbox->cmd.length) {
- memcpy(&x25_udp_pkt->data, &mbox->data, mbox->cmd.length);
- }
- break;
-
- } //switch
-
- }
-
- /* Fill UDP TTL */
-
- x25_udp_pkt->ip_pkt.ttl = card->wandev.ttl;
- len = reply_udp(card->u.x.udp_pkt_data, mbox->cmd.length);
-
-
- if(card->u.x.udp_pkt_src == UDP_PKT_FRM_NETWORK) {
-
- err = x25_send(card, lcn, 0, len, card->u.x.udp_pkt_data);
- if (!err)
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_adptr_send_passed;
- else
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_adptr_send_failed;
-
- } else {
-
- /* Allocate socket buffer */
- if((new_skb = dev_alloc_skb(len)) != NULL) {
- void *buf;
-
- /* copy data into new_skb */
- buf = skb_put(new_skb, len);
- memcpy(buf, card->u.x.udp_pkt_data, len);
-
- /* Decapsulate packet and pass it up the protocol
- stack */
- new_skb->dev = dev;
-
- if (chan->common.usedby == API)
- new_skb->protocol = htons(X25_PROT);
- else
- new_skb->protocol = htons(ETH_P_IP);
-
- new_skb->mac.raw = new_skb->data;
-
- netif_rx(new_skb);
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_passed_to_stack;
-
- } else {
- ++chan->pipe_mgmt_stat.UDP_PIPE_mgmt_no_socket;
- printk(KERN_INFO
- "%s: UDP mgmt cmnd, no socket buffers available!\n",
- card->devname);
- }
- }
-
- card->u.x.udp_pkt_lgth = 0;
-
- return 1;
-}
-
-
-/*==============================================================================
- * Determine what type of UDP call it is. DRVSTATS or XPIPE8ND ?
- */
-static int udp_pkt_type( struct sk_buff *skb, sdla_t* card )
-{
- x25_udp_pkt_t *x25_udp_pkt = (x25_udp_pkt_t *)skb->data;
-
- if((x25_udp_pkt->ip_pkt.protocol == UDPMGMT_UDP_PROTOCOL) &&
- (x25_udp_pkt->ip_pkt.ver_inet_hdr_length == 0x45) &&
- (x25_udp_pkt->udp_pkt.udp_dst_port == ntohs(card->wandev.udp_port)) &&
- (x25_udp_pkt->wp_mgmt.request_reply == UDPMGMT_REQUEST)) {
-
- if(!strncmp(x25_udp_pkt->wp_mgmt.signature,
- UDPMGMT_XPIPE_SIGNATURE, 8)){
- return UDP_XPIPE_TYPE;
- }else{
- printk(KERN_INFO "%s: UDP Packet, Failed Signature !\n",
- card->devname);
- }
- }
-
- return UDP_INVALID_TYPE;
-}
-
-
-/*============================================================================
- * Reply to UDP Management system.
- * Return nothing.
- */
-static int reply_udp( unsigned char *data, unsigned int mbox_len )
-{
- unsigned short len, udp_length, temp, ip_length;
- unsigned long ip_temp;
- int even_bound = 0;
-
-
- x25_udp_pkt_t *x25_udp_pkt = (x25_udp_pkt_t *)data;
-
- /* Set length of packet */
- len = sizeof(ip_pkt_t)+
- sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- mbox_len;
-
-
- /* fill in UDP reply */
- x25_udp_pkt->wp_mgmt.request_reply = UDPMGMT_REPLY;
-
- /* fill in UDP length */
- udp_length = sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- mbox_len;
-
-
- /* put it on an even boundary */
- if ( udp_length & 0x0001 ) {
- udp_length += 1;
- len += 1;
- even_bound = 1;
- }
-
- temp = (udp_length<<8)|(udp_length>>8);
- x25_udp_pkt->udp_pkt.udp_length = temp;
-
- /* swap UDP ports */
- temp = x25_udp_pkt->udp_pkt.udp_src_port;
- x25_udp_pkt->udp_pkt.udp_src_port =
- x25_udp_pkt->udp_pkt.udp_dst_port;
- x25_udp_pkt->udp_pkt.udp_dst_port = temp;
-
-
-
- /* add UDP pseudo header */
- temp = 0x1100;
- *((unsigned short *)
- (x25_udp_pkt->data+mbox_len+even_bound)) = temp;
- temp = (udp_length<<8)|(udp_length>>8);
- *((unsigned short *)
- (x25_udp_pkt->data+mbox_len+even_bound+2)) = temp;
-
- /* calculate UDP checksum */
- x25_udp_pkt->udp_pkt.udp_checksum = 0;
-
- x25_udp_pkt->udp_pkt.udp_checksum =
- calc_checksum(&data[UDP_OFFSET], udp_length+UDP_OFFSET);
-
- /* fill in IP length */
- ip_length = len;
- temp = (ip_length<<8)|(ip_length>>8);
- x25_udp_pkt->ip_pkt.total_length = temp;
-
- /* swap IP addresses */
- ip_temp = x25_udp_pkt->ip_pkt.ip_src_address;
- x25_udp_pkt->ip_pkt.ip_src_address =
- x25_udp_pkt->ip_pkt.ip_dst_address;
- x25_udp_pkt->ip_pkt.ip_dst_address = ip_temp;
-
-
- /* fill in IP checksum */
- x25_udp_pkt->ip_pkt.hdr_checksum = 0;
- x25_udp_pkt->ip_pkt.hdr_checksum = calc_checksum(data, sizeof(ip_pkt_t));
-
- return len;
-} /* reply_udp */
-
-unsigned short calc_checksum (char *data, int len)
-{
- unsigned short temp;
- unsigned long sum=0;
- int i;
-
- for( i = 0; i <len; i+=2 ) {
- memcpy(&temp,&data[i],2);
- sum += (unsigned long)temp;
- }
-
- while (sum >> 16 ) {
- sum = (sum & 0xffffUL) + (sum >> 16);
- }
-
- temp = (unsigned short)sum;
- temp = ~temp;
-
- if( temp == 0 )
- temp = 0xffff;
-
- return temp;
-}
-
-/*=============================================================================
- * Store a UDP management packet for later processing.
- */
-
-static int store_udp_mgmt_pkt(int udp_type, char udp_pkt_src, sdla_t* card,
- struct net_device *dev, struct sk_buff *skb,
- int lcn)
-{
- int udp_pkt_stored = 0;
-
- if(!card->u.x.udp_pkt_lgth && (skb->len <= MAX_LGTH_UDP_MGNT_PKT)){
- card->u.x.udp_pkt_lgth = skb->len;
- card->u.x.udp_type = udp_type;
- card->u.x.udp_pkt_src = udp_pkt_src;
- card->u.x.udp_lcn = lcn;
- card->u.x.udp_dev = dev;
- memcpy(card->u.x.udp_pkt_data, skb->data, skb->len);
- card->u.x.timer_int_enabled |= TMR_INT_ENABLED_UDP_PKT;
- udp_pkt_stored = 1;
-
- }else{
- printk(KERN_INFO "%s: ERROR: UDP packet not stored for LCN %d\n",
- card->devname,lcn);
- }
-
- if(udp_pkt_src == UDP_PKT_FRM_STACK){
- dev_kfree_skb_any(skb);
- }else{
- dev_kfree_skb_any(skb);
- }
-
- return(udp_pkt_stored);
-}
-
-
-
-/*=============================================================================
- * Initial the ppp_private_area structure.
- */
-static void init_x25_channel_struct( x25_channel_t *chan )
-{
- memset(&chan->if_send_stat.if_send_entry,0,sizeof(if_send_stat_t));
- memset(&chan->rx_intr_stat.rx_intr_no_socket,0,sizeof(rx_intr_stat_t));
- memset(&chan->pipe_mgmt_stat.UDP_PIPE_mgmt_kmalloc_err,0,sizeof(pipe_mgmt_stat_t));
-}
-
-/*============================================================================
- * Initialize Global Statistics
- */
-static void init_global_statistics( sdla_t *card )
-{
- memset(&card->statistics.isr_entry,0,sizeof(global_stats_t));
-}
-
-
-/*===============================================================
- * SMP Support
- * ==============================================================*/
-
-static void S508_S514_lock(sdla_t *card, unsigned long *smp_flags)
-{
- spin_lock_irqsave(&card->wandev.lock, *smp_flags);
-}
-static void S508_S514_unlock(sdla_t *card, unsigned long *smp_flags)
-{
- spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
-}
-
-/*===============================================================
- * x25_timer_routine
- *
- * A more efficient polling routine. Each half a second
- * queue a polling task. We want to do the polling in a
- * task not timer, because timer runs in interrupt time.
- *
- * FIXME Polling should be rethinked.
- *==============================================================*/
-
-static void x25_timer_routine(unsigned long data)
-{
- sdla_t *card = (sdla_t*)data;
-
- if (!card->wandev.dev){
- printk(KERN_INFO "%s: Stopping the X25 Poll Timer: No Dev.\n",
- card->devname);
- return;
- }
-
- if (card->open_cnt != card->u.x.num_of_ch){
- printk(KERN_INFO "%s: Stopping the X25 Poll Timer: Interface down.\n",
- card->devname);
- return;
- }
-
- if (test_bit(PERI_CRIT,&card->wandev.critical)){
- printk(KERN_INFO "%s: Stopping the X25 Poll Timer: Shutting down.\n",
- card->devname);
- return;
- }
-
- if (!test_and_set_bit(POLL_CRIT,&card->wandev.critical)){
- trigger_x25_poll(card);
- }
-
- card->u.x.x25_timer.expires=jiffies+(HZ>>1);
- add_timer(&card->u.x.x25_timer);
- return;
-}
-
-void disable_comm_shutdown(sdla_t *card)
-{
- TX25Mbox* mbox = card->mbox;
- int err;
-
- /* Turn of interrutps */
- mbox->data[0] = 0;
- if (card->hw.fwid == SFID_X25_508){
- mbox->data[1] = card->hw.irq;
- mbox->data[2] = 2;
- mbox->cmd.length = 3;
- }else {
- mbox->cmd.length = 1;
- }
- mbox->cmd.command = X25_SET_INTERRUPT_MODE;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err)
- printk(KERN_INFO "INTERRUPT OFF FAIED %x\n",err);
-
- /* Bring down HDLC */
- mbox->cmd.command = X25_HDLC_LINK_CLOSE;
- mbox->cmd.length = 0;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err)
- printk(KERN_INFO "LINK CLOSED FAILED %x\n",err);
-
-
- /* Brind down DTR */
- mbox->data[0] = 0;
- mbox->data[2] = 0;
- mbox->data[1] = 0x01;
- mbox->cmd.length = 3;
- mbox->cmd.command = X25_SET_GLOBAL_VARS;
- err = sdla_exec(mbox) ? mbox->cmd.result : CMD_TIMEOUT;
- if (err)
- printk(KERN_INFO "DTR DOWN FAILED %x\n",err);
-
-}
-
-MODULE_LICENSE("GPL");
-
-/****** End *****************************************************************/
diff --git a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c
deleted file mode 100644
index 032c0f81928e1..0000000000000
--- a/drivers/net/wan/sdladrv.c
+++ /dev/null
@@ -1,2314 +0,0 @@
-/*****************************************************************************
-* sdladrv.c SDLA Support Module. Main module.
-*
-* This module is a library of common hardware-specific functions
-* used by all Sangoma drivers.
-*
-* Author: Gideon Hack
-*
-* Copyright: (c) 1995-2000 Sangoma Technologies 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.
-* ============================================================================
-* Mar 20, 2001 Nenad Corbic Added the auto_pci_cfg filed, to support
-* the PCISLOT #0.
-* Apr 04, 2000 Nenad Corbic Fixed the auto memory detection code.
-* The memory test at address 0xC8000.
-* Mar 09, 2000 Nenad Corbic Added Gideon's Bug Fix: clear pci
-* interrupt flags on initial load.
-* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
-* Updates for Linux 2.2.X kernels.
-* Sep 17, 1998 Jaspreet Singh Updates for linux 2.2.X kernels
-* Dec 20, 1996 Gene Kozin Version 3.0.0. Complete overhaul.
-* Jul 12, 1996 Gene Kozin Changes for Linux 2.0 compatibility.
-* Jun 12, 1996 Gene Kozin Added support for S503 card.
-* Apr 30, 1996 Gene Kozin SDLA hardware interrupt is acknowledged before
-* calling protocolspecific ISR.
-* Register I/O ports with Linux kernel.
-* Miscellaneous bug fixes.
-* Dec 20, 1995 Gene Kozin Fixed a bug in interrupt routine.
-* Oct 14, 1995 Gene Kozin Initial version.
-*****************************************************************************/
-
-/*****************************************************************************
- * Notes:
- * ------
- * 1. This code is ment to be system-independent (as much as possible). To
- * achive this, various macros are used to hide system-specific interfaces.
- * To compile this code, one of the following constants must be defined:
- *
- * Platform Define
- * -------- ------
- * Linux _LINUX_
- * SCO Unix _SCO_UNIX_
- *
- * 2. Supported adapter types:
- *
- * S502A
- * ES502A (S502E)
- * S503
- * S507
- * S508 (S509)
- *
- * 3. S502A Notes:
- *
- * There is no separate DPM window enable/disable control in S502A. It
- * opens immediately after a window number it written to the HMCR
- * register. To close the window, HMCR has to be written a value
- * ????1111b (e.g. 0x0F or 0xFF).
- *
- * S502A DPM window cannot be located at offset E000 (e.g. 0xAE000).
- *
- * There should be a delay of ??? before reading back S502A status
- * register.
- *
- * 4. S502E Notes:
- *
- * S502E has a h/w bug: although default IRQ line state is HIGH, enabling
- * interrupts by setting bit 1 of the control register (BASE) to '1'
- * causes it to go LOW! Therefore, disabling interrupts by setting that
- * bit to '0' causes low-to-high transition on IRQ line (ghosty
- * interrupt). The same occurs when disabling CPU by resetting bit 0 of
- * CPU control register (BASE+3) - see the next note.
- *
- * S502E CPU and DPM control is limited:
- *
- * o CPU cannot be stopped independently. Resetting bit 0 of the CPUi
- * control register (BASE+3) shuts the board down entirely, including
- * DPM;
- *
- * o DPM access cannot be controlled dynamically. Ones CPU is started,
- * bit 1 of the control register (BASE) is used to enable/disable IRQ,
- * so that access to shared memory cannot be disabled while CPU is
- * running.
- ****************************************************************************/
-
-#define _LINUX_
-
-#if defined(_LINUX_) /****** Linux *******************************/
-
-#include <linux/config.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/module.h> /* support for loadable modules */
-#include <linux/jiffies.h> /* for jiffies, HZ, etc. */
-#include <linux/sdladrv.h> /* API definitions */
-#include <linux/sdlasfm.h> /* SDLA firmware module definitions */
-#include <linux/sdlapci.h> /* SDLA PCI hardware definitions */
-#include <linux/pci.h> /* PCI defines and function prototypes */
-#include <asm/io.h> /* for inb(), outb(), etc. */
-
-#define _INB(port) (inb(port))
-#define _OUTB(port, byte) (outb((byte),(port)))
-#define SYSTEM_TICK jiffies
-
-#include <linux/init.h>
-
-
-#elif defined(_SCO_UNIX_) /****** SCO Unix ****************************/
-
-#if !defined(INKERNEL)
-#error This code MUST be compiled in kernel mode!
-#endif
-#include <sys/sdladrv.h> /* API definitions */
-#include <sys/sdlasfm.h> /* SDLA firmware module definitions */
-#include <sys/inline.h> /* for inb(), outb(), etc. */
-#define _INB(port) (inb(port))
-#define _OUTB(port, byte) (outb((port),(byte)))
-#define SYSTEM_TICK lbolt
-
-#else
-#error Unknown system type!
-#endif
-
-#define MOD_VERSION 3
-#define MOD_RELEASE 0
-
-#define SDLA_IODELAY 100 /* I/O Rd/Wr delay, 10 works for 486DX2-66 */
-#define EXEC_DELAY 20 /* shared memory access delay, mks */
-#define EXEC_TIMEOUT (HZ*2) /* command timeout, in ticks */
-
-/* I/O port address range */
-#define S502A_IORANGE 3
-#define S502E_IORANGE 4
-#define S503_IORANGE 3
-#define S507_IORANGE 4
-#define S508_IORANGE 4
-
-/* Maximum amount of memory */
-#define S502_MAXMEM 0x10000L
-#define S503_MAXMEM 0x10000L
-#define S507_MAXMEM 0x40000L
-#define S508_MAXMEM 0x40000L
-
-/* Minimum amount of memory */
-#define S502_MINMEM 0x8000L
-#define S503_MINMEM 0x8000L
-#define S507_MINMEM 0x20000L
-#define S508_MINMEM 0x20000L
-#define NO_PORT -1
-
-
-
-
-
-/****** Function Prototypes *************************************************/
-
-/* Hardware-specific functions */
-static int sdla_detect (sdlahw_t* hw);
-static int sdla_autodpm (sdlahw_t* hw);
-static int sdla_setdpm (sdlahw_t* hw);
-static int sdla_load (sdlahw_t* hw, sfm_t* sfm, unsigned len);
-static int sdla_init (sdlahw_t* hw);
-static unsigned long sdla_memtest (sdlahw_t* hw);
-static int sdla_bootcfg (sdlahw_t* hw, sfm_info_t* sfminfo);
-static unsigned char make_config_byte (sdlahw_t* hw);
-static int sdla_start (sdlahw_t* hw, unsigned addr);
-
-static int init_s502a (sdlahw_t* hw);
-static int init_s502e (sdlahw_t* hw);
-static int init_s503 (sdlahw_t* hw);
-static int init_s507 (sdlahw_t* hw);
-static int init_s508 (sdlahw_t* hw);
-
-static int detect_s502a (int port);
-static int detect_s502e (int port);
-static int detect_s503 (int port);
-static int detect_s507 (int port);
-static int detect_s508 (int port);
-static int detect_s514 (sdlahw_t* hw);
-static int find_s514_adapter(sdlahw_t* hw, char find_first_S514_card);
-
-/* Miscellaneous functions */
-static void peek_by_4 (unsigned long src, void* buf, unsigned len);
-static void poke_by_4 (unsigned long dest, void* buf, unsigned len);
-static int calibrate_delay (int mks);
-static int get_option_index (unsigned* optlist, unsigned optval);
-static unsigned check_memregion (void* ptr, unsigned len);
-static unsigned test_memregion (void* ptr, unsigned len);
-static unsigned short checksum (unsigned char* buf, unsigned len);
-static int init_pci_slot(sdlahw_t *);
-
-static int pci_probe(sdlahw_t *hw);
-
-/****** Global Data **********************************************************
- * Note: All data must be explicitly initialized!!!
- */
-
-static struct pci_device_id sdladrv_pci_tbl[] = {
- { V3_VENDOR_ID, V3_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, },
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(pci, sdladrv_pci_tbl);
-
-MODULE_LICENSE("GPL");
-
-/* private data */
-static char modname[] = "sdladrv";
-static char fullname[] = "SDLA Support Module";
-static char copyright[] = "(c) 1995-1999 Sangoma Technologies Inc.";
-static unsigned exec_idle;
-
-/* Hardware configuration options.
- * These are arrays of configuration options used by verification routines.
- * The first element of each array is its size (i.e. number of options).
- */
-static unsigned s502_port_options[] =
- { 4, 0x250, 0x300, 0x350, 0x360 }
-;
-static unsigned s503_port_options[] =
- { 8, 0x250, 0x254, 0x300, 0x304, 0x350, 0x354, 0x360, 0x364 }
-;
-static unsigned s508_port_options[] =
- { 8, 0x250, 0x270, 0x280, 0x300, 0x350, 0x360, 0x380, 0x390 }
-;
-
-static unsigned s502a_irq_options[] = { 0 };
-static unsigned s502e_irq_options[] = { 4, 2, 3, 5, 7 };
-static unsigned s503_irq_options[] = { 5, 2, 3, 4, 5, 7 };
-static unsigned s508_irq_options[] = { 8, 3, 4, 5, 7, 10, 11, 12, 15 };
-
-static unsigned s502a_dpmbase_options[] =
-{
- 28,
- 0xA0000, 0xA2000, 0xA4000, 0xA6000, 0xA8000, 0xAA000, 0xAC000,
- 0xC0000, 0xC2000, 0xC4000, 0xC6000, 0xC8000, 0xCA000, 0xCC000,
- 0xD0000, 0xD2000, 0xD4000, 0xD6000, 0xD8000, 0xDA000, 0xDC000,
- 0xE0000, 0xE2000, 0xE4000, 0xE6000, 0xE8000, 0xEA000, 0xEC000,
-};
-static unsigned s507_dpmbase_options[] =
-{
- 32,
- 0xA0000, 0xA2000, 0xA4000, 0xA6000, 0xA8000, 0xAA000, 0xAC000, 0xAE000,
- 0xB0000, 0xB2000, 0xB4000, 0xB6000, 0xB8000, 0xBA000, 0xBC000, 0xBE000,
- 0xC0000, 0xC2000, 0xC4000, 0xC6000, 0xC8000, 0xCA000, 0xCC000, 0xCE000,
- 0xE0000, 0xE2000, 0xE4000, 0xE6000, 0xE8000, 0xEA000, 0xEC000, 0xEE000,
-};
-static unsigned s508_dpmbase_options[] = /* incl. S502E and S503 */
-{
- 32,
- 0xA0000, 0xA2000, 0xA4000, 0xA6000, 0xA8000, 0xAA000, 0xAC000, 0xAE000,
- 0xC0000, 0xC2000, 0xC4000, 0xC6000, 0xC8000, 0xCA000, 0xCC000, 0xCE000,
- 0xD0000, 0xD2000, 0xD4000, 0xD6000, 0xD8000, 0xDA000, 0xDC000, 0xDE000,
- 0xE0000, 0xE2000, 0xE4000, 0xE6000, 0xE8000, 0xEA000, 0xEC000, 0xEE000,
-};
-
-/*
-static unsigned s502_dpmsize_options[] = { 2, 0x2000, 0x10000 };
-static unsigned s507_dpmsize_options[] = { 2, 0x2000, 0x4000 };
-static unsigned s508_dpmsize_options[] = { 1, 0x2000 };
-*/
-
-static unsigned s502a_pclk_options[] = { 2, 3600, 7200 };
-static unsigned s502e_pclk_options[] = { 5, 3600, 5000, 7200, 8000, 10000 };
-static unsigned s503_pclk_options[] = { 3, 7200, 8000, 10000 };
-static unsigned s507_pclk_options[] = { 1, 12288 };
-static unsigned s508_pclk_options[] = { 1, 16000 };
-
-/* Host memory control register masks */
-static unsigned char s502a_hmcr[] =
-{
- 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, /* A0000 - AC000 */
- 0x20, 0x22, 0x24, 0x26, 0x28, 0x2A, 0x2C, /* C0000 - CC000 */
- 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, /* D0000 - DC000 */
- 0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, /* E0000 - EC000 */
-};
-static unsigned char s502e_hmcr[] =
-{
- 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E, /* A0000 - AE000 */
- 0x20, 0x22, 0x24, 0x26, 0x28, 0x2A, 0x2C, 0x2E, /* C0000 - CE000 */
- 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, /* D0000 - DE000 */
- 0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E, /* E0000 - EE000 */
-};
-static unsigned char s507_hmcr[] =
-{
- 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, /* A0000 - AE000 */
- 0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E, /* B0000 - BE000 */
- 0x80, 0x82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, /* C0000 - CE000 */
- 0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0xCE, /* E0000 - EE000 */
-};
-static unsigned char s508_hmcr[] =
-{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* A0000 - AE000 */
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* C0000 - CE000 */
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* D0000 - DE000 */
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, /* E0000 - EE000 */
-};
-
-static unsigned char s507_irqmask[] =
-{
- 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0
-};
-
-static int pci_slot_ar[MAX_S514_CARDS];
-
-/******* Kernel Loadable Module Entry Points ********************************/
-
-/*============================================================================
- * Module 'insert' entry point.
- * o print announcement
- * o initialize static data
- * o calibrate SDLA shared memory access delay.
- *
- * Return: 0 Ok
- * < 0 error.
- * Context: process
- */
-
-static int __init sdladrv_init(void)
-{
- int i=0;
-
- printk(KERN_INFO "%s v%u.%u %s\n",
- fullname, MOD_VERSION, MOD_RELEASE, copyright);
- exec_idle = calibrate_delay(EXEC_DELAY);
-#ifdef WANDEBUG
- printk(KERN_DEBUG "%s: exec_idle = %d\n", modname, exec_idle);
-#endif
-
- /* Initialize the PCI Card array, which
- * will store flags, used to mark
- * card initialization state */
- for (i=0; i<MAX_S514_CARDS; i++)
- pci_slot_ar[i] = 0xFF;
-
- return 0;
-}
-
-/*============================================================================
- * Module 'remove' entry point.
- * o release all remaining system resources
- */
-static void __exit sdladrv_cleanup(void)
-{
-}
-
-module_init(sdladrv_init);
-module_exit(sdladrv_cleanup);
-
-/******* Kernel APIs ********************************************************/
-
-/*============================================================================
- * Set up adapter.
- * o detect adapter type
- * o verify hardware configuration options
- * o check for hardware conflicts
- * o set up adapter shared memory
- * o test adapter memory
- * o load firmware
- * Return: 0 ok.
- * < 0 error
- */
-
-EXPORT_SYMBOL(sdla_setup);
-
-int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len)
-{
- unsigned* irq_opt = NULL; /* IRQ options */
- unsigned* dpmbase_opt = NULL; /* DPM window base options */
- unsigned* pclk_opt = NULL; /* CPU clock rate options */
- int err=0;
-
- if (sdla_detect(hw)) {
- if(hw->type != SDLA_S514)
- printk(KERN_INFO "%s: no SDLA card found at port 0x%X\n",
- modname, hw->port);
- return -EINVAL;
- }
-
- if(hw->type != SDLA_S514) {
- printk(KERN_INFO "%s: found S%04u card at port 0x%X.\n",
- modname, hw->type, hw->port);
-
- hw->dpmsize = SDLA_WINDOWSIZE;
- switch (hw->type) {
- case SDLA_S502A:
- hw->io_range = S502A_IORANGE;
- irq_opt = s502a_irq_options;
- dpmbase_opt = s502a_dpmbase_options;
- pclk_opt = s502a_pclk_options;
- break;
-
- case SDLA_S502E:
- hw->io_range = S502E_IORANGE;
- irq_opt = s502e_irq_options;
- dpmbase_opt = s508_dpmbase_options;
- pclk_opt = s502e_pclk_options;
- break;
-
- case SDLA_S503:
- hw->io_range = S503_IORANGE;
- irq_opt = s503_irq_options;
- dpmbase_opt = s508_dpmbase_options;
- pclk_opt = s503_pclk_options;
- break;
-
- case SDLA_S507:
- hw->io_range = S507_IORANGE;
- irq_opt = s508_irq_options;
- dpmbase_opt = s507_dpmbase_options;
- pclk_opt = s507_pclk_options;
- break;
-
- case SDLA_S508:
- hw->io_range = S508_IORANGE;
- irq_opt = s508_irq_options;
- dpmbase_opt = s508_dpmbase_options;
- pclk_opt = s508_pclk_options;
- break;
- }
-
- /* Verify IRQ configuration options */
- if (!get_option_index(irq_opt, hw->irq)) {
- printk(KERN_INFO "%s: IRQ %d is invalid!\n",
- modname, hw->irq);
- return -EINVAL;
- }
-
- /* Verify CPU clock rate configuration options */
- if (hw->pclk == 0)
- hw->pclk = pclk_opt[1]; /* use default */
-
- else if (!get_option_index(pclk_opt, hw->pclk)) {
- printk(KERN_INFO "%s: CPU clock %u is invalid!\n",
- modname, hw->pclk);
- return -EINVAL;
- }
- printk(KERN_INFO "%s: assuming CPU clock rate of %u kHz.\n",
- modname, hw->pclk);
-
- /* Setup adapter dual-port memory window and test memory */
- if (hw->dpmbase == 0) {
- err = sdla_autodpm(hw);
- if (err) {
- printk(KERN_INFO
- "%s: can't find available memory region!\n",
- modname);
- return err;
- }
- }
- else if (!get_option_index(dpmbase_opt,
- virt_to_phys(hw->dpmbase))) {
- printk(KERN_INFO
- "%s: memory address 0x%lX is invalid!\n",
- modname, virt_to_phys(hw->dpmbase));
- return -EINVAL;
- }
- else if (sdla_setdpm(hw)) {
- printk(KERN_INFO
- "%s: 8K memory region at 0x%lX is not available!\n",
- modname, virt_to_phys(hw->dpmbase));
- return -EINVAL;
- }
- printk(KERN_INFO
- "%s: dual-port memory window is set at 0x%lX.\n",
- modname, virt_to_phys(hw->dpmbase));
-
-
- /* If we find memory in 0xE**** Memory region,
- * warn the user to disable the SHADOW RAM.
- * Since memory corruption can occur if SHADOW is
- * enabled. This can causes random crashes ! */
- if (virt_to_phys(hw->dpmbase) >= 0xE0000){
- printk(KERN_WARNING "\n%s: !!!!!!!! WARNING !!!!!!!!\n",modname);
- printk(KERN_WARNING "%s: WANPIPE is using 0x%lX memory region !!!\n",
- modname, virt_to_phys(hw->dpmbase));
- printk(KERN_WARNING " Please disable the SHADOW RAM, otherwise\n");
- printk(KERN_WARNING " your system might crash randomly from time to time !\n");
- printk(KERN_WARNING "%s: !!!!!!!! WARNING !!!!!!!!\n\n",modname);
- }
- }
-
- else {
- hw->memory = test_memregion((void*)hw->dpmbase,
- MAX_SIZEOF_S514_MEMORY);
- if(hw->memory < (256 * 1024)) {
- printk(KERN_INFO
- "%s: error in testing S514 memory (0x%lX)\n",
- modname, hw->memory);
- sdla_down(hw);
- return -EINVAL;
- }
- }
-
- printk(KERN_INFO "%s: found %luK bytes of on-board memory\n",
- modname, hw->memory / 1024);
-
- /* Load firmware. If loader fails then shut down adapter */
- err = sdla_load(hw, sfm, len);
- if (err) sdla_down(hw); /* shutdown adapter */
-
- return err;
-}
-
-/*============================================================================
- * Shut down SDLA: disable shared memory access and interrupts, stop CPU, etc.
- */
-
-EXPORT_SYMBOL(sdla_down);
-
-int sdla_down (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int i;
- unsigned char CPU_no;
- u32 int_config, int_status;
-
- if(!port && (hw->type != SDLA_S514))
- return -EFAULT;
-
- switch (hw->type) {
- case SDLA_S502A:
- _OUTB(port, 0x08); /* halt CPU */
- _OUTB(port, 0x08);
- _OUTB(port, 0x08);
- hw->regs[0] = 0x08;
- _OUTB(port + 1, 0xFF); /* close memory window */
- hw->regs[1] = 0xFF;
- break;
-
- case SDLA_S502E:
- _OUTB(port + 3, 0); /* stop CPU */
- _OUTB(port, 0); /* reset board */
- for (i = 0; i < S502E_IORANGE; ++i)
- hw->regs[i] = 0
- ;
- break;
-
- case SDLA_S503:
- case SDLA_S507:
- case SDLA_S508:
- _OUTB(port, 0); /* reset board logic */
- hw->regs[0] = 0;
- break;
-
- case SDLA_S514:
- /* halt the adapter */
- *(char *)hw->vector = S514_CPU_HALT;
- CPU_no = hw->S514_cpu_no[0];
-
- /* disable the PCI IRQ and disable memory access */
- pci_read_config_dword(hw->pci_dev, PCI_INT_CONFIG, &int_config);
- int_config &= (CPU_no == S514_CPU_A) ? ~PCI_DISABLE_IRQ_CPU_A : ~PCI_DISABLE_IRQ_CPU_B;
- pci_write_config_dword(hw->pci_dev, PCI_INT_CONFIG, int_config);
- read_S514_int_stat(hw, &int_status);
- S514_intack(hw, int_status);
- if(CPU_no == S514_CPU_A)
- pci_write_config_dword(hw->pci_dev, PCI_MAP0_DWORD,
- PCI_CPU_A_MEM_DISABLE);
- else
- pci_write_config_dword(hw->pci_dev, PCI_MAP1_DWORD,
- PCI_CPU_B_MEM_DISABLE);
-
- /* free up the allocated virtual memory */
- iounmap((void *)hw->dpmbase);
- iounmap((void *)hw->vector);
- break;
-
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-/*============================================================================
- * Map shared memory window into SDLA address space.
- */
-
-EXPORT_SYMBOL(sdla_mapmem);
-
-int sdla_mapmem (sdlahw_t* hw, unsigned long addr)
-{
- unsigned port = hw->port;
- register int tmp;
-
- switch (hw->type) {
- case SDLA_S502A:
- case SDLA_S502E:
- if (addr < S502_MAXMEM) { /* verify parameter */
- tmp = addr >> 13; /* convert to register mask */
- _OUTB(port + 2, tmp);
- hw->regs[2] = tmp;
- }
- else return -EINVAL;
- break;
-
- case SDLA_S503:
- if (addr < S503_MAXMEM) { /* verify parameter */
- tmp = (hw->regs[0] & 0x8F) | ((addr >> 9) & 0x70);
- _OUTB(port, tmp);
- hw->regs[0] = tmp;
- }
- else return -EINVAL;
- break;
-
- case SDLA_S507:
- if (addr < S507_MAXMEM) {
- if (!(_INB(port) & 0x02))
- return -EIO;
- tmp = addr >> 13; /* convert to register mask */
- _OUTB(port + 2, tmp);
- hw->regs[2] = tmp;
- }
- else return -EINVAL;
- break;
-
- case SDLA_S508:
- if (addr < S508_MAXMEM) {
- tmp = addr >> 13; /* convert to register mask */
- _OUTB(port + 2, tmp);
- hw->regs[2] = tmp;
- }
- else return -EINVAL;
- break;
-
- case SDLA_S514:
- return 0;
-
- default:
- return -EINVAL;
- }
- hw->vector = addr & 0xFFFFE000L;
- return 0;
-}
-
-/*============================================================================
- * Enable interrupt generation.
- */
-
-static int sdla_inten (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- switch (hw->type) {
- case SDLA_S502E:
- /* Note thar interrupt control operations on S502E are allowed
- * only if CPU is enabled (bit 0 of status register is set).
- */
- if (_INB(port) & 0x01) {
- _OUTB(port, 0x02); /* bit1 = 1, bit2 = 0 */
- _OUTB(port, 0x06); /* bit1 = 1, bit2 = 1 */
- hw->regs[0] = 0x06;
- }
- else return -EIO;
- break;
-
- case SDLA_S503:
- tmp = hw->regs[0] | 0x04;
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (!(_INB(port) & 0x02)) /* verify */
- return -EIO;
- break;
-
- case SDLA_S508:
- tmp = hw->regs[0] | 0x10;
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (!(_INB(port + 1) & 0x10)) /* verify */
- return -EIO;
- break;
-
- case SDLA_S502A:
- case SDLA_S507:
- break;
-
- case SDLA_S514:
- break;
-
- default:
- return -EINVAL;
-
- }
- return 0;
-}
-
-/*============================================================================
- * Disable interrupt generation.
- */
-
-#if 0
-int sdla_intde (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- switch (hw->type) {
- case SDLA_S502E:
- /* Notes:
- * 1) interrupt control operations are allowed only if CPU is
- * enabled (bit 0 of status register is set).
- * 2) disabling interrupts using bit 1 of control register
- * causes IRQ line go high, therefore we are going to use
- * 0x04 instead: lower it to inhibit interrupts to PC.
- */
- if (_INB(port) & 0x01) {
- _OUTB(port, hw->regs[0] & ~0x04);
- hw->regs[0] &= ~0x04;
- }
- else return -EIO;
- break;
-
- case SDLA_S503:
- tmp = hw->regs[0] & ~0x04;
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) & 0x02) /* verify */
- return -EIO;
- break;
-
- case SDLA_S508:
- tmp = hw->regs[0] & ~0x10;
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) & 0x10) /* verify */
- return -EIO;
- break;
-
- case SDLA_S502A:
- case SDLA_S507:
- break;
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-#endif /* 0 */
-
-/*============================================================================
- * Acknowledge SDLA hardware interrupt.
- */
-
-static int sdla_intack (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp;
-
- switch (hw->type) {
- case SDLA_S502E:
- /* To acknoledge hardware interrupt we have to toggle bit 3 of
- * control register: \_/
- * Note that interrupt control operations on S502E are allowed
- * only if CPU is enabled (bit 1 of status register is set).
- */
- if (_INB(port) & 0x01) {
- tmp = hw->regs[0] & ~0x04;
- _OUTB(port, tmp);
- tmp |= 0x04;
- _OUTB(port, tmp);
- hw->regs[0] = tmp;
- }
- else return -EIO;
- break;
-
- case SDLA_S503:
- if (_INB(port) & 0x04) {
- tmp = hw->regs[0] & ~0x08;
- _OUTB(port, tmp);
- tmp |= 0x08;
- _OUTB(port, tmp);
- hw->regs[0] = tmp;
- }
- break;
-
- case SDLA_S502A:
- case SDLA_S507:
- case SDLA_S508:
- break;
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-
-/*============================================================================
- * Acknowledge S514 hardware interrupt.
- */
-
-EXPORT_SYMBOL(S514_intack);
-
-void S514_intack (sdlahw_t* hw, u32 int_status)
-{
- pci_write_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status);
-}
-
-
-/*============================================================================
- * Read the S514 hardware interrupt status.
- */
-
-EXPORT_SYMBOL(read_S514_int_stat);
-
-void read_S514_int_stat (sdlahw_t* hw, u32* int_status)
-{
- pci_read_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status);
-}
-
-
-/*============================================================================
- * Generate an interrupt to adapter's CPU.
- */
-
-#if 0
-int sdla_intr (sdlahw_t* hw)
-{
- unsigned port = hw->port;
-
- switch (hw->type) {
- case SDLA_S502A:
- if (!(_INB(port) & 0x40)) {
- _OUTB(port, 0x10); /* issue NMI to CPU */
- hw->regs[0] = 0x10;
- }
- else return -EIO;
- break;
-
- case SDLA_S507:
- if ((_INB(port) & 0x06) == 0x06) {
- _OUTB(port + 3, 0);
- }
- else return -EIO;
- break;
-
- case SDLA_S508:
- if (_INB(port + 1) & 0x02) {
- _OUTB(port, 0x08);
- }
- else return -EIO;
- break;
-
- case SDLA_S502E:
- case SDLA_S503:
- default:
- return -EINVAL;
- }
- return 0;
-}
-#endif /* 0 */
-
-/*============================================================================
- * Execute Adapter Command.
- * o Set exec flag.
- * o Busy-wait until flag is reset.
- * o Return number of loops made, or 0 if command timed out.
- */
-
-EXPORT_SYMBOL(sdla_exec);
-
-int sdla_exec (void* opflag)
-{
- volatile unsigned char* flag = opflag;
- unsigned long tstop;
- int nloops;
-
- if(readb(flag) != 0x00) {
- printk(KERN_INFO
- "WANPIPE: opp flag set on entry to sdla_exec\n");
- return 0;
- }
-
- writeb(0x01, flag);
-
- tstop = SYSTEM_TICK + EXEC_TIMEOUT;
-
- for (nloops = 1; (readb(flag) == 0x01); ++ nloops) {
- unsigned delay = exec_idle;
- while (-- delay); /* delay */
- if (SYSTEM_TICK > tstop) return 0; /* time is up! */
- }
- return nloops;
-}
-
-/*============================================================================
- * Read absolute adapter memory.
- * Transfer data from adapter's memory to data buffer.
- *
- * Note:
- * Care should be taken when crossing dual-port memory window boundary.
- * This function is not atomic, so caller must disable interrupt if
- * interrupt routines are accessing adapter shared memory.
- */
-
-EXPORT_SYMBOL(sdla_peek);
-
-int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len)
-{
-
- if (addr + len > hw->memory) /* verify arguments */
- return -EINVAL;
-
- if(hw->type == SDLA_S514) { /* copy data for the S514 adapter */
- peek_by_4 ((unsigned long)hw->dpmbase + addr, buf, len);
- return 0;
- }
-
- else { /* copy data for the S508 adapter */
- unsigned long oldvec = hw->vector;
- unsigned winsize = hw->dpmsize;
- unsigned curpos, curlen; /* current offset and block size */
- unsigned long curvec; /* current DPM window vector */
- int err = 0;
-
- while (len && !err) {
- curpos = addr % winsize; /* current window offset */
- curvec = addr - curpos; /* current window vector */
- curlen = (len > (winsize - curpos)) ?
- (winsize - curpos) : len;
- /* Relocate window and copy block of data */
- err = sdla_mapmem(hw, curvec);
- peek_by_4 ((unsigned long)hw->dpmbase + curpos, buf,
- curlen);
- addr += curlen;
- buf = (char*)buf + curlen;
- len -= curlen;
- }
-
- /* Restore DPM window position */
- sdla_mapmem(hw, oldvec);
- return err;
- }
-}
-
-
-/*============================================================================
- * Read data from adapter's memory to a data buffer in 4-byte chunks.
- * Note that we ensure that the SDLA memory address is on a 4-byte boundary
- * before we begin moving the data in 4-byte chunks.
-*/
-
-static void peek_by_4 (unsigned long src, void* buf, unsigned len)
-{
-
- /* byte copy data until we get to a 4-byte boundary */
- while (len && (src & 0x03)) {
- *(char *)buf ++ = readb(src ++);
- len --;
- }
-
- /* copy data in 4-byte chunks */
- while (len >= 4) {
- *(unsigned long *)buf = readl(src);
- buf += 4;
- src += 4;
- len -= 4;
- }
-
- /* byte copy any remaining data */
- while (len) {
- *(char *)buf ++ = readb(src ++);
- len --;
- }
-}
-
-
-/*============================================================================
- * Write Absolute Adapter Memory.
- * Transfer data from data buffer to adapter's memory.
- *
- * Note:
- * Care should be taken when crossing dual-port memory window boundary.
- * This function is not atomic, so caller must disable interrupt if
- * interrupt routines are accessing adapter shared memory.
- */
-
-EXPORT_SYMBOL(sdla_poke);
-
-int sdla_poke (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len)
-{
-
- if (addr + len > hw->memory) /* verify arguments */
- return -EINVAL;
-
- if(hw->type == SDLA_S514) { /* copy data for the S514 adapter */
- poke_by_4 ((unsigned long)hw->dpmbase + addr, buf, len);
- return 0;
- }
-
- else { /* copy data for the S508 adapter */
- unsigned long oldvec = hw->vector;
- unsigned winsize = hw->dpmsize;
- unsigned curpos, curlen; /* current offset and block size */
- unsigned long curvec; /* current DPM window vector */
- int err = 0;
-
- while (len && !err) {
- curpos = addr % winsize; /* current window offset */
- curvec = addr - curpos; /* current window vector */
- curlen = (len > (winsize - curpos)) ?
- (winsize - curpos) : len;
- /* Relocate window and copy block of data */
- sdla_mapmem(hw, curvec);
- poke_by_4 ((unsigned long)hw->dpmbase + curpos, buf,
- curlen);
- addr += curlen;
- buf = (char*)buf + curlen;
- len -= curlen;
- }
-
- /* Restore DPM window position */
- sdla_mapmem(hw, oldvec);
- return err;
- }
-}
-
-
-/*============================================================================
- * Write from a data buffer to adapter's memory in 4-byte chunks.
- * Note that we ensure that the SDLA memory address is on a 4-byte boundary
- * before we begin moving the data in 4-byte chunks.
-*/
-
-static void poke_by_4 (unsigned long dest, void* buf, unsigned len)
-{
-
- /* byte copy data until we get to a 4-byte boundary */
- while (len && (dest & 0x03)) {
- writeb (*(char *)buf ++, dest ++);
- len --;
- }
-
- /* copy data in 4-byte chunks */
- while (len >= 4) {
- writel (*(unsigned long *)buf, dest);
- dest += 4;
- buf += 4;
- len -= 4;
- }
-
- /* byte copy any remaining data */
- while (len) {
- writeb (*(char *)buf ++ , dest ++);
- len --;
- }
-}
-
-
-#ifdef DONT_COMPIPLE_THIS
-#endif /* DONT_COMPIPLE_THIS */
-
-/****** Hardware-Specific Functions *****************************************/
-
-/*============================================================================
- * Detect adapter type.
- * o if adapter type is specified then call detection routine for that adapter
- * type. Otherwise call detection routines for every adapter types until
- * adapter is detected.
- *
- * Notes:
- * 1) Detection tests are destructive! Adapter will be left in shutdown state
- * after the test.
- */
-static int sdla_detect (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int err = 0;
-
- if (!port && (hw->type != SDLA_S514))
- return -EFAULT;
-
- switch (hw->type) {
- case SDLA_S502A:
- if (!detect_s502a(port)) err = -ENODEV;
- break;
-
- case SDLA_S502E:
- if (!detect_s502e(port)) err = -ENODEV;
- break;
-
- case SDLA_S503:
- if (!detect_s503(port)) err = -ENODEV;
- break;
-
- case SDLA_S507:
- if (!detect_s507(port)) err = -ENODEV;
- break;
-
- case SDLA_S508:
- if (!detect_s508(port)) err = -ENODEV;
- break;
-
- case SDLA_S514:
- if (!detect_s514(hw)) err = -ENODEV;
- break;
-
- default:
- if (detect_s502a(port))
- hw->type = SDLA_S502A;
- else if (detect_s502e(port))
- hw->type = SDLA_S502E;
- else if (detect_s503(port))
- hw->type = SDLA_S503;
- else if (detect_s507(port))
- hw->type = SDLA_S507;
- else if (detect_s508(port))
- hw->type = SDLA_S508;
- else err = -ENODEV;
- }
- return err;
-}
-
-/*============================================================================
- * Autoselect memory region.
- * o try all available DMP address options from the top down until success.
- */
-static int sdla_autodpm (sdlahw_t* hw)
-{
- int i, err = -EINVAL;
- unsigned* opt;
-
- switch (hw->type) {
- case SDLA_S502A:
- opt = s502a_dpmbase_options;
- break;
-
- case SDLA_S502E:
- case SDLA_S503:
- case SDLA_S508:
- opt = s508_dpmbase_options;
- break;
-
- case SDLA_S507:
- opt = s507_dpmbase_options;
- break;
-
- default:
- return -EINVAL;
- }
-
- /* Start testing from 8th position, address
- * 0xC8000 from the 508 address table.
- * We don't want to test A**** addresses, since
- * they are usually used for Video */
- for (i = 8; i <= opt[0] && err; i++) {
- hw->dpmbase = phys_to_virt(opt[i]);
- err = sdla_setdpm(hw);
- }
- return err;
-}
-
-/*============================================================================
- * Set up adapter dual-port memory window.
- * o shut down adapter
- * o make sure that no physical memory exists in this region, i.e entire
- * region reads 0xFF and is not writable when adapter is shut down.
- * o initialize adapter hardware
- * o make sure that region is usable with SDLA card, i.e. we can write to it
- * when adapter is configured.
- */
-static int sdla_setdpm (sdlahw_t* hw)
-{
- int err;
-
- /* Shut down card and verify memory region */
- sdla_down(hw);
- if (check_memregion(hw->dpmbase, hw->dpmsize))
- return -EINVAL;
-
- /* Initialize adapter and test on-board memory segment by segment.
- * If memory size appears to be less than shared memory window size,
- * assume that memory region is unusable.
- */
- err = sdla_init(hw);
- if (err) return err;
-
- if (sdla_memtest(hw) < hw->dpmsize) { /* less than window size */
- sdla_down(hw);
- return -EIO;
- }
- sdla_mapmem(hw, 0L); /* set window vector at bottom */
- return 0;
-}
-
-/*============================================================================
- * Load adapter from the memory image of the SDLA firmware module.
- * o verify firmware integrity and compatibility
- * o start adapter up
- */
-static int sdla_load (sdlahw_t* hw, sfm_t* sfm, unsigned len)
-{
-
- int i;
-
- /* Verify firmware signature */
- if (strcmp(sfm->signature, SFM_SIGNATURE)) {
- printk(KERN_INFO "%s: not SDLA firmware!\n",
- modname);
- return -EINVAL;
- }
-
- /* Verify firmware module format version */
- if (sfm->version != SFM_VERSION) {
- printk(KERN_INFO
- "%s: firmware format %u rejected! Expecting %u.\n",
- modname, sfm->version, SFM_VERSION);
- return -EINVAL;
- }
-
- /* Verify firmware module length and checksum */
- if ((len - offsetof(sfm_t, image) != sfm->info.codesize) ||
- (checksum((void*)&sfm->info,
- sizeof(sfm_info_t) + sfm->info.codesize) != sfm->checksum)) {
- printk(KERN_INFO "%s: firmware corrupted!\n", modname);
- return -EINVAL;
- }
-
- /* Announce */
- printk(KERN_INFO "%s: loading %s (ID=%u)...\n", modname,
- (sfm->descr[0] != '\0') ? sfm->descr : "unknown firmware",
- sfm->info.codeid);
-
- if(hw->type == SDLA_S514)
- printk(KERN_INFO "%s: loading S514 adapter, CPU %c\n",
- modname, hw->S514_cpu_no[0]);
-
- /* Scan through the list of compatible adapters and make sure our
- * adapter type is listed.
- */
- for (i = 0;
- (i < SFM_MAX_SDLA) && (sfm->info.adapter[i] != hw->type);
- ++i);
-
- if (i == SFM_MAX_SDLA) {
- printk(KERN_INFO "%s: firmware is not compatible with S%u!\n",
- modname, hw->type);
- return -EINVAL;
- }
-
-
- /* Make sure there is enough on-board memory */
- if (hw->memory < sfm->info.memsize) {
- printk(KERN_INFO
- "%s: firmware needs %lu bytes of on-board memory!\n",
- modname, sfm->info.memsize);
- return -EINVAL;
- }
-
- /* Move code onto adapter */
- if (sdla_poke(hw, sfm->info.codeoffs, sfm->image, sfm->info.codesize)) {
- printk(KERN_INFO "%s: failed to load code segment!\n",
- modname);
- return -EIO;
- }
-
- /* Prepare boot-time configuration data and kick-off CPU */
- sdla_bootcfg(hw, &sfm->info);
- if (sdla_start(hw, sfm->info.startoffs)) {
- printk(KERN_INFO "%s: Damn... Adapter won't start!\n",
- modname);
- return -EIO;
- }
-
- /* position DPM window over the mailbox and enable interrupts */
- if (sdla_mapmem(hw, sfm->info.winoffs) || sdla_inten(hw)) {
- printk(KERN_INFO "%s: adapter hardware failure!\n",
- modname);
- return -EIO;
- }
- hw->fwid = sfm->info.codeid; /* set firmware ID */
- return 0;
-}
-
-/*============================================================================
- * Initialize SDLA hardware: setup memory window, IRQ, etc.
- */
-static int sdla_init (sdlahw_t* hw)
-{
- int i;
-
- for (i = 0; i < SDLA_MAXIORANGE; ++i)
- hw->regs[i] = 0;
-
- switch (hw->type) {
- case SDLA_S502A: return init_s502a(hw);
- case SDLA_S502E: return init_s502e(hw);
- case SDLA_S503: return init_s503(hw);
- case SDLA_S507: return init_s507(hw);
- case SDLA_S508: return init_s508(hw);
- }
- return -EINVAL;
-}
-
-/*============================================================================
- * Test adapter on-board memory.
- * o slide DPM window from the bottom up and test adapter memory segment by
- * segment.
- * Return adapter memory size.
- */
-static unsigned long sdla_memtest (sdlahw_t* hw)
-{
- unsigned long memsize;
- unsigned winsize;
-
- for (memsize = 0, winsize = hw->dpmsize;
- !sdla_mapmem(hw, memsize) &&
- (test_memregion(hw->dpmbase, winsize) == winsize)
- ;
- memsize += winsize)
- ;
- hw->memory = memsize;
- return memsize;
-}
-
-/*============================================================================
- * Prepare boot-time firmware configuration data.
- * o position DPM window
- * o initialize configuration data area
- */
-static int sdla_bootcfg (sdlahw_t* hw, sfm_info_t* sfminfo)
-{
- unsigned char* data;
-
- if (!sfminfo->datasize) return 0; /* nothing to do */
-
- if (sdla_mapmem(hw, sfminfo->dataoffs) != 0)
- return -EIO;
-
- if(hw->type == SDLA_S514)
- data = (void*)(hw->dpmbase + sfminfo->dataoffs);
- else
- data = (void*)((u8 *)hw->dpmbase +
- (sfminfo->dataoffs - hw->vector));
-
- memset_io (data, 0, sfminfo->datasize);
-
- writeb (make_config_byte(hw), &data[0x00]);
-
- switch (sfminfo->codeid) {
- case SFID_X25_502:
- case SFID_X25_508:
- writeb (3, &data[0x01]); /* T1 timer */
- writeb (10, &data[0x03]); /* N2 */
- writeb (7, &data[0x06]); /* HDLC window size */
- writeb (1, &data[0x0B]); /* DTE */
- writeb (2, &data[0x0C]); /* X.25 packet window size */
- writew (128, &data[0x0D]); /* default X.25 data size */
- writew (128, &data[0x0F]); /* maximum X.25 data size */
- break;
- }
- return 0;
-}
-
-/*============================================================================
- * Prepare configuration byte identifying adapter type and CPU clock rate.
- */
-static unsigned char make_config_byte (sdlahw_t* hw)
-{
- unsigned char byte = 0;
-
- switch (hw->pclk) {
- case 5000: byte = 0x01; break;
- case 7200: byte = 0x02; break;
- case 8000: byte = 0x03; break;
- case 10000: byte = 0x04; break;
- case 16000: byte = 0x05; break;
- }
-
- switch (hw->type) {
- case SDLA_S502E: byte |= 0x80; break;
- case SDLA_S503: byte |= 0x40; break;
- }
- return byte;
-}
-
-/*============================================================================
- * Start adapter's CPU.
- * o calculate a pointer to adapter's cold boot entry point
- * o position DPM window
- * o place boot instruction (jp addr) at cold boot entry point
- * o start CPU
- */
-static int sdla_start (sdlahw_t* hw, unsigned addr)
-{
- unsigned port = hw->port;
- unsigned char *bootp;
- int err, tmp, i;
-
- if (!port && (hw->type != SDLA_S514)) return -EFAULT;
-
- switch (hw->type) {
- case SDLA_S502A:
- bootp = hw->dpmbase;
- bootp += 0x66;
- break;
-
- case SDLA_S502E:
- case SDLA_S503:
- case SDLA_S507:
- case SDLA_S508:
- case SDLA_S514:
- bootp = hw->dpmbase;
- break;
-
- default:
- return -EINVAL;
- }
-
- err = sdla_mapmem(hw, 0);
- if (err) return err;
-
- writeb (0xC3, bootp); /* Z80: 'jp' opcode */
- bootp ++;
- writew (addr, bootp);
-
- switch (hw->type) {
- case SDLA_S502A:
- _OUTB(port, 0x10); /* issue NMI to CPU */
- hw->regs[0] = 0x10;
- break;
-
- case SDLA_S502E:
- _OUTB(port + 3, 0x01); /* start CPU */
- hw->regs[3] = 0x01;
- for (i = 0; i < SDLA_IODELAY; ++i);
- if (_INB(port) & 0x01) { /* verify */
- /*
- * Enabling CPU changes functionality of the
- * control register, so we have to reset its
- * mirror.
- */
- _OUTB(port, 0); /* disable interrupts */
- hw->regs[0] = 0;
- }
- else return -EIO;
- break;
-
- case SDLA_S503:
- tmp = hw->regs[0] | 0x09; /* set bits 0 and 3 */
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i);
- if (!(_INB(port) & 0x01)) /* verify */
- return -EIO;
- break;
-
- case SDLA_S507:
- tmp = hw->regs[0] | 0x02;
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i);
- if (!(_INB(port) & 0x04)) /* verify */
- return -EIO;
- break;
-
- case SDLA_S508:
- tmp = hw->regs[0] | 0x02;
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i);
- if (!(_INB(port + 1) & 0x02)) /* verify */
- return -EIO;
- break;
-
- case SDLA_S514:
- writeb (S514_CPU_START, hw->vector);
- break;
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-/*============================================================================
- * Initialize S502A adapter.
- */
-static int init_s502a (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- if (!detect_s502a(port))
- return -ENODEV;
-
- hw->regs[0] = 0x08;
- hw->regs[1] = 0xFF;
-
- /* Verify configuration options */
- i = get_option_index(s502a_dpmbase_options, virt_to_phys(hw->dpmbase));
- if (i == 0)
- return -EINVAL;
-
- tmp = s502a_hmcr[i - 1];
- switch (hw->dpmsize) {
- case 0x2000:
- tmp |= 0x01;
- break;
-
- case 0x10000L:
- break;
-
- default:
- return -EINVAL;
- }
-
- /* Setup dual-port memory window (this also enables memory access) */
- _OUTB(port + 1, tmp);
- hw->regs[1] = tmp;
- hw->regs[0] = 0x08;
- return 0;
-}
-
-/*============================================================================
- * Initialize S502E adapter.
- */
-static int init_s502e (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- if (!detect_s502e(port))
- return -ENODEV;
-
- /* Verify configuration options */
- i = get_option_index(s508_dpmbase_options, virt_to_phys(hw->dpmbase));
- if (i == 0)
- return -EINVAL;
-
- tmp = s502e_hmcr[i - 1];
- switch (hw->dpmsize) {
- case 0x2000:
- tmp |= 0x01;
- break;
-
- case 0x10000L:
- break;
-
- default:
- return -EINVAL;
- }
-
- /* Setup dual-port memory window */
- _OUTB(port + 1, tmp);
- hw->regs[1] = tmp;
-
- /* Enable memory access */
- _OUTB(port, 0x02);
- hw->regs[0] = 0x02;
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- return (_INB(port) & 0x02) ? 0 : -EIO;
-}
-
-/*============================================================================
- * Initialize S503 adapter.
- * ---------------------------------------------------------------------------
- */
-static int init_s503 (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- if (!detect_s503(port))
- return -ENODEV;
-
- /* Verify configuration options */
- i = get_option_index(s508_dpmbase_options, virt_to_phys(hw->dpmbase));
- if (i == 0)
- return -EINVAL;
-
- tmp = s502e_hmcr[i - 1];
- switch (hw->dpmsize) {
- case 0x2000:
- tmp |= 0x01;
- break;
-
- case 0x10000L:
- break;
-
- default:
- return -EINVAL;
- }
-
- /* Setup dual-port memory window */
- _OUTB(port + 1, tmp);
- hw->regs[1] = tmp;
-
- /* Enable memory access */
- _OUTB(port, 0x02);
- hw->regs[0] = 0x02; /* update mirror */
- return 0;
-}
-
-/*============================================================================
- * Initialize S507 adapter.
- */
-static int init_s507 (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- if (!detect_s507(port))
- return -ENODEV;
-
- /* Verify configuration options */
- i = get_option_index(s507_dpmbase_options, virt_to_phys(hw->dpmbase));
- if (i == 0)
- return -EINVAL;
-
- tmp = s507_hmcr[i - 1];
- switch (hw->dpmsize) {
- case 0x2000:
- tmp |= 0x01;
- break;
-
- case 0x10000L:
- break;
-
- default:
- return -EINVAL;
- }
-
- /* Enable adapter's logic */
- _OUTB(port, 0x01);
- hw->regs[0] = 0x01;
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (!(_INB(port) & 0x20))
- return -EIO;
-
- /* Setup dual-port memory window */
- _OUTB(port + 1, tmp);
- hw->regs[1] = tmp;
-
- /* Enable memory access */
- tmp = hw->regs[0] | 0x04;
- if (hw->irq) {
- i = get_option_index(s508_irq_options, hw->irq);
- if (i) tmp |= s507_irqmask[i - 1];
- }
- _OUTB(port, tmp);
- hw->regs[0] = tmp; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- return (_INB(port) & 0x08) ? 0 : -EIO;
-}
-
-/*============================================================================
- * Initialize S508 adapter.
- */
-static int init_s508 (sdlahw_t* hw)
-{
- unsigned port = hw->port;
- int tmp, i;
-
- if (!detect_s508(port))
- return -ENODEV;
-
- /* Verify configuration options */
- i = get_option_index(s508_dpmbase_options, virt_to_phys(hw->dpmbase));
- if (i == 0)
- return -EINVAL;
-
- /* Setup memory configuration */
- tmp = s508_hmcr[i - 1];
- _OUTB(port + 1, tmp);
- hw->regs[1] = tmp;
-
- /* Enable memory access */
- _OUTB(port, 0x04);
- hw->regs[0] = 0x04; /* update mirror */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- return (_INB(port + 1) & 0x04) ? 0 : -EIO;
-}
-
-/*============================================================================
- * Detect S502A adapter.
- * Following tests are used to detect S502A adapter:
- * 1. All registers other than status (BASE) should read 0xFF
- * 2. After writing 00001000b to control register, status register should
- * read 01000000b.
- * 3. After writing 0 to control register, status register should still
- * read 01000000b.
- * 4. After writing 00000100b to control register, status register should
- * read 01000100b.
- * Return 1 if detected o.k. or 0 if failed.
- * Note: This test is destructive! Adapter will be left in shutdown
- * state after the test.
- */
-static int detect_s502a (int port)
-{
- int i, j;
-
- if (!get_option_index(s502_port_options, port))
- return 0;
-
- for (j = 1; j < SDLA_MAXIORANGE; ++j) {
- if (_INB(port + j) != 0xFF)
- return 0;
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- }
-
- _OUTB(port, 0x08); /* halt CPU */
- _OUTB(port, 0x08);
- _OUTB(port, 0x08);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0x40)
- return 0;
- _OUTB(port, 0x00);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0x40)
- return 0;
- _OUTB(port, 0x04);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0x44)
- return 0;
-
- /* Reset adapter */
- _OUTB(port, 0x08);
- _OUTB(port, 0x08);
- _OUTB(port, 0x08);
- _OUTB(port + 1, 0xFF);
- return 1;
-}
-
-/*============================================================================
- * Detect S502E adapter.
- * Following tests are used to verify adapter presence:
- * 1. All registers other than status (BASE) should read 0xFF.
- * 2. After writing 0 to CPU control register (BASE+3), status register
- * (BASE) should read 11111000b.
- * 3. After writing 00000100b to port BASE (set bit 2), status register
- * (BASE) should read 11111100b.
- * Return 1 if detected o.k. or 0 if failed.
- * Note: This test is destructive! Adapter will be left in shutdown
- * state after the test.
- */
-static int detect_s502e (int port)
-{
- int i, j;
-
- if (!get_option_index(s502_port_options, port))
- return 0;
- for (j = 1; j < SDLA_MAXIORANGE; ++j) {
- if (_INB(port + j) != 0xFF)
- return 0;
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- }
-
- _OUTB(port + 3, 0); /* CPU control reg. */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0xF8) /* read status */
- return 0;
- _OUTB(port, 0x04); /* set bit 2 */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0xFC) /* verify */
- return 0;
-
- /* Reset adapter */
- _OUTB(port, 0);
- return 1;
-}
-
-/*============================================================================
- * Detect s503 adapter.
- * Following tests are used to verify adapter presence:
- * 1. All registers other than status (BASE) should read 0xFF.
- * 2. After writing 0 to control register (BASE), status register (BASE)
- * should read 11110000b.
- * 3. After writing 00000100b (set bit 2) to control register (BASE),
- * status register should read 11110010b.
- * Return 1 if detected o.k. or 0 if failed.
- * Note: This test is destructive! Adapter will be left in shutdown
- * state after the test.
- */
-static int detect_s503 (int port)
-{
- int i, j;
-
- if (!get_option_index(s503_port_options, port))
- return 0;
- for (j = 1; j < SDLA_MAXIORANGE; ++j) {
- if (_INB(port + j) != 0xFF)
- return 0;
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- }
-
- _OUTB(port, 0); /* reset control reg.*/
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0xF0) /* read status */
- return 0;
- _OUTB(port, 0x04); /* set bit 2 */
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if (_INB(port) != 0xF2) /* verify */
- return 0;
-
- /* Reset adapter */
- _OUTB(port, 0);
- return 1;
-}
-
-/*============================================================================
- * Detect s507 adapter.
- * Following tests are used to detect s507 adapter:
- * 1. All ports should read the same value.
- * 2. After writing 0x00 to control register, status register should read
- * ?011000?b.
- * 3. After writing 0x01 to control register, status register should read
- * ?011001?b.
- * Return 1 if detected o.k. or 0 if failed.
- * Note: This test is destructive! Adapter will be left in shutdown
- * state after the test.
- */
-static int detect_s507 (int port)
-{
- int tmp, i, j;
-
- if (!get_option_index(s508_port_options, port))
- return 0;
- tmp = _INB(port);
- for (j = 1; j < S507_IORANGE; ++j) {
- if (_INB(port + j) != tmp)
- return 0;
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- }
-
- _OUTB(port, 0x00);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if ((_INB(port) & 0x7E) != 0x30)
- return 0;
- _OUTB(port, 0x01);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if ((_INB(port) & 0x7E) != 0x32)
- return 0;
-
- /* Reset adapter */
- _OUTB(port, 0x00);
- return 1;
-}
-
-/*============================================================================
- * Detect s508 adapter.
- * Following tests are used to detect s508 adapter:
- * 1. After writing 0x00 to control register, status register should read
- * ??000000b.
- * 2. After writing 0x10 to control register, status register should read
- * ??010000b
- * Return 1 if detected o.k. or 0 if failed.
- * Note: This test is destructive! Adapter will be left in shutdown
- * state after the test.
- */
-static int detect_s508 (int port)
-{
- int i;
-
- if (!get_option_index(s508_port_options, port))
- return 0;
- _OUTB(port, 0x00);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if ((_INB(port + 1) & 0x3F) != 0x00)
- return 0;
- _OUTB(port, 0x10);
- for (i = 0; i < SDLA_IODELAY; ++i); /* delay */
- if ((_INB(port + 1) & 0x3F) != 0x10)
- return 0;
-
- /* Reset adapter */
- _OUTB(port, 0x00);
- return 1;
-}
-
-/*============================================================================
- * Detect s514 PCI adapter.
- * Return 1 if detected o.k. or 0 if failed.
- * Note: This test is destructive! Adapter will be left in shutdown
- * state after the test.
- */
-static int detect_s514 (sdlahw_t* hw)
-{
- unsigned char CPU_no, slot_no, auto_slot_cfg;
- int number_S514_cards = 0;
- u32 S514_mem_base_addr = 0;
- u32 ut_u32;
- struct pci_dev *pci_dev;
-
-
-#ifndef CONFIG_PCI
- printk(KERN_INFO "%s: Linux not compiled for PCI usage!\n", modname);
- return 0;
-#endif
-
- /*
- The 'setup()' procedure in 'sdlamain.c' passes the CPU number and the
- slot number defined in 'router.conf' via the 'port' definition.
- */
- CPU_no = hw->S514_cpu_no[0];
- slot_no = hw->S514_slot_no;
- auto_slot_cfg = hw->auto_pci_cfg;
-
- if (auto_slot_cfg){
- printk(KERN_INFO "%s: srch... S514 card, CPU %c, Slot=Auto\n",
- modname, CPU_no);
-
- }else{
- printk(KERN_INFO "%s: srch... S514 card, CPU %c, Slot #%d\n",
- modname, CPU_no, slot_no);
- }
-
- /* check to see that CPU A or B has been selected in 'router.conf' */
- switch(CPU_no) {
- case S514_CPU_A:
- case S514_CPU_B:
- break;
-
- default:
- printk(KERN_INFO "%s: S514 CPU definition invalid.\n",
- modname);
- printk(KERN_INFO "Must be 'A' or 'B'\n");
- return 0;
- }
-
- number_S514_cards = find_s514_adapter(hw, 0);
- if(!number_S514_cards)
- return 0;
-
- /* we are using a single S514 adapter with a slot of 0 so re-read the */
- /* location of this adapter */
- if((number_S514_cards == 1) && auto_slot_cfg) {
- number_S514_cards = find_s514_adapter(hw, 1);
- if(!number_S514_cards) {
- printk(KERN_INFO "%s: Error finding PCI card\n",
- modname);
- return 0;
- }
- }
-
- pci_dev = hw->pci_dev;
- /* read the physical memory base address */
- S514_mem_base_addr = (CPU_no == S514_CPU_A) ?
- (pci_dev->resource[1].start) :
- (pci_dev->resource[2].start);
-
- printk(KERN_INFO "%s: S514 PCI memory at 0x%X\n",
- modname, S514_mem_base_addr);
- if(!S514_mem_base_addr) {
- if(CPU_no == S514_CPU_B)
- printk(KERN_INFO "%s: CPU #B not present on the card\n", modname);
- else
- printk(KERN_INFO "%s: No PCI memory allocated to card\n", modname);
- return 0;
- }
-
- /* enable the PCI memory */
- pci_read_config_dword(pci_dev,
- (CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD,
- &ut_u32);
- pci_write_config_dword(pci_dev,
- (CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD,
- (ut_u32 | PCI_MEMORY_ENABLE));
-
- /* check the IRQ allocated and enable IRQ usage */
- if(!(hw->irq = pci_dev->irq)) {
- printk(KERN_INFO "%s: IRQ not allocated to S514 adapter\n",
- modname);
- return 0;
- }
-
- /* BUG FIX : Mar 6 2000
- * On a initial loading of the card, we must check
- * and clear PCI interrupt bits, due to a reset
- * problem on some other boards. i.e. An interrupt
- * might be pending, even after system bootup,
- * in which case, when starting wanrouter the machine
- * would crash.
- */
- if (init_pci_slot(hw))
- return 0;
-
- pci_read_config_dword(pci_dev, PCI_INT_CONFIG, &ut_u32);
- ut_u32 |= (CPU_no == S514_CPU_A) ?
- PCI_ENABLE_IRQ_CPU_A : PCI_ENABLE_IRQ_CPU_B;
- pci_write_config_dword(pci_dev, PCI_INT_CONFIG, ut_u32);
-
- printk(KERN_INFO "%s: IRQ %d allocated to the S514 card\n",
- modname, hw->irq);
-
- /* map the physical PCI memory to virtual memory */
- hw->dpmbase = ioremap((unsigned long)S514_mem_base_addr,
- (unsigned long)MAX_SIZEOF_S514_MEMORY);
- /* map the physical control register memory to virtual memory */
- hw->vector = (unsigned long)ioremap(
- (unsigned long)(S514_mem_base_addr + S514_CTRL_REG_BYTE),
- (unsigned long)16);
-
- if(!hw->dpmbase || !hw->vector) {
- printk(KERN_INFO "%s: PCI virtual memory allocation failed\n",
- modname);
- return 0;
- }
-
- /* halt the adapter */
- writeb (S514_CPU_HALT, hw->vector);
-
- return 1;
-}
-
-/*============================================================================
- * Find the S514 PCI adapter in the PCI bus.
- * Return the number of S514 adapters found (0 if no adapter found).
- */
-static int find_s514_adapter(sdlahw_t* hw, char find_first_S514_card)
-{
- unsigned char slot_no;
- int number_S514_cards = 0;
- char S514_found_in_slot = 0;
- u16 PCI_subsys_vendor;
-
- struct pci_dev *pci_dev = NULL;
-
- slot_no = hw->S514_slot_no;
-
- while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev))
- != NULL) {
-
- pci_read_config_word(pci_dev, PCI_SUBSYS_VENDOR_WORD,
- &PCI_subsys_vendor);
-
- if(PCI_subsys_vendor != SANGOMA_SUBSYS_VENDOR)
- continue;
-
- hw->pci_dev = pci_dev;
-
- if(find_first_S514_card)
- return(1);
-
- number_S514_cards ++;
-
- printk(KERN_INFO
- "%s: S514 card found, slot #%d (devfn 0x%X)\n",
- modname, ((pci_dev->devfn >> 3) & PCI_DEV_SLOT_MASK),
- pci_dev->devfn);
-
- if (hw->auto_pci_cfg){
- hw->S514_slot_no = ((pci_dev->devfn >> 3) & PCI_DEV_SLOT_MASK);
- slot_no = hw->S514_slot_no;
-
- }else if (((pci_dev->devfn >> 3) & PCI_DEV_SLOT_MASK) == slot_no){
- S514_found_in_slot = 1;
- break;
- }
- }
-
- /* if no S514 adapter has been found, then exit */
- if (!number_S514_cards) {
- printk(KERN_INFO "%s: Error, no S514 adapters found\n", modname);
- return 0;
- }
- /* if more than one S514 card has been found, then the user must have */ /* defined a slot number so that the correct adapter is used */
- else if ((number_S514_cards > 1) && hw->auto_pci_cfg) {
- printk(KERN_INFO "%s: Error, PCI Slot autodetect Failed! \n"
- "%s: More than one S514 adapter found.\n"
- "%s: Disable the Autodetect feature and supply\n"
- "%s: the PCISLOT numbers for each card.\n",
- modname,modname,modname,modname);
- return 0;
- }
- /* if the user has specified a slot number and the S514 adapter has */
- /* not been found in that slot, then exit */
- else if (!hw->auto_pci_cfg && !S514_found_in_slot) {
- printk(KERN_INFO
- "%s: Error, S514 card not found in specified slot #%d\n",
- modname, slot_no);
- return 0;
- }
-
- return (number_S514_cards);
-}
-
-
-
-/******* Miscellaneous ******************************************************/
-
-/*============================================================================
- * Calibrate SDLA memory access delay.
- * Count number of idle loops made within 1 second and then calculate the
- * number of loops that should be made to achive desired delay.
- */
-static int calibrate_delay (int mks)
-{
- unsigned int delay;
- unsigned long stop;
-
- for (delay = 0, stop = SYSTEM_TICK + HZ; SYSTEM_TICK < stop; ++delay);
- return (delay/(1000000L/mks) + 1);
-}
-
-/*============================================================================
- * Get option's index into the options list.
- * Return option's index (1 .. N) or zero if option is invalid.
- */
-static int get_option_index (unsigned* optlist, unsigned optval)
-{
- int i;
-
- for (i = 1; i <= optlist[0]; ++i)
- if ( optlist[i] == optval)
- return i;
- return 0;
-}
-
-/*============================================================================
- * Check memory region to see if it's available.
- * Return: 0 ok.
- */
-static unsigned check_memregion (void* ptr, unsigned len)
-{
- volatile unsigned char* p = ptr;
-
- for (; len && (readb (p) == 0xFF); --len, ++p) {
- writeb (0, p); /* attempt to write 0 */
- if (readb(p) != 0xFF) { /* still has to read 0xFF */
- writeb (0xFF, p);/* restore original value */
- break; /* not good */
- }
- }
-
- return len;
-}
-
-/*============================================================================
- * Test memory region.
- * Return: size of the region that passed the test.
- * Note: Region size must be multiple of 2 !
- */
-static unsigned test_memregion (void* ptr, unsigned len)
-{
- volatile unsigned short* w_ptr;
- unsigned len_w = len >> 1; /* region len in words */
- unsigned i;
-
- for (i = 0, w_ptr = ptr; i < len_w; ++i, ++w_ptr)
- writew (0xAA55, w_ptr);
-
- for (i = 0, w_ptr = ptr; i < len_w; ++i, ++w_ptr)
- if (readw (w_ptr) != 0xAA55) {
- len_w = i;
- break;
- }
-
- for (i = 0, w_ptr = ptr; i < len_w; ++i, ++w_ptr)
- writew (0x55AA, w_ptr);
-
- for (i = 0, w_ptr = ptr; i < len_w; ++i, ++w_ptr)
- if (readw(w_ptr) != 0x55AA) {
- len_w = i;
- break;
- }
-
- for (i = 0, w_ptr = ptr; i < len_w; ++i, ++w_ptr)
- writew (0, w_ptr);
-
- return len_w << 1;
-}
-
-/*============================================================================
- * Calculate 16-bit CRC using CCITT polynomial.
- */
-static unsigned short checksum (unsigned char* buf, unsigned len)
-{
- unsigned short crc = 0;
- unsigned mask, flag;
-
- for (; len; --len, ++buf) {
- for (mask = 0x80; mask; mask >>= 1) {
- flag = (crc & 0x8000);
- crc <<= 1;
- crc |= ((*buf & mask) ? 1 : 0);
- if (flag) crc ^= 0x1021;
- }
- }
- return crc;
-}
-
-static int init_pci_slot(sdlahw_t *hw)
-{
-
- u32 int_status;
- int volatile found=0;
- int i=0;
-
- /* Check if this is a very first load for a specific
- * pci card. If it is, clear the interrput bits, and
- * set the flag indicating that this card was initialized.
- */
-
- for (i=0; (i<MAX_S514_CARDS) && !found; i++){
- if (pci_slot_ar[i] == hw->S514_slot_no){
- found=1;
- break;
- }
- if (pci_slot_ar[i] == 0xFF){
- break;
- }
- }
-
- if (!found){
- read_S514_int_stat(hw,&int_status);
- S514_intack(hw,int_status);
- if (i == MAX_S514_CARDS){
- printk(KERN_INFO "%s: Critical Error !!!\n",modname);
- printk(KERN_INFO
- "%s: Number of Sangoma PCI cards exceeded maximum limit.\n",
- modname);
- printk(KERN_INFO "Please contact Sangoma Technologies\n");
- return 1;
- }
- pci_slot_ar[i] = hw->S514_slot_no;
- }
- return 0;
-}
-
-static int pci_probe(sdlahw_t *hw)
-{
-
- unsigned char slot_no;
- int number_S514_cards = 0;
- u16 PCI_subsys_vendor;
- u16 PCI_card_type;
-
- struct pci_dev *pci_dev = NULL;
- struct pci_bus *bus = NULL;
-
- slot_no = 0;
-
- while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev))
- != NULL) {
-
- pci_read_config_word(pci_dev, PCI_SUBSYS_VENDOR_WORD,
- &PCI_subsys_vendor);
-
- if(PCI_subsys_vendor != SANGOMA_SUBSYS_VENDOR)
- continue;
-
- pci_read_config_word(pci_dev, PCI_CARD_TYPE,
- &PCI_card_type);
-
- bus = pci_dev->bus;
-
- /* A dual cpu card can support up to 4 physical connections,
- * where a single cpu card can support up to 2 physical
- * connections. The FT1 card can only support a single
- * connection, however we cannot distinguish between a Single
- * CPU card and an FT1 card. */
- if (PCI_card_type == S514_DUAL_CPU){
- number_S514_cards += 4;
- printk(KERN_INFO
- "wanpipe: S514-PCI card found, cpu(s) 2, bus #%d, slot #%d, irq #%d\n",
- bus->number,((pci_dev->devfn >> 3) & PCI_DEV_SLOT_MASK),
- pci_dev->irq);
- }else{
- number_S514_cards += 2;
- printk(KERN_INFO
- "wanpipe: S514-PCI card found, cpu(s) 1, bus #%d, slot #%d, irq #%d\n",
- bus->number,((pci_dev->devfn >> 3) & PCI_DEV_SLOT_MASK),
- pci_dev->irq);
- }
- }
-
- return number_S514_cards;
-
-}
-
-
-
-EXPORT_SYMBOL(wanpipe_hw_probe);
-
-unsigned wanpipe_hw_probe(void)
-{
- sdlahw_t hw;
- unsigned* opt = s508_port_options;
- unsigned cardno=0;
- int i;
-
- memset(&hw, 0, sizeof(hw));
-
- for (i = 1; i <= opt[0]; i++) {
- if (detect_s508(opt[i])){
- /* S508 card can support up to two physical links */
- cardno+=2;
- printk(KERN_INFO "wanpipe: S508-ISA card found, port 0x%x\n",opt[i]);
- }
- }
-
- #ifdef CONFIG_PCI
- hw.S514_slot_no = 0;
- cardno += pci_probe(&hw);
- #else
- printk(KERN_INFO "wanpipe: Warning, Kernel not compiled for PCI support!\n");
- printk(KERN_INFO "wanpipe: PCI Hardware Probe Failed!\n");
- #endif
-
- return cardno;
-}
-
-/****** End *****************************************************************/
diff --git a/drivers/net/wan/sdlamain.c b/drivers/net/wan/sdlamain.c
deleted file mode 100644
index 7a8b22a7ea31e..0000000000000
--- a/drivers/net/wan/sdlamain.c
+++ /dev/null
@@ -1,1346 +0,0 @@
-/****************************************************************************
-* sdlamain.c WANPIPE(tm) Multiprotocol WAN Link Driver. Main module.
-*
-* Author: Nenad Corbic <ncorbic@sangoma.com>
-* Gideon Hack
-*
-* Copyright: (c) 1995-2000 Sangoma Technologies 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.
-* ============================================================================
-* Dec 22, 2000 Nenad Corbic Updated for 2.4.X kernels.
-* Removed the polling routine.
-* Nov 13, 2000 Nenad Corbic Added hw probing on module load and dynamic
-* device allocation.
-* Nov 7, 2000 Nenad Corbic Fixed the Multi-Port PPP for kernels
-* 2.2.16 and above.
-* Aug 2, 2000 Nenad Corbic Block the Multi-Port PPP from running on
-* kernels 2.2.16 or greater. The SyncPPP
-* has changed.
-* Jul 25, 2000 Nenad Corbic Updated the Piggiback support for MultPPPP.
-* Jul 13, 2000 Nenad Corbic Added Multi-PPP support.
-* Feb 02, 2000 Nenad Corbic Fixed up piggyback probing and selection.
-* Sep 23, 1999 Nenad Corbic Added support for SMP
-* Sep 13, 1999 Nenad Corbic Each port is treated as a separate device.
-* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
-* Updates for Linux 2.2.X kernels.
-* Sep 17, 1998 Jaspreet Singh Updated for 2.1.121+ kernel
-* Nov 28, 1997 Jaspreet Singh Changed DRV_RELEASE to 1
-* Nov 10, 1997 Jaspreet Singh Changed sti() to restore_flags();
-* Nov 06, 1997 Jaspreet Singh Changed DRV_VERSION to 4 and DRV_RELEASE to 0
-* Oct 20, 1997 Jaspreet Singh Modified sdla_isr routine so that card->in_isr
-* assignments are taken out and placed in the
-* sdla_ppp.c, sdla_fr.c and sdla_x25.c isr
-* routines. Took out 'wandev->tx_int_enabled' and
-* replaced it with 'wandev->enable_tx_int'.
-* May 29, 1997 Jaspreet Singh Flow Control Problem
-* added "wandev->tx_int_enabled=1" line in the
-* init module. This line initializes the flag for
-* preventing Interrupt disabled with device set to
-* busy
-* Jan 15, 1997 Gene Kozin Version 3.1.0
-* o added UDP management stuff
-* Jan 02, 1997 Gene Kozin Initial version.
-*****************************************************************************/
-
-#include <linux/config.h> /* OS configuration options */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/init.h>
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/module.h> /* support for loadable modules */
-#include <linux/ioport.h> /* request_region(), release_region() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/rcupdate.h>
-
-#include <linux/in.h>
-#include <asm/io.h> /* phys_to_virt() */
-#include <linux/pci.h>
-#include <linux/sdlapci.h>
-#include <linux/if_wanpipe_common.h>
-
-#include <asm/uaccess.h> /* kernel <-> user copy */
-#include <linux/inetdevice.h>
-
-#include <linux/ip.h>
-#include <net/route.h>
-
-#define KMEM_SAFETYZONE 8
-
-
-#ifndef CONFIG_WANPIPE_FR
- #define wpf_init(a,b) (-EPROTONOSUPPORT)
-#endif
-
-#ifndef CONFIG_WANPIPE_CHDLC
- #define wpc_init(a,b) (-EPROTONOSUPPORT)
-#endif
-
-#ifndef CONFIG_WANPIPE_X25
- #define wpx_init(a,b) (-EPROTONOSUPPORT)
-#endif
-
-#ifndef CONFIG_WANPIPE_PPP
- #define wpp_init(a,b) (-EPROTONOSUPPORT)
-#endif
-
-#ifndef CONFIG_WANPIPE_MULTPPP
- #define wsppp_init(a,b) (-EPROTONOSUPPORT)
-#endif
-
-
-/***********FOR DEBUGGING PURPOSES*********************************************
-static void * dbg_kmalloc(unsigned int size, int prio, int line) {
- int i = 0;
- void * v = kmalloc(size+sizeof(unsigned int)+2*KMEM_SAFETYZONE*8,prio);
- char * c1 = v;
- c1 += sizeof(unsigned int);
- *((unsigned int *)v) = size;
-
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- c1[0] = 'D'; c1[1] = 'E'; c1[2] = 'A'; c1[3] = 'D';
- c1[4] = 'B'; c1[5] = 'E'; c1[6] = 'E'; c1[7] = 'F';
- c1 += 8;
- }
- c1 += size;
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- c1[0] = 'M'; c1[1] = 'U'; c1[2] = 'N'; c1[3] = 'G';
- c1[4] = 'W'; c1[5] = 'A'; c1[6] = 'L'; c1[7] = 'L';
- c1 += 8;
- }
- v = ((char *)v) + sizeof(unsigned int) + KMEM_SAFETYZONE*8;
- printk(KERN_INFO "line %d kmalloc(%d,%d) = %p\n",line,size,prio,v);
- return v;
-}
-static void dbg_kfree(void * v, int line) {
- unsigned int * sp = (unsigned int *)(((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8));
- unsigned int size = *sp;
- char * c1 = ((char *)v) - KMEM_SAFETYZONE*8;
- int i = 0;
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- if ( c1[0] != 'D' || c1[1] != 'E' || c1[2] != 'A' || c1[3] != 'D'
- || c1[4] != 'B' || c1[5] != 'E' || c1[6] != 'E' || c1[7] != 'F') {
- printk(KERN_INFO "kmalloced block at %p has been corrupted (underrun)!\n",v);
- printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
- c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
- }
- c1 += 8;
- }
- c1 += size;
- for (i = 0; i < KMEM_SAFETYZONE; i++) {
- if ( c1[0] != 'M' || c1[1] != 'U' || c1[2] != 'N' || c1[3] != 'G'
- || c1[4] != 'W' || c1[5] != 'A' || c1[6] != 'L' || c1[7] != 'L'
- ) {
- printk(KERN_INFO "kmalloced block at %p has been corrupted (overrun):\n",v);
- printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
- c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
- }
- c1 += 8;
- }
- printk(KERN_INFO "line %d kfree(%p)\n",line,v);
- v = ((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8);
- kfree(v);
-}
-
-#define kmalloc(x,y) dbg_kmalloc(x,y,__LINE__)
-#define kfree(x) dbg_kfree(x,__LINE__)
-******************************************************************************/
-
-
-
-/****** Defines & Macros ****************************************************/
-
-#ifdef _DEBUG_
-#define STATIC
-#else
-#define STATIC static
-#endif
-
-#define DRV_VERSION 5 /* version number */
-#define DRV_RELEASE 0 /* release (minor version) number */
-#define MAX_CARDS 16 /* max number of adapters */
-
-#ifndef CONFIG_WANPIPE_CARDS /* configurable option */
-#define CONFIG_WANPIPE_CARDS 1
-#endif
-
-#define CMD_OK 0 /* normal firmware return code */
-#define CMD_TIMEOUT 0xFF /* firmware command timed out */
-#define MAX_CMD_RETRY 10 /* max number of firmware retries */
-/****** Function Prototypes *************************************************/
-
-extern void disable_irq(unsigned int);
-extern void enable_irq(unsigned int);
-
-/* WAN link driver entry points */
-static int setup(struct wan_device* wandev, wandev_conf_t* conf);
-static int shutdown(struct wan_device* wandev);
-static int ioctl(struct wan_device* wandev, unsigned cmd, unsigned long arg);
-
-/* IOCTL handlers */
-static int ioctl_dump (sdla_t* card, sdla_dump_t* u_dump);
-static int ioctl_exec (sdla_t* card, sdla_exec_t* u_exec, int);
-
-/* Miscellaneous functions */
-STATIC irqreturn_t sdla_isr (int irq, void* dev_id, struct pt_regs *regs);
-static void release_hw (sdla_t *card);
-
-static int check_s508_conflicts (sdla_t* card,wandev_conf_t* conf, int*);
-static int check_s514_conflicts (sdla_t* card,wandev_conf_t* conf, int*);
-
-
-/****** Global Data **********************************************************
- * Note: All data must be explicitly initialized!!!
- */
-
-/* private data */
-static char drvname[] = "wanpipe";
-static char fullname[] = "WANPIPE(tm) Multiprotocol Driver";
-static char copyright[] = "(c) 1995-2000 Sangoma Technologies Inc.";
-static int ncards;
-static sdla_t* card_array; /* adapter data space */
-
-/* Wanpipe's own workqueue, used for all API's.
- * All protocol specific tasks will be inserted
- * into the "wanpipe_wq" workqueue.
-
- * The kernel workqueue mechanism will execute
- * all pending tasks in the "wanpipe_wq" workqueue.
- */
-
-struct workqueue_struct *wanpipe_wq;
-DECLARE_WORK(wanpipe_work, NULL, NULL);
-
-static int wanpipe_bh_critical;
-
-/******* Kernel Loadable Module Entry Points ********************************/
-
-/*============================================================================
- * Module 'insert' entry point.
- * o print announcement
- * o allocate adapter data space
- * o initialize static data
- * o register all cards with WAN router
- * o calibrate SDLA shared memory access delay.
- *
- * Return: 0 Ok
- * < 0 error.
- * Context: process
- */
-
-static int __init wanpipe_init(void)
-{
- int cnt, err = 0;
-
- printk(KERN_INFO "%s v%u.%u %s\n",
- fullname, DRV_VERSION, DRV_RELEASE, copyright);
-
- wanpipe_wq = create_workqueue("wanpipe_wq");
- if (!wanpipe_wq)
- return -ENOMEM;
-
- /* Probe for wanpipe cards and return the number found */
- printk(KERN_INFO "wanpipe: Probing for WANPIPE hardware.\n");
- ncards = wanpipe_hw_probe();
- if (ncards){
- printk(KERN_INFO "wanpipe: Allocating maximum %i devices: wanpipe%i - wanpipe%i.\n",ncards,1,ncards);
- }else{
- printk(KERN_INFO "wanpipe: No S514/S508 cards found, unloading modules!\n");
- destroy_workqueue(wanpipe_wq);
- return -ENODEV;
- }
-
- /* Verify number of cards and allocate adapter data space */
- card_array = kmalloc(sizeof(sdla_t) * ncards, GFP_KERNEL);
- if (card_array == NULL) {
- destroy_workqueue(wanpipe_wq);
- return -ENOMEM;
- }
-
- memset(card_array, 0, sizeof(sdla_t) * ncards);
-
- /* Register adapters with WAN router */
- for (cnt = 0; cnt < ncards; ++ cnt) {
- sdla_t* card = &card_array[cnt];
- struct wan_device* wandev = &card->wandev;
-
- card->next = NULL;
- sprintf(card->devname, "%s%d", drvname, cnt + 1);
- wandev->magic = ROUTER_MAGIC;
- wandev->name = card->devname;
- wandev->private = card;
- wandev->enable_tx_int = 0;
- wandev->setup = &setup;
- wandev->shutdown = &shutdown;
- wandev->ioctl = &ioctl;
- err = register_wan_device(wandev);
- if (err) {
- printk(KERN_INFO
- "%s: %s registration failed with error %d!\n",
- drvname, card->devname, err);
- break;
- }
- }
- if (cnt){
- ncards = cnt; /* adjust actual number of cards */
- }else {
- kfree(card_array);
- destroy_workqueue(wanpipe_wq);
- printk(KERN_INFO "IN Init Module: NO Cards registered\n");
- err = -ENODEV;
- }
-
- return err;
-}
-
-/*============================================================================
- * Module 'remove' entry point.
- * o unregister all adapters from the WAN router
- * o release all remaining system resources
- */
-static void __exit wanpipe_cleanup(void)
-{
- int i;
-
- if (!ncards)
- return;
-
- for (i = 0; i < ncards; ++i) {
- sdla_t* card = &card_array[i];
- unregister_wan_device(card->devname);
- }
- destroy_workqueue(wanpipe_wq);
- kfree(card_array);
-
- printk(KERN_INFO "\nwanpipe: WANPIPE Modules Unloaded.\n");
-}
-
-module_init(wanpipe_init);
-module_exit(wanpipe_cleanup);
-
-/******* WAN Device Driver Entry Points *************************************/
-
-/*============================================================================
- * Setup/configure WAN link driver.
- * o check adapter state
- * o make sure firmware is present in configuration
- * o make sure I/O port and IRQ are specified
- * o make sure I/O region is available
- * o allocate interrupt vector
- * o setup SDLA hardware
- * o call appropriate routine to perform protocol-specific initialization
- * o mark I/O region as used
- * o if this is the first active card, then schedule background task
- *
- * This function is called when router handles ROUTER_SETUP IOCTL. The
- * configuration structure is in kernel memory (including extended data, if
- * any).
- */
-
-static int setup(struct wan_device* wandev, wandev_conf_t* conf)
-{
- sdla_t* card;
- int err = 0;
- int irq=0;
-
- /* Sanity checks */
- if ((wandev == NULL) || (wandev->private == NULL) || (conf == NULL)){
- printk(KERN_INFO
- "%s: Failed Sdlamain Setup wandev %u, card %u, conf %u !\n",
- wandev->name,
- (unsigned int)wandev,(unsigned int)wandev->private,
- (unsigned int)conf);
- return -EFAULT;
- }
-
- printk(KERN_INFO "%s: Starting WAN Setup\n", wandev->name);
-
- card = wandev->private;
- if (wandev->state != WAN_UNCONFIGURED){
- printk(KERN_INFO "%s: failed sdlamain setup, busy!\n",
- wandev->name);
- return -EBUSY; /* already configured */
- }
-
- printk(KERN_INFO "\nProcessing WAN device %s...\n", wandev->name);
-
- /* Initialize the counters for each wandev
- * Used for counting number of times new_if and
- * del_if get called.
- */
- wandev->del_if_cnt = 0;
- wandev->new_if_cnt = 0;
- wandev->config_id = conf->config_id;
-
- if (!conf->data_size || (conf->data == NULL)) {
- printk(KERN_INFO
- "%s: firmware not found in configuration data!\n",
- wandev->name);
- return -EINVAL;
- }
-
- /* Check for resource conflicts and setup the
- * card for piggibacking if necessary */
- if(!conf->S514_CPU_no[0]) {
- if ((err=check_s508_conflicts(card,conf,&irq)) != 0){
- return err;
- }
- }else {
- if ((err=check_s514_conflicts(card,conf,&irq)) != 0){
- return err;
- }
- }
-
- /* If the current card has already been configured
- * or it's a piggyback card, do not try to allocate
- * resources.
- */
- if (!card->wandev.piggyback && !card->configured){
-
- /* Configure hardware, load firmware, etc. */
- memset(&card->hw, 0, sizeof(sdlahw_t));
-
- /* for an S514 adapter, pass the CPU number and the slot number read */
- /* from 'router.conf' to the 'sdla_setup()' function via the 'port' */
- /* parameter */
- if (conf->S514_CPU_no[0]){
-
- card->hw.S514_cpu_no[0] = conf->S514_CPU_no[0];
- card->hw.S514_slot_no = conf->PCI_slot_no;
- card->hw.auto_pci_cfg = conf->auto_pci_cfg;
-
- if (card->hw.auto_pci_cfg == WANOPT_YES){
- printk(KERN_INFO "%s: Setting CPU to %c and Slot to Auto\n",
- card->devname, card->hw.S514_cpu_no[0]);
- }else{
- printk(KERN_INFO "%s: Setting CPU to %c and Slot to %i\n",
- card->devname, card->hw.S514_cpu_no[0], card->hw.S514_slot_no);
- }
-
- }else{
- /* 508 Card io port and irq initialization */
- card->hw.port = conf->ioport;
- card->hw.irq = (conf->irq == 9) ? 2 : conf->irq;
- }
-
-
- /* Compute the virtual address of the card in kernel space */
- if(conf->maddr){
- card->hw.dpmbase = phys_to_virt(conf->maddr);
- }else{
- card->hw.dpmbase = (void *)conf->maddr;
- }
-
- card->hw.dpmsize = SDLA_WINDOWSIZE;
-
- /* set the adapter type if using an S514 adapter */
- card->hw.type = (conf->S514_CPU_no[0]) ? SDLA_S514 : conf->hw_opt[0];
- card->hw.pclk = conf->hw_opt[1];
-
- err = sdla_setup(&card->hw, conf->data, conf->data_size);
- if (err){
- printk(KERN_INFO "%s: Hardware setup Failed %i\n",
- card->devname,err);
- return err;
- }
-
- if(card->hw.type != SDLA_S514)
- irq = (conf->irq == 2) ? 9 : conf->irq; /* IRQ2 -> IRQ9 */
- else
- irq = card->hw.irq;
-
- /* request an interrupt vector - note that interrupts may be shared */
- /* when using the S514 PCI adapter */
-
- if(request_irq(irq, sdla_isr,
- (card->hw.type == SDLA_S514) ? SA_SHIRQ : 0,
- wandev->name, card)){
-
- printk(KERN_INFO "%s: Can't reserve IRQ %d!\n", wandev->name, irq);
- return -EINVAL;
- }
-
- }else{
- printk(KERN_INFO "%s: Card Configured %lu or Piggybacking %i!\n",
- wandev->name,card->configured,card->wandev.piggyback);
- }
-
-
- if (!card->configured){
-
- /* Initialize the Spin lock */
- printk(KERN_INFO "%s: Initializing for SMP\n",wandev->name);
-
- /* Piggyback spin lock has already been initialized,
- * in check_s514/s508_conflicts() */
- if (!card->wandev.piggyback){
- spin_lock_init(&card->wandev.lock);
- }
-
- /* Intialize WAN device data space */
- wandev->irq = irq;
- wandev->dma = 0;
- if(card->hw.type != SDLA_S514){
- wandev->ioport = card->hw.port;
- }else{
- wandev->S514_cpu_no[0] = card->hw.S514_cpu_no[0];
- wandev->S514_slot_no = card->hw.S514_slot_no;
- }
- wandev->maddr = (unsigned long)card->hw.dpmbase;
- wandev->msize = card->hw.dpmsize;
- wandev->hw_opt[0] = card->hw.type;
- wandev->hw_opt[1] = card->hw.pclk;
- wandev->hw_opt[2] = card->hw.memory;
- wandev->hw_opt[3] = card->hw.fwid;
- }
-
- /* Protocol-specific initialization */
- switch (card->hw.fwid) {
-
- case SFID_X25_502:
- case SFID_X25_508:
- printk(KERN_INFO "%s: Starting X.25 Protocol Init.\n",
- card->devname);
- err = wpx_init(card, conf);
- break;
- case SFID_FR502:
- case SFID_FR508:
- printk(KERN_INFO "%s: Starting Frame Relay Protocol Init.\n",
- card->devname);
- err = wpf_init(card, conf);
- break;
- case SFID_PPP502:
- case SFID_PPP508:
- printk(KERN_INFO "%s: Starting PPP Protocol Init.\n",
- card->devname);
- err = wpp_init(card, conf);
- break;
-
- case SFID_CHDLC508:
- case SFID_CHDLC514:
- if (conf->ft1){
- printk(KERN_INFO "%s: Starting FT1 CSU/DSU Config Driver.\n",
- card->devname);
- err = wpft1_init(card, conf);
- break;
-
- }else if (conf->config_id == WANCONFIG_MPPP){
- printk(KERN_INFO "%s: Starting Multi-Port PPP Protocol Init.\n",
- card->devname);
- err = wsppp_init(card,conf);
- break;
-
- }else{
- printk(KERN_INFO "%s: Starting CHDLC Protocol Init.\n",
- card->devname);
- err = wpc_init(card, conf);
- break;
- }
- default:
- printk(KERN_INFO "%s: Error, Firmware is not supported %X %X!\n",
- wandev->name,card->hw.fwid,SFID_CHDLC508);
- err = -EPROTONOSUPPORT;
- }
-
- if (err != 0){
- if (err == -EPROTONOSUPPORT){
- printk(KERN_INFO
- "%s: Error, Protocol selected has not been compiled!\n",
- card->devname);
- printk(KERN_INFO
- "%s: Re-configure the kernel and re-build the modules!\n",
- card->devname);
- }
-
- release_hw(card);
- wandev->state = WAN_UNCONFIGURED;
- return err;
- }
-
-
- /* Reserve I/O region and schedule background task */
- if(card->hw.type != SDLA_S514 && !card->wandev.piggyback)
- if (!request_region(card->hw.port, card->hw.io_range,
- wandev->name)) {
- printk(KERN_WARNING "port 0x%04x busy\n", card->hw.port);
- release_hw(card);
- wandev->state = WAN_UNCONFIGURED;
- return -EBUSY;
- }
-
- /* Only use the polling routine for the X25 protocol */
-
- card->wandev.critical=0;
- return 0;
-}
-
-/*==================================================================
- * configure_s508_card
- *
- * For a S508 adapter, check for a possible configuration error in that
- * we are loading an adapter in the same IO port as a previously loaded S508
- * card.
- */
-
-static int check_s508_conflicts (sdla_t* card,wandev_conf_t* conf, int *irq)
-{
- unsigned long smp_flags;
- int i;
-
- if (conf->ioport <= 0) {
- printk(KERN_INFO
- "%s: can't configure without I/O port address!\n",
- card->wandev.name);
- return -EINVAL;
- }
-
- if (conf->irq <= 0) {
- printk(KERN_INFO "%s: can't configure without IRQ!\n",
- card->wandev.name);
- return -EINVAL;
- }
-
- if (test_bit(0,&card->configured))
- return 0;
-
-
- /* Check for already loaded card with the same IO port and IRQ
- * If found, copy its hardware configuration and use its
- * resources (i.e. piggybacking)
- */
-
- for (i = 0; i < ncards; i++) {
- sdla_t *nxt_card = &card_array[i];
-
- /* Skip the current card ptr */
- if (nxt_card == card)
- continue;
-
-
- /* Find a card that is already configured with the
- * same IO Port */
- if ((nxt_card->hw.type == SDLA_S508) &&
- (nxt_card->hw.port == conf->ioport) &&
- (nxt_card->next == NULL)){
-
- /* We found a card the card that has same configuration
- * as us. This means, that we must setup this card in
- * piggibacking mode. However, only CHDLC and MPPP protocol
- * support this setup */
-
- if ((conf->config_id == WANCONFIG_CHDLC ||
- conf->config_id == WANCONFIG_MPPP) &&
- (nxt_card->wandev.config_id == WANCONFIG_CHDLC ||
- nxt_card->wandev.config_id == WANCONFIG_MPPP)){
-
- *irq = nxt_card->hw.irq;
- memcpy(&card->hw, &nxt_card->hw, sizeof(sdlahw_t));
-
- /* The master could already be running, we must
- * set this as a critical area */
- lock_adapter_irq(&nxt_card->wandev.lock, &smp_flags);
-
- nxt_card->next = card;
- card->next = nxt_card;
-
- card->wandev.piggyback = WANOPT_YES;
-
- /* We must initialise the piggiback spin lock here
- * since isr will try to lock card->next if it
- * exists */
- spin_lock_init(&card->wandev.lock);
-
- unlock_adapter_irq(&nxt_card->wandev.lock, &smp_flags);
- break;
- }else{
- /* Trying to run piggibacking with a wrong protocol */
- printk(KERN_INFO "%s: ERROR: Resource busy, ioport: 0x%x\n"
- "%s: This protocol doesn't support\n"
- "%s: multi-port operation!\n",
- card->devname,nxt_card->hw.port,
- card->devname,card->devname);
- return -EEXIST;
- }
- }
- }
-
-
- /* Make sure I/O port region is available only if we are the
- * master device. If we are running in piggybacking mode,
- * we will use the resources of the master card. */
- if (!card->wandev.piggyback) {
- struct resource *rr =
- request_region(conf->ioport, SDLA_MAXIORANGE, "sdlamain");
- release_region(conf->ioport, SDLA_MAXIORANGE);
-
- if (!rr) {
- printk(KERN_INFO
- "%s: I/O region 0x%X - 0x%X is in use!\n",
- card->wandev.name, conf->ioport,
- conf->ioport + SDLA_MAXIORANGE - 1);
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-/*==================================================================
- * configure_s514_card
- *
- * For a S514 adapter, check for a possible configuration error in that
- * we are loading an adapter in the same slot as a previously loaded S514
- * card.
- */
-
-
-static int check_s514_conflicts(sdla_t* card,wandev_conf_t* conf, int *irq)
-{
- unsigned long smp_flags;
- int i;
-
- if (test_bit(0,&card->configured))
- return 0;
-
-
- /* Check for already loaded card with the same IO port and IRQ
- * If found, copy its hardware configuration and use its
- * resources (i.e. piggybacking)
- */
-
- for (i = 0; i < ncards; i ++) {
-
- sdla_t* nxt_card = &card_array[i];
- if(nxt_card == card)
- continue;
-
- if((nxt_card->hw.type == SDLA_S514) &&
- (nxt_card->hw.S514_slot_no == conf->PCI_slot_no) &&
- (nxt_card->hw.S514_cpu_no[0] == conf->S514_CPU_no[0])&&
- (nxt_card->next == NULL)){
-
-
- if ((conf->config_id == WANCONFIG_CHDLC ||
- conf->config_id == WANCONFIG_MPPP) &&
- (nxt_card->wandev.config_id == WANCONFIG_CHDLC ||
- nxt_card->wandev.config_id == WANCONFIG_MPPP)){
-
- *irq = nxt_card->hw.irq;
- memcpy(&card->hw, &nxt_card->hw, sizeof(sdlahw_t));
-
- /* The master could already be running, we must
- * set this as a critical area */
- lock_adapter_irq(&nxt_card->wandev.lock,&smp_flags);
- nxt_card->next = card;
- card->next = nxt_card;
-
- card->wandev.piggyback = WANOPT_YES;
-
- /* We must initialise the piggiback spin lock here
- * since isr will try to lock card->next if it
- * exists */
- spin_lock_init(&card->wandev.lock);
-
- unlock_adapter_irq(&nxt_card->wandev.lock,&smp_flags);
-
- }else{
- /* Trying to run piggibacking with a wrong protocol */
- printk(KERN_INFO "%s: ERROR: Resource busy: CPU %c PCISLOT %i\n"
- "%s: This protocol doesn't support\n"
- "%s: multi-port operation!\n",
- card->devname,
- conf->S514_CPU_no[0],conf->PCI_slot_no,
- card->devname,card->devname);
- return -EEXIST;
- }
- }
- }
-
- return 0;
-}
-
-
-
-/*============================================================================
- * Shut down WAN link driver.
- * o shut down adapter hardware
- * o release system resources.
- *
- * This function is called by the router when device is being unregistered or
- * when it handles ROUTER_DOWN IOCTL.
- */
-static int shutdown(struct wan_device* wandev)
-{
- sdla_t *card;
- int err=0;
-
- /* sanity checks */
- if ((wandev == NULL) || (wandev->private == NULL)){
- return -EFAULT;
- }
-
- if (wandev->state == WAN_UNCONFIGURED){
- return 0;
- }
-
- card = wandev->private;
-
- if (card->tty_opt){
- if (card->tty_open){
- printk(KERN_INFO
- "%s: Shutdown Failed: TTY is still open\n",
- card->devname);
- return -EBUSY;
- }
- }
-
- wandev->state = WAN_UNCONFIGURED;
-
- set_bit(PERI_CRIT,(void*)&wandev->critical);
-
- /* In case of piggibacking, make sure that
- * we never try to shutdown both devices at the same
- * time, because they depend on one another */
-
- if (card->disable_comm){
- card->disable_comm(card);
- }
-
- /* Release Resources */
- release_hw(card);
-
- /* only free the allocated I/O range if not an S514 adapter */
- if (wandev->hw_opt[0] != SDLA_S514 && !card->configured){
- release_region(card->hw.port, card->hw.io_range);
- }
-
- if (!card->configured){
- memset(&card->hw, 0, sizeof(sdlahw_t));
- if (card->next){
- memset(&card->next->hw, 0, sizeof(sdlahw_t));
- }
- }
-
-
- clear_bit(PERI_CRIT,(void*)&wandev->critical);
- return err;
-}
-
-static void release_hw (sdla_t *card)
-{
- sdla_t *nxt_card;
-
-
- /* Check if next device exists */
- if (card->next){
- nxt_card = card->next;
- /* If next device is down then release resources */
- if (nxt_card->wandev.state == WAN_UNCONFIGURED){
- if (card->wandev.piggyback){
- /* If this device is piggyback then use
- * information of the master device
- */
- printk(KERN_INFO "%s: Piggyback shutting down\n",card->devname);
- sdla_down(&card->next->hw);
- free_irq(card->wandev.irq, card->next);
- card->configured = 0;
- card->next->configured = 0;
- card->wandev.piggyback = 0;
- }else{
- /* Master device shutting down */
- printk(KERN_INFO "%s: Master shutting down\n",card->devname);
- sdla_down(&card->hw);
- free_irq(card->wandev.irq, card);
- card->configured = 0;
- card->next->configured = 0;
- }
- }else{
- printk(KERN_INFO "%s: Device still running %i\n",
- nxt_card->devname,nxt_card->wandev.state);
-
- card->configured = 1;
- }
- }else{
- printk(KERN_INFO "%s: Master shutting down\n",card->devname);
- sdla_down(&card->hw);
- free_irq(card->wandev.irq, card);
- card->configured = 0;
- }
- return;
-}
-
-
-/*============================================================================
- * Driver I/O control.
- * o verify arguments
- * o perform requested action
- *
- * This function is called when router handles one of the reserved user
- * IOCTLs. Note that 'arg' stil points to user address space.
- */
-static int ioctl(struct wan_device* wandev, unsigned cmd, unsigned long arg)
-{
- sdla_t* card;
- int err;
-
- /* sanity checks */
- if ((wandev == NULL) || (wandev->private == NULL))
- return -EFAULT;
- if (wandev->state == WAN_UNCONFIGURED)
- return -ENODEV;
-
- card = wandev->private;
-
- if(card->hw.type != SDLA_S514){
- disable_irq(card->hw.irq);
- }
-
- if (test_bit(SEND_CRIT, (void*)&wandev->critical)) {
- return -EAGAIN;
- }
-
- switch (cmd) {
- case WANPIPE_DUMP:
- err = ioctl_dump(wandev->private, (void*)arg);
- break;
-
- case WANPIPE_EXEC:
- err = ioctl_exec(wandev->private, (void*)arg, cmd);
- break;
- default:
- err = -EINVAL;
- }
-
- return err;
-}
-
-/****** Driver IOCTL Handlers ***********************************************/
-
-/*============================================================================
- * Dump adapter memory to user buffer.
- * o verify request structure
- * o copy request structure to kernel data space
- * o verify length/offset
- * o verify user buffer
- * o copy adapter memory image to user buffer
- *
- * Note: when dumping memory, this routine switches curent dual-port memory
- * vector, so care must be taken to avoid racing conditions.
- */
-static int ioctl_dump (sdla_t* card, sdla_dump_t* u_dump)
-{
- sdla_dump_t dump;
- unsigned winsize;
- unsigned long oldvec; /* DPM window vector */
- unsigned long smp_flags;
- int err = 0;
-
- if(copy_from_user((void*)&dump, (void*)u_dump, sizeof(sdla_dump_t)))
- return -EFAULT;
-
- if ((dump.magic != WANPIPE_MAGIC) ||
- (dump.offset + dump.length > card->hw.memory))
- return -EINVAL;
-
- winsize = card->hw.dpmsize;
-
- if(card->hw.type != SDLA_S514) {
-
- lock_adapter_irq(&card->wandev.lock, &smp_flags);
-
- oldvec = card->hw.vector;
- while (dump.length) {
- /* current offset */
- unsigned pos = dump.offset % winsize;
- /* current vector */
- unsigned long vec = dump.offset - pos;
- unsigned len = (dump.length > (winsize - pos)) ?
- (winsize - pos) : dump.length;
- /* relocate window */
- if (sdla_mapmem(&card->hw, vec) != 0) {
- err = -EIO;
- break;
- }
-
- if(copy_to_user((void *)dump.ptr,
- (u8 *)card->hw.dpmbase + pos, len)){
-
- unlock_adapter_irq(&card->wandev.lock, &smp_flags);
- return -EFAULT;
- }
-
- dump.length -= len;
- dump.offset += len;
- dump.ptr = (char*)dump.ptr + len;
- }
-
- sdla_mapmem(&card->hw, oldvec);/* restore DPM window position */
- unlock_adapter_irq(&card->wandev.lock, &smp_flags);
-
- }else {
-
- if(copy_to_user((void *)dump.ptr,
- (u8 *)card->hw.dpmbase + dump.offset, dump.length)){
- return -EFAULT;
- }
- }
-
- return err;
-}
-
-/*============================================================================
- * Execute adapter firmware command.
- * o verify request structure
- * o copy request structure to kernel data space
- * o call protocol-specific 'exec' function
- */
-static int ioctl_exec (sdla_t* card, sdla_exec_t* u_exec, int cmd)
-{
- sdla_exec_t exec;
- int err=0;
-
- if (card->exec == NULL && cmd == WANPIPE_EXEC){
- return -ENODEV;
- }
-
- if(copy_from_user((void*)&exec, (void*)u_exec, sizeof(sdla_exec_t)))
- return -EFAULT;
-
- if ((exec.magic != WANPIPE_MAGIC) || (exec.cmd == NULL))
- return -EINVAL;
-
- switch (cmd) {
- case WANPIPE_EXEC:
- err = card->exec(card, exec.cmd, exec.data);
- break;
- }
- return err;
-}
-
-/******* Miscellaneous ******************************************************/
-
-/*============================================================================
- * SDLA Interrupt Service Routine.
- * o acknowledge SDLA hardware interrupt.
- * o call protocol-specific interrupt service routine, if any.
- */
-STATIC irqreturn_t sdla_isr (int irq, void* dev_id, struct pt_regs *regs)
-{
-#define card ((sdla_t*)dev_id)
-
- if(card->hw.type == SDLA_S514) { /* handle interrrupt on S514 */
- u32 int_status;
- unsigned char CPU_no = card->hw.S514_cpu_no[0];
- unsigned char card_found_for_IRQ;
- u8 IRQ_count = 0;
-
- for(;;) {
-
- read_S514_int_stat(&card->hw, &int_status);
-
- /* check if the interrupt is for this device */
- if(!((unsigned char)int_status &
- (IRQ_CPU_A | IRQ_CPU_B)))
- return IRQ_HANDLED;
-
- /* if the IRQ is for both CPUs on the same adapter, */
- /* then alter the interrupt status so as to handle */
- /* one CPU at a time */
- if(((unsigned char)int_status & (IRQ_CPU_A | IRQ_CPU_B))
- == (IRQ_CPU_A | IRQ_CPU_B)) {
- int_status &= (CPU_no == S514_CPU_A) ?
- ~IRQ_CPU_B : ~IRQ_CPU_A;
- }
-
- card_found_for_IRQ = 0;
-
- /* check to see that the CPU number for this device */
- /* corresponds to the interrupt status read */
- switch (CPU_no) {
- case S514_CPU_A:
- if((unsigned char)int_status &
- IRQ_CPU_A)
- card_found_for_IRQ = 1;
- break;
-
- case S514_CPU_B:
- if((unsigned char)int_status &
- IRQ_CPU_B)
- card_found_for_IRQ = 1;
- break;
- }
-
- /* exit if the interrupt is for another CPU on the */
- /* same IRQ */
- if(!card_found_for_IRQ)
- return IRQ_HANDLED;
-
- if (!card ||
- (card->wandev.state == WAN_UNCONFIGURED && !card->configured)){
- printk(KERN_INFO
- "Received IRQ %d for CPU #%c\n",
- irq, CPU_no);
- printk(KERN_INFO
- "IRQ for unconfigured adapter\n");
- S514_intack(&card->hw, int_status);
- return IRQ_HANDLED;
- }
-
- if (card->in_isr) {
- printk(KERN_INFO
- "%s: interrupt re-entrancy on IRQ %d\n",
- card->devname, card->wandev.irq);
- S514_intack(&card->hw, int_status);
- return IRQ_HANDLED;
- }
-
- spin_lock(&card->wandev.lock);
- if (card->next){
- spin_lock(&card->next->wandev.lock);
- }
-
- S514_intack(&card->hw, int_status);
- if (card->isr)
- card->isr(card);
-
- if (card->next){
- spin_unlock(&card->next->wandev.lock);
- }
- spin_unlock(&card->wandev.lock);
-
- /* handle a maximum of two interrupts (one for each */
- /* CPU on the adapter) before returning */
- if((++ IRQ_count) == 2)
- return IRQ_HANDLED;
- }
- }
-
- else { /* handle interrupt on S508 adapter */
-
- if (!card || ((card->wandev.state == WAN_UNCONFIGURED) && !card->configured))
- return IRQ_HANDLED;
-
- if (card->in_isr) {
- printk(KERN_INFO
- "%s: interrupt re-entrancy on IRQ %d!\n",
- card->devname, card->wandev.irq);
- return IRQ_HANDLED;
- }
-
- spin_lock(&card->wandev.lock);
- if (card->next){
- spin_lock(&card->next->wandev.lock);
- }
-
- sdla_intack(&card->hw);
- if (card->isr)
- card->isr(card);
-
- if (card->next){
- spin_unlock(&card->next->wandev.lock);
- }
- spin_unlock(&card->wandev.lock);
-
- }
- return IRQ_HANDLED;
-#undef card
-}
-
-/*============================================================================
- * This routine is called by the protocol-specific modules when network
- * interface is being open. The only reason we need this, is because we
- * have to call MOD_INC_USE_COUNT, but cannot include 'module.h' where it's
- * defined more than once into the same kernel module.
- */
-void wanpipe_open (sdla_t* card)
-{
- ++card->open_cnt;
-}
-
-/*============================================================================
- * This routine is called by the protocol-specific modules when network
- * interface is being closed. The only reason we need this, is because we
- * have to call MOD_DEC_USE_COUNT, but cannot include 'module.h' where it's
- * defined more than once into the same kernel module.
- */
-void wanpipe_close (sdla_t* card)
-{
- --card->open_cnt;
-}
-
-/*============================================================================
- * Set WAN device state.
- */
-void wanpipe_set_state (sdla_t* card, int state)
-{
- if (card->wandev.state != state) {
- switch (state) {
- case WAN_CONNECTED:
- printk (KERN_INFO "%s: link connected!\n",
- card->devname);
- break;
-
- case WAN_CONNECTING:
- printk (KERN_INFO "%s: link connecting...\n",
- card->devname);
- break;
-
- case WAN_DISCONNECTED:
- printk (KERN_INFO "%s: link disconnected!\n",
- card->devname);
- break;
- }
- card->wandev.state = state;
- }
- card->state_tick = jiffies;
-}
-
-sdla_t * wanpipe_find_card (char *name)
-{
- int cnt;
- for (cnt = 0; cnt < ncards; ++ cnt) {
- sdla_t* card = &card_array[cnt];
- if (!strcmp(card->devname,name))
- return card;
- }
- return NULL;
-}
-
-sdla_t * wanpipe_find_card_num (int num)
-{
- if (num < 1 || num > ncards)
- return NULL;
- num--;
- return &card_array[num];
-}
-
-/*
- * @work_pointer: work_struct to be done;
- * should already have PREPARE_WORK() or
- * INIT_WORK() done on it by caller;
- */
-void wanpipe_queue_work (struct work_struct *work_pointer)
-{
- if (test_and_set_bit(1, (void*)&wanpipe_bh_critical))
- printk(KERN_INFO "CRITICAL IN QUEUING WORK\n");
-
- queue_work(wanpipe_wq, work_pointer);
- clear_bit(1,(void*)&wanpipe_bh_critical);
-}
-
-void wakeup_sk_bh(struct net_device *dev)
-{
- wanpipe_common_t *chan = dev->priv;
-
- if (test_bit(0,&chan->common_critical))
- return;
-
- if (chan->sk && chan->tx_timer){
- chan->tx_timer->expires=jiffies+1;
- add_timer(chan->tx_timer);
- }
-}
-
-int change_dev_flags(struct net_device *dev, unsigned flags)
-{
- struct ifreq if_info;
- mm_segment_t fs = get_fs();
- int err;
-
- memset(&if_info, 0, sizeof(if_info));
- strcpy(if_info.ifr_name, dev->name);
- if_info.ifr_flags = flags;
-
- set_fs(get_ds()); /* get user space block */
- err = devinet_ioctl(SIOCSIFFLAGS, &if_info);
- set_fs(fs);
-
- return err;
-}
-
-unsigned long get_ip_address(struct net_device *dev, int option)
-{
-
- struct in_ifaddr *ifaddr;
- struct in_device *in_dev;
- unsigned long addr = 0;
-
- rcu_read_lock();
- if ((in_dev = __in_dev_get_rcu(dev)) == NULL){
- goto out;
- }
-
- if ((ifaddr = in_dev->ifa_list)== NULL ){
- goto out;
- }
-
- switch (option){
-
- case WAN_LOCAL_IP:
- addr = ifaddr->ifa_local;
- break;
-
- case WAN_POINTOPOINT_IP:
- addr = ifaddr->ifa_address;
- break;
-
- case WAN_NETMASK_IP:
- addr = ifaddr->ifa_mask;
- break;
-
- case WAN_BROADCAST_IP:
- addr = ifaddr->ifa_broadcast;
- break;
- default:
- break;
- }
-
-out:
- rcu_read_unlock();
- return addr;
-}
-
-void add_gateway(sdla_t *card, struct net_device *dev)
-{
- mm_segment_t oldfs;
- struct rtentry route;
- int res;
-
- memset((char*)&route,0,sizeof(struct rtentry));
-
- ((struct sockaddr_in *)
- &(route.rt_dst))->sin_addr.s_addr = 0;
- ((struct sockaddr_in *)
- &(route.rt_dst))->sin_family = AF_INET;
-
- ((struct sockaddr_in *)
- &(route.rt_genmask))->sin_addr.s_addr = 0;
- ((struct sockaddr_in *)
- &(route.rt_genmask)) ->sin_family = AF_INET;
-
-
- route.rt_flags = 0;
- route.rt_dev = dev->name;
-
- oldfs = get_fs();
- set_fs(get_ds());
- res = ip_rt_ioctl(SIOCADDRT,&route);
- set_fs(oldfs);
-
- if (res == 0){
- printk(KERN_INFO "%s: Gateway added for %s\n",
- card->devname,dev->name);
- }
-
- return;
-}
-
-MODULE_LICENSE("GPL");
-
-/****** End *********************************************************/
diff --git a/drivers/net/wan/wanpipe_multppp.c b/drivers/net/wan/wanpipe_multppp.c
deleted file mode 100644
index 812a1183c502b..0000000000000
--- a/drivers/net/wan/wanpipe_multppp.c
+++ /dev/null
@@ -1,2358 +0,0 @@
-/*****************************************************************************
-* wanpipe_multppp.c Multi-Port PPP driver module.
-*
-* Authors: Nenad Corbic <ncorbic@sangoma.com>
-*
-* Copyright: (c) 1995-2001 Sangoma Technologies 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.
-* ============================================================================
-* Dec 15 2000 Updated for 2.4.X kernel
-* Nov 15 2000 Fixed the SyncPPP support for kernels 2.2.16 and higher.
-* The pppstruct has changed.
-* Jul 13 2000 Using the kernel Syncppp module on top of RAW Wanpipe CHDLC
-* module.
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h> /* printk(), and other useful stuff */
-#include <linux/stddef.h> /* offsetof(), etc. */
-#include <linux/errno.h> /* return codes */
-#include <linux/string.h> /* inline memset(), etc. */
-#include <linux/slab.h> /* kmalloc(), kfree() */
-#include <linux/wanrouter.h> /* WAN router definitions */
-#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
-#include <linux/if_arp.h> /* ARPHRD_* defines */
-#include <linux/jiffies.h> /* time_after() macro */
-
-#include <linux/in.h> /* sockaddr_in */
-#include <linux/inet.h>
-#include <linux/if.h>
-#include <asm/byteorder.h> /* htons(), etc. */
-#include <linux/sdlapci.h>
-#include <asm/io.h>
-
-#include <linux/sdla_chdlc.h> /* CHDLC firmware API definitions */
-#include <linux/sdla_asy.h> /* CHDLC (async) API definitions */
-
-#include <linux/if_wanpipe_common.h> /* Socket Driver common area */
-#include <linux/if_wanpipe.h>
-
-
-#include <linux/inetdevice.h>
-#include <asm/uaccess.h>
-
-#include <net/syncppp.h>
-
-
-/****** Defines & Macros ****************************************************/
-
-#ifdef _DEBUG_
-#define STATIC
-#else
-#define STATIC static
-#endif
-
-/* reasons for enabling the timer interrupt on the adapter */
-#define TMR_INT_ENABLED_UDP 0x01
-#define TMR_INT_ENABLED_UPDATE 0x02
-#define TMR_INT_ENABLED_CONFIG 0x04
-
-#define CHDLC_DFLT_DATA_LEN 1500 /* default MTU */
-#define CHDLC_HDR_LEN 1
-
-#define IFF_POINTTOPOINT 0x10
-
-#define CHDLC_API 0x01
-
-#define PORT(x) (x == 0 ? "PRIMARY" : "SECONDARY" )
-#define MAX_BH_BUFF 10
-
-#define CRC_LENGTH 2
-#define PPP_HEADER_LEN 4
-
-/******Data Structures*****************************************************/
-
-/* This structure is placed in the private data area of the device structure.
- * The card structure used to occupy the private area but now the following
- * structure will incorporate the card structure along with CHDLC specific data
- */
-
-typedef struct chdlc_private_area
-{
- void *if_ptr; /* General Pointer used by SPPP */
- wanpipe_common_t common;
- sdla_t *card;
- int TracingEnabled; /* For enabling Tracing */
- unsigned long curr_trace_addr; /* Used for Tracing */
- unsigned long start_trace_addr;
- unsigned long end_trace_addr;
- unsigned long base_addr_trace_buffer;
- unsigned long end_addr_trace_buffer;
- unsigned short number_trace_elements;
- unsigned available_buffer_space;
- unsigned long router_start_time;
- unsigned char route_status;
- unsigned char route_removed;
- unsigned long tick_counter; /* For 5s timeout counter */
- unsigned long router_up_time;
- u32 IP_address; /* IP addressing */
- u32 IP_netmask;
- unsigned char mc; /* Mulitcast support on/off */
- unsigned short udp_pkt_lgth; /* udp packet processing */
- char udp_pkt_src;
- char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
- unsigned short timer_int_enabled;
- char update_comms_stats; /* updating comms stats */
-
- //FIXME: add driver stats as per frame relay!
-
-} chdlc_private_area_t;
-
-/* Route Status options */
-#define NO_ROUTE 0x00
-#define ADD_ROUTE 0x01
-#define ROUTE_ADDED 0x02
-#define REMOVE_ROUTE 0x03
-
-
-/* variable for keeping track of enabling/disabling FT1 monitor status */
-static int rCount = 0;
-
-/* variable for tracking how many interfaces to open for WANPIPE on the
- two ports */
-
-extern void disable_irq(unsigned int);
-extern void enable_irq(unsigned int);
-
-/****** Function Prototypes *************************************************/
-/* WAN link driver entry points. These are called by the WAN router module. */
-static int update(struct wan_device* wandev);
-static int new_if(struct wan_device* wandev, struct net_device* dev,
- wanif_conf_t* conf);
-static int del_if(struct wan_device* wandev, struct net_device* dev);
-
-/* Network device interface */
-static int if_init(struct net_device* dev);
-static int if_open(struct net_device* dev);
-static int if_close(struct net_device* dev);
-static int if_send(struct sk_buff* skb, struct net_device* dev);
-static struct net_device_stats* if_stats(struct net_device* dev);
-
-static void if_tx_timeout(struct net_device *dev);
-
-/* CHDLC Firmware interface functions */
-static int chdlc_configure (sdla_t* card, void* data);
-static int chdlc_comm_enable (sdla_t* card);
-static int chdlc_comm_disable (sdla_t* card);
-static int chdlc_read_version (sdla_t* card, char* str);
-static int chdlc_set_intr_mode (sdla_t* card, unsigned mode);
-static int chdlc_send (sdla_t* card, void* data, unsigned len);
-static int chdlc_read_comm_err_stats (sdla_t* card);
-static int chdlc_read_op_stats (sdla_t* card);
-static int config_chdlc (sdla_t *card);
-
-
-/* Miscellaneous CHDLC Functions */
-static int set_chdlc_config (sdla_t* card);
-static void init_chdlc_tx_rx_buff(sdla_t* card, struct net_device *dev);
-static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb);
-static int process_chdlc_exception(sdla_t *card);
-static int process_global_exception(sdla_t *card);
-static int update_comms_stats(sdla_t* card,
- chdlc_private_area_t* chdlc_priv_area);
-static void port_set_state (sdla_t *card, int);
-
-/* Interrupt handlers */
-static void wsppp_isr (sdla_t* card);
-static void rx_intr (sdla_t* card);
-static void timer_intr(sdla_t *);
-
-/* Miscellaneous functions */
-static int reply_udp( unsigned char *data, unsigned int mbox_len );
-static int intr_test( sdla_t* card);
-static int udp_pkt_type( struct sk_buff *skb , sdla_t* card);
-static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area);
-static int process_udp_mgmt_pkt(sdla_t* card, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area);
-static unsigned short calc_checksum (char *, int);
-static void s508_lock (sdla_t *card, unsigned long *smp_flags);
-static void s508_unlock (sdla_t *card, unsigned long *smp_flags);
-static void send_ppp_term_request(struct net_device *dev);
-
-
-static int Intr_test_counter;
-/****** Public Functions ****************************************************/
-
-/*============================================================================
- * Cisco HDLC protocol initialization routine.
- *
- * This routine is called by the main WANPIPE module during setup. At this
- * point adapter is completely initialized and firmware is running.
- * o read firmware version (to make sure it's alive)
- * o configure adapter
- * o initialize protocol-specific fields of the adapter data space.
- *
- * Return: 0 o.k.
- * < 0 failure.
- */
-int wsppp_init (sdla_t* card, wandev_conf_t* conf)
-{
- unsigned char port_num;
- int err;
- unsigned long max_permitted_baud = 0;
- SHARED_MEMORY_INFO_STRUCT *flags;
-
- union
- {
- char str[80];
- } u;
- volatile CHDLC_MAILBOX_STRUCT* mb;
- CHDLC_MAILBOX_STRUCT* mb1;
- unsigned long timeout;
-
- /* Verify configuration ID */
- if (conf->config_id != WANCONFIG_MPPP) {
- printk(KERN_INFO "%s: invalid configuration ID %u!\n",
- card->devname, conf->config_id);
- return -EINVAL;
- }
-
- /* Find out which Port to use */
- if ((conf->comm_port == WANOPT_PRI) || (conf->comm_port == WANOPT_SEC)){
- if (card->next){
-
- if (conf->comm_port != card->next->u.c.comm_port){
- card->u.c.comm_port = conf->comm_port;
- }else{
- printk(KERN_ERR "%s: ERROR - %s port used!\n",
- card->wandev.name, PORT(conf->comm_port));
- return -EINVAL;
- }
- }else{
- card->u.c.comm_port = conf->comm_port;
- }
- }else{
- printk(KERN_ERR "%s: ERROR - Invalid Port Selected!\n",
- card->wandev.name);
- return -EINVAL;
- }
-
-
- /* Initialize protocol-specific fields */
- if(card->hw.type != SDLA_S514){
-
- if (card->u.c.comm_port == WANOPT_PRI){
- card->mbox = (void *) card->hw.dpmbase;
- }else{
- card->mbox = (void *) card->hw.dpmbase +
- SEC_BASE_ADDR_MB_STRUCT - PRI_BASE_ADDR_MB_STRUCT;
- }
- }else{
- /* for a S514 adapter, set a pointer to the actual mailbox in the */
- /* allocated virtual memory area */
- if (card->u.c.comm_port == WANOPT_PRI){
- card->mbox = (void *) card->hw.dpmbase + PRI_BASE_ADDR_MB_STRUCT;
- }else{
- card->mbox = (void *) card->hw.dpmbase + SEC_BASE_ADDR_MB_STRUCT;
- }
- }
-
- mb = mb1 = card->mbox;
-
- if (!card->configured){
-
- /* The board will place an 'I' in the return code to indicate that it is
- ready to accept commands. We expect this to be completed in less
- than 1 second. */
-
- timeout = jiffies + 1 * HZ;
- while (mb->return_code != 'I') /* Wait 1s for board to initialize */
- if (time_after(jiffies, timeout)) break;
-
- if (mb->return_code != 'I') {
- printk(KERN_INFO
- "%s: Initialization not completed by adapter\n",
- card->devname);
- printk(KERN_INFO "Please contact Sangoma representative.\n");
- return -EIO;
- }
- }
-
- /* Read firmware version. Note that when adapter initializes, it
- * clears the mailbox, so it may appear that the first command was
- * executed successfully when in fact it was merely erased. To work
- * around this, we execute the first command twice.
- */
-
- if (chdlc_read_version(card, u.str))
- return -EIO;
-
- printk(KERN_INFO "%s: Running Raw CHDLC firmware v%s\n"
- "%s: for Multi-Port PPP protocol.\n",
- card->devname,u.str,card->devname);
-
- card->isr = &wsppp_isr;
- card->poll = NULL;
- card->exec = NULL;
- card->wandev.update = &update;
- card->wandev.new_if = &new_if;
- card->wandev.del_if = &del_if;
- card->wandev.udp_port = conf->udp_port;
-
- card->wandev.new_if_cnt = 0;
-
- /* reset the number of times the 'update()' proc has been called */
- card->u.c.update_call_count = 0;
-
- card->wandev.ttl = conf->ttl;
- card->wandev.interface = conf->interface;
-
- if ((card->u.c.comm_port == WANOPT_SEC && conf->interface == WANOPT_V35)&&
- card->hw.type != SDLA_S514){
- printk(KERN_INFO "%s: ERROR - V35 Interface not supported on S508 %s port \n",
- card->devname, PORT(card->u.c.comm_port));
- return -EIO;
- }
-
-
- card->wandev.clocking = conf->clocking;
-
- port_num = card->u.c.comm_port;
-
- /* Setup Port Bps */
-
- if(card->wandev.clocking) {
- if((port_num == WANOPT_PRI) || card->u.c.receive_only) {
- /* For Primary Port 0 */
- max_permitted_baud =
- (card->hw.type == SDLA_S514) ?
- PRI_MAX_BAUD_RATE_S514 :
- PRI_MAX_BAUD_RATE_S508;
- }
- else if(port_num == WANOPT_SEC) {
- /* For Secondary Port 1 */
- max_permitted_baud =
- (card->hw.type == SDLA_S514) ?
- SEC_MAX_BAUD_RATE_S514 :
- SEC_MAX_BAUD_RATE_S508;
- }
-
- if(conf->bps > max_permitted_baud) {
- conf->bps = max_permitted_baud;
- printk(KERN_INFO "%s: Baud too high!\n",
- card->wandev.name);
- printk(KERN_INFO "%s: Baud rate set to %lu bps\n",
- card->wandev.name, max_permitted_baud);
- }
-
- card->wandev.bps = conf->bps;
- }else{
- card->wandev.bps = 0;
- }
-
- /* Setup the Port MTU */
- if((port_num == WANOPT_PRI) || card->u.c.receive_only) {
-
- /* For Primary Port 0 */
- card->wandev.mtu =
- (conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
- min_t(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
- CHDLC_DFLT_DATA_LEN;
- } else if(port_num == WANOPT_SEC) {
- /* For Secondary Port 1 */
- card->wandev.mtu =
- (conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
- min_t(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
- CHDLC_DFLT_DATA_LEN;
- }
-
- /* Add on a PPP Header */
- card->wandev.mtu += PPP_HEADER_LEN;
-
- /* Set up the interrupt status area */
- /* Read the CHDLC Configuration and obtain:
- * Ptr to shared memory infor struct
- * Use this pointer to calculate the value of card->u.c.flags !
- */
- mb1->buffer_length = 0;
- mb1->command = READ_CHDLC_CONFIGURATION;
- err = sdla_exec(mb1) ? mb1->return_code : CMD_TIMEOUT;
- if(err != COMMAND_OK) {
- clear_bit(1, (void*)&card->wandev.critical);
-
- if(card->hw.type != SDLA_S514)
- enable_irq(card->hw.irq);
-
- chdlc_error(card, err, mb1);
- return -EIO;
- }
-
- if(card->hw.type == SDLA_S514){
- card->u.c.flags = (void *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb1->data)->
- ptr_shared_mem_info_struct));
- }else{
- card->u.c.flags = (void *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb1->data)->
- ptr_shared_mem_info_struct % SDLA_WINDOWSIZE));
- }
-
- flags = card->u.c.flags;
-
- /* This is for the ports link state */
- card->wandev.state = WAN_DUALPORT;
- card->u.c.state = WAN_DISCONNECTED;
-
-
- if (!card->wandev.piggyback){
- err = intr_test(card);
-
- if(err || (Intr_test_counter < MAX_INTR_TEST_COUNTER)) {
- printk(KERN_ERR "%s: Interrupt test failed (%i)\n",
- card->devname, Intr_test_counter);
- printk(KERN_ERR "%s: Please choose another interrupt\n",
- card->devname);
- return -EIO;
- }
-
- printk(KERN_INFO "%s: Interrupt test passed (%i)\n",
- card->devname, Intr_test_counter);
- }
-
-
- if (chdlc_set_intr_mode(card, APP_INT_ON_TIMER)){
- printk (KERN_INFO "%s: Failed to set interrupt triggers!\n",
- card->devname);
- return -EIO;
- }
-
- /* Mask the Timer interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TIMER;
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-/******* WAN Device Driver Entry Points *************************************/
-
-/*============================================================================
- * Update device status & statistics
- * This procedure is called when updating the PROC file system and returns
- * various communications statistics. These statistics are accumulated from 3
- * different locations:
- * 1) The 'if_stats' recorded for the device.
- * 2) Communication error statistics on the adapter.
- * 3) CHDLC operational statistics on the adapter.
- * The board level statistics are read during a timer interrupt. Note that we
- * read the error and operational statistics during consecitive timer ticks so
- * as to minimize the time that we are inside the interrupt handler.
- *
- */
-static int update(struct wan_device* wandev)
-{
- sdla_t* card = wandev->private;
- struct net_device* dev;
- volatile chdlc_private_area_t* chdlc_priv_area;
- SHARED_MEMORY_INFO_STRUCT *flags;
- unsigned long timeout;
-
- /* sanity checks */
- if((wandev == NULL) || (wandev->private == NULL))
- return -EFAULT;
-
- if(wandev->state == WAN_UNCONFIGURED)
- return -ENODEV;
-
- /* more sanity checks */
- if(!card->u.c.flags)
- return -ENODEV;
-
- if((dev=card->wandev.dev) == NULL)
- return -ENODEV;
-
- if((chdlc_priv_area=dev->priv) == NULL)
- return -ENODEV;
-
- flags = card->u.c.flags;
-
- if(chdlc_priv_area->update_comms_stats){
- return -EAGAIN;
- }
-
- /* we will need 2 timer interrupts to complete the */
- /* reading of the statistics */
- chdlc_priv_area->update_comms_stats = 2;
- flags->interrupt_info_struct.interrupt_permission |= APP_INT_ON_TIMER;
- chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE;
-
- /* wait a maximum of 1 second for the statistics to be updated */
- timeout = jiffies + 1 * HZ;
- for(;;) {
- if(chdlc_priv_area->update_comms_stats == 0)
- break;
- if (time_after(jiffies, timeout)){
- chdlc_priv_area->update_comms_stats = 0;
- chdlc_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_UPDATE;
- return -EAGAIN;
- }
- }
-
- return 0;
-}
-
-
-/*============================================================================
- * Create new logical channel.
- * This routine is called by the router when ROUTER_IFNEW IOCTL is being
- * handled.
- * o parse media- and hardware-specific configuration
- * o make sure that a new channel can be created
- * o allocate resources, if necessary
- * o prepare network device structure for registaration.
- *
- * Return: 0 o.k.
- * < 0 failure (channel will not be created)
- */
-static int new_if(struct wan_device* wandev, struct net_device* pdev,
- wanif_conf_t* conf)
-{
-
- struct ppp_device *pppdev = (struct ppp_device *)pdev;
- struct net_device *dev = NULL;
- struct sppp *sp;
- sdla_t* card = wandev->private;
- chdlc_private_area_t* chdlc_priv_area;
-
- if ((conf->name[0] == '\0') || (strlen(conf->name) > WAN_IFNAME_SZ)) {
- printk(KERN_INFO "%s: invalid interface name!\n",
- card->devname);
- return -EINVAL;
- }
-
- /* allocate and initialize private data */
- chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
-
- if(chdlc_priv_area == NULL)
- return -ENOMEM;
-
- memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t));
-
- chdlc_priv_area->card = card;
-
- /* initialize data */
- strcpy(card->u.c.if_name, conf->name);
-
- if(card->wandev.new_if_cnt > 0) {
- kfree(chdlc_priv_area);
- return -EEXIST;
- }
-
- card->wandev.new_if_cnt++;
-
- chdlc_priv_area->TracingEnabled = 0;
-
- //We don't need this any more
- chdlc_priv_area->route_status = NO_ROUTE;
- chdlc_priv_area->route_removed = 0;
-
- printk(KERN_INFO "%s: Firmware running in HDLC STREAMING Mode\n",
- wandev->name);
-
- /* Setup wanpipe as a router (WANPIPE) or as an API */
- if( strcmp(conf->usedby, "WANPIPE") == 0) {
- printk(KERN_INFO "%s: Driver running in WANPIPE mode!\n",
- wandev->name);
- card->u.c.usedby = WANPIPE;
- } else {
- printk(KERN_INFO
- "%s: API Mode is not supported for SyncPPP!\n",
- wandev->name);
- kfree(chdlc_priv_area);
- return -EINVAL;
- }
-
- /* Get Multicast Information */
- chdlc_priv_area->mc = conf->mc;
-
-
- chdlc_priv_area->if_ptr = pppdev;
-
- /* prepare network device data space for registration */
-
- strcpy(dev->name,card->u.c.if_name);
-
- /* Attach PPP protocol layer to pppdev
- * The sppp_attach() will initilize the dev structure
- * and setup ppp layer protocols.
- * All we have to do is to bind in:
- * if_open(), if_close(), if_send() and get_stats() functions.
- */
- sppp_attach(pppdev);
- dev = pppdev->dev;
- sp = &pppdev->sppp;
-
- /* Enable PPP Debugging */
- // FIXME Fix this up somehow
- //sp->pp_flags |= PP_DEBUG;
- sp->pp_flags &= ~PP_CISCO;
-
- dev->init = &if_init;
- dev->priv = chdlc_priv_area;
-
- return 0;
-}
-
-
-
-
-/*============================================================================
- * Delete logical channel.
- */
-static int del_if(struct wan_device* wandev, struct net_device* dev)
-{
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
- sdla_t *card = chdlc_priv_area->card;
- unsigned long smp_lock;
-
- /* Detach the PPP layer */
- printk(KERN_INFO "%s: Detaching SyncPPP Module from %s\n",
- wandev->name,dev->name);
-
- lock_adapter_irq(&wandev->lock,&smp_lock);
-
- sppp_detach(dev);
- chdlc_priv_area->if_ptr=NULL;
-
- chdlc_set_intr_mode(card, 0);
- if (card->u.c.comm_enabled)
- chdlc_comm_disable(card);
- unlock_adapter_irq(&wandev->lock,&smp_lock);
-
- port_set_state(card, WAN_DISCONNECTED);
-
- return 0;
-}
-
-
-/****** Network Device Interface ********************************************/
-
-/*============================================================================
- * Initialize Linux network interface.
- *
- * This routine is called only once for each interface, during Linux network
- * interface registration. Returning anything but zero will fail interface
- * registration.
- */
-static int if_init(struct net_device* dev)
-{
- chdlc_private_area_t* chdlc_priv_area = dev->priv;
- sdla_t* card = chdlc_priv_area->card;
- struct wan_device* wandev = &card->wandev;
-
- /* NOTE: Most of the dev initialization was
- * done in sppp_attach(), called by new_if()
- * function. All we have to do here is
- * to link four major routines below.
- */
-
- /* Initialize device driver entry points */
- dev->open = &if_open;
- dev->stop = &if_close;
- dev->hard_start_xmit = &if_send;
- dev->get_stats = &if_stats;
- dev->tx_timeout = &if_tx_timeout;
- dev->watchdog_timeo = TX_TIMEOUT;
-
-
- /* Initialize hardware parameters */
- dev->irq = wandev->irq;
- dev->dma = wandev->dma;
- dev->base_addr = wandev->ioport;
- dev->mem_start = wandev->maddr;
- dev->mem_end = wandev->maddr + wandev->msize - 1;
-
- /* Set transmit buffer queue length
- * If we over fill this queue the packets will
- * be droped by the kernel.
- * sppp_attach() sets this to 10, but
- * 100 will give us more room at low speeds.
- */
- dev->tx_queue_len = 100;
-
- return 0;
-}
-
-
-/*============================================================================
- * Handle transmit timeout event from netif watchdog
- */
-static void if_tx_timeout(struct net_device *dev)
-{
- chdlc_private_area_t* chan = dev->priv;
- sdla_t *card = chan->card;
-
- /* If our device stays busy for at least 5 seconds then we will
- * kick start the device by making dev->tbusy = 0. We expect
- * that our device never stays busy more than 5 seconds. So this
- * is only used as a last resort.
- */
-
- ++card->wandev.stats.collisions;
-
- printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name);
- netif_wake_queue (dev);
-}
-
-
-/*============================================================================
- * Open network interface.
- * o enable communications and interrupts.
- * o prevent module from unloading by incrementing use count
- *
- * Return 0 if O.k. or errno.
- */
-static int if_open(struct net_device* dev)
-{
- chdlc_private_area_t* chdlc_priv_area = dev->priv;
- sdla_t* card = chdlc_priv_area->card;
- struct timeval tv;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
-
- /* Only one open per interface is allowed */
- if (netif_running(dev))
- return -EBUSY;
-
- /* Start PPP Layer */
- if (sppp_open(dev)){
- return -EIO;
- }
-
- do_gettimeofday(&tv);
- chdlc_priv_area->router_start_time = tv.tv_sec;
-
- netif_start_queue(dev);
-
- wanpipe_open(card);
-
- chdlc_priv_area->timer_int_enabled |= TMR_INT_ENABLED_CONFIG;
- flags->interrupt_info_struct.interrupt_permission |= APP_INT_ON_TIMER;
- return 0;
-}
-
-/*============================================================================
- * Close network interface.
- * o if this is the last close, then disable communications and interrupts.
- * o reset flags.
- */
-static int if_close(struct net_device* dev)
-{
- chdlc_private_area_t* chdlc_priv_area = dev->priv;
- sdla_t* card = chdlc_priv_area->card;
-
- /* Stop the PPP Layer */
- sppp_close(dev);
- netif_stop_queue(dev);
-
- wanpipe_close(card);
-
- return 0;
-}
-
-/*============================================================================
- * Send a packet on a network interface.
- * o set tbusy flag (marks start of the transmission) to block a timer-based
- * transmit from overlapping.
- * o check link state. If link is not up, then drop the packet.
- * o execute adapter send command.
- * o free socket buffer
- *
- * Return: 0 complete (socket buffer must be freed)
- * non-0 packet may be re-transmitted (tbusy must be set)
- *
- * Notes:
- * 1. This routine is called either by the protocol stack or by the "net
- * bottom half" (with interrupts enabled).
- * 2. Setting tbusy flag will inhibit further transmit requests from the
- * protocol stack and can be used for flow control with protocol layer.
- */
-static int if_send(struct sk_buff* skb, struct net_device* dev)
-{
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
- sdla_t *card = chdlc_priv_area->card;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- INTERRUPT_INFORMATION_STRUCT *chdlc_int = &flags->interrupt_info_struct;
- int udp_type = 0;
- unsigned long smp_flags;
- int err=0;
-
- netif_stop_queue(dev);
-
-
- if (skb == NULL){
- /* If we get here, some higher layer thinks we've missed an
- * tx-done interrupt.
- */
- printk(KERN_INFO "%s: Received NULL skb buffer! interface %s got kicked!\n",
- card->devname, dev->name);
-
- netif_wake_queue(dev);
- return 0;
- }
-
- if (ntohs(skb->protocol) != htons(PVC_PROT)){
- /* check the udp packet type */
-
- udp_type = udp_pkt_type(skb, card);
- if (udp_type == UDP_CPIPE_TYPE){
- if(store_udp_mgmt_pkt(UDP_PKT_FRM_STACK, card, skb, dev,
- chdlc_priv_area)){
- chdlc_int->interrupt_permission |=
- APP_INT_ON_TIMER;
- }
- netif_start_queue(dev);
- return 0;
- }
- }
-
- /* Lock the 508 Card: SMP is supported */
- if(card->hw.type != SDLA_S514){
- s508_lock(card,&smp_flags);
- }
-
- if (test_and_set_bit(SEND_CRIT, (void*)&card->wandev.critical)){
-
- printk(KERN_INFO "%s: Critical in if_send: %lx\n",
- card->wandev.name,card->wandev.critical);
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
- goto if_send_crit_exit;
- }
-
- if (card->wandev.state != WAN_CONNECTED){
- ++card->wandev.stats.tx_dropped;
- netif_start_queue(dev);
- goto if_send_crit_exit;
- }
-
- if (chdlc_send(card, skb->data, skb->len)){
- netif_stop_queue(dev);
-
- }else{
- ++card->wandev.stats.tx_packets;
- card->wandev.stats.tx_bytes += skb->len;
- dev->trans_start = jiffies;
- netif_start_queue(dev);
- }
-
-if_send_crit_exit:
- if (!(err=netif_queue_stopped(dev))){
- dev_kfree_skb_any(skb);
- }else{
- chdlc_priv_area->tick_counter = jiffies;
- chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME;
- }
-
- clear_bit(SEND_CRIT, (void*)&card->wandev.critical);
- if(card->hw.type != SDLA_S514){
- s508_unlock(card,&smp_flags);
- }
-
- return err;
-}
-
-
-/*============================================================================
- * Reply to UDP Management system.
- * Return length of reply.
- */
-static int reply_udp( unsigned char *data, unsigned int mbox_len )
-{
-
- unsigned short len, udp_length, temp, ip_length;
- unsigned long ip_temp;
- int even_bound = 0;
- chdlc_udp_pkt_t *c_udp_pkt = (chdlc_udp_pkt_t *)data;
-
- /* Set length of packet */
- len = sizeof(ip_pkt_t)+
- sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- sizeof(trace_info_t)+
- mbox_len;
-
- /* fill in UDP reply */
- c_udp_pkt->wp_mgmt.request_reply = UDPMGMT_REPLY;
-
- /* fill in UDP length */
- udp_length = sizeof(udp_pkt_t)+
- sizeof(wp_mgmt_t)+
- sizeof(cblock_t)+
- sizeof(trace_info_t)+
- mbox_len;
-
- /* put it on an even boundary */
- if ( udp_length & 0x0001 ) {
- udp_length += 1;
- len += 1;
- even_bound = 1;
- }
-
- temp = (udp_length<<8)|(udp_length>>8);
- c_udp_pkt->udp_pkt.udp_length = temp;
-
- /* swap UDP ports */
- temp = c_udp_pkt->udp_pkt.udp_src_port;
- c_udp_pkt->udp_pkt.udp_src_port =
- c_udp_pkt->udp_pkt.udp_dst_port;
- c_udp_pkt->udp_pkt.udp_dst_port = temp;
-
- /* add UDP pseudo header */
- temp = 0x1100;
- *((unsigned short *)(c_udp_pkt->data+mbox_len+even_bound)) = temp;
- temp = (udp_length<<8)|(udp_length>>8);
- *((unsigned short *)(c_udp_pkt->data+mbox_len+even_bound+2)) = temp;
-
-
- /* calculate UDP checksum */
- c_udp_pkt->udp_pkt.udp_checksum = 0;
- c_udp_pkt->udp_pkt.udp_checksum = calc_checksum(&data[UDP_OFFSET],udp_length+UDP_OFFSET);
-
- /* fill in IP length */
- ip_length = len;
- temp = (ip_length<<8)|(ip_length>>8);
- c_udp_pkt->ip_pkt.total_length = temp;
-
- /* swap IP addresses */
- ip_temp = c_udp_pkt->ip_pkt.ip_src_address;
- c_udp_pkt->ip_pkt.ip_src_address = c_udp_pkt->ip_pkt.ip_dst_address;
- c_udp_pkt->ip_pkt.ip_dst_address = ip_temp;
-
- /* fill in IP checksum */
- c_udp_pkt->ip_pkt.hdr_checksum = 0;
- c_udp_pkt->ip_pkt.hdr_checksum = calc_checksum(data,sizeof(ip_pkt_t));
-
- return len;
-
-} /* reply_udp */
-
-unsigned short calc_checksum (char *data, int len)
-{
- unsigned short temp;
- unsigned long sum=0;
- int i;
-
- for( i = 0; i <len; i+=2 ) {
- memcpy(&temp,&data[i],2);
- sum += (unsigned long)temp;
- }
-
- while (sum >> 16 ) {
- sum = (sum & 0xffffUL) + (sum >> 16);
- }
-
- temp = (unsigned short)sum;
- temp = ~temp;
-
- if( temp == 0 )
- temp = 0xffff;
-
- return temp;
-}
-
-
-/*============================================================================
- * Get ethernet-style interface statistics.
- * Return a pointer to struct enet_statistics.
- */
-static struct net_device_stats* if_stats(struct net_device* dev)
-{
- sdla_t *my_card;
- chdlc_private_area_t* chdlc_priv_area;
-
- /* Shutdown bug fix. In del_if() we kill
- * dev->priv pointer. This function, gets
- * called after del_if(), thus check
- * if pointer has been deleted */
- if ((chdlc_priv_area=dev->priv) == NULL)
- return NULL;
-
- my_card = chdlc_priv_area->card;
- return &my_card->wandev.stats;
-}
-
-
-/****** Cisco HDLC Firmware Interface Functions *******************************/
-
-/*============================================================================
- * Read firmware code version.
- * Put code version as ASCII string in str.
- */
-static int chdlc_read_version (sdla_t* card, char* str)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int len;
- char err;
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CODE_VERSION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if(err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- }
- else if (str) { /* is not null */
- len = mb->buffer_length;
- memcpy(str, mb->data, len);
- str[len] = '\0';
- }
- return (err);
-}
-
-/*-----------------------------------------------------------------------------
- * Configure CHDLC firmware.
- */
-static int chdlc_configure (sdla_t* card, void* data)
-{
- int err;
- CHDLC_MAILBOX_STRUCT *mailbox = card->mbox;
- int data_length = sizeof(CHDLC_CONFIGURATION_STRUCT);
-
- mailbox->buffer_length = data_length;
- memcpy(mailbox->data, data, data_length);
- mailbox->command = SET_CHDLC_CONFIGURATION;
- err = sdla_exec(mailbox) ? mailbox->return_code : CMD_TIMEOUT;
-
- if (err != COMMAND_OK) chdlc_error (card, err, mailbox);
-
- return err;
-}
-
-
-/*============================================================================
- * Set interrupt mode -- HDLC Version.
- */
-
-static int chdlc_set_intr_mode (sdla_t* card, unsigned mode)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- CHDLC_INT_TRIGGERS_STRUCT* int_data =
- (CHDLC_INT_TRIGGERS_STRUCT *)mb->data;
- int err;
-
- int_data->CHDLC_interrupt_triggers = mode;
- int_data->IRQ = card->hw.irq;
- int_data->interrupt_timer = 1;
-
- mb->buffer_length = sizeof(CHDLC_INT_TRIGGERS_STRUCT);
- mb->command = SET_CHDLC_INTERRUPT_TRIGGERS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error (card, err, mb);
- return err;
-}
-
-
-/*============================================================================
- * Enable communications.
- */
-
-static int chdlc_comm_enable (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = ENABLE_CHDLC_COMMUNICATIONS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card, err, mb);
- else
- card->u.c.comm_enabled=1;
-
- return err;
-}
-
-/*============================================================================
- * Disable communications and Drop the Modem lines (DCD and RTS).
- */
-static int chdlc_comm_disable (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = DISABLE_CHDLC_COMMUNICATIONS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card,err,mb);
-
- return err;
-}
-
-/*============================================================================
- * Read communication error statistics.
- */
-static int chdlc_read_comm_err_stats (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = READ_COMMS_ERROR_STATS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card,err,mb);
- return err;
-}
-
-
-/*============================================================================
- * Read CHDLC operational statistics.
- */
-static int chdlc_read_op_stats (sdla_t* card)
-{
- int err;
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_OPERATIONAL_STATS;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK)
- chdlc_error(card,err,mb);
- return err;
-}
-
-
-/*============================================================================
- * Update communications error and general packet statistics.
- */
-static int update_comms_stats(sdla_t* card,
- chdlc_private_area_t* chdlc_priv_area)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- COMMS_ERROR_STATS_STRUCT* err_stats;
- CHDLC_OPERATIONAL_STATS_STRUCT *op_stats;
-
- /* on the first timer interrupt, read the comms error statistics */
- if(chdlc_priv_area->update_comms_stats == 2) {
- if(chdlc_read_comm_err_stats(card))
- return 1;
- err_stats = (COMMS_ERROR_STATS_STRUCT *)mb->data;
- card->wandev.stats.rx_over_errors =
- err_stats->Rx_overrun_err_count;
- card->wandev.stats.rx_crc_errors =
- err_stats->CRC_err_count;
- card->wandev.stats.rx_frame_errors =
- err_stats->Rx_abort_count;
- card->wandev.stats.rx_fifo_errors =
- err_stats->Rx_dis_pri_bfrs_full_count;
- card->wandev.stats.rx_missed_errors =
- card->wandev.stats.rx_fifo_errors;
- card->wandev.stats.tx_aborted_errors =
- err_stats->sec_Tx_abort_count;
- }
-
- /* on the second timer interrupt, read the operational statistics */
- else {
- if(chdlc_read_op_stats(card))
- return 1;
- op_stats = (CHDLC_OPERATIONAL_STATS_STRUCT *)mb->data;
- card->wandev.stats.rx_length_errors =
- (op_stats->Rx_Data_discard_short_count +
- op_stats->Rx_Data_discard_long_count);
- }
-
- return 0;
-}
-
-/*============================================================================
- * Send packet.
- * Return: 0 - o.k.
- * 1 - no transmit buffers available
- */
-static int chdlc_send (sdla_t* card, void* data, unsigned len)
-{
- CHDLC_DATA_TX_STATUS_EL_STRUCT *txbuf = card->u.c.txbuf;
-
- if (txbuf->opp_flag)
- return 1;
-
- sdla_poke(&card->hw, txbuf->ptr_data_bfr, data, len);
-
- txbuf->frame_length = len;
- txbuf->opp_flag = 1; /* start transmission */
-
- /* Update transmit buffer control fields */
- card->u.c.txbuf = ++txbuf;
-
- if ((void*)txbuf > card->u.c.txbuf_last)
- card->u.c.txbuf = card->u.c.txbuf_base;
-
- return 0;
-}
-
-/****** Firmware Error Handler **********************************************/
-
-/*============================================================================
- * Firmware error handler.
- * This routine is called whenever firmware command returns non-zero
- * return code.
- *
- * Return zero if previous command has to be cancelled.
- */
-static int chdlc_error (sdla_t *card, int err, CHDLC_MAILBOX_STRUCT *mb)
-{
- unsigned cmd = mb->command;
-
- switch (err) {
-
- case CMD_TIMEOUT:
- printk(KERN_ERR "%s: command 0x%02X timed out!\n",
- card->devname, cmd);
- break;
-
- case S514_BOTH_PORTS_SAME_CLK_MODE:
- if(cmd == SET_CHDLC_CONFIGURATION) {
- printk(KERN_INFO
- "%s: Configure both ports for the same clock source\n",
- card->devname);
- break;
- }
-
- default:
- printk(KERN_INFO "%s: command 0x%02X returned 0x%02X!\n",
- card->devname, cmd, err);
- }
-
- return 0;
-}
-
-/****** Interrupt Handlers **************************************************/
-
-/*============================================================================
- * Cisco HDLC interrupt service routine.
- */
-STATIC void wsppp_isr (sdla_t* card)
-{
- struct net_device* dev;
- SHARED_MEMORY_INFO_STRUCT* flags = NULL;
- int i;
- sdla_t *my_card;
-
-
- /* Check for which port the interrupt has been generated
- * Since Secondary Port is piggybacking on the Primary
- * the check must be done here.
- */
-
- flags = card->u.c.flags;
- if (!flags->interrupt_info_struct.interrupt_type){
- /* Check for a second port (piggybacking) */
- if((my_card = card->next)){
- flags = my_card->u.c.flags;
- if (flags->interrupt_info_struct.interrupt_type){
- card = my_card;
- card->isr(card);
- return;
- }
- }
- }
-
- dev = card->wandev.dev;
- card->in_isr = 1;
- flags = card->u.c.flags;
-
- /* If we get an interrupt with no network device, stop the interrupts
- * and issue an error */
- if ((!dev || !dev->priv) && flags->interrupt_info_struct.interrupt_type !=
- COMMAND_COMPLETE_APP_INT_PEND){
- goto isr_done;
- }
-
-
- /* if critical due to peripheral operations
- * ie. update() or getstats() then reset the interrupt and
- * wait for the board to retrigger.
- */
- if(test_bit(PERI_CRIT, (void*)&card->wandev.critical)) {
- flags->interrupt_info_struct.
- interrupt_type = 0;
- goto isr_done;
- }
-
-
- /* On a 508 Card, if critical due to if_send
- * Major Error !!!
- */
- if(card->hw.type != SDLA_S514) {
- if(test_bit(0, (void*)&card->wandev.critical)) {
- printk(KERN_INFO "%s: Critical while in ISR: %lx\n",
- card->devname, card->wandev.critical);
- goto isr_done;
- }
- }
-
- switch(flags->interrupt_info_struct.interrupt_type) {
-
- case RX_APP_INT_PEND: /* 0x01: receive interrupt */
- rx_intr(card);
- break;
-
- case TX_APP_INT_PEND: /* 0x02: transmit interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TX_FRAME;
-
- netif_wake_queue(dev);
- break;
-
- case COMMAND_COMPLETE_APP_INT_PEND:/* 0x04: cmd cplt */
- ++ Intr_test_counter;
- break;
-
- case CHDLC_EXCEP_COND_APP_INT_PEND: /* 0x20 */
- process_chdlc_exception(card);
- break;
-
- case GLOBAL_EXCEP_COND_APP_INT_PEND:
- process_global_exception(card);
- break;
-
- case TIMER_APP_INT_PEND:
- timer_intr(card);
- break;
-
- default:
- printk(KERN_INFO "%s: spurious interrupt 0x%02X!\n",
- card->devname,
- flags->interrupt_info_struct.interrupt_type);
- printk(KERN_INFO "Code name: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codename[i]);
- printk(KERN_INFO "\nCode version: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codeversion[i]);
- printk(KERN_INFO "\n");
- break;
- }
-
-isr_done:
- card->in_isr = 0;
- flags->interrupt_info_struct.interrupt_type = 0;
-}
-
-/*============================================================================
- * Receive interrupt handler.
- */
-static void rx_intr (sdla_t* card)
-{
- struct net_device *dev;
- chdlc_private_area_t *chdlc_priv_area;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- CHDLC_DATA_RX_STATUS_EL_STRUCT *rxbuf = card->u.c.rxmb;
- struct sk_buff *skb;
- unsigned len;
- unsigned addr = rxbuf->ptr_data_bfr;
- void *buf;
- int i,udp_type;
-
- if (rxbuf->opp_flag != 0x01) {
- printk(KERN_INFO
- "%s: corrupted Rx buffer @ 0x%X, flag = 0x%02X!\n",
- card->devname, (unsigned)rxbuf, rxbuf->opp_flag);
- printk(KERN_INFO "Code name: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codename[i]);
- printk(KERN_INFO "\nCode version: ");
- for(i = 0; i < 4; i ++)
- printk(KERN_INFO "%c",
- flags->global_info_struct.codeversion[i]);
- printk(KERN_INFO "\n");
-
-
- /* Bug Fix: Mar 6 2000
- * If we get a corrupted mailbox, it measn that driver
- * is out of sync with the firmware. There is no recovery.
- * If we don't turn off all interrupts for this card
- * the machine will crash.
- */
- printk(KERN_INFO "%s: Critical router failure ...!!!\n", card->devname);
- printk(KERN_INFO "Please contact Sangoma Technologies !\n");
- chdlc_set_intr_mode(card,0);
- return;
- }
-
- dev = card->wandev.dev;
-
- if (!dev){
- goto rx_exit;
- }
-
- if (!netif_running(dev)){
- goto rx_exit;
- }
-
- chdlc_priv_area = dev->priv;
-
- if (rxbuf->error_flag){
- goto rx_exit;
- }
- /* Take off two CRC bytes */
-
- if (rxbuf->frame_length < 7 || rxbuf->frame_length > 1506 ){
- goto rx_exit;
- }
-
- len = rxbuf->frame_length - CRC_LENGTH;
-
- /* Allocate socket buffer */
- skb = dev_alloc_skb(len);
-
- if (skb == NULL) {
- if (net_ratelimit()){
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- }
- ++card->wandev.stats.rx_dropped;
- goto rx_exit;
- }
-
- /* Copy data to the socket buffer */
- if((addr + len) > card->u.c.rx_top + 1) {
- unsigned tmp = card->u.c.rx_top - addr + 1;
- buf = skb_put(skb, tmp);
- sdla_peek(&card->hw, addr, buf, tmp);
- addr = card->u.c.rx_base;
- len -= tmp;
- }
-
- buf = skb_put(skb, len);
- sdla_peek(&card->hw, addr, buf, len);
-
- skb->protocol = htons(ETH_P_WAN_PPP);
-
- card->wandev.stats.rx_packets ++;
- card->wandev.stats.rx_bytes += skb->len;
- udp_type = udp_pkt_type( skb, card );
-
- if(udp_type == UDP_CPIPE_TYPE) {
- if(store_udp_mgmt_pkt(UDP_PKT_FRM_NETWORK,
- card, skb, dev, chdlc_priv_area)) {
- flags->interrupt_info_struct.
- interrupt_permission |=
- APP_INT_ON_TIMER;
- }
- }else{
- /* Pass it up the protocol stack */
- skb->dev = dev;
- skb->mac.raw = skb->data;
- netif_rx(skb);
- dev->last_rx = jiffies;
- }
-
-rx_exit:
- /* Release buffer element and calculate a pointer to the next one */
- rxbuf->opp_flag = 0x00;
- card->u.c.rxmb = ++ rxbuf;
- if((void*)rxbuf > card->u.c.rxbuf_last){
- card->u.c.rxmb = card->u.c.rxbuf_base;
- }
-}
-
-/*============================================================================
- * Timer interrupt handler.
- * The timer interrupt is used for two purposes:
- * 1) Processing udp calls from 'cpipemon'.
- * 2) Reading board-level statistics for updating the proc file system.
- */
-void timer_intr(sdla_t *card)
-{
- struct net_device* dev;
- chdlc_private_area_t* chdlc_priv_area = NULL;
- SHARED_MEMORY_INFO_STRUCT* flags = NULL;
-
- dev = card->wandev.dev;
- chdlc_priv_area = dev->priv;
-
- if (chdlc_priv_area->timer_int_enabled & TMR_INT_ENABLED_CONFIG) {
- if (!config_chdlc(card)){
- chdlc_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_CONFIG;
- }
- }
-
- /* process a udp call if pending */
- if(chdlc_priv_area->timer_int_enabled & TMR_INT_ENABLED_UDP) {
- process_udp_mgmt_pkt(card, dev,
- chdlc_priv_area);
- chdlc_priv_area->timer_int_enabled &= ~TMR_INT_ENABLED_UDP;
- }
-
-
- /* read the communications statistics if required */
- if(chdlc_priv_area->timer_int_enabled & TMR_INT_ENABLED_UPDATE) {
- update_comms_stats(card, chdlc_priv_area);
- if(!(-- chdlc_priv_area->update_comms_stats)) {
- chdlc_priv_area->timer_int_enabled &=
- ~TMR_INT_ENABLED_UPDATE;
- }
- }
-
- /* only disable the timer interrupt if there are no udp or statistic */
- /* updates pending */
- if(!chdlc_priv_area->timer_int_enabled) {
- flags = card->u.c.flags;
- flags->interrupt_info_struct.interrupt_permission &=
- ~APP_INT_ON_TIMER;
- }
-}
-
-/*------------------------------------------------------------------------------
- Miscellaneous Functions
- - set_chdlc_config() used to set configuration options on the board
-------------------------------------------------------------------------------*/
-
-static int set_chdlc_config(sdla_t* card)
-{
-
- CHDLC_CONFIGURATION_STRUCT cfg;
-
- memset(&cfg, 0, sizeof(CHDLC_CONFIGURATION_STRUCT));
-
- if(card->wandev.clocking)
- cfg.baud_rate = card->wandev.bps;
-
- cfg.line_config_options = (card->wandev.interface == WANOPT_RS232) ?
- INTERFACE_LEVEL_RS232 : INTERFACE_LEVEL_V35;
-
- cfg.modem_config_options = 0;
- //API OPTIONS
- cfg.CHDLC_API_options = DISCARD_RX_ERROR_FRAMES;
- cfg.modem_status_timer = 100;
- cfg.CHDLC_protocol_options = HDLC_STREAMING_MODE;
- cfg.percent_data_buffer_for_Tx = 50;
- cfg.CHDLC_statistics_options = (CHDLC_TX_DATA_BYTE_COUNT_STAT |
- CHDLC_RX_DATA_BYTE_COUNT_STAT);
- cfg.max_CHDLC_data_field_length = card->wandev.mtu;
-
- cfg.transmit_keepalive_timer = 0;
- cfg.receive_keepalive_timer = 0;
- cfg.keepalive_error_tolerance = 0;
- cfg.SLARP_request_timer = 0;
-
- cfg.IP_address = 0;
- cfg.IP_netmask = 0;
-
- return chdlc_configure(card, &cfg);
-}
-
-/*============================================================================
- * Process global exception condition
- */
-static int process_global_exception(sdla_t *card)
-{
- CHDLC_MAILBOX_STRUCT* mbox = card->mbox;
- int err;
-
- mbox->buffer_length = 0;
- mbox->command = READ_GLOBAL_EXCEPTION_CONDITION;
- err = sdla_exec(mbox) ? mbox->return_code : CMD_TIMEOUT;
-
- if(err != CMD_TIMEOUT ){
-
- switch(mbox->return_code) {
-
- case EXCEP_MODEM_STATUS_CHANGE:
-
- printk(KERN_INFO "%s: Modem status change\n",
- card->devname);
-
- switch(mbox->data[0] & (DCD_HIGH | CTS_HIGH)) {
- case (DCD_HIGH):
- printk(KERN_INFO "%s: DCD high, CTS low\n",card->devname);
- break;
- case (CTS_HIGH):
- printk(KERN_INFO "%s: DCD low, CTS high\n",card->devname);
- break;
- case ((DCD_HIGH | CTS_HIGH)):
- printk(KERN_INFO "%s: DCD high, CTS high\n",card->devname);
- break;
- default:
- printk(KERN_INFO "%s: DCD low, CTS low\n",card->devname);
- break;
- }
-
- if (!(mbox->data[0] & DCD_HIGH) || !(mbox->data[0] & DCD_HIGH)){
- //printk(KERN_INFO "Sending TERM Request Manually !\n");
- send_ppp_term_request(card->wandev.dev);
- }
- break;
-
- case EXCEP_TRC_DISABLED:
- printk(KERN_INFO "%s: Line trace disabled\n",
- card->devname);
- break;
-
- case EXCEP_IRQ_TIMEOUT:
- printk(KERN_INFO "%s: IRQ timeout occurred\n",
- card->devname);
- break;
-
- default:
- printk(KERN_INFO "%s: Global exception %x\n",
- card->devname, mbox->return_code);
- break;
- }
- }
- return 0;
-}
-
-
-/*============================================================================
- * Process chdlc exception condition
- */
-static int process_chdlc_exception(sdla_t *card)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int err;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_EXCEPTION_CONDITION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if(err != CMD_TIMEOUT) {
-
- switch (err) {
-
- case EXCEP_LINK_ACTIVE:
- port_set_state(card, WAN_CONNECTED);
- break;
-
- case EXCEP_LINK_INACTIVE_MODEM:
- port_set_state(card, WAN_DISCONNECTED);
- break;
-
- case EXCEP_LOOPBACK_CONDITION:
- printk(KERN_INFO "%s: Loopback Condition Detected.\n",
- card->devname);
- break;
-
- case NO_CHDLC_EXCEP_COND_TO_REPORT:
- printk(KERN_INFO "%s: No exceptions reported.\n",
- card->devname);
- break;
- default:
- printk(KERN_INFO "%s: Exception Condition %x!\n",
- card->devname,err);
- break;
- }
-
- }
- return 0;
-}
-
-
-/*=============================================================================
- * Store a UDP management packet for later processing.
- */
-
-static int store_udp_mgmt_pkt(char udp_pkt_src, sdla_t* card,
- struct sk_buff *skb, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area )
-{
- int udp_pkt_stored = 0;
-
- if(!chdlc_priv_area->udp_pkt_lgth &&
- (skb->len <= MAX_LGTH_UDP_MGNT_PKT)) {
- chdlc_priv_area->udp_pkt_lgth = skb->len;
- chdlc_priv_area->udp_pkt_src = udp_pkt_src;
- memcpy(chdlc_priv_area->udp_pkt_data, skb->data, skb->len);
- chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UDP;
- udp_pkt_stored = 1;
- }
-
- if(udp_pkt_src == UDP_PKT_FRM_STACK)
- dev_kfree_skb_any(skb);
- else
- dev_kfree_skb_any(skb);
-
- return(udp_pkt_stored);
-}
-
-
-/*=============================================================================
- * Process UDP management packet.
- */
-
-static int process_udp_mgmt_pkt(sdla_t* card, struct net_device* dev,
- chdlc_private_area_t* chdlc_priv_area )
-{
- unsigned char *buf;
- unsigned int frames, len;
- struct sk_buff *new_skb;
- unsigned short buffer_length, real_len;
- unsigned long data_ptr;
- unsigned data_length;
- int udp_mgmt_req_valid = 1;
- CHDLC_MAILBOX_STRUCT *mb = card->mbox;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
- chdlc_udp_pkt_t *chdlc_udp_pkt;
- struct timeval tv;
- int err;
- char ut_char;
-
- chdlc_udp_pkt = (chdlc_udp_pkt_t *) chdlc_priv_area->udp_pkt_data;
-
- if(chdlc_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK) {
-
- switch(chdlc_udp_pkt->cblock.command) {
- case READ_GLOBAL_STATISTICS:
- case READ_MODEM_STATUS:
- case READ_CHDLC_LINK_STATUS:
- case CPIPE_ROUTER_UP_TIME:
- case READ_COMMS_ERROR_STATS:
- case READ_CHDLC_OPERATIONAL_STATS:
-
- /* These two commands are executed for
- * each request */
- case READ_CHDLC_CONFIGURATION:
- case READ_CHDLC_CODE_VERSION:
- udp_mgmt_req_valid = 1;
- break;
- default:
- udp_mgmt_req_valid = 0;
- break;
- }
- }
-
- if(!udp_mgmt_req_valid) {
-
- /* set length to 0 */
- chdlc_udp_pkt->cblock.buffer_length = 0;
-
- /* set return code */
- chdlc_udp_pkt->cblock.return_code = 0xCD;
-
- if (net_ratelimit()){
- printk(KERN_INFO
- "%s: Warning, Illegal UDP command attempted from network: %x\n",
- card->devname,chdlc_udp_pkt->cblock.command);
- }
-
- } else {
- unsigned long trace_status_cfg_addr = 0;
- TRACE_STATUS_EL_CFG_STRUCT trace_cfg_struct;
- TRACE_STATUS_ELEMENT_STRUCT trace_element_struct;
-
- switch(chdlc_udp_pkt->cblock.command) {
-
- case CPIPE_ENABLE_TRACING:
- if (!chdlc_priv_area->TracingEnabled) {
-
- /* OPERATE_DATALINE_MONITOR */
-
- mb->buffer_length = sizeof(LINE_TRACE_CONFIG_STRUCT);
- mb->command = SET_TRACE_CONFIGURATION;
-
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->
- trace_config = TRACE_ACTIVE;
- /* Trace delay mode is not used because it slows
- down transfer and results in a standoff situation
- when there is a lot of data */
-
- /* Configure the Trace based on user inputs */
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->trace_config |=
- chdlc_udp_pkt->data[0];
-
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->
- trace_deactivation_timer = 4000;
-
-
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- card->TracingEnabled = 0;
- chdlc_udp_pkt->cblock.return_code = err;
- mb->buffer_length = 0;
- break;
- }
-
- /* Get the base address of the trace element list */
- mb->buffer_length = 0;
- mb->command = READ_TRACE_CONFIGURATION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if (err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- chdlc_priv_area->TracingEnabled = 0;
- chdlc_udp_pkt->cblock.return_code = err;
- mb->buffer_length = 0;
- break;
- }
-
- trace_status_cfg_addr =((LINE_TRACE_CONFIG_STRUCT *)
- mb->data) -> ptr_trace_stat_el_cfg_struct;
-
- sdla_peek(&card->hw, trace_status_cfg_addr,
- &trace_cfg_struct, sizeof(trace_cfg_struct));
-
- chdlc_priv_area->start_trace_addr = trace_cfg_struct.
- base_addr_trace_status_elements;
-
- chdlc_priv_area->number_trace_elements =
- trace_cfg_struct.number_trace_status_elements;
-
- chdlc_priv_area->end_trace_addr = (unsigned long)
- ((TRACE_STATUS_ELEMENT_STRUCT *)
- chdlc_priv_area->start_trace_addr +
- (chdlc_priv_area->number_trace_elements - 1));
-
- chdlc_priv_area->base_addr_trace_buffer =
- trace_cfg_struct.base_addr_trace_buffer;
-
- chdlc_priv_area->end_addr_trace_buffer =
- trace_cfg_struct.end_addr_trace_buffer;
-
- chdlc_priv_area->curr_trace_addr =
- trace_cfg_struct.next_trace_element_to_use;
-
- chdlc_priv_area->available_buffer_space = 2000 -
- sizeof(ip_pkt_t) -
- sizeof(udp_pkt_t) -
- sizeof(wp_mgmt_t) -
- sizeof(cblock_t) -
- sizeof(trace_info_t);
- }
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- mb->buffer_length = 0;
- chdlc_priv_area->TracingEnabled = 1;
- break;
-
-
- case CPIPE_DISABLE_TRACING:
- if (chdlc_priv_area->TracingEnabled) {
-
- /* OPERATE_DATALINE_MONITOR */
- mb->buffer_length = sizeof(LINE_TRACE_CONFIG_STRUCT);
- mb->command = SET_TRACE_CONFIGURATION;
- ((LINE_TRACE_CONFIG_STRUCT *)mb->data)->
- trace_config = TRACE_INACTIVE;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- }
-
- chdlc_priv_area->TracingEnabled = 0;
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- mb->buffer_length = 0;
- break;
-
-
- case CPIPE_GET_TRACE_INFO:
-
- if (!chdlc_priv_area->TracingEnabled) {
- chdlc_udp_pkt->cblock.return_code = 1;
- mb->buffer_length = 0;
- break;
- }
-
- chdlc_udp_pkt->trace_info.ismoredata = 0x00;
- buffer_length = 0; /* offset of packet already occupied */
-
- for (frames=0; frames < chdlc_priv_area->number_trace_elements; frames++){
-
- trace_pkt_t *trace_pkt = (trace_pkt_t *)
- &chdlc_udp_pkt->data[buffer_length];
-
- sdla_peek(&card->hw, chdlc_priv_area->curr_trace_addr,
- (unsigned char *)&trace_element_struct,
- sizeof(TRACE_STATUS_ELEMENT_STRUCT));
-
- if (trace_element_struct.opp_flag == 0x00) {
- break;
- }
-
- /* get pointer to real data */
- data_ptr = trace_element_struct.ptr_data_bfr;
-
- /* See if there is actual data on the trace buffer */
- if (data_ptr){
- data_length = trace_element_struct.trace_length;
- }else{
- data_length = 0;
- chdlc_udp_pkt->trace_info.ismoredata = 0x01;
- }
-
- if( (chdlc_priv_area->available_buffer_space - buffer_length)
- < ( sizeof(trace_pkt_t) + data_length) ) {
-
- /* indicate there are more frames on board & exit */
- chdlc_udp_pkt->trace_info.ismoredata = 0x01;
- break;
- }
-
- trace_pkt->status = trace_element_struct.trace_type;
-
- trace_pkt->time_stamp =
- trace_element_struct.trace_time_stamp;
-
- trace_pkt->real_length =
- trace_element_struct.trace_length;
-
- /* see if we can fit the frame into the user buffer */
- real_len = trace_pkt->real_length;
-
- if (data_ptr == 0) {
- trace_pkt->data_avail = 0x00;
- } else {
- unsigned tmp = 0;
-
- /* get the data from circular buffer
- must check for end of buffer */
- trace_pkt->data_avail = 0x01;
-
- if ((data_ptr + real_len) >
- chdlc_priv_area->end_addr_trace_buffer + 1){
-
- tmp = chdlc_priv_area->end_addr_trace_buffer - data_ptr + 1;
- sdla_peek(&card->hw, data_ptr,
- trace_pkt->data,tmp);
- data_ptr = chdlc_priv_area->base_addr_trace_buffer;
- }
-
- sdla_peek(&card->hw, data_ptr,
- &trace_pkt->data[tmp], real_len - tmp);
- }
-
- /* zero the opp flag to show we got the frame */
- ut_char = 0x00;
- sdla_poke(&card->hw, chdlc_priv_area->curr_trace_addr, &ut_char, 1);
-
- /* now move onto the next frame */
- chdlc_priv_area->curr_trace_addr += sizeof(TRACE_STATUS_ELEMENT_STRUCT);
-
- /* check if we went over the last address */
- if ( chdlc_priv_area->curr_trace_addr > chdlc_priv_area->end_trace_addr ) {
- chdlc_priv_area->curr_trace_addr = chdlc_priv_area->start_trace_addr;
- }
-
- if(trace_pkt->data_avail == 0x01) {
- buffer_length += real_len - 1;
- }
-
- /* for the header */
- buffer_length += sizeof(trace_pkt_t);
-
- } /* For Loop */
-
- if (frames == chdlc_priv_area->number_trace_elements){
- chdlc_udp_pkt->trace_info.ismoredata = 0x01;
- }
- chdlc_udp_pkt->trace_info.num_frames = frames;
-
- mb->buffer_length = buffer_length;
- chdlc_udp_pkt->cblock.buffer_length = buffer_length;
-
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
-
- break;
-
-
- case CPIPE_FT1_READ_STATUS:
- ((unsigned char *)chdlc_udp_pkt->data )[0] =
- flags->FT1_info_struct.parallel_port_A_input;
-
- ((unsigned char *)chdlc_udp_pkt->data )[1] =
- flags->FT1_info_struct.parallel_port_B_input;
-
- chdlc_udp_pkt->cblock.return_code = COMMAND_OK;
- mb->buffer_length = 2;
- break;
-
- case CPIPE_ROUTER_UP_TIME:
- do_gettimeofday( &tv );
- chdlc_priv_area->router_up_time = tv.tv_sec -
- chdlc_priv_area->router_start_time;
- *(unsigned long *)&chdlc_udp_pkt->data =
- chdlc_priv_area->router_up_time;
- mb->buffer_length = sizeof(unsigned long);
- break;
-
- case FT1_MONITOR_STATUS_CTRL:
- /* Enable FT1 MONITOR STATUS */
- if ((chdlc_udp_pkt->data[0] & ENABLE_READ_FT1_STATUS) ||
- (chdlc_udp_pkt->data[0] & ENABLE_READ_FT1_OP_STATS)) {
-
- if( rCount++ != 0 ) {
- chdlc_udp_pkt->cblock.
- return_code = COMMAND_OK;
- mb->buffer_length = 1;
- break;
- }
- }
-
- /* Disable FT1 MONITOR STATUS */
- if( chdlc_udp_pkt->data[0] == 0) {
-
- if( --rCount != 0) {
- chdlc_udp_pkt->cblock.
- return_code = COMMAND_OK;
- mb->buffer_length = 1;
- break;
- }
- }
-
- default:
- /* it's a board command */
- mb->command = chdlc_udp_pkt->cblock.command;
- mb->buffer_length = chdlc_udp_pkt->cblock.buffer_length;
- if (mb->buffer_length) {
- memcpy(&mb->data, (unsigned char *) chdlc_udp_pkt->
- data, mb->buffer_length);
- }
- /* run the command on the board */
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- if (err != COMMAND_OK) {
- break;
- }
-
- /* copy the result back to our buffer */
- memcpy(&chdlc_udp_pkt->cblock, mb, sizeof(cblock_t));
-
- if (mb->buffer_length) {
- memcpy(&chdlc_udp_pkt->data, &mb->data,
- mb->buffer_length);
- }
-
- } /* end of switch */
- } /* end of else */
-
- /* Fill UDP TTL */
- chdlc_udp_pkt->ip_pkt.ttl = card->wandev.ttl;
-
- len = reply_udp(chdlc_priv_area->udp_pkt_data, mb->buffer_length);
-
- if(chdlc_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK) {
- if(!chdlc_send(card, chdlc_priv_area->udp_pkt_data, len)) {
- ++ card->wandev.stats.tx_packets;
- card->wandev.stats.tx_bytes += len;
- }
- } else {
-
- /* Pass it up the stack
- Allocate socket buffer */
- if ((new_skb = dev_alloc_skb(len)) != NULL) {
- /* copy data into new_skb */
-
- buf = skb_put(new_skb, len);
- memcpy(buf, chdlc_priv_area->udp_pkt_data, len);
-
- /* Decapsulate pkt and pass it up the protocol stack */
- new_skb->protocol = htons(ETH_P_IP);
- new_skb->dev = dev;
- new_skb->mac.raw = new_skb->data;
-
- netif_rx(new_skb);
- dev->last_rx = jiffies;
- } else {
-
- printk(KERN_INFO "%s: no socket buffers available!\n",
- card->devname);
- }
- }
-
- chdlc_priv_area->udp_pkt_lgth = 0;
-
- return 0;
-}
-
-/*============================================================================
- * Initialize Receive and Transmit Buffers.
- */
-
-static void init_chdlc_tx_rx_buff(sdla_t* card, struct net_device *dev)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- CHDLC_TX_STATUS_EL_CFG_STRUCT *tx_config;
- CHDLC_RX_STATUS_EL_CFG_STRUCT *rx_config;
- char err;
-
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CONFIGURATION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
-
- if(err != COMMAND_OK) {
- chdlc_error(card,err,mb);
- return;
- }
-
- if(card->hw.type == SDLA_S514) {
- tx_config = (CHDLC_TX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Tx_stat_el_cfg_struct));
- rx_config = (CHDLC_RX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Rx_stat_el_cfg_struct));
-
- /* Setup Head and Tails for buffers */
- card->u.c.txbuf_base = (void *)(card->hw.dpmbase +
- tx_config->base_addr_Tx_status_elements);
- card->u.c.txbuf_last =
- (CHDLC_DATA_TX_STATUS_EL_STRUCT *)
- card->u.c.txbuf_base +
- (tx_config->number_Tx_status_elements - 1);
-
- card->u.c.rxbuf_base = (void *)(card->hw.dpmbase +
- rx_config->base_addr_Rx_status_elements);
- card->u.c.rxbuf_last =
- (CHDLC_DATA_RX_STATUS_EL_STRUCT *)
- card->u.c.rxbuf_base +
- (rx_config->number_Rx_status_elements - 1);
-
- /* Set up next pointer to be used */
- card->u.c.txbuf = (void *)(card->hw.dpmbase +
- tx_config->next_Tx_status_element_to_use);
- card->u.c.rxmb = (void *)(card->hw.dpmbase +
- rx_config->next_Rx_status_element_to_use);
- }
- else {
- tx_config = (CHDLC_TX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Tx_stat_el_cfg_struct % SDLA_WINDOWSIZE));
-
- rx_config = (CHDLC_RX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
- (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
- ptr_CHDLC_Rx_stat_el_cfg_struct % SDLA_WINDOWSIZE));
-
- /* Setup Head and Tails for buffers */
- card->u.c.txbuf_base = (void *)(card->hw.dpmbase +
- (tx_config->base_addr_Tx_status_elements % SDLA_WINDOWSIZE));
- card->u.c.txbuf_last =
- (CHDLC_DATA_TX_STATUS_EL_STRUCT *)card->u.c.txbuf_base
- + (tx_config->number_Tx_status_elements - 1);
- card->u.c.rxbuf_base = (void *)(card->hw.dpmbase +
- (rx_config->base_addr_Rx_status_elements % SDLA_WINDOWSIZE));
- card->u.c.rxbuf_last =
- (CHDLC_DATA_RX_STATUS_EL_STRUCT *)card->u.c.rxbuf_base
- + (rx_config->number_Rx_status_elements - 1);
-
- /* Set up next pointer to be used */
- card->u.c.txbuf = (void *)(card->hw.dpmbase +
- (tx_config->next_Tx_status_element_to_use % SDLA_WINDOWSIZE));
- card->u.c.rxmb = (void *)(card->hw.dpmbase +
- (rx_config->next_Rx_status_element_to_use % SDLA_WINDOWSIZE));
- }
-
- /* Setup Actual Buffer Start and end addresses */
- card->u.c.rx_base = rx_config->base_addr_Rx_buffer;
- card->u.c.rx_top = rx_config->end_addr_Rx_buffer;
-
-}
-
-/*=============================================================================
- * Perform Interrupt Test by running READ_CHDLC_CODE_VERSION command MAX_INTR
- * _TEST_COUNTER times.
- */
-static int intr_test( sdla_t* card)
-{
- CHDLC_MAILBOX_STRUCT* mb = card->mbox;
- int err,i;
-
- Intr_test_counter = 0;
-
- /* The critical flag is unset because during initialization (if_open)
- * we want the interrupts to be enabled so that when the wpc_isr is
- * called it does not exit due to critical flag set.
- */
-
- err = chdlc_set_intr_mode(card, APP_INT_ON_COMMAND_COMPLETE);
-
- if (err == CMD_OK) {
- for (i = 0; i < MAX_INTR_TEST_COUNTER; i ++) {
- mb->buffer_length = 0;
- mb->command = READ_CHDLC_CODE_VERSION;
- err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
- }
- }
- else {
- return err;
- }
-
- err = chdlc_set_intr_mode(card, 0);
-
- if (err != CMD_OK)
- return err;
-
- return 0;
-}
-
-/*==============================================================================
- * Determine what type of UDP call it is. CPIPEAB ?
- */
-static int udp_pkt_type(struct sk_buff *skb, sdla_t* card)
-{
- chdlc_udp_pkt_t *chdlc_udp_pkt = (chdlc_udp_pkt_t *)skb->data;
-
- if (!strncmp(chdlc_udp_pkt->wp_mgmt.signature,UDPMGMT_SIGNATURE,8) &&
- (chdlc_udp_pkt->udp_pkt.udp_dst_port == ntohs(card->wandev.udp_port)) &&
- (chdlc_udp_pkt->ip_pkt.protocol == UDPMGMT_UDP_PROTOCOL) &&
- (chdlc_udp_pkt->wp_mgmt.request_reply == UDPMGMT_REQUEST)) {
- return UDP_CPIPE_TYPE;
- }
- else return UDP_INVALID_TYPE;
-}
-
-/*============================================================================
- * Set PORT state.
- */
-static void port_set_state (sdla_t *card, int state)
-{
- struct net_device *dev = card->wandev.dev;
- chdlc_private_area_t *chdlc_priv_area = dev->priv;
-
- if (card->u.c.state != state)
- {
- switch (state)
- {
- case WAN_CONNECTED:
- printk (KERN_INFO "%s: HDLC link connected!\n",
- card->devname);
- break;
-
- case WAN_CONNECTING:
- printk (KERN_INFO "%s: HDLC link connecting...\n",
- card->devname);
- break;
-
- case WAN_DISCONNECTED:
- printk (KERN_INFO "%s: HDLC link disconnected!\n",
- card->devname);
- break;
- }
-
- card->wandev.state = card->u.c.state = state;
- chdlc_priv_area->common.state = state;
- }
-}
-
-void s508_lock (sdla_t *card, unsigned long *smp_flags)
-{
- spin_lock_irqsave(&card->wandev.lock, *smp_flags);
- if (card->next){
- /* It is ok to use spin_lock here, since we
- * already turned off interrupts */
- spin_lock(&card->next->wandev.lock);
- }
-}
-
-void s508_unlock (sdla_t *card, unsigned long *smp_flags)
-{
- if (card->next){
- spin_unlock(&card->next->wandev.lock);
- }
- spin_unlock_irqrestore(&card->wandev.lock, *smp_flags);
-}
-
-
-
-/*===========================================================================
- * config_chdlc
- *
- * Configure the chdlc protocol and enable communications.
- *
- * The if_open() function binds this function to the poll routine.
- * Therefore, this function will run every time the chdlc interface
- * is brought up. We cannot run this function from the if_open
- * because if_open does not have access to the remote IP address.
- *
- * If the communications are not enabled, proceed to configure
- * the card and enable communications.
- *
- * If the communications are enabled, it means that the interface
- * was shutdown by ether the user or driver. In this case, we
- * have to check that the IP addresses have not changed. If
- * the IP addresses have changed, we have to reconfigure the firmware
- * and update the changed IP addresses. Otherwise, just exit.
- *
- */
-
-static int config_chdlc (sdla_t *card)
-{
- struct net_device *dev = card->wandev.dev;
- SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags;
-
- if (card->u.c.comm_enabled){
- chdlc_comm_disable(card);
- port_set_state(card, WAN_DISCONNECTED);
- }
-
- if (set_chdlc_config(card)) {
- printk(KERN_INFO "%s: CHDLC Configuration Failed!\n",
- card->devname);
- return 0;
- }
- init_chdlc_tx_rx_buff(card, dev);
-
- /* Set interrupt mode and mask */
- if (chdlc_set_intr_mode(card, APP_INT_ON_RX_FRAME |
- APP_INT_ON_GLOBAL_EXCEP_COND |
- APP_INT_ON_TX_FRAME |
- APP_INT_ON_CHDLC_EXCEP_COND | APP_INT_ON_TIMER)){
- printk (KERN_INFO "%s: Failed to set interrupt triggers!\n",
- card->devname);
- return 0;
- }
-
-
- /* Mask the Transmit and Timer interrupt */
- flags->interrupt_info_struct.interrupt_permission &=
- ~(APP_INT_ON_TX_FRAME | APP_INT_ON_TIMER);
-
-
- if (chdlc_comm_enable(card) != 0) {
- printk(KERN_INFO "%s: Failed to enable chdlc communications!\n",
- card->devname);
- flags->interrupt_info_struct.interrupt_permission = 0;
- card->u.c.comm_enabled=0;
- chdlc_set_intr_mode(card,0);
- return 0;
- }
-
- /* Initialize Rx/Tx buffer control fields */
- port_set_state(card, WAN_CONNECTING);
- return 0;
-}
-
-
-static void send_ppp_term_request(struct net_device *dev)
-{
- struct sk_buff *new_skb;
- unsigned char *buf;
-
- if ((new_skb = dev_alloc_skb(8)) != NULL) {
- /* copy data into new_skb */
-
- buf = skb_put(new_skb, 8);
- sprintf(buf,"%c%c%c%c%c%c%c%c", 0xFF,0x03,0xC0,0x21,0x05,0x98,0x00,0x07);
-
- /* Decapsulate pkt and pass it up the protocol stack */
- new_skb->protocol = htons(ETH_P_WAN_PPP);
- new_skb->dev = dev;
- new_skb->mac.raw = new_skb->data;
-
- netif_rx(new_skb);
- dev->last_rx = jiffies;
- }
-}
-
-
-MODULE_LICENSE("GPL");
-
-/****** End ****************************************************************/
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index d121644646b9e..98b83a85c60e2 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -100,8 +100,6 @@ static struct pci_device_id parport_serial_pci_tbl[] = {
PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo },
{ PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9835,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo },
- { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9835,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo },
{ PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9845,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo },
{ PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855,
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 929dd8090578b..65d090dbef460 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -147,6 +147,16 @@ config RTC_DRV_SA1100
To compile this driver as a module, choose M here: the
module will be called rtc-sa1100.
+config RTC_DRV_VR41XX
+ tristate "NEC VR41XX"
+ depends on RTC_CLASS && CPU_VR41XX
+ help
+ If you say Y here you will get access to the real time clock
+ built into your NEC VR41XX CPU.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rtc-vr41xx.
+
config RTC_DRV_TEST
tristate "Test driver/device"
depends on RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 8d4c7fe88d585..a9ca0f1716868 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -19,3 +19,4 @@ obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o
+obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 8533936d50d86..413c7d54ea10f 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -96,6 +96,8 @@ exit_idr:
idr_remove(&rtc_idr, id);
exit:
+ dev_err(dev, "rtc core: unable to register %s, err = %d\n",
+ name, err);
return ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(rtc_device_register);
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 358695a416f32..9be81fd4737c2 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -1,6 +1,8 @@
/*
* An rtc/i2c driver for the Dallas DS1672
- * Copyright 2005 Alessandro Zummo
+ * Copyright 2005-06 Tower Technologies
+ *
+ * Author: Alessandro Zummo <a.zummo@towertech.it>
*
* 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
@@ -11,7 +13,7 @@
#include <linux/i2c.h>
#include <linux/rtc.h>
-#define DRV_VERSION "0.2"
+#define DRV_VERSION "0.3"
/* Addresses to scan: none. This chip cannot be detected. */
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
@@ -25,6 +27,7 @@ I2C_CLIENT_INSMOD;
#define DS1672_REG_CONTROL 4
#define DS1672_REG_TRICKLE 5
+#define DS1672_REG_CONTROL_EOSC 0x80
/* Prototypes */
static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind);
@@ -53,8 +56,7 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
dev_dbg(&client->dev,
"%s: raw read data - counters=%02x,%02x,%02x,%02x\n"
- __FUNCTION__,
- buf[0], buf[1], buf[2], buf[3]);
+ __FUNCTION__, buf[0], buf[1], buf[2], buf[3]);
time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
@@ -62,8 +64,7 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
"mday=%d, mon=%d, year=%d, wday=%d\n",
- __FUNCTION__,
- tm->tm_sec, tm->tm_min, tm->tm_hour,
+ __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour,
tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
return 0;
@@ -72,16 +73,17 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs)
{
int xfer;
- unsigned char buf[5];
+ unsigned char buf[6];
buf[0] = DS1672_REG_CNT_BASE;
buf[1] = secs & 0x000000FF;
buf[2] = (secs & 0x0000FF00) >> 8;
buf[3] = (secs & 0x00FF0000) >> 16;
buf[4] = (secs & 0xFF000000) >> 24;
+ buf[5] = 0; /* set control reg to enable counting */
- xfer = i2c_master_send(client, buf, 5);
- if (xfer != 5) {
+ xfer = i2c_master_send(client, buf, 6);
+ if (xfer != 6) {
dev_err(&client->dev, "%s: send: %d\n", __FUNCTION__, xfer);
return -EIO;
}
@@ -120,6 +122,40 @@ static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs)
return ds1672_set_mmss(to_i2c_client(dev), secs);
}
+static int ds1672_get_control(struct i2c_client *client, u8 *status)
+{
+ unsigned char addr = DS1672_REG_CONTROL;
+
+ struct i2c_msg msgs[] = {
+ { client->addr, 0, 1, &addr }, /* setup read ptr */
+ { client->addr, I2C_M_RD, 1, status }, /* read control */
+ };
+
+ /* read control register */
+ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
+ dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+/* following are the sysfs callback functions */
+static ssize_t show_control(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ u8 control;
+ int err;
+
+ err = ds1672_get_control(client, &control);
+ if (err)
+ return err;
+
+ return sprintf(buf, "%s\n", (control & DS1672_REG_CONTROL_EOSC)
+ ? "disabled" : "enabled");
+}
+static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);
+
static struct rtc_class_ops ds1672_rtc_ops = {
.read_time = ds1672_rtc_read_time,
.set_time = ds1672_rtc_set_time,
@@ -128,7 +164,6 @@ static struct rtc_class_ops ds1672_rtc_ops = {
static int ds1672_attach(struct i2c_adapter *adapter)
{
- dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
return i2c_probe(adapter, &addr_data, ds1672_probe);
}
@@ -137,8 +172,6 @@ static int ds1672_detach(struct i2c_client *client)
int err;
struct rtc_device *rtc = i2c_get_clientdata(client);
- dev_dbg(&client->dev, "%s\n", __FUNCTION__);
-
if (rtc)
rtc_device_unregister(rtc);
@@ -162,6 +195,7 @@ static struct i2c_driver ds1672_driver = {
static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
{
int err = 0;
+ u8 control;
struct i2c_client *client;
struct rtc_device *rtc;
@@ -195,13 +229,23 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
- dev_err(&client->dev,
- "unable to register the class device\n");
goto exit_detach;
}
i2c_set_clientdata(client, rtc);
+ /* read control register */
+ err = ds1672_get_control(client, &control);
+ if (err)
+ goto exit_detach;
+
+ if (control & DS1672_REG_CONTROL_EOSC)
+ dev_warn(&client->dev, "Oscillator not enabled. "
+ "Set time to enable.\n");
+
+ /* Register sysfs hooks */
+ device_create_file(&client->dev, &dev_attr_control);
+
return 0;
exit_detach:
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 0dd80ea686a9b..e1a1169e46649 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -67,7 +67,6 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
ep93xx_get_swcomp(dev, &preload, &delete);
- seq_printf(seq, "24hr\t\t: yes\n");
seq_printf(seq, "preload\t\t: %d\n", preload);
seq_printf(seq, "delete\t\t: %d\n", delete);
@@ -110,7 +109,6 @@ static int __devinit ep93xx_rtc_probe(struct platform_device *dev)
&dev->dev, &ep93xx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
- dev_err(&dev->dev, "unable to register\n");
return PTR_ERR(rtc);
}
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c
index db445c872b1b9..f6e7ee04f3dc6 100644
--- a/drivers/rtc/rtc-m48t86.c
+++ b/drivers/rtc/rtc-m48t86.c
@@ -23,7 +23,7 @@
#define M48T86_REG_SECALRM 0x01
#define M48T86_REG_MIN 0x02
#define M48T86_REG_MINALRM 0x03
-#define M48T86_REG_HOUR 0x04
+#define M48T86_REG_HOUR 0x04
#define M48T86_REG_HOURALRM 0x05
#define M48T86_REG_DOW 0x06 /* 1 = sunday */
#define M48T86_REG_DOM 0x07
@@ -127,9 +127,6 @@ static int m48t86_rtc_proc(struct device *dev, struct seq_file *seq)
reg = ops->readb(M48T86_REG_B);
- seq_printf(seq, "24hr\t\t: %s\n",
- (reg & M48T86_REG_B_H24) ? "yes" : "no");
-
seq_printf(seq, "mode\t\t: %s\n",
(reg & M48T86_REG_B_DM) ? "binary" : "bcd");
@@ -154,10 +151,8 @@ static int __devinit m48t86_rtc_probe(struct platform_device *dev)
struct rtc_device *rtc = rtc_device_register("m48t86",
&dev->dev, &m48t86_rtc_ops, THIS_MODULE);
- if (IS_ERR(rtc)) {
- dev_err(&dev->dev, "unable to register\n");
+ if (IS_ERR(rtc))
return PTR_ERR(rtc);
- }
platform_set_drvdata(dev, rtc);
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index d857d45bdbe85..ba9a583b7b681 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -227,14 +227,7 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
return pcf8563_set_datetime(to_i2c_client(dev), tm);
}
-static int pcf8563_rtc_proc(struct device *dev, struct seq_file *seq)
-{
- seq_printf(seq, "24hr\t\t: yes\n");
- return 0;
-}
-
static struct rtc_class_ops pcf8563_rtc_ops = {
- .proc = pcf8563_rtc_proc,
.read_time = pcf8563_rtc_read_time,
.set_time = pcf8563_rtc_set_time,
};
@@ -297,8 +290,6 @@ static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
- dev_err(&client->dev,
- "unable to register the class device\n");
goto exit_detach;
}
@@ -321,8 +312,6 @@ static int pcf8563_detach(struct i2c_client *client)
int err;
struct rtc_device *rtc = i2c_get_clientdata(client);
- dev_dbg(&client->dev, "%s\n", __FUNCTION__);
-
if (rtc)
rtc_device_unregister(rtc);
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 90b8a97a09198..cef5f5a3bbf92 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -71,6 +71,8 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
alrm.pending ? "yes" : "no");
}
+ seq_printf(seq, "24hr\t\t: yes\n");
+
if (ops->proc)
ops->proc(class_dev->dev, seq);
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 396c8681f66c7..7553d797603fd 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -151,9 +151,8 @@ static int rs5c372_rtc_proc(struct device *dev, struct seq_file *seq)
{
int err, osc, trim;
- seq_printf(seq, "24hr\t\t: yes\n");
-
- if ((err = rs5c372_get_trim(to_i2c_client(dev), &osc, &trim)) == 0) {
+ err = rs5c372_get_trim(to_i2c_client(dev), &osc, &trim);
+ if (err == 0) {
seq_printf(seq, "%d.%03d KHz\n", osc / 1000, osc % 1000);
seq_printf(seq, "trim\t: %d\n", trim);
}
@@ -170,30 +169,31 @@ static struct rtc_class_ops rs5c372_rtc_ops = {
static ssize_t rs5c372_sysfs_show_trim(struct device *dev,
struct device_attribute *attr, char *buf)
{
- int trim;
+ int err, trim;
- if (rs5c372_get_trim(to_i2c_client(dev), NULL, &trim) == 0)
- return sprintf(buf, "0x%2x\n", trim);
+ err = rs5c372_get_trim(to_i2c_client(dev), NULL, &trim);
+ if (err)
+ return err;
- return 0;
+ return sprintf(buf, "0x%2x\n", trim);
}
static DEVICE_ATTR(trim, S_IRUGO, rs5c372_sysfs_show_trim, NULL);
static ssize_t rs5c372_sysfs_show_osc(struct device *dev,
struct device_attribute *attr, char *buf)
{
- int osc;
+ int err, osc;
- if (rs5c372_get_trim(to_i2c_client(dev), &osc, NULL) == 0)
- return sprintf(buf, "%d.%03d KHz\n", osc / 1000, osc % 1000);
+ err = rs5c372_get_trim(to_i2c_client(dev), &osc, NULL);
+ if (err)
+ return err;
- return 0;
+ return sprintf(buf, "%d.%03d KHz\n", osc / 1000, osc % 1000);
}
static DEVICE_ATTR(osc, S_IRUGO, rs5c372_sysfs_show_osc, NULL);
static int rs5c372_attach(struct i2c_adapter *adapter)
{
- dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
return i2c_probe(adapter, &addr_data, rs5c372_probe);
}
@@ -233,8 +233,6 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
- dev_err(&client->dev,
- "unable to register the class device\n");
goto exit_detach;
}
@@ -260,8 +258,6 @@ static int rs5c372_detach(struct i2c_client *client)
int err;
struct rtc_device *rtc = i2c_get_clientdata(client);
- dev_dbg(&client->dev, "%s\n", __FUNCTION__);
-
if (rtc)
rtc_device_unregister(rtc);
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 83b2bb480a16d..a23ec54989f6d 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -160,19 +160,19 @@ static int sa1100_rtc_open(struct device *dev)
ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, SA_INTERRUPT,
"rtc 1Hz", dev);
if (ret) {
- printk(KERN_ERR "rtc: IRQ%d already in use.\n", IRQ_RTC1Hz);
+ dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz);
goto fail_ui;
}
ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, SA_INTERRUPT,
"rtc Alrm", dev);
if (ret) {
- printk(KERN_ERR "rtc: IRQ%d already in use.\n", IRQ_RTCAlrm);
+ dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm);
goto fail_ai;
}
ret = request_irq(IRQ_OST1, timer1_interrupt, SA_INTERRUPT,
"rtc timer", dev);
if (ret) {
- printk(KERN_ERR "rtc: IRQ%d already in use.\n", IRQ_OST1);
+ dev_err(dev, "IRQ %d already in use.\n", IRQ_OST1);
goto fail_pi;
}
return 0;
@@ -332,7 +332,7 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
*/
if (RTTR == 0) {
RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
- printk(KERN_WARNING "rtc: warning: initializing default clock divider/trim value\n");
+ dev_warn(&pdev->dev, "warning: initializing default clock divider/trim value\n");
/* The current RTC value probably doesn't make sense either */
RCNR = 0;
}
@@ -340,15 +340,11 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops,
THIS_MODULE);
- if (IS_ERR(rtc)) {
- dev_err(&pdev->dev, "Unable to register the RTC device\n");
+ if (IS_ERR(rtc))
return PTR_ERR(rtc);
- }
platform_set_drvdata(pdev, rtc);
- dev_info(&pdev->dev, "SA11xx/PXA2xx RTC Registered\n");
-
return 0;
}
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 43d107487820a..e1f7e8e86daff 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -49,7 +49,6 @@ static int test_rtc_proc(struct device *dev, struct seq_file *seq)
{
struct platform_device *plat_dev = to_platform_device(dev);
- seq_printf(seq, "24hr\t\t: yes\n");
seq_printf(seq, "test\t\t: yes\n");
seq_printf(seq, "id\t\t: %d\n", plat_dev->id);
@@ -120,8 +119,6 @@ static int test_probe(struct platform_device *plat_dev)
&test_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
- dev_err(&plat_dev->dev,
- "unable to register the class device\n");
return err;
}
device_create_file(&plat_dev->dev, &dev_attr_irq);
diff --git a/drivers/char/vr41xx_rtc.c b/drivers/rtc/rtc-vr41xx.c
index b109d9a502d63..4d49fd501198f 100644
--- a/drivers/char/vr41xx_rtc.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -1,7 +1,7 @@
/*
- * Driver for NEC VR4100 series Real Time Clock unit.
+ * Driver for NEC VR4100 series Real Time Clock unit.
*
- * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
+ * Copyright (C) 2003-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
*
* 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
@@ -17,23 +17,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <linux/platform_device.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/irq.h>
-#include <linux/mc146818rtc.h>
-#include <linux/miscdevice.h>
#include <linux/module.h>
-#include <linux/poll.h>
+#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
#include <linux/types.h>
-#include <linux/wait.h>
#include <asm/div64.h>
#include <asm/io.h>
-#include <asm/time.h>
#include <asm/uaccess.h>
#include <asm/vr41xx/vr41xx.h>
@@ -99,27 +94,11 @@ static void __iomem *rtc2_base;
static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */
-static spinlock_t rtc_task_lock;
-static wait_queue_head_t rtc_wait;
-static unsigned long rtc_irq_data;
-static struct fasync_struct *rtc_async_queue;
-static rtc_task_t *rtc_callback;
+static spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
static char rtc_name[] = "RTC";
static unsigned long periodic_frequency;
static unsigned long periodic_count;
-typedef enum {
- RTC_RELEASE,
- RTC_OPEN,
-} rtc_status_t;
-
-static rtc_status_t rtc_status;
-
-typedef enum {
- FUNCTION_RTC_IOCTL,
- FUNCTION_RTC_CONTROL,
-} rtc_callfrom_t;
-
struct resource rtc_resource[2] = {
{ .name = rtc_name,
.flags = IORESOURCE_MEM, },
@@ -129,7 +108,9 @@ struct resource rtc_resource[2] = {
static inline unsigned long read_elapsed_second(void)
{
+
unsigned long first_low, first_mid, first_high;
+
unsigned long second_low, second_mid, second_high;
do {
@@ -156,50 +137,36 @@ static inline void write_elapsed_second(unsigned long sec)
spin_unlock_irq(&rtc_lock);
}
-static void set_alarm(struct rtc_time *time)
+static void vr41xx_rtc_release(struct device *dev)
{
- unsigned long alarm_sec;
-
- alarm_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
- time->tm_hour, time->tm_min, time->tm_sec);
-
- spin_lock_irq(&rtc_lock);
-
- rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15));
- rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1));
- rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17));
-
- spin_unlock_irq(&rtc_lock);
-}
-
-static void read_alarm(struct rtc_time *time)
-{
- unsigned long low, mid, high;
spin_lock_irq(&rtc_lock);
- low = rtc1_read(ECMPLREG);
- mid = rtc1_read(ECMPMREG);
- high = rtc1_read(ECMPHREG);
+ rtc1_write(ECMPLREG, 0);
+ rtc1_write(ECMPMREG, 0);
+ rtc1_write(ECMPHREG, 0);
+ rtc1_write(RTCL1LREG, 0);
+ rtc1_write(RTCL1HREG, 0);
spin_unlock_irq(&rtc_lock);
- to_tm((high << 17) | (mid << 1) | (low >> 15), time);
- time->tm_year -= 1900;
+ disable_irq(ELAPSEDTIME_IRQ);
+ disable_irq(RTCLONG1_IRQ);
}
-static void read_time(struct rtc_time *time)
+static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time)
{
unsigned long epoch_sec, elapsed_sec;
epoch_sec = mktime(epoch, 1, 1, 0, 0, 0);
elapsed_sec = read_elapsed_second();
- to_tm(epoch_sec + elapsed_sec, time);
- time->tm_year -= 1900;
+ rtc_time_to_tm(epoch_sec + elapsed_sec, time);
+
+ return 0;
}
-static void set_time(struct rtc_time *time)
+static int vr41xx_rtc_set_time(struct device *dev, struct rtc_time *time)
{
unsigned long epoch_sec, current_sec;
@@ -208,73 +175,49 @@ static void set_time(struct rtc_time *time)
time->tm_hour, time->tm_min, time->tm_sec);
write_elapsed_second(current_sec - epoch_sec);
+
+ return 0;
}
-static ssize_t rtc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
{
- DECLARE_WAITQUEUE(wait, current);
- unsigned long irq_data;
- int retval = 0;
-
- if (count != sizeof(unsigned int) && count != sizeof(unsigned long))
- return -EINVAL;
-
- add_wait_queue(&rtc_wait, &wait);
-
- do {
- __set_current_state(TASK_INTERRUPTIBLE);
+ unsigned long low, mid, high;
+ struct rtc_time *time = &wkalrm->time;
- spin_lock_irq(&rtc_lock);
- irq_data = rtc_irq_data;
- rtc_irq_data = 0;
- spin_unlock_irq(&rtc_lock);
+ spin_lock_irq(&rtc_lock);
- if (irq_data != 0)
- break;
+ low = rtc1_read(ECMPLREG);
+ mid = rtc1_read(ECMPMREG);
+ high = rtc1_read(ECMPHREG);
- if (file->f_flags & O_NONBLOCK) {
- retval = -EAGAIN;
- break;
- }
+ spin_unlock_irq(&rtc_lock);
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
- } while (1);
+ rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time);
- if (retval == 0) {
- if (count == sizeof(unsigned int)) {
- retval = put_user(irq_data, (unsigned int __user *)buf);
- if (retval == 0)
- retval = sizeof(unsigned int);
- } else {
- retval = put_user(irq_data, (unsigned long __user *)buf);
- if (retval == 0)
- retval = sizeof(unsigned long);
- }
+ return 0;
+}
- }
+static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
+{
+ unsigned long alarm_sec;
+ struct rtc_time *time = &wkalrm->time;
- __set_current_state(TASK_RUNNING);
- remove_wait_queue(&rtc_wait, &wait);
+ alarm_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
+ time->tm_hour, time->tm_min, time->tm_sec);
- return retval;
-}
+ spin_lock_irq(&rtc_lock);
-static unsigned int rtc_poll(struct file *file, struct poll_table_struct *table)
-{
- poll_wait(file, &rtc_wait, table);
+ rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15));
+ rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1));
+ rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17));
- if (rtc_irq_data != 0)
- return POLLIN | POLLRDNORM;
+ spin_unlock_irq(&rtc_lock);
return 0;
}
-static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, rtc_callfrom_t from)
+static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
- struct rtc_time time;
unsigned long count;
switch (cmd) {
@@ -290,33 +233,6 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, rtc_callfrom_t from
case RTC_PIE_OFF:
disable_irq(RTCLONG1_IRQ);
break;
- case RTC_ALM_SET:
- if (copy_from_user(&time, (struct rtc_time __user *)arg,
- sizeof(struct rtc_time)))
- return -EFAULT;
-
- set_alarm(&time);
- break;
- case RTC_ALM_READ:
- memset(&time, 0, sizeof(struct rtc_time));
- read_alarm(&time);
- break;
- case RTC_RD_TIME:
- memset(&time, 0, sizeof(struct rtc_time));
- read_time(&time);
- if (copy_to_user((void __user *)arg, &time, sizeof(struct rtc_time)))
- return -EFAULT;
- break;
- case RTC_SET_TIME:
- if (capable(CAP_SYS_TIME) == 0)
- return -EACCES;
-
- if (copy_from_user(&time, (struct rtc_time __user *)arg,
- sizeof(struct rtc_time)))
- return -EFAULT;
-
- set_time(&time);
- break;
case RTC_IRQP_READ:
return put_user(periodic_frequency, (unsigned long __user *)arg);
break;
@@ -324,8 +240,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, rtc_callfrom_t from
if (arg > MAX_PERIODIC_RATE)
return -EINVAL;
- if (from == FUNCTION_RTC_IOCTL && arg > MAX_USER_PERIODIC_RATE &&
- capable(CAP_SYS_RESOURCE) == 0)
+ if (arg > MAX_USER_PERIODIC_RATE && capable(CAP_SYS_RESOURCE) == 0)
return -EACCES;
periodic_frequency = arg;
@@ -361,205 +276,46 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, rtc_callfrom_t from
return 0;
}
-static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- return rtc_do_ioctl(cmd, arg, FUNCTION_RTC_IOCTL);
-}
-
-static int rtc_open(struct inode *inode, struct file *file)
-{
- spin_lock_irq(&rtc_lock);
-
- if (rtc_status == RTC_OPEN) {
- spin_unlock_irq(&rtc_lock);
- return -EBUSY;
- }
-
- rtc_status = RTC_OPEN;
- rtc_irq_data = 0;
-
- spin_unlock_irq(&rtc_lock);
-
- return 0;
-}
-
-static int rtc_release(struct inode *inode, struct file *file)
-{
- if (file->f_flags & FASYNC)
- (void)fasync_helper(-1, file, 0, &rtc_async_queue);
-
- spin_lock_irq(&rtc_lock);
-
- rtc1_write(ECMPLREG, 0);
- rtc1_write(ECMPMREG, 0);
- rtc1_write(ECMPHREG, 0);
- rtc1_write(RTCL1LREG, 0);
- rtc1_write(RTCL1HREG, 0);
-
- rtc_status = RTC_RELEASE;
-
- spin_unlock_irq(&rtc_lock);
-
- disable_irq(ELAPSEDTIME_IRQ);
- disable_irq(RTCLONG1_IRQ);
-
- return 0;
-}
-
-static int rtc_fasync(int fd, struct file *file, int on)
-{
- return fasync_helper(fd, file, on, &rtc_async_queue);
-}
-
-static struct file_operations rtc_fops = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .read = rtc_read,
- .poll = rtc_poll,
- .ioctl = rtc_ioctl,
- .open = rtc_open,
- .release = rtc_release,
- .fasync = rtc_fasync,
-};
-
static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- spin_lock(&rtc_lock);
- rtc2_write(RTCINTREG, ELAPSEDTIME_INT);
-
- rtc_irq_data += 0x100;
- rtc_irq_data &= ~0xff;
- rtc_irq_data |= RTC_AF;
- spin_unlock(&rtc_lock);
+ struct platform_device *pdev = (struct platform_device *)dev_id;
+ struct rtc_device *rtc = platform_get_drvdata(pdev);
- spin_lock(&rtc_lock);
- if (rtc_callback)
- rtc_callback->func(rtc_callback->private_data);
- spin_unlock(&rtc_lock);
-
- wake_up_interruptible(&rtc_wait);
+ rtc2_write(RTCINTREG, ELAPSEDTIME_INT);
- kill_fasync(&rtc_async_queue, SIGIO, POLL_IN);
+ rtc_update_irq(&rtc->class_dev, 1, RTC_AF);
return IRQ_HANDLED;
}
static irqreturn_t rtclong1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
+ struct platform_device *pdev = (struct platform_device *)dev_id;
+ struct rtc_device *rtc = platform_get_drvdata(pdev);
unsigned long count = periodic_count;
- spin_lock(&rtc_lock);
rtc2_write(RTCINTREG, RTCLONG1_INT);
rtc1_write(RTCL1LREG, count);
rtc1_write(RTCL1HREG, count >> 16);
- rtc_irq_data += 0x100;
- rtc_irq_data &= ~0xff;
- rtc_irq_data |= RTC_PF;
- spin_unlock(&rtc_lock);
-
- spin_lock(&rtc_task_lock);
- if (rtc_callback)
- rtc_callback->func(rtc_callback->private_data);
- spin_unlock(&rtc_task_lock);
-
- wake_up_interruptible(&rtc_wait);
-
- kill_fasync(&rtc_async_queue, SIGIO, POLL_IN);
+ rtc_update_irq(&rtc->class_dev, 1, RTC_PF);
return IRQ_HANDLED;
}
-int rtc_register(rtc_task_t *task)
-{
- if (task == NULL || task->func == NULL)
- return -EINVAL;
-
- spin_lock_irq(&rtc_lock);
- if (rtc_status == RTC_OPEN) {
- spin_unlock_irq(&rtc_lock);
- return -EBUSY;
- }
-
- spin_lock(&rtc_task_lock);
- if (rtc_callback != NULL) {
- spin_unlock(&rtc_task_lock);
- spin_unlock_irq(&rtc_task_lock);
- return -EBUSY;
- }
-
- rtc_callback = task;
- spin_unlock(&rtc_task_lock);
-
- rtc_status = RTC_OPEN;
-
- spin_unlock_irq(&rtc_lock);
-
- return 0;
-}
-
-EXPORT_SYMBOL_GPL(rtc_register);
-
-int rtc_unregister(rtc_task_t *task)
-{
- spin_lock_irq(&rtc_task_lock);
- if (task == NULL || rtc_callback != task) {
- spin_unlock_irq(&rtc_task_lock);
- return -ENXIO;
- }
-
- spin_lock(&rtc_lock);
-
- rtc1_write(ECMPLREG, 0);
- rtc1_write(ECMPMREG, 0);
- rtc1_write(ECMPHREG, 0);
- rtc1_write(RTCL1LREG, 0);
- rtc1_write(RTCL1HREG, 0);
-
- rtc_status = RTC_RELEASE;
-
- spin_unlock(&rtc_lock);
-
- rtc_callback = NULL;
-
- spin_unlock_irq(&rtc_task_lock);
-
- disable_irq(ELAPSEDTIME_IRQ);
- disable_irq(RTCLONG1_IRQ);
-
- return 0;
-}
-
-EXPORT_SYMBOL_GPL(rtc_unregister);
-
-int rtc_control(rtc_task_t *task, unsigned int cmd, unsigned long arg)
-{
- int retval = 0;
-
- spin_lock_irq(&rtc_task_lock);
-
- if (rtc_callback != task)
- retval = -ENXIO;
- else
- rtc_do_ioctl(cmd, arg, FUNCTION_RTC_CONTROL);
-
- spin_unlock_irq(&rtc_task_lock);
-
- return retval;
-}
-
-EXPORT_SYMBOL_GPL(rtc_control);
-
-static struct miscdevice rtc_miscdevice = {
- .minor = RTC_MINOR,
- .name = rtc_name,
- .fops = &rtc_fops,
+static struct rtc_class_ops vr41xx_rtc_ops = {
+ .release = vr41xx_rtc_release,
+ .ioctl = vr41xx_rtc_ioctl,
+ .read_time = vr41xx_rtc_read_time,
+ .set_time = vr41xx_rtc_set_time,
+ .read_alarm = vr41xx_rtc_read_alarm,
+ .set_alarm = vr41xx_rtc_set_alarm,
};
static int __devinit rtc_probe(struct platform_device *pdev)
{
+ struct rtc_device *rtc;
unsigned int irq;
int retval;
@@ -577,13 +333,13 @@ static int __devinit rtc_probe(struct platform_device *pdev)
return -EBUSY;
}
- retval = misc_register(&rtc_miscdevice);
- if (retval < 0) {
+ rtc = rtc_device_register(rtc_name, &pdev->dev, &vr41xx_rtc_ops, THIS_MODULE);
+ if (IS_ERR(rtc)) {
iounmap(rtc1_base);
iounmap(rtc2_base);
rtc1_base = NULL;
rtc2_base = NULL;
- return retval;
+ return PTR_ERR(rtc);
}
spin_lock_irq(&rtc_lock);
@@ -594,24 +350,20 @@ static int __devinit rtc_probe(struct platform_device *pdev)
rtc1_write(RTCL1LREG, 0);
rtc1_write(RTCL1HREG, 0);
- rtc_status = RTC_RELEASE;
- rtc_irq_data = 0;
-
spin_unlock_irq(&rtc_lock);
- init_waitqueue_head(&rtc_wait);
-
irq = ELAPSEDTIME_IRQ;
retval = request_irq(irq, elapsedtime_interrupt, SA_INTERRUPT,
- "elapsed_time", NULL);
+ "elapsed_time", pdev);
if (retval == 0) {
irq = RTCLONG1_IRQ;
retval = request_irq(irq, rtclong1_interrupt, SA_INTERRUPT,
- "rtclong1", NULL);
+ "rtclong1", pdev);
}
if (retval < 0) {
printk(KERN_ERR "rtc: IRQ%d is busy\n", irq);
+ rtc_device_unregister(rtc);
if (irq == RTCLONG1_IRQ)
free_irq(ELAPSEDTIME_IRQ, NULL);
iounmap(rtc1_base);
@@ -621,23 +373,25 @@ static int __devinit rtc_probe(struct platform_device *pdev)
return retval;
}
+ platform_set_drvdata(pdev, rtc);
+
disable_irq(ELAPSEDTIME_IRQ);
disable_irq(RTCLONG1_IRQ);
- spin_lock_init(&rtc_task_lock);
-
printk(KERN_INFO "rtc: Real Time Clock of NEC VR4100 series\n");
return 0;
}
-static int __devexit rtc_remove(struct platform_device *dev)
+static int __devexit rtc_remove(struct platform_device *pdev)
{
- int retval;
+ struct rtc_device *rtc;
- retval = misc_deregister(&rtc_miscdevice);
- if (retval < 0)
- return retval;
+ rtc = platform_get_drvdata(pdev);
+ if (rtc != NULL)
+ rtc_device_unregister(rtc);
+
+ platform_set_drvdata(pdev, NULL);
free_irq(ELAPSEDTIME_IRQ, NULL);
free_irq(RTCLONG1_IRQ, NULL);
@@ -651,7 +405,7 @@ static int __devexit rtc_remove(struct platform_device *dev)
static struct platform_device *rtc_platform_device;
-static struct platform_driver rtc_device_driver = {
+static struct platform_driver rtc_platform_driver = {
.probe = rtc_probe,
.remove = __devexit_p(rtc_remove),
.driver = {
@@ -686,7 +440,7 @@ static int __init vr41xx_rtc_init(void)
}
rtc_platform_device = platform_device_alloc("RTC", -1);
- if (!rtc_platform_device)
+ if (rtc_platform_device == NULL)
return -ENOMEM;
retval = platform_device_add_resources(rtc_platform_device,
@@ -700,7 +454,7 @@ static int __init vr41xx_rtc_init(void)
return retval;
}
- retval = platform_driver_register(&rtc_device_driver);
+ retval = platform_driver_register(&rtc_platform_driver);
if (retval < 0)
platform_device_unregister(rtc_platform_device);
@@ -709,7 +463,7 @@ static int __init vr41xx_rtc_init(void)
static void __exit vr41xx_rtc_exit(void)
{
- platform_driver_unregister(&rtc_device_driver);
+ platform_driver_unregister(&rtc_platform_driver);
platform_device_unregister(rtc_platform_device);
}
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index 621d17afc0d96..788b6d1f8f2fd 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -19,7 +19,7 @@
#include <linux/rtc.h>
#include <linux/delay.h>
-#define DRV_VERSION "1.0.6"
+#define DRV_VERSION "1.0.7"
/* Addresses to scan: none. This chip is located at
* 0x6f and uses a two bytes register addressing.
@@ -451,8 +451,6 @@ static int x1205_rtc_proc(struct device *dev, struct seq_file *seq)
{
int err, dtrim, atrim;
- seq_printf(seq, "24hr\t\t: yes\n");
-
if ((err = x1205_get_dtrim(to_i2c_client(dev), &dtrim)) == 0)
seq_printf(seq, "digital_trim\t: %d ppm\n", dtrim);
@@ -473,30 +471,31 @@ static struct rtc_class_ops x1205_rtc_ops = {
static ssize_t x1205_sysfs_show_atrim(struct device *dev,
struct device_attribute *attr, char *buf)
{
- int atrim;
+ int err, atrim;
- if (x1205_get_atrim(to_i2c_client(dev), &atrim) == 0)
- return sprintf(buf, "%d.%02d pF\n",
- atrim / 1000, atrim % 1000);
- return 0;
+ err = x1205_get_atrim(to_i2c_client(dev), &atrim);
+ if (err)
+ return err;
+
+ return sprintf(buf, "%d.%02d pF\n", atrim / 1000, atrim % 1000);
}
static DEVICE_ATTR(atrim, S_IRUGO, x1205_sysfs_show_atrim, NULL);
static ssize_t x1205_sysfs_show_dtrim(struct device *dev,
struct device_attribute *attr, char *buf)
{
- int dtrim;
+ int err, dtrim;
- if (x1205_get_dtrim(to_i2c_client(dev), &dtrim) == 0)
- return sprintf(buf, "%d ppm\n", dtrim);
+ err = x1205_get_dtrim(to_i2c_client(dev), &dtrim);
+ if (err)
+ return err;
- return 0;
+ return sprintf(buf, "%d ppm\n", dtrim);
}
static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL);
static int x1205_attach(struct i2c_adapter *adapter)
{
- dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
return i2c_probe(adapter, &addr_data, x1205_probe);
}
@@ -545,8 +544,6 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
- dev_err(&client->dev,
- "unable to register the class device\n");
goto exit_detach;
}
@@ -585,8 +582,6 @@ static int x1205_detach(struct i2c_client *client)
int err;
struct rtc_device *rtc = i2c_get_clientdata(client);
- dev_dbg(&client->dev, "%s\n", __FUNCTION__);
-
if (rtc)
rtc_device_unregister(rtc);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 0a9f12c4e9115..a3bfebcf31efe 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1257,25 +1257,28 @@ __dasd_start_head(struct dasd_device * device)
if (list_empty(&device->ccw_queue))
return;
cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
- /* check FAILFAST */
+ if (cqr->status != DASD_CQR_QUEUED)
+ return;
+ /* Non-temporary stop condition will trigger fail fast */
if (device->stopped & ~DASD_STOPPED_PENDING &&
test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
(!dasd_eer_enabled(device))) {
cqr->status = DASD_CQR_FAILED;
dasd_schedule_bh(device);
+ return;
}
- if ((cqr->status == DASD_CQR_QUEUED) &&
- (!device->stopped)) {
- /* try to start the first I/O that can be started */
- rc = device->discipline->start_IO(cqr);
- if (rc == 0)
- dasd_set_timer(device, cqr->expires);
- else if (rc == -EACCES) {
- dasd_schedule_bh(device);
- } else
- /* Hmpf, try again in 1/2 sec */
- dasd_set_timer(device, 50);
- }
+ /* Don't try to start requests if device is stopped */
+ if (device->stopped)
+ return;
+
+ rc = device->discipline->start_IO(cqr);
+ if (rc == 0)
+ dasd_set_timer(device, cqr->expires);
+ else if (rc == -EACCES) {
+ dasd_schedule_bh(device);
+ } else
+ /* Hmpf, try again in 1/2 sec */
+ dasd_set_timer(device, 50);
}
/*
@@ -1968,7 +1971,7 @@ int
dasd_generic_set_offline (struct ccw_device *cdev)
{
struct dasd_device *device;
- int max_count;
+ int max_count, open_count;
device = dasd_device_from_cdev(cdev);
if (IS_ERR(device))
@@ -1985,10 +1988,16 @@ dasd_generic_set_offline (struct ccw_device *cdev)
* in the other openers.
*/
max_count = device->bdev ? 0 : -1;
- if (atomic_read(&device->open_count) > max_count) {
- printk (KERN_WARNING "Can't offline dasd device with open"
- " count = %i.\n",
- atomic_read(&device->open_count));
+ open_count = (int) atomic_read(&device->open_count);
+ if (open_count > max_count) {
+ if (open_count > 0)
+ printk (KERN_WARNING "Can't offline dasd device with "
+ "open count = %i.\n",
+ open_count);
+ else
+ printk (KERN_WARNING "%s",
+ "Can't offline dasd device due to internal "
+ "use\n");
clear_bit(DASD_FLAG_OFFLINE, &device->flags);
dasd_put_device(device);
return -EBUSY;
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 1aa3c261718a6..ad23aede356c6 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -294,23 +294,40 @@ out_error:
#endif /* CONFIG_DASD_PROFILE */
}
+/*
+ * Create dasd proc-fs entries.
+ * In case creation failed, cleanup and return -ENOENT.
+ */
int
dasd_proc_init(void)
{
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 = 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);
+ if (!dasd_statistics_entry)
+ goto out_nostatistics;
dasd_statistics_entry->read_proc = dasd_statistics_read;
dasd_statistics_entry->write_proc = dasd_statistics_write;
dasd_statistics_entry->owner = THIS_MODULE;
return 0;
+
+ out_nostatistics:
+ remove_proc_entry("devices", dasd_proc_root_entry);
+ out_nodevices:
+ remove_proc_entry("dasd", &proc_root);
+ out_nodasd:
+ return -ENOENT;
}
void
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index 6badd84034094..d4d2ff0a9da20 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -54,7 +54,7 @@ kbd_alloc(void) {
if (!kbd)
goto out;
kbd->key_maps = kzalloc(sizeof(key_maps), GFP_KERNEL);
- if (!key_maps)
+ if (!kbd->key_maps)
goto out_kbd;
for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
if (key_maps[i]) {
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 5c65cf3e5cc02..b70d926902424 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -432,8 +432,8 @@ tapeblock_ioctl(
) {
int rc;
int minor;
- struct gendisk *disk = inode->i_bdev->bd_disk;
- struct tape_device *device = disk->private_data;
+ struct gendisk *disk;
+ struct tape_device *device;
rc = 0;
disk = inode->i_bdev->bd_disk;
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 389ee2c0f4435..e6e4086d3224b 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -210,18 +210,14 @@ tape_state_set(struct tape_device *device, enum tape_state newstate)
return;
}
DBF_EVENT(4, "ts. dev: %x\n", device->first_minor);
- if (device->tape_state < TO_SIZE && device->tape_state >= 0)
- str = tape_state_verbose[device->tape_state];
- else
- str = "UNKNOWN TS";
- DBF_EVENT(4, "old ts: %s\n", str);
- if (device->tape_state < TO_SIZE && device->tape_state >=0 )
+ DBF_EVENT(4, "old ts:\t\n");
+ if (device->tape_state < TS_SIZE && device->tape_state >=0 )
str = tape_state_verbose[device->tape_state];
else
str = "UNKNOWN TS";
DBF_EVENT(4, "%s\n", str);
DBF_EVENT(4, "new ts:\t\n");
- if (newstate < TO_SIZE && newstate >= 0)
+ if (newstate < TS_SIZE && newstate >= 0)
str = tape_state_verbose[newstate];
else
str = "UNKNOWN TS";
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index cb8e2e672b686..0960bef7b199c 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -414,11 +414,11 @@ cio_ignore_proc_init (void)
entry = create_proc_entry ("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR,
&proc_root);
if (!entry)
- return 0;
+ return -ENOENT;
entry->proc_fops = &cio_ignore_proc_fops;
- return 1;
+ return 0;
}
__initcall (cio_ignore_proc_init);
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index cbb86fa5f293b..5b20d8c9c0257 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -67,7 +67,7 @@ cio_debug_init (void)
goto out_unregister;
debug_register_view (cio_debug_msg_id, &debug_sprintf_view);
debug_set_level (cio_debug_msg_id, 2);
- cio_debug_trace_id = debug_register ("cio_trace", 16, 4, 8);
+ cio_debug_trace_id = debug_register ("cio_trace", 16, 4, 16);
if (!cio_debug_trace_id)
goto out_unregister;
debug_register_view (cio_debug_trace_id, &debug_hex_ascii_view);
diff --git a/drivers/s390/cio/cio_debug.h b/drivers/s390/cio/cio_debug.h
index 6af8b27d366b0..f88844adae1ba 100644
--- a/drivers/s390/cio/cio_debug.h
+++ b/drivers/s390/cio/cio_debug.h
@@ -3,6 +3,11 @@
#include <asm/debug.h>
+/* for use of debug feature */
+extern debug_info_t *cio_debug_msg_id;
+extern debug_info_t *cio_debug_trace_id;
+extern debug_info_t *cio_debug_crw_id;
+
#define CIO_TRACE_EVENT(imp, txt) do { \
debug_text_event(cio_debug_trace_id, imp, txt); \
} while (0)
@@ -15,18 +20,19 @@
debug_sprintf_event(cio_debug_crw_id, imp , ##args); \
} while (0)
-#define CIO_HEX_EVENT(imp, args...) do { \
- debug_event(cio_debug_trace_id, imp, ##args); \
- } while (0)
+static inline void
+CIO_HEX_EVENT(int level, void *data, int length)
+{
+ while (length > 0) {
+ debug_event(cio_debug_trace_id, level, data, length);
+ length -= cio_debug_trace_id->buf_size;
+ data += cio_debug_trace_id->buf_size;
+ }
+}
#define CIO_DEBUG(printk_level,event_level,msg...) ({ \
if (cio_show_msg) printk(printk_level msg); \
CIO_MSG_EVENT (event_level, msg); \
})
-/* for use of debug feature */
-extern debug_info_t *cio_debug_msg_id;
-extern debug_info_t *cio_debug_trace_id;
-extern debug_info_t *cio_debug_crw_id;
-
#endif
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 25f678d0780b2..e8e41e6eb42a9 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1508,10 +1508,12 @@ static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id,
struct scsi_cmnd *cmd = tw_dev->srb[request_id];
void *buf;
unsigned int transfer_len;
+ unsigned long flags = 0;
if (cmd->use_sg) {
struct scatterlist *sg =
(struct scatterlist *)cmd->request_buffer;
+ local_irq_save(flags);
buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
transfer_len = min(sg->length, len);
} else {
@@ -1526,6 +1528,7 @@ static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id,
sg = (struct scatterlist *)cmd->request_buffer;
kunmap_atomic(buf - sg->offset, KM_IRQ0);
+ local_irq_restore(flags);
}
}
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 1bd82c4e52a0d..b4f8fb1d628b9 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -207,7 +207,6 @@ static struct scsi_host_template ahci_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = AHCI_MAX_SG,
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 24e71b5551722..6dc88149f9f15 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -209,7 +209,6 @@ static struct scsi_host_template piix_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index ef57f253031c6..dfcb96f3e60ce 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -294,18 +294,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
if (sht->unchecked_isa_dma && privsize)
gfp_mask |= __GFP_DMA;
- /* Check to see if this host has any error handling facilities */
- if (!sht->eh_strategy_handler && !sht->eh_abort_handler &&
- !sht->eh_device_reset_handler && !sht->eh_bus_reset_handler &&
- !sht->eh_host_reset_handler) {
- printk(KERN_ERR "ERROR: SCSI host `%s' has no error handling\n"
- "ERROR: This is not a safe way to run your "
- "SCSI host\n"
- "ERROR: The error handling must be added to "
- "this driver\n", sht->proc_name);
- dump_stack();
- }
-
shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
if (!shost)
return NULL;
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index e63c1ff1e1025..bd147207f25d4 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -4938,7 +4938,6 @@ EXPORT_SYMBOL_GPL(ata_busy_sleep);
EXPORT_SYMBOL_GPL(ata_port_queue_task);
EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
-EXPORT_SYMBOL_GPL(ata_scsi_error);
EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
EXPORT_SYMBOL_GPL(ata_scsi_release);
EXPORT_SYMBOL_GPL(ata_host_intr);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 53f5b0d9161c0..a0289ec3e283b 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -53,6 +53,7 @@
typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
static struct ata_device *
ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);
+static void ata_scsi_error(struct Scsi_Host *host);
enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
#define RW_RECOVERY_MPAGE 0x1
@@ -99,6 +100,7 @@ static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = {
* It just needs the eh_timed_out hook.
*/
struct scsi_transport_template ata_scsi_transport_template = {
+ .eh_strategy_handler = ata_scsi_error,
.eh_timed_out = ata_scsi_timed_out,
};
@@ -772,12 +774,9 @@ enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
*
* LOCKING:
* Inherited from SCSI layer (none, can sleep)
- *
- * RETURNS:
- * Zero.
*/
-int ata_scsi_error(struct Scsi_Host *host)
+static void ata_scsi_error(struct Scsi_Host *host)
{
struct ata_port *ap;
unsigned long flags;
@@ -805,7 +804,6 @@ int ata_scsi_error(struct Scsi_Host *host)
spin_unlock_irqrestore(&ap->host_set->lock, flags);
DPRINTK("EXIT\n");
- return 0;
}
static void ata_eh_scsidone(struct scsi_cmnd *scmd)
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 1c755b14521a9..bac8cbae06fe9 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -60,7 +60,6 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
extern struct scsi_transport_template ata_scsi_transport_template;
extern void ata_scsi_scan_host(struct ata_port *ap);
-extern int ata_scsi_error(struct Scsi_Host *host);
extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
unsigned int buflen);
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 3c85c4b66e195..5cda16cfacb03 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -143,7 +143,6 @@ static struct scsi_host_template adma_ata_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index fa901fd650856..d5fdcb9a88425 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -378,7 +378,6 @@ static struct scsi_host_template mv_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = MV_USE_Q_DEPTH,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = MV_MAX_SG_CT / 2,
@@ -748,7 +747,7 @@ static void mv_dump_all_regs(void __iomem *mmio_base, int port,
mv_dump_mem(mmio_base+0xf00, 0x4);
mv_dump_mem(mmio_base+0x1d00, 0x6c);
for (hc = start_hc; hc < start_hc + num_hcs; hc++) {
- hc_base = mv_hc_base(mmio_base, port >> MV_PORT_HC_SHIFT);
+ hc_base = mv_hc_base(mmio_base, hc);
DPRINTK("HC regs (HC %i):\n", hc);
mv_dump_mem(hc_base, 0x1c);
}
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index f77bf183dfab8..9f553081b5e83 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -201,7 +201,6 @@ static struct scsi_host_template nv_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index cc928c68a4790..7eb67a6bdc64c 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -111,7 +111,6 @@ static struct scsi_host_template pdc_ata_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index 9ffe1ef0d2051..886f3447dd48b 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -132,7 +132,6 @@ static struct scsi_host_template qs_ata_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = QS_MAX_PRD,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 18c296c568991..106627299d55f 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -146,7 +146,6 @@ static struct scsi_host_template sil_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 068c98a4111bc..f7264fd611c22 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -281,7 +281,6 @@ static struct scsi_host_template sil24_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index acc8439dea233..728530df2e075 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -87,7 +87,6 @@ static struct scsi_host_template sis_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = ATA_MAX_PRD,
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 724f0ed6a52d2..53b0d5c0a61f4 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -290,7 +290,6 @@ static struct scsi_host_template k2_sata_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index ae70f60c7c0d0..4139ad4b1df06 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -182,7 +182,6 @@ static struct scsi_host_template pdc_sata_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 7ac5a5f5a9050..38b52bd3fa3f1 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -81,7 +81,6 @@ static struct scsi_host_template uli_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 791bf652ba632..9e7ae4e0db324 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -94,7 +94,6 @@ static struct scsi_host_template svia_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 836bbbb26ff2c..8a29ce340b472 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -263,7 +263,6 @@ static struct scsi_host_template vsc_sata_sht = {
.name = DRV_NAME,
.ioctl = ata_scsi_ioctl,
.queuecommand = ata_scsi_queuecmd,
- .eh_strategy_handler = ata_scsi_error,
.can_queue = ATA_DEF_QUEUE,
.this_id = ATA_SHT_THIS_ID,
.sg_tablesize = LIBATA_MAX_PRD,
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 5f0fdfb2618ca..1c75646f9689d 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1537,8 +1537,8 @@ int scsi_error_handler(void *data)
* what we need to do to get it up and online again (if we can).
* If we fail, we end up taking the thing offline.
*/
- if (shost->hostt->eh_strategy_handler)
- shost->hostt->eh_strategy_handler(shost);
+ if (shost->transportt->eh_strategy_handler)
+ shost->transportt->eh_strategy_handler(shost);
else
scsi_unjam_host(shost);
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c
index 93449a1a0065f..0b49ff78efc12 100644
--- a/drivers/sn/ioc3.c
+++ b/drivers/sn/ioc3.c
@@ -11,6 +11,7 @@
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
@@ -619,9 +620,9 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
pci_set_master(pdev);
#ifdef USE_64BIT_DMA
- ret = pci_set_dma_mask(pdev, 0xffffffffffffffffULL);
+ ret = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
if (!ret) {
- ret = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL);
+ ret = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
if (ret < 0) {
printk(KERN_WARNING "%s: Unable to obtain 64 bit DMA "
"for consistent allocations\n",
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 495db5755df9e..5cf2b80add7aa 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -28,6 +28,7 @@
2005-09-10 v0.4.3 added HUAWEI E600 card and Audiovox AirCard
2005-09-20 v0.4.4 increased recv buffer size: the card sometimes
wants to send >2000 bytes.
+ 2006-04-10 v0.4.2 fixed two array overrun errors :-/
Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
@@ -582,14 +583,14 @@ static void option_setup_urbs(struct usb_serial *serial)
portdata = usb_get_serial_port_data(port);
/* Do indat endpoints first */
- for (j = 0; j <= N_IN_URB; ++j) {
+ for (j = 0; j < N_IN_URB; ++j) {
portdata->in_urbs[j] = option_setup_urb (serial,
port->bulk_in_endpointAddress, USB_DIR_IN, port,
portdata->in_buffer[j], IN_BUFLEN, option_indat_callback);
}
/* outdat endpoints */
- for (j = 0; j <= N_OUT_URB; ++j) {
+ for (j = 0; j < N_OUT_URB; ++j) {
portdata->out_urbs[j] = option_setup_urb (serial,
port->bulk_out_endpointAddress, USB_DIR_OUT, port,
portdata->out_buffer[j], OUT_BUFLEN, option_outdat_callback);
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index f87c0171f4eca..9060e71374411 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -961,7 +961,7 @@ config FB_ATY128
config FB_ATY
tristate "ATI Mach64 display support" if PCI || ATARI
- depends on FB
+ depends on FB && !SPARC32
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index b39e72d5413b6..d9d7d3c4cae2e 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -3400,7 +3400,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi
struct atyfb_par *par;
int i, rc = -ENOMEM;
- for (i = ARRAY_SIZE(aty_chips); i >= 0; i--)
+ for (i = ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
if (pdev->device == aty_chips[i].pci_id)
break;
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 944855b3e4afe..8d8eadb648530 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -435,6 +435,11 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
depth = info->var.green.length;
}
+ if (info->fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR) {
+ /* assume console colormap */
+ depth = 4;
+ }
+
if (depth >= 8) {
switch (info->fix.visual) {
case FB_VISUAL_TRUECOLOR:
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 8982e540214c5..b0b9acfdd430e 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -57,7 +57,7 @@ static unsigned short *pmi_base = NULL;
static void (*pmi_start)(void);
static void (*pmi_pal)(void);
static int depth;
-
+static int vga_compat;
/* --------------------------------------------------------------------- */
static int vesafb_pan_display(struct fb_var_screeninfo *var,
@@ -83,9 +83,10 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var,
static void vesa_setpalette(int regno, unsigned red, unsigned green,
unsigned blue)
{
+ int shift = 16 - depth;
+
#ifdef __i386__
struct { u_char blue, green, red, pad; } entry;
- int shift = 16 - depth;
if (pmi_setpal) {
entry.red = red >> shift;
@@ -101,14 +102,20 @@ static void vesa_setpalette(int regno, unsigned red, unsigned green,
"d" (regno), /* EDX */
"D" (&entry), /* EDI */
"S" (&pmi_pal)); /* ESI */
- } else {
- /* without protected mode interface, try VGA registers... */
+ return;
+ }
+#endif
+
+/*
+ * without protected mode interface and if VGA compatible,
+ * try VGA registers...
+ */
+ if (vga_compat) {
outb_p(regno, dac_reg);
outb_p(red >> shift, dac_val);
outb_p(green >> shift, dac_val);
outb_p(blue >> shift, dac_val);
}
-#endif
}
static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
@@ -214,6 +221,7 @@ static int __init vesafb_probe(struct platform_device *dev)
if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
return -ENODEV;
+ vga_compat = (screen_info.capabilities & 2) ? 0 : 1;
vesafb_fix.smem_start = screen_info.lfb_base;
vesafb_defined.bits_per_pixel = screen_info.lfb_depth;
if (15 == vesafb_defined.bits_per_pixel)
@@ -318,6 +326,12 @@ static int __init vesafb_probe(struct platform_device *dev)
}
}
+ if (vesafb_defined.bits_per_pixel == 8 && !pmi_setpal && !vga_compat) {
+ printk(KERN_WARNING "vesafb: hardware palette is unchangeable,\n"
+ " colors may be incorrect\n");
+ vesafb_fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
+ }
+
vesafb_defined.xres_virtual = vesafb_defined.xres;
vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length;
if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) {
@@ -354,7 +368,8 @@ static int __init vesafb_probe(struct platform_device *dev)
printk(KERN_INFO "vesafb: %s: "
"size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
(vesafb_defined.bits_per_pixel > 8) ?
- "Truecolor" : "Pseudocolor",
+ "Truecolor" : (vga_compat || pmi_setpal) ?
+ "Pseudocolor" : "Static Pseudocolor",
screen_info.rsvd_size,
screen_info.red_size,
screen_info.green_size,
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index b0a0ae509c005..61c599b4a1e32 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -127,12 +127,13 @@ static struct super_block *v9fs_get_sb(struct file_system_type
if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) {
dprintk(DEBUG_ERROR, "problem initiating session\n");
- kfree(v9ses);
- return ERR_PTR(newfid);
+ sb = ERR_PTR(newfid);
+ goto out_free_session;
}
sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
-
+ if (IS_ERR(sb))
+ goto out_close_session;
v9fs_fill_super(sb, v9ses, flags);
inode = v9fs_get_inode(sb, S_IFDIR | mode);
@@ -185,6 +186,12 @@ static struct super_block *v9fs_get_sb(struct file_system_type
return sb;
+out_close_session:
+ v9fs_session_close(v9ses);
+out_free_session:
+ kfree(v9ses);
+ return sb;
+
put_back_sb:
/* deactivate_super calls v9fs_kill_super which will frees the rest */
up_write(&sb->s_umount);
diff --git a/fs/Kconfig b/fs/Kconfig
index e207be68d4cad..2524629dc8350 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -799,6 +799,7 @@ config PROC_KCORE
config PROC_VMCORE
bool "/proc/vmcore support (EXPERIMENTAL)"
depends on PROC_FS && EXPERIMENTAL && CRASH_DUMP
+ default y
help
Exports the dump image of crashed kernel in ELF format.
@@ -861,7 +862,7 @@ config RAMFS
config CONFIGFS_FS
tristate "Userspace-driven configuration filesystem (EXPERIMENTAL)"
- depends on EXPERIMENTAL
+ depends on SYSFS && EXPERIMENTAL
help
configfs is a ram-based filesystem that provides the converse
of sysfs's functionality. Where sysfs is a filesystem-based
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 8ed9b06a98283..5638c8f9362f9 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -504,7 +504,7 @@ static int populate_groups(struct config_group *group)
int ret = 0;
int i;
- if (group && group->default_groups) {
+ if (group->default_groups) {
/* FYI, we're faking mkdir here
* I'm not sure we need this semaphore, as we're called
* from our parent's mkdir. That holds our parent's
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 242fe1a66ce57..1b4491cdd1158 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -599,7 +599,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
switch (op) {
case EPOLL_CTL_ADD:
if (!epi) {
- epds.events |= POLLERR | POLLHUP | POLLRDHUP;
+ epds.events |= POLLERR | POLLHUP;
error = ep_insert(ep, &epds, tfile, fd);
} else
@@ -613,7 +613,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
break;
case EPOLL_CTL_MOD:
if (epi) {
- epds.events |= POLLERR | POLLHUP | POLLRDHUP;
+ epds.events |= POLLERR | POLLHUP;
error = ep_modify(ep, epi, &epds);
} else
error = -ENOENT;
diff --git a/fs/exec.c b/fs/exec.c
index 0291a68a36261..3234a0c32d540 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -678,6 +678,18 @@ static int de_thread(struct task_struct *tsk)
while (leader->exit_state != EXIT_ZOMBIE)
yield();
+ /*
+ * The only record we have of the real-time age of a
+ * process, regardless of execs it's done, is start_time.
+ * All the past CPU time is accumulated in signal_struct
+ * from sister threads now dead. But in this non-leader
+ * exec, nothing survives from the original leader thread,
+ * whose birth marks the true age of this process now.
+ * When we take on its identity by switching to its PID, we
+ * also take its birthdate (always earlier than our own).
+ */
+ current->start_time = leader->start_time;
+
spin_lock(&leader->proc_lock);
spin_lock(&current->proc_lock);
proc_dentry1 = proc_pid_unhash(current);
@@ -723,7 +735,12 @@ static int de_thread(struct task_struct *tsk)
current->parent = current->real_parent = leader->real_parent;
leader->parent = leader->real_parent = child_reaper;
current->group_leader = current;
- leader->group_leader = leader;
+ leader->group_leader = current;
+
+ /* Reduce leader to a thread */
+ detach_pid(leader, PIDTYPE_PGID);
+ detach_pid(leader, PIDTYPE_SID);
+ list_del_init(&leader->tasks);
add_parent(current);
add_parent(leader);
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 1041dab6de2fd..14f5f6ea3e723 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -974,6 +974,7 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
ext3_warning(sb, __FUNCTION__,
"multiple resizers run on filesystem!");
+ unlock_super(sb);
err = -EBUSY;
goto exit_put;
}
diff --git a/fs/fifo.c b/fs/fifo.c
index 889f722ee36d6..49035b174b48a 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -15,30 +15,35 @@
#include <linux/fs.h>
#include <linux/pipe_fs_i.h>
-static void wait_for_partner(struct inode* inode, unsigned int* cnt)
+static void wait_for_partner(struct inode* inode, unsigned int *cnt)
{
int cur = *cnt;
- while(cur == *cnt) {
- pipe_wait(inode);
- if(signal_pending(current))
+
+ while (cur == *cnt) {
+ pipe_wait(inode->i_pipe);
+ if (signal_pending(current))
break;
}
}
static void wake_up_partner(struct inode* inode)
{
- wake_up_interruptible(PIPE_WAIT(*inode));
+ wake_up_interruptible(&inode->i_pipe->wait);
}
static int fifo_open(struct inode *inode, struct file *filp)
{
+ struct pipe_inode_info *pipe;
int ret;
- mutex_lock(PIPE_MUTEX(*inode));
- if (!inode->i_pipe) {
+ mutex_lock(&inode->i_mutex);
+ pipe = inode->i_pipe;
+ if (!pipe) {
ret = -ENOMEM;
- if(!pipe_new(inode))
+ pipe = alloc_pipe_info(inode);
+ if (!pipe)
goto err_nocleanup;
+ inode->i_pipe = pipe;
}
filp->f_version = 0;
@@ -53,18 +58,18 @@ static int fifo_open(struct inode *inode, struct file *filp)
* opened, even when there is no process writing the FIFO.
*/
filp->f_op = &read_fifo_fops;
- PIPE_RCOUNTER(*inode)++;
- if (PIPE_READERS(*inode)++ == 0)
+ pipe->r_counter++;
+ if (pipe->readers++ == 0)
wake_up_partner(inode);
- if (!PIPE_WRITERS(*inode)) {
+ if (!pipe->writers) {
if ((filp->f_flags & O_NONBLOCK)) {
/* suppress POLLHUP until we have
* seen a writer */
- filp->f_version = PIPE_WCOUNTER(*inode);
+ filp->f_version = pipe->w_counter;
} else
{
- wait_for_partner(inode, &PIPE_WCOUNTER(*inode));
+ wait_for_partner(inode, &pipe->w_counter);
if(signal_pending(current))
goto err_rd;
}
@@ -78,16 +83,16 @@ static int fifo_open(struct inode *inode, struct file *filp)
* errno=ENXIO when there is no process reading the FIFO.
*/
ret = -ENXIO;
- if ((filp->f_flags & O_NONBLOCK) && !PIPE_READERS(*inode))
+ if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
goto err;
filp->f_op = &write_fifo_fops;
- PIPE_WCOUNTER(*inode)++;
- if (!PIPE_WRITERS(*inode)++)
+ pipe->w_counter++;
+ if (!pipe->writers++)
wake_up_partner(inode);
- if (!PIPE_READERS(*inode)) {
- wait_for_partner(inode, &PIPE_RCOUNTER(*inode));
+ if (!pipe->readers) {
+ wait_for_partner(inode, &pipe->r_counter);
if (signal_pending(current))
goto err_wr;
}
@@ -102,11 +107,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
*/
filp->f_op = &rdwr_fifo_fops;
- PIPE_READERS(*inode)++;
- PIPE_WRITERS(*inode)++;
- PIPE_RCOUNTER(*inode)++;
- PIPE_WCOUNTER(*inode)++;
- if (PIPE_READERS(*inode) == 1 || PIPE_WRITERS(*inode) == 1)
+ pipe->readers++;
+ pipe->writers++;
+ pipe->r_counter++;
+ pipe->w_counter++;
+ if (pipe->readers == 1 || pipe->writers == 1)
wake_up_partner(inode);
break;
@@ -116,27 +121,27 @@ static int fifo_open(struct inode *inode, struct file *filp)
}
/* Ok! */
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_unlock(&inode->i_mutex);
return 0;
err_rd:
- if (!--PIPE_READERS(*inode))
- wake_up_interruptible(PIPE_WAIT(*inode));
+ if (!--pipe->readers)
+ wake_up_interruptible(&pipe->wait);
ret = -ERESTARTSYS;
goto err;
err_wr:
- if (!--PIPE_WRITERS(*inode))
- wake_up_interruptible(PIPE_WAIT(*inode));
+ if (!--pipe->writers)
+ wake_up_interruptible(&pipe->wait);
ret = -ERESTARTSYS;
goto err;
err:
- if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode))
+ if (!pipe->readers && !pipe->writers)
free_pipe_info(inode);
err_nocleanup:
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_unlock(&inode->i_mutex);
return ret;
}
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 23d1f52eb1b8d..6c740f860665f 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1,6 +1,6 @@
/*
FUSE: Filesystem in Userspace
- Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
+ Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
@@ -23,13 +23,11 @@ static kmem_cache_t *fuse_req_cachep;
static struct fuse_conn *fuse_get_conn(struct file *file)
{
- struct fuse_conn *fc;
- spin_lock(&fuse_lock);
- fc = file->private_data;
- if (fc && !fc->connected)
- fc = NULL;
- spin_unlock(&fuse_lock);
- return fc;
+ /*
+ * Lockless access is OK, because file->private data is set
+ * once during mount and is valid until the file is released.
+ */
+ return file->private_data;
}
static void fuse_request_init(struct fuse_req *req)
@@ -74,10 +72,8 @@ static void restore_sigs(sigset_t *oldset)
*/
void fuse_reset_request(struct fuse_req *req)
{
- int preallocated = req->preallocated;
BUG_ON(atomic_read(&req->count) != 1);
fuse_request_init(req);
- req->preallocated = preallocated;
}
static void __fuse_get_request(struct fuse_req *req)
@@ -92,80 +88,52 @@ static void __fuse_put_request(struct fuse_req *req)
atomic_dec(&req->count);
}
-static struct fuse_req *do_get_request(struct fuse_conn *fc)
+struct fuse_req *fuse_get_req(struct fuse_conn *fc)
{
struct fuse_req *req;
-
- spin_lock(&fuse_lock);
- BUG_ON(list_empty(&fc->unused_list));
- req = list_entry(fc->unused_list.next, struct fuse_req, list);
- list_del_init(&req->list);
- spin_unlock(&fuse_lock);
- fuse_request_init(req);
- req->preallocated = 1;
- req->in.h.uid = current->fsuid;
- req->in.h.gid = current->fsgid;
- req->in.h.pid = current->pid;
- return req;
-}
-
-/* This can return NULL, but only in case it's interrupted by a SIGKILL */
-struct fuse_req *fuse_get_request(struct fuse_conn *fc)
-{
- int intr;
sigset_t oldset;
+ int err;
- atomic_inc(&fc->num_waiting);
block_sigs(&oldset);
- intr = down_interruptible(&fc->outstanding_sem);
+ err = wait_event_interruptible(fc->blocked_waitq, !fc->blocked);
restore_sigs(&oldset);
- if (intr) {
- atomic_dec(&fc->num_waiting);
- return NULL;
- }
- return do_get_request(fc);
-}
+ if (err)
+ return ERR_PTR(-EINTR);
-/* Must be called with fuse_lock held */
-static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req)
-{
- if (req->preallocated) {
- atomic_dec(&fc->num_waiting);
- list_add(&req->list, &fc->unused_list);
- } else
- fuse_request_free(req);
+ req = fuse_request_alloc();
+ if (!req)
+ return ERR_PTR(-ENOMEM);
- /* If we are in debt decrease that first */
- if (fc->outstanding_debt)
- fc->outstanding_debt--;
- else
- up(&fc->outstanding_sem);
+ atomic_inc(&fc->num_waiting);
+ fuse_request_init(req);
+ req->in.h.uid = current->fsuid;
+ req->in.h.gid = current->fsgid;
+ req->in.h.pid = current->pid;
+ return req;
}
void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req)
{
if (atomic_dec_and_test(&req->count)) {
- spin_lock(&fuse_lock);
- fuse_putback_request(fc, req);
- spin_unlock(&fuse_lock);
+ atomic_dec(&fc->num_waiting);
+ fuse_request_free(req);
}
}
-static void fuse_put_request_locked(struct fuse_conn *fc, struct fuse_req *req)
-{
- if (atomic_dec_and_test(&req->count))
- fuse_putback_request(fc, req);
-}
-
-void fuse_release_background(struct fuse_req *req)
+void fuse_release_background(struct fuse_conn *fc, struct fuse_req *req)
{
iput(req->inode);
iput(req->inode2);
if (req->file)
fput(req->file);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
list_del(&req->bg_entry);
- spin_unlock(&fuse_lock);
+ if (fc->num_background == FUSE_MAX_BACKGROUND) {
+ fc->blocked = 0;
+ wake_up_all(&fc->blocked_waitq);
+ }
+ fc->num_background--;
+ spin_unlock(&fc->lock);
}
/*
@@ -184,23 +152,23 @@ void fuse_release_background(struct fuse_req *req)
* interrupted and put in the background, it will return with an error
* and hence never be reset and reused.
*
- * Called with fuse_lock, unlocks it
+ * Called with fc->lock, unlocks it
*/
static void request_end(struct fuse_conn *fc, struct fuse_req *req)
{
list_del(&req->list);
req->state = FUSE_REQ_FINISHED;
if (!req->background) {
+ spin_unlock(&fc->lock);
wake_up(&req->waitq);
- fuse_put_request_locked(fc, req);
- spin_unlock(&fuse_lock);
+ fuse_put_request(fc, req);
} else {
void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;
req->end = NULL;
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
down_read(&fc->sbput_sem);
if (fc->mounted)
- fuse_release_background(req);
+ fuse_release_background(fc, req);
up_read(&fc->sbput_sem);
if (end)
end(fc, req);
@@ -242,6 +210,9 @@ static void background_request(struct fuse_conn *fc, struct fuse_req *req)
{
req->background = 1;
list_add(&req->bg_entry, &fc->background);
+ fc->num_background++;
+ if (fc->num_background == FUSE_MAX_BACKGROUND)
+ fc->blocked = 1;
if (req->inode)
req->inode = igrab(req->inode);
if (req->inode2)
@@ -250,16 +221,16 @@ static void background_request(struct fuse_conn *fc, struct fuse_req *req)
get_file(req->file);
}
-/* Called with fuse_lock held. Releases, and then reacquires it. */
+/* Called with fc->lock held. Releases, and then reacquires it. */
static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
{
sigset_t oldset;
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
block_sigs(&oldset);
wait_event_interruptible(req->waitq, req->state == FUSE_REQ_FINISHED);
restore_sigs(&oldset);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
if (req->state == FUSE_REQ_FINISHED && !req->interrupted)
return;
@@ -273,9 +244,9 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
locked state, there mustn't be any filesystem
operation (e.g. page fault), since that could lead
to deadlock */
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
wait_event(req->waitq, !req->locked);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
}
if (req->state == FUSE_REQ_PENDING) {
list_del(&req->list);
@@ -304,19 +275,10 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
req->in.h.unique = fc->reqctr;
req->in.h.len = sizeof(struct fuse_in_header) +
len_args(req->in.numargs, (struct fuse_arg *) req->in.args);
- if (!req->preallocated) {
- /* If request is not preallocated (either FORGET or
- RELEASE), then still decrease outstanding_sem, so
- user can't open infinite number of files while not
- processing the RELEASE requests. However for
- efficiency do it without blocking, so if down()
- would block, just increase the debt instead */
- if (down_trylock(&fc->outstanding_sem))
- fc->outstanding_debt++;
- }
list_add_tail(&req->list, &fc->pending);
req->state = FUSE_REQ_PENDING;
wake_up(&fc->waitq);
+ kill_fasync(&fc->fasync, SIGIO, POLL_IN);
}
/*
@@ -325,7 +287,7 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
void request_send(struct fuse_conn *fc, struct fuse_req *req)
{
req->isreply = 1;
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
if (!fc->connected)
req->out.h.error = -ENOTCONN;
else if (fc->conn_error)
@@ -338,15 +300,16 @@ void request_send(struct fuse_conn *fc, struct fuse_req *req)
request_wait_answer(fc, req);
}
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
}
static void request_send_nowait(struct fuse_conn *fc, struct fuse_req *req)
{
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
+ background_request(fc, req);
if (fc->connected) {
queue_request(fc, req);
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
} else {
req->out.h.error = -ENOTCONN;
request_end(fc, req);
@@ -362,9 +325,6 @@ void request_send_noreply(struct fuse_conn *fc, struct fuse_req *req)
void request_send_background(struct fuse_conn *fc, struct fuse_req *req)
{
req->isreply = 1;
- spin_lock(&fuse_lock);
- background_request(fc, req);
- spin_unlock(&fuse_lock);
request_send_nowait(fc, req);
}
@@ -373,16 +333,16 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req)
* anything that could cause a page-fault. If the request was already
* interrupted bail out.
*/
-static int lock_request(struct fuse_req *req)
+static int lock_request(struct fuse_conn *fc, struct fuse_req *req)
{
int err = 0;
if (req) {
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
if (req->interrupted)
err = -ENOENT;
else
req->locked = 1;
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
}
return err;
}
@@ -392,18 +352,19 @@ static int lock_request(struct fuse_req *req)
* requester thread is currently waiting for it to be unlocked, so
* wake it up.
*/
-static void unlock_request(struct fuse_req *req)
+static void unlock_request(struct fuse_conn *fc, struct fuse_req *req)
{
if (req) {
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
req->locked = 0;
if (req->interrupted)
wake_up(&req->waitq);
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
}
}
struct fuse_copy_state {
+ struct fuse_conn *fc;
int write;
struct fuse_req *req;
const struct iovec *iov;
@@ -416,11 +377,12 @@ struct fuse_copy_state {
unsigned len;
};
-static void fuse_copy_init(struct fuse_copy_state *cs, int write,
- struct fuse_req *req, const struct iovec *iov,
- unsigned long nr_segs)
+static void fuse_copy_init(struct fuse_copy_state *cs, struct fuse_conn *fc,
+ int write, struct fuse_req *req,
+ const struct iovec *iov, unsigned long nr_segs)
{
memset(cs, 0, sizeof(*cs));
+ cs->fc = fc;
cs->write = write;
cs->req = req;
cs->iov = iov;
@@ -450,7 +412,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
unsigned long offset;
int err;
- unlock_request(cs->req);
+ unlock_request(cs->fc, cs->req);
fuse_copy_finish(cs);
if (!cs->seglen) {
BUG_ON(!cs->nr_segs);
@@ -473,7 +435,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
cs->seglen -= cs->len;
cs->addr += cs->len;
- return lock_request(cs->req);
+ return lock_request(cs->fc, cs->req);
}
/* Do as much copy to/from userspace buffer as we can */
@@ -585,9 +547,9 @@ static void request_wait(struct fuse_conn *fc)
if (signal_pending(current))
break;
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
schedule();
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&fc->waitq, &wait);
@@ -606,18 +568,21 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
unsigned long nr_segs, loff_t *off)
{
int err;
- struct fuse_conn *fc;
struct fuse_req *req;
struct fuse_in *in;
struct fuse_copy_state cs;
unsigned reqsize;
+ struct fuse_conn *fc = fuse_get_conn(file);
+ if (!fc)
+ return -EPERM;
restart:
- spin_lock(&fuse_lock);
- fc = file->private_data;
- err = -EPERM;
- if (!fc)
+ spin_lock(&fc->lock);
+ err = -EAGAIN;
+ if ((file->f_flags & O_NONBLOCK) && fc->connected &&
+ list_empty(&fc->pending))
goto err_unlock;
+
request_wait(fc);
err = -ENODEV;
if (!fc->connected)
@@ -641,14 +606,14 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
request_end(fc, req);
goto restart;
}
- spin_unlock(&fuse_lock);
- fuse_copy_init(&cs, 1, req, iov, nr_segs);
+ spin_unlock(&fc->lock);
+ fuse_copy_init(&cs, fc, 1, req, iov, nr_segs);
err = fuse_copy_one(&cs, &in->h, sizeof(in->h));
if (!err)
err = fuse_copy_args(&cs, in->numargs, in->argpages,
(struct fuse_arg *) in->args, 0);
fuse_copy_finish(&cs);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
req->locked = 0;
if (!err && req->interrupted)
err = -ENOENT;
@@ -663,12 +628,12 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
else {
req->state = FUSE_REQ_SENT;
list_move_tail(&req->list, &fc->processing);
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
}
return reqsize;
err_unlock:
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
return err;
}
@@ -735,9 +700,9 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
struct fuse_copy_state cs;
struct fuse_conn *fc = fuse_get_conn(file);
if (!fc)
- return -ENODEV;
+ return -EPERM;
- fuse_copy_init(&cs, 0, NULL, iov, nr_segs);
+ fuse_copy_init(&cs, fc, 0, NULL, iov, nr_segs);
if (nbytes < sizeof(struct fuse_out_header))
return -EINVAL;
@@ -749,7 +714,7 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
oh.len != nbytes)
goto err_finish;
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
err = -ENOENT;
if (!fc->connected)
goto err_unlock;
@@ -760,9 +725,9 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
goto err_unlock;
if (req->interrupted) {
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
fuse_copy_finish(&cs);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
request_end(fc, req);
return -ENOENT;
}
@@ -770,12 +735,12 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
req->out.h = oh;
req->locked = 1;
cs.req = req;
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
err = copy_out_args(&cs, &req->out, nbytes);
fuse_copy_finish(&cs);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
req->locked = 0;
if (!err) {
if (req->interrupted)
@@ -787,7 +752,7 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
return err ? err : nbytes;
err_unlock:
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
err_finish:
fuse_copy_finish(&cs);
return err;
@@ -804,18 +769,19 @@ static ssize_t fuse_dev_write(struct file *file, const char __user *buf,
static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
{
- struct fuse_conn *fc = fuse_get_conn(file);
unsigned mask = POLLOUT | POLLWRNORM;
-
+ struct fuse_conn *fc = fuse_get_conn(file);
if (!fc)
- return -ENODEV;
+ return POLLERR;
poll_wait(file, &fc->waitq, wait);
- spin_lock(&fuse_lock);
- if (!list_empty(&fc->pending))
- mask |= POLLIN | POLLRDNORM;
- spin_unlock(&fuse_lock);
+ spin_lock(&fc->lock);
+ if (!fc->connected)
+ mask = POLLERR;
+ else if (!list_empty(&fc->pending))
+ mask |= POLLIN | POLLRDNORM;
+ spin_unlock(&fc->lock);
return mask;
}
@@ -823,7 +789,7 @@ static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
/*
* Abort all requests on the given list (pending or processing)
*
- * This function releases and reacquires fuse_lock
+ * This function releases and reacquires fc->lock
*/
static void end_requests(struct fuse_conn *fc, struct list_head *head)
{
@@ -832,7 +798,7 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head)
req = list_entry(head->next, struct fuse_req, list);
req->out.h.error = -ECONNABORTED;
request_end(fc, req);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
}
}
@@ -863,10 +829,10 @@ static void end_io_requests(struct fuse_conn *fc)
req->end = NULL;
/* The end function will consume this reference */
__fuse_get_request(req);
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
wait_event(req->waitq, !req->locked);
end(fc, req);
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
}
}
}
@@ -893,35 +859,44 @@ static void end_io_requests(struct fuse_conn *fc)
*/
void fuse_abort_conn(struct fuse_conn *fc)
{
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
if (fc->connected) {
fc->connected = 0;
end_io_requests(fc);
end_requests(fc, &fc->pending);
end_requests(fc, &fc->processing);
wake_up_all(&fc->waitq);
+ kill_fasync(&fc->fasync, SIGIO, POLL_IN);
}
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
}
static int fuse_dev_release(struct inode *inode, struct file *file)
{
- struct fuse_conn *fc;
-
- spin_lock(&fuse_lock);
- fc = file->private_data;
+ struct fuse_conn *fc = fuse_get_conn(file);
if (fc) {
+ spin_lock(&fc->lock);
fc->connected = 0;
end_requests(fc, &fc->pending);
end_requests(fc, &fc->processing);
- }
- spin_unlock(&fuse_lock);
- if (fc)
+ spin_unlock(&fc->lock);
+ fasync_helper(-1, file, 0, &fc->fasync);
kobject_put(&fc->kobj);
+ }
return 0;
}
+static int fuse_dev_fasync(int fd, struct file *file, int on)
+{
+ struct fuse_conn *fc = fuse_get_conn(file);
+ if (!fc)
+ return -EPERM;
+
+ /* No locking - fasync_helper does its own locking */
+ return fasync_helper(fd, file, on, &fc->fasync);
+}
+
const struct file_operations fuse_dev_operations = {
.owner = THIS_MODULE,
.llseek = no_llseek,
@@ -931,6 +906,7 @@ const struct file_operations fuse_dev_operations = {
.writev = fuse_dev_writev,
.poll = fuse_dev_poll,
.release = fuse_dev_release,
+ .fasync = fuse_dev_fasync,
};
static struct miscdevice fuse_miscdevice = {
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 256355b80256f..8d7546e832e89 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -117,8 +117,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
return 0;
fc = get_fuse_conn(inode);
- req = fuse_get_request(fc);
- if (!req)
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
return 0;
fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg);
@@ -188,9 +188,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
if (entry->d_name.len > FUSE_NAME_MAX)
return ERR_PTR(-ENAMETOOLONG);
- req = fuse_get_request(fc);
- if (!req)
- return ERR_PTR(-EINTR);
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return ERR_PTR(PTR_ERR(req));
fuse_lookup_init(req, dir, entry, &outarg);
request_send(fc, req);
@@ -244,15 +244,14 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
struct file *file;
int flags = nd->intent.open.flags - 1;
- err = -ENOSYS;
if (fc->no_create)
- goto out;
+ return -ENOSYS;
- err = -EINTR;
- req = fuse_get_request(fc);
- if (!req)
- goto out;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
+ err = -ENOMEM;
ff = fuse_file_alloc();
if (!ff)
goto out_put_request;
@@ -314,7 +313,6 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
fuse_file_free(ff);
out_put_request:
fuse_put_request(fc, req);
- out:
return err;
}
@@ -375,9 +373,9 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode,
{
struct fuse_mknod_in inarg;
struct fuse_conn *fc = get_fuse_conn(dir);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.mode = mode;
@@ -407,9 +405,9 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, int mode)
{
struct fuse_mkdir_in inarg;
struct fuse_conn *fc = get_fuse_conn(dir);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.mode = mode;
@@ -427,9 +425,9 @@ static int fuse_symlink(struct inode *dir, struct dentry *entry,
{
struct fuse_conn *fc = get_fuse_conn(dir);
unsigned len = strlen(link) + 1;
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
req->in.h.opcode = FUSE_SYMLINK;
req->in.numargs = 2;
@@ -444,9 +442,9 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry)
{
int err;
struct fuse_conn *fc = get_fuse_conn(dir);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
req->in.h.opcode = FUSE_UNLINK;
req->in.h.nodeid = get_node_id(dir);
@@ -476,9 +474,9 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
{
int err;
struct fuse_conn *fc = get_fuse_conn(dir);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
req->in.h.opcode = FUSE_RMDIR;
req->in.h.nodeid = get_node_id(dir);
@@ -504,9 +502,9 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent,
int err;
struct fuse_rename_in inarg;
struct fuse_conn *fc = get_fuse_conn(olddir);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.newdir = get_node_id(newdir);
@@ -553,9 +551,9 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
struct fuse_link_in inarg;
struct inode *inode = entry->d_inode;
struct fuse_conn *fc = get_fuse_conn(inode);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.oldnodeid = get_node_id(inode);
@@ -583,9 +581,9 @@ int fuse_do_getattr(struct inode *inode)
int err;
struct fuse_attr_out arg;
struct fuse_conn *fc = get_fuse_conn(inode);
- struct fuse_req *req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ struct fuse_req *req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
req->in.h.opcode = FUSE_GETATTR;
req->in.h.nodeid = get_node_id(inode);
@@ -673,9 +671,9 @@ static int fuse_access(struct inode *inode, int mask)
if (fc->no_access)
return 0;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.mask = mask;
@@ -780,9 +778,9 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
if (is_bad_inode(inode))
return -EIO;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
page = alloc_page(GFP_KERNEL);
if (!page) {
@@ -809,11 +807,11 @@ static char *read_link(struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
struct fuse_conn *fc = get_fuse_conn(inode);
- struct fuse_req *req = fuse_get_request(fc);
+ struct fuse_req *req = fuse_get_req(fc);
char *link;
- if (!req)
- return ERR_PTR(-EINTR);
+ if (IS_ERR(req))
+ return ERR_PTR(PTR_ERR(req));
link = (char *) __get_free_page(GFP_KERNEL);
if (!link) {
@@ -933,9 +931,9 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
}
}
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
iattr_to_fattr(attr, &inarg);
@@ -995,9 +993,9 @@ static int fuse_setxattr(struct dentry *entry, const char *name,
if (fc->no_setxattr)
return -EOPNOTSUPP;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.size = size;
@@ -1035,9 +1033,9 @@ static ssize_t fuse_getxattr(struct dentry *entry, const char *name,
if (fc->no_getxattr)
return -EOPNOTSUPP;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.size = size;
@@ -1085,9 +1083,9 @@ static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
if (fc->no_listxattr)
return -EOPNOTSUPP;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.size = size;
@@ -1131,9 +1129,9 @@ static int fuse_removexattr(struct dentry *entry, const char *name)
if (fc->no_removexattr)
return -EOPNOTSUPP;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
req->in.h.opcode = FUSE_REMOVEXATTR;
req->in.h.nodeid = get_node_id(inode);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 975f2697e8663..e4f041a11bb5f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -22,9 +22,9 @@ static int fuse_send_open(struct inode *inode, struct file *file, int isdir,
struct fuse_req *req;
int err;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
@@ -184,9 +184,9 @@ static int fuse_flush(struct file *file)
if (fc->no_flush)
return 0;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.fh = ff->fh;
@@ -223,9 +223,9 @@ int fuse_fsync_common(struct file *file, struct dentry *de, int datasync,
if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir))
return 0;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&inarg, 0, sizeof(inarg));
inarg.fh = ff->fh;
@@ -297,9 +297,9 @@ static int fuse_readpage(struct file *file, struct page *page)
if (is_bad_inode(inode))
goto out;
- err = -EINTR;
- req = fuse_get_request(fc);
- if (!req)
+ req = fuse_get_req(fc);
+ err = PTR_ERR(req);
+ if (IS_ERR(req))
goto out;
req->out.page_zeroing = 1;
@@ -368,10 +368,10 @@ static int fuse_readpages_fill(void *_data, struct page *page)
(req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read ||
req->pages[req->num_pages - 1]->index + 1 != page->index)) {
fuse_send_readpages(req, data->file, inode);
- data->req = req = fuse_get_request(fc);
- if (!req) {
+ data->req = req = fuse_get_req(fc);
+ if (IS_ERR(req)) {
unlock_page(page);
- return -EINTR;
+ return PTR_ERR(req);
}
}
req->pages[req->num_pages] = page;
@@ -392,13 +392,17 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
data.file = file;
data.inode = inode;
- data.req = fuse_get_request(fc);
- if (!data.req)
- return -EINTR;
+ data.req = fuse_get_req(fc);
+ if (IS_ERR(data.req))
+ return PTR_ERR(data.req);
err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data);
- if (!err)
- fuse_send_readpages(data.req, file, inode);
+ if (!err) {
+ if (data.req->num_pages)
+ fuse_send_readpages(data.req, file, inode);
+ else
+ fuse_put_request(fc, data.req);
+ }
return err;
}
@@ -451,9 +455,9 @@ static int fuse_commit_write(struct file *file, struct page *page,
if (is_bad_inode(inode))
return -EIO;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
req->num_pages = 1;
req->pages[0] = page;
@@ -528,9 +532,9 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
if (is_bad_inode(inode))
return -EIO;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
while (count) {
size_t nres;
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index a16a04fcf41ec..19c7185a7546b 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1,6 +1,6 @@
/*
FUSE: Filesystem in Userspace
- Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
+ Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
@@ -18,8 +18,8 @@
/** Max number of pages that can be used in a single read request */
#define FUSE_MAX_PAGES_PER_REQ 32
-/** If more requests are outstanding, then the operation will block */
-#define FUSE_MAX_OUTSTANDING 10
+/** Maximum number of outstanding background requests */
+#define FUSE_MAX_BACKGROUND 10
/** It could be as large as PATH_MAX, but would that have any uses? */
#define FUSE_NAME_MAX 1024
@@ -131,8 +131,8 @@ struct fuse_conn;
* A request to the client
*/
struct fuse_req {
- /** This can be on either unused_list, pending processing or
- io lists in fuse_conn */
+ /** This can be on either pending processing or io lists in
+ fuse_conn */
struct list_head list;
/** Entry on the background list */
@@ -144,15 +144,12 @@ struct fuse_req {
/*
* The following bitfields are either set once before the
* request is queued or setting/clearing them is protected by
- * fuse_lock
+ * fuse_conn->lock
*/
/** True if the request has reply */
unsigned isreply:1;
- /** The request is preallocated */
- unsigned preallocated:1;
-
/** The request was interrupted */
unsigned interrupted:1;
@@ -213,6 +210,9 @@ struct fuse_req {
* unmounted.
*/
struct fuse_conn {
+ /** Lock protecting accessess to members of this structure */
+ spinlock_t lock;
+
/** The user id for this mount */
uid_t user_id;
@@ -244,19 +244,20 @@ struct fuse_conn {
interrupted request) */
struct list_head background;
- /** Controls the maximum number of outstanding requests */
- struct semaphore outstanding_sem;
+ /** Number of requests currently in the background */
+ unsigned num_background;
+
+ /** Flag indicating if connection is blocked. This will be
+ the case before the INIT reply is received, and if there
+ are too many outstading backgrounds requests */
+ int blocked;
- /** This counts the number of outstanding requests if
- outstanding_sem would go negative */
- unsigned outstanding_debt;
+ /** waitq for blocked connection */
+ wait_queue_head_t blocked_waitq;
/** RW semaphore for exclusion with fuse_put_super() */
struct rw_semaphore sbput_sem;
- /** The list of unused requests */
- struct list_head unused_list;
-
/** The next unique request id */
u64 reqctr;
@@ -318,6 +319,9 @@ struct fuse_conn {
/** kobject */
struct kobject kobj;
+
+ /** O_ASYNC requests */
+ struct fasync_struct *fasync;
};
static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
@@ -349,21 +353,6 @@ static inline u64 get_node_id(struct inode *inode)
extern const struct file_operations fuse_dev_operations;
/**
- * This is the single global spinlock which protects FUSE's structures
- *
- * The following data is protected by this lock:
- *
- * - the private_data field of the device file
- * - the s_fs_info field of the super block
- * - unused_list, pending, processing lists in fuse_conn
- * - background list in fuse_conn
- * - the unique request ID counter reqctr in fuse_conn
- * - the sb (super_block) field in fuse_conn
- * - the file (device file) field in fuse_conn
- */
-extern spinlock_t fuse_lock;
-
-/**
* Get a filled in inode
*/
struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
@@ -461,11 +450,11 @@ void fuse_reset_request(struct fuse_req *req);
/**
* Reserve a preallocated request
*/
-struct fuse_req *fuse_get_request(struct fuse_conn *fc);
+struct fuse_req *fuse_get_req(struct fuse_conn *fc);
/**
- * Decrement reference count of a request. If count goes to zero put
- * on unused list (preallocated) or free request (not preallocated).
+ * Decrement reference count of a request. If count goes to zero free
+ * the request.
*/
void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req);
@@ -487,7 +476,7 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req);
/**
* Release inodes and file associated with background request
*/
-void fuse_release_background(struct fuse_req *req);
+void fuse_release_background(struct fuse_conn *fc, struct fuse_req *req);
/* Abort all requests */
void fuse_abort_conn(struct fuse_conn *fc);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 879e6fba94803..fd34037b05884 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1,6 +1,6 @@
/*
FUSE: Filesystem in Userspace
- Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
+ Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
@@ -22,7 +22,6 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
MODULE_DESCRIPTION("Filesystem in Userspace");
MODULE_LICENSE("GPL");
-spinlock_t fuse_lock;
static kmem_cache_t *fuse_inode_cachep;
static struct subsystem connections_subsys;
@@ -207,15 +206,17 @@ static void fuse_put_super(struct super_block *sb)
down_write(&fc->sbput_sem);
while (!list_empty(&fc->background))
- fuse_release_background(list_entry(fc->background.next,
+ fuse_release_background(fc,
+ list_entry(fc->background.next,
struct fuse_req, bg_entry));
- spin_lock(&fuse_lock);
+ spin_lock(&fc->lock);
fc->mounted = 0;
fc->connected = 0;
- spin_unlock(&fuse_lock);
+ spin_unlock(&fc->lock);
up_write(&fc->sbput_sem);
/* Flush all readers on this fs */
+ kill_fasync(&fc->fasync, SIGIO, POLL_IN);
wake_up_all(&fc->waitq);
kobject_del(&fc->kobj);
kobject_put(&fc->kobj);
@@ -242,9 +243,9 @@ static int fuse_statfs(struct super_block *sb, struct kstatfs *buf)
struct fuse_statfs_out outarg;
int err;
- req = fuse_get_request(fc);
- if (!req)
- return -EINTR;
+ req = fuse_get_req(fc);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
memset(&outarg, 0, sizeof(outarg));
req->in.numargs = 0;
@@ -369,15 +370,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
static void fuse_conn_release(struct kobject *kobj)
{
- struct fuse_conn *fc = get_fuse_conn_kobj(kobj);
-
- while (!list_empty(&fc->unused_list)) {
- struct fuse_req *req;
- req = list_entry(fc->unused_list.next, struct fuse_req, list);
- list_del(&req->list);
- fuse_request_free(req);
- }
- kfree(fc);
+ kfree(get_fuse_conn_kobj(kobj));
}
static struct fuse_conn *new_conn(void)
@@ -386,64 +379,25 @@ static struct fuse_conn *new_conn(void)
fc = kzalloc(sizeof(*fc), GFP_KERNEL);
if (fc) {
- int i;
+ spin_lock_init(&fc->lock);
init_waitqueue_head(&fc->waitq);
+ init_waitqueue_head(&fc->blocked_waitq);
INIT_LIST_HEAD(&fc->pending);
INIT_LIST_HEAD(&fc->processing);
INIT_LIST_HEAD(&fc->io);
- INIT_LIST_HEAD(&fc->unused_list);
INIT_LIST_HEAD(&fc->background);
- sema_init(&fc->outstanding_sem, 1); /* One for INIT */
init_rwsem(&fc->sbput_sem);
kobj_set_kset_s(fc, connections_subsys);
kobject_init(&fc->kobj);
atomic_set(&fc->num_waiting, 0);
- for (i = 0; i < FUSE_MAX_OUTSTANDING; i++) {
- struct fuse_req *req = fuse_request_alloc();
- if (!req) {
- kobject_put(&fc->kobj);
- return NULL;
- }
- list_add(&req->list, &fc->unused_list);
- }
fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
fc->bdi.unplug_io_fn = default_unplug_io_fn;
fc->reqctr = 0;
+ fc->blocked = 1;
}
return fc;
}
-static struct fuse_conn *get_conn(struct file *file, struct super_block *sb)
-{
- struct fuse_conn *fc;
- int err;
-
- err = -EINVAL;
- if (file->f_op != &fuse_dev_operations)
- goto out_err;
-
- err = -ENOMEM;
- fc = new_conn();
- if (!fc)
- goto out_err;
-
- spin_lock(&fuse_lock);
- err = -EINVAL;
- if (file->private_data)
- goto out_unlock;
-
- kobject_get(&fc->kobj);
- file->private_data = fc;
- spin_unlock(&fuse_lock);
- return fc;
-
- out_unlock:
- spin_unlock(&fuse_lock);
- kobject_put(&fc->kobj);
- out_err:
- return ERR_PTR(err);
-}
-
static struct inode *get_root_inode(struct super_block *sb, unsigned mode)
{
struct fuse_attr attr;
@@ -467,7 +421,6 @@ static struct super_operations fuse_super_operations = {
static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
{
- int i;
struct fuse_init_out *arg = &req->misc.init_out;
if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION)
@@ -486,22 +439,13 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
fc->minor = arg->minor;
fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
}
-
- /* After INIT reply is received other requests can go
- out. So do (FUSE_MAX_OUTSTANDING - 1) number of
- up()s on outstanding_sem. The last up() is done in
- fuse_putback_request() */
- for (i = 1; i < FUSE_MAX_OUTSTANDING; i++)
- up(&fc->outstanding_sem);
-
fuse_put_request(fc, req);
+ fc->blocked = 0;
+ wake_up_all(&fc->blocked_waitq);
}
-static void fuse_send_init(struct fuse_conn *fc)
+static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
{
- /* This is called from fuse_read_super() so there's guaranteed
- to be exactly one request available */
- struct fuse_req *req = fuse_get_request(fc);
struct fuse_init_in *arg = &req->misc.init_in;
arg->major = FUSE_KERNEL_VERSION;
@@ -525,12 +469,9 @@ static void fuse_send_init(struct fuse_conn *fc)
static unsigned long long conn_id(void)
{
+ /* BKL is held for ->get_sb() */
static unsigned long long ctr = 1;
- unsigned long long val;
- spin_lock(&fuse_lock);
- val = ctr++;
- spin_unlock(&fuse_lock);
- return val;
+ return ctr++;
}
static int fuse_fill_super(struct super_block *sb, void *data, int silent)
@@ -540,6 +481,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
struct fuse_mount_data d;
struct file *file;
struct dentry *root_dentry;
+ struct fuse_req *init_req;
int err;
if (!parse_fuse_opt((char *) data, &d))
@@ -555,10 +497,17 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
if (!file)
return -EINVAL;
- fc = get_conn(file, sb);
- fput(file);
- if (IS_ERR(fc))
- return PTR_ERR(fc);
+ if (file->f_op != &fuse_dev_operations)
+ return -EINVAL;
+
+ /* Setting file->private_data can't race with other mount()
+ instances, since BKL is held for ->get_sb() */
+ if (file->private_data)
+ return -EINVAL;
+
+ fc = new_conn();
+ if (!fc)
+ return -ENOMEM;
fc->flags = d.flags;
fc->user_id = d.user_id;
@@ -579,27 +528,40 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
goto err;
}
+ init_req = fuse_request_alloc();
+ if (!init_req)
+ goto err_put_root;
+
err = kobject_set_name(&fc->kobj, "%llu", conn_id());
if (err)
- goto err_put_root;
+ goto err_free_req;
err = kobject_add(&fc->kobj);
if (err)
- goto err_put_root;
+ goto err_free_req;
sb->s_root = root_dentry;
- spin_lock(&fuse_lock);
fc->mounted = 1;
fc->connected = 1;
- spin_unlock(&fuse_lock);
+ kobject_get(&fc->kobj);
+ file->private_data = fc;
+ /*
+ * atomic_dec_and_test() in fput() provides the necessary
+ * memory barrier for file->private_data to be visible on all
+ * CPUs after this
+ */
+ fput(file);
- fuse_send_init(fc);
+ fuse_send_init(fc, init_req);
return 0;
+ err_free_req:
+ fuse_request_free(init_req);
err_put_root:
dput(root_dentry);
err:
+ fput(file);
kobject_put(&fc->kobj);
return err;
}
@@ -753,7 +715,6 @@ static int __init fuse_init(void)
printk("fuse init (API version %i.%i)\n",
FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
- spin_lock_init(&fuse_lock);
res = fuse_fs_init();
if (res)
goto err;
diff --git a/fs/inotify.c b/fs/inotify.c
index 367c487c014b6..1f50302849c53 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -538,7 +538,7 @@ void inotify_d_instantiate(struct dentry *entry, struct inode *inode)
WARN_ON(entry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
spin_lock(&entry->d_lock);
parent = entry->d_parent;
- if (inotify_inode_watched(parent->d_inode))
+ if (parent->d_inode && inotify_inode_watched(parent->d_inode))
entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
spin_unlock(&entry->d_lock);
}
diff --git a/fs/namespace.c b/fs/namespace.c
index bf478addb852b..2c5f1f80bdc28 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -899,11 +899,13 @@ static int do_change_type(struct nameidata *nd, int flag)
/*
* do loopback mount.
*/
-static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
+static int do_loopback(struct nameidata *nd, char *old_name, unsigned long flags, int mnt_flags)
{
struct nameidata old_nd;
struct vfsmount *mnt = NULL;
+ int recurse = flags & MS_REC;
int err = mount_is_safe(nd);
+
if (err)
return err;
if (!old_name || !*old_name)
@@ -937,6 +939,7 @@ static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
spin_unlock(&vfsmount_lock);
release_mounts(&umount_list);
}
+ mnt->mnt_flags = mnt_flags;
out:
up_write(&namespace_sem);
@@ -1350,7 +1353,7 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
data_page);
else if (flags & MS_BIND)
- retval = do_loopback(&nd, dev_name, flags & MS_REC);
+ retval = do_loopback(&nd, dev_name, flags, mnt_flags);
else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
retval = do_change_type(&nd, flags);
else if (flags & MS_MOVE)
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
index cfe9ce8816132..6e92b0fe53234 100644
--- a/fs/nfsd/auth.c
+++ b/fs/nfsd/auth.c
@@ -14,46 +14,46 @@
int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
{
- struct svc_cred *cred = &rqstp->rq_cred;
+ struct svc_cred cred = rqstp->rq_cred;
int i;
int ret;
if (exp->ex_flags & NFSEXP_ALLSQUASH) {
- cred->cr_uid = exp->ex_anon_uid;
- cred->cr_gid = exp->ex_anon_gid;
- put_group_info(cred->cr_group_info);
- cred->cr_group_info = groups_alloc(0);
+ cred.cr_uid = exp->ex_anon_uid;
+ cred.cr_gid = exp->ex_anon_gid;
+ cred.cr_group_info = groups_alloc(0);
} else if (exp->ex_flags & NFSEXP_ROOTSQUASH) {
struct group_info *gi;
- if (!cred->cr_uid)
- cred->cr_uid = exp->ex_anon_uid;
- if (!cred->cr_gid)
- cred->cr_gid = exp->ex_anon_gid;
- gi = groups_alloc(cred->cr_group_info->ngroups);
+ if (!cred.cr_uid)
+ cred.cr_uid = exp->ex_anon_uid;
+ if (!cred.cr_gid)
+ cred.cr_gid = exp->ex_anon_gid;
+ gi = groups_alloc(cred.cr_group_info->ngroups);
if (gi)
- for (i = 0; i < cred->cr_group_info->ngroups; i++) {
- if (!GROUP_AT(cred->cr_group_info, i))
+ for (i = 0; i < cred.cr_group_info->ngroups; i++) {
+ if (!GROUP_AT(cred.cr_group_info, i))
GROUP_AT(gi, i) = exp->ex_anon_gid;
else
- GROUP_AT(gi, i) = GROUP_AT(cred->cr_group_info, i);
+ GROUP_AT(gi, i) = GROUP_AT(cred.cr_group_info, i);
}
- put_group_info(cred->cr_group_info);
- cred->cr_group_info = gi;
- }
+ cred.cr_group_info = gi;
+ } else
+ get_group_info(cred.cr_group_info);
- if (cred->cr_uid != (uid_t) -1)
- current->fsuid = cred->cr_uid;
+ if (cred.cr_uid != (uid_t) -1)
+ current->fsuid = cred.cr_uid;
else
current->fsuid = exp->ex_anon_uid;
- if (cred->cr_gid != (gid_t) -1)
- current->fsgid = cred->cr_gid;
+ if (cred.cr_gid != (gid_t) -1)
+ current->fsgid = cred.cr_gid;
else
current->fsgid = exp->ex_anon_gid;
- if (!cred->cr_group_info)
+ if (!cred.cr_group_info)
return -ENOMEM;
- ret = set_current_groups(cred->cr_group_info);
- if ((cred->cr_uid)) {
+ ret = set_current_groups(cred.cr_group_info);
+ put_group_info(cred.cr_group_info);
+ if ((cred.cr_uid)) {
cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
} else {
cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index c340be0a3f59b..4e0578121d9a6 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -422,7 +422,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
goto out;
err = path_lookup(buf, 0, &nd);
- if (err) goto out;
+ if (err) goto out_no_path;
exp.h.flags = 0;
exp.ex_client = dom;
@@ -475,6 +475,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
out:
if (nd.dentry)
path_release(&nd);
+ out_no_path:
if (dom)
auth_domain_put(dom);
kfree(buf);
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index 6d2dfed1de087..f61142afea449 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -682,7 +682,7 @@ static struct svc_procedure nfsd_procedures3[22] = {
PROC(lookup, dirop, dirop, fhandle2, RC_NOCACHE, ST+FH+pAT+pAT),
PROC(access, access, access, fhandle, RC_NOCACHE, ST+pAT+1),
PROC(readlink, readlink, readlink, fhandle, RC_NOCACHE, ST+pAT+1+NFS3_MAXPATHLEN/4),
- PROC(read, read, read, fhandle, RC_NOCACHE, ST+pAT+4+NFSSVC_MAXBLKSIZE),
+ PROC(read, read, read, fhandle, RC_NOCACHE, ST+pAT+4+NFSSVC_MAXBLKSIZE/4),
PROC(write, write, write, fhandle, RC_REPLBUFF, ST+WC+4),
PROC(create, create, create, fhandle2, RC_REPLBUFF, ST+(1+FH+pAT)+WC),
PROC(mkdir, mkdir, create, fhandle2, RC_REPLBUFF, ST+(1+FH+pAT)+WC),
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index 7391f4aabedb0..edb107e61b91d 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -710,9 +710,9 @@ calculate_posix_ace_count(struct nfs4_acl *n4acl)
/* Also, the remaining entries are for named users and
* groups, and come in threes (mask, allow, deny): */
if (n4acl->naces < 7)
- return -1;
+ return -EINVAL;
if ((n4acl->naces - 7) % 3)
- return -1;
+ return -EINVAL;
return 4 + (n4acl->naces - 7)/3;
}
}
@@ -790,7 +790,7 @@ nfs4_acl_split(struct nfs4_acl *acl, struct nfs4_acl *dacl)
continue;
error = nfs4_acl_add_ace(dacl, ace->type, ace->flag,
- ace->access_mask, ace->whotype, ace->who) == -1;
+ ace->access_mask, ace->whotype, ace->who);
if (error < 0)
goto out;
@@ -866,7 +866,7 @@ nfs4_acl_add_ace(struct nfs4_acl *acl, u32 type, u32 flag, u32 access_mask,
struct nfs4_ace *ace;
if ((ace = kmalloc(sizeof(*ace), GFP_KERNEL)) == NULL)
- return -1;
+ return -ENOMEM;
ace->type = type;
ace->flag = flag;
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index c872bd07fc105..dbaf3f93f3283 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -441,8 +441,9 @@ nfsd4_probe_callback(struct nfs4_client *clp)
goto out_clnt;
}
- /* the task holds a reference to the nfs4_client struct */
cb->cb_client = clnt;
+
+ /* the task holds a reference to the nfs4_client struct */
atomic_inc(&clp->cl_count);
msg.rpc_cred = nfsd4_lookupcred(clp,0);
@@ -460,13 +461,12 @@ nfsd4_probe_callback(struct nfs4_client *clp)
out_rpciod:
atomic_dec(&clp->cl_count);
rpciod_down();
+ cb->cb_client = NULL;
out_clnt:
rpc_shutdown_client(clnt);
- goto out_err;
out_err:
dprintk("NFSD: warning: no callback path to client %.*s\n",
(int)clp->cl_name.len, clp->cl_name.data);
- cb->cb_client = NULL;
}
static void
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 6d63f1d9e5f59..b0e095ea0c03c 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -288,8 +288,6 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct svc_fh *current_fh)
fh_put(current_fh);
status = exp_pseudoroot(rqstp->rq_client, current_fh,
&rqstp->rq_chandle);
- if (!status)
- status = nfserrno(nfsd_setuser(rqstp, current_fh->fh_export));
return status;
}
@@ -975,7 +973,7 @@ struct nfsd4_voidargs { int dummy; };
*/
static struct svc_procedure nfsd_procedures4[2] = {
PROC(null, void, void, void, RC_NOCACHE, 1),
- PROC(compound, compound, compound, compound, RC_NOCACHE, NFSD_BUFSIZE)
+ PROC(compound, compound, compound, compound, RC_NOCACHE, NFSD_BUFSIZE/4)
};
struct svc_version nfsd_version4 = {
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 47ec112b266cf..96c7578cbe1e8 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -147,6 +147,42 @@ get_nfs4_file(struct nfs4_file *fi)
kref_get(&fi->fi_ref);
}
+static int num_delegations;
+
+/*
+ * Open owner state (share locks)
+ */
+
+/* hash tables for nfs4_stateowner */
+#define OWNER_HASH_BITS 8
+#define OWNER_HASH_SIZE (1 << OWNER_HASH_BITS)
+#define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1)
+
+#define ownerid_hashval(id) \
+ ((id) & OWNER_HASH_MASK)
+#define ownerstr_hashval(clientid, ownername) \
+ (((clientid) + opaque_hashval((ownername.data), (ownername.len))) & OWNER_HASH_MASK)
+
+static struct list_head ownerid_hashtbl[OWNER_HASH_SIZE];
+static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE];
+
+/* hash table for nfs4_file */
+#define FILE_HASH_BITS 8
+#define FILE_HASH_SIZE (1 << FILE_HASH_BITS)
+#define FILE_HASH_MASK (FILE_HASH_SIZE - 1)
+/* hash table for (open)nfs4_stateid */
+#define STATEID_HASH_BITS 10
+#define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS)
+#define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1)
+
+#define file_hashval(x) \
+ hash_ptr(x, FILE_HASH_BITS)
+#define stateid_hashval(owner_id, file_id) \
+ (((owner_id) + (file_id)) & STATEID_HASH_MASK)
+
+static struct list_head file_hashtbl[FILE_HASH_SIZE];
+static struct list_head stateid_hashtbl[STATEID_HASH_SIZE];
+
static struct nfs4_delegation *
alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_fh *current_fh, u32 type)
{
@@ -155,9 +191,12 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f
struct nfs4_callback *cb = &stp->st_stateowner->so_client->cl_callback;
dprintk("NFSD alloc_init_deleg\n");
+ if (num_delegations > STATEID_HASH_SIZE * 4)
+ return NULL;
dp = kmem_cache_alloc(deleg_slab, GFP_KERNEL);
if (dp == NULL)
return dp;
+ num_delegations++;
INIT_LIST_HEAD(&dp->dl_perfile);
INIT_LIST_HEAD(&dp->dl_perclnt);
INIT_LIST_HEAD(&dp->dl_recall_lru);
@@ -192,6 +231,7 @@ nfs4_put_delegation(struct nfs4_delegation *dp)
dprintk("NFSD: freeing dp %p\n",dp);
put_nfs4_file(dp->dl_file);
kmem_cache_free(deleg_slab, dp);
+ num_delegations--;
}
}
@@ -330,22 +370,29 @@ put_nfs4_client(struct nfs4_client *clp)
}
static void
+shutdown_callback_client(struct nfs4_client *clp)
+{
+ struct rpc_clnt *clnt = clp->cl_callback.cb_client;
+
+ /* shutdown rpc client, ending any outstanding recall rpcs */
+ if (clnt) {
+ clp->cl_callback.cb_client = NULL;
+ rpc_shutdown_client(clnt);
+ rpciod_down();
+ }
+}
+
+static void
expire_client(struct nfs4_client *clp)
{
struct nfs4_stateowner *sop;
struct nfs4_delegation *dp;
- struct nfs4_callback *cb = &clp->cl_callback;
- struct rpc_clnt *clnt = clp->cl_callback.cb_client;
struct list_head reaplist;
dprintk("NFSD: expire_client cl_count %d\n",
atomic_read(&clp->cl_count));
- /* shutdown rpc client, ending any outstanding recall rpcs */
- if (atomic_read(&cb->cb_set) == 1 && clnt) {
- rpc_shutdown_client(clnt);
- clnt = clp->cl_callback.cb_client = NULL;
- }
+ shutdown_callback_client(clp);
INIT_LIST_HEAD(&reaplist);
spin_lock(&recall_lock);
@@ -936,40 +983,6 @@ out:
return status;
}
-/*
- * Open owner state (share locks)
- */
-
-/* hash tables for nfs4_stateowner */
-#define OWNER_HASH_BITS 8
-#define OWNER_HASH_SIZE (1 << OWNER_HASH_BITS)
-#define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1)
-
-#define ownerid_hashval(id) \
- ((id) & OWNER_HASH_MASK)
-#define ownerstr_hashval(clientid, ownername) \
- (((clientid) + opaque_hashval((ownername.data), (ownername.len))) & OWNER_HASH_MASK)
-
-static struct list_head ownerid_hashtbl[OWNER_HASH_SIZE];
-static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE];
-
-/* hash table for nfs4_file */
-#define FILE_HASH_BITS 8
-#define FILE_HASH_SIZE (1 << FILE_HASH_BITS)
-#define FILE_HASH_MASK (FILE_HASH_SIZE - 1)
-/* hash table for (open)nfs4_stateid */
-#define STATEID_HASH_BITS 10
-#define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS)
-#define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1)
-
-#define file_hashval(x) \
- hash_ptr(x, FILE_HASH_BITS)
-#define stateid_hashval(owner_id, file_id) \
- (((owner_id) + (file_id)) & STATEID_HASH_MASK)
-
-static struct list_head file_hashtbl[FILE_HASH_SIZE];
-static struct list_head stateid_hashtbl[STATEID_HASH_SIZE];
-
/* OPEN Share state helper functions */
static inline struct nfs4_file *
alloc_init_file(struct inode *ino)
@@ -1186,8 +1199,7 @@ move_to_close_lru(struct nfs4_stateowner *sop)
{
dprintk("NFSD: move_to_close_lru nfs4_stateowner %p\n", sop);
- unhash_stateowner(sop);
- list_add_tail(&sop->so_close_lru, &close_lru);
+ list_move_tail(&sop->so_close_lru, &close_lru);
sop->so_time = get_seconds();
}
@@ -1916,8 +1928,7 @@ nfs4_laundromat(void)
}
dprintk("NFSD: purging unused open stateowner (so_id %d)\n",
sop->so_id);
- list_del(&sop->so_close_lru);
- nfs4_put_stateowner(sop);
+ release_stateowner(sop);
}
if (clientid_val < NFSD_LAUNDROMAT_MINTIMEOUT)
clientid_val = NFSD_LAUNDROMAT_MINTIMEOUT;
@@ -2495,36 +2506,27 @@ nfs4_transform_lock_offset(struct file_lock *lock)
lock->fl_end = OFFSET_MAX;
}
-static int
-nfs4_verify_lock_stateowner(struct nfs4_stateowner *sop, unsigned int hashval)
-{
- struct nfs4_stateowner *local = NULL;
- int status = 0;
-
- if (hashval >= LOCK_HASH_SIZE)
- goto out;
- list_for_each_entry(local, &lock_ownerid_hashtbl[hashval], so_idhash) {
- if (local == sop) {
- status = 1;
- goto out;
- }
- }
-out:
- return status;
-}
-
+/* Hack!: For now, we're defining this just so we can use a pointer to it
+ * as a unique cookie to identify our (NFSv4's) posix locks. */
+static struct lock_manager_operations nfsd_posix_mng_ops = {
+};
static inline void
nfs4_set_lock_denied(struct file_lock *fl, struct nfsd4_lock_denied *deny)
{
- struct nfs4_stateowner *sop = (struct nfs4_stateowner *) fl->fl_owner;
- unsigned int hval = lockownerid_hashval(sop->so_id);
+ struct nfs4_stateowner *sop;
+ unsigned int hval;
- deny->ld_sop = NULL;
- if (nfs4_verify_lock_stateowner(sop, hval)) {
+ if (fl->fl_lmops == &nfsd_posix_mng_ops) {
+ sop = (struct nfs4_stateowner *) fl->fl_owner;
+ hval = lockownerid_hashval(sop->so_id);
kref_get(&sop->so_ref);
deny->ld_sop = sop;
deny->ld_clientid = sop->so_client->cl_clientid;
+ } else {
+ deny->ld_sop = NULL;
+ deny->ld_clientid.cl_boot = 0;
+ deny->ld_clientid.cl_id = 0;
}
deny->ld_start = fl->fl_start;
deny->ld_length = ~(u64)0;
@@ -2736,6 +2738,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
file_lock.fl_pid = current->tgid;
file_lock.fl_file = filp;
file_lock.fl_flags = FL_POSIX;
+ file_lock.fl_lmops = &nfsd_posix_mng_ops;
file_lock.fl_start = lock->lk_offset;
if ((lock->lk_length == ~(u64)0) ||
@@ -2841,6 +2844,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
file_lock.fl_owner = (fl_owner_t)lockt->lt_stateowner;
file_lock.fl_pid = current->tgid;
file_lock.fl_flags = FL_POSIX;
+ file_lock.fl_lmops = &nfsd_posix_mng_ops;
file_lock.fl_start = lockt->lt_offset;
if ((lockt->lt_length == ~(u64)0) || LOFF_OVERFLOW(lockt->lt_offset, lockt->lt_length))
@@ -2900,6 +2904,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
file_lock.fl_pid = current->tgid;
file_lock.fl_file = filp;
file_lock.fl_flags = FL_POSIX;
+ file_lock.fl_lmops = &nfsd_posix_mng_ops;
file_lock.fl_start = locku->lu_offset;
if ((locku->lu_length == ~(u64)0) || LOFF_OVERFLOW(locku->lu_offset, locku->lu_length))
@@ -3211,15 +3216,8 @@ __nfs4_state_shutdown(void)
int i;
struct nfs4_client *clp = NULL;
struct nfs4_delegation *dp = NULL;
- struct nfs4_stateowner *sop = NULL;
struct list_head *pos, *next, reaplist;
- list_for_each_safe(pos, next, &close_lru) {
- sop = list_entry(pos, struct nfs4_stateowner, so_close_lru);
- list_del(&sop->so_close_lru);
- nfs4_put_stateowner(sop);
- }
-
for (i = 0; i < CLIENT_HASH_SIZE; i++) {
while (!list_empty(&conf_id_hashtbl[i])) {
clp = list_entry(conf_id_hashtbl[i].next, struct nfs4_client, cl_idhash);
@@ -3244,8 +3242,6 @@ __nfs4_state_shutdown(void)
}
cancel_delayed_work(&laundromat_work);
- flush_workqueue(laundry_wq);
- destroy_workqueue(laundry_wq);
nfsd4_shutdown_recdir();
nfs4_init = 0;
}
@@ -3253,6 +3249,8 @@ __nfs4_state_shutdown(void)
void
nfs4_state_shutdown(void)
{
+ cancel_rearming_delayed_workqueue(laundry_wq, &laundromat_work);
+ destroy_workqueue(laundry_wq);
nfs4_lock_state();
nfs4_release_reclaim();
__nfs4_state_shutdown();
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 03857fd811263..de3998f15f101 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -299,11 +299,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *ia
buf, dummy32, &ace.who);
if (status)
goto out_nfserr;
- if (nfs4_acl_add_ace(*acl, ace.type, ace.flag,
- ace.access_mask, ace.whotype, ace.who) != 0) {
- status = -ENOMEM;
+ status = nfs4_acl_add_ace(*acl, ace.type, ace.flag,
+ ace.access_mask, ace.whotype, ace.who);
+ if (status)
goto out_nfserr;
- }
}
} else
*acl = NULL;
@@ -2085,27 +2084,20 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_read
WRITE32(eof);
WRITE32(maxcount);
ADJUST_ARGS();
- resp->xbuf->head[0].iov_len = ((char*)resp->p) - (char*)resp->xbuf->head[0].iov_base;
-
+ resp->xbuf->head[0].iov_len = (char*)p
+ - (char*)resp->xbuf->head[0].iov_base;
resp->xbuf->page_len = maxcount;
- /* read zero bytes -> don't set up tail */
- if(!maxcount)
- return 0;
-
- /* set up page for remaining responses */
- svc_take_page(resp->rqstp);
- resp->xbuf->tail[0].iov_base =
- page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
- resp->rqstp->rq_restailpage = resp->rqstp->rq_resused-1;
+ /* Use rest of head for padding and remaining ops: */
+ resp->rqstp->rq_restailpage = 0;
+ resp->xbuf->tail[0].iov_base = p;
resp->xbuf->tail[0].iov_len = 0;
- resp->p = resp->xbuf->tail[0].iov_base;
- resp->end = resp->p + PAGE_SIZE/4;
-
if (maxcount&3) {
- *(resp->p)++ = 0;
+ RESERVE_SPACE(4);
+ WRITE32(0);
resp->xbuf->tail[0].iov_base += maxcount&3;
resp->xbuf->tail[0].iov_len = 4 - (maxcount&3);
+ ADJUST_ARGS();
}
return 0;
}
@@ -2142,21 +2134,20 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_r
WRITE32(maxcount);
ADJUST_ARGS();
- resp->xbuf->head[0].iov_len = ((char*)resp->p) - (char*)resp->xbuf->head[0].iov_base;
+ resp->xbuf->head[0].iov_len = (char*)p
+ - (char*)resp->xbuf->head[0].iov_base;
+ resp->xbuf->page_len = maxcount;
- svc_take_page(resp->rqstp);
- resp->xbuf->tail[0].iov_base =
- page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
- resp->rqstp->rq_restailpage = resp->rqstp->rq_resused-1;
+ /* Use rest of head for padding and remaining ops: */
+ resp->rqstp->rq_restailpage = 0;
+ resp->xbuf->tail[0].iov_base = p;
resp->xbuf->tail[0].iov_len = 0;
- resp->p = resp->xbuf->tail[0].iov_base;
- resp->end = resp->p + PAGE_SIZE/4;
-
- resp->xbuf->page_len = maxcount;
if (maxcount&3) {
- *(resp->p)++ = 0;
+ RESERVE_SPACE(4);
+ WRITE32(0);
resp->xbuf->tail[0].iov_base += maxcount&3;
resp->xbuf->tail[0].iov_len = 4 - (maxcount&3);
+ ADJUST_ARGS();
}
return 0;
}
@@ -2166,7 +2157,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_re
{
int maxcount;
loff_t offset;
- u32 *page, *savep;
+ u32 *page, *savep, *tailbase;
ENCODE_HEAD;
if (nfserr)
@@ -2182,6 +2173,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_re
WRITE32(0);
ADJUST_ARGS();
resp->xbuf->head[0].iov_len = ((char*)resp->p) - (char*)resp->xbuf->head[0].iov_base;
+ tailbase = p;
maxcount = PAGE_SIZE;
if (maxcount > readdir->rd_maxcount)
@@ -2226,14 +2218,12 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_re
*p++ = htonl(readdir->common.err == nfserr_eof);
resp->xbuf->page_len = ((char*)p) - (char*)page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
- /* allocate a page for the tail */
- svc_take_page(resp->rqstp);
- resp->xbuf->tail[0].iov_base =
- page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
- resp->rqstp->rq_restailpage = resp->rqstp->rq_resused-1;
+ /* Use rest of head for padding and remaining ops: */
+ resp->rqstp->rq_restailpage = 0;
+ resp->xbuf->tail[0].iov_base = tailbase;
resp->xbuf->tail[0].iov_len = 0;
resp->p = resp->xbuf->tail[0].iov_base;
- resp->end = resp->p + PAGE_SIZE/4;
+ resp->end = resp->p + (PAGE_SIZE - resp->xbuf->head[0].iov_len)/4;
return 0;
err_no_verf:
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 3e6b75cd90fd1..06cd0db0f32b3 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -553,7 +553,7 @@ static struct svc_procedure nfsd_procedures2[18] = {
PROC(none, void, void, none, RC_NOCACHE, ST),
PROC(lookup, diropargs, diropres, fhandle, RC_NOCACHE, ST+FH+AT),
PROC(readlink, readlinkargs, readlinkres, none, RC_NOCACHE, ST+1+NFS_MAXPATHLEN/4),
- PROC(read, readargs, readres, fhandle, RC_NOCACHE, ST+AT+1+NFSSVC_MAXBLKSIZE),
+ PROC(read, readargs, readres, fhandle, RC_NOCACHE, ST+AT+1+NFSSVC_MAXBLKSIZE/4),
PROC(none, void, void, none, RC_NOCACHE, ST),
PROC(write, writeargs, attrstat, fhandle, RC_REPLBUFF, ST+AT),
PROC(create, createargs, diropres, fhandle, RC_REPLBUFF, ST+FH+AT),
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 31018333dc383..6aa92d0e68764 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -371,7 +371,6 @@ out_nfserr:
static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf)
{
ssize_t buflen;
- int error;
buflen = vfs_getxattr(dentry, key, NULL, 0);
if (buflen <= 0)
@@ -381,10 +380,7 @@ static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf)
if (!*buf)
return -ENOMEM;
- error = vfs_getxattr(dentry, key, *buf, buflen);
- if (error < 0)
- return error;
- return buflen;
+ return vfs_getxattr(dentry, key, *buf, buflen);
}
#endif
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index bff0f0d06867f..21f38accd0399 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -153,6 +153,7 @@ struct o2hb_region {
struct o2hb_bio_wait_ctxt {
atomic_t wc_num_reqs;
struct completion wc_io_complete;
+ int wc_error;
};
static void o2hb_write_timeout(void *arg)
@@ -186,6 +187,7 @@ static inline void o2hb_bio_wait_init(struct o2hb_bio_wait_ctxt *wc,
{
atomic_set(&wc->wc_num_reqs, num_ios);
init_completion(&wc->wc_io_complete);
+ wc->wc_error = 0;
}
/* Used in error paths too */
@@ -218,8 +220,10 @@ static int o2hb_bio_end_io(struct bio *bio,
{
struct o2hb_bio_wait_ctxt *wc = bio->bi_private;
- if (error)
+ if (error) {
mlog(ML_ERROR, "IO Error %d\n", error);
+ wc->wc_error = error;
+ }
if (bio->bi_size)
return 1;
@@ -390,6 +394,8 @@ static int o2hb_read_slots(struct o2hb_region *reg,
bail_and_wait:
o2hb_wait_on_io(reg, &wc);
+ if (wc.wc_error && !status)
+ status = wc.wc_error;
if (bios) {
for(i = 0; i < num_bios; i++)
@@ -790,20 +796,24 @@ static int o2hb_highest_node(unsigned long *nodes,
return highest;
}
-static void o2hb_do_disk_heartbeat(struct o2hb_region *reg)
+static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
{
int i, ret, highest_node, change = 0;
unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)];
struct bio *write_bio;
struct o2hb_bio_wait_ctxt write_wc;
- if (o2nm_configured_node_map(configured_nodes, sizeof(configured_nodes)))
- return;
+ ret = o2nm_configured_node_map(configured_nodes,
+ sizeof(configured_nodes));
+ if (ret) {
+ mlog_errno(ret);
+ return ret;
+ }
highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES);
if (highest_node >= O2NM_MAX_NODES) {
mlog(ML_NOTICE, "ocfs2_heartbeat: no configured nodes found!\n");
- return;
+ return -EINVAL;
}
/* No sense in reading the slots of nodes that don't exist
@@ -813,7 +823,7 @@ static void o2hb_do_disk_heartbeat(struct o2hb_region *reg)
ret = o2hb_read_slots(reg, highest_node + 1);
if (ret < 0) {
mlog_errno(ret);
- return;
+ return ret;
}
/* With an up to date view of the slots, we can check that no
@@ -831,7 +841,7 @@ static void o2hb_do_disk_heartbeat(struct o2hb_region *reg)
ret = o2hb_issue_node_write(reg, &write_bio, &write_wc);
if (ret < 0) {
mlog_errno(ret);
- return;
+ return ret;
}
i = -1;
@@ -847,6 +857,15 @@ static void o2hb_do_disk_heartbeat(struct o2hb_region *reg)
*/
o2hb_wait_on_io(reg, &write_wc);
bio_put(write_bio);
+ if (write_wc.wc_error) {
+ /* Do not re-arm the write timeout on I/O error - we
+ * can't be sure that the new block ever made it to
+ * disk */
+ mlog(ML_ERROR, "Write error %d on device \"%s\"\n",
+ write_wc.wc_error, reg->hr_dev_name);
+ return write_wc.wc_error;
+ }
+
o2hb_arm_write_timeout(reg);
/* let the person who launched us know when things are steady */
@@ -854,6 +873,8 @@ static void o2hb_do_disk_heartbeat(struct o2hb_region *reg)
if (atomic_dec_and_test(&reg->hr_steady_iterations))
wake_up(&o2hb_steady_queue);
}
+
+ return 0;
}
/* Subtract b from a, storing the result in a. a *must* have a larger
@@ -913,7 +934,10 @@ static int o2hb_thread(void *data)
* likely to time itself out. */
do_gettimeofday(&before_hb);
- o2hb_do_disk_heartbeat(reg);
+ i = 0;
+ do {
+ ret = o2hb_do_disk_heartbeat(reg);
+ } while (ret && ++i < 2);
do_gettimeofday(&after_hb);
elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb);
diff --git a/fs/ocfs2/dlm/userdlm.c b/fs/ocfs2/dlm/userdlm.c
index c3764f4744ee6..74ca4e5f9765a 100644
--- a/fs/ocfs2/dlm/userdlm.c
+++ b/fs/ocfs2/dlm/userdlm.c
@@ -139,6 +139,10 @@ static void user_ast(void *opaque)
return;
}
+ mlog_bug_on_msg(lockres->l_requested == LKM_IVMODE,
+ "Lockres %s, requested ivmode. flags 0x%x\n",
+ lockres->l_name, lockres->l_flags);
+
/* we're downconverting. */
if (lockres->l_requested < lockres->l_level) {
if (lockres->l_requested <=
@@ -229,23 +233,42 @@ static void user_unlock_ast(void *opaque, enum dlm_status status)
mlog(0, "UNLOCK AST called on lock %s\n", lockres->l_name);
- if (status != DLM_NORMAL)
+ if (status != DLM_NORMAL && status != DLM_CANCELGRANT)
mlog(ML_ERROR, "Dlm returns status %d\n", status);
spin_lock(&lockres->l_lock);
- if (lockres->l_flags & USER_LOCK_IN_TEARDOWN)
+ /* The teardown flag gets set early during the unlock process,
+ * so test the cancel flag to make sure that this ast isn't
+ * for a concurrent cancel. */
+ if (lockres->l_flags & USER_LOCK_IN_TEARDOWN
+ && !(lockres->l_flags & USER_LOCK_IN_CANCEL)) {
lockres->l_level = LKM_IVMODE;
- else {
+ } else if (status == DLM_CANCELGRANT) {
+ mlog(0, "Lock %s, cancel fails, flags 0x%x\n",
+ lockres->l_name, lockres->l_flags);
+ /* We tried to cancel a convert request, but it was
+ * already granted. Don't clear the busy flag - the
+ * ast should've done this already. */
+ BUG_ON(!(lockres->l_flags & USER_LOCK_IN_CANCEL));
+ lockres->l_flags &= ~USER_LOCK_IN_CANCEL;
+ goto out_noclear;
+ } else {
+ BUG_ON(!(lockres->l_flags & USER_LOCK_IN_CANCEL));
+ /* Cancel succeeded, we want to re-queue */
+ mlog(0, "Lock %s, cancel succeeds, flags 0x%x\n",
+ lockres->l_name, lockres->l_flags);
lockres->l_requested = LKM_IVMODE; /* cancel an
* upconvert
* request. */
lockres->l_flags &= ~USER_LOCK_IN_CANCEL;
/* we want the unblock thread to look at it again
* now. */
- __user_dlm_queue_lockres(lockres);
+ if (lockres->l_flags & USER_LOCK_BLOCKED)
+ __user_dlm_queue_lockres(lockres);
}
lockres->l_flags &= ~USER_LOCK_BUSY;
+out_noclear:
spin_unlock(&lockres->l_lock);
wake_up(&lockres->l_event);
@@ -268,13 +291,26 @@ static void user_dlm_unblock_lock(void *opaque)
spin_lock(&lockres->l_lock);
- BUG_ON(!(lockres->l_flags & USER_LOCK_BLOCKED));
- BUG_ON(!(lockres->l_flags & USER_LOCK_QUEUED));
+ mlog_bug_on_msg(!(lockres->l_flags & USER_LOCK_QUEUED),
+ "Lockres %s, flags 0x%x\n",
+ lockres->l_name, lockres->l_flags);
- /* notice that we don't clear USER_LOCK_BLOCKED here. That's
- * for user_ast to do. */
+ /* notice that we don't clear USER_LOCK_BLOCKED here. If it's
+ * set, we want user_ast clear it. */
lockres->l_flags &= ~USER_LOCK_QUEUED;
+ /* It's valid to get here and no longer be blocked - if we get
+ * several basts in a row, we might be queued by the first
+ * one, the unblock thread might run and clear the queued
+ * flag, and finally we might get another bast which re-queues
+ * us before our ast for the downconvert is called. */
+ if (!(lockres->l_flags & USER_LOCK_BLOCKED)) {
+ mlog(0, "Lockres %s, flags 0x%x: queued but not blocking\n",
+ lockres->l_name, lockres->l_flags);
+ spin_unlock(&lockres->l_lock);
+ goto drop_ref;
+ }
+
if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
mlog(0, "lock is in teardown so we do nothing\n");
spin_unlock(&lockres->l_lock);
@@ -282,7 +318,9 @@ static void user_dlm_unblock_lock(void *opaque)
}
if (lockres->l_flags & USER_LOCK_BUSY) {
- mlog(0, "BUSY flag detected...\n");
+ mlog(0, "Cancel lock %s, flags 0x%x\n",
+ lockres->l_name, lockres->l_flags);
+
if (lockres->l_flags & USER_LOCK_IN_CANCEL) {
spin_unlock(&lockres->l_lock);
goto drop_ref;
@@ -296,14 +334,7 @@ static void user_dlm_unblock_lock(void *opaque)
LKM_CANCEL,
user_unlock_ast,
lockres);
- if (status == DLM_CANCELGRANT) {
- /* If we got this, then the ast was fired
- * before we could cancel. We cleanup our
- * state, and restart the function. */
- spin_lock(&lockres->l_lock);
- lockres->l_flags &= ~USER_LOCK_IN_CANCEL;
- spin_unlock(&lockres->l_lock);
- } else if (status != DLM_NORMAL)
+ if (status != DLM_NORMAL)
user_log_dlm_error("dlmunlock", status, lockres);
goto drop_ref;
}
@@ -581,6 +612,14 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
mlog(0, "asked to destroy %s\n", lockres->l_name);
spin_lock(&lockres->l_lock);
+ if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
+ mlog(0, "Lock is already torn down\n");
+ spin_unlock(&lockres->l_lock);
+ return 0;
+ }
+
+ lockres->l_flags |= USER_LOCK_IN_TEARDOWN;
+
while (lockres->l_flags & USER_LOCK_BUSY) {
spin_unlock(&lockres->l_lock);
@@ -606,7 +645,6 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
lockres->l_flags &= ~USER_LOCK_ATTACHED;
lockres->l_flags |= USER_LOCK_BUSY;
- lockres->l_flags |= USER_LOCK_IN_TEARDOWN;
spin_unlock(&lockres->l_lock);
mlog(0, "unlocking lockres %s\n", lockres->l_name);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 34e903a6a46b2..581eb451a41a3 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -260,6 +260,17 @@ static int ocfs2_truncate_file(struct inode *inode,
if (new_i_size == le64_to_cpu(fe->i_size))
goto bail;
+ /* This forces other nodes to sync and drop their pages. Do
+ * this even if we have a truncate without allocation change -
+ * ocfs2 cluster sizes can be much greater than page size, so
+ * we have to truncate them anyway. */
+ status = ocfs2_data_lock(inode, 1);
+ if (status < 0) {
+ mlog_errno(status);
+ goto bail;
+ }
+ ocfs2_data_unlock(inode, 1);
+
if (le32_to_cpu(fe->i_clusters) ==
ocfs2_clusters_for_bytes(osb->sb, new_i_size)) {
mlog(0, "fe->i_clusters = %u, so we do a simple truncate\n",
@@ -272,14 +283,6 @@ static int ocfs2_truncate_file(struct inode *inode,
goto bail;
}
- /* This forces other nodes to sync and drop their pages */
- status = ocfs2_data_lock(inode, 1);
- if (status < 0) {
- mlog_errno(status);
- goto bail;
- }
- ocfs2_data_unlock(inode, 1);
-
/* alright, we're going to need to do a full blown alloc size
* change. Orphan the inode so that recovery can complete the
* truncate if necessary. This does the task of marking
diff --git a/fs/pipe.c b/fs/pipe.c
index 109a102c150d3..e984beb93a0ea 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -36,7 +36,7 @@
*/
/* Drop the inode semaphore and wait for a pipe event, atomically */
-void pipe_wait(struct inode * inode)
+void pipe_wait(struct pipe_inode_info *pipe)
{
DEFINE_WAIT(wait);
@@ -44,11 +44,14 @@ void pipe_wait(struct inode * inode)
* Pipes are system-local resources, so sleeping on them
* is considered a noninteractive wait:
*/
- prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE);
- mutex_unlock(PIPE_MUTEX(*inode));
+ prepare_to_wait(&pipe->wait, &wait,
+ TASK_INTERRUPTIBLE | TASK_NONINTERACTIVE);
+ if (pipe->inode)
+ mutex_unlock(&pipe->inode->i_mutex);
schedule();
- finish_wait(PIPE_WAIT(*inode), &wait);
- mutex_lock(PIPE_MUTEX(*inode));
+ finish_wait(&pipe->wait, &wait);
+ if (pipe->inode)
+ mutex_lock(&pipe->inode->i_mutex);
}
static int
@@ -91,40 +94,40 @@ pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len)
return 0;
}
-static void anon_pipe_buf_release(struct pipe_inode_info *info, struct pipe_buffer *buf)
+static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
+ struct pipe_buffer *buf)
{
struct page *page = buf->page;
+ buf->flags &= ~PIPE_BUF_FLAG_STOLEN;
+
/*
* If nobody else uses this page, and we don't already have a
* temporary page, let's keep track of it as a one-deep
- * allocation cache
- */
- if (page_count(page) == 1 && !info->tmp_page) {
- info->tmp_page = page;
- return;
- }
-
- /*
- * Otherwise just release our reference to it
+ * allocation cache. (Otherwise just release our reference to it)
*/
- page_cache_release(page);
+ if (page_count(page) == 1 && !pipe->tmp_page)
+ pipe->tmp_page = page;
+ else
+ page_cache_release(page);
}
-static void *anon_pipe_buf_map(struct file *file, struct pipe_inode_info *info, struct pipe_buffer *buf)
+static void * anon_pipe_buf_map(struct file *file, struct pipe_inode_info *pipe,
+ struct pipe_buffer *buf)
{
return kmap(buf->page);
}
-static void anon_pipe_buf_unmap(struct pipe_inode_info *info, struct pipe_buffer *buf)
+static void anon_pipe_buf_unmap(struct pipe_inode_info *pipe,
+ struct pipe_buffer *buf)
{
kunmap(buf->page);
}
-static int anon_pipe_buf_steal(struct pipe_inode_info *info,
+static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
struct pipe_buffer *buf)
{
- buf->stolen = 1;
+ buf->flags |= PIPE_BUF_FLAG_STOLEN;
return 0;
}
@@ -141,7 +144,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
unsigned long nr_segs, loff_t *ppos)
{
struct inode *inode = filp->f_dentry->d_inode;
- struct pipe_inode_info *info;
+ struct pipe_inode_info *pipe;
int do_wakeup;
ssize_t ret;
struct iovec *iov = (struct iovec *)_iov;
@@ -154,13 +157,13 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
do_wakeup = 0;
ret = 0;
- mutex_lock(PIPE_MUTEX(*inode));
- info = inode->i_pipe;
+ mutex_lock(&inode->i_mutex);
+ pipe = inode->i_pipe;
for (;;) {
- int bufs = info->nrbufs;
+ int bufs = pipe->nrbufs;
if (bufs) {
- int curbuf = info->curbuf;
- struct pipe_buffer *buf = info->bufs + curbuf;
+ int curbuf = pipe->curbuf;
+ struct pipe_buffer *buf = pipe->bufs + curbuf;
struct pipe_buf_operations *ops = buf->ops;
void *addr;
size_t chars = buf->len;
@@ -169,16 +172,17 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
if (chars > total_len)
chars = total_len;
- addr = ops->map(filp, info, buf);
+ addr = ops->map(filp, pipe, buf);
if (IS_ERR(addr)) {
if (!ret)
ret = PTR_ERR(addr);
break;
}
error = pipe_iov_copy_to_user(iov, addr + buf->offset, chars);
- ops->unmap(info, buf);
+ ops->unmap(pipe, buf);
if (unlikely(error)) {
- if (!ret) ret = -EFAULT;
+ if (!ret)
+ ret = -EFAULT;
break;
}
ret += chars;
@@ -186,10 +190,10 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
buf->len -= chars;
if (!buf->len) {
buf->ops = NULL;
- ops->release(info, buf);
+ ops->release(pipe, buf);
curbuf = (curbuf + 1) & (PIPE_BUFFERS-1);
- info->curbuf = curbuf;
- info->nrbufs = --bufs;
+ pipe->curbuf = curbuf;
+ pipe->nrbufs = --bufs;
do_wakeup = 1;
}
total_len -= chars;
@@ -198,9 +202,9 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
}
if (bufs) /* More to do? */
continue;
- if (!PIPE_WRITERS(*inode))
+ if (!pipe->writers)
break;
- if (!PIPE_WAITING_WRITERS(*inode)) {
+ if (!pipe->waiting_writers) {
/* syscall merging: Usually we must not sleep
* if O_NONBLOCK is set, or if we got some data.
* But if a writer sleeps in kernel space, then
@@ -214,20 +218,22 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
}
}
if (signal_pending(current)) {
- if (!ret) ret = -ERESTARTSYS;
+ if (!ret)
+ ret = -ERESTARTSYS;
break;
}
if (do_wakeup) {
- wake_up_interruptible_sync(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
+ wake_up_interruptible_sync(&pipe->wait);
+ kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
- pipe_wait(inode);
+ pipe_wait(pipe);
}
- mutex_unlock(PIPE_MUTEX(*inode));
- /* Signal writers asynchronously that there is more room. */
+ mutex_unlock(&inode->i_mutex);
+
+ /* Signal writers asynchronously that there is more room. */
if (do_wakeup) {
- wake_up_interruptible(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
+ wake_up_interruptible(&pipe->wait);
+ kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
if (ret > 0)
file_accessed(filp);
@@ -238,6 +244,7 @@ static ssize_t
pipe_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
{
struct iovec iov = { .iov_base = buf, .iov_len = count };
+
return pipe_readv(filp, &iov, 1, ppos);
}
@@ -246,7 +253,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
unsigned long nr_segs, loff_t *ppos)
{
struct inode *inode = filp->f_dentry->d_inode;
- struct pipe_inode_info *info;
+ struct pipe_inode_info *pipe;
ssize_t ret;
int do_wakeup;
struct iovec *iov = (struct iovec *)_iov;
@@ -260,10 +267,10 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
do_wakeup = 0;
ret = 0;
- mutex_lock(PIPE_MUTEX(*inode));
- info = inode->i_pipe;
+ mutex_lock(&inode->i_mutex);
+ pipe = inode->i_pipe;
- if (!PIPE_READERS(*inode)) {
+ if (!pipe->readers) {
send_sig(SIGPIPE, current, 0);
ret = -EPIPE;
goto out;
@@ -271,23 +278,25 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
/* We try to merge small writes */
chars = total_len & (PAGE_SIZE-1); /* size of the last buffer */
- if (info->nrbufs && chars != 0) {
- int lastbuf = (info->curbuf + info->nrbufs - 1) & (PIPE_BUFFERS-1);
- struct pipe_buffer *buf = info->bufs + lastbuf;
+ if (pipe->nrbufs && chars != 0) {
+ int lastbuf = (pipe->curbuf + pipe->nrbufs - 1) &
+ (PIPE_BUFFERS-1);
+ struct pipe_buffer *buf = pipe->bufs + lastbuf;
struct pipe_buf_operations *ops = buf->ops;
int offset = buf->offset + buf->len;
+
if (ops->can_merge && offset + chars <= PAGE_SIZE) {
void *addr;
int error;
- addr = ops->map(filp, info, buf);
+ addr = ops->map(filp, pipe, buf);
if (IS_ERR(addr)) {
error = PTR_ERR(addr);
goto out;
}
error = pipe_iov_copy_from_user(offset + addr, iov,
chars);
- ops->unmap(info, buf);
+ ops->unmap(pipe, buf);
ret = error;
do_wakeup = 1;
if (error)
@@ -302,16 +311,18 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
for (;;) {
int bufs;
- if (!PIPE_READERS(*inode)) {
+
+ if (!pipe->readers) {
send_sig(SIGPIPE, current, 0);
- if (!ret) ret = -EPIPE;
+ if (!ret)
+ ret = -EPIPE;
break;
}
- bufs = info->nrbufs;
+ bufs = pipe->nrbufs;
if (bufs < PIPE_BUFFERS) {
- int newbuf = (info->curbuf + bufs) & (PIPE_BUFFERS-1);
- struct pipe_buffer *buf = info->bufs + newbuf;
- struct page *page = info->tmp_page;
+ int newbuf = (pipe->curbuf + bufs) & (PIPE_BUFFERS-1);
+ struct pipe_buffer *buf = pipe->bufs + newbuf;
+ struct page *page = pipe->tmp_page;
int error;
if (!page) {
@@ -320,9 +331,9 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
ret = ret ? : -ENOMEM;
break;
}
- info->tmp_page = page;
+ pipe->tmp_page = page;
}
- /* Always wakeup, even if the copy fails. Otherwise
+ /* Always wake up, even if the copy fails. Otherwise
* we lock up (O_NONBLOCK-)readers that sleep due to
* syscall merging.
* FIXME! Is this really true?
@@ -335,7 +346,8 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
error = pipe_iov_copy_from_user(kmap(page), iov, chars);
kunmap(page);
if (unlikely(error)) {
- if (!ret) ret = -EFAULT;
+ if (!ret)
+ ret = -EFAULT;
break;
}
ret += chars;
@@ -345,8 +357,8 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
buf->ops = &anon_pipe_buf_ops;
buf->offset = 0;
buf->len = chars;
- info->nrbufs = ++bufs;
- info->tmp_page = NULL;
+ pipe->nrbufs = ++bufs;
+ pipe->tmp_page = NULL;
total_len -= chars;
if (!total_len)
@@ -355,27 +367,29 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
if (bufs < PIPE_BUFFERS)
continue;
if (filp->f_flags & O_NONBLOCK) {
- if (!ret) ret = -EAGAIN;
+ if (!ret)
+ ret = -EAGAIN;
break;
}
if (signal_pending(current)) {
- if (!ret) ret = -ERESTARTSYS;
+ if (!ret)
+ ret = -ERESTARTSYS;
break;
}
if (do_wakeup) {
- wake_up_interruptible_sync(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
+ wake_up_interruptible_sync(&pipe->wait);
+ kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
do_wakeup = 0;
}
- PIPE_WAITING_WRITERS(*inode)++;
- pipe_wait(inode);
- PIPE_WAITING_WRITERS(*inode)--;
+ pipe->waiting_writers++;
+ pipe_wait(pipe);
+ pipe->waiting_writers--;
}
out:
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_unlock(&inode->i_mutex);
if (do_wakeup) {
- wake_up_interruptible(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
+ wake_up_interruptible(&pipe->wait);
+ kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
}
if (ret > 0)
file_update_time(filp);
@@ -387,6 +401,7 @@ pipe_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count };
+
return pipe_writev(filp, &iov, 1, ppos);
}
@@ -397,7 +412,8 @@ bad_pipe_r(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
}
static ssize_t
-bad_pipe_w(struct file *filp, const char __user *buf, size_t count, loff_t *ppos)
+bad_pipe_w(struct file *filp, const char __user *buf, size_t count,
+ loff_t *ppos)
{
return -EBADF;
}
@@ -407,21 +423,22 @@ pipe_ioctl(struct inode *pino, struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct inode *inode = filp->f_dentry->d_inode;
- struct pipe_inode_info *info;
+ struct pipe_inode_info *pipe;
int count, buf, nrbufs;
switch (cmd) {
case FIONREAD:
- mutex_lock(PIPE_MUTEX(*inode));
- info = inode->i_pipe;
+ mutex_lock(&inode->i_mutex);
+ pipe = inode->i_pipe;
count = 0;
- buf = info->curbuf;
- nrbufs = info->nrbufs;
+ buf = pipe->curbuf;
+ nrbufs = pipe->nrbufs;
while (--nrbufs >= 0) {
- count += info->bufs[buf].len;
+ count += pipe->bufs[buf].len;
buf = (buf+1) & (PIPE_BUFFERS-1);
}
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_unlock(&inode->i_mutex);
+
return put_user(count, (int __user *)arg);
default:
return -EINVAL;
@@ -434,17 +451,17 @@ pipe_poll(struct file *filp, poll_table *wait)
{
unsigned int mask;
struct inode *inode = filp->f_dentry->d_inode;
- struct pipe_inode_info *info = inode->i_pipe;
+ struct pipe_inode_info *pipe = inode->i_pipe;
int nrbufs;
- poll_wait(filp, PIPE_WAIT(*inode), wait);
+ poll_wait(filp, &pipe->wait, wait);
/* Reading only -- no need for acquiring the semaphore. */
- nrbufs = info->nrbufs;
+ nrbufs = pipe->nrbufs;
mask = 0;
if (filp->f_mode & FMODE_READ) {
mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
- if (!PIPE_WRITERS(*inode) && filp->f_version != PIPE_WCOUNTER(*inode))
+ if (!pipe->writers && filp->f_version != pipe->w_counter)
mask |= POLLHUP;
}
@@ -454,7 +471,7 @@ pipe_poll(struct file *filp, poll_table *wait)
* Most Unices do not set POLLERR for FIFOs but on Linux they
* behave exactly like pipes for poll().
*/
- if (!PIPE_READERS(*inode))
+ if (!pipe->readers)
mask |= POLLERR;
}
@@ -464,17 +481,21 @@ pipe_poll(struct file *filp, poll_table *wait)
static int
pipe_release(struct inode *inode, int decr, int decw)
{
- mutex_lock(PIPE_MUTEX(*inode));
- PIPE_READERS(*inode) -= decr;
- PIPE_WRITERS(*inode) -= decw;
- if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
+ struct pipe_inode_info *pipe;
+
+ mutex_lock(&inode->i_mutex);
+ pipe = inode->i_pipe;
+ pipe->readers -= decr;
+ pipe->writers -= decw;
+
+ if (!pipe->readers && !pipe->writers) {
free_pipe_info(inode);
} else {
- wake_up_interruptible(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
- kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
+ wake_up_interruptible(&pipe->wait);
+ kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
+ kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_unlock(&inode->i_mutex);
return 0;
}
@@ -485,9 +506,9 @@ pipe_read_fasync(int fd, struct file *filp, int on)
struct inode *inode = filp->f_dentry->d_inode;
int retval;
- mutex_lock(PIPE_MUTEX(*inode));
- retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_lock(&inode->i_mutex);
+ retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
+ mutex_unlock(&inode->i_mutex);
if (retval < 0)
return retval;
@@ -502,9 +523,9 @@ pipe_write_fasync(int fd, struct file *filp, int on)
struct inode *inode = filp->f_dentry->d_inode;
int retval;
- mutex_lock(PIPE_MUTEX(*inode));
- retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_lock(&inode->i_mutex);
+ retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
+ mutex_unlock(&inode->i_mutex);
if (retval < 0)
return retval;
@@ -517,16 +538,17 @@ static int
pipe_rdwr_fasync(int fd, struct file *filp, int on)
{
struct inode *inode = filp->f_dentry->d_inode;
+ struct pipe_inode_info *pipe = inode->i_pipe;
int retval;
- mutex_lock(PIPE_MUTEX(*inode));
+ mutex_lock(&inode->i_mutex);
- retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
+ retval = fasync_helper(fd, filp, on, &pipe->fasync_readers);
if (retval >= 0)
- retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
+ retval = fasync_helper(fd, filp, on, &pipe->fasync_writers);
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_unlock(&inode->i_mutex);
if (retval < 0)
return retval;
@@ -565,9 +587,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
{
/* We could have perhaps used atomic_t, but this and friends
below are the only places. So it doesn't seem worthwhile. */
- mutex_lock(PIPE_MUTEX(*inode));
- PIPE_READERS(*inode)++;
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_lock(&inode->i_mutex);
+ inode->i_pipe->readers++;
+ mutex_unlock(&inode->i_mutex);
return 0;
}
@@ -575,9 +597,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
static int
pipe_write_open(struct inode *inode, struct file *filp)
{
- mutex_lock(PIPE_MUTEX(*inode));
- PIPE_WRITERS(*inode)++;
- mutex_unlock(PIPE_MUTEX(*inode));
+ mutex_lock(&inode->i_mutex);
+ inode->i_pipe->writers++;
+ mutex_unlock(&inode->i_mutex);
return 0;
}
@@ -585,12 +607,12 @@ pipe_write_open(struct inode *inode, struct file *filp)
static int
pipe_rdwr_open(struct inode *inode, struct file *filp)
{
- mutex_lock(PIPE_MUTEX(*inode));
+ mutex_lock(&inode->i_mutex);
if (filp->f_mode & FMODE_READ)
- PIPE_READERS(*inode)++;
+ inode->i_pipe->readers++;
if (filp->f_mode & FMODE_WRITE)
- PIPE_WRITERS(*inode)++;
- mutex_unlock(PIPE_MUTEX(*inode));
+ inode->i_pipe->writers++;
+ mutex_unlock(&inode->i_mutex);
return 0;
}
@@ -673,37 +695,38 @@ static struct file_operations rdwr_pipe_fops = {
.fasync = pipe_rdwr_fasync,
};
-void free_pipe_info(struct inode *inode)
+struct pipe_inode_info * alloc_pipe_info(struct inode *inode)
+{
+ struct pipe_inode_info *pipe;
+
+ pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
+ if (pipe) {
+ init_waitqueue_head(&pipe->wait);
+ pipe->r_counter = pipe->w_counter = 1;
+ pipe->inode = inode;
+ }
+
+ return pipe;
+}
+
+void __free_pipe_info(struct pipe_inode_info *pipe)
{
int i;
- struct pipe_inode_info *info = inode->i_pipe;
- inode->i_pipe = NULL;
for (i = 0; i < PIPE_BUFFERS; i++) {
- struct pipe_buffer *buf = info->bufs + i;
+ struct pipe_buffer *buf = pipe->bufs + i;
if (buf->ops)
- buf->ops->release(info, buf);
+ buf->ops->release(pipe, buf);
}
- if (info->tmp_page)
- __free_page(info->tmp_page);
- kfree(info);
+ if (pipe->tmp_page)
+ __free_page(pipe->tmp_page);
+ kfree(pipe);
}
-struct inode* pipe_new(struct inode* inode)
+void free_pipe_info(struct inode *inode)
{
- struct pipe_inode_info *info;
-
- info = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
- if (!info)
- goto fail_page;
- inode->i_pipe = info;
-
- init_waitqueue_head(PIPE_WAIT(*inode));
- PIPE_RCOUNTER(*inode) = PIPE_WCOUNTER(*inode) = 1;
-
- return inode;
-fail_page:
- return NULL;
+ __free_pipe_info(inode->i_pipe);
+ inode->i_pipe = NULL;
}
static struct vfsmount *pipe_mnt __read_mostly;
@@ -711,6 +734,7 @@ static int pipefs_delete_dentry(struct dentry *dentry)
{
return 1;
}
+
static struct dentry_operations pipefs_dentry_operations = {
.d_delete = pipefs_delete_dentry,
};
@@ -718,13 +742,17 @@ static struct dentry_operations pipefs_dentry_operations = {
static struct inode * get_pipe_inode(void)
{
struct inode *inode = new_inode(pipe_mnt->mnt_sb);
+ struct pipe_inode_info *pipe;
if (!inode)
goto fail_inode;
- if(!pipe_new(inode))
+ pipe = alloc_pipe_info(inode);
+ if (!pipe)
goto fail_iput;
- PIPE_READERS(*inode) = PIPE_WRITERS(*inode) = 1;
+ inode->i_pipe = pipe;
+
+ pipe->readers = pipe->writers = 1;
inode->i_fop = &rdwr_pipe_fops;
/*
@@ -739,10 +767,12 @@ static struct inode * get_pipe_inode(void)
inode->i_gid = current->fsgid;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_blksize = PAGE_SIZE;
+
return inode;
fail_iput:
iput(inode);
+
fail_inode:
return NULL;
}
@@ -755,7 +785,7 @@ int do_pipe(int *fd)
struct inode * inode;
struct file *f1, *f2;
int error;
- int i,j;
+ int i, j;
error = -ENFILE;
f1 = get_empty_filp();
@@ -788,6 +818,7 @@ int do_pipe(int *fd)
dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this);
if (!dentry)
goto close_f12_inode_i_j;
+
dentry->d_op = &pipefs_dentry_operations;
d_add(dentry, inode);
f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt));
@@ -811,6 +842,7 @@ int do_pipe(int *fd)
fd_install(j, f2);
fd[0] = i;
fd[1] = j;
+
return 0;
close_f12_inode_i_j:
@@ -835,8 +867,9 @@ no_files:
* d_name - pipe: will go nicely and kill the special-casing in procfs.
*/
-static struct super_block *pipefs_get_sb(struct file_system_type *fs_type,
- int flags, const char *dev_name, void *data)
+static struct super_block *
+pipefs_get_sb(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data)
{
return get_sb_pseudo(fs_type, "pipe:", NULL, PIPEFS_MAGIC);
}
@@ -850,6 +883,7 @@ static struct file_system_type pipe_fs_type = {
static int __init init_pipe_fs(void)
{
int err = register_filesystem(&pipe_fs_type);
+
if (!err) {
pipe_mnt = kern_mount(&pipe_fs_type);
if (IS_ERR(pipe_mnt)) {
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 7efa73d44c9a5..20d4b2237fcef 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -103,8 +103,8 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
size_t buflen, loff_t *fpos)
{
ssize_t acc = 0, tmp;
- size_t tsz, nr_bytes;
- u64 start;
+ size_t tsz;
+ u64 start, nr_bytes;
struct vmcore *curr_m = NULL;
if (buflen == 0 || *fpos >= vmcore_size)
diff --git a/fs/read_write.c b/fs/read_write.c
index 6256ca81a7186..5bc0e9234f9d7 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -202,7 +202,7 @@ int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count
goto Einval;
inode = file->f_dentry->d_inode;
- if (inode->i_flock && MANDATORY_LOCK(inode)) {
+ if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) {
int retval = locks_mandatory_area(
read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,
inode, file, pos, count);
diff --git a/fs/select.c b/fs/select.c
index 071660fa7b01e..a8109baa5e464 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -310,8 +310,9 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
fd_set __user *exp, s64 *timeout)
{
fd_set_bits fds;
- char *bits;
- int ret, size, max_fdset;
+ void *bits;
+ int ret, max_fdset;
+ unsigned int size;
struct fdtable *fdt;
/* Allocate small arguments on the stack to save memory and be faster */
long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
@@ -333,20 +334,21 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
* since we used fdset we need to allocate memory in units of
* long-words.
*/
- ret = -ENOMEM;
size = FDS_BYTES(n);
- if (6*size < SELECT_STACK_ALLOC)
- bits = stack_fds;
- else
+ bits = stack_fds;
+ if (size > sizeof(stack_fds) / 6) {
+ /* Not enough space in on-stack array; must use kmalloc */
+ ret = -ENOMEM;
bits = kmalloc(6 * size, GFP_KERNEL);
- if (!bits)
- goto out_nofds;
- fds.in = (unsigned long *) bits;
- fds.out = (unsigned long *) (bits + size);
- fds.ex = (unsigned long *) (bits + 2*size);
- fds.res_in = (unsigned long *) (bits + 3*size);
- fds.res_out = (unsigned long *) (bits + 4*size);
- fds.res_ex = (unsigned long *) (bits + 5*size);
+ if (!bits)
+ goto out_nofds;
+ }
+ fds.in = bits;
+ fds.out = bits + size;
+ fds.ex = bits + 2*size;
+ fds.res_in = bits + 3*size;
+ fds.res_out = bits + 4*size;
+ fds.res_ex = bits + 5*size;
if ((ret = get_fd_set(n, inp, fds.in)) ||
(ret = get_fd_set(n, outp, fds.out)) ||
diff --git a/fs/splice.c b/fs/splice.c
index 6081cf7d2d1ba..e50a460239dd2 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -9,11 +9,12 @@
* that transfers data buffers to or from a pipe buffer.
*
* Named by Larry McVoy, original implementation from Linus, extended by
- * Jens to support splicing to files and fixing the initial implementation
- * bugs.
+ * Jens to support splicing to files, network, direct splicing, etc and
+ * fixing lots of bugs.
*
- * Copyright (C) 2005 Jens Axboe <axboe@suse.de>
- * Copyright (C) 2005 Linus Torvalds <torvalds@osdl.org>
+ * Copyright (C) 2005-2006 Jens Axboe <axboe@suse.de>
+ * Copyright (C) 2005-2006 Linus Torvalds <torvalds@osdl.org>
+ * Copyright (C) 2006 Ingo Molnar <mingo@elte.hu>
*
*/
#include <linux/fs.h>
@@ -22,7 +23,10 @@
#include <linux/pipe_fs_i.h>
#include <linux/mm_inline.h>
#include <linux/swap.h>
+#include <linux/writeback.h>
+#include <linux/buffer_head.h>
#include <linux/module.h>
+#include <linux/syscalls.h>
/*
* Passed to the actors
@@ -34,28 +38,37 @@ struct splice_desc {
loff_t pos; /* file position */
};
+/*
+ * Attempt to steal a page from a pipe buffer. This should perhaps go into
+ * a vm helper function, it's already simplified quite a bit by the
+ * addition of remove_mapping(). If success is returned, the caller may
+ * attempt to reuse this page for another destination.
+ */
static int page_cache_pipe_buf_steal(struct pipe_inode_info *info,
struct pipe_buffer *buf)
{
struct page *page = buf->page;
+ struct address_space *mapping = page_mapping(page);
WARN_ON(!PageLocked(page));
WARN_ON(!PageUptodate(page));
- if (!remove_mapping(page_mapping(page), page))
- return 1;
+ /*
+ * At least for ext2 with nobh option, we need to wait on writeback
+ * completing on this page, since we'll remove it from the pagecache.
+ * Otherwise truncate wont wait on the page, allowing the disk
+ * blocks to be reused by someone else before we actually wrote our
+ * data to them. fs corruption ensues.
+ */
+ wait_on_page_writeback(page);
- if (PageLRU(page)) {
- struct zone *zone = page_zone(page);
+ if (PagePrivate(page))
+ try_to_release_page(page, mapping_gfp_mask(mapping));
- spin_lock_irq(&zone->lru_lock);
- BUG_ON(!PageLRU(page));
- __ClearPageLRU(page);
- del_page_from_lru(zone, page);
- spin_unlock_irq(&zone->lru_lock);
- }
+ if (!remove_mapping(mapping, page))
+ return 1;
- buf->stolen = 1;
+ buf->flags |= PIPE_BUF_FLAG_STOLEN | PIPE_BUF_FLAG_LRU;
return 0;
}
@@ -64,7 +77,7 @@ static void page_cache_pipe_buf_release(struct pipe_inode_info *info,
{
page_cache_release(buf->page);
buf->page = NULL;
- buf->stolen = 0;
+ buf->flags &= ~(PIPE_BUF_FLAG_STOLEN | PIPE_BUF_FLAG_LRU);
}
static void *page_cache_pipe_buf_map(struct file *file,
@@ -72,27 +85,43 @@ static void *page_cache_pipe_buf_map(struct file *file,
struct pipe_buffer *buf)
{
struct page *page = buf->page;
-
- lock_page(page);
+ int err;
if (!PageUptodate(page)) {
- unlock_page(page);
- return ERR_PTR(-EIO);
- }
+ lock_page(page);
- if (!page->mapping) {
+ /*
+ * Page got truncated/unhashed. This will cause a 0-byte
+ * splice, if this is the first page.
+ */
+ if (!page->mapping) {
+ err = -ENODATA;
+ goto error;
+ }
+
+ /*
+ * Uh oh, read-error from disk.
+ */
+ if (!PageUptodate(page)) {
+ err = -EIO;
+ goto error;
+ }
+
+ /*
+ * Page is ok afterall, fall through to mapping.
+ */
unlock_page(page);
- return ERR_PTR(-ENODATA);
}
- return kmap(buf->page);
+ return kmap(page);
+error:
+ unlock_page(page);
+ return ERR_PTR(err);
}
static void page_cache_pipe_buf_unmap(struct pipe_inode_info *info,
struct pipe_buffer *buf)
{
- if (!buf->stolen)
- unlock_page(buf->page);
kunmap(buf->page);
}
@@ -104,34 +133,34 @@ static struct pipe_buf_operations page_cache_pipe_buf_ops = {
.steal = page_cache_pipe_buf_steal,
};
-static ssize_t move_to_pipe(struct inode *inode, struct page **pages,
+/*
+ * Pipe output worker. This sets up our pipe format with the page cache
+ * pipe buffer operations. Otherwise very similar to the regular pipe_writev().
+ */
+static ssize_t move_to_pipe(struct pipe_inode_info *pipe, struct page **pages,
int nr_pages, unsigned long offset,
unsigned long len, unsigned int flags)
{
- struct pipe_inode_info *info;
int ret, do_wakeup, i;
ret = 0;
do_wakeup = 0;
i = 0;
- mutex_lock(PIPE_MUTEX(*inode));
+ if (pipe->inode)
+ mutex_lock(&pipe->inode->i_mutex);
- info = inode->i_pipe;
for (;;) {
- int bufs;
-
- if (!PIPE_READERS(*inode)) {
+ if (!pipe->readers) {
send_sig(SIGPIPE, current, 0);
if (!ret)
ret = -EPIPE;
break;
}
- bufs = info->nrbufs;
- if (bufs < PIPE_BUFFERS) {
- int newbuf = (info->curbuf + bufs) & (PIPE_BUFFERS - 1);
- struct pipe_buffer *buf = info->bufs + newbuf;
+ if (pipe->nrbufs < PIPE_BUFFERS) {
+ int newbuf = (pipe->curbuf + pipe->nrbufs) & (PIPE_BUFFERS - 1);
+ struct pipe_buffer *buf = pipe->bufs + newbuf;
struct page *page = pages[i++];
unsigned long this_len;
@@ -143,8 +172,9 @@ static ssize_t move_to_pipe(struct inode *inode, struct page **pages,
buf->offset = offset;
buf->len = this_len;
buf->ops = &page_cache_pipe_buf_ops;
- info->nrbufs = ++bufs;
- do_wakeup = 1;
+ pipe->nrbufs++;
+ if (pipe->inode)
+ do_wakeup = 1;
ret += this_len;
len -= this_len;
@@ -153,7 +183,7 @@ static ssize_t move_to_pipe(struct inode *inode, struct page **pages,
break;
if (!len)
break;
- if (bufs < PIPE_BUFFERS)
+ if (pipe->nrbufs < PIPE_BUFFERS)
continue;
break;
@@ -172,22 +202,26 @@ static ssize_t move_to_pipe(struct inode *inode, struct page **pages,
}
if (do_wakeup) {
- wake_up_interruptible_sync(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO,
- POLL_IN);
+ smp_mb();
+ if (waitqueue_active(&pipe->wait))
+ wake_up_interruptible_sync(&pipe->wait);
+ kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
do_wakeup = 0;
}
- PIPE_WAITING_WRITERS(*inode)++;
- pipe_wait(inode);
- PIPE_WAITING_WRITERS(*inode)--;
+ pipe->waiting_writers++;
+ pipe_wait(pipe);
+ pipe->waiting_writers--;
}
- mutex_unlock(PIPE_MUTEX(*inode));
+ if (pipe->inode)
+ mutex_unlock(&pipe->inode->i_mutex);
if (do_wakeup) {
- wake_up_interruptible(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
+ smp_mb();
+ if (waitqueue_active(&pipe->wait))
+ wake_up_interruptible(&pipe->wait);
+ kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
}
while (i < nr_pages)
@@ -196,15 +230,16 @@ static ssize_t move_to_pipe(struct inode *inode, struct page **pages,
return ret;
}
-static int __generic_file_splice_read(struct file *in, struct inode *pipe,
- size_t len, unsigned int flags)
+static int
+__generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
+ size_t len, unsigned int flags)
{
struct address_space *mapping = in->f_mapping;
unsigned int offset, nr_pages;
- struct page *pages[PIPE_BUFFERS], *shadow[PIPE_BUFFERS];
+ struct page *pages[PIPE_BUFFERS];
struct page *page;
- pgoff_t index, pidx;
- int i, j;
+ pgoff_t index;
+ int i, error;
index = in->f_pos >> PAGE_CACHE_SHIFT;
offset = in->f_pos & ~PAGE_CACHE_MASK;
@@ -214,81 +249,106 @@ static int __generic_file_splice_read(struct file *in, struct inode *pipe,
nr_pages = PIPE_BUFFERS;
/*
- * initiate read-ahead on this page range
+ * Initiate read-ahead on this page range. however, don't call into
+ * read-ahead if this is a non-zero offset (we are likely doing small
+ * chunk splice and the page is already there) for a single page.
*/
- do_page_cache_readahead(mapping, in, index, nr_pages);
+ if (!offset || nr_pages > 1)
+ do_page_cache_readahead(mapping, in, index, nr_pages);
/*
- * Get as many pages from the page cache as possible..
- * Start IO on the page cache entries we create (we
- * can assume that any pre-existing ones we find have
- * already had IO started on them).
+ * Now fill in the holes:
*/
- i = find_get_pages(mapping, index, nr_pages, pages);
-
- /*
- * common case - we found all pages and they are contiguous,
- * kick them off
- */
- if (i && (pages[i - 1]->index == index + i - 1))
- goto splice_them;
+ error = 0;
+ for (i = 0; i < nr_pages; i++, index++) {
+find_page:
+ /*
+ * lookup the page for this index
+ */
+ page = find_get_page(mapping, index);
+ if (!page) {
+ /*
+ * If in nonblock mode then dont block on
+ * readpage (we've kicked readahead so there
+ * will be asynchronous progress):
+ */
+ if (flags & SPLICE_F_NONBLOCK)
+ break;
- /*
- * fill shadow[] with pages at the right locations, so we only
- * have to fill holes
- */
- memset(shadow, 0, i * sizeof(struct page *));
- for (j = 0, pidx = index; j < i; pidx++, j++)
- shadow[pages[j]->index - pidx] = pages[j];
+ /*
+ * page didn't exist, allocate one
+ */
+ page = page_cache_alloc_cold(mapping);
+ if (!page)
+ break;
- /*
- * now fill in the holes
- */
- for (i = 0, pidx = index; i < nr_pages; pidx++, i++) {
- int error;
+ error = add_to_page_cache_lru(page, mapping, index,
+ mapping_gfp_mask(mapping));
+ if (unlikely(error)) {
+ page_cache_release(page);
+ break;
+ }
- if (shadow[i])
- continue;
+ goto readpage;
+ }
/*
- * no page there, look one up / create it
+ * If the page isn't uptodate, we may need to start io on it
*/
- page = find_or_create_page(mapping, pidx,
- mapping_gfp_mask(mapping));
- if (!page)
- break;
+ if (!PageUptodate(page)) {
+ lock_page(page);
+
+ /*
+ * page was truncated, stop here. if this isn't the
+ * first page, we'll just complete what we already
+ * added
+ */
+ if (!page->mapping) {
+ unlock_page(page);
+ page_cache_release(page);
+ break;
+ }
+ /*
+ * page was already under io and is now done, great
+ */
+ if (PageUptodate(page)) {
+ unlock_page(page);
+ goto fill_it;
+ }
- if (PageUptodate(page))
- unlock_page(page);
- else {
+readpage:
+ /*
+ * need to read in the page
+ */
error = mapping->a_ops->readpage(in, page);
if (unlikely(error)) {
page_cache_release(page);
+ if (error == AOP_TRUNCATED_PAGE)
+ goto find_page;
break;
}
}
- shadow[i] = page;
- }
-
- if (!i) {
- for (i = 0; i < nr_pages; i++) {
- if (shadow[i])
- page_cache_release(shadow[i]);
- }
- return 0;
+fill_it:
+ pages[i] = page;
}
- memcpy(pages, shadow, i * sizeof(struct page *));
+ if (i)
+ return move_to_pipe(pipe, pages, i, offset, len, flags);
- /*
- * Now we splice them into the pipe..
- */
-splice_them:
- return move_to_pipe(pipe, pages, i, offset, len, flags);
+ return error;
}
-ssize_t generic_file_splice_read(struct file *in, struct inode *pipe,
+/**
+ * generic_file_splice_read - splice data from file to a pipe
+ * @in: file to splice from
+ * @pipe: pipe to splice to
+ * @len: number of bytes to splice
+ * @flags: splice modifier flags
+ *
+ * Will read pages from given file and fill them into a pipe.
+ */
+ssize_t generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
{
ssize_t spliced;
@@ -296,6 +356,7 @@ ssize_t generic_file_splice_read(struct file *in, struct inode *pipe,
ret = 0;
spliced = 0;
+
while (len) {
ret = __generic_file_splice_read(in, pipe, len, flags);
@@ -318,8 +379,11 @@ ssize_t generic_file_splice_read(struct file *in, struct inode *pipe,
return ret;
}
+EXPORT_SYMBOL(generic_file_splice_read);
+
/*
- * Send 'len' bytes to socket from 'file' at position 'pos' using sendpage().
+ * Send 'sd->len' bytes to socket from 'sd->file' at position 'sd->pos'
+ * using sendpage().
*/
static int pipe_to_sendpage(struct pipe_inode_info *info,
struct pipe_buffer *buf, struct splice_desc *sd)
@@ -329,21 +393,22 @@ static int pipe_to_sendpage(struct pipe_inode_info *info,
unsigned int offset;
ssize_t ret;
void *ptr;
+ int more;
/*
- * sub-optimal, but we are limited by the pipe ->map. we don't
+ * Sub-optimal, but we are limited by the pipe ->map. We don't
* need a kmap'ed buffer here, we just want to make sure we
* have the page pinned if the pipe page originates from the
- * page cache
+ * page cache.
*/
ptr = buf->ops->map(file, info, buf);
if (IS_ERR(ptr))
return PTR_ERR(ptr);
offset = pos & ~PAGE_CACHE_MASK;
+ more = (sd->flags & SPLICE_F_MORE) || sd->len < sd->total_len;
- ret = file->f_op->sendpage(file, buf->page, offset, sd->len, &pos,
- sd->len < sd->total_len);
+ ret = file->f_op->sendpage(file, buf->page, offset, sd->len, &pos,more);
buf->ops->unmap(info, buf);
if (ret == sd->len)
@@ -365,16 +430,19 @@ static int pipe_to_sendpage(struct pipe_inode_info *info,
* - Destination page does not exist, we can add the pipe page to
* the page cache and avoid the copy.
*
- * For now we just do the slower thing and always copy pages over, it's
- * easier than migrating pages from the pipe to the target file. For the
- * case of doing file | file splicing, the migrate approach had some LRU
- * nastiness...
+ * If asked to move pages to the output file (SPLICE_F_MOVE is set in
+ * sd->flags), we attempt to migrate pages from the pipe to the output
+ * file address space page cache. This is possible if no one else has
+ * the pipe page referenced outside of the pipe and page cache. If
+ * SPLICE_F_MOVE isn't set, or we cannot move the page, we simply create
+ * a new page in the output file page cache and fill/dirty that.
*/
static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
struct splice_desc *sd)
{
struct file *file = sd->file;
struct address_space *mapping = file->f_mapping;
+ gfp_t gfp_mask = mapping_gfp_mask(mapping);
unsigned int offset;
struct page *page;
pgoff_t index;
@@ -382,7 +450,7 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
int ret;
/*
- * after this, page will be locked and unmapped
+ * make sure the data in this buffer is uptodate
*/
src = buf->ops->map(file, info, buf);
if (IS_ERR(src))
@@ -392,23 +460,31 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
offset = sd->pos & ~PAGE_CACHE_MASK;
/*
- * reuse buf page, if SPLICE_F_MOVE is set
+ * Reuse buf page, if SPLICE_F_MOVE is set.
*/
if (sd->flags & SPLICE_F_MOVE) {
+ /*
+ * If steal succeeds, buf->page is now pruned from the vm
+ * side (LRU and page cache) and we can reuse it.
+ */
if (buf->ops->steal(info, buf))
goto find_page;
+ /*
+ * this will also set the page locked
+ */
page = buf->page;
- if (add_to_page_cache_lru(page, mapping, index,
- mapping_gfp_mask(mapping)))
+ if (add_to_page_cache(page, mapping, index, gfp_mask))
goto find_page;
+
+ if (!(buf->flags & PIPE_BUF_FLAG_LRU))
+ lru_cache_add(page);
} else {
find_page:
ret = -ENOMEM;
- page = find_or_create_page(mapping, index,
- mapping_gfp_mask(mapping));
+ page = find_or_create_page(mapping, index, gfp_mask);
if (!page)
- goto out;
+ goto out_nomem;
/*
* If the page is uptodate, it is also locked. If it isn't
@@ -425,7 +501,7 @@ find_page:
if (!PageUptodate(page)) {
/*
- * page got invalidated, repeat
+ * Page got invalidated, repeat.
*/
if (!page->mapping) {
unlock_page(page);
@@ -443,10 +519,13 @@ find_page:
}
ret = mapping->a_ops->prepare_write(file, page, 0, sd->len);
- if (ret)
+ if (ret == AOP_TRUNCATED_PAGE) {
+ page_cache_release(page);
+ goto find_page;
+ } else if (ret)
goto out;
- if (!buf->stolen) {
+ if (!(buf->flags & PIPE_BUF_FLAG_STOLEN)) {
char *dst = kmap_atomic(page, KM_USER0);
memcpy(dst + offset, src + buf->offset, sd->len);
@@ -455,16 +534,20 @@ find_page:
}
ret = mapping->a_ops->commit_write(file, page, 0, sd->len);
- if (ret < 0)
+ if (ret == AOP_TRUNCATED_PAGE) {
+ page_cache_release(page);
+ goto find_page;
+ } else if (ret)
goto out;
- set_page_dirty(page);
- ret = write_one_page(page, 0);
+ mark_page_accessed(page);
+ balance_dirty_pages_ratelimited(mapping);
out:
- if (ret < 0)
- unlock_page(page);
- if (!buf->stolen)
+ if (!(buf->flags & PIPE_BUF_FLAG_STOLEN)) {
page_cache_release(page);
+ unlock_page(page);
+ }
+out_nomem:
buf->ops->unmap(info, buf);
return ret;
}
@@ -472,11 +555,15 @@ out:
typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,
struct splice_desc *);
-static ssize_t move_from_pipe(struct inode *inode, struct file *out,
+/*
+ * Pipe input worker. Most of this logic works like a regular pipe, the
+ * key here is the 'actor' worker passed in that actually moves the data
+ * to the wanted destination. See pipe_to_file/pipe_to_sendpage above.
+ */
+static ssize_t move_from_pipe(struct pipe_inode_info *pipe, struct file *out,
size_t len, unsigned int flags,
splice_actor *actor)
{
- struct pipe_inode_info *info;
int ret, do_wakeup, err;
struct splice_desc sd;
@@ -488,22 +575,19 @@ static ssize_t move_from_pipe(struct inode *inode, struct file *out,
sd.file = out;
sd.pos = out->f_pos;
- mutex_lock(PIPE_MUTEX(*inode));
+ if (pipe->inode)
+ mutex_lock(&pipe->inode->i_mutex);
- info = inode->i_pipe;
for (;;) {
- int bufs = info->nrbufs;
-
- if (bufs) {
- int curbuf = info->curbuf;
- struct pipe_buffer *buf = info->bufs + curbuf;
+ if (pipe->nrbufs) {
+ struct pipe_buffer *buf = pipe->bufs + pipe->curbuf;
struct pipe_buf_operations *ops = buf->ops;
sd.len = buf->len;
if (sd.len > sd.total_len)
sd.len = sd.total_len;
- err = actor(info, buf, &sd);
+ err = actor(pipe, buf, &sd);
if (err) {
if (!ret && err != -ENODATA)
ret = err;
@@ -514,13 +598,14 @@ static ssize_t move_from_pipe(struct inode *inode, struct file *out,
ret += sd.len;
buf->offset += sd.len;
buf->len -= sd.len;
+
if (!buf->len) {
buf->ops = NULL;
- ops->release(info, buf);
- curbuf = (curbuf + 1) & (PIPE_BUFFERS - 1);
- info->curbuf = curbuf;
- info->nrbufs = --bufs;
- do_wakeup = 1;
+ ops->release(pipe, buf);
+ pipe->curbuf = (pipe->curbuf + 1) & (PIPE_BUFFERS - 1);
+ pipe->nrbufs--;
+ if (pipe->inode)
+ do_wakeup = 1;
}
sd.pos += sd.len;
@@ -529,11 +614,11 @@ static ssize_t move_from_pipe(struct inode *inode, struct file *out,
break;
}
- if (bufs)
+ if (pipe->nrbufs)
continue;
- if (!PIPE_WRITERS(*inode))
+ if (!pipe->writers)
break;
- if (!PIPE_WAITING_WRITERS(*inode)) {
+ if (!pipe->waiting_writers) {
if (ret)
break;
}
@@ -551,56 +636,109 @@ static ssize_t move_from_pipe(struct inode *inode, struct file *out,
}
if (do_wakeup) {
- wake_up_interruptible_sync(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_WRITERS(*inode),SIGIO,POLL_OUT);
+ smp_mb();
+ if (waitqueue_active(&pipe->wait))
+ wake_up_interruptible_sync(&pipe->wait);
+ kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
do_wakeup = 0;
}
- pipe_wait(inode);
+ pipe_wait(pipe);
}
- mutex_unlock(PIPE_MUTEX(*inode));
+ if (pipe->inode)
+ mutex_unlock(&pipe->inode->i_mutex);
if (do_wakeup) {
- wake_up_interruptible(PIPE_WAIT(*inode));
- kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
+ smp_mb();
+ if (waitqueue_active(&pipe->wait))
+ wake_up_interruptible(&pipe->wait);
+ kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
- mutex_lock(&out->f_mapping->host->i_mutex);
out->f_pos = sd.pos;
- mutex_unlock(&out->f_mapping->host->i_mutex);
return ret;
}
-ssize_t generic_file_splice_write(struct inode *inode, struct file *out,
- size_t len, unsigned int flags)
+/**
+ * generic_file_splice_write - splice data from a pipe to a file
+ * @pipe: pipe info
+ * @out: file to write to
+ * @len: number of bytes to splice
+ * @flags: splice modifier flags
+ *
+ * Will either move or copy pages (determined by @flags options) from
+ * the given pipe inode to the given file.
+ *
+ */
+ssize_t
+generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
+ size_t len, unsigned int flags)
{
- return move_from_pipe(inode, out, len, flags, pipe_to_file);
+ struct address_space *mapping = out->f_mapping;
+ ssize_t ret;
+
+ ret = move_from_pipe(pipe, out, len, flags, pipe_to_file);
+
+ /*
+ * If file or inode is SYNC and we actually wrote some data, sync it.
+ */
+ if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(mapping->host))
+ && ret > 0) {
+ struct inode *inode = mapping->host;
+ int err;
+
+ mutex_lock(&inode->i_mutex);
+ err = generic_osync_inode(mapping->host, mapping,
+ OSYNC_METADATA|OSYNC_DATA);
+ mutex_unlock(&inode->i_mutex);
+
+ if (err)
+ ret = err;
+ }
+
+ return ret;
}
-ssize_t generic_splice_sendpage(struct inode *inode, struct file *out,
+EXPORT_SYMBOL(generic_file_splice_write);
+
+/**
+ * generic_splice_sendpage - splice data from a pipe to a socket
+ * @inode: pipe inode
+ * @out: socket to write to
+ * @len: number of bytes to splice
+ * @flags: splice modifier flags
+ *
+ * Will send @len bytes from the pipe to a network socket. No data copying
+ * is involved.
+ *
+ */
+ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out,
size_t len, unsigned int flags)
{
- return move_from_pipe(inode, out, len, flags, pipe_to_sendpage);
+ return move_from_pipe(pipe, out, len, flags, pipe_to_sendpage);
}
-EXPORT_SYMBOL(generic_file_splice_write);
-EXPORT_SYMBOL(generic_file_splice_read);
+EXPORT_SYMBOL(generic_splice_sendpage);
-static long do_splice_from(struct inode *pipe, struct file *out, size_t len,
- unsigned int flags)
+/*
+ * Attempt to initiate a splice from pipe to file.
+ */
+static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+ size_t len, unsigned int flags)
{
loff_t pos;
int ret;
- if (!out->f_op || !out->f_op->splice_write)
+ if (unlikely(!out->f_op || !out->f_op->splice_write))
return -EINVAL;
- if (!(out->f_mode & FMODE_WRITE))
+ if (unlikely(!(out->f_mode & FMODE_WRITE)))
return -EBADF;
pos = out->f_pos;
+
ret = rw_verify_area(WRITE, out, &pos, len);
if (unlikely(ret < 0))
return ret;
@@ -608,19 +746,23 @@ static long do_splice_from(struct inode *pipe, struct file *out, size_t len,
return out->f_op->splice_write(pipe, out, len, flags);
}
-static long do_splice_to(struct file *in, struct inode *pipe, size_t len,
- unsigned int flags)
+/*
+ * Attempt to initiate a splice from a file to a pipe.
+ */
+static long do_splice_to(struct file *in, struct pipe_inode_info *pipe,
+ size_t len, unsigned int flags)
{
loff_t pos, isize, left;
int ret;
- if (!in->f_op || !in->f_op->splice_read)
+ if (unlikely(!in->f_op || !in->f_op->splice_read))
return -EINVAL;
- if (!(in->f_mode & FMODE_READ))
+ if (unlikely(!(in->f_mode & FMODE_READ)))
return -EBADF;
pos = in->f_pos;
+
ret = rw_verify_area(READ, in, &pos, len);
if (unlikely(ret < 0))
return ret;
@@ -630,29 +772,168 @@ static long do_splice_to(struct file *in, struct inode *pipe, size_t len,
return 0;
left = isize - in->f_pos;
- if (left < len)
+ if (unlikely(left < len))
len = left;
return in->f_op->splice_read(in, pipe, len, flags);
}
-static long do_splice(struct file *in, struct file *out, size_t len,
+long do_splice_direct(struct file *in, struct file *out, size_t len,
unsigned int flags)
{
- struct inode *pipe;
+ struct pipe_inode_info *pipe;
+ long ret, bytes;
+ umode_t i_mode;
+ int i;
+
+ /*
+ * We require the input being a regular file, as we don't want to
+ * randomly drop data for eg socket -> socket splicing. Use the
+ * piped splicing for that!
+ */
+ i_mode = in->f_dentry->d_inode->i_mode;
+ if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode)))
+ return -EINVAL;
+
+ /*
+ * neither in nor out is a pipe, setup an internal pipe attached to
+ * 'out' and transfer the wanted data from 'in' to 'out' through that
+ */
+ pipe = current->splice_pipe;
+ if (unlikely(!pipe)) {
+ pipe = alloc_pipe_info(NULL);
+ if (!pipe)
+ return -ENOMEM;
+
+ /*
+ * We don't have an immediate reader, but we'll read the stuff
+ * out of the pipe right after the move_to_pipe(). So set
+ * PIPE_READERS appropriately.
+ */
+ pipe->readers = 1;
+
+ current->splice_pipe = pipe;
+ }
+
+ /*
+ * Do the splice.
+ */
+ ret = 0;
+ bytes = 0;
+
+ while (len) {
+ size_t read_len, max_read_len;
+
+ /*
+ * Do at most PIPE_BUFFERS pages worth of transfer:
+ */
+ max_read_len = min(len, (size_t)(PIPE_BUFFERS*PAGE_SIZE));
+
+ ret = do_splice_to(in, pipe, max_read_len, flags);
+ if (unlikely(ret < 0))
+ goto out_release;
+
+ read_len = ret;
+
+ /*
+ * NOTE: nonblocking mode only applies to the input. We
+ * must not do the output in nonblocking mode as then we
+ * could get stuck data in the internal pipe:
+ */
+ ret = do_splice_from(pipe, out, read_len,
+ flags & ~SPLICE_F_NONBLOCK);
+ if (unlikely(ret < 0))
+ goto out_release;
+
+ bytes += ret;
+ len -= ret;
+
+ /*
+ * In nonblocking mode, if we got back a short read then
+ * that was due to either an IO error or due to the
+ * pagecache entry not being there. In the IO error case
+ * the _next_ splice attempt will produce a clean IO error
+ * return value (not a short read), so in both cases it's
+ * correct to break out of the loop here:
+ */
+ if ((flags & SPLICE_F_NONBLOCK) && (read_len < max_read_len))
+ break;
+ }
+
+ pipe->nrbufs = pipe->curbuf = 0;
+
+ return bytes;
+
+out_release:
+ /*
+ * If we did an incomplete transfer we must release
+ * the pipe buffers in question:
+ */
+ for (i = 0; i < PIPE_BUFFERS; i++) {
+ struct pipe_buffer *buf = pipe->bufs + i;
+
+ if (buf->ops) {
+ buf->ops->release(pipe, buf);
+ buf->ops = NULL;
+ }
+ }
+ pipe->nrbufs = pipe->curbuf = 0;
+
+ /*
+ * If we transferred some data, return the number of bytes:
+ */
+ if (bytes > 0)
+ return bytes;
+
+ return ret;
+}
+
+EXPORT_SYMBOL(do_splice_direct);
+
+/*
+ * Determine where to splice to/from.
+ */
+static long do_splice(struct file *in, loff_t __user *off_in,
+ struct file *out, loff_t __user *off_out,
+ size_t len, unsigned int flags)
+{
+ struct pipe_inode_info *pipe;
+
+ pipe = in->f_dentry->d_inode->i_pipe;
+ if (pipe) {
+ if (off_in)
+ return -ESPIPE;
+ if (off_out) {
+ if (out->f_op->llseek == no_llseek)
+ return -EINVAL;
+ if (copy_from_user(&out->f_pos, off_out,
+ sizeof(loff_t)))
+ return -EFAULT;
+ }
- pipe = in->f_dentry->d_inode;
- if (pipe->i_pipe)
return do_splice_from(pipe, out, len, flags);
+ }
+
+ pipe = out->f_dentry->d_inode->i_pipe;
+ if (pipe) {
+ if (off_out)
+ return -ESPIPE;
+ if (off_in) {
+ if (in->f_op->llseek == no_llseek)
+ return -EINVAL;
+ if (copy_from_user(&in->f_pos, off_in, sizeof(loff_t)))
+ return -EFAULT;
+ }
- pipe = out->f_dentry->d_inode;
- if (pipe->i_pipe)
return do_splice_to(in, pipe, len, flags);
+ }
return -EINVAL;
}
-asmlinkage long sys_splice(int fdin, int fdout, size_t len, unsigned int flags)
+asmlinkage long sys_splice(int fd_in, loff_t __user *off_in,
+ int fd_out, loff_t __user *off_out,
+ size_t len, unsigned int flags)
{
long error;
struct file *in, *out;
@@ -662,13 +943,15 @@ asmlinkage long sys_splice(int fdin, int fdout, size_t len, unsigned int flags)
return 0;
error = -EBADF;
- in = fget_light(fdin, &fput_in);
+ in = fget_light(fd_in, &fput_in);
if (in) {
if (in->f_mode & FMODE_READ) {
- out = fget_light(fdout, &fput_out);
+ out = fget_light(fd_out, &fput_out);
if (out) {
if (out->f_mode & FMODE_WRITE)
- error = do_splice(in, out, len, flags);
+ error = do_splice(in, off_in,
+ out, off_out,
+ len, flags);
fput_light(out, fput_out);
}
}
diff --git a/fs/sync.c b/fs/sync.c
index 8616006d20948..aab5ffe77e9fd 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -61,7 +61,7 @@
* will be available after a crash.
*/
asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
- int flags)
+ unsigned int flags)
{
int ret;
struct file *file;
@@ -126,7 +126,7 @@ out:
* `endbyte' is inclusive
*/
int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte,
- int flags)
+ unsigned int flags)
{
int ret;
struct address_space *mapping;
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 6cbbd165c60db..4d191ef39b67a 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -870,12 +870,14 @@ xfs_page_state_convert(
pgoff_t end_index, last_index, tlast;
ssize_t size, len;
int flags, err, iomap_valid = 0, uptodate = 1;
- int page_dirty, count = 0, trylock_flag = 0;
+ int page_dirty, count = 0;
+ int trylock = 0;
int all_bh = unmapped;
- /* wait for other IO threads? */
- if (startio && (wbc->sync_mode == WB_SYNC_NONE && wbc->nonblocking))
- trylock_flag |= BMAPI_TRYLOCK;
+ if (startio) {
+ if (wbc->sync_mode == WB_SYNC_NONE && wbc->nonblocking)
+ trylock |= BMAPI_TRYLOCK;
+ }
/* Is this page beyond the end of the file? */
offset = i_size_read(inode);
@@ -956,15 +958,13 @@ xfs_page_state_convert(
if (buffer_unwritten(bh)) {
type = IOMAP_UNWRITTEN;
- flags = BMAPI_WRITE|BMAPI_IGNSTATE;
+ flags = BMAPI_WRITE | BMAPI_IGNSTATE;
} else if (buffer_delay(bh)) {
type = IOMAP_DELAY;
- flags = BMAPI_ALLOCATE;
- if (!startio)
- flags |= trylock_flag;
+ flags = BMAPI_ALLOCATE | trylock;
} else {
type = IOMAP_NEW;
- flags = BMAPI_WRITE|BMAPI_MMAP;
+ flags = BMAPI_WRITE | BMAPI_MMAP;
}
if (!iomap_valid) {
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 9fb0312665caa..26fed0756f010 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -182,7 +182,7 @@ free_address(
{
a_list_t *aentry;
- aentry = kmalloc(sizeof(a_list_t), GFP_ATOMIC & ~__GFP_HIGH);
+ aentry = kmalloc(sizeof(a_list_t), GFP_NOWAIT);
if (likely(aentry)) {
spin_lock(&as_lock);
aentry->next = as_free_head;
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 85997b1205f5f..269721af02f3b 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -69,7 +69,6 @@ __xfs_file_read(
return rval;
}
-
STATIC ssize_t
xfs_file_aio_read(
struct kiocb *iocb,
@@ -90,7 +89,6 @@ xfs_file_aio_read_invis(
return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
}
-
STATIC inline ssize_t
__xfs_file_write(
struct kiocb *iocb,
@@ -113,7 +111,6 @@ __xfs_file_write(
return rval;
}
-
STATIC ssize_t
xfs_file_aio_write(
struct kiocb *iocb,
@@ -134,7 +131,6 @@ xfs_file_aio_write_invis(
return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
}
-
STATIC inline ssize_t
__xfs_file_readv(
struct file *file,
@@ -179,7 +175,6 @@ xfs_file_readv_invis(
return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos);
}
-
STATIC inline ssize_t
__xfs_file_writev(
struct file *file,
@@ -204,7 +199,6 @@ __xfs_file_writev(
return rval;
}
-
STATIC ssize_t
xfs_file_writev(
struct file *file,
@@ -228,7 +222,7 @@ xfs_file_writev_invis(
STATIC ssize_t
xfs_file_sendfile(
struct file *filp,
- loff_t *ppos,
+ loff_t *pos,
size_t count,
read_actor_t actor,
void *target)
@@ -236,10 +230,80 @@ xfs_file_sendfile(
vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode);
ssize_t rval;
- VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval);
+ VOP_SENDFILE(vp, filp, pos, 0, count, actor, target, NULL, rval);
return rval;
}
+STATIC ssize_t
+xfs_file_sendfile_invis(
+ struct file *filp,
+ loff_t *pos,
+ size_t count,
+ read_actor_t actor,
+ void *target)
+{
+ vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode);
+ ssize_t rval;
+
+ VOP_SENDFILE(vp, filp, pos, IO_INVIS, count, actor, target, NULL, rval);
+ return rval;
+}
+
+STATIC ssize_t
+xfs_file_splice_read(
+ struct file *infilp,
+ struct pipe_inode_info *pipe,
+ size_t len,
+ unsigned int flags)
+{
+ vnode_t *vp = vn_from_inode(infilp->f_dentry->d_inode);
+ ssize_t rval;
+
+ VOP_SPLICE_READ(vp, infilp, pipe, len, flags, 0, NULL, rval);
+ return rval;
+}
+
+STATIC ssize_t
+xfs_file_splice_read_invis(
+ struct file *infilp,
+ struct pipe_inode_info *pipe,
+ size_t len,
+ unsigned int flags)
+{
+ vnode_t *vp = vn_from_inode(infilp->f_dentry->d_inode);
+ ssize_t rval;
+
+ VOP_SPLICE_READ(vp, infilp, pipe, len, flags, IO_INVIS, NULL, rval);
+ return rval;
+}
+
+STATIC ssize_t
+xfs_file_splice_write(
+ struct pipe_inode_info *pipe,
+ struct file *outfilp,
+ size_t len,
+ unsigned int flags)
+{
+ vnode_t *vp = vn_from_inode(outfilp->f_dentry->d_inode);
+ ssize_t rval;
+
+ VOP_SPLICE_WRITE(vp, pipe, outfilp, len, flags, 0, NULL, rval);
+ return rval;
+}
+
+STATIC ssize_t
+xfs_file_splice_write_invis(
+ struct pipe_inode_info *pipe,
+ struct file *outfilp,
+ size_t len,
+ unsigned int flags)
+{
+ vnode_t *vp = vn_from_inode(outfilp->f_dentry->d_inode);
+ ssize_t rval;
+
+ VOP_SPLICE_WRITE(vp, pipe, outfilp, len, flags, IO_INVIS, NULL, rval);
+ return rval;
+}
STATIC int
xfs_file_open(
@@ -251,13 +315,10 @@ xfs_file_open(
if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EFBIG;
-
- ASSERT(vp);
VOP_OPEN(vp, NULL, error);
return -error;
}
-
STATIC int
xfs_file_release(
struct inode *inode,
@@ -271,7 +332,6 @@ xfs_file_release(
return -error;
}
-
STATIC int
xfs_file_fsync(
struct file *filp,
@@ -285,21 +345,11 @@ xfs_file_fsync(
if (datasync)
flags |= FSYNC_DATA;
-
- ASSERT(vp);
VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error);
return -error;
}
-/*
- * xfs_file_readdir maps to VOP_READDIR().
- * We need to build a uio, cred, ...
- */
-
-#define nextdp(dp) ((struct xfs_dirent *)((char *)(dp) + (dp)->d_reclen))
-
#ifdef CONFIG_XFS_DMAPI
-
STATIC struct page *
xfs_vm_nopage(
struct vm_area_struct *area,
@@ -319,10 +369,8 @@ xfs_vm_nopage(
return filemap_nopage(area, address, type);
}
-
#endif /* CONFIG_XFS_DMAPI */
-
STATIC int
xfs_file_readdir(
struct file *filp,
@@ -330,7 +378,7 @@ xfs_file_readdir(
filldir_t filldir)
{
int error = 0;
- vnode_t *vp;
+ vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode);
uio_t uio;
iovec_t iov;
int eof = 0;
@@ -340,9 +388,6 @@ xfs_file_readdir(
xfs_off_t start_offset, curr_offset;
xfs_dirent_t *dbp = NULL;
- vp = vn_from_inode(filp->f_dentry->d_inode);
- ASSERT(vp);
-
/* Try fairly hard to get memory */
do {
if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL)))
@@ -387,7 +432,7 @@ xfs_file_readdir(
}
size -= dbp->d_reclen;
curr_offset = (loff_t)dbp->d_off /* & 0x7fffffff */;
- dbp = nextdp(dbp);
+ dbp = (xfs_dirent_t *)((char *)dbp + dbp->d_reclen);
}
}
done:
@@ -402,7 +447,6 @@ done:
return -error;
}
-
STATIC int
xfs_file_mmap(
struct file *filp,
@@ -457,11 +501,10 @@ xfs_file_ioctl_invis(
unsigned int cmd,
unsigned long arg)
{
- int error;
struct inode *inode = filp->f_dentry->d_inode;
vnode_t *vp = vn_from_inode(inode);
+ int error;
- ASSERT(vp);
VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error);
VMODIFY(vp);
@@ -537,6 +580,8 @@ const struct file_operations xfs_file_operations = {
.aio_read = xfs_file_aio_read,
.aio_write = xfs_file_aio_write,
.sendfile = xfs_file_sendfile,
+ .splice_read = xfs_file_splice_read,
+ .splice_write = xfs_file_splice_write,
.unlocked_ioctl = xfs_file_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = xfs_file_compat_ioctl,
@@ -558,7 +603,9 @@ const struct file_operations xfs_invis_file_operations = {
.writev = xfs_file_writev_invis,
.aio_read = xfs_file_aio_read_invis,
.aio_write = xfs_file_aio_write_invis,
- .sendfile = xfs_file_sendfile,
+ .sendfile = xfs_file_sendfile_invis,
+ .splice_read = xfs_file_splice_read_invis,
+ .splice_write = xfs_file_splice_write_invis,
.unlocked_ioctl = xfs_file_ioctl_invis,
#ifdef CONFIG_COMPAT
.compat_ioctl = xfs_file_compat_invis_ioctl,
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 149237304fb6b..2e2e275c786f2 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -673,8 +673,7 @@ xfs_vn_setattr(
if (ia_valid & ATTR_ATIME) {
vattr.va_mask |= XFS_AT_ATIME;
vattr.va_atime = attr->ia_atime;
- if (ia_valid & ATTR_ATIME_SET)
- inode->i_atime = attr->ia_atime;
+ inode->i_atime = attr->ia_atime;
}
if (ia_valid & ATTR_MTIME) {
vattr.va_mask |= XFS_AT_MTIME;
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 1fe09f2d65194..e9fe43d74768a 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -103,6 +103,7 @@
*/
#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */
#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */
+#define HAVE_SPLICE /* a splice(2) exists in 2.6, but not in 2.4 */
#ifdef CONFIG_SMP
#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
#else
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 84ddf1893894b..74a52937f2084 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -301,36 +301,23 @@ xfs_sendfile(
void *target,
cred_t *credp)
{
+ xfs_inode_t *ip = XFS_BHVTOI(bdp);
+ xfs_mount_t *mp = ip->i_mount;
ssize_t ret;
- xfs_fsize_t n;
- xfs_inode_t *ip;
- xfs_mount_t *mp;
- vnode_t *vp;
-
- ip = XFS_BHVTOI(bdp);
- vp = BHV_TO_VNODE(bdp);
- mp = ip->i_mount;
XFS_STATS_INC(xs_read_calls);
-
- n = XFS_MAXIOFFSET(mp) - *offset;
- if ((n <= 0) || (count == 0))
- return 0;
-
- if (n < count)
- count = n;
-
- if (XFS_FORCED_SHUTDOWN(ip->i_mount))
+ if (XFS_FORCED_SHUTDOWN(mp))
return -EIO;
xfs_ilock(ip, XFS_IOLOCK_SHARED);
- if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&
(!(ioflags & IO_INVIS))) {
vrwlock_t locktype = VRWLOCK_READ;
int error;
- error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,
+ error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),
+ *offset, count,
FILP_DELAY_FLAG(filp), &locktype);
if (error) {
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
@@ -340,12 +327,96 @@ xfs_sendfile(
xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,
(void *)(unsigned long)target, count, *offset, ioflags);
ret = generic_file_sendfile(filp, offset, count, actor, target);
+ if (ret > 0)
+ XFS_STATS_ADD(xs_read_bytes, ret);
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
+ return ret;
+}
+ssize_t
+xfs_splice_read(
+ bhv_desc_t *bdp,
+ struct file *infilp,
+ struct pipe_inode_info *pipe,
+ size_t count,
+ int flags,
+ int ioflags,
+ cred_t *credp)
+{
+ xfs_inode_t *ip = XFS_BHVTOI(bdp);
+ xfs_mount_t *mp = ip->i_mount;
+ ssize_t ret;
+
+ XFS_STATS_INC(xs_read_calls);
+ if (XFS_FORCED_SHUTDOWN(ip->i_mount))
+ return -EIO;
+
+ xfs_ilock(ip, XFS_IOLOCK_SHARED);
+
+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&
+ (!(ioflags & IO_INVIS))) {
+ vrwlock_t locktype = VRWLOCK_READ;
+ int error;
+
+ error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),
+ infilp->f_pos, count,
+ FILP_DELAY_FLAG(infilp), &locktype);
+ if (error) {
+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);
+ return -error;
+ }
+ }
+ xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, &ip->i_iocore,
+ pipe, count, infilp->f_pos, ioflags);
+ ret = generic_file_splice_read(infilp, pipe, count, flags);
if (ret > 0)
XFS_STATS_ADD(xs_read_bytes, ret);
+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);
+ return ret;
+}
+
+ssize_t
+xfs_splice_write(
+ bhv_desc_t *bdp,
+ struct pipe_inode_info *pipe,
+ struct file *outfilp,
+ size_t count,
+ int flags,
+ int ioflags,
+ cred_t *credp)
+{
+ xfs_inode_t *ip = XFS_BHVTOI(bdp);
+ xfs_mount_t *mp = ip->i_mount;
+ ssize_t ret;
+
+ XFS_STATS_INC(xs_write_calls);
+ if (XFS_FORCED_SHUTDOWN(ip->i_mount))
+ return -EIO;
+
+ xfs_ilock(ip, XFS_IOLOCK_EXCL);
+
+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_WRITE) &&
+ (!(ioflags & IO_INVIS))) {
+ vrwlock_t locktype = VRWLOCK_WRITE;
+ int error;
+
+ error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, BHV_TO_VNODE(bdp),
+ outfilp->f_pos, count,
+ FILP_DELAY_FLAG(outfilp), &locktype);
+ if (error) {
+ xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+ return -error;
+ }
+ }
+ xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, &ip->i_iocore,
+ pipe, count, outfilp->f_pos, ioflags);
+ ret = generic_file_splice_write(pipe, outfilp, count, flags);
+ if (ret > 0)
+ XFS_STATS_ADD(xs_write_bytes, ret);
+
+ xfs_iunlock(ip, XFS_IOLOCK_EXCL);
return ret;
}
@@ -363,7 +434,7 @@ xfs_zero_last_block(
xfs_fsize_t end_size)
{
xfs_fileoff_t last_fsb;
- xfs_mount_t *mp;
+ xfs_mount_t *mp = io->io_mount;
int nimaps;
int zero_offset;
int zero_len;
@@ -373,8 +444,6 @@ xfs_zero_last_block(
ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);
- mp = io->io_mount;
-
zero_offset = XFS_B_FSB_OFFSET(mp, isize);
if (zero_offset == 0) {
/*
@@ -405,10 +474,9 @@ xfs_zero_last_block(
* don't deadlock when the buffer cache calls back to us.
*/
XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
- loff = XFS_FSB_TO_B(mp, last_fsb);
+ loff = XFS_FSB_TO_B(mp, last_fsb);
zero_len = mp->m_sb.sb_blocksize - zero_offset;
-
error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size);
XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
@@ -441,7 +509,7 @@ xfs_zero_eof(
xfs_fileoff_t zero_count_fsb;
xfs_fileoff_t last_fsb;
xfs_extlen_t buf_len_fsb;
- xfs_mount_t *mp;
+ xfs_mount_t *mp = io->io_mount;
int nimaps;
int error = 0;
xfs_bmbt_irec_t imap;
@@ -450,8 +518,6 @@ xfs_zero_eof(
ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
ASSERT(offset > isize);
- mp = io->io_mount;
-
/*
* First handle zeroing the block on which isize resides.
* We only zero a part of that block so it is handled specially.
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h
index 38864a88d42d4..55c689a86ad2e 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.h
+++ b/fs/xfs/linux-2.6/xfs_lrw.h
@@ -60,6 +60,8 @@ struct xfs_iomap;
#define XFS_IOMAP_ALLOC_ENTER 25
#define XFS_IOMAP_ALLOC_MAP 26
#define XFS_IOMAP_UNWRITTEN 27
+#define XFS_SPLICE_READ_ENTER 28
+#define XFS_SPLICE_WRITE_ENTER 29
extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
void *, size_t, loff_t, int);
extern void xfs_inval_cached_trace(struct xfs_iocore *,
@@ -78,6 +80,7 @@ extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int,
struct xfs_iomap *, int *);
extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
extern int xfs_bdstrat_cb(struct xfs_buf *);
+extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t,
xfs_fsize_t, xfs_fsize_t);
@@ -90,7 +93,11 @@ extern ssize_t xfs_write(struct bhv_desc *, struct kiocb *,
extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *,
loff_t *, int, size_t, read_actor_t,
void *, struct cred *);
-
-extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
+extern ssize_t xfs_splice_read(struct bhv_desc *, struct file *,
+ struct pipe_inode_info *, size_t, int, int,
+ struct cred *);
+extern ssize_t xfs_splice_write(struct bhv_desc *, struct pipe_inode_info *,
+ struct file *, size_t, int, int,
+ struct cred *);
#endif /* __XFS_LRW_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 1884300417e37..68f4793e8a11f 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -67,7 +67,8 @@ mempool_t *xfs_ioend_pool;
STATIC struct xfs_mount_args *
xfs_args_allocate(
- struct super_block *sb)
+ struct super_block *sb,
+ int silent)
{
struct xfs_mount_args *args;
@@ -80,8 +81,8 @@ xfs_args_allocate(
args->flags |= XFSMNT_DIRSYNC;
if (sb->s_flags & MS_SYNCHRONOUS)
args->flags |= XFSMNT_WSYNC;
-
- /* Default to 32 bit inodes on Linux all the time */
+ if (silent)
+ args->flags |= XFSMNT_QUIET;
args->flags |= XFSMNT_32BITINODES;
return args;
@@ -719,7 +720,7 @@ xfs_fs_remount(
char *options)
{
vfs_t *vfsp = vfs_from_sb(sb);
- struct xfs_mount_args *args = xfs_args_allocate(sb);
+ struct xfs_mount_args *args = xfs_args_allocate(sb, 0);
int error;
VFS_PARSEARGS(vfsp, options, args, 1, error);
@@ -825,7 +826,7 @@ xfs_fs_fill_super(
{
vnode_t *rootvp;
struct vfs *vfsp = vfs_allocate(sb);
- struct xfs_mount_args *args = xfs_args_allocate(sb);
+ struct xfs_mount_args *args = xfs_args_allocate(sb, silent);
struct kstatfs statvfs;
int error, error2;
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 06f5845e9568e..88b09f1862899 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -173,6 +173,12 @@ typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct kiocb *,
typedef ssize_t (*vop_sendfile_t)(bhv_desc_t *, struct file *,
loff_t *, int, size_t, read_actor_t,
void *, struct cred *);
+typedef ssize_t (*vop_splice_read_t)(bhv_desc_t *, struct file *,
+ struct pipe_inode_info *, size_t, int, int,
+ struct cred *);
+typedef ssize_t (*vop_splice_write_t)(bhv_desc_t *, struct pipe_inode_info *,
+ struct file *, size_t, int, int,
+ struct cred *);
typedef int (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *,
int, unsigned int, void __user *);
typedef int (*vop_getattr_t)(bhv_desc_t *, struct vattr *, int,
@@ -231,6 +237,8 @@ typedef struct vnodeops {
vop_read_t vop_read;
vop_write_t vop_write;
vop_sendfile_t vop_sendfile;
+ vop_splice_read_t vop_splice_read;
+ vop_splice_write_t vop_splice_write;
vop_ioctl_t vop_ioctl;
vop_getattr_t vop_getattr;
vop_setattr_t vop_setattr;
@@ -276,6 +284,10 @@ typedef struct vnodeops {
rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
#define VOP_SENDFILE(vp,f,off,ioflags,cnt,act,targ,cr,rv) \
rv = _VOP_(vop_sendfile, vp)((vp)->v_fbhv,f,off,ioflags,cnt,act,targ,cr)
+#define VOP_SPLICE_READ(vp,f,pipe,cnt,fl,iofl,cr,rv) \
+ rv = _VOP_(vop_splice_read, vp)((vp)->v_fbhv,f,pipe,cnt,fl,iofl,cr)
+#define VOP_SPLICE_WRITE(vp,f,pipe,cnt,fl,iofl,cr,rv) \
+ rv = _VOP_(vop_splice_write, vp)((vp)->v_fbhv,f,pipe,cnt,fl,iofl,cr)
#define VOP_BMAP(vp,of,sz,rw,b,n,rv) \
rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)
#define VOP_OPEN(vp, cr, rv) \
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 73c1e5e80c077..7fb5eca9bd501 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -2624,7 +2624,7 @@ xfs_qm_vop_chown_reserve(
{
int error;
xfs_mount_t *mp;
- uint delblks, blkflags;
+ uint delblks, blkflags, prjflags = 0;
xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq;
ASSERT(XFS_ISLOCKED_INODE(ip));
@@ -2650,10 +2650,13 @@ xfs_qm_vop_chown_reserve(
}
}
if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) {
- if ((XFS_IS_GQUOTA_ON(ip->i_mount) &&
- ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) ||
- (XFS_IS_PQUOTA_ON(ip->i_mount) &&
- ip->i_d.di_projid != be32_to_cpu(gdqp->q_core.d_id))) {
+ if (XFS_IS_PQUOTA_ON(ip->i_mount) &&
+ ip->i_d.di_projid != be32_to_cpu(gdqp->q_core.d_id))
+ prjflags = XFS_QMOPT_ENOSPC;
+
+ if (prjflags ||
+ (XFS_IS_GQUOTA_ON(ip->i_mount) &&
+ ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id))) {
delblksgdq = gdqp;
if (delblks) {
ASSERT(ip->i_gdquot);
@@ -2664,7 +2667,7 @@ xfs_qm_vop_chown_reserve(
if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
delblksudq, delblksgdq, ip->i_d.di_nblocks, 1,
- flags | blkflags)))
+ flags | blkflags | prjflags)))
return (error);
/*
@@ -2681,7 +2684,7 @@ xfs_qm_vop_chown_reserve(
ASSERT(unresudq || unresgdq);
if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0,
- flags | blkflags)))
+ flags | blkflags | prjflags)))
return (error);
xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0,
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c
index d8e131ec0aa8e..9168918db252f 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/quota/xfs_trans_dquot.c
@@ -595,12 +595,19 @@ xfs_trans_unreserve_and_mod_dquots(
}
}
+STATIC int
+xfs_quota_error(uint flags)
+{
+ if (flags & XFS_QMOPT_ENOSPC)
+ return ENOSPC;
+ return EDQUOT;
+}
+
/*
* This reserves disk blocks and inodes against a dquot.
* Flags indicate if the dquot is to be locked here and also
* if the blk reservation is for RT or regular blocks.
* Sending in XFS_QMOPT_FORCE_RES flag skips the quota check.
- * Returns EDQUOT if quota is exceeded.
*/
STATIC int
xfs_trans_dqresv(
@@ -666,19 +673,15 @@ xfs_trans_dqresv(
*/
if (hardlimit > 0ULL &&
(hardlimit <= nblks + *resbcountp)) {
- error = EDQUOT;
+ error = xfs_quota_error(flags);
goto error_return;
}
if (softlimit > 0ULL &&
(softlimit <= nblks + *resbcountp)) {
- /*
- * If timer or warnings has expired,
- * return EDQUOT
- */
if ((timer != 0 && get_seconds() > timer) ||
(warns != 0 && warns >= warnlimit)) {
- error = EDQUOT;
+ error = xfs_quota_error(flags);
goto error_return;
}
}
@@ -695,16 +698,12 @@ xfs_trans_dqresv(
if (!softlimit)
softlimit = q->qi_isoftlimit;
if (hardlimit > 0ULL && count >= hardlimit) {
- error = EDQUOT;
+ error = xfs_quota_error(flags);
goto error_return;
} else if (softlimit > 0ULL && count >= softlimit) {
- /*
- * If timer or warnings has expired,
- * return EDQUOT
- */
if ((timer != 0 && get_seconds() > timer) ||
(warns != 0 && warns >= warnlimit)) {
- error = EDQUOT;
+ error = xfs_quota_error(flags);
goto error_return;
}
}
@@ -751,13 +750,14 @@ error_return:
/*
- * Given a dquot(s), make disk block and/or inode reservations against them.
+ * Given dquot(s), make disk block and/or inode reservations against them.
* The fact that this does the reservation against both the usr and
- * grp quotas is important, because this follows a both-or-nothing
+ * grp/prj quotas is important, because this follows a both-or-nothing
* approach.
*
* flags = XFS_QMOPT_DQLOCK indicate if dquot(s) need to be locked.
* XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown.
+ * XFS_QMOPT_ENOSPC returns ENOSPC not EDQUOT. Used by pquota.
* XFS_TRANS_DQ_RES_BLKS reserves regular disk blocks
* XFS_TRANS_DQ_RES_RTBLKS reserves realtime disk blocks
* dquots are unlocked on return, if they were not locked by caller.
@@ -772,25 +772,27 @@ xfs_trans_reserve_quota_bydquots(
long ninos,
uint flags)
{
- int resvd;
+ int resvd = 0, error;
- if (! XFS_IS_QUOTA_ON(mp))
- return (0);
+ if (!XFS_IS_QUOTA_ON(mp))
+ return 0;
if (tp && tp->t_dqinfo == NULL)
xfs_trans_alloc_dqinfo(tp);
ASSERT(flags & XFS_QMOPT_RESBLK_MASK);
- resvd = 0;
if (udqp) {
- if (xfs_trans_dqresv(tp, mp, udqp, nblks, ninos, flags))
- return (EDQUOT);
+ error = xfs_trans_dqresv(tp, mp, udqp, nblks, ninos,
+ (flags & ~XFS_QMOPT_ENOSPC));
+ if (error)
+ return error;
resvd = 1;
}
if (gdqp) {
- if (xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags)) {
+ error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags);
+ if (error) {
/*
* can't do it, so backout previous reservation
*/
@@ -799,14 +801,14 @@ xfs_trans_reserve_quota_bydquots(
xfs_trans_dqresv(tp, mp, udqp,
-nblks, -ninos, flags);
}
- return (EDQUOT);
+ return error;
}
}
/*
* Didn't change anything critical, so, no need to log
*/
- return (0);
+ return 0;
}
@@ -814,8 +816,6 @@ xfs_trans_reserve_quota_bydquots(
* Lock the dquot and change the reservation if we can.
* This doesn't change the actual usage, just the reservation.
* The inode sent in is locked.
- *
- * Returns 0 on success, EDQUOT or other errors otherwise
*/
STATIC int
xfs_trans_reserve_quota_nblks(
@@ -824,20 +824,24 @@ xfs_trans_reserve_quota_nblks(
xfs_inode_t *ip,
long nblks,
long ninos,
- uint type)
+ uint flags)
{
int error;
if (!XFS_IS_QUOTA_ON(mp))
- return (0);
+ return 0;
+ if (XFS_IS_PQUOTA_ON(mp))
+ flags |= XFS_QMOPT_ENOSPC;
ASSERT(ip->i_ino != mp->m_sb.sb_uquotino);
ASSERT(ip->i_ino != mp->m_sb.sb_gquotino);
ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
- ASSERT((type & ~XFS_QMOPT_FORCE_RES) == XFS_TRANS_DQ_RES_RTBLKS ||
- (type & ~XFS_QMOPT_FORCE_RES) == XFS_TRANS_DQ_RES_BLKS);
+ ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
+ XFS_TRANS_DQ_RES_RTBLKS ||
+ (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
+ XFS_TRANS_DQ_RES_BLKS);
/*
* Reserve nblks against these dquots, with trans as the mediator.
@@ -845,8 +849,8 @@ xfs_trans_reserve_quota_nblks(
error = xfs_trans_reserve_quota_bydquots(tp, mp,
ip->i_udquot, ip->i_gdquot,
nblks, ninos,
- type);
- return (error);
+ flags);
+ return error;
}
/*
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index d384e489705f8..26939d364bc47 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -4719,18 +4719,17 @@ xfs_bmapi(
/*
* Make a transaction-less quota reservation for
* delayed allocation blocks. This number gets
- * adjusted later.
- * We return EDQUOT if we haven't allocated
- * blks already inside this loop;
+ * adjusted later. We return if we haven't
+ * allocated blocks already inside this loop.
*/
- if (XFS_TRANS_RESERVE_QUOTA_NBLKS(
+ if ((error = XFS_TRANS_RESERVE_QUOTA_NBLKS(
mp, NULL, ip, (long)alen, 0,
rt ? XFS_QMOPT_RES_RTBLKS :
- XFS_QMOPT_RES_REGBLKS)) {
+ XFS_QMOPT_RES_REGBLKS))) {
if (n == 0) {
*nmap = 0;
ASSERT(cur == NULL);
- return XFS_ERROR(EDQUOT);
+ return error;
}
break;
}
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index f83399c89ce3c..8e0d73d9ccc45 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -353,10 +353,11 @@ xfs_check_nostate_extents(
xfs_extnum_t num);
/*
- * Call xfs_bmap_do_search_extents() to search for the extent
- * record containing block bno. If in multi-level in-core extent
- * allocation mode, find and extract the target extent buffer,
- * otherwise just use the direct extent list.
+ * Search the extent records for the entry containing block bno.
+ * If bno lies in a hole, point to the next entry. If bno lies
+ * past eof, *eofp will be set, and *prevp will contain the last
+ * entry (null if none). Else, *lastxp will be set to the index
+ * of the found entry; *gotp will contain the entry.
*/
xfs_bmbt_rec_t *
xfs_bmap_search_multi_extents(struct xfs_ifork *, xfs_fileoff_t, int *,
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h
index 022fff62085b1..5b7eb81453be0 100644
--- a/fs/xfs/xfs_clnt.h
+++ b/fs/xfs/xfs_clnt.h
@@ -68,6 +68,7 @@ struct xfs_mount_args {
* enforcement */
#define XFSMNT_PQUOTAENF 0x00000040 /* IRIX project quota limit
* enforcement */
+#define XFSMNT_QUIET 0x00000080 /* don't report mount errors */
#define XFSMNT_NOALIGN 0x00000200 /* don't allocate at
* stripe boundaries*/
#define XFSMNT_RETERR 0x00000400 /* return error to user */
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 26b8e709a5690..bc43163456ef8 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -186,4 +186,7 @@ extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...);
#define xfs_fs_repair_cmn_err(level, mp, fmt, args...) \
xfs_fs_cmn_err(level, mp, fmt " Unmount and run xfs_repair.", ## args)
+#define xfs_fs_mount_cmn_err(f, fmt, args...) \
+ ((f & XFS_MFSI_QUIET)? cmn_err(CE_WARN, "XFS: " fmt, ## args) : (void)0)
+
#endif /* __XFS_ERROR_H__ */
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 4eeb856183b13..deddbd03c1667 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -158,9 +158,10 @@ xfs_ialloc_ag_alloc(
*/
agi = XFS_BUF_TO_AGI(agbp);
newino = be32_to_cpu(agi->agi_newino);
- if(likely(newino != NULLAGINO)) {
- args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
- XFS_IALLOC_BLOCKS(args.mp);
+ args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
+ XFS_IALLOC_BLOCKS(args.mp);
+ if (likely(newino != NULLAGINO &&
+ (args.agbno < be32_to_cpu(agi->agi_length)))) {
args.fsbno = XFS_AGB_TO_FSB(args.mp,
be32_to_cpu(agi->agi_seqno), args.agbno);
args.type = XFS_ALLOCTYPE_THIS_BNO;
@@ -182,8 +183,8 @@ xfs_ialloc_ag_alloc(
* Set the alignment for the allocation.
* If stripe alignment is turned on then align at stripe unit
* boundary.
- * If the cluster size is smaller than a filesystem block
- * then we're doing I/O for inodes in filesystem block size
+ * If the cluster size is smaller than a filesystem block
+ * then we're doing I/O for inodes in filesystem block size
* pieces, so don't need alignment anyway.
*/
isaligned = 0;
@@ -192,7 +193,7 @@ xfs_ialloc_ag_alloc(
args.alignment = args.mp->m_dalign;
isaligned = 1;
} else if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) &&
- args.mp->m_sb.sb_inoalignmt >=
+ args.mp->m_sb.sb_inoalignmt >=
XFS_B_TO_FSBT(args.mp,
XFS_INODE_CLUSTER_SIZE(args.mp)))
args.alignment = args.mp->m_sb.sb_inoalignmt;
@@ -220,7 +221,7 @@ xfs_ialloc_ag_alloc(
if ((error = xfs_alloc_vextent(&args)))
return error;
}
-
+
/*
* If stripe alignment is turned on, then try again with cluster
* alignment.
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index bb33113eef9f6..b53854325266e 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -421,7 +421,10 @@ finish_inode:
ip->i_chash = chlnew;
chlnew->chl_ip = ip;
chlnew->chl_blkno = ip->i_blkno;
+ if (ch->ch_list)
+ ch->ch_list->chl_prev = chlnew;
chlnew->chl_next = ch->ch_list;
+ chlnew->chl_prev = NULL;
ch->ch_list = chlnew;
chlnew = NULL;
}
@@ -723,23 +726,15 @@ xfs_iextract(
ASSERT(ip->i_cnext == ip && ip->i_cprev == ip);
ASSERT(ip->i_chash != NULL);
chm=NULL;
- for (chl = ch->ch_list; chl != NULL; chl = chl->chl_next) {
- if (chl->chl_blkno == ip->i_blkno) {
- if (chm == NULL) {
- /* first item on the list */
- ch->ch_list = chl->chl_next;
- } else {
- chm->chl_next = chl->chl_next;
- }
- kmem_zone_free(xfs_chashlist_zone, chl);
- break;
- } else {
- ASSERT(chl->chl_ip != ip);
- chm = chl;
- }
- }
- ASSERT_ALWAYS(chl != NULL);
- } else {
+ chl = ip->i_chash;
+ if (chl->chl_prev)
+ chl->chl_prev->chl_next = chl->chl_next;
+ else
+ ch->ch_list = chl->chl_next;
+ if (chl->chl_next)
+ chl->chl_next->chl_prev = chl->chl_prev;
+ kmem_zone_free(xfs_chashlist_zone, chl);
+ } else {
/* delete one inode from a non-empty list */
iq = ip->i_cnext;
iq->i_cprev = ip->i_cprev;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 48146bdc6bdde..94b60dd03801b 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2732,16 +2732,29 @@ xfs_iunpin(
ASSERT(atomic_read(&ip->i_pincount) > 0);
if (atomic_dec_and_test(&ip->i_pincount)) {
- vnode_t *vp = XFS_ITOV_NULL(ip);
+ /*
+ * If the inode is currently being reclaimed, the
+ * linux inode _and_ the xfs vnode may have been
+ * freed so we cannot reference either of them safely.
+ * Hence we should not try to do anything to them
+ * if the xfs inode is currently in the reclaim
+ * path.
+ *
+ * However, we still need to issue the unpin wakeup
+ * call as the inode reclaim may be blocked waiting for
+ * the inode to become unpinned.
+ */
+ if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
+ vnode_t *vp = XFS_ITOV_NULL(ip);
- /* make sync come back and flush this inode */
- if (vp) {
- struct inode *inode = vn_to_inode(vp);
+ /* make sync come back and flush this inode */
+ if (vp) {
+ struct inode *inode = vn_to_inode(vp);
- if (!(inode->i_state & I_NEW))
- mark_inode_dirty_sync(inode);
+ if (!(inode->i_state & I_NEW))
+ mark_inode_dirty_sync(inode);
+ }
}
-
wake_up(&ip->i_ipin_wait);
}
}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 39ef9c36ea558..3b544db1790b1 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -189,6 +189,7 @@ typedef struct xfs_ihash {
*/
typedef struct xfs_chashlist {
struct xfs_chashlist *chl_next;
+ struct xfs_chashlist *chl_prev;
struct xfs_inode *chl_ip;
xfs_daddr_t chl_blkno; /* starting block number of
* the cluster */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 72e7e78bfff8a..c0b1c2906880d 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -213,7 +213,8 @@ xfs_mount_free(
STATIC int
xfs_mount_validate_sb(
xfs_mount_t *mp,
- xfs_sb_t *sbp)
+ xfs_sb_t *sbp,
+ int flags)
{
/*
* If the log device and data device have the
@@ -223,33 +224,29 @@ xfs_mount_validate_sb(
* a volume filesystem in a non-volume manner.
*/
if (sbp->sb_magicnum != XFS_SB_MAGIC) {
- cmn_err(CE_WARN, "XFS: bad magic number");
+ xfs_fs_mount_cmn_err(flags, "bad magic number");
return XFS_ERROR(EWRONGFS);
}
if (!XFS_SB_GOOD_VERSION(sbp)) {
- cmn_err(CE_WARN, "XFS: bad version");
+ xfs_fs_mount_cmn_err(flags, "bad version");
return XFS_ERROR(EWRONGFS);
}
if (unlikely(
sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) {
- cmn_err(CE_WARN,
- "XFS: filesystem is marked as having an external log; "
- "specify logdev on the\nmount command line.");
- XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(1)",
- XFS_ERRLEVEL_HIGH, mp, sbp);
- return XFS_ERROR(EFSCORRUPTED);
+ xfs_fs_mount_cmn_err(flags,
+ "filesystem is marked as having an external log; "
+ "specify logdev on the\nmount command line.");
+ return XFS_ERROR(EINVAL);
}
if (unlikely(
sbp->sb_logstart != 0 && mp->m_logdev_targp != mp->m_ddev_targp)) {
- cmn_err(CE_WARN,
- "XFS: filesystem is marked as having an internal log; "
- "don't specify logdev on\nthe mount command line.");
- XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(2)",
- XFS_ERRLEVEL_HIGH, mp, sbp);
- return XFS_ERROR(EFSCORRUPTED);
+ xfs_fs_mount_cmn_err(flags,
+ "filesystem is marked as having an internal log; "
+ "do not specify logdev on\nthe mount command line.");
+ return XFS_ERROR(EINVAL);
}
/*
@@ -273,10 +270,8 @@ xfs_mount_validate_sb(
(sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) ||
(sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
(sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||
- (sbp->sb_imax_pct > 100 || sbp->sb_imax_pct < 1))) {
- cmn_err(CE_WARN, "XFS: SB sanity check 1 failed");
- XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(3)",
- XFS_ERRLEVEL_LOW, mp, sbp);
+ (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */))) {
+ xfs_fs_mount_cmn_err(flags, "SB sanity check 1 failed");
return XFS_ERROR(EFSCORRUPTED);
}
@@ -289,9 +284,7 @@ xfs_mount_validate_sb(
(xfs_drfsbno_t)sbp->sb_agcount * sbp->sb_agblocks ||
sbp->sb_dblocks < (xfs_drfsbno_t)(sbp->sb_agcount - 1) *
sbp->sb_agblocks + XFS_MIN_AG_BLOCKS)) {
- cmn_err(CE_WARN, "XFS: SB sanity check 2 failed");
- XFS_ERROR_REPORT("xfs_mount_validate_sb(4)",
- XFS_ERRLEVEL_LOW, mp);
+ xfs_fs_mount_cmn_err(flags, "SB sanity check 2 failed");
return XFS_ERROR(EFSCORRUPTED);
}
@@ -307,15 +300,13 @@ xfs_mount_validate_sb(
(sbp->sb_dblocks << (sbp->sb_blocklog - BBSHIFT)) > UINT_MAX ||
(sbp->sb_rblocks << (sbp->sb_blocklog - BBSHIFT)) > UINT_MAX)) {
#endif
- cmn_err(CE_WARN,
- "XFS: File system is too large to be mounted on this system.");
+ xfs_fs_mount_cmn_err(flags,
+ "file system too large to be mounted on this system.");
return XFS_ERROR(E2BIG);
}
if (unlikely(sbp->sb_inprogress)) {
- cmn_err(CE_WARN, "XFS: file system busy");
- XFS_ERROR_REPORT("xfs_mount_validate_sb(5)",
- XFS_ERRLEVEL_LOW, mp);
+ xfs_fs_mount_cmn_err(flags, "file system busy");
return XFS_ERROR(EFSCORRUPTED);
}
@@ -323,8 +314,8 @@ xfs_mount_validate_sb(
* Version 1 directory format has never worked on Linux.
*/
if (unlikely(!XFS_SB_VERSION_HASDIRV2(sbp))) {
- cmn_err(CE_WARN,
- "XFS: Attempted to mount file system using version 1 directory format");
+ xfs_fs_mount_cmn_err(flags,
+ "file system using version 1 directory format");
return XFS_ERROR(ENOSYS);
}
@@ -332,11 +323,11 @@ xfs_mount_validate_sb(
* Until this is fixed only page-sized or smaller data blocks work.
*/
if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) {
- cmn_err(CE_WARN,
- "XFS: Attempted to mount file system with blocksize %d bytes",
+ xfs_fs_mount_cmn_err(flags,
+ "file system with blocksize %d bytes",
sbp->sb_blocksize);
- cmn_err(CE_WARN,
- "XFS: Only page-sized (%ld) or less blocksizes currently work.",
+ xfs_fs_mount_cmn_err(flags,
+ "only pagesize (%ld) or less will currently work.",
PAGE_SIZE);
return XFS_ERROR(ENOSYS);
}
@@ -484,7 +475,7 @@ xfs_xlatesb(
* Does the initial read of the superblock.
*/
int
-xfs_readsb(xfs_mount_t *mp)
+xfs_readsb(xfs_mount_t *mp, int flags)
{
unsigned int sector_size;
unsigned int extra_flags;
@@ -506,7 +497,7 @@ xfs_readsb(xfs_mount_t *mp)
bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR,
BTOBB(sector_size), extra_flags);
if (!bp || XFS_BUF_ISERROR(bp)) {
- cmn_err(CE_WARN, "XFS: SB read failed");
+ xfs_fs_mount_cmn_err(flags, "SB read failed");
error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
goto fail;
}
@@ -520,9 +511,9 @@ xfs_readsb(xfs_mount_t *mp)
sbp = XFS_BUF_TO_SBP(bp);
xfs_xlatesb(XFS_BUF_PTR(bp), &(mp->m_sb), 1, XFS_SB_ALL_BITS);
- error = xfs_mount_validate_sb(mp, &(mp->m_sb));
+ error = xfs_mount_validate_sb(mp, &(mp->m_sb), flags);
if (error) {
- cmn_err(CE_WARN, "XFS: SB validate failed");
+ xfs_fs_mount_cmn_err(flags, "SB validate failed");
goto fail;
}
@@ -530,8 +521,8 @@ xfs_readsb(xfs_mount_t *mp)
* We must be able to do sector-sized and sector-aligned IO.
*/
if (sector_size > mp->m_sb.sb_sectsize) {
- cmn_err(CE_WARN,
- "XFS: device supports only %u byte sectors (not %u)",
+ xfs_fs_mount_cmn_err(flags,
+ "device supports only %u byte sectors (not %u)",
sector_size, mp->m_sb.sb_sectsize);
error = ENOSYS;
goto fail;
@@ -548,7 +539,7 @@ xfs_readsb(xfs_mount_t *mp)
bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR,
BTOBB(sector_size), extra_flags);
if (!bp || XFS_BUF_ISERROR(bp)) {
- cmn_err(CE_WARN, "XFS: SB re-read failed");
+ xfs_fs_mount_cmn_err(flags, "SB re-read failed");
error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
goto fail;
}
@@ -678,7 +669,7 @@ xfs_mountfs(
int error = 0;
if (mp->m_sb_bp == NULL) {
- if ((error = xfs_readsb(mp))) {
+ if ((error = xfs_readsb(mp, mfsi_flags))) {
return error;
}
}
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 66cbee79864e2..668ad23fd37c9 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -510,9 +510,12 @@ xfs_preferred_iosize(xfs_mount_t *mp)
*/
#define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */
#define XFS_MFSI_CLIENT 0x02 /* Is a client -- skip lots of stuff */
+/* XFS_MFSI_RRINODES */
#define XFS_MFSI_NOUNLINK 0x08 /* Skip unlinked inode processing in */
/* log recovery */
#define XFS_MFSI_NO_QUOTACHECK 0x10 /* Skip quotacheck processing */
+/* XFS_MFSI_CONVERT_SUNIT */
+#define XFS_MFSI_QUIET 0x40 /* Be silent if mount errors found */
/*
* Macros for getting from mount to vfs and back.
@@ -581,7 +584,7 @@ extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t,
extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
uint, int);
extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
-extern int xfs_readsb(xfs_mount_t *mp);
+extern int xfs_readsb(xfs_mount_t *, int);
extern void xfs_freesb(xfs_mount_t *);
extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
extern int xfs_syncsub(xfs_mount_t *, int, int, int *);
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index 4f6a034de7f7c..7fbef974bce66 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -196,10 +196,11 @@ typedef struct xfs_qoff_logformat {
#define XFS_QMOPT_QUOTAOFF 0x0000080 /* quotas are being turned off */
#define XFS_QMOPT_UMOUNTING 0x0000100 /* filesys is being unmounted */
#define XFS_QMOPT_DOLOG 0x0000200 /* log buf changes (in quotacheck) */
-#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if necessary */
+#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */
#define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */
-#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot, if damaged. */
+#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */
#define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */
+#define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */
/*
* flags to xfs_trans_mod_dquot to indicate which field needs to be
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 504d2a80747a7..f0e09ca141393 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -442,6 +442,9 @@ xfs_mount(
p = vfs_bhv_lookup(vfsp, VFS_POSITION_IO);
mp->m_io_ops = p ? *(xfs_ioops_t *) vfs_bhv_custom(p) : xfs_iocore_xfs;
+ if (args->flags & XFSMNT_QUIET)
+ flags |= XFS_MFSI_QUIET;
+
/*
* Open real time and log devices - order is important.
*/
@@ -492,7 +495,7 @@ xfs_mount(
error = xfs_start_flags(vfsp, args, mp);
if (error)
goto error1;
- error = xfs_readsb(mp);
+ error = xfs_readsb(mp, flags);
if (error)
goto error1;
error = xfs_finish_flags(vfsp, args, mp);
@@ -1697,8 +1700,9 @@ xfs_parseargs(
int dsunit, dswidth, vol_dsunit, vol_dswidth;
int iosize;
- args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
args->flags |= XFSMNT_IDELETE;
+ args->flags |= XFSMNT_BARRIER;
+ args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
if (!options)
goto done;
@@ -1947,8 +1951,6 @@ xfs_showargs(
seq_printf(m, "," MNTOPT_IKEEP);
if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE))
seq_printf(m, "," MNTOPT_LARGEIO);
- if (mp->m_flags & XFS_MOUNT_BARRIER)
- seq_printf(m, "," MNTOPT_BARRIER);
if (!(vfsp->vfs_flag & VFS_32BITINODES))
seq_printf(m, "," MNTOPT_64BITINODE);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index de49601919c13..fa71b305ba5c0 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -4649,6 +4649,10 @@ vnodeops_t xfs_vnodeops = {
#ifdef HAVE_SENDFILE
.vop_sendfile = xfs_sendfile,
#endif
+#ifdef HAVE_SPLICE
+ .vop_splice_read = xfs_splice_read,
+ .vop_splice_write = xfs_splice_write,
+#endif
.vop_write = xfs_write,
.vop_ioctl = xfs_ioctl,
.vop_getattr = xfs_getattr,
diff --git a/include/asm-alpha/numnodes.h b/include/asm-alpha/numnodes.h
deleted file mode 100644
index cd425827e4f35..0000000000000
--- a/include/asm-alpha/numnodes.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _ASM_MAX_NUMNODES_H
-#define _ASM_MAX_NUMNODES_H
-
-/* Max 128 Nodes - Marvel */
-#define NODES_SHIFT 7
-
-#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-arm/arch-at91rm9200/at91rm9200_mci.h b/include/asm-arm/arch-at91rm9200/at91rm9200_mci.h
new file mode 100644
index 0000000000000..f28636d61e39b
--- /dev/null
+++ b/include/asm-arm/arch-at91rm9200/at91rm9200_mci.h
@@ -0,0 +1,104 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91rm9200_mci.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * MultiMedia Card Interface (MCI) registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * 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 AT91RM9200_MCI_H
+#define AT91RM9200_MCI_H
+
+#define AT91_MCI_CR 0x00 /* Control Register */
+#define AT91_MCI_MCIEN (1 << 0) /* Multi-Media Interface Enable */
+#define AT91_MCI_MCIDIS (1 << 1) /* Multi-Media Interface Disable */
+#define AT91_MCI_PWSEN (1 << 2) /* Power Save Mode Enable */
+#define AT91_MCI_PWSDIS (1 << 3) /* Power Save Mode Disable */
+#define AT91_MCI_SWRST (1 << 7) /* Software Reset */
+
+#define AT91_MCI_MR 0x04 /* Mode Register */
+#define AT91_MCI_CLKDIV (0xff << 0) /* Clock Divider */
+#define AT91_MCI_PWSDIV (3 << 8) /* Power Saving Divider */
+#define AT91_MCI_PDCPADV (1 << 14) /* PDC Padding Value */
+#define AT91_MCI_PDCMODE (1 << 15) /* PDC-orientated Mode */
+#define AT91_MCI_BLKLEN (0xfff << 18) /* Data Block Length */
+
+#define AT91_MCI_DTOR 0x08 /* Data Timeout Register */
+#define AT91_MCI_DTOCYC (0xf << 0) /* Data Timeout Cycle Number */
+#define AT91_MCI_DTOMUL (7 << 4) /* Data Timeout Multiplier */
+#define AT91_MCI_DTOMUL_1 (0 << 4)
+#define AT91_MCI_DTOMUL_16 (1 << 4)
+#define AT91_MCI_DTOMUL_128 (2 << 4)
+#define AT91_MCI_DTOMUL_256 (3 << 4)
+#define AT91_MCI_DTOMUL_1K (4 << 4)
+#define AT91_MCI_DTOMUL_4K (5 << 4)
+#define AT91_MCI_DTOMUL_64K (6 << 4)
+#define AT91_MCI_DTOMUL_1M (7 << 4)
+
+#define AT91_MCI_SDCR 0x0c /* SD Card Register */
+#define AT91_MCI_SDCSEL (0xf << 0) /* SD Card Selector */
+#define AT91_MCI_SDCBUS (1 << 7) /* 1-bit or 4-bit bus */
+
+#define AT91_MCI_ARGR 0x10 /* Argument Register */
+
+#define AT91_MCI_CMDR 0x14 /* Command Register */
+#define AT91_MCI_CMDNB (0x3f << 0) /* Command Number */
+#define AT91_MCI_RSPTYP (3 << 6) /* Response Type */
+#define AT91_MCI_RSPTYP_NONE (0 << 6)
+#define AT91_MCI_RSPTYP_48 (1 << 6)
+#define AT91_MCI_RSPTYP_136 (2 << 6)
+#define AT91_MCI_SPCMD (7 << 8) /* Special Command */
+#define AT91_MCI_SPCMD_NONE (0 << 8)
+#define AT91_MCI_SPCMD_INIT (1 << 8)
+#define AT91_MCI_SPCMD_SYNC (2 << 8)
+#define AT91_MCI_SPCMD_ICMD (4 << 8)
+#define AT91_MCI_SPCMD_IRESP (5 << 8)
+#define AT91_MCI_OPDCMD (1 << 11) /* Open Drain Command */
+#define AT91_MCI_MAXLAT (1 << 12) /* Max Latency for Command to Response */
+#define AT91_MCI_TRCMD (3 << 16) /* Transfer Command */
+#define AT91_MCI_TRCMD_NONE (0 << 16)
+#define AT91_MCI_TRCMD_START (1 << 16)
+#define AT91_MCI_TRCMD_STOP (2 << 16)
+#define AT91_MCI_TRDIR (1 << 18) /* Transfer Direction */
+#define AT91_MCI_TRTYP (3 << 19) /* Transfer Type */
+#define AT91_MCI_TRTYP_BLOCK (0 << 19)
+#define AT91_MCI_TRTYP_MULTIPLE (1 << 19)
+#define AT91_MCI_TRTYP_STREAM (2 << 19)
+
+#define AT91_MCI_RSPR(n) (0x20 + ((n) * 4)) /* Response Registers 0-3 */
+#define AT91_MCR_RDR 0x30 /* Receive Data Register */
+#define AT91_MCR_TDR 0x34 /* Transmit Data Register */
+
+#define AT91_MCI_SR 0x40 /* Status Register */
+#define AT91_MCI_CMDRDY (1 << 0) /* Command Ready */
+#define AT91_MCI_RXRDY (1 << 1) /* Receiver Ready */
+#define AT91_MCI_TXRDY (1 << 2) /* Transmit Ready */
+#define AT91_MCI_BLKE (1 << 3) /* Data Block Ended */
+#define AT91_MCI_DTIP (1 << 4) /* Data Transfer in Progress */
+#define AT91_MCI_NOTBUSY (1 << 5) /* Data Not Busy */
+#define AT91_MCI_ENDRX (1 << 6) /* End of RX Buffer */
+#define AT91_MCI_ENDTX (1 << 7) /* End fo TX Buffer */
+#define AT91_MCI_RXBUFF (1 << 14) /* RX Buffer Full */
+#define AT91_MCI_TXBUFE (1 << 15) /* TX Buffer Empty */
+#define AT91_MCI_RINDE (1 << 16) /* Response Index Error */
+#define AT91_MCI_RDIRE (1 << 17) /* Response Direction Error */
+#define AT91_MCI_RCRCE (1 << 18) /* Response CRC Error */
+#define AT91_MCI_RENDE (1 << 19) /* Response End Bit Error */
+#define AT91_MCI_RTOE (1 << 20) /* Reponse Time-out Error */
+#define AT91_MCI_DCRCE (1 << 21) /* Data CRC Error */
+#define AT91_MCI_DTOE (1 << 22) /* Data Time-out Error */
+#define AT91_MCI_OVRE (1 << 30) /* Overrun */
+#define AT91_MCI_UNRE (1 << 31) /* Underrun */
+
+#define AT91_MCI_IER 0x44 /* Interrupt Enable Register */
+#define AT91_MCI_IDR 0x48 /* Interrupt Disable Register */
+#define AT91_MCI_IMR 0x4c /* Interrupt Mask Register */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/board.h b/include/asm-arm/arch-at91rm9200/board.h
index 2e7d1139a7998..4fdef13d01d4a 100644
--- a/include/asm-arm/arch-at91rm9200/board.h
+++ b/include/asm-arm/arch-at91rm9200/board.h
@@ -38,6 +38,8 @@ extern unsigned long at91_master_clock;
extern int at91_serial_map[AT91_NR_UART];
extern int at91_console_port;
+#include <linux/mtd/partitions.h>
+
/* USB Device */
struct at91_udc_data {
u8 vbus_pin; /* high == host powering us */
@@ -77,4 +79,26 @@ struct at91_usbh_data {
};
extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
+ /* NAND / SmartMedia */
+struct at91_nand_data {
+ u8 enable_pin; /* chip enable */
+ u8 det_pin; /* card detect */
+ u8 rdy_pin; /* ready/busy */
+ u8 ale; /* address line number connected to ALE */
+ u8 cle; /* address line number connected to CLE */
+ struct mtd_partition* (*partition_info)(int, int*);
+};
+extern void __init at91_add_device_nand(struct at91_nand_data *data);
+
+ /* I2C*/
+void __init at91_add_device_i2c(void);
+
+ /* RTC */
+void __init at91_add_device_rtc(void);
+
+ /* LEDs */
+extern u8 at91_leds_cpu;
+extern u8 at91_leds_timer;
+extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
+
#endif
diff --git a/include/asm-arm/arch-cl7500/hardware.h b/include/asm-arm/arch-cl7500/hardware.h
index 2339b764f69f6..1adfd18e6154b 100644
--- a/include/asm-arm/arch-cl7500/hardware.h
+++ b/include/asm-arm/arch-cl7500/hardware.h
@@ -53,16 +53,12 @@
#define SCREEN_END 0xdfc00000
#define SCREEN_BASE 0xdf800000
-#define FLUSH_BASE 0xdf000000
-
#define VIDC_BASE (void __iomem *)0xe0400000
#define IOMD_BASE IOMEM(0xe0200000)
#define IOC_BASE IOMEM(0xe0200000)
#define FLOPPYDMA_BASE IOMEM(0xe002a000)
#define PCIO_BASE IOMEM(0xe0010000)
-#define FLUSH_BASE_PHYS 0x00000000 /* ROM */
-
#define vidc_writel(val) __raw_writel(val, VIDC_BASE)
/* in/out bias for the ISA slot region */
diff --git a/include/asm-arm/arch-cl7500/memory.h b/include/asm-arm/arch-cl7500/memory.h
index 34f40a6cec304..3178140e24cae 100644
--- a/include/asm-arm/arch-cl7500/memory.h
+++ b/include/asm-arm/arch-cl7500/memory.h
@@ -26,4 +26,10 @@
#define __virt_to_bus(x) __virt_to_phys(x)
#define __bus_to_virt(x) __phys_to_virt(x)
+/*
+ * Cache flushing area - ROM
+ */
+#define FLUSH_BASE_PHYS 0x00000000
+#define FLUSH_BASE 0xdf000000
+
#endif
diff --git a/include/asm-arm/arch-ebsa110/debug-macro.S b/include/asm-arm/arch-ebsa110/debug-macro.S
index f61cadabe0ec6..9213bfe4831d6 100644
--- a/include/asm-arm/arch-ebsa110/debug-macro.S
+++ b/include/asm-arm/arch-ebsa110/debug-macro.S
@@ -18,4 +18,4 @@
#define UART_SHIFT 2
#define FLOW_CONTROL
-#include <asm/hardware/debug-8250.h>
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-ebsa110/hardware.h b/include/asm-arm/arch-ebsa110/hardware.h
index 4e41c2358f4ee..3ce864def41ef 100644
--- a/include/asm-arm/arch-ebsa110/hardware.h
+++ b/include/asm-arm/arch-ebsa110/hardware.h
@@ -57,9 +57,6 @@
/*
* RAM definitions
*/
-#define FLUSH_BASE_PHYS 0x40000000
-#define FLUSH_BASE 0xdf000000
-
#define UNCACHEABLE_ADDR 0xff000000 /* IRQ_STAT */
#endif
diff --git a/include/asm-arm/arch-ebsa110/memory.h b/include/asm-arm/arch-ebsa110/memory.h
index 02f144520c10f..c7c500e176d0e 100644
--- a/include/asm-arm/arch-ebsa110/memory.h
+++ b/include/asm-arm/arch-ebsa110/memory.h
@@ -28,4 +28,10 @@
#define __virt_to_bus(x) (x)
#define __bus_to_virt(x) (x)
+/*
+ * Cache flushing area - SRAM
+ */
+#define FLUSH_BASE_PHYS 0x40000000
+#define FLUSH_BASE 0xdf000000
+
#endif
diff --git a/include/asm-arm/arch-ebsa110/uncompress.h b/include/asm-arm/arch-ebsa110/uncompress.h
index 66b19c7fd908a..ae5b775eb0b75 100644
--- a/include/asm-arm/arch-ebsa110/uncompress.h
+++ b/include/asm-arm/arch-ebsa110/uncompress.h
@@ -10,7 +10,7 @@
#include <linux/serial_reg.h>
-#define SERIAL_BASE ((unsigned char *)0xfe000be0)
+#define SERIAL_BASE ((unsigned char *)0xf0000be0)
/*
* This does not append a newline
diff --git a/include/asm-arm/arch-ebsa285/hardware.h b/include/asm-arm/arch-ebsa285/hardware.h
index 2ef2200f108cd..ec51fe92483b1 100644
--- a/include/asm-arm/arch-ebsa285/hardware.h
+++ b/include/asm-arm/arch-ebsa285/hardware.h
@@ -48,9 +48,6 @@
#define PCICFG0_SIZE 0x01000000
#define PCICFG0_BASE 0xfa000000
-#define FLUSH_SIZE 0x00100000
-#define FLUSH_BASE 0xf9000000
-
#define PCIMEM_SIZE 0x01000000
#define PCIMEM_BASE 0xf0000000
@@ -61,9 +58,6 @@
#define PCIMEM_SIZE 0x80000000
#define PCIMEM_BASE 0x80000000
-#define FLUSH_SIZE 0x00100000
-#define FLUSH_BASE 0x7e000000
-
#define WFLUSH_SIZE 0x01000000
#define WFLUSH_BASE 0x7d000000
@@ -94,7 +88,6 @@
#define XBUS_SWITCH_J17_11 ((*XBUS_SWITCH) & (1 << 5))
#define XBUS_SWITCH_J17_9 ((*XBUS_SWITCH) & (1 << 6))
-#define FLUSH_BASE_PHYS 0x50000000
#define UNCACHEABLE_ADDR (ARMCSR_BASE + 0x108)
diff --git a/include/asm-arm/arch-ebsa285/memory.h b/include/asm-arm/arch-ebsa285/memory.h
index 09e335cd687d8..99181ffc7e279 100644
--- a/include/asm-arm/arch-ebsa285/memory.h
+++ b/include/asm-arm/arch-ebsa285/memory.h
@@ -49,12 +49,22 @@ extern unsigned long __bus_to_virt(unsigned long);
#define TASK_SIZE UL(0xbf000000)
#define PAGE_OFFSET UL(0xc0000000)
+/*
+ * Cache flushing area.
+ */
+#define FLUSH_BASE 0xf9000000
+
#elif defined(CONFIG_ARCH_CO285)
/* Task size and page offset at 1.5GB */
#define TASK_SIZE UL(0x5f000000)
#define PAGE_OFFSET UL(0x60000000)
+/*
+ * Cache flushing area.
+ */
+#define FLUSH_BASE 0x7e000000
+
#else
#error "Undefined footbridge architecture"
@@ -72,4 +82,6 @@ extern unsigned long __bus_to_virt(unsigned long);
*/
#define TASK_UNMAPPED_BASE ((TASK_SIZE + 0x01000000) / 3)
+#define FLUSH_BASE_PHYS 0x50000000
+
#endif
diff --git a/include/asm-arm/arch-ep93xx/ts72xx.h b/include/asm-arm/arch-ep93xx/ts72xx.h
index 412215e77f444..a94f63ff05352 100644
--- a/include/asm-arm/arch-ep93xx/ts72xx.h
+++ b/include/asm-arm/arch-ep93xx/ts72xx.h
@@ -12,6 +12,8 @@
* febfc000 [67]0000000 4K NAND data register
* febfb000 [67]0400000 4K NAND control register
* febfa000 [67]0800000 4K NAND busy register
+ * febf9000 10800000 4K TS-5620 RTC index register
+ * febf8000 11700000 4K TS-5620 RTC data register
*/
#define TS72XX_MODEL_PHYS_BASE 0x22000000
@@ -58,6 +60,15 @@
#define TS72XX_NAND_BUSY_SIZE 0x00001000
+#define TS72XX_RTC_INDEX_VIRT_BASE 0xfebf9000
+#define TS72XX_RTC_INDEX_PHYS_BASE 0x10800000
+#define TS72XX_RTC_INDEX_SIZE 0x00001000
+
+#define TS72XX_RTC_DATA_VIRT_BASE 0xfebf8000
+#define TS72XX_RTC_DATA_PHYS_BASE 0x11700000
+#define TS72XX_RTC_DATA_SIZE 0x00001000
+
+
#ifndef __ASSEMBLY__
#include <asm/io.h>
diff --git a/include/asm-arm/arch-imx/dma.h b/include/asm-arm/arch-imx/dma.h
index b45fa367d71e4..621ff2c730f2d 100644
--- a/include/asm-arm/arch-imx/dma.h
+++ b/include/asm-arm/arch-imx/dma.h
@@ -17,27 +17,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#ifndef __ASM_ARCH_DMA_H
#define __ASM_ARCH_DMA_H
-/*
- * DMA registration
- */
-
typedef enum {
DMA_PRIO_HIGH = 0,
- DMA_PRIO_MEDIUM = 3,
- DMA_PRIO_LOW = 6
+ DMA_PRIO_MEDIUM = 1,
+ DMA_PRIO_LOW = 2
} imx_dma_prio;
-int imx_request_dma(char *name, imx_dma_prio prio,
- void (*irq_handler) (int, void *, struct pt_regs *),
- void (*err_handler) (int, void *, struct pt_regs *),
- void *data);
-
-void imx_free_dma(int dma_ch);
-
-
#define DMA_REQ_UART3_T 2
#define DMA_REQ_UART3_R 3
#define DMA_REQ_SSI2_T 4
diff --git a/include/asm-arm/arch-imx/imx-dma.h b/include/asm-arm/arch-imx/imx-dma.h
new file mode 100644
index 0000000000000..f2063c1d610d7
--- /dev/null
+++ b/include/asm-arm/arch-imx/imx-dma.h
@@ -0,0 +1,90 @@
+/*
+ * linux/include/asm-arm/imxads/dma.h
+ *
+ * Copyright (C) 1997,1998 Russell King
+ *
+ * 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 <asm/dma.h>
+
+#ifndef __ASM_ARCH_IMX_DMA_H
+#define __ASM_ARCH_IMX_DMA_H
+
+#define IMX_DMA_CHANNELS 11
+
+/*
+ * struct imx_dma_channel - i.MX specific DMA extension
+ * @name: name specified by DMA client
+ * @irq_handler: client callback for end of transfer
+ * @err_handler: client callback for error condition
+ * @data: clients context data for callbacks
+ * @dma_mode: direction of the transfer %DMA_MODE_READ or %DMA_MODE_WRITE
+ * @sg: pointer to the actual read/written chunk for scatter-gather emulation
+ * @sgbc: counter of processed bytes in the actual read/written chunk
+ * @resbytes: total residual number of bytes to transfer
+ * (it can be lower or same as sum of SG mapped chunk sizes)
+ * @sgcount: number of chunks to be read/written
+ *
+ * Structure is used for IMX DMA processing. It would be probably good
+ * @struct dma_struct in the future for external interfacing and use
+ * @struct imx_dma_channel only as extension to it.
+ */
+
+struct imx_dma_channel {
+ const char *name;
+ void (*irq_handler) (int, void *, struct pt_regs *);
+ void (*err_handler) (int, void *, struct pt_regs *);
+ void *data;
+ dmamode_t dma_mode;
+ struct scatterlist *sg;
+ unsigned int sgbc;
+ unsigned int sgcount;
+ unsigned int resbytes;
+ int dma_num;
+};
+
+extern struct imx_dma_channel imx_dma_channels[IMX_DMA_CHANNELS];
+
+
+/* The type to distinguish channel numbers parameter from ordinal int type */
+typedef int imx_dmach_t;
+
+int
+imx_dma_setup_single(imx_dmach_t dma_ch, dma_addr_t dma_address,
+ unsigned int dma_length, unsigned int dev_addr, dmamode_t dmamode);
+
+int
+imx_dma_setup_sg(imx_dmach_t dma_ch,
+ struct scatterlist *sg, unsigned int sgcount, unsigned int dma_length,
+ unsigned int dev_addr, dmamode_t dmamode);
+
+int
+imx_dma_setup_handlers(imx_dmach_t dma_ch,
+ void (*irq_handler) (int, void *, struct pt_regs *),
+ void (*err_handler) (int, void *, struct pt_regs *), void *data);
+
+void imx_dma_enable(imx_dmach_t dma_ch);
+
+void imx_dma_disable(imx_dmach_t dma_ch);
+
+int imx_dma_request(imx_dmach_t dma_ch, const char *name);
+
+void imx_dma_free(imx_dmach_t dma_ch);
+
+int imx_dma_request_by_prio(imx_dmach_t *pdma_ch, const char *name, imx_dma_prio prio);
+
+
+#endif /* _ASM_ARCH_IMX_DMA_H */
diff --git a/include/asm-arm/arch-imx/mmc.h b/include/asm-arm/arch-imx/mmc.h
new file mode 100644
index 0000000000000..1937151665c75
--- /dev/null
+++ b/include/asm-arm/arch-imx/mmc.h
@@ -0,0 +1,12 @@
+#ifndef ASMARM_ARCH_MMC_H
+#define ASMARM_ARCH_MMC_H
+
+#include <linux/mmc/protocol.h>
+
+struct imxmmc_platform_data {
+ int (*card_present)(void);
+};
+
+extern void imx_set_mmc_info(struct imxmmc_platform_data *info);
+
+#endif
diff --git a/include/asm-arm/arch-ixp23xx/debug-macro.S b/include/asm-arm/arch-ixp23xx/debug-macro.S
index eb99fd69fd242..2b25e640247d1 100644
--- a/include/asm-arm/arch-ixp23xx/debug-macro.S
+++ b/include/asm-arm/arch-ixp23xx/debug-macro.S
@@ -17,6 +17,9 @@
tst \rx, #1 @ mmu enabled?
ldreq \rx, =IXP23XX_PERIPHERAL_PHYS @ physical
ldrne \rx, =IXP23XX_PERIPHERAL_VIRT @ virtual
+#ifdef __ARMEB__
+ orr \rx, \rx, #0x00000003
+#endif
.endm
#define UART_SHIFT 2
diff --git a/include/asm-arm/arch-ixp23xx/memory.h b/include/asm-arm/arch-ixp23xx/memory.h
index bebcf0aa0d725..6e19f46d54d1c 100644
--- a/include/asm-arm/arch-ixp23xx/memory.h
+++ b/include/asm-arm/arch-ixp23xx/memory.h
@@ -28,6 +28,7 @@
* to an address that the kernel can use.
*/
#ifndef __ASSEMBLY__
+#include <asm/mach-types.h>
#define __virt_to_bus(v) \
({ unsigned int ret; \
@@ -40,6 +41,22 @@
data = *((volatile int *)IXP23XX_PCI_SDRAM_BAR); \
__phys_to_virt((((b - (data & 0xfffffff0)) + 0x00000000))); })
+/*
+ * Coherency support. Only supported on A2 CPUs or on A1
+ * systems that have the cache coherency workaround.
+ */
+static inline int __ixp23xx_arch_is_coherent(void)
+{
+ extern unsigned int processor_id;
+
+ if (((processor_id & 15) >= 2) || machine_is_roadrunner())
+ return 1;
+
+ return 0;
+}
+
+#define arch_is_coherent() __ixp23xx_arch_is_coherent()
+
#endif
diff --git a/include/asm-arm/arch-ixp23xx/platform.h b/include/asm-arm/arch-ixp23xx/platform.h
index f85b4685a491e..e4d99060a049d 100644
--- a/include/asm-arm/arch-ixp23xx/platform.h
+++ b/include/asm-arm/arch-ixp23xx/platform.h
@@ -22,6 +22,7 @@ void ixp23xx_sys_init(void);
int ixp23xx_pci_setup(int, struct pci_sys_data *);
void ixp23xx_pci_preinit(void);
struct pci_bus *ixp23xx_pci_scan_bus(int, struct pci_sys_data*);
+void ixp23xx_pci_slave_init(void);
extern struct sys_timer ixp23xx_timer;
diff --git a/include/asm-arm/arch-l7200/hardware.h b/include/asm-arm/arch-l7200/hardware.h
index b755079befabb..2ab43f3a4a8de 100644
--- a/include/asm-arm/arch-l7200/hardware.h
+++ b/include/asm-arm/arch-l7200/hardware.h
@@ -52,9 +52,6 @@
#define ISA_SIZE 0x20000000
#define ISA_BASE 0xe0000000
-#define FLUSH_BASE_PHYS 0x40000000 /* ROM */
-#define FLUSH_BASE 0xdf000000
-
#define PCIO_BASE IO_BASE
#endif
diff --git a/include/asm-arm/arch-l7200/memory.h b/include/asm-arm/arch-l7200/memory.h
index 9e50a171f78ac..402df637e7403 100644
--- a/include/asm-arm/arch-l7200/memory.h
+++ b/include/asm-arm/arch-l7200/memory.h
@@ -20,4 +20,10 @@
#define __virt_to_bus(x) __virt_to_phys(x)
#define __bus_to_virt(x) __phys_to_virt(x)
+/*
+ * Cache flushing area - ROM
+ */
+#define FLUSH_BASE_PHYS 0x40000000
+#define FLUSH_BASE 0xdf000000
+
#endif
diff --git a/include/asm-arm/arch-lh7a40x/memory.h b/include/asm-arm/arch-lh7a40x/memory.h
index c92bcb8376295..9f1a58cbf407d 100644
--- a/include/asm-arm/arch-lh7a40x/memory.h
+++ b/include/asm-arm/arch-lh7a40x/memory.h
@@ -31,8 +31,6 @@
#ifdef CONFIG_DISCONTIGMEM
-#define NODES_SHIFT 4 /* Up to 16 nodes */
-
/*
* Given a kernel address, find the home node of the underlying memory.
*/
diff --git a/include/asm-arm/arch-omap/aic23.h b/include/asm-arm/arch-omap/aic23.h
index 590bac25b7c44..6513065941d08 100644
--- a/include/asm-arm/arch-omap/aic23.h
+++ b/include/asm-arm/arch-omap/aic23.h
@@ -57,6 +57,7 @@
#define LHV_MIN 0x0000
// Analog audio path control register
+#define STA_REG(x) ((x)<<6)
#define STE_ENABLED 0x0020
#define DAC_SELECTED 0x0010
#define BYPASS_ON 0x0008
@@ -109,4 +110,7 @@
#define TLV320AIC23ID1 (0x1a) // cs low
#define TLV320AIC23ID2 (0x1b) // cs high
+void tlv320aic23_power_up(void);
+void tlv320aic23_power_down(void);
+
#endif /* __ASM_ARCH_AIC23_H */
diff --git a/include/asm-arm/arch-omap/board-ams-delta.h b/include/asm-arm/arch-omap/board-ams-delta.h
new file mode 100644
index 0000000000000..0070f6d3b75ce
--- /dev/null
+++ b/include/asm-arm/arch-omap/board-ams-delta.h
@@ -0,0 +1,65 @@
+/*
+ * linux/include/asm-arm/arch-omap/board-ams-delta.h
+ *
+ * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
+ *
+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * 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.
+ */
+#ifndef __ASM_ARCH_OMAP_AMS_DELTA_H
+#define __ASM_ARCH_OMAP_AMS_DELTA_H
+
+#if defined (CONFIG_MACH_AMS_DELTA)
+
+#define AMS_DELTA_LATCH1_PHYS 0x01000000
+#define AMS_DELTA_LATCH1_VIRT 0xEA000000
+#define AMS_DELTA_MODEM_PHYS 0x04000000
+#define AMS_DELTA_MODEM_VIRT 0xEB000000
+#define AMS_DELTA_LATCH2_PHYS 0x08000000
+#define AMS_DELTA_LATCH2_VIRT 0xEC000000
+
+#define AMS_DELTA_LATCH1_LED_CAMERA 0x01
+#define AMS_DELTA_LATCH1_LED_ADVERT 0x02
+#define AMS_DELTA_LATCH1_LED_EMAIL 0x04
+#define AMS_DELTA_LATCH1_LED_HANDSFREE 0x08
+#define AMS_DELTA_LATCH1_LED_VOICEMAIL 0x10
+#define AMS_DELTA_LATCH1_LED_VOICE 0x20
+
+#define AMS_DELTA_LATCH2_LCD_VBLEN 0x0001
+#define AMS_DELTA_LATCH2_LCD_NDISP 0x0002
+#define AMS_DELTA_LATCH2_NAND_NCE 0x0004
+#define AMS_DELTA_LATCH2_NAND_NRE 0x0008
+#define AMS_DELTA_LATCH2_NAND_NWP 0x0010
+#define AMS_DELTA_LATCH2_NAND_NWE 0x0020
+#define AMS_DELTA_LATCH2_NAND_ALE 0x0040
+#define AMS_DELTA_LATCH2_NAND_CLE 0x0080
+#define AMS_DELTA_LATCH2_MODEM_NRESET 0x1000
+#define AMS_DELTA_LATCH2_MODEM_CODEC 0x2000
+
+#define AMS_DELTA_GPIO_PIN_NAND_RB 12
+
+#ifndef __ASSEMBLY__
+void ams_delta_latch1_write(u8 mask, u8 value);
+void ams_delta_latch2_write(u16 mask, u16 value);
+#endif
+
+#endif /* CONFIG_MACH_AMS_DELTA */
+
+#endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */
diff --git a/include/asm-arm/arch-omap/board-apollon.h b/include/asm-arm/arch-omap/board-apollon.h
new file mode 100644
index 0000000000000..de0c5b792c585
--- /dev/null
+++ b/include/asm-arm/arch-omap/board-apollon.h
@@ -0,0 +1,45 @@
+/*
+ * linux/include/asm-arm/arch-omap/board-apollon.h
+ *
+ * Hardware definitions for Samsung OMAP24XX Apollon board.
+ *
+ * Initial creation by Kyungmin Park <kyungmin.park@samsung.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.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * 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.
+ */
+
+#ifndef __ASM_ARCH_OMAP_APOLLON_H
+#define __ASM_ARCH_OMAP_APOLLON_H
+
+/* Placeholder for APOLLON specific defines */
+/* GPMC CS0 */
+#define APOLLON_CS0_BASE 0x00000000
+/* GPMC CS1 */
+#define APOLLON_CS1_BASE 0x08000000
+#define APOLLON_ETHR_START (APOLLON_CS1_BASE + 0x300)
+#define APOLLON_ETHR_GPIO_IRQ 74
+/* GPMC CS2 - reserved for OneNAND */
+#define APOLLON_CS2_BASE 0x10000000
+/* GPMC CS3 - reserved for NOR or NAND */
+#define APOLLON_CS3_BASE 0x18000000
+
+#endif /* __ASM_ARCH_OMAP_APOLLON_H */
+
diff --git a/include/asm-arm/arch-omap/board-h2.h b/include/asm-arm/arch-omap/board-h2.h
index 39ca5a31aeea7..b2888ef9e9b4a 100644
--- a/include/asm-arm/arch-omap/board-h2.h
+++ b/include/asm-arm/arch-omap/board-h2.h
@@ -34,9 +34,5 @@
/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
#define OMAP1610_ETHR_START 0x04000300
-/* Samsung NAND flash at CS2B or CS3(NAND Boot) */
-#define OMAP_NAND_FLASH_START1 0x0A000000 /* CS2B */
-#define OMAP_NAND_FLASH_START2 0x0C000000 /* CS3 */
-
#endif /* __ASM_ARCH_OMAP_H2_H */
diff --git a/include/asm-arm/arch-omap/board-h3.h b/include/asm-arm/arch-omap/board-h3.h
index 1b12c1dcc2faf..761ea0a178972 100644
--- a/include/asm-arm/arch-omap/board-h3.h
+++ b/include/asm-arm/arch-omap/board-h3.h
@@ -30,10 +30,6 @@
/* In OMAP1710 H3 the Ethernet is directly connected to CS1 */
#define OMAP1710_ETHR_START 0x04000300
-/* Samsung NAND flash at CS2B or CS3(NAND Boot) */
-#define OMAP_NAND_FLASH_START1 0x0A000000 /* CS2B */
-#define OMAP_NAND_FLASH_START2 0x0C000000 /* CS3 */
-
#define MAXIRQNUM (IH_BOARD_BASE)
#define MAXFIQNUM MAXIRQNUM
#define MAXSWINUM MAXIRQNUM
diff --git a/include/asm-arm/arch-omap/board-h4.h b/include/asm-arm/arch-omap/board-h4.h
index 33ea29a416548..7ef664bc9e330 100644
--- a/include/asm-arm/arch-omap/board-h4.h
+++ b/include/asm-arm/arch-omap/board-h4.h
@@ -33,12 +33,6 @@
/* GPMC CS1 */
#define OMAP24XX_ETHR_START 0x08000300
#define OMAP24XX_ETHR_GPIO_IRQ 92
-
-#define H4_CS0_BASE 0x04000000
-
-#define H4_CS0_BASE 0x04000000
-
-#define H4_CS0_BASE 0x04000000
-
+#define H4_CS0_BASE 0x04000000
#endif /* __ASM_ARCH_OMAP_H4_H */
diff --git a/include/asm-arm/arch-omap/board-netstar.h b/include/asm-arm/arch-omap/board-netstar.h
deleted file mode 100644
index 77cc0fb54d54c..0000000000000
--- a/include/asm-arm/arch-omap/board-netstar.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz>
- *
- * Hardware definitions for OMAP5910 based NetStar board.
- *
- * 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.
- */
-
-#ifndef __ASM_ARCH_NETSTAR_H
-#define __ASM_ARCH_NETSTAR_H
-
-#include <asm/arch/tc.h>
-
-#define OMAP_NAND_FLASH_START1 OMAP_CS1_PHYS + (1 << 23)
-#define OMAP_NAND_FLASH_START2 OMAP_CS1_PHYS + (2 << 23)
-
-#endif /* __ASM_ARCH_NETSTAR_H */
diff --git a/include/asm-arm/arch-omap/board-nokia.h b/include/asm-arm/arch-omap/board-nokia.h
new file mode 100644
index 0000000000000..72deea203493b
--- /dev/null
+++ b/include/asm-arm/arch-omap/board-nokia.h
@@ -0,0 +1,54 @@
+/*
+ * linux/include/asm-arm/arch-omap/board-nokia.h
+ *
+ * Information structures for Nokia-specific board config data
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ */
+
+#ifndef _OMAP_BOARD_NOKIA_H
+#define _OMAP_BOARD_NOKIA_H
+
+#include <linux/types.h>
+
+#define OMAP_TAG_NOKIA_BT 0x4e01
+#define OMAP_TAG_WLAN_CX3110X 0x4e02
+#define OMAP_TAG_CBUS 0x4e03
+#define OMAP_TAG_EM_ASIC_BB5 0x4e04
+
+
+#define BT_CHIP_CSR 1
+#define BT_CHIP_TI 2
+
+#define BT_SYSCLK_12 1
+#define BT_SYSCLK_38_4 2
+
+struct omap_bluetooth_config {
+ u8 chip_type;
+ u8 bt_wakeup_gpio;
+ u8 host_wakeup_gpio;
+ u8 reset_gpio;
+ u8 bt_uart;
+ u8 bd_addr[6];
+ u8 bt_sysclk;
+};
+
+struct omap_wlan_cx3110x_config {
+ u8 chip_type;
+ s16 power_gpio;
+ s16 irq_gpio;
+ s16 spi_cs_gpio;
+};
+
+struct omap_cbus_config {
+ s16 clk_gpio;
+ s16 dat_gpio;
+ s16 sel_gpio;
+};
+
+struct omap_em_asic_bb5_config {
+ s16 retu_irq_gpio;
+ s16 tahvo_irq_gpio;
+};
+
+#endif
diff --git a/include/asm-arm/arch-omap/board-perseus2.h b/include/asm-arm/arch-omap/board-perseus2.h
index 691e52a52b433..eb74420cb4398 100644
--- a/include/asm-arm/arch-omap/board-perseus2.h
+++ b/include/asm-arm/arch-omap/board-perseus2.h
@@ -42,8 +42,4 @@
#define NR_IRQS (MAXIRQNUM + 1)
-/* Samsung NAND flash at CS2B or CS3(NAND Boot) */
-#define OMAP_NAND_FLASH_START1 0x0A000000 /* CS2B */
-#define OMAP_NAND_FLASH_START2 0x0C000000 /* CS3 */
-
#endif
diff --git a/include/asm-arm/arch-omap/board.h b/include/asm-arm/arch-omap/board.h
index a0040cd866394..6d6240a4681ca 100644
--- a/include/asm-arm/arch-omap/board.h
+++ b/include/asm-arm/arch-omap/board.h
@@ -21,9 +21,12 @@
#define OMAP_TAG_LCD 0x4f05
#define OMAP_TAG_GPIO_SWITCH 0x4f06
#define OMAP_TAG_UART 0x4f07
+#define OMAP_TAG_FBMEM 0x4f08
+#define OMAP_TAG_STI_CONSOLE 0x4f09
#define OMAP_TAG_BOOT_REASON 0x4f80
#define OMAP_TAG_FLASH_PART 0x4f81
+#define OMAP_TAG_VERSION_STR 0x4f82
struct omap_clock_config {
/* 0 for 12 MHz, 1 for 13 MHz and 2 for 19.2 MHz */
@@ -54,6 +57,11 @@ struct omap_serial_console_config {
u32 console_speed;
};
+struct omap_sti_console_config {
+ unsigned enable:1;
+ u8 channel;
+};
+
struct omap_usb_config {
/* Configure drivers according to the connectors on your board:
* - "A" connector (rectagular)
@@ -87,6 +95,13 @@ struct omap_lcd_config {
char ctrl_name[16];
};
+struct omap_fbmem_config {
+ u32 fb_sram_start;
+ u32 fb_sram_size;
+ u32 fb_sdram_start;
+ u32 fb_sdram_size;
+};
+
/* Cover:
* high -> closed
* low -> open
@@ -106,6 +121,12 @@ struct omap_gpio_switch_config {
int key_code:24; /* Linux key code */
};
+struct omap_uart_config {
+ /* Bit field of UARTs present; bit 0 --> UART1 */
+ unsigned int enabled_uarts;
+};
+
+
struct omap_flash_part_config {
char part_table[0];
};
@@ -114,11 +135,14 @@ struct omap_boot_reason_config {
char reason_str[12];
};
-struct omap_uart_config {
- /* Bit field of UARTs present; bit 0 --> UART1 */
- unsigned int enabled_uarts;
+struct omap_version_config {
+ char component[12];
+ char version[12];
};
+
+#include <asm-arm/arch-omap/board-nokia.h>
+
struct omap_board_config_entry {
u16 tag;
u16 len;
diff --git a/include/asm-arm/arch-omap/clock.h b/include/asm-arm/arch-omap/clock.h
index 46a0402696de9..3c4eb9fbe48ac 100644
--- a/include/asm-arm/arch-omap/clock.h
+++ b/include/asm-arm/arch-omap/clock.h
@@ -19,6 +19,7 @@ struct clk {
struct list_head node;
struct module *owner;
const char *name;
+ int id;
struct clk *parent;
unsigned long rate;
__u32 flags;
@@ -57,6 +58,7 @@ extern void propagate_rate(struct clk *clk);
extern void followparent_recalc(struct clk * clk);
extern void clk_allow_idle(struct clk *clk);
extern void clk_deny_idle(struct clk *clk);
+extern int clk_get_usecount(struct clk *clk);
/* Clock flags */
#define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */
@@ -80,10 +82,11 @@ extern void clk_deny_idle(struct clk *clk);
#define CM_PLL_SEL1 (1 << 18)
#define CM_PLL_SEL2 (1 << 19)
#define CM_SYSCLKOUT_SEL1 (1 << 20)
-#define CLOCK_IN_OMAP730 (1 << 21)
-#define CLOCK_IN_OMAP1510 (1 << 22)
-#define CLOCK_IN_OMAP16XX (1 << 23)
-#define CLOCK_IN_OMAP242X (1 << 24)
-#define CLOCK_IN_OMAP243X (1 << 25)
+#define CLOCK_IN_OMAP310 (1 << 21)
+#define CLOCK_IN_OMAP730 (1 << 22)
+#define CLOCK_IN_OMAP1510 (1 << 23)
+#define CLOCK_IN_OMAP16XX (1 << 24)
+#define CLOCK_IN_OMAP242X (1 << 25)
+#define CLOCK_IN_OMAP243X (1 << 26)
#endif
diff --git a/include/asm-arm/arch-omap/dma.h b/include/asm-arm/arch-omap/dma.h
index d4e73efcb816e..ca1202312a457 100644
--- a/include/asm-arm/arch-omap/dma.h
+++ b/include/asm-arm/arch-omap/dma.h
@@ -404,6 +404,7 @@ extern void omap_free_lcd_dma(void);
extern void omap_setup_lcd_dma(void);
extern void omap_enable_lcd_dma(void);
extern void omap_stop_lcd_dma(void);
+extern int omap_lcd_dma_ext_running(void);
extern void omap_set_lcd_dma_ext_controller(int external);
extern void omap_set_lcd_dma_single_transfer(int single);
extern void omap_set_lcd_dma_b1(unsigned long addr, u16 fb_xres, u16 fb_yres,
diff --git a/include/asm-arm/arch-omap/dmtimer.h b/include/asm-arm/arch-omap/dmtimer.h
index 11772c792f3e9..e6522e6a38344 100644
--- a/include/asm-arm/arch-omap/dmtimer.h
+++ b/include/asm-arm/arch-omap/dmtimer.h
@@ -88,5 +88,6 @@ unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer);
void omap_dm_timer_reset_counter(struct omap_dm_timer *timer);
int omap_dm_timers_active(void);
+u32 omap_dm_timer_modify_idlect_mask(u32 inputmask);
#endif /* __ASM_ARCH_TIMER_H */
diff --git a/include/asm-arm/arch-omap/dsp.h b/include/asm-arm/arch-omap/dsp.h
index 57bf4f39ca580..06dad83dd41f1 100644
--- a/include/asm-arm/arch-omap/dsp.h
+++ b/include/asm-arm/arch-omap/dsp.h
@@ -181,10 +181,16 @@ struct omap_dsp_varinfo {
#define OMAP_DSP_MBCMD_PM_ENABLE 0x01
#define OMAP_DSP_MBCMD_KFUNC_FBCTL 0x00
+#define OMAP_DSP_MBCMD_KFUNC_AUDIO_PWR 0x01
+#define OMAP_DSP_MBCMD_FBCTL_UPD 0x0000
#define OMAP_DSP_MBCMD_FBCTL_ENABLE 0x0002
#define OMAP_DSP_MBCMD_FBCTL_DISABLE 0x0003
+#define OMAP_DSP_MBCMD_AUDIO_PWR_UP 0x0000
+#define OMAP_DSP_MBCMD_AUDIO_PWR_DOWN1 0x0001
+#define OMAP_DSP_MBCMD_AUDIO_PWR_DOWN2 0x0002
+
#define OMAP_DSP_MBCMD_TDEL_SAFE 0x0000
#define OMAP_DSP_MBCMD_TDEL_KILL 0x0001
diff --git a/include/asm-arm/arch-omap/dsp_common.h b/include/asm-arm/arch-omap/dsp_common.h
index 4fcce6944056e..16a459dfa714a 100644
--- a/include/asm-arm/arch-omap/dsp_common.h
+++ b/include/asm-arm/arch-omap/dsp_common.h
@@ -27,11 +27,12 @@
#ifndef ASM_ARCH_DSP_COMMON_H
#define ASM_ARCH_DSP_COMMON_H
-void omap_dsp_pm_suspend(void);
-void omap_dsp_pm_resume(void);
-void omap_dsp_request_mpui(void);
-void omap_dsp_release_mpui(void);
-int omap_dsp_request_mem(void);
-int omap_dsp_release_mem(void);
+extern void omap_dsp_request_mpui(void);
+extern void omap_dsp_release_mpui(void);
+extern int omap_dsp_request_mem(void);
+extern int omap_dsp_release_mem(void);
+
+extern void (*omap_dsp_audio_pwr_up_request)(int stage);
+extern void (*omap_dsp_audio_pwr_down_request)(int stage);
#endif /* ASM_ARCH_DSP_COMMON_H */
diff --git a/include/asm-arm/arch-omap/gpioexpander.h b/include/asm-arm/arch-omap/gpioexpander.h
new file mode 100644
index 0000000000000..7a43b0a912e4e
--- /dev/null
+++ b/include/asm-arm/arch-omap/gpioexpander.h
@@ -0,0 +1,24 @@
+/*
+ * linux/include/asm-arm/arch-omap/gpioexpander.h
+ *
+ *
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
+ * This package 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 PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef __ASM_ARCH_OMAP_GPIOEXPANDER_H
+#define __ASM_ARCH_OMAP_GPIOEXPANDER_H
+
+/* Function Prototypes for GPIO Expander functions */
+
+int read_gpio_expa(u8 *, int);
+int write_gpio_expa(u8 , int);
+
+#endif /* __ASM_ARCH_OMAP_GPIOEXPANDER_H */
diff --git a/include/asm-arm/arch-omap/hardware.h b/include/asm-arm/arch-omap/hardware.h
index 5406b875c4222..7909b729826c4 100644
--- a/include/asm-arm/arch-omap/hardware.h
+++ b/include/asm-arm/arch-omap/hardware.h
@@ -306,6 +306,10 @@
#include "board-h4.h"
#endif
+#ifdef CONFIG_MACH_OMAP_APOLLON
+#include "board-apollon.h"
+#endif
+
#ifdef CONFIG_MACH_OMAP_OSK
#include "board-osk.h"
#endif
@@ -314,10 +318,6 @@
#include "board-voiceblue.h"
#endif
-#ifdef CONFIG_MACH_NETSTAR
-#include "board-netstar.h"
-#endif
-
#endif /* !__ASSEMBLER__ */
#endif /* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/include/asm-arm/arch-omap/irda.h b/include/asm-arm/arch-omap/irda.h
new file mode 100644
index 0000000000000..805ae3575e44c
--- /dev/null
+++ b/include/asm-arm/arch-omap/irda.h
@@ -0,0 +1,36 @@
+/*
+ * linux/include/asm-arm/arch-omap/irda.h
+ *
+ * Copyright (C) 2005-2006 Komal Shah <komal_shah802003@yahoo.com>
+ *
+ * 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.
+ */
+#ifndef ASMARM_ARCH_IRDA_H
+#define ASMARM_ARCH_IRDA_H
+
+/* board specific transceiver capabilities */
+
+#define IR_SEL 1 /* Selects IrDA */
+#define IR_SIRMODE 2
+#define IR_FIRMODE 4
+#define IR_MIRMODE 8
+
+struct omap_irda_config {
+ int transceiver_cap;
+ int (*transceiver_mode)(struct device *dev, int mode);
+ int (*select_irda)(struct device *dev, int state);
+ /* Very specific to the needs of some platforms (h3,h4)
+ * having calls which can sleep in irda_set_speed.
+ */
+ struct work_struct gpio_expa;
+ int rx_channel;
+ int tx_channel;
+ unsigned long dest_start;
+ unsigned long src_start;
+ int tx_trigger;
+ int rx_trigger;
+};
+
+#endif
diff --git a/include/asm-arm/arch-omap/irqs.h b/include/asm-arm/arch-omap/irqs.h
index 4ffce1d777591..42098d99f3022 100644
--- a/include/asm-arm/arch-omap/irqs.h
+++ b/include/asm-arm/arch-omap/irqs.h
@@ -242,6 +242,11 @@
#define INT_24XX_GPIO_BANK2 30
#define INT_24XX_GPIO_BANK3 31
#define INT_24XX_GPIO_BANK4 32
+#define INT_24XX_MCBSP1_IRQ_TX 59
+#define INT_24XX_MCBSP1_IRQ_RX 60
+#define INT_24XX_MCBSP2_IRQ_TX 62
+#define INT_24XX_MCBSP2_IRQ_RX 63
+#define INT_24XX_UART3_IRQ 74
/* Max. 128 level 2 IRQs (OMAP1610), 192 GPIOs (OMAP730) and
* 16 MPUIO lines */
diff --git a/include/asm-arm/arch-omap/keypad.h b/include/asm-arm/arch-omap/keypad.h
new file mode 100644
index 0000000000000..8a023a984acb5
--- /dev/null
+++ b/include/asm-arm/arch-omap/keypad.h
@@ -0,0 +1,36 @@
+/*
+ * linux/include/asm-arm/arch-omap/keypad.h
+ *
+ * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
+ *
+ * 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.
+ */
+#ifndef ASMARM_ARCH_KEYPAD_H
+#define ASMARM_ARCH_KEYPAD_H
+
+struct omap_kp_platform_data {
+ int rows;
+ int cols;
+ int *keymap;
+ unsigned int rep:1;
+ /* specific to OMAP242x*/
+ unsigned int *row_gpios;
+ unsigned int *col_gpios;
+};
+
+/* Group (0..3) -- when multiple keys are pressed, only the
+ * keys pressed in the same group are considered as pressed. This is
+ * in order to workaround certain crappy HW designs that produce ghost
+ * keypresses. */
+#define GROUP_0 (0 << 16)
+#define GROUP_1 (1 << 16)
+#define GROUP_2 (2 << 16)
+#define GROUP_3 (3 << 16)
+#define GROUP_MASK GROUP_3
+
+#define KEY(col, row, val) (((col) << 28) | ((row) << 24) | (val))
+
+#endif
+
diff --git a/include/asm-arm/arch-omap/lcd_lph8923.h b/include/asm-arm/arch-omap/lcd_lph8923.h
new file mode 100644
index 0000000000000..004e67e22ca7d
--- /dev/null
+++ b/include/asm-arm/arch-omap/lcd_lph8923.h
@@ -0,0 +1,14 @@
+#ifndef __LCD_LPH8923_H
+#define __LCD_LPH8923_H
+
+enum lcd_lph8923_test_num {
+ LCD_LPH8923_TEST_RGB_LINES,
+};
+
+enum lcd_lph8923_test_result {
+ LCD_LPH8923_TEST_SUCCESS,
+ LCD_LPH8923_TEST_INVALID,
+ LCD_LPH8923_TEST_FAILED,
+};
+
+#endif
diff --git a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
index e79d98ab2ab63..ed0dde4f72196 100644
--- a/include/asm-arm/arch-omap/mcbsp.h
+++ b/include/asm-arm/arch-omap/mcbsp.h
@@ -37,6 +37,11 @@
#define OMAP1610_MCBSP2_BASE 0xfffb1000
#define OMAP1610_MCBSP3_BASE 0xe1017000
+#define OMAP24XX_MCBSP1_BASE 0x48074000
+#define OMAP24XX_MCBSP2_BASE 0x48076000
+
+#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730)
+
#define OMAP_MCBSP_REG_DRR2 0x00
#define OMAP_MCBSP_REG_DRR1 0x02
#define OMAP_MCBSP_REG_DXR2 0x04
@@ -71,9 +76,62 @@
#define OMAP_MAX_MCBSP_COUNT 3
+#define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1)
+#define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1)
+
+#define AUDIO_MCBSP OMAP_MCBSP1
+#define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX
+#define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX
+
+#elif defined(CONFIG_ARCH_OMAP24XX)
+
+#define OMAP_MCBSP_REG_DRR2 0x00
+#define OMAP_MCBSP_REG_DRR1 0x04
+#define OMAP_MCBSP_REG_DXR2 0x08
+#define OMAP_MCBSP_REG_DXR1 0x0C
+#define OMAP_MCBSP_REG_SPCR2 0x10
+#define OMAP_MCBSP_REG_SPCR1 0x14
+#define OMAP_MCBSP_REG_RCR2 0x18
+#define OMAP_MCBSP_REG_RCR1 0x1C
+#define OMAP_MCBSP_REG_XCR2 0x20
+#define OMAP_MCBSP_REG_XCR1 0x24
+#define OMAP_MCBSP_REG_SRGR2 0x28
+#define OMAP_MCBSP_REG_SRGR1 0x2C
+#define OMAP_MCBSP_REG_MCR2 0x30
+#define OMAP_MCBSP_REG_MCR1 0x34
+#define OMAP_MCBSP_REG_RCERA 0x38
+#define OMAP_MCBSP_REG_RCERB 0x3C
+#define OMAP_MCBSP_REG_XCERA 0x40
+#define OMAP_MCBSP_REG_XCERB 0x44
+#define OMAP_MCBSP_REG_PCR0 0x48
+#define OMAP_MCBSP_REG_RCERC 0x4C
+#define OMAP_MCBSP_REG_RCERD 0x50
+#define OMAP_MCBSP_REG_XCERC 0x54
+#define OMAP_MCBSP_REG_XCERD 0x58
+#define OMAP_MCBSP_REG_RCERE 0x5C
+#define OMAP_MCBSP_REG_RCERF 0x60
+#define OMAP_MCBSP_REG_XCERE 0x64
+#define OMAP_MCBSP_REG_XCERF 0x68
+#define OMAP_MCBSP_REG_RCERG 0x6C
+#define OMAP_MCBSP_REG_RCERH 0x70
+#define OMAP_MCBSP_REG_XCERG 0x74
+#define OMAP_MCBSP_REG_XCERH 0x78
+
+#define OMAP_MAX_MCBSP_COUNT 2
+
+#define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
+#define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
+
+#define AUDIO_MCBSP OMAP_MCBSP2
+#define AUDIO_DMA_TX OMAP24XX_DMA_MCBSP2_TX
+#define AUDIO_DMA_RX OMAP24XX_DMA_MCBSP2_RX
+
+#endif
+
#define OMAP_MCBSP_READ(base, reg) __raw_readw((base) + OMAP_MCBSP_REG_##reg)
#define OMAP_MCBSP_WRITE(base, reg, val) __raw_writew((val), (base) + OMAP_MCBSP_REG_##reg)
+
/************************** McBSP SPCR1 bit definitions ***********************/
#define RRST 0x0001
#define RRDY 0x0002
@@ -195,6 +253,10 @@ typedef enum {
OMAP_MCBSP3,
} omap_mcbsp_id;
+typedef int __bitwise omap_mcbsp_io_type_t;
+#define OMAP_MCBSP_IRQ_IO ((__force omap_mcbsp_io_type_t) 1)
+#define OMAP_MCBSP_POLL_IO ((__force omap_mcbsp_io_type_t) 2)
+
typedef enum {
OMAP_MCBSP_WORD_8 = 0,
OMAP_MCBSP_WORD_12,
@@ -246,6 +308,9 @@ u32 omap_mcbsp_recv_word(unsigned int id);
int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
+int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word);
+int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word);
+
/* SPI specific API */
void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg);
diff --git a/include/asm-arm/arch-omap/mcspi.h b/include/asm-arm/arch-omap/mcspi.h
new file mode 100644
index 0000000000000..9e7f40a88e1b2
--- /dev/null
+++ b/include/asm-arm/arch-omap/mcspi.h
@@ -0,0 +1,16 @@
+#ifndef _OMAP2_MCSPI_H
+#define _OMAP2_MCSPI_H
+
+struct omap2_mcspi_platform_config {
+ unsigned long base;
+ unsigned short num_cs;
+};
+
+struct omap2_mcspi_device_config {
+ unsigned turbo_mode:1;
+
+ /* Do we want one channel enabled at the same time? */
+ unsigned single_channel:1;
+};
+
+#endif
diff --git a/include/asm-arm/arch-omap/menelaus.h b/include/asm-arm/arch-omap/menelaus.h
index 46be8b8d63465..88cd4c87f0dec 100644
--- a/include/asm-arm/arch-omap/menelaus.h
+++ b/include/asm-arm/arch-omap/menelaus.h
@@ -7,7 +7,7 @@
#ifndef __ASM_ARCH_MENELAUS_H
#define __ASM_ARCH_MENELAUS_H
-extern void menelaus_mmc_register(void (*callback)(u8 card_mask),
+extern void menelaus_mmc_register(void (*callback)(unsigned long data, u8 card_mask),
unsigned long data);
extern void menelaus_mmc_remove(void);
extern void menelaus_mmc_opendrain(int enable);
diff --git a/include/asm-arm/arch-omap/mux.h b/include/asm-arm/arch-omap/mux.h
index 13415a9aab064..0dc24d4ba59c7 100644
--- a/include/asm-arm/arch-omap/mux.h
+++ b/include/asm-arm/arch-omap/mux.h
@@ -112,14 +112,13 @@
* as mux config
*/
#define MUX_CFG_730(desc, mux_reg, mode_offset, mode, \
- pull_reg, pull_bit, pull_status, \
- pu_pd_reg, pu_pd_status, debug_status)\
+ pull_bit, pull_status, debug_status)\
{ \
.name = desc, \
.debug = debug_status, \
MUX_REG_730(mux_reg, mode_offset, mode) \
PULL_REG_730(mux_reg, pull_bit, pull_status) \
- PU_PD_REG(pu_pd_reg, pu_pd_status) \
+ PU_PD_REG(NA, 0) \
},
#define MUX_CFG_24XX(desc, reg_offset, mode, \
@@ -172,6 +171,11 @@ enum omap730_index {
E4_730_KBC2,
F4_730_KBC3,
E3_730_KBC4,
+
+ /* USB */
+ AA17_730_USB_DM,
+ W16_730_USB_PU_EN,
+ W17_730_USB_VBUSI,
};
enum omap1xxx_index {
@@ -403,9 +407,53 @@ enum omap24xx_index {
/* 24xx Menelaus interrupt */
W19_24XX_SYS_NIRQ,
+ /* 24xx clock */
+ W14_24XX_SYS_CLKOUT,
+
+ /* 242X McBSP */
+ Y15_24XX_MCBSP2_CLKX,
+ R14_24XX_MCBSP2_FSX,
+ W15_24XX_MCBSP2_DR,
+ V15_24XX_MCBSP2_DX,
+
/* 24xx GPIO */
+ M21_242X_GPIO11,
+ AA10_242X_GPIO13,
+ AA6_242X_GPIO14,
+ AA4_242X_GPIO15,
+ Y11_242X_GPIO16,
+ AA12_242X_GPIO17,
+ AA8_242X_GPIO58,
Y20_24XX_GPIO60,
+ W4__24XX_GPIO74,
M15_24XX_GPIO92,
+ V14_24XX_GPIO117,
+
+ P20_24XX_TSC_IRQ,
+
+ /* UART3 */
+ K15_24XX_UART3_TX,
+ K14_24XX_UART3_RX,
+
+ /* Keypad GPIO*/
+ T19_24XX_KBR0,
+ R19_24XX_KBR1,
+ V18_24XX_KBR2,
+ M21_24XX_KBR3,
+ E5__24XX_KBR4,
+ M18_24XX_KBR5,
+ R20_24XX_KBC0,
+ M14_24XX_KBC1,
+ H19_24XX_KBC2,
+ V17_24XX_KBC3,
+ P21_24XX_KBC4,
+ L14_24XX_KBC5,
+ N19_24XX_KBC6,
+
+ /* 24xx Menelaus Keypad GPIO */
+ B3__24XX_KBR5,
+ AA4_24XX_KBC2,
+ B13_24XX_KBC6,
};
#ifdef CONFIG_OMAP_MUX
diff --git a/include/asm-arm/arch-omap/omap-alsa.h b/include/asm-arm/arch-omap/omap-alsa.h
new file mode 100644
index 0000000000000..df4695474e3d8
--- /dev/null
+++ b/include/asm-arm/arch-omap/omap-alsa.h
@@ -0,0 +1,124 @@
+/*
+ * linux/include/asm-arm/arch-omap/omap-alsa.h
+ *
+ * Alsa Driver for AIC23 and TSC2101 codecs on OMAP platform boards.
+ *
+ * Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
+ *
+ * Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
+ * Written by Daniel Petrini, David Cohen, Anderson Briglia
+ * {daniel.petrini, david.cohen, anderson.briglia}@indt.org.br
+ *
+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * 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.
+ *
+ * History
+ * -------
+ *
+ * 2005/07/25 INdT-10LE Kernel Team - Alsa driver for omap osk,
+ * original version based in sa1100 driver
+ * and omap oss driver.
+ */
+
+#ifndef __OMAP_ALSA_H
+#define __OMAP_ALSA_H
+
+#include <sound/driver.h>
+#include <asm/arch/dma.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <asm/arch/mcbsp.h>
+#include <linux/platform_device.h>
+
+#define DMA_BUF_SIZE (1024 * 8)
+
+/*
+ * Buffer management for alsa and dma
+ */
+struct audio_stream {
+ char *id; /* identification string */
+ int stream_id; /* numeric identification */
+ int dma_dev; /* dma number of that device */
+ int *lch; /* Chain of channels this stream is linked to */
+ char started; /* to store if the chain was started or not */
+ int dma_q_head; /* DMA Channel Q Head */
+ int dma_q_tail; /* DMA Channel Q Tail */
+ char dma_q_count; /* DMA Channel Q Count */
+ int active:1; /* we are using this stream for transfer now */
+ int period; /* current transfer period */
+ int periods; /* current count of periods registerd in the DMA engine */
+ spinlock_t dma_lock; /* for locking in DMA operations */
+ snd_pcm_substream_t *stream; /* the pcm stream */
+ unsigned linked:1; /* dma channels linked */
+ int offset; /* store start position of the last period in the alsa buffer */
+ int (*hw_start)(void); /* interface to start HW interface, e.g. McBSP */
+ int (*hw_stop)(void); /* interface to stop HW interface, e.g. McBSP */
+};
+
+/*
+ * Alsa card structure for aic23
+ */
+struct snd_card_omap_codec {
+ snd_card_t *card;
+ snd_pcm_t *pcm;
+ long samplerate;
+ struct audio_stream s[2]; /* playback & capture */
+};
+
+/* Codec specific information and function pointers.
+ * Codec (omap-alsa-aic23.c and omap-alsa-tsc2101.c)
+ * are responsible for defining the function pointers.
+ */
+struct omap_alsa_codec_config {
+ char *name;
+ struct omap_mcbsp_reg_cfg *mcbsp_regs_alsa;
+ snd_pcm_hw_constraint_list_t *hw_constraints_rates;
+ snd_pcm_hardware_t *snd_omap_alsa_playback;
+ snd_pcm_hardware_t *snd_omap_alsa_capture;
+ void (*codec_configure_dev)(void);
+ void (*codec_set_samplerate)(long);
+ void (*codec_clock_setup)(void);
+ int (*codec_clock_on)(void);
+ int (*codec_clock_off)(void);
+ int (*get_default_samplerate)(void);
+};
+
+/*********** Mixer function prototypes *************************/
+int snd_omap_mixer(struct snd_card_omap_codec *);
+void snd_omap_init_mixer(void);
+
+#ifdef CONFIG_PM
+void snd_omap_suspend_mixer(void);
+void snd_omap_resume_mixer(void);
+#endif
+
+int snd_omap_alsa_post_probe(struct platform_device *pdev, struct omap_alsa_codec_config *config);
+int snd_omap_alsa_remove(struct platform_device *pdev);
+#ifdef CONFIG_PM
+int snd_omap_alsa_suspend(struct platform_device *pdev, pm_message_t state);
+int snd_omap_alsa_resume(struct platform_device *pdev);
+#else
+#define snd_omap_alsa_suspend NULL
+#define snd_omap_alsa_resume NULL
+#endif
+
+void callback_omap_alsa_sound_dma(void *);
+
+#endif
diff --git a/include/asm-arm/arch-omap/omapfb.h b/include/asm-arm/arch-omap/omapfb.h
index 4ba2622cc1428..fccdb3db025ff 100644
--- a/include/asm-arm/arch-omap/omapfb.h
+++ b/include/asm-arm/arch-omap/omapfb.h
@@ -34,9 +34,10 @@
#define OMAPFB_MIRROR OMAP_IOW(31, int)
#define OMAPFB_SYNC_GFX OMAP_IO(37)
#define OMAPFB_VSYNC OMAP_IO(38)
-#define OMAPFB_SET_UPDATE_MODE OMAP_IOW(40, enum omapfb_update_mode)
+#define OMAPFB_SET_UPDATE_MODE OMAP_IOW(40, int)
+#define OMAPFB_UPDATE_WINDOW_OLD OMAP_IOW(41, struct omapfb_update_window_old)
#define OMAPFB_GET_CAPS OMAP_IOR(42, unsigned long)
-#define OMAPFB_GET_UPDATE_MODE OMAP_IOW(43, enum omapfb_update_mode)
+#define OMAPFB_GET_UPDATE_MODE OMAP_IOW(43, int)
#define OMAPFB_LCD_TEST OMAP_IOW(45, int)
#define OMAPFB_CTRL_TEST OMAP_IOW(46, int)
#define OMAPFB_UPDATE_WINDOW OMAP_IOW(47, struct omapfb_update_window)
@@ -66,9 +67,14 @@ enum omapfb_color_format {
};
struct omapfb_update_window {
- u32 x, y;
- u32 width, height;
- u32 format;
+ __u32 x, y;
+ __u32 width, height;
+ __u32 format;
+};
+
+struct omapfb_update_window_old {
+ __u32 x, y;
+ __u32 width, height;
};
enum omapfb_plane {
@@ -83,17 +89,17 @@ enum omapfb_channel_out {
};
struct omapfb_setup_plane {
- u8 plane;
- u8 channel_out;
- u32 offset;
- u32 pos_x, pos_y;
- u32 width, height;
- u32 color_mode;
+ __u8 plane;
+ __u8 channel_out;
+ __u32 offset;
+ __u32 pos_x, pos_y;
+ __u32 width, height;
+ __u32 color_mode;
};
struct omapfb_enable_plane {
- u8 plane;
- u8 enable;
+ __u8 plane;
+ __u8 enable;
};
enum omapfb_color_key_type {
@@ -103,10 +109,10 @@ enum omapfb_color_key_type {
};
struct omapfb_color_key {
- u8 channel_out;
- u32 background;
- u32 trans_key;
- u8 key_type;
+ __u8 channel_out;
+ __u32 background;
+ __u32 trans_key;
+ __u8 key_type;
};
enum omapfb_update_mode {
@@ -120,6 +126,9 @@ enum omapfb_update_mode {
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/fb.h>
+#include <linux/mutex.h>
+
+#include <asm/arch/board.h>
#define OMAP_LCDC_INV_VSYNC 0x0001
#define OMAP_LCDC_INV_HSYNC 0x0002
@@ -184,19 +193,38 @@ struct extif_timings {
int re_cycle_time;
int cs_pulse_width;
int access_time;
+
+ int clk_div;
+
+ u32 tim[5]; /* set by extif->convert_timings */
+
+ int converted;
};
struct lcd_ctrl_extif {
int (*init) (void);
void (*cleanup) (void);
+ void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
+ int (*convert_timings) (struct extif_timings *timings);
void (*set_timings) (const struct extif_timings *timings);
- void (*write_command) (u32 cmd);
- u32 (*read_data) (void);
- void (*write_data) (u32 data);
+ void (*set_bits_per_cycle)(int bpc);
+ void (*write_command) (const void *buf, unsigned int len);
+ void (*read_data) (void *buf, unsigned int len);
+ void (*write_data) (const void *buf, unsigned int len);
void (*transfer_area) (int width, int height,
void (callback)(void * data), void *data);
+ unsigned long max_transmit_size;
};
+struct omapfb_notifier_block {
+ struct notifier_block nb;
+ void *data;
+};
+
+typedef int (*omapfb_notifier_callback_t)(struct omapfb_notifier_block *,
+ unsigned long event,
+ struct omapfb_device *fbdev);
+
struct lcd_ctrl {
const char *name;
void *data;
@@ -204,9 +232,11 @@ struct lcd_ctrl {
int (*init) (struct omapfb_device *fbdev,
int ext_mode, int req_vram_size);
void (*cleanup) (void);
+ void (*bind_client) (struct omapfb_notifier_block *nb);
void (*get_vram_layout)(unsigned long *size,
void **virt_base,
dma_addr_t *phys_base);
+ int (*mmap) (struct vm_area_struct *vma);
unsigned long (*get_caps) (void);
int (*set_update_mode)(enum omapfb_update_mode mode);
enum omapfb_update_mode (*get_update_mode)(void);
@@ -240,7 +270,7 @@ struct omapfb_device {
int state;
int ext_lcdc; /* Using external
LCD controller */
- struct semaphore rqueue_sema;
+ struct mutex rqueue_mutex;
void *vram_virt_base;
dma_addr_t vram_phys_base;
@@ -261,12 +291,13 @@ struct omapfb_device {
struct device *dev;
};
-extern struct lcd_panel h3_panel;
-extern struct lcd_panel h2_panel;
-extern struct lcd_panel p2_panel;
-extern struct lcd_panel osk_panel;
-extern struct lcd_panel innovator1610_panel;
-extern struct lcd_panel innovator1510_panel;
+struct omapfb_platform_data {
+ struct omap_lcd_config lcd;
+ struct omap_fbmem_config fbmem;
+};
+
+#define OMAPFB_EVENT_READY 1
+#define OMAPFB_EVENT_DISABLED 2
#ifdef CONFIG_ARCH_OMAP1
extern struct lcd_ctrl omap1_lcd_ctrl;
@@ -274,7 +305,20 @@ extern struct lcd_ctrl omap1_lcd_ctrl;
extern struct lcd_ctrl omap2_disp_ctrl;
#endif
+extern void omapfb_register_panel(struct lcd_panel *panel);
extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
+extern void omapfb_notify_clients(struct omapfb_device *fbdev,
+ unsigned long event);
+extern int omapfb_register_client(struct omapfb_notifier_block *nb,
+ omapfb_notifier_callback_t callback,
+ void *callback_data);
+extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
+extern int omapfb_update_window_async(struct omapfb_update_window *win,
+ void (*callback)(void *),
+ void *callback_data);
+
+/* in arch/arm/plat-omap/devices.c */
+extern void omapfb_reserve_mem(void);
#endif /* __KERNEL__ */
diff --git a/include/asm-arm/arch-omap/param.h b/include/asm-arm/arch-omap/param.h
new file mode 100644
index 0000000000000..face9ad41e97a
--- /dev/null
+++ b/include/asm-arm/arch-omap/param.h
@@ -0,0 +1,8 @@
+/*
+ * linux/include/asm-arm/arch-omap/param.h
+ *
+ */
+
+#ifdef CONFIG_OMAP_32K_TIMER_HZ
+#define HZ CONFIG_OMAP_32K_TIMER_HZ
+#endif
diff --git a/include/asm-arm/arch-omap/pm.h b/include/asm-arm/arch-omap/pm.h
index 7c790425e3633..05b003f3a94c6 100644
--- a/include/asm-arm/arch-omap/pm.h
+++ b/include/asm-arm/arch-omap/pm.h
@@ -49,7 +49,7 @@
/*
* ----------------------------------------------------------------------------
- * Powermanagement bitmasks
+ * Power management bitmasks
* ----------------------------------------------------------------------------
*/
#define IDLE_WAIT_CYCLES 0x00000fff
@@ -112,32 +112,59 @@
#endif
#ifndef __ASSEMBLER__
+
+#include <linux/clk.h>
+
+extern void prevent_idle_sleep(void);
+extern void allow_idle_sleep(void);
+
+/**
+ * clk_deny_idle - Prevents the clock from being idled during MPU idle
+ * @clk: clock signal handle
+ */
+void clk_deny_idle(struct clk *clk);
+
+/**
+ * clk_allow_idle - Counters previous clk_deny_idle
+ * @clk: clock signal handle
+ */
+void clk_deny_idle(struct clk *clk);
+
extern void omap_pm_idle(void);
extern void omap_pm_suspend(void);
extern void omap730_cpu_suspend(unsigned short, unsigned short);
extern void omap1510_cpu_suspend(unsigned short, unsigned short);
extern void omap1610_cpu_suspend(unsigned short, unsigned short);
+extern void omap24xx_cpu_suspend(u32 dll_ctrl, u32 cpu_revision);
extern void omap730_idle_loop_suspend(void);
extern void omap1510_idle_loop_suspend(void);
extern void omap1610_idle_loop_suspend(void);
+extern void omap24xx_idle_loop_suspend(void);
+
+extern unsigned int omap730_cpu_suspend_sz;
+extern unsigned int omap1510_cpu_suspend_sz;
+extern unsigned int omap1610_cpu_suspend_sz;
+extern unsigned int omap24xx_cpu_suspend_sz;
+extern unsigned int omap730_idle_loop_suspend_sz;
+extern unsigned int omap1510_idle_loop_suspend_sz;
+extern unsigned int omap1610_idle_loop_suspend_sz;
+extern unsigned int omap24xx_idle_loop_suspend_sz;
#ifdef CONFIG_OMAP_SERIAL_WAKE
extern void omap_serial_wake_trigger(int enable);
#else
+#define omap_serial_wakeup_init() {}
#define omap_serial_wake_trigger(x) {}
#endif /* CONFIG_OMAP_SERIAL_WAKE */
-extern unsigned int omap730_cpu_suspend_sz;
-extern unsigned int omap730_idle_loop_suspend_sz;
-extern unsigned int omap1510_cpu_suspend_sz;
-extern unsigned int omap1510_idle_loop_suspend_sz;
-extern unsigned int omap1610_cpu_suspend_sz;
-extern unsigned int omap1610_idle_loop_suspend_sz;
-
#define ARM_SAVE(x) arm_sleep_save[ARM_SLEEP_SAVE_##x] = omap_readl(x)
#define ARM_RESTORE(x) omap_writel((arm_sleep_save[ARM_SLEEP_SAVE_##x]), (x))
#define ARM_SHOW(x) arm_sleep_save[ARM_SLEEP_SAVE_##x]
+#define DSP_SAVE(x) dsp_sleep_save[DSP_SLEEP_SAVE_##x] = __raw_readw(x)
+#define DSP_RESTORE(x) __raw_writew((dsp_sleep_save[DSP_SLEEP_SAVE_##x]), (x))
+#define DSP_SHOW(x) dsp_sleep_save[DSP_SLEEP_SAVE_##x]
+
#define ULPD_SAVE(x) ulpd_sleep_save[ULPD_SLEEP_SAVE_##x] = omap_readw(x)
#define ULPD_RESTORE(x) omap_writew((ulpd_sleep_save[ULPD_SLEEP_SAVE_##x]), (x))
#define ULPD_SHOW(x) ulpd_sleep_save[ULPD_SLEEP_SAVE_##x]
@@ -154,6 +181,10 @@ extern unsigned int omap1610_idle_loop_suspend_sz;
#define MPUI1610_RESTORE(x) omap_writel((mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_##x]), (x))
#define MPUI1610_SHOW(x) mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_##x]
+#define OMAP24XX_SAVE(x) omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_##x] = x
+#define OMAP24XX_RESTORE(x) x = omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_##x]
+#define OMAP24XX_SHOW(x) omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_##x]
+
/*
* List of global OMAP registers to preserve.
* More ones like CP and general purpose register values are preserved
@@ -176,6 +207,15 @@ enum arm_save_state {
ARM_SLEEP_SAVE_SIZE
};
+enum dsp_save_state {
+ DSP_SLEEP_SAVE_START = 0,
+ /*
+ * DSP registers 16 bits
+ */
+ DSP_SLEEP_SAVE_DSP_IDLECT2,
+ DSP_SLEEP_SAVE_SIZE
+};
+
enum ulpd_save_state {
ULPD_SLEEP_SAVE_START = 0,
/*
@@ -254,5 +294,30 @@ enum mpui1610_save_state {
#endif
};
+enum omap24xx_save_state {
+ OMAP24XX_SLEEP_SAVE_START = 0,
+ OMAP24XX_SLEEP_SAVE_INTC_MIR0,
+ OMAP24XX_SLEEP_SAVE_INTC_MIR1,
+ OMAP24XX_SLEEP_SAVE_INTC_MIR2,
+ OMAP24XX_SLEEP_SAVE_CM_FCLKEN1_CORE,
+ OMAP24XX_SLEEP_SAVE_CM_FCLKEN2_CORE,
+ OMAP24XX_SLEEP_SAVE_CM_ICLKEN1_CORE,
+ OMAP24XX_SLEEP_SAVE_CM_ICLKEN2_CORE,
+ OMAP24XX_SLEEP_SAVE_CM_ICLKEN4_CORE,
+ OMAP24XX_SLEEP_SAVE_GPIO1_IRQENABLE1,
+ OMAP24XX_SLEEP_SAVE_GPIO2_IRQENABLE1,
+ OMAP24XX_SLEEP_SAVE_GPIO3_IRQENABLE1,
+ OMAP24XX_SLEEP_SAVE_GPIO4_IRQENABLE1,
+ OMAP24XX_SLEEP_SAVE_GPIO3_OE,
+ OMAP24XX_SLEEP_SAVE_GPIO4_OE,
+ OMAP24XX_SLEEP_SAVE_GPIO3_RISINGDETECT,
+ OMAP24XX_SLEEP_SAVE_GPIO3_FALLINGDETECT,
+ OMAP24XX_SLEEP_SAVE_CONTROL_PADCONF_SPI1_NCS2,
+ OMAP24XX_SLEEP_SAVE_CONTROL_PADCONF_MCBSP1_DX,
+ OMAP24XX_SLEEP_SAVE_CONTROL_PADCONF_SSI1_FLAG_TX,
+ OMAP24XX_SLEEP_SAVE_CONTROL_PADCONF_SYS_NIRQW0,
+ OMAP24XX_SLEEP_SAVE_SIZE
+};
+
#endif /* ASSEMBLER */
#endif /* __ASM_ARCH_OMAP_PM_H */
diff --git a/include/asm-arm/arch-omap/prcm.h b/include/asm-arm/arch-omap/prcm.h
index 7b48a5cbb15fc..7bcaf94bde9f5 100644
--- a/include/asm-arm/arch-omap/prcm.h
+++ b/include/asm-arm/arch-omap/prcm.h
@@ -1,5 +1,7 @@
/*
- * prcm.h - Access definations for use in OMAP24XX clock and power management
+ * linux/include/asm-arm/arch-omap/prcm.h
+ *
+ * Access definations for use in OMAP24XX clock and power management
*
* Copyright (C) 2005 Texas Instruments, Inc.
*
@@ -21,405 +23,7 @@
#ifndef __ASM_ARM_ARCH_DPM_PRCM_H
#define __ASM_ARM_ARCH_DPM_PRCM_H
-/* SET_PERFORMANCE_LEVEL PARAMETERS */
-#define PRCM_HALF_SPEED 1
-#define PRCM_FULL_SPEED 2
-
-#ifndef __ASSEMBLER__
-
-#define PRCM_REG32(offset) __REG32(OMAP24XX_PRCM_BASE + (offset))
-
-#define PRCM_REVISION PRCM_REG32(0x000)
-#define PRCM_SYSCONFIG PRCM_REG32(0x010)
-#define PRCM_IRQSTATUS_MPU PRCM_REG32(0x018)
-#define PRCM_IRQENABLE_MPU PRCM_REG32(0x01C)
-#define PRCM_VOLTCTRL PRCM_REG32(0x050)
-#define PRCM_VOLTST PRCM_REG32(0x054)
-#define PRCM_CLKSRC_CTRL PRCM_REG32(0x060)
-#define PRCM_CLKOUT_CTRL PRCM_REG32(0x070)
-#define PRCM_CLKEMUL_CTRL PRCM_REG32(0x078)
-#define PRCM_CLKCFG_CTRL PRCM_REG32(0x080)
-#define PRCM_CLKCFG_STATUS PRCM_REG32(0x084)
-#define PRCM_VOLTSETUP PRCM_REG32(0x090)
-#define PRCM_CLKSSETUP PRCM_REG32(0x094)
-#define PRCM_POLCTRL PRCM_REG32(0x098)
-
-/* GENERAL PURPOSE */
-#define GENERAL_PURPOSE1 PRCM_REG32(0x0B0)
-#define GENERAL_PURPOSE2 PRCM_REG32(0x0B4)
-#define GENERAL_PURPOSE3 PRCM_REG32(0x0B8)
-#define GENERAL_PURPOSE4 PRCM_REG32(0x0BC)
-#define GENERAL_PURPOSE5 PRCM_REG32(0x0C0)
-#define GENERAL_PURPOSE6 PRCM_REG32(0x0C4)
-#define GENERAL_PURPOSE7 PRCM_REG32(0x0C8)
-#define GENERAL_PURPOSE8 PRCM_REG32(0x0CC)
-#define GENERAL_PURPOSE9 PRCM_REG32(0x0D0)
-#define GENERAL_PURPOSE10 PRCM_REG32(0x0D4)
-#define GENERAL_PURPOSE11 PRCM_REG32(0x0D8)
-#define GENERAL_PURPOSE12 PRCM_REG32(0x0DC)
-#define GENERAL_PURPOSE13 PRCM_REG32(0x0E0)
-#define GENERAL_PURPOSE14 PRCM_REG32(0x0E4)
-#define GENERAL_PURPOSE15 PRCM_REG32(0x0E8)
-#define GENERAL_PURPOSE16 PRCM_REG32(0x0EC)
-#define GENERAL_PURPOSE17 PRCM_REG32(0x0F0)
-#define GENERAL_PURPOSE18 PRCM_REG32(0x0F4)
-#define GENERAL_PURPOSE19 PRCM_REG32(0x0F8)
-#define GENERAL_PURPOSE20 PRCM_REG32(0x0FC)
-
-/* MPU */
-#define CM_CLKSEL_MPU PRCM_REG32(0x140)
-#define CM_CLKSTCTRL_MPU PRCM_REG32(0x148)
-#define RM_RSTST_MPU PRCM_REG32(0x158)
-#define PM_WKDEP_MPU PRCM_REG32(0x1C8)
-#define PM_EVGENCTRL_MPU PRCM_REG32(0x1D4)
-#define PM_EVEGENONTIM_MPU PRCM_REG32(0x1D8)
-#define PM_EVEGENOFFTIM_MPU PRCM_REG32(0x1DC)
-#define PM_PWSTCTRL_MPU PRCM_REG32(0x1E0)
-#define PM_PWSTST_MPU PRCM_REG32(0x1E4)
-
-/* CORE */
-#define CM_FCLKEN1_CORE PRCM_REG32(0x200)
-#define CM_FCLKEN2_CORE PRCM_REG32(0x204)
-#define CM_FCLKEN3_CORE PRCM_REG32(0x208)
-#define CM_ICLKEN1_CORE PRCM_REG32(0x210)
-#define CM_ICLKEN2_CORE PRCM_REG32(0x214)
-#define CM_ICLKEN3_CORE PRCM_REG32(0x218)
-#define CM_ICLKEN4_CORE PRCM_REG32(0x21C)
-#define CM_IDLEST1_CORE PRCM_REG32(0x220)
-#define CM_IDLEST2_CORE PRCM_REG32(0x224)
-#define CM_IDLEST3_CORE PRCM_REG32(0x228)
-#define CM_IDLEST4_CORE PRCM_REG32(0x22C)
-#define CM_AUTOIDLE1_CORE PRCM_REG32(0x230)
-#define CM_AUTOIDLE2_CORE PRCM_REG32(0x234)
-#define CM_AUTOIDLE3_CORE PRCM_REG32(0x238)
-#define CM_AUTOIDLE4_CORE PRCM_REG32(0x23C)
-#define CM_CLKSEL1_CORE PRCM_REG32(0x240)
-#define CM_CLKSEL2_CORE PRCM_REG32(0x244)
-#define CM_CLKSTCTRL_CORE PRCM_REG32(0x248)
-#define PM_WKEN1_CORE PRCM_REG32(0x2A0)
-#define PM_WKEN2_CORE PRCM_REG32(0x2A4)
-#define PM_WKST1_CORE PRCM_REG32(0x2B0)
-#define PM_WKST2_CORE PRCM_REG32(0x2B4)
-#define PM_WKDEP_CORE PRCM_REG32(0x2C8)
-#define PM_PWSTCTRL_CORE PRCM_REG32(0x2E0)
-#define PM_PWSTST_CORE PRCM_REG32(0x2E4)
-
-/* GFX */
-#define CM_FCLKEN_GFX PRCM_REG32(0x300)
-#define CM_ICLKEN_GFX PRCM_REG32(0x310)
-#define CM_IDLEST_GFX PRCM_REG32(0x320)
-#define CM_CLKSEL_GFX PRCM_REG32(0x340)
-#define CM_CLKSTCTRL_GFX PRCM_REG32(0x348)
-#define RM_RSTCTRL_GFX PRCM_REG32(0x350)
-#define RM_RSTST_GFX PRCM_REG32(0x358)
-#define PM_WKDEP_GFX PRCM_REG32(0x3C8)
-#define PM_PWSTCTRL_GFX PRCM_REG32(0x3E0)
-#define PM_PWSTST_GFX PRCM_REG32(0x3E4)
-
-/* WAKE-UP */
-#define CM_FCLKEN_WKUP PRCM_REG32(0x400)
-#define CM_ICLKEN_WKUP PRCM_REG32(0x410)
-#define CM_IDLEST_WKUP PRCM_REG32(0x420)
-#define CM_AUTOIDLE_WKUP PRCM_REG32(0x430)
-#define CM_CLKSEL_WKUP PRCM_REG32(0x440)
-#define RM_RSTCTRL_WKUP PRCM_REG32(0x450)
-#define RM_RSTTIME_WKUP PRCM_REG32(0x454)
-#define RM_RSTST_WKUP PRCM_REG32(0x458)
-#define PM_WKEN_WKUP PRCM_REG32(0x4A0)
-#define PM_WKST_WKUP PRCM_REG32(0x4B0)
-
-/* CLOCKS */
-#define CM_CLKEN_PLL PRCM_REG32(0x500)
-#define CM_IDLEST_CKGEN PRCM_REG32(0x520)
-#define CM_AUTOIDLE_PLL PRCM_REG32(0x530)
-#define CM_CLKSEL1_PLL PRCM_REG32(0x540)
-#define CM_CLKSEL2_PLL PRCM_REG32(0x544)
-
-/* DSP */
-#define CM_FCLKEN_DSP PRCM_REG32(0x800)
-#define CM_ICLKEN_DSP PRCM_REG32(0x810)
-#define CM_IDLEST_DSP PRCM_REG32(0x820)
-#define CM_AUTOIDLE_DSP PRCM_REG32(0x830)
-#define CM_CLKSEL_DSP PRCM_REG32(0x840)
-#define CM_CLKSTCTRL_DSP PRCM_REG32(0x848)
-#define RM_RSTCTRL_DSP PRCM_REG32(0x850)
-#define RM_RSTST_DSP PRCM_REG32(0x858)
-#define PM_WKEN_DSP PRCM_REG32(0x8A0)
-#define PM_WKDEP_DSP PRCM_REG32(0x8C8)
-#define PM_PWSTCTRL_DSP PRCM_REG32(0x8E0)
-#define PM_PWSTST_DSP PRCM_REG32(0x8E4)
-#define PRCM_IRQSTATUS_DSP PRCM_REG32(0x8F0)
-#define PRCM_IRQENABLE_DSP PRCM_REG32(0x8F4)
-
-/* IVA */
-#define PRCM_IRQSTATUS_IVA PRCM_REG32(0x8F8)
-#define PRCM_IRQENABLE_IVA PRCM_REG32(0x8FC)
-
-/* Modem on 2430 */
-#define CM_FCLKEN_MDM PRCM_REG32(0xC00)
-#define CM_ICLKEN_MDM PRCM_REG32(0xC10)
-#define CM_IDLEST_MDM PRCM_REG32(0xC20)
-#define CM_CLKSEL_MDM PRCM_REG32(0xC40)
-
-/* FIXME: Move to header for 2430 */
-#define DISP_BASE (OMAP24XX_L4_IO_BASE+0x50000)
-#define DISP_REG32(offset) __REG32(DISP_BASE + (offset))
-
-#define OMAP24XX_GPMC_BASE (L3_24XX_BASE + 0xa000)
-#define GPMC_BASE (OMAP24XX_GPMC_BASE)
-#define GPMC_REG32(offset) __REG32(GPMC_BASE + (offset))
-
-#define GPT1_BASE (OMAP24XX_GPT1)
-#define GPT1_REG32(offset) __REG32(GPT1_BASE + (offset))
-
-/* Misc sysconfig */
-#define DISPC_SYSCONFIG DISP_REG32(0x410)
-#define SPI_BASE (OMAP24XX_L4_IO_BASE+0x98000)
-#define MCSPI1_SYSCONFIG __REG32(SPI_BASE + 0x10)
-#define MCSPI2_SYSCONFIG __REG32(SPI_BASE+0x2000 + 0x10)
-
-//#define DSP_MMU_SYSCONFIG 0x5A000010
-#define CAMERA_MMU_SYSCONFIG __REG32(DISP_BASE+0x2C10)
-//#define IVA_MMU_SYSCONFIG 0x5D000010
-//#define DSP_DMA_SYSCONFIG 0x00FCC02C
-#define CAMERA_DMA_SYSCONFIG __REG32(DISP_BASE+0x282C)
-#define SYSTEM_DMA_SYSCONFIG __REG32(DISP_BASE+0x602C)
-#define GPMC_SYSCONFIG GPMC_REG32(0x010)
-#define MAILBOXES_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x94010)
-#define UART1_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x6A054)
-#define UART2_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x6C054)
-#define UART3_SYSCONFIG __REG32(OMAP24XX_L4_IO_BASE+0x6E054)
-//#define IVA_SYSCONFIG 0x5C060010
-#define SDRC_SYSCONFIG __REG32(OMAP24XX_SDRC_BASE+0x10)
-#define SMS_SYSCONFIG __REG32(OMAP24XX_SMS_BASE+0x10)
-#define SSI_SYSCONFIG __REG32(DISP_BASE+0x8010)
-//#define VLYNQ_SYSCONFIG 0x67FFFE10
-
-/* rkw - good cannidates for PM_ to start what nm was trying */
-#define OMAP24XX_GPT2 (OMAP24XX_L4_IO_BASE+0x2A000)
-#define OMAP24XX_GPT3 (OMAP24XX_L4_IO_BASE+0x78000)
-#define OMAP24XX_GPT4 (OMAP24XX_L4_IO_BASE+0x7A000)
-#define OMAP24XX_GPT5 (OMAP24XX_L4_IO_BASE+0x7C000)
-#define OMAP24XX_GPT6 (OMAP24XX_L4_IO_BASE+0x7E000)
-#define OMAP24XX_GPT7 (OMAP24XX_L4_IO_BASE+0x80000)
-#define OMAP24XX_GPT8 (OMAP24XX_L4_IO_BASE+0x82000)
-#define OMAP24XX_GPT9 (OMAP24XX_L4_IO_BASE+0x84000)
-#define OMAP24XX_GPT10 (OMAP24XX_L4_IO_BASE+0x86000)
-#define OMAP24XX_GPT11 (OMAP24XX_L4_IO_BASE+0x88000)
-#define OMAP24XX_GPT12 (OMAP24XX_L4_IO_BASE+0x8A000)
-
-#define GPTIMER1_SYSCONFIG GPT1_REG32(0x010)
-#define GPTIMER2_SYSCONFIG __REG32(OMAP24XX_GPT2 + 0x10)
-#define GPTIMER3_SYSCONFIG __REG32(OMAP24XX_GPT3 + 0x10)
-#define GPTIMER4_SYSCONFIG __REG32(OMAP24XX_GPT4 + 0x10)
-#define GPTIMER5_SYSCONFIG __REG32(OMAP24XX_GPT5 + 0x10)
-#define GPTIMER6_SYSCONFIG __REG32(OMAP24XX_GPT6 + 0x10)
-#define GPTIMER7_SYSCONFIG __REG32(OMAP24XX_GPT7 + 0x10)
-#define GPTIMER8_SYSCONFIG __REG32(OMAP24XX_GPT8 + 0x10)
-#define GPTIMER9_SYSCONFIG __REG32(OMAP24XX_GPT9 + 0x10)
-#define GPTIMER10_SYSCONFIG __REG32(OMAP24XX_GPT10 + 0x10)
-#define GPTIMER11_SYSCONFIG __REG32(OMAP24XX_GPT11 + 0x10)
-#define GPTIMER12_SYSCONFIG __REG32(OMAP24XX_GPT12 + 0x10)
-
-#define GPIOX_BASE(X) (OMAP24XX_GPIO_BASE+(0x2000*((X)-1)))
-
-#define GPIO1_SYSCONFIG __REG32((GPIOX_BASE(1)+0x10))
-#define GPIO2_SYSCONFIG __REG32((GPIOX_BASE(2)+0x10))
-#define GPIO3_SYSCONFIG __REG32((GPIOX_BASE(3)+0x10))
-#define GPIO4_SYSCONFIG __REG32((GPIOX_BASE(4)+0x10))
-
-/* GP TIMER 1 */
-#define GPTIMER1_TISTAT GPT1_REG32(0x014)
-#define GPTIMER1_TISR GPT1_REG32(0x018)
-#define GPTIMER1_TIER GPT1_REG32(0x01C)
-#define GPTIMER1_TWER GPT1_REG32(0x020)
-#define GPTIMER1_TCLR GPT1_REG32(0x024)
-#define GPTIMER1_TCRR GPT1_REG32(0x028)
-#define GPTIMER1_TLDR GPT1_REG32(0x02C)
-#define GPTIMER1_TTGR GPT1_REG32(0x030)
-#define GPTIMER1_TWPS GPT1_REG32(0x034)
-#define GPTIMER1_TMAR GPT1_REG32(0x038)
-#define GPTIMER1_TCAR1 GPT1_REG32(0x03C)
-#define GPTIMER1_TSICR GPT1_REG32(0x040)
-#define GPTIMER1_TCAR2 GPT1_REG32(0x044)
-
-/* rkw -- base fix up please... */
-#define GPTIMER3_TISR __REG32(OMAP24XX_L4_IO_BASE+0x78018)
-
-/* SDRC */
-#define SDRC_DLLA_CTRL __REG32(OMAP24XX_SDRC_BASE+0x060)
-#define SDRC_DLLA_STATUS __REG32(OMAP24XX_SDRC_BASE+0x064)
-#define SDRC_DLLB_CTRL __REG32(OMAP24XX_SDRC_BASE+0x068)
-#define SDRC_DLLB_STATUS __REG32(OMAP24XX_SDRC_BASE+0x06C)
-#define SDRC_POWER __REG32(OMAP24XX_SDRC_BASE+0x070)
-#define SDRC_MR_0 __REG32(OMAP24XX_SDRC_BASE+0x084)
-
-/* GPIO 1 */
-#define GPIO1_BASE GPIOX_BASE(1)
-#define GPIO1_REG32(offset) __REG32(GPIO1_BASE + (offset))
-#define GPIO1_IRQENABLE1 GPIO1_REG32(0x01C)
-#define GPIO1_IRQSTATUS1 GPIO1_REG32(0x018)
-#define GPIO1_IRQENABLE2 GPIO1_REG32(0x02C)
-#define GPIO1_IRQSTATUS2 GPIO1_REG32(0x028)
-#define GPIO1_WAKEUPENABLE GPIO1_REG32(0x020)
-#define GPIO1_RISINGDETECT GPIO1_REG32(0x048)
-#define GPIO1_DATAIN GPIO1_REG32(0x038)
-#define GPIO1_OE GPIO1_REG32(0x034)
-#define GPIO1_DATAOUT GPIO1_REG32(0x03C)
-
-/* GPIO2 */
-#define GPIO2_BASE GPIOX_BASE(2)
-#define GPIO2_REG32(offset) __REG32(GPIO2_BASE + (offset))
-#define GPIO2_IRQENABLE1 GPIO2_REG32(0x01C)
-#define GPIO2_IRQSTATUS1 GPIO2_REG32(0x018)
-#define GPIO2_IRQENABLE2 GPIO2_REG32(0x02C)
-#define GPIO2_IRQSTATUS2 GPIO2_REG32(0x028)
-#define GPIO2_WAKEUPENABLE GPIO2_REG32(0x020)
-#define GPIO2_RISINGDETECT GPIO2_REG32(0x048)
-#define GPIO2_DATAIN GPIO2_REG32(0x038)
-#define GPIO2_OE GPIO2_REG32(0x034)
-#define GPIO2_DATAOUT GPIO2_REG32(0x03C)
-
-/* GPIO 3 */
-#define GPIO3_BASE GPIOX_BASE(3)
-#define GPIO3_REG32(offset) __REG32(GPIO3_BASE + (offset))
-#define GPIO3_IRQENABLE1 GPIO3_REG32(0x01C)
-#define GPIO3_IRQSTATUS1 GPIO3_REG32(0x018)
-#define GPIO3_IRQENABLE2 GPIO3_REG32(0x02C)
-#define GPIO3_IRQSTATUS2 GPIO3_REG32(0x028)
-#define GPIO3_WAKEUPENABLE GPIO3_REG32(0x020)
-#define GPIO3_RISINGDETECT GPIO3_REG32(0x048)
-#define GPIO3_FALLINGDETECT GPIO3_REG32(0x04C)
-#define GPIO3_DATAIN GPIO3_REG32(0x038)
-#define GPIO3_OE GPIO3_REG32(0x034)
-#define GPIO3_DATAOUT GPIO3_REG32(0x03C)
-#define GPIO3_DEBOUNCENABLE GPIO3_REG32(0x050)
-#define GPIO3_DEBOUNCINGTIME GPIO3_REG32(0x054)
-
-/* GPIO 4 */
-#define GPIO4_BASE GPIOX_BASE(4)
-#define GPIO4_REG32(offset) __REG32(GPIO4_BASE + (offset))
-#define GPIO4_IRQENABLE1 GPIO4_REG32(0x01C)
-#define GPIO4_IRQSTATUS1 GPIO4_REG32(0x018)
-#define GPIO4_IRQENABLE2 GPIO4_REG32(0x02C)
-#define GPIO4_IRQSTATUS2 GPIO4_REG32(0x028)
-#define GPIO4_WAKEUPENABLE GPIO4_REG32(0x020)
-#define GPIO4_RISINGDETECT GPIO4_REG32(0x048)
-#define GPIO4_FALLINGDETECT GPIO4_REG32(0x04C)
-#define GPIO4_DATAIN GPIO4_REG32(0x038)
-#define GPIO4_OE GPIO4_REG32(0x034)
-#define GPIO4_DATAOUT GPIO4_REG32(0x03C)
-#define GPIO4_DEBOUNCENABLE GPIO4_REG32(0x050)
-#define GPIO4_DEBOUNCINGTIME GPIO4_REG32(0x054)
-
-
-/* IO CONFIG */
-#define CONTROL_BASE (OMAP24XX_CTRL_BASE)
-#define CONTROL_REG32(offset) __REG32(CONTROL_BASE + (offset))
-
-#define CONTROL_PADCONF_SPI1_NCS2 CONTROL_REG32(0x104)
-#define CONTROL_PADCONF_SYS_XTALOUT CONTROL_REG32(0x134)
-#define CONTROL_PADCONF_UART1_RX CONTROL_REG32(0x0C8)
-#define CONTROL_PADCONF_MCBSP1_DX CONTROL_REG32(0x10C)
-#define CONTROL_PADCONF_GPMC_NCS4 CONTROL_REG32(0x090)
-#define CONTROL_PADCONF_DSS_D5 CONTROL_REG32(0x0B8)
-#define CONTROL_PADCONF_DSS_D9 CONTROL_REG32(0x0BC)
-#define CONTROL_PADCONF_DSS_D13 CONTROL_REG32(0x0C0)
-#define CONTROL_PADCONF_DSS_VSYNC CONTROL_REG32(0x0CC)
-
-/* CONTROL */
-#define CONTROL_DEVCONF CONTROL_REG32(0x274)
-
-/* INTERRUPT CONTROLLER */
-#define INTC_BASE (OMAP24XX_L4_IO_BASE+0xfe000)
-#define INTC_REG32(offset) __REG32(INTC_BASE + (offset))
-
-#define INTC1_U_BASE INTC_REG32(0x000)
-#define INTC_MIR0 INTC_REG32(0x084)
-#define INTC_MIR_SET0 INTC_REG32(0x08C)
-#define INTC_MIR_CLEAR0 INTC_REG32(0x088)
-#define INTC_ISR_CLEAR0 INTC_REG32(0x094)
-#define INTC_MIR1 INTC_REG32(0x0A4)
-#define INTC_MIR_SET1 INTC_REG32(0x0AC)
-#define INTC_MIR_CLEAR1 INTC_REG32(0x0A8)
-#define INTC_ISR_CLEAR1 INTC_REG32(0x0B4)
-#define INTC_MIR2 INTC_REG32(0x0C4)
-#define INTC_MIR_SET2 INTC_REG32(0x0CC)
-#define INTC_MIR_CLEAR2 INTC_REG32(0x0C8)
-#define INTC_ISR_CLEAR2 INTC_REG32(0x0D4)
-#define INTC_SIR_IRQ INTC_REG32(0x040)
-#define INTC_CONTROL INTC_REG32(0x048)
-#define INTC_ILR11 INTC_REG32(0x12C)
-#define INTC_ILR32 INTC_REG32(0x180)
-#define INTC_ILR37 INTC_REG32(0x194)
-#define INTC_SYSCONFIG INTC_REG32(0x010)
-
-/* RAM FIREWALL */
-#define RAMFW_BASE (0x68005000)
-#define RAMFW_REG32(offset) __REG32(RAMFW_BASE + (offset))
-
-#define RAMFW_REQINFOPERM0 RAMFW_REG32(0x048)
-#define RAMFW_READPERM0 RAMFW_REG32(0x050)
-#define RAMFW_WRITEPERM0 RAMFW_REG32(0x058)
-
-/* GPMC CS1 FPGA ON USER INTERFACE MODULE */
-//#define DEBUG_BOARD_LED_REGISTER 0x04000014
-
-/* GPMC CS0 */
-#define GPMC_CONFIG1_0 GPMC_REG32(0x060)
-#define GPMC_CONFIG2_0 GPMC_REG32(0x064)
-#define GPMC_CONFIG3_0 GPMC_REG32(0x068)
-#define GPMC_CONFIG4_0 GPMC_REG32(0x06C)
-#define GPMC_CONFIG5_0 GPMC_REG32(0x070)
-#define GPMC_CONFIG6_0 GPMC_REG32(0x074)
-#define GPMC_CONFIG7_0 GPMC_REG32(0x078)
-
-/* GPMC CS1 */
-#define GPMC_CONFIG1_1 GPMC_REG32(0x090)
-#define GPMC_CONFIG2_1 GPMC_REG32(0x094)
-#define GPMC_CONFIG3_1 GPMC_REG32(0x098)
-#define GPMC_CONFIG4_1 GPMC_REG32(0x09C)
-#define GPMC_CONFIG5_1 GPMC_REG32(0x0a0)
-#define GPMC_CONFIG6_1 GPMC_REG32(0x0a4)
-#define GPMC_CONFIG7_1 GPMC_REG32(0x0a8)
-
-/* DSS */
-#define DSS_CONTROL DISP_REG32(0x040)
-#define DISPC_CONTROL DISP_REG32(0x440)
-#define DISPC_SYSSTATUS DISP_REG32(0x414)
-#define DISPC_IRQSTATUS DISP_REG32(0x418)
-#define DISPC_IRQENABLE DISP_REG32(0x41C)
-#define DISPC_CONFIG DISP_REG32(0x444)
-#define DISPC_DEFAULT_COLOR0 DISP_REG32(0x44C)
-#define DISPC_DEFAULT_COLOR1 DISP_REG32(0x450)
-#define DISPC_TRANS_COLOR0 DISP_REG32(0x454)
-#define DISPC_TRANS_COLOR1 DISP_REG32(0x458)
-#define DISPC_LINE_NUMBER DISP_REG32(0x460)
-#define DISPC_TIMING_H DISP_REG32(0x464)
-#define DISPC_TIMING_V DISP_REG32(0x468)
-#define DISPC_POL_FREQ DISP_REG32(0x46C)
-#define DISPC_DIVISOR DISP_REG32(0x470)
-#define DISPC_SIZE_DIG DISP_REG32(0x478)
-#define DISPC_SIZE_LCD DISP_REG32(0x47C)
-#define DISPC_GFX_BA0 DISP_REG32(0x480)
-#define DISPC_GFX_BA1 DISP_REG32(0x484)
-#define DISPC_GFX_POSITION DISP_REG32(0x488)
-#define DISPC_GFX_SIZE DISP_REG32(0x48C)
-#define DISPC_GFX_ATTRIBUTES DISP_REG32(0x4A0)
-#define DISPC_GFX_FIFO_THRESHOLD DISP_REG32(0x4A4)
-#define DISPC_GFX_ROW_INC DISP_REG32(0x4AC)
-#define DISPC_GFX_PIXEL_INC DISP_REG32(0x4B0)
-#define DISPC_GFX_WINDOW_SKIP DISP_REG32(0x4B4)
-#define DISPC_GFX_TABLE_BA DISP_REG32(0x4B8)
-#define DISPC_DATA_CYCLE1 DISP_REG32(0x5D4)
-#define DISPC_DATA_CYCLE2 DISP_REG32(0x5D8)
-#define DISPC_DATA_CYCLE3 DISP_REG32(0x5DC)
-
-/* Wake up define for board */
-#define GPIO97 (1 << 1)
-#define GPIO88 (1 << 24)
-
-#endif /* __ASSEMBLER__ */
+u32 omap_prcm_get_reset_sources(void);
#endif
diff --git a/include/asm-arm/arch-omap/sram.h b/include/asm-arm/arch-omap/sram.h
index e72ccbf0fe068..6fc0dd57b7c38 100644
--- a/include/asm-arm/arch-omap/sram.h
+++ b/include/asm-arm/arch-omap/sram.h
@@ -20,6 +20,8 @@ extern void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
u32 mem_type);
extern u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass);
+extern unsigned long omap_fb_sram_start;
+extern unsigned long omap_fb_sram_size;
/* Do not use these */
extern void sram_reprogram_clock(u32 ckctl, u32 dpllctl);
diff --git a/include/asm-arm/arch-omap/system.h b/include/asm-arm/arch-omap/system.h
index 6724a81bd10bb..67970d1a2020b 100644
--- a/include/asm-arm/arch-omap/system.h
+++ b/include/asm-arm/arch-omap/system.h
@@ -9,12 +9,13 @@
#include <asm/mach-types.h>
#include <asm/hardware.h>
-#include <asm/arch/prcm.h>
#ifndef CONFIG_MACH_VOICEBLUE
#define voiceblue_reset() do {} while (0)
#endif
+extern void omap_prcm_arch_reset(char mode);
+
static inline void arch_idle(void)
{
cpu_do_idle();
@@ -38,24 +39,12 @@ static inline void omap1_arch_reset(char mode)
omap_writew(1, ARM_RSTCT1);
}
-static inline void omap2_arch_reset(char mode)
-{
- u32 rate;
- struct clk *vclk, *sclk;
-
- vclk = clk_get(NULL, "virt_prcm_set");
- sclk = clk_get(NULL, "sys_ck");
- rate = clk_get_rate(sclk);
- clk_set_rate(vclk, rate); /* go to bypass for OMAP limitation */
- RM_RSTCTRL_WKUP |= 2;
-}
-
static inline void arch_reset(char mode)
{
if (!cpu_is_omap24xx())
omap1_arch_reset(mode);
else
- omap2_arch_reset(mode);
+ omap_prcm_arch_reset(mode);
}
#endif
diff --git a/include/asm-arm/arch-rpc/hardware.h b/include/asm-arm/arch-rpc/hardware.h
index 9d7f87375aa77..7480f4e8d9747 100644
--- a/include/asm-arm/arch-rpc/hardware.h
+++ b/include/asm-arm/arch-rpc/hardware.h
@@ -46,7 +46,6 @@
#define SCREEN_END 0xdfc00000
#define SCREEN_BASE 0xdf800000
-#define FLUSH_BASE 0xdf000000
#define UNCACHEABLE_ADDR 0xdf010000
/*
@@ -59,8 +58,6 @@
#define PCIO_BASE IOMEM(0xe0010000)
#define FLOPPYDMA_BASE IOMEM(0xe002a000)
-#define FLUSH_BASE_PHYS 0x00000000 /* ROM */
-
#define vidc_writel(val) __raw_writel(val, VIDC_BASE)
#define IO_EC_EASI_BASE 0x81400000
diff --git a/include/asm-arm/arch-rpc/memory.h b/include/asm-arm/arch-rpc/memory.h
index 0592cb3f0c743..303c424ce673e 100644
--- a/include/asm-arm/arch-rpc/memory.h
+++ b/include/asm-arm/arch-rpc/memory.h
@@ -30,4 +30,10 @@
#define __virt_to_bus(x) __virt_to_phys(x)
#define __bus_to_virt(x) __phys_to_virt(x)
+/*
+ * Cache flushing area - ROM
+ */
+#define FLUSH_BASE_PHYS 0x00000000
+#define FLUSH_BASE 0xdf000000
+
#endif
diff --git a/include/asm-arm/arch-s3c2410/entry-macro.S b/include/asm-arm/arch-s3c2410/entry-macro.S
index cc06b1bd37b24..894c35cf3b1e2 100644
--- a/include/asm-arm/arch-s3c2410/entry-macro.S
+++ b/include/asm-arm/arch-s3c2410/entry-macro.S
@@ -6,116 +6,83 @@
* 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.
+*/
+
+/* We have a problem that the INTOFFSET register does not always
+ * show one interrupt. Occasionally we get two interrupts through
+ * the prioritiser, and this causes the INTOFFSET register to show
+ * what looks like the logical-or of the two interrupt numbers.
+ *
+ * Thanks to Klaus, Shannon, et al for helping to debug this problem
+*/
+
+#define INTPND (0x10)
+#define INTOFFSET (0x14)
+#define EXTINTPEND (0xa8)
+#define EXTINTMASK (0xa4)
- * Modifications:
- * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
- */
#include <asm/hardware.h>
#include <asm/arch/irqs.h>
-
.macro get_irqnr_and_base, irqnr, irqstat, base, tmp
- mov \tmp, #S3C24XX_VA_IRQ
- ldr \irqnr, [ \tmp, #0x14 ] @ get irq no
-30000:
- teq \irqnr, #4
- teqne \irqnr, #5
- beq 1002f @ external irq reg
-
- @ debug check to see if interrupt reported is the same
- @ as the offset....
-
- teq \irqnr, #0
- beq 20002f
- ldr \irqstat, [ \tmp, #0x10 ] @ INTPND
- mov \irqstat, \irqstat, lsr \irqnr
- tst \irqstat, #1
- bne 20002f
-
- /* debug/warning if we get an invalud response from the
- * INTOFFSET register */
-#if 1
- stmfd r13!, { r0 - r4 , r8-r12, r14 }
- ldr r1, [ \tmp, #0x14 ] @ INTOFFSET
- ldr r2, [ \tmp, #0x10 ] @ INTPND
- ldr r3, [ \tmp, #0x00 ] @ SRCPND
- adr r0, 20003f
- bl printk
- b 20004f
-
-20003:
- .ascii "<7>irq: err - bad offset %d, intpnd=%08x, srcpnd=%08x\n"
- .byte 0
- .align 4
-20004:
- mov r1, #1
- mov \tmp, #S3C24XX_VA_IRQ
- ldmfd r13!, { r0 - r4 , r8-r12, r14 }
-#endif
-
- @ try working out interrupt number for ourselves
- mov \irqnr, #0
- ldr \irqstat, [ \tmp, #0x10 ] @ INTPND
-10021:
- movs \irqstat, \irqstat, lsr#1
- bcs 30000b @ try and re-start the proccess
- add \irqnr, \irqnr, #1
- cmp \irqnr, #32
- ble 10021b
-
- @ found no interrupt, set Z flag and leave
- movs \irqnr, #0
- b 1001f
-
-20005:
-20002: @ exit
- @ we base the s3c2410x interrupts at 16 and above to allow
- @ isa peripherals to have their standard interrupts, also
- @ ensure that Z flag is un-set on exit
-
- @ note, we cannot be sure if we get IRQ_EINT0 (0) that
- @ there is simply no interrupt pending, so in all other
- @ cases we jump to say we have found something, otherwise
- @ we check to see if the interrupt really is assrted
- adds \irqnr, \irqnr, #IRQ_EINT0
- teq \irqnr, #IRQ_EINT0
- bne 1001f @ exit
- ldr \irqstat, [ \tmp, #0x10 ] @ INTPND
- teq \irqstat, #0
- moveq \irqnr, #0
- b 1001f
-
- @ we get here from no main or external interrupts pending
-1002:
- add \tmp, \tmp, #S3C24XX_VA_GPIO - S3C24XX_VA_IRQ
- ldr \irqstat, [ \tmp, # 0xa8 ] @ EXTINTPEND
- ldr \irqnr, [ \tmp, # 0xa4 ] @ EXTINTMASK
-
- bic \irqstat, \irqstat, \irqnr @ clear masked irqs
-
- mov \irqnr, #IRQ_EINT4 @ start extint nos
- mov \irqstat, \irqstat, lsr#4 @ ignore bottom 4 bits
-10021:
- movs \irqstat, \irqstat, lsr#1
- bcs 1004f
- add \irqnr, \irqnr, #1
- cmp \irqnr, #IRQ_EINT23
- ble 10021b
-
- @ found no interrupt, set Z flag and leave
- movs \irqnr, #0
-
-1004: @ ensure Z flag clear in case our MOVS shifted out the last bit
- teq \irqnr, #0
+ mov \base, #S3C24XX_VA_IRQ
+
+ ldr \irqstat, [ \base, #INTPND]
+ bics \irqnr, \irqstat, #3<<4 @@ only an GPIO IRQ
+ beq 2000f
+
+ @@ try the interrupt offset register, since it is there
+
+ ldr \irqnr, [ \base, #INTOFFSET ]
+ mov \tmp, #1
+ tst \irqstat, \tmp, lsl \irqnr
+ addne \irqnr, \irqnr, #IRQ_EINT0
+ bne 1001f
+
+ @@ the number specified is not a valid irq, so try
+ @@ and work it out for ourselves
+
+ mov \irqnr, #IRQ_EINT0 @@ start here
+ b 3000f
+
+2000:
+ @@ load the GPIO interrupt register, and check it
+
+ add \tmp, \base, #S3C24XX_VA_GPIO - S3C24XX_VA_IRQ
+ ldr \irqstat, [ \tmp, # EXTINTPEND ]
+ ldr \irqnr, [ \tmp, # EXTINTMASK ]
+ bics \irqstat, \irqstat, \irqnr
+ beq 1001f
+
+ mov \irqnr, #(IRQ_EINT4 - 4)
+
+ @@ work out which irq (if any) we got
+3000:
+ movs \tmp, \irqstat, lsl#16
+ addeq \irqnr, \irqnr, #16
+ moveq \irqstat, \irqstat, lsr#16
+ tst \irqstat, #0xff
+ addeq \irqnr, \irqnr, #8
+ moveq \irqstat, \irqstat, lsr#8
+ tst \irqstat, #0xf
+ addeq \irqnr, \irqnr, #4
+ moveq \irqstat, \irqstat, lsr#4
+ tst \irqstat, #0x3
+ addeq \irqnr, \irqnr, #2
+ moveq \irqstat, \irqstat, lsr#2
+ tst \irqstat, #0x1
+ addeq \irqnr, \irqnr, #1
+
+ @@ we have the value
+ movs \irqnr, \irqnr
+
1001:
- @ exit irq routine
- .endm
+ @@ exit here, Z flag unset if IRQ
+ .endm
/* currently don't need an disable_fiq macro */
.macro disable_fiq
.endm
-
-
diff --git a/include/asm-arm/arch-s3c2410/leds-gpio.h b/include/asm-arm/arch-s3c2410/leds-gpio.h
new file mode 100644
index 0000000000000..f07ed040622b1
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/leds-gpio.h
@@ -0,0 +1,28 @@
+/* linux/include/asm-arm/arch-s3c2410/leds-gpio.h
+ *
+ * (c) 2006 Simtec Electronics
+ * http://armlinux.simtec.co.uk/
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C24XX - LEDs GPIO connector
+ *
+ * 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.
+*/
+
+#ifndef __ASM_ARCH_LEDSGPIO_H
+#define __ASM_ARCH_LEDSGPIO_H "leds-gpio.h"
+
+#define S3C24XX_LEDF_ACTLOW (1<<0) /* LED is on when GPIO low */
+#define S3C24XX_LEDF_TRISTATE (1<<1) /* tristate to turn off */
+
+struct s3c24xx_led_platdata {
+ unsigned int gpio;
+ unsigned int flags;
+
+ char *name;
+ char *def_trigger;
+};
+
+#endif /* __ASM_ARCH_LEDSGPIO_H */
diff --git a/include/asm-arm/arch-sa1100/hardware.h b/include/asm-arm/arch-sa1100/hardware.h
index 28711aaa4968b..ee008a5484f31 100644
--- a/include/asm-arm/arch-sa1100/hardware.h
+++ b/include/asm-arm/arch-sa1100/hardware.h
@@ -14,10 +14,6 @@
#include <linux/config.h>
-/* Flushing areas */
-#define FLUSH_BASE_PHYS 0xe0000000 /* SA1100 zero bank */
-#define FLUSH_BASE 0xf5000000
-#define FLUSH_BASE_MINICACHE 0xf5800000
#define UNCACHEABLE_ADDR 0xfa050000
diff --git a/include/asm-arm/arch-sa1100/memory.h b/include/asm-arm/arch-sa1100/memory.h
index 018a9f0e3986d..a29fac1387caf 100644
--- a/include/asm-arm/arch-sa1100/memory.h
+++ b/include/asm-arm/arch-sa1100/memory.h
@@ -91,4 +91,11 @@ void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes);
#endif
+/*
+ * Cache flushing area - SA1100 zero bank
+ */
+#define FLUSH_BASE_PHYS 0xe0000000
+#define FLUSH_BASE 0xf5000000
+#define FLUSH_BASE_MINICACHE 0xf5100000
+
#endif
diff --git a/include/asm-arm/arch-shark/hardware.h b/include/asm-arm/arch-shark/hardware.h
index 4d35f8c154c30..ecba45260898d 100644
--- a/include/asm-arm/arch-shark/hardware.h
+++ b/include/asm-arm/arch-shark/hardware.h
@@ -17,11 +17,6 @@
*/
#define IO_BASE 0xe0000000
-/*
- * RAM definitions
- */
-#define FLUSH_BASE_PHYS 0x80000000
-
#else
#define IO_BASE 0
@@ -33,7 +28,6 @@
#define ROMCARD_SIZE 0x08000000
#define ROMCARD_START 0x10000000
-#define FLUSH_BASE 0xdf000000
#define PCIO_BASE 0xe0000000
diff --git a/include/asm-arm/arch-shark/memory.h b/include/asm-arm/arch-shark/memory.h
index 95a29b4bc5d07..6968d6103ea00 100644
--- a/include/asm-arm/arch-shark/memory.h
+++ b/include/asm-arm/arch-shark/memory.h
@@ -39,4 +39,10 @@ static inline void __arch_adjust_zones(int node, unsigned long *zone_size, unsig
#define __virt_to_bus(x) __virt_to_phys(x)
#define __bus_to_virt(x) __phys_to_virt(x)
+/*
+ * Cache flushing area
+ */
+#define FLUSH_BASE_PHYS 0x80000000
+#define FLUSH_BASE 0xdf000000
+
#endif
diff --git a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
index e3e8541ee63b0..63ca7412a4623 100644
--- a/include/asm-arm/dma-mapping.h
+++ b/include/asm-arm/dma-mapping.h
@@ -47,7 +47,7 @@ static inline int dma_get_cache_alignment(void)
static inline int dma_is_consistent(dma_addr_t handle)
{
- return 0;
+ return !!arch_is_coherent();
}
/*
@@ -145,7 +145,9 @@ static inline dma_addr_t
dma_map_single(struct device *dev, void *cpu_addr, size_t size,
enum dma_data_direction dir)
{
- consistent_sync(cpu_addr, size, dir);
+ if (!arch_is_coherent())
+ consistent_sync(cpu_addr, size, dir);
+
return virt_to_dma(dev, (unsigned long)cpu_addr);
}
#else
@@ -255,7 +257,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
sg->dma_address = page_to_dma(dev, sg->page) + sg->offset;
virt = page_address(sg->page) + sg->offset;
- consistent_sync(virt, sg->length, dir);
+
+ if (!arch_is_coherent())
+ consistent_sync(virt, sg->length, dir);
}
return nents;
@@ -310,14 +314,16 @@ static inline void
dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size,
enum dma_data_direction dir)
{
- consistent_sync((void *)dma_to_virt(dev, handle), size, dir);
+ if (!arch_is_coherent())
+ consistent_sync((void *)dma_to_virt(dev, handle), size, dir);
}
static inline void
dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size,
enum dma_data_direction dir)
{
- consistent_sync((void *)dma_to_virt(dev, handle), size, dir);
+ if (!arch_is_coherent())
+ consistent_sync((void *)dma_to_virt(dev, handle), size, dir);
}
#else
extern void dma_sync_single_for_cpu(struct device*, dma_addr_t, size_t, enum dma_data_direction);
@@ -347,7 +353,8 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
for (i = 0; i < nents; i++, sg++) {
char *virt = page_address(sg->page) + sg->offset;
- consistent_sync(virt, sg->length, dir);
+ if (!arch_is_coherent())
+ consistent_sync(virt, sg->length, dir);
}
}
@@ -359,7 +366,8 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents,
for (i = 0; i < nents; i++, sg++) {
char *virt = page_address(sg->page) + sg->offset;
- consistent_sync(virt, sg->length, dir);
+ if (!arch_is_coherent())
+ consistent_sync(virt, sg->length, dir);
}
}
#else
diff --git a/include/asm-arm/fpstate.h b/include/asm-arm/fpstate.h
index 6246bf83627d3..52bae088a185c 100644
--- a/include/asm-arm/fpstate.h
+++ b/include/asm-arm/fpstate.h
@@ -26,7 +26,9 @@
struct vfp_hard_struct {
__u64 fpregs[16];
+#if __LINUX_ARM_ARCH__ < 6
__u32 fpmx_state;
+#endif
__u32 fpexc;
__u32 fpscr;
/*
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h
index afa5c3ea077cc..2092894075954 100644
--- a/include/asm-arm/memory.h
+++ b/include/asm-arm/memory.h
@@ -172,10 +172,10 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
* virt_addr_valid(k) indicates whether a virtual address is valid
*/
#ifndef CONFIG_DISCONTIGMEM
-#define ARCH_PFN_OFFSET (PHYS_PFN_OFFSET)
+#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
-#define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
+#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory)
#define PHYS_TO_NID(addr) (0)
@@ -187,8 +187,8 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
* around in memory.
*/
#include <linux/numa.h>
-#define arch_pfn_to_nid(pfn) (PFN_TO_NID(pfn))
-#define arch_local_page_offset(pfn, nid) (LOCAL_MAP_NR((pfn) << PAGE_OFFSET))
+#define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn)
+#define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT)
#define pfn_valid(pfn) \
({ \
@@ -234,6 +234,14 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
#define virt_to_dma(dev, addr) (__arch_virt_to_dma(dev, addr))
#endif
+/*
+ * Optional coherency support. Currently used only by selected
+ * Intel XSC3-based systems.
+ */
+#ifndef arch_is_coherent
+#define arch_is_coherent() 0
+#endif
+
#endif
#include <asm-generic/memory_model.h>
diff --git a/include/asm-arm/numnodes.h b/include/asm-arm/numnodes.h
deleted file mode 100644
index 8df36818ebc9d..0000000000000
--- a/include/asm-arm/numnodes.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * linux/include/asm-arm/numnodes.h
- *
- * Copyright (C) 2002 Russell King
- *
- * 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 declaration for the size of the NUMA (CONFIG_DISCONTIGMEM)
- * memory node table is the default.
- *
- * A good place to override this value is include/asm/arch/memory.h.
- */
-
-#ifndef __ASM_ARM_NUMNODES_H
-#define __ASM_ARM_NUMNODES_H
-
-#include <asm/memory.h>
-
-#ifndef NODES_SHIFT
-# define NODES_SHIFT 2 /* Normally, Max 4 Nodes */
-#endif
-
-#endif
diff --git a/include/asm-arm/pgtable-hwdef.h b/include/asm-arm/pgtable-hwdef.h
index 1d033495cc750..1bc1f997bda2a 100644
--- a/include/asm-arm/pgtable-hwdef.h
+++ b/include/asm-arm/pgtable-hwdef.h
@@ -73,6 +73,7 @@
#define PTE_EXT_AP_URW_SRW (PTE_EXT_AP1|PTE_EXT_AP0)
#define PTE_EXT_TEX(x) ((x) << 6) /* v5 */
#define PTE_EXT_APX (1 << 9) /* v6 */
+#define PTE_EXT_COHERENT (1 << 9) /* XScale3 */
#define PTE_EXT_SHARED (1 << 10) /* v6 */
#define PTE_EXT_NG (1 << 11) /* v6 */
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index e595ae24efe27..e85c08d78ddad 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -156,6 +156,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
#define L_PTE_WRITE (1 << 5)
#define L_PTE_EXEC (1 << 6)
#define L_PTE_DIRTY (1 << 7)
+#define L_PTE_COHERENT (1 << 9) /* I/O coherent (xsc3) */
#define L_PTE_SHARED (1 << 10) /* shared between CPUs (v6) */
#define L_PTE_ASID (1 << 11) /* non-global (use ASID, v6) */
diff --git a/include/asm-arm/vfpmacros.h b/include/asm-arm/vfpmacros.h
index 15bd6e74c9cf4..27fe028b4e72b 100644
--- a/include/asm-arm/vfpmacros.h
+++ b/include/asm-arm/vfpmacros.h
@@ -16,10 +16,18 @@
@ read all the working registers back into the VFP
.macro VFPFLDMIA, base
+#if __LINUX_ARM_ARCH__ < 6
LDC p11, cr0, [\base],#33*4 @ FLDMIAX \base!, {d0-d15}
+#else
+ LDC p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d0-d15}
+#endif
.endm
@ write all the working registers out of the VFP
.macro VFPFSTMIA, base
+#if __LINUX_ARM_ARCH__ < 6
STC p11, cr0, [\base],#33*4 @ FSTMIAX \base!, {d0-d15}
+#else
+ STC p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d0-d15}
+#endif
.endm
diff --git a/include/asm-cris/system.h b/include/asm-cris/system.h
index 1d63c2aa8ec2c..b1c593b6dbff1 100644
--- a/include/asm-cris/system.h
+++ b/include/asm-cris/system.h
@@ -8,7 +8,6 @@
*/
extern struct task_struct *resume(struct task_struct *prev, struct task_struct *next, int);
-#define prepare_to_switch() do { } while(0)
#define switch_to(prev,next,last) last = resume(prev,next, \
(int)&((struct task_struct *)0)->thread)
diff --git a/include/asm-cris/unistd.h b/include/asm-cris/unistd.h
index 2627bbdf8a114..bb2dfe4802135 100644
--- a/include/asm-cris/unistd.h
+++ b/include/asm-cris/unistd.h
@@ -288,7 +288,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 283
+#define __NR_kexec_load 283
#define __NR_waitid 284
/* #define __NR_sys_setaltroot 285 */
#define __NR_add_key 286
diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h
index f72ff0c4dc0b9..1734ed91bcdcd 100644
--- a/include/asm-frv/system.h
+++ b/include/asm-frv/system.h
@@ -18,8 +18,6 @@
struct thread_struct;
-#define prepare_to_switch() do { } while(0)
-
/*
* switch_to(prev, next) should switch from task `prev' to `next'
* `prev' will never be the same as `next'.
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h
index 322531caa484f..2662a3e12dc41 100644
--- a/include/asm-frv/unistd.h
+++ b/include/asm-frv/unistd.h
@@ -289,7 +289,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 283
+#define __NR_kexec_load 283
#define __NR_waitid 284
/* #define __NR_sys_setaltroot 285 */
#define __NR_add_key 286
diff --git a/include/asm-h8300/system.h b/include/asm-h8300/system.h
index dfe96c7121cfe..8e81cf665e75e 100644
--- a/include/asm-h8300/system.h
+++ b/include/asm-h8300/system.h
@@ -4,8 +4,6 @@
#include <linux/config.h> /* get configuration macros */
#include <linux/linkage.h>
-#define prepare_to_switch() do { } while(0)
-
/*
* switch_to(n) should switch tasks to task ptr, first checking that
* ptr isn't the current task, in which case it does nothing. This
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
index 56a4a5686c881..adb05159379b9 100644
--- a/include/asm-h8300/unistd.h
+++ b/include/asm-h8300/unistd.h
@@ -285,7 +285,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 283
+#define __NR_kexec_load 283
#define __NR_waitid 284
/* #define __NR_sys_setaltroot 285 */
#define __NR_add_key 286
diff --git a/include/asm-i386/apic.h b/include/asm-i386/apic.h
index ff9ac8d19eb25..288233fd77d7b 100644
--- a/include/asm-i386/apic.h
+++ b/include/asm-i386/apic.h
@@ -139,6 +139,8 @@ void switch_ipi_to_APIC_timer(void *cpumask);
extern int timer_over_8254;
+extern int modern_apic(void);
+
#else /* !CONFIG_X86_LOCAL_APIC */
static inline void lapic_shutdown(void) { }
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index edf65be21a924..ca82acb8cb1f7 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -35,6 +35,10 @@ struct e820map {
};
extern struct e820map e820;
+
+extern int e820_all_mapped(unsigned long start, unsigned long end,
+ unsigned type);
+
#endif/*!__ASSEMBLY__*/
#endif/*__E820_HEADER*/
diff --git a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
index 16ef9f996e3f4..7f1a8a6ee32fa 100644
--- a/include/asm-i386/hpet.h
+++ b/include/asm-i386/hpet.h
@@ -89,6 +89,7 @@
* then 32 bit HPET counter wrapsaround in less than 0.5 sec.
*/
#define HPET_MIN_PERIOD (100000UL)
+#define HPET_TICK_RATE (HZ * 100000UL)
extern unsigned long hpet_tick; /* hpet clks count per tick */
extern unsigned long hpet_address; /* hpet memory map physical address */
diff --git a/include/asm-i386/mpspec.h b/include/asm-i386/mpspec.h
index 62113d3bfdc21..770bf6da8c3dd 100644
--- a/include/asm-i386/mpspec.h
+++ b/include/asm-i386/mpspec.h
@@ -18,7 +18,6 @@ extern void find_smp_config (void);
extern void get_smp_config (void);
extern int nr_ioapics;
extern int apic_version [MAX_APICS];
-extern int mp_bus_id_to_type [MAX_MP_BUSSES];
extern int mp_irq_entries;
extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES];
extern int mpc_default_type;
diff --git a/include/asm-i386/numnodes.h b/include/asm-i386/numnodes.h
deleted file mode 100644
index a61f38c8176f4..0000000000000
--- a/include/asm-i386/numnodes.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _ASM_MAX_NUMNODES_H
-#define _ASM_MAX_NUMNODES_H
-
-#include <linux/config.h>
-
-#ifdef CONFIG_X86_NUMAQ
-
-/* Max 16 Nodes */
-#define NODES_SHIFT 4
-
-#elif defined(CONFIG_ACPI_SRAT)
-
-/* Max 8 Nodes */
-#define NODES_SHIFT 3
-
-#endif /* CONFIG_X86_NUMAQ */
-
-#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index 2e7f3e257fddf..6a8dd83c350f9 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -288,7 +288,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 283
+#define __NR_kexec_load 283
#define __NR_waitid 284
/* #define __NR_sys_setaltroot 285 */
#define __NR_add_key 286
@@ -318,8 +318,8 @@
#define __NR_unshare 310
#define __NR_set_robust_list 311
#define __NR_get_robust_list 312
-#define __NR_sys_splice 313
-#define __NR_sys_sync_file_range 314
+#define __NR_splice 313
+#define __NR_sync_file_range 314
#define NR_syscalls 315
diff --git a/include/asm-ia64/acpi-ext.h b/include/asm-ia64/acpi-ext.h
index 56d2ddc97b30c..734d137dda6ec 100644
--- a/include/asm-ia64/acpi-ext.h
+++ b/include/asm-ia64/acpi-ext.h
@@ -1,12 +1,15 @@
/*
- * ia64/platform/hp/common/hp_acpi.h
+ * (c) Copyright 2003, 2006 Hewlett-Packard Development Company, L.P.
+ * Alex Williamson <alex.williamson@hp.com>
+ * Bjorn Helgaas <bjorn.helgaas@hp.com>
*
- * Copyright (C) 2003 Hewlett-Packard
- * Copyright (C) Alex Williamson
- * Copyright (C) Bjorn Helgaas
+ * 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.
*
* Vendor specific extensions to ACPI.
*/
+
#ifndef _ASM_IA64_ACPI_EXT_H
#define _ASM_IA64_ACPI_EXT_H
diff --git a/include/asm-ia64/kdebug.h b/include/asm-ia64/kdebug.h
index 218c458ab60c8..c195a9ad12551 100644
--- a/include/asm-ia64/kdebug.h
+++ b/include/asm-ia64/kdebug.h
@@ -58,6 +58,8 @@ enum die_val {
DIE_MCA_RENDZVOUS_ENTER,
DIE_MCA_RENDZVOUS_PROCESS,
DIE_MCA_RENDZVOUS_LEAVE,
+ DIE_MCA_NEW_TIMEOUT,
+ DIE_INIT_ENTER,
DIE_INIT_MONARCH_ENTER,
DIE_INIT_MONARCH_PROCESS,
DIE_INIT_MONARCH_LEAVE,
diff --git a/include/asm-ia64/mca.h b/include/asm-ia64/mca.h
index bfbbb8da79c7b..9c5389b7e6237 100644
--- a/include/asm-ia64/mca.h
+++ b/include/asm-ia64/mca.h
@@ -148,6 +148,11 @@ extern int ia64_reg_MCA_extension(int (*fn)(void *, struct ia64_sal_os_state *)
extern void ia64_unreg_MCA_extension(void);
extern u64 ia64_get_rnat(u64 *);
+struct ia64_mca_notify_die {
+ struct ia64_sal_os_state *sos;
+ int *monarch_cpu;
+};
+
#else /* __ASSEMBLY__ */
#define IA64_MCA_CORRECTED 0x0 /* Error has been corrected by OS_MCA */
diff --git a/include/asm-ia64/mutex.h b/include/asm-ia64/mutex.h
index 5a3224f6af380..bed73a643a56e 100644
--- a/include/asm-ia64/mutex.h
+++ b/include/asm-ia64/mutex.h
@@ -84,7 +84,7 @@ __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *))
static inline int
__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
{
- if (likely(cmpxchg_acq(count, 1, 0)) == 1)
+ if (cmpxchg_acq(count, 1, 0) == 1)
return 1;
return 0;
}
diff --git a/include/asm-ia64/numnodes.h b/include/asm-ia64/numnodes.h
deleted file mode 100644
index e9d356f549d90..0000000000000
--- a/include/asm-ia64/numnodes.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _ASM_MAX_NUMNODES_H
-#define _ASM_MAX_NUMNODES_H
-
-#ifdef CONFIG_IA64_DIG
-/* Max 8 Nodes */
-# define NODES_SHIFT 3
-#elif defined(CONFIG_IA64_HP_ZX1) || defined(CONFIG_IA64_HP_ZX1_SWIOTLB)
-/* Max 32 Nodes */
-# define NODES_SHIFT 5
-#elif defined(CONFIG_IA64_SGI_SN2) || defined(CONFIG_IA64_GENERIC)
-# if CONFIG_IA64_NR_NODES == 256
-# define NODES_SHIFT 8
-# elif CONFIG_IA64_NR_NODES <= 512
-# define NODES_SHIFT 9
-# elif CONFIG_IA64_NR_NODES <= 1024
-# define NODES_SHIFT 10
-# endif
-#endif
-
-#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
index 36070c1014d88..1c749acca021b 100644
--- a/include/asm-ia64/unistd.h
+++ b/include/asm-ia64/unistd.h
@@ -286,12 +286,15 @@
/* 1294, 1295 reserved for pselect/ppoll */
#define __NR_unshare 1296
#define __NR_splice 1297
+#define __NR_set_robust_list 1298
+#define __NR_get_robust_list 1299
+#define __NR_sync_file_range 1300
#ifdef __KERNEL__
#include <linux/config.h>
-#define NR_syscalls 274 /* length of syscall table */
+#define NR_syscalls 277 /* length of syscall table */
#define __ARCH_WANT_SYS_RT_SIGACTION
diff --git a/include/asm-ia64/vga.h b/include/asm-ia64/vga.h
index bc3349ffc5055..091177cda2237 100644
--- a/include/asm-ia64/vga.h
+++ b/include/asm-ia64/vga.h
@@ -17,7 +17,7 @@
extern unsigned long vga_console_iobase;
extern unsigned long vga_console_membase;
-#define VGA_MAP_MEM(x) ((unsigned long) ioremap(vga_console_membase + (x), 0))
+#define VGA_MAP_MEM(x) ((unsigned long) ioremap_nocache(vga_console_membase + (x), 0))
#define vga_readb(x) (*(x))
#define vga_writeb(x,y) (*(y) = (x))
diff --git a/include/asm-m32r/numnodes.h b/include/asm-m32r/numnodes.h
deleted file mode 100644
index 479a39d49f835..0000000000000
--- a/include/asm-m32r/numnodes.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _ASM_NUMNODES_H_
-#define _ASM_NUMNODES_H_
-
-#include <linux/config.h>
-
-#ifdef CONFIG_DISCONTIGMEM
-
-#if defined(CONFIG_CHIP_M32700)
-#define NODES_SHIFT 1 /* Max 2 Nodes */
-#endif /* CONFIG_CHIP_M32700 */
-
-#endif /* CONFIG_DISCONTIGMEM */
-
-#endif /* _ASM_NUMNODES_H_ */
-
diff --git a/include/asm-m32r/smp.h b/include/asm-m32r/smp.h
index 7885b7df84a2b..1184293e57127 100644
--- a/include/asm-m32r/smp.h
+++ b/include/asm-m32r/smp.h
@@ -67,7 +67,8 @@ extern volatile int cpu_2_physid[NR_CPUS];
#define raw_smp_processor_id() (current_thread_info()->cpu)
extern cpumask_t cpu_callout_map;
-#define cpu_possible_map cpu_callout_map
+extern cpumask_t cpu_possible_map;
+extern cpumask_t cpu_present_map;
static __inline__ int hard_smp_processor_id(void)
{
diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h
index d6a2c613be68a..c5ab5da56d21a 100644
--- a/include/asm-m32r/system.h
+++ b/include/asm-m32r/system.h
@@ -22,10 +22,6 @@
* `next' and `prev' should be struct task_struct, but it isn't always defined
*/
-#ifndef CONFIG_SMP
-#define prepare_to_switch() do { } while(0)
-#endif /* not CONFIG_SMP */
-
#define switch_to(prev, next, last) do { \
register unsigned long arg0 __asm__ ("r0") = (unsigned long)prev; \
register unsigned long arg1 __asm__ ("r1") = (unsigned long)next; \
diff --git a/include/asm-m32r/uaccess.h b/include/asm-m32r/uaccess.h
index e8ae61956a513..819cc28a94f7c 100644
--- a/include/asm-m32r/uaccess.h
+++ b/include/asm-m32r/uaccess.h
@@ -5,17 +5,9 @@
* linux/include/asm-m32r/uaccess.h
*
* M32R version.
- * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
+ * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
*/
-#undef UACCESS_DEBUG
-
-#ifdef UACCESS_DEBUG
-#define UAPRINTK(args...) printk(args)
-#else
-#define UAPRINTK(args...)
-#endif /* UACCESS_DEBUG */
-
/*
* User space memory access functions
*/
@@ -38,27 +30,29 @@
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#ifdef CONFIG_MMU
+
#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
-#else
-#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
-#define USER_DS MAKE_MM_SEG(0xFFFFFFFF)
-#endif /* CONFIG_MMU */
-
#define get_ds() (KERNEL_DS)
-#ifdef CONFIG_MMU
#define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x))
-#else
+
+#else /* not CONFIG_MMU */
+
+#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
+#define USER_DS MAKE_MM_SEG(0xFFFFFFFF)
+#define get_ds() (KERNEL_DS)
+
static inline mm_segment_t get_fs(void)
{
- return USER_DS;
+ return USER_DS;
}
static inline void set_fs(mm_segment_t s)
{
}
-#endif /* CONFIG_MMU */
+
+#endif /* not CONFIG_MMU */
#define segment_eq(a,b) ((a).seg == (b).seg)
@@ -83,9 +77,9 @@ static inline void set_fs(mm_segment_t s)
" subx %0, %0\n" \
" cmpu %4, %1\n" \
" subx %0, %5\n" \
- : "=&r"(flag), "=r"(sum) \
- : "1"(addr), "r"((int)(size)), \
- "r"(current_thread_info()->addr_limit.seg), "r"(0) \
+ : "=&r" (flag), "=r" (sum) \
+ : "1" (addr), "r" ((int)(size)), \
+ "r" (current_thread_info()->addr_limit.seg), "r" (0) \
: "cbit" ); \
flag; })
@@ -113,10 +107,10 @@ static inline void set_fs(mm_segment_t s)
#else
static inline int access_ok(int type, const void *addr, unsigned long size)
{
- extern unsigned long memory_start, memory_end;
- unsigned long val = (unsigned long)addr;
+ extern unsigned long memory_start, memory_end;
+ unsigned long val = (unsigned long)addr;
- return ((val >= memory_start) && ((val + size) < memory_end));
+ return ((val >= memory_start) && ((val + size) < memory_end));
}
#endif /* CONFIG_MMU */
@@ -155,39 +149,6 @@ extern int fixup_exception(struct pt_regs *regs);
* accesses to the same area of user memory).
*/
-extern void __get_user_1(void);
-extern void __get_user_2(void);
-extern void __get_user_4(void);
-
-#ifndef MODULE
-#define __get_user_x(size,ret,x,ptr) \
- __asm__ __volatile__( \
- " mv r0, %0\n" \
- " mv r1, %1\n" \
- " bl __get_user_" #size "\n" \
- " mv %0, r0\n" \
- " mv %1, r1\n" \
- : "=r"(ret), "=r"(x) \
- : "0"(ptr) \
- : "r0", "r1", "r14" )
-#else /* MODULE */
-/*
- * Use "jl" instead of "bl" for MODULE
- */
-#define __get_user_x(size,ret,x,ptr) \
- __asm__ __volatile__( \
- " mv r0, %0\n" \
- " mv r1, %1\n" \
- " seth lr, #high(__get_user_" #size ")\n" \
- " or3 lr, lr, #low(__get_user_" #size ")\n" \
- " jl lr\n" \
- " mv %0, r0\n" \
- " mv %1, r1\n" \
- : "=r"(ret), "=r"(x) \
- : "0"(ptr) \
- : "r0", "r1", "r14" )
-#endif
-
/* Careful: we have to cast the result to the type of the pointer for sign
reasons */
/**
@@ -208,20 +169,7 @@ extern void __get_user_4(void);
* On error, the variable @x is set to zero.
*/
#define get_user(x,ptr) \
-({ int __ret_gu; \
- unsigned long __val_gu; \
- __chk_user_ptr(ptr); \
- switch(sizeof (*(ptr))) { \
- case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \
- case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \
- case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \
- default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; \
- } \
- (x) = (__typeof__(*(ptr)))__val_gu; \
- __ret_gu; \
-})
-
-extern void __put_user_bad(void);
+ __get_user_check((x),(ptr),sizeof(*(ptr)))
/**
* put_user: - Write a simple value into user space.
@@ -240,8 +188,7 @@ extern void __put_user_bad(void);
* Returns zero on success, or -EFAULT on error.
*/
#define put_user(x,ptr) \
- __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
-
+ __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
/**
* __get_user: - Get a simple variable from user space, with less checking.
@@ -264,8 +211,64 @@ extern void __put_user_bad(void);
* On error, the variable @x is set to zero.
*/
#define __get_user(x,ptr) \
- __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
+ __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
+#define __get_user_nocheck(x,ptr,size) \
+({ \
+ long __gu_err = 0; \
+ unsigned long __gu_val; \
+ might_sleep(); \
+ __get_user_size(__gu_val,(ptr),(size),__gu_err); \
+ (x) = (__typeof__(*(ptr)))__gu_val; \
+ __gu_err; \
+})
+
+#define __get_user_check(x,ptr,size) \
+({ \
+ long __gu_err = -EFAULT; \
+ unsigned long __gu_val = 0; \
+ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+ might_sleep(); \
+ if (access_ok(VERIFY_READ,__gu_addr,size)) \
+ __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
+ (x) = (__typeof__(*(ptr)))__gu_val; \
+ __gu_err; \
+})
+
+extern long __get_user_bad(void);
+
+#define __get_user_size(x,ptr,size,retval) \
+do { \
+ retval = 0; \
+ __chk_user_ptr(ptr); \
+ switch (size) { \
+ case 1: __get_user_asm(x,ptr,retval,"ub"); break; \
+ case 2: __get_user_asm(x,ptr,retval,"uh"); break; \
+ case 4: __get_user_asm(x,ptr,retval,""); break; \
+ default: (x) = __get_user_bad(); \
+ } \
+} while (0)
+
+#define __get_user_asm(x, addr, err, itype) \
+ __asm__ __volatile__( \
+ " .fillinsn\n" \
+ "1: ld"itype" %1,@%2\n" \
+ " .fillinsn\n" \
+ "2:\n" \
+ ".section .fixup,\"ax\"\n" \
+ " .balign 4\n" \
+ "3: ldi %0,%3\n" \
+ " seth r14,#high(2b)\n" \
+ " or3 r14,r14,#low(2b)\n" \
+ " jmp r14\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ " .balign 4\n" \
+ " .long 1b,3b\n" \
+ ".previous" \
+ : "=&r" (err), "=&r" (x) \
+ : "r" (addr), "i" (-EFAULT), "0" (err) \
+ : "r14", "memory")
/**
* __put_user: - Write a simple value into user space, with less checking.
@@ -287,11 +290,13 @@ extern void __put_user_bad(void);
* Returns zero on success, or -EFAULT on error.
*/
#define __put_user(x,ptr) \
- __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
+ __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
+
#define __put_user_nocheck(x,ptr,size) \
({ \
long __pu_err; \
+ might_sleep(); \
__put_user_size((x),(ptr),(size),__pu_err); \
__pu_err; \
})
@@ -308,28 +313,28 @@ extern void __put_user_bad(void);
})
#if defined(__LITTLE_ENDIAN__)
-#define __put_user_u64(x, addr, err) \
- __asm__ __volatile__( \
- " .fillinsn\n" \
- "1: st %L1,@%2\n" \
- " .fillinsn\n" \
- "2: st %H1,@(4,%2)\n" \
- " .fillinsn\n" \
- "3:\n" \
- ".section .fixup,\"ax\"\n" \
- " .balign 4\n" \
- "4: ldi %0,%3\n" \
- " seth r14,#high(3b)\n" \
- " or3 r14,r14,#low(3b)\n" \
- " jmp r14\n" \
- ".previous\n" \
- ".section __ex_table,\"a\"\n" \
- " .balign 4\n" \
- " .long 1b,4b\n" \
- " .long 2b,4b\n" \
- ".previous" \
- : "=&r"(err) \
- : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \
+#define __put_user_u64(x, addr, err) \
+ __asm__ __volatile__( \
+ " .fillinsn\n" \
+ "1: st %L1,@%2\n" \
+ " .fillinsn\n" \
+ "2: st %H1,@(4,%2)\n" \
+ " .fillinsn\n" \
+ "3:\n" \
+ ".section .fixup,\"ax\"\n" \
+ " .balign 4\n" \
+ "4: ldi %0,%3\n" \
+ " seth r14,#high(3b)\n" \
+ " or3 r14,r14,#low(3b)\n" \
+ " jmp r14\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ " .balign 4\n" \
+ " .long 1b,4b\n" \
+ " .long 2b,4b\n" \
+ ".previous" \
+ : "=&r" (err) \
+ : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err) \
: "r14", "memory")
#elif defined(__BIG_ENDIAN__)
@@ -353,13 +358,15 @@ extern void __put_user_bad(void);
" .long 1b,4b\n" \
" .long 2b,4b\n" \
".previous" \
- : "=&r"(err) \
- : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \
+ : "=&r" (err) \
+ : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err) \
: "r14", "memory")
#else
#error no endian defined
#endif
+extern void __put_user_bad(void);
+
#define __put_user_size(x,ptr,size,retval) \
do { \
retval = 0; \
@@ -398,52 +405,8 @@ struct __large_struct { unsigned long buf[100]; };
" .balign 4\n" \
" .long 1b,3b\n" \
".previous" \
- : "=&r"(err) \
- : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \
- : "r14", "memory")
-
-#define __get_user_nocheck(x,ptr,size) \
-({ \
- long __gu_err; \
- unsigned long __gu_val; \
- __get_user_size(__gu_val,(ptr),(size),__gu_err); \
- (x) = (__typeof__(*(ptr)))__gu_val; \
- __gu_err; \
-})
-
-extern long __get_user_bad(void);
-
-#define __get_user_size(x,ptr,size,retval) \
-do { \
- retval = 0; \
- __chk_user_ptr(ptr); \
- switch (size) { \
- case 1: __get_user_asm(x,ptr,retval,"ub"); break; \
- case 2: __get_user_asm(x,ptr,retval,"uh"); break; \
- case 4: __get_user_asm(x,ptr,retval,""); break; \
- default: (x) = __get_user_bad(); \
- } \
-} while (0)
-
-#define __get_user_asm(x, addr, err, itype) \
- __asm__ __volatile__( \
- " .fillinsn\n" \
- "1: ld"itype" %1,@%2\n" \
- " .fillinsn\n" \
- "2:\n" \
- ".section .fixup,\"ax\"\n" \
- " .balign 4\n" \
- "3: ldi %0,%3\n" \
- " seth r14,#high(2b)\n" \
- " or3 r14,r14,#low(2b)\n" \
- " jmp r14\n" \
- ".previous\n" \
- ".section __ex_table,\"a\"\n" \
- " .balign 4\n" \
- " .long 1b,3b\n" \
- ".previous" \
- : "=&r"(err), "=&r"(x) \
- : "r"(addr), "i"(-EFAULT), "0"(err) \
+ : "=&r" (err) \
+ : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err) \
: "r14", "memory")
/*
@@ -453,7 +416,6 @@ do { \
* anything, so this is accurate.
*/
-
/*
* Copy To/From Userspace
*/
@@ -511,8 +473,9 @@ do { \
" .long 2b,9b\n" \
" .long 3b,9b\n" \
".previous\n" \
- : "=&r"(__dst), "=&r"(__src), "=&r"(size), "=&r"(__c) \
- : "0"(to), "1"(from), "2"(size), "3"(size / 4) \
+ : "=&r" (__dst), "=&r" (__src), "=&r" (size), \
+ "=&r" (__c) \
+ : "0" (to), "1" (from), "2" (size), "3" (size / 4) \
: "r14", "memory"); \
} while (0)
@@ -573,8 +536,9 @@ do { \
" .long 2b,7b\n" \
" .long 3b,7b\n" \
".previous\n" \
- : "=&r"(__dst), "=&r"(__src), "=&r"(size), "=&r"(__c) \
- : "0"(to), "1"(from), "2"(size), "3"(size / 4) \
+ : "=&r" (__dst), "=&r" (__src), "=&r" (size), \
+ "=&r" (__c) \
+ : "0" (to), "1" (from), "2" (size), "3" (size / 4) \
: "r14", "memory"); \
} while (0)
@@ -676,7 +640,7 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
#define copy_from_user(to,from,n) \
({ \
might_sleep(); \
-__generic_copy_from_user((to),(from),(n)); \
+ __generic_copy_from_user((to),(from),(n)); \
})
long __must_check strncpy_from_user(char *dst, const char __user *src,
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index 39be87ca2a5a7..be0eb014c3b0c 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -292,7 +292,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 283
+#define __NR_kexec_load 283
#define __NR_waitid 284
#define NR_syscalls 285
diff --git a/include/asm-mips/numnodes.h b/include/asm-mips/numnodes.h
deleted file mode 100644
index 4f00c16ceeb0e..0000000000000
--- a/include/asm-mips/numnodes.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _ASM_MAX_NUMNODES_H
-#define _ASM_MAX_NUMNODES_H
-
-/* Max 128 Nodes */
-#define NODES_SHIFT 6
-
-#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-parisc/numnodes.h b/include/asm-parisc/numnodes.h
deleted file mode 100644
index 6c67651efd1c8..0000000000000
--- a/include/asm-parisc/numnodes.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _ASM_MAX_NUMNODES_H
-#define _ASM_MAX_NUMNODES_H
-
-/* Max 8 Nodes */
-#define NODES_SHIFT 3
-
-#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-powerpc/numnodes.h b/include/asm-powerpc/numnodes.h
deleted file mode 100644
index e138edae09ddf..0000000000000
--- a/include/asm-powerpc/numnodes.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _ASM_POWERPC_MAX_NUMNODES_H
-#define _ASM_POWERPC_MAX_NUMNODES_H
-#ifdef __KERNEL__
-
-/* Max 16 Nodes */
-#define NODES_SHIFT 4
-
-#endif /* __KERNEL__ */
-#endif /* _ASM_POWERPC_MAX_NUMNODES_H */
diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h
index de1d9926aa603..399bf02894dd1 100644
--- a/include/asm-s390/atomic.h
+++ b/include/asm-s390/atomic.h
@@ -1,6 +1,8 @@
#ifndef __ARCH_S390_ATOMIC__
#define __ARCH_S390_ATOMIC__
+#include <linux/compiler.h>
+
/*
* include/asm-s390/atomic.h
*
diff --git a/include/asm-s390/ebcdic.h b/include/asm-s390/ebcdic.h
index 4cbc336e4d60a..15fd2eda6c901 100644
--- a/include/asm-s390/ebcdic.h
+++ b/include/asm-s390/ebcdic.h
@@ -14,12 +14,12 @@
#include <types.h>
#endif
-extern __u8 _ascebc_500[]; /* ASCII -> EBCDIC 500 conversion table */
-extern __u8 _ebcasc_500[]; /* EBCDIC 500 -> ASCII conversion table */
-extern __u8 _ascebc[]; /* ASCII -> EBCDIC conversion table */
-extern __u8 _ebcasc[]; /* EBCDIC -> ASCII conversion table */
-extern __u8 _ebc_tolower[]; /* EBCDIC -> lowercase */
-extern __u8 _ebc_toupper[]; /* EBCDIC -> uppercase */
+extern __u8 _ascebc_500[256]; /* ASCII -> EBCDIC 500 conversion table */
+extern __u8 _ebcasc_500[256]; /* EBCDIC 500 -> ASCII conversion table */
+extern __u8 _ascebc[256]; /* ASCII -> EBCDIC conversion table */
+extern __u8 _ebcasc[256]; /* EBCDIC -> ASCII conversion table */
+extern __u8 _ebc_tolower[256]; /* EBCDIC -> lowercase */
+extern __u8 _ebc_toupper[256]; /* EBCDIC -> uppercase */
static inline void
codepage_convert(const __u8 *codepage, volatile __u8 * addr, unsigned long nr)
diff --git a/include/asm-sh/numnodes.h b/include/asm-sh/numnodes.h
deleted file mode 100644
index f73e85b72ecbd..0000000000000
--- a/include/asm-sh/numnodes.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _ASM_MAX_NUMNODES_H
-#define _ASM_MAX_NUMNODES_H
-
-/* Max 2 Nodes */
-#define NODES_SHIFT 1
-
-#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index f2c8e14d1fd9c..05520cebda128 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -290,7 +290,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 283
+#define __NR_kexec_load 283
#define __NR_waitid 284
#define __NR_add_key 285
#define __NR_request_key 286
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh64/unistd.h
index 2a1cfa404ea4b..1f8f394ae3718 100644
--- a/include/asm-sh64/unistd.h
+++ b/include/asm-sh64/unistd.h
@@ -333,7 +333,7 @@
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
-#define __NR_sys_kexec_load 311
+#define __NR_kexec_load 311
#define __NR_waitid 312
#define __NR_add_key 313
#define __NR_request_key 314
diff --git a/include/asm-sparc/vga.h b/include/asm-sparc/vga.h
new file mode 100644
index 0000000000000..c69d5b2ba19a4
--- /dev/null
+++ b/include/asm-sparc/vga.h
@@ -0,0 +1,33 @@
+/*
+ * Access to VGA videoram
+ *
+ * (c) 1998 Martin Mares <mj@ucw.cz>
+ */
+
+#ifndef _LINUX_ASM_VGA_H_
+#define _LINUX_ASM_VGA_H_
+
+#include <asm/types.h>
+
+#define VT_BUF_HAVE_RW
+
+#undef scr_writew
+#undef scr_readw
+
+static inline void scr_writew(u16 val, u16 *addr)
+{
+ BUG_ON((long) addr >= 0);
+
+ *addr = val;
+}
+
+static inline u16 scr_readw(const u16 *addr)
+{
+ BUG_ON((long) addr >= 0);
+
+ return *addr;
+}
+
+#define VGA_MAP_MEM(x,s) (x)
+
+#endif
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
index 82032e159a763..baef13b589525 100644
--- a/include/asm-sparc64/percpu.h
+++ b/include/asm-sparc64/percpu.h
@@ -26,7 +26,7 @@ register unsigned long __local_per_cpu_offset asm("g5");
#define percpu_modcopy(pcpudst, src, size) \
do { \
unsigned int __i; \
- for_each_cpu(__i) \
+ for_each_possible_cpu(__i) \
memcpy((pcpudst)+__per_cpu_offset(__i), \
(src), (size)); \
} while (0)
diff --git a/include/asm-um/ptrace-i386.h b/include/asm-um/ptrace-i386.h
index 30656c962d742..6e2528bb0083e 100644
--- a/include/asm-um/ptrace-i386.h
+++ b/include/asm-um/ptrace-i386.h
@@ -56,6 +56,9 @@ extern int do_get_thread_area_tt(struct user_desc *info);
extern int arch_switch_tls_skas(struct task_struct *from, struct task_struct *to);
extern int arch_switch_tls_tt(struct task_struct *from, struct task_struct *to);
+extern void arch_switch_to_tt(struct task_struct *from, struct task_struct *to);
+extern void arch_switch_to_skas(struct task_struct *from, struct task_struct *to);
+
static inline int do_get_thread_area(struct user_desc *info)
{
return CHOOSE_MODE_PROC(do_get_thread_area_tt, do_get_thread_area_skas, info);
diff --git a/include/asm-v850/system.h b/include/asm-v850/system.h
index 107decbd6e6cf..7091af4b78667 100644
--- a/include/asm-v850/system.h
+++ b/include/asm-v850/system.h
@@ -18,8 +18,6 @@
#include <asm/ptrace.h>
-#define prepare_to_switch() do { } while (0)
-
/*
* switch_to(n) should switch tasks to task ptr, first checking that
* ptr isn't the current task, in which case it does nothing.
diff --git a/include/asm-x86_64/e820.h b/include/asm-x86_64/e820.h
index 8dcc32665240f..93b51df516877 100644
--- a/include/asm-x86_64/e820.h
+++ b/include/asm-x86_64/e820.h
@@ -47,7 +47,8 @@ extern void contig_e820_setup(void);
extern unsigned long e820_end_of_ram(void);
extern void e820_reserve_resources(void);
extern void e820_print_map(char *who);
-extern int e820_mapped(unsigned long start, unsigned long end, unsigned type);
+extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
+extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);
extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end);
extern void e820_setup_gap(void);
diff --git a/include/asm-x86_64/hpet.h b/include/asm-x86_64/hpet.h
index 08b75c15269ae..18ff7ee9e774c 100644
--- a/include/asm-x86_64/hpet.h
+++ b/include/asm-x86_64/hpet.h
@@ -51,6 +51,8 @@
#define HPET_TN_ROUTE_SHIFT 9
+#define HPET_TICK_RATE (HZ * 100000UL)
+
extern int is_hpet_enabled(void);
extern int hpet_rtc_timer_init(void);
extern int oem_force_hpet_timer(void);
diff --git a/include/asm-x86_64/ia32_unistd.h b/include/asm-x86_64/ia32_unistd.h
index eeb2bcd635de6..b4f4b172b15ad 100644
--- a/include/asm-x86_64/ia32_unistd.h
+++ b/include/asm-x86_64/ia32_unistd.h
@@ -317,6 +317,4 @@
#define __NR_ia32_ppoll 309
#define __NR_ia32_unshare 310
-#define IA32_NR_syscalls 315 /* must be > than biggest syscall! */
-
#endif /* _ASM_X86_64_IA32_UNISTD_H_ */
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index cafdfb37f0d8a..a05da8a50bfdf 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -177,7 +177,7 @@ static inline __u16 __readw(const volatile void __iomem *addr)
{
return *(__force volatile __u16 *)addr;
}
-static inline __u32 __readl(const volatile void __iomem *addr)
+static __always_inline __u32 __readl(const volatile void __iomem *addr)
{
return *(__force volatile __u32 *)addr;
}
diff --git a/include/asm-x86_64/mce.h b/include/asm-x86_64/mce.h
index 5d298b799a9f5..7229785094e37 100644
--- a/include/asm-x86_64/mce.h
+++ b/include/asm-x86_64/mce.h
@@ -70,6 +70,9 @@ struct mce_log {
#define MCE_THRESHOLD_BASE MCE_EXTENDED_BANK + 1 /* MCE_AMD */
#define MCE_THRESHOLD_DRAM_ECC MCE_THRESHOLD_BASE + 4
+#ifdef __KERNEL__
+#include <asm/atomic.h>
+
void mce_log(struct mce *m);
#ifdef CONFIG_X86_MCE_INTEL
void mce_intel_feature_init(struct cpuinfo_x86 *c);
@@ -87,4 +90,8 @@ static inline void mce_amd_feature_init(struct cpuinfo_x86 *c)
}
#endif
+extern atomic_t mce_entry;
+
+#endif
+
#endif
diff --git a/include/asm-x86_64/numa.h b/include/asm-x86_64/numa.h
index f6cbb4cbb5a3e..1cc92fe02503d 100644
--- a/include/asm-x86_64/numa.h
+++ b/include/asm-x86_64/numa.h
@@ -2,7 +2,6 @@
#define _ASM_X8664_NUMA_H 1
#include <linux/nodemask.h>
-#include <asm/numnodes.h>
struct bootnode {
u64 start,end;
@@ -18,6 +17,8 @@ extern void numa_init_array(void);
extern int numa_off;
extern void numa_set_node(int cpu, int node);
+extern void srat_reserve_add_area(int nodeid);
+extern int hotadd_percent;
extern unsigned char apicid_to_node[256];
#ifdef CONFIG_NUMA
diff --git a/include/asm-x86_64/numnodes.h b/include/asm-x86_64/numnodes.h
deleted file mode 100644
index 32be16b8ae961..0000000000000
--- a/include/asm-x86_64/numnodes.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _ASM_X8664_NUMNODES_H
-#define _ASM_X8664_NUMNODES_H 1
-
-#include <linux/config.h>
-
-#ifdef CONFIG_NUMA
-#define NODES_SHIFT 6
-#else
-#define NODES_SHIFT 0
-#endif
-
-#endif
diff --git a/include/asm-x86_64/timex.h b/include/asm-x86_64/timex.h
index f18443fcdf04c..b9e5320b76252 100644
--- a/include/asm-x86_64/timex.h
+++ b/include/asm-x86_64/timex.h
@@ -33,7 +33,7 @@ static __always_inline cycles_t get_cycles_sync(void)
unsigned eax;
/* Don't do an additional sync on CPUs where we know
RDTSC is already synchronous. */
- alternative_io(ASM_NOP2, "cpuid", X86_FEATURE_SYNC_RDTSC,
+ alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC,
"=a" (eax), "0" (1) : "ebx","ecx","edx","memory");
rdtscll(ret);
return ret;
diff --git a/include/asm-xtensa/system.h b/include/asm-xtensa/system.h
index 9284867f1cb90..b29f7ae6a08ae 100644
--- a/include/asm-xtensa/system.h
+++ b/include/asm-xtensa/system.h
@@ -111,8 +111,6 @@ extern void *_switch_to(void *last, void *next);
#endif /* __ASSEMBLY__ */
-#define prepare_to_switch() do { } while(0)
-
#define switch_to(prev,next,last) \
do { \
clear_cpenable(); \
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index de3eb8d8ae26d..da2d107fe2cf3 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -45,6 +45,7 @@ extern unsigned long __init bootmem_bootmap_pages (unsigned long);
extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
extern void __init free_bootmem (unsigned long addr, unsigned long size);
extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
+extern void * __init __alloc_bootmem_nopanic (unsigned long size, unsigned long align, unsigned long goal);
extern void * __init __alloc_bootmem_low(unsigned long size,
unsigned long align,
unsigned long goal);
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 9b4751aecc238..ff61817082fa8 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -21,7 +21,7 @@ enum dma_data_direction {
#define DMA_30BIT_MASK 0x000000003fffffffULL
#define DMA_29BIT_MASK 0x000000001fffffffULL
#define DMA_28BIT_MASK 0x000000000fffffffULL
-#define DMA_24BIT_MASK 0x0000000000ffffffULL
+#define DMA_24BIT_MASK 0x0000000000ffffffULL
#include <asm/dma-mapping.h>
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1e9ebaba07b7a..162c6e57307a0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -762,7 +762,7 @@ extern int fcntl_getlease(struct file *filp);
#define SYNC_FILE_RANGE_WRITE 2
#define SYNC_FILE_RANGE_WAIT_AFTER 4
extern int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte,
- int flags);
+ unsigned int flags);
/* fs/locks.c */
extern void locks_init_lock(struct file_lock *);
@@ -1039,8 +1039,8 @@ struct file_operations {
int (*check_flags)(int);
int (*dir_notify)(struct file *filp, unsigned long arg);
int (*flock) (struct file *, int, struct file_lock *);
- ssize_t (*splice_write)(struct inode *, struct file *, size_t, unsigned int);
- ssize_t (*splice_read)(struct file *, struct inode *, size_t, unsigned int);
+ ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int);
+ ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);
};
struct inode_operations {
@@ -1611,8 +1611,17 @@ extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor
extern void do_generic_mapping_read(struct address_space *mapping,
struct file_ra_state *, struct file *,
loff_t *, read_descriptor_t *, read_actor_t);
-extern ssize_t generic_file_splice_read(struct file *, struct inode *, size_t, unsigned int);
-extern ssize_t generic_file_splice_write(struct inode *, struct file *, size_t, unsigned int);
+
+/* fs/splice.c */
+extern ssize_t generic_file_splice_read(struct file *,
+ struct pipe_inode_info *, size_t, unsigned int);
+extern ssize_t generic_file_splice_write(struct pipe_inode_info *,
+ struct file *, size_t, unsigned int);
+extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+ struct file *out, size_t len, unsigned int flags);
+extern long do_splice_direct(struct file *in, struct file *out,
+ size_t len, unsigned int flags);
+
extern void
file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov,
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 7851e6b520cf0..3ac452945a7d5 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -57,6 +57,8 @@ struct vm_area_struct;
__GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
__GFP_NOMEMALLOC|__GFP_HARDWALL)
+/* This equals 0, but use constants in case they ever change */
+#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH)
/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */
#define GFP_ATOMIC (__GFP_HIGH)
#define GFP_NOIO (__GFP_WAIT)
diff --git a/include/linux/init.h b/include/linux/init.h
index ed0ac7c39fdc4..93dcbe1abb4c8 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -245,7 +245,8 @@ void __init parse_early_param(void);
#define __cpuexitdata __exitdata
#endif
-#ifdef CONFIG_MEMORY_HOTPLUG
+#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \
+ || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)
#define __meminit
#define __meminitdata
#define __memexit
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 99905e180532e..043376920f51a 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -36,6 +36,8 @@
/* LATCH is used in the interval timer and ftape setup. */
#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
+#define LATCH_HPET ((HPET_TICK_RATE + HZ/2) / HZ)
+
/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can
* improve accuracy by shifting LSH bits, hence calculating:
* (NOM << LSH) / DEN
@@ -51,9 +53,13 @@
/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */
#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
+#define ACTHZ_HPET (SH_DIV (HPET_TICK_RATE, LATCH_HPET, 8))
+
/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */
#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
+#define TICK_NSEC_HPET (SH_DIV(1000000UL * 1000, ACTHZ_HPET, 8))
+
/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index a3720f973ea58..e1bd0842f6a13 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -176,7 +176,7 @@ static inline void console_verbose(void)
extern void bust_spinlocks(int yes);
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
-extern __deprecated_for_modules int panic_timeout;
+extern int panic_timeout;
extern int panic_on_oops;
extern int tainted;
extern const char *print_tainted(void);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 4617e75903b00..dc23c7c639f32 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -19,39 +19,38 @@ struct class_device;
*/
enum led_brightness {
- LED_OFF = 0,
- LED_HALF = 127,
- LED_FULL = 255,
+ LED_OFF = 0,
+ LED_HALF = 127,
+ LED_FULL = 255,
};
struct led_classdev {
- const char *name;
- int brightness;
- int flags;
-#define LED_SUSPENDED (1 << 0)
+ const char *name;
+ int brightness;
+ int flags;
- /* A function to set the brightness of the led */
- void (*brightness_set)(struct led_classdev *led_cdev,
- enum led_brightness brightness);
+#define LED_SUSPENDED (1 << 0)
- struct class_device *class_dev;
- /* LED Device linked list */
- struct list_head node;
+ /* Set LED brightness level */
+ void (*brightness_set)(struct led_classdev *led_cdev,
+ enum led_brightness brightness);
+
+ struct class_device *class_dev;
+ struct list_head node; /* LED Device list */
+ char *default_trigger; /* Trigger to use */
- /* Trigger data */
- char *default_trigger;
#ifdef CONFIG_LEDS_TRIGGERS
- rwlock_t trigger_lock;
/* Protects the trigger data below */
+ rwlock_t trigger_lock;
- struct led_trigger *trigger;
- struct list_head trig_list;
- void *trigger_data;
+ struct led_trigger *trigger;
+ struct list_head trig_list;
+ void *trigger_data;
#endif
};
extern int led_classdev_register(struct device *parent,
- struct led_classdev *led_cdev);
+ struct led_classdev *led_cdev);
extern void led_classdev_unregister(struct led_classdev *led_cdev);
extern void led_classdev_suspend(struct led_classdev *led_cdev);
extern void led_classdev_resume(struct led_classdev *led_cdev);
@@ -65,16 +64,16 @@ extern void led_classdev_resume(struct led_classdev *led_cdev);
struct led_trigger {
/* Trigger Properties */
- const char *name;
- void (*activate)(struct led_classdev *led_cdev);
- void (*deactivate)(struct led_classdev *led_cdev);
+ const char *name;
+ void (*activate)(struct led_classdev *led_cdev);
+ void (*deactivate)(struct led_classdev *led_cdev);
/* LEDs under control by this trigger (for simple triggers) */
- rwlock_t leddev_list_lock;
- struct list_head led_cdevs;
+ rwlock_t leddev_list_lock;
+ struct list_head led_cdevs;
/* Link to next registered trigger */
- struct list_head next_trig;
+ struct list_head next_trig;
};
/* Registration functions for complex triggers */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 0d61357604d5b..b80d2e7fa6d25 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -523,7 +523,6 @@ extern void ata_host_set_remove(struct ata_host_set *host_set);
extern int ata_scsi_detect(struct scsi_host_template *sht);
extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
-extern int ata_scsi_error(struct Scsi_Host *host);
extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
extern int ata_scsi_release(struct Scsi_Host *host);
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 968b1aa3732cb..4ca3e6ad03ec4 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -58,8 +58,6 @@ extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
/* need some defines for these for archs that don't support it */
extern void online_page(struct page *page);
/* VM interface that may be used by firmware interface */
-extern int add_memory(u64 start, u64 size);
-extern int remove_memory(u64 start, u64 size);
extern int online_pages(unsigned long, unsigned long);
/* reasonably generic interface to expand the physical pages in a zone */
@@ -92,11 +90,6 @@ static inline int mhp_notimplemented(const char *func)
return -ENOSYS;
}
-static inline int __add_pages(struct zone *zone, unsigned long start_pfn,
- unsigned long nr_pages)
-{
- return mhp_notimplemented(__FUNCTION__);
-}
#endif /* ! CONFIG_MEMORY_HOTPLUG */
static inline int __remove_pages(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages)
@@ -105,4 +98,11 @@ static inline int __remove_pages(struct zone *zone, unsigned long start_pfn,
dump_stack();
return -ENOSYS;
}
+
+#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \
+ || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)
+extern int add_memory(u64 start, u64 size);
+extern int remove_memory(u64 start, u64 size);
+#endif
+
#endif /* __LINUX_MEMORY_HOTPLUG_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6aa016f1d3ae0..1154684209a44 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -229,10 +229,9 @@ struct page {
unsigned long private; /* Mapping-private opaque data:
* usually used for buffer_heads
* if PagePrivate set; used for
- * swp_entry_t if PageSwapCache.
- * When page is free, this
+ * swp_entry_t if PageSwapCache;
* indicates order in the buddy
- * system.
+ * system if PG_buddy is set.
*/
struct address_space *mapping; /* If low bit clear, points to
* inode address_space, or NULL.
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 412e52ca9720c..b31a9bca93613 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -110,6 +110,8 @@ struct nf_info
/* Function to register/unregister hook points. */
int nf_register_hook(struct nf_hook_ops *reg);
void nf_unregister_hook(struct nf_hook_ops *reg);
+int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n);
+void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
/* Functions to register get/setsockopt ranges (non-inclusive). You
need to check permissions yourself! */
@@ -281,16 +283,42 @@ extern void nf_invalidate_cache(int pf);
Returns true or false. */
extern int skb_make_writable(struct sk_buff **pskb, unsigned int writable_len);
-struct nf_queue_rerouter {
- void (*save)(const struct sk_buff *skb, struct nf_info *info);
- int (*reroute)(struct sk_buff **skb, const struct nf_info *info);
- int rer_size;
+struct nf_afinfo {
+ unsigned short family;
+ unsigned int (*checksum)(struct sk_buff *skb, unsigned int hook,
+ unsigned int dataoff, u_int8_t protocol);
+ void (*saveroute)(const struct sk_buff *skb,
+ struct nf_info *info);
+ int (*reroute)(struct sk_buff **skb,
+ const struct nf_info *info);
+ int route_key_size;
};
-#define nf_info_reroute(x) ((void *)x + sizeof(struct nf_info))
+extern struct nf_afinfo *nf_afinfo[];
+static inline struct nf_afinfo *nf_get_afinfo(unsigned short family)
+{
+ return rcu_dereference(nf_afinfo[family]);
+}
+
+static inline unsigned int
+nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
+ u_int8_t protocol, unsigned short family)
+{
+ struct nf_afinfo *afinfo;
+ unsigned int csum = 0;
+
+ rcu_read_lock();
+ afinfo = nf_get_afinfo(family);
+ if (afinfo)
+ csum = afinfo->checksum(skb, hook, dataoff, protocol);
+ rcu_read_unlock();
+ return csum;
+}
-extern int nf_register_queue_rerouter(int pf, struct nf_queue_rerouter *rer);
-extern int nf_unregister_queue_rerouter(int pf);
+extern int nf_register_afinfo(struct nf_afinfo *afinfo);
+extern void nf_unregister_afinfo(struct nf_afinfo *afinfo);
+
+#define nf_info_reroute(x) ((void *)x + sizeof(struct nf_info))
#include <net/flow.h>
extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *);
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 43c09d790b838..85301c5e8d246 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -80,6 +80,8 @@ enum nf_ip_hook_priorities {
#ifdef __KERNEL__
extern int ip_route_me_harder(struct sk_buff **pskb);
extern int ip_xfrm_me_harder(struct sk_buff **pskb);
+extern unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
+ unsigned int dataoff, u_int8_t protocol);
#endif /*__KERNEL__*/
#endif /*__LINUX_IP_NETFILTER_H*/
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_h323.h b/include/linux/netfilter_ipv4/ip_conntrack_h323.h
index 0987cea538403..eace86bd2adbe 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_h323.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_h323.h
@@ -3,6 +3,8 @@
#ifdef __KERNEL__
+#include <linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h>
+
#define RAS_PORT 1719
#define Q931_PORT 1720
#define H323_RTP_CHANNEL_MAX 4 /* Audio, video, FAX and other */
@@ -25,6 +27,56 @@ struct ip_ct_h323_master {
};
};
+struct ip_conntrack_expect;
+
+extern int get_h225_addr(unsigned char *data, TransportAddress * addr,
+ u_int32_t * ip, u_int16_t * port);
+extern void ip_conntrack_h245_expect(struct ip_conntrack *new,
+ struct ip_conntrack_expect *this);
+extern void ip_conntrack_q931_expect(struct ip_conntrack *new,
+ struct ip_conntrack_expect *this);
+extern int (*set_h245_addr_hook) (struct sk_buff ** pskb,
+ unsigned char **data, int dataoff,
+ H245_TransportAddress * addr,
+ u_int32_t ip, u_int16_t port);
+extern int (*set_h225_addr_hook) (struct sk_buff ** pskb,
+ unsigned char **data, int dataoff,
+ TransportAddress * addr,
+ u_int32_t ip, u_int16_t port);
+extern int (*set_sig_addr_hook) (struct sk_buff ** pskb,
+ struct ip_conntrack * ct,
+ enum ip_conntrack_info ctinfo,
+ unsigned char **data,
+ TransportAddress * addr, int count);
+extern int (*set_ras_addr_hook) (struct sk_buff ** pskb,
+ struct ip_conntrack * ct,
+ enum ip_conntrack_info ctinfo,
+ unsigned char **data,
+ TransportAddress * addr, int count);
+extern int (*nat_rtp_rtcp_hook) (struct sk_buff ** pskb,
+ struct ip_conntrack * ct,
+ enum ip_conntrack_info ctinfo,
+ unsigned char **data, int dataoff,
+ H245_TransportAddress * addr,
+ u_int16_t port, u_int16_t rtp_port,
+ struct ip_conntrack_expect * rtp_exp,
+ struct ip_conntrack_expect * rtcp_exp);
+extern int (*nat_t120_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
+ enum ip_conntrack_info ctinfo,
+ unsigned char **data, int dataoff,
+ H245_TransportAddress * addr, u_int16_t port,
+ struct ip_conntrack_expect * exp);
+extern int (*nat_h245_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
+ enum ip_conntrack_info ctinfo,
+ unsigned char **data, int dataoff,
+ TransportAddress * addr, u_int16_t port,
+ struct ip_conntrack_expect * exp);
+extern int (*nat_q931_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
+ enum ip_conntrack_info ctinfo,
+ unsigned char **data, TransportAddress * addr,
+ int idx, u_int16_t port,
+ struct ip_conntrack_expect * exp);
+
#endif
#endif
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.h b/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h
index 0bd828081c0c4..0bd828081c0c4 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_types.h b/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h
index cc98f7aa5abee..cc98f7aa5abee 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_types.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
index 14f2bd010884d..52a7b9e76428c 100644
--- a/include/linux/netfilter_ipv6.h
+++ b/include/linux/netfilter_ipv6.h
@@ -73,6 +73,9 @@ enum nf_ip6_hook_priorities {
};
#ifdef CONFIG_NETFILTER
+extern unsigned int nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
+ unsigned int dataoff, u_int8_t protocol);
+
extern int ipv6_netfilter_init(void);
extern void ipv6_netfilter_fini(void);
#else /* CONFIG_NETFILTER */
diff --git a/include/linux/numa.h b/include/linux/numa.h
index f0c539bd3cfc4..e481feb1bfd81 100644
--- a/include/linux/numa.h
+++ b/include/linux/numa.h
@@ -3,11 +3,9 @@
#include <linux/config.h>
-#ifndef CONFIG_FLATMEM
-#include <asm/numnodes.h>
-#endif
-
-#ifndef NODES_SHIFT
+#ifdef CONFIG_NODES_SHIFT
+#define NODES_SHIFT CONFIG_NODES_SHIFT
+#else
#define NODES_SHIFT 0
#endif
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 9ea629c02a4b9..d276a4e2f8250 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -48,8 +48,20 @@
/*
* Don't use the *_dontuse flags. Use the macros. Otherwise you'll break
- * locked- and dirty-page accounting. The top eight bits of page->flags are
- * used for page->zone, so putting flag bits there doesn't work.
+ * locked- and dirty-page accounting.
+ *
+ * The page flags field is split into two parts, the main flags area
+ * which extends from the low bits upwards, and the fields area which
+ * extends from the high bits downwards.
+ *
+ * | FIELD | ... | FLAGS |
+ * N-1 ^ 0
+ * (N-FLAGS_RESERVED)
+ *
+ * The fields area is reserved for fields mapping zone, node and SPARSEMEM
+ * section. The boundry between these two areas is defined by
+ * FLAGS_RESERVED which defines the width of the fields section
+ * (see linux/mmzone.h). New flags must _not_ overlap with this area.
*/
#define PG_locked 0 /* Page is locked. Don't touch. */
#define PG_error 1
@@ -74,7 +86,9 @@
#define PG_mappedtodisk 16 /* Has blocks allocated on-disk */
#define PG_reclaim 17 /* To be reclaimed asap */
#define PG_nosave_free 18 /* Free, should not be written */
-#define PG_uncached 19 /* Page has been mapped as uncached */
+#define PG_buddy 19 /* Page is free, on buddy lists */
+
+#define PG_uncached 20 /* Page has been mapped as uncached */
/*
* Global page accounting. One instance per CPU. Only unsigned longs are
@@ -317,6 +331,10 @@ extern void __mod_page_state_offset(unsigned long offset, unsigned long delta);
#define SetPageNosaveFree(page) set_bit(PG_nosave_free, &(page)->flags)
#define ClearPageNosaveFree(page) clear_bit(PG_nosave_free, &(page)->flags)
+#define PageBuddy(page) test_bit(PG_buddy, &(page)->flags)
+#define __SetPageBuddy(page) __set_bit(PG_buddy, &(page)->flags)
+#define __ClearPageBuddy(page) __clear_bit(PG_buddy, &(page)->flags)
+
#define PageMappedToDisk(page) test_bit(PG_mappedtodisk, &(page)->flags)
#define SetPageMappedToDisk(page) set_bit(PG_mappedtodisk, &(page)->flags)
#define ClearPageMappedToDisk(page) clear_bit(PG_mappedtodisk, &(page)->flags)
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index d218fc7293199..123a7c24bc72b 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -5,11 +5,14 @@
#define PIPE_BUFFERS (16)
+#define PIPE_BUF_FLAG_STOLEN 0x01
+#define PIPE_BUF_FLAG_LRU 0x02
+
struct pipe_buffer {
struct page *page;
unsigned int offset, len;
struct pipe_buf_operations *ops;
- unsigned int stolen;
+ unsigned int flags;
};
struct pipe_buf_operations {
@@ -33,27 +36,19 @@ struct pipe_inode_info {
unsigned int w_counter;
struct fasync_struct *fasync_readers;
struct fasync_struct *fasync_writers;
+ struct inode *inode;
};
/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
#define PIPE_SIZE PAGE_SIZE
-#define PIPE_MUTEX(inode) (&(inode).i_mutex)
-#define PIPE_WAIT(inode) (&(inode).i_pipe->wait)
-#define PIPE_READERS(inode) ((inode).i_pipe->readers)
-#define PIPE_WRITERS(inode) ((inode).i_pipe->writers)
-#define PIPE_WAITING_WRITERS(inode) ((inode).i_pipe->waiting_writers)
-#define PIPE_RCOUNTER(inode) ((inode).i_pipe->r_counter)
-#define PIPE_WCOUNTER(inode) ((inode).i_pipe->w_counter)
-#define PIPE_FASYNC_READERS(inode) (&((inode).i_pipe->fasync_readers))
-#define PIPE_FASYNC_WRITERS(inode) (&((inode).i_pipe->fasync_writers))
-
/* Drop the inode semaphore and wait for a pipe event, atomically */
-void pipe_wait(struct inode * inode);
+void pipe_wait(struct pipe_inode_info *pipe);
-struct inode* pipe_new(struct inode* inode);
-void free_pipe_info(struct inode* inode);
+struct pipe_inode_info * alloc_pipe_info(struct inode * inode);
+void free_pipe_info(struct inode * inode);
+void __free_pipe_info(struct pipe_inode_info *);
/*
* splice is tied to pipes as a transport (at least for now), so we'll just
@@ -63,5 +58,6 @@ void free_pipe_info(struct inode* inode);
#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
/* we may still block on the fd we splice */
/* from/to, of course */
+#define SPLICE_F_MORE (0x04) /* expect more data */
#endif
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 135871df99110..4b47a0253425f 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -79,7 +79,7 @@ struct kcore_list {
struct vmcore {
struct list_head list;
unsigned long long paddr;
- unsigned long size;
+ unsigned long long size;
loff_t offset;
};
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
index 774e1acfb8c4b..f1fbae7e390ec 100644
--- a/include/linux/raid/md_p.h
+++ b/include/linux/raid/md_p.h
@@ -227,8 +227,8 @@ struct mdp_superblock_1 {
*/
/* These are only valid with feature bit '4' */
- __u64 reshape_position; /* next address in array-space for reshape */
__u32 new_level; /* new level we are reshaping to */
+ __u64 reshape_position; /* next address in array-space for reshape */
__u32 delta_disks; /* change in number of raid_disks */
__u32 new_layout; /* new layout */
__u32 new_chunk; /* new chunk size (bytes) */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 541f4828f5e76..e3539c14e47e9 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -684,6 +684,7 @@ static inline void prefetch_stack(struct task_struct *t) { }
struct audit_context; /* See audit.c */
struct mempolicy;
+struct pipe_inode_info;
enum sleep_type {
SLEEP_NORMAL,
@@ -882,6 +883,11 @@ struct task_struct {
atomic_t fs_excl; /* holding fs exclusive resources */
struct rcu_head rcu;
+
+ /*
+ * cache last used pipe for splice
+ */
+ struct pipe_inode_info *splice_pipe;
};
static inline pid_t process_group(struct task_struct *tsk)
@@ -1203,9 +1209,10 @@ extern void wait_task_inactive(task_t * p);
#define while_each_thread(g, t) \
while ((t = next_thread(t)) != g)
-#define thread_group_leader(p) (p->pid == p->tgid)
+/* de_thread depends on thread_group_leader not being a pid based check */
+#define thread_group_leader(p) (p == p->group_leader)
-static inline task_t *next_thread(task_t *p)
+static inline task_t *next_thread(const task_t *p)
{
return list_entry(rcu_dereference(p->thread_group.next),
task_t, thread_group);
diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
index 6336987dae628..2925e66a67329 100644
--- a/include/linux/screen_info.h
+++ b/include/linux/screen_info.h
@@ -41,7 +41,8 @@ struct screen_info {
u16 vesapm_off; /* 0x30 */
u16 pages; /* 0x32 */
u16 vesa_attributes; /* 0x34 */
- /* 0x36 -- 0x3f reserved for future expansion */
+ u32 capabilities; /* 0x36 */
+ /* 0x3a -- 0x3f reserved for future expansion */
};
extern struct screen_info screen_info;
diff --git a/include/linux/sdla_asy.h b/include/linux/sdla_asy.h
deleted file mode 100644
index f62242537c86d..0000000000000
--- a/include/linux/sdla_asy.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*****************************************************************************
-* sdla_asy.h Header file for the Sangoma S508/S514 asynchronous code API
-*
-* Author: Gideon Hack
-*
-* Copyright: (c) 2000 Sangoma Technologies 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.
-* ============================================================================
-*
-* Jan 28, 2000 Gideon Hack Initial Version
-*
-*****************************************************************************/
-
-
-#ifndef _WANPIPE_ASYNC_H
-#define _WANPIPE_ASYNC_H
-
-/* ----------------------------------------------------------------------------
- * Interface commands
- * --------------------------------------------------------------------------*/
-
-#define SET_ASY_CONFIGURATION 0xE2 /* set the asychronous operational configuration */
-#define READ_ASY_CONFIGURATION 0xE3 /* read the current asychronous operational configuration */
-#define ENABLE_ASY_COMMUNICATIONS 0xE4 /* enable asychronous communications */
-#define DISABLE_ASY_COMMUNICATIONS 0xE5 /* disable asychronous communications */
-#define READ_ASY_OPERATIONAL_STATS 0xE7 /* retrieve the asychronous operational statistics */
-#define FLUSH_ASY_OPERATIONAL_STATS 0xE8 /* flush the asychronous operational statistics */
-#define TRANSMIT_ASY_BREAK_SIGNAL 0xEC /* transmit an asychronous break signal */
-
-
-
-/* ----------------------------------------------------------------------------
- * Return codes from interface commands
- * --------------------------------------------------------------------------*/
-
-#define COMMAND_INVALID_FOR_PORT 0x50 /* the command is invalid for the selected port */
-#define DISABLE_ASY_COMMS_BEFORE_CFG 0xE1 /* communications must be disabled before setting the configuration */
-#define ASY_COMMS_ENABLED 0xE1 /* communications are currently enabled */
-#define ASY_COMMS_DISABLED 0xE1 /* communications are currently disabled */
-#define ASY_CFG_BEFORE_COMMS_ENABLED 0xE2 /* perform a SET_ASY_CONFIGURATION before enabling comms */
-#define LGTH_ASY_CFG_DATA_INVALID 0xE2 /* the length of the passed configuration data is invalid */
-#define INVALID_ASY_CFG_DATA 0xE3 /* the passed configuration data is invalid */
-#define ASY_BREAK_SIGNAL_BUSY 0xEC /* a break signal is being transmitted */
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the SET_ASY_CONFIGURATION/READ_ASY_CONFIGURATION command
- * --------------------------------------------------------------------------*/
-
-/* the asynchronous configuration structure */
-typedef struct {
- unsigned long baud_rate PACKED; /* the baud rate */
- unsigned short line_config_options PACKED; /* line configuration options */
- unsigned short modem_config_options PACKED; /* modem configuration options */
- unsigned short asy_API_options PACKED; /* asynchronous API options */
- unsigned short asy_protocol_options PACKED; /* asynchronous protocol options */
- unsigned short Tx_bits_per_char PACKED; /* number of bits per tx character */
- unsigned short Rx_bits_per_char PACKED; /* number of bits per received character */
- unsigned short stop_bits PACKED; /* number of stop bits per character */
- unsigned short parity PACKED; /* parity definition */
- unsigned short break_timer PACKED; /* the break signal timer */
- unsigned short asy_Rx_inter_char_timer PACKED; /* the receive inter-character timer */
- unsigned short asy_Rx_complete_length PACKED; /* the receive 'buffer complete' length */
- unsigned short XON_char PACKED; /* the XON character */
- unsigned short XOFF_char PACKED; /* the XOFF character */
- unsigned short asy_statistics_options PACKED; /* async operational stat options */
- unsigned long ptr_shared_mem_info_struct PACKED;/* ptr to the shared memory area information structure */
- unsigned long ptr_asy_Tx_stat_el_cfg_struct PACKED;/* ptr to the transmit status element configuration structure */
- unsigned long ptr_asy_Rx_stat_el_cfg_struct PACKED;/* ptr to the receive status element configuration structure */
-} ASY_CONFIGURATION_STRUCT;
-
-/* permitted minimum and maximum values for setting the asynchronous configuration */
-#define MIN_ASY_BAUD_RATE 50 /* maximum baud rate */
-#define MAX_ASY_BAUD_RATE 250000 /* minimum baud rate */
-#define MIN_ASY_BITS_PER_CHAR 5 /* minimum number of bits per character */
-#define MAX_ASY_BITS_PER_CHAR 8 /* maximum number of bits per character */
-#define MIN_BREAK_TMR_VAL 0 /* minimum break signal timer */
-#define MAX_BREAK_TMR_VAL 5000 /* maximum break signal timer */
-#define MIN_ASY_RX_INTER_CHAR_TMR 0 /* minimum receive inter-character timer */
-#define MAX_ASY_RX_INTER_CHAR_TMR 30000 /* maximum receive inter-character timer */
-#define MIN_ASY_RX_CPLT_LENGTH 0 /* minimum receive 'length complete' value */
-#define MAX_ASY_RX_CPLT_LENGTH 2000 /* maximum receive 'length complete' value */
-
-/* bit settings for the 'asy_API_options' */
-#define ASY_RX_DATA_TRANSPARENT 0x0001 /* do not strip parity and unused bits from received characters */
-
-/* bit settings for the 'asy_protocol_options' */
-#define ASY_RTS_HS_FOR_RX 0x0001 /* RTS handshaking is used for reception control */
-#define ASY_XON_XOFF_HS_FOR_RX 0x0002 /* XON/XOFF handshaking is used for reception control */
-#define ASY_XON_XOFF_HS_FOR_TX 0x0004 /* XON/XOFF handshaking is used for transmission control */
-#define ASY_DCD_HS_FOR_TX 0x0008 /* DCD handshaking is used for transmission control */
-#define ASY_CTS_HS_FOR_TX 0x0020 /* CTS handshaking is used for transmission control */
-
-/* bit settings for the 'stop_bits' definition */
-#define ONE_STOP_BIT 1 /* representation for 1 stop bit */
-#define TWO_STOP_BITS 2 /* representation for 2 stop bits */
-#define ONE_AND_A_HALF_STOP_BITS 3 /* representation for 1.5 stop bits */
-
-/* bit settings for the 'parity' definition */
-#define NO_PARITY 0 /* representation for no parity */
-#define ODD_PARITY 1 /* representation for odd parity */
-#define EVEN_PARITY 2 /* representation for even parity */
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the READ_COMMS_ERROR_STATS command (asynchronous mode)
- * --------------------------------------------------------------------------*/
-
-/* the communications error statistics structure */
-typedef struct {
- unsigned short Rx_overrun_err_count PACKED; /* receiver overrun error count */
- unsigned short Rx_parity_err_count PACKED; /* parity errors received count */
- unsigned short Rx_framing_err_count PACKED; /* framing errors received count */
- unsigned short comms_err_stat_reserved_1 PACKED;/* reserved for later use */
- unsigned short comms_err_stat_reserved_2 PACKED;/* reserved for later use */
- unsigned short comms_err_stat_reserved_3 PACKED;/* reserved for later use */
- unsigned short comms_err_stat_reserved_4 PACKED;/* reserved for later use */
- unsigned short comms_err_stat_reserved_5 PACKED;/* reserved for later use */
- unsigned short DCD_state_change_count PACKED; /* DCD state change count */
- unsigned short CTS_state_change_count PACKED; /* CTS state change count */
-} ASY_COMMS_ERROR_STATS_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the READ_ASY_OPERATIONAL_STATS command
- * --------------------------------------------------------------------------*/
-
-/* the asynchronous operational statistics structure */
-typedef struct {
-
- /* Data transmission statistics */
- unsigned long Data_blocks_Tx_count PACKED;/* number of blocks transmitted */
- unsigned long Data_bytes_Tx_count PACKED;/* number of bytes transmitted */
- unsigned long Data_Tx_throughput PACKED;/* transmit throughput */
- unsigned long no_ms_for_Data_Tx_thruput_comp PACKED;/* millisecond time used for the Tx throughput computation */
- unsigned long Tx_Data_discard_lgth_err_count PACKED;/* number of Data blocks discarded (length error) */
- unsigned long reserved_Data_frm_Tx_stat1 PACKED;/* reserved for later use */
- unsigned long reserved_Data_frm_Tx_stat2 PACKED;/* reserved for later use */
- unsigned long reserved_Data_frm_Tx_stat3 PACKED;/* reserved for later use */
-
- /* Data reception statistics */
- unsigned long Data_blocks_Rx_count PACKED;/* number of blocks received */
- unsigned long Data_bytes_Rx_count PACKED;/* number of bytes received */
- unsigned long Data_Rx_throughput PACKED;/* receive throughput */
- unsigned long no_ms_for_Data_Rx_thruput_comp PACKED;/* millisecond time used for the Rx throughput computation */
- unsigned long Rx_Data_bytes_discard_count PACKED;/* received Data bytes discarded */
- unsigned long reserved_Data_frm_Rx_stat1 PACKED;/* reserved for later use */
-
- /* handshaking protocol statistics */
- unsigned short XON_chars_Tx_count PACKED; /* number of XON characters transmitted */
- unsigned short XOFF_chars_Tx_count PACKED; /* number of XOFF characters transmitted */
- unsigned short XON_chars_Rx_count PACKED; /* number of XON characters received */
- unsigned short XOFF_chars_Rx_count PACKED; /* number of XOFF characters received */
- unsigned short Tx_halt_modem_low_count PACKED; /* number of times Tx halted (modem line low) */
- unsigned short Rx_halt_RTS_low_count PACKED; /* number of times Rx halted by setting RTS low */
- unsigned long reserved_handshaking_stat1 PACKED;/* reserved for later use */
-
- /* break statistics */
- unsigned short break_Tx_count PACKED; /* number of break sequences transmitted */
- unsigned short break_Rx_count PACKED; /* number of break sequences received */
- unsigned long reserved_break_stat1 PACKED;/* reserved for later use */
-
- /* miscellaneous statistics */
- unsigned long reserved_misc_stat1 PACKED; /* reserved for later use */
- unsigned long reserved_misc_stat2 PACKED; /* reserved for later use */
-
-} ASY_OPERATIONAL_STATS_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for Data transmission
- * --------------------------------------------------------------------------*/
-
-/* the Data block transmit status element configuration structure */
-typedef struct {
- unsigned short number_Tx_status_elements PACKED; /* number of transmit status elements */
- unsigned long base_addr_Tx_status_elements PACKED; /* base address of the transmit element list */
- unsigned long next_Tx_status_element_to_use PACKED; /* pointer to the next transmit element to be used */
-} ASY_TX_STATUS_EL_CFG_STRUCT;
-
-
-/* the Data block transmit status element structure */
-typedef struct {
- unsigned char opp_flag PACKED; /* opp flag */
- unsigned short data_length PACKED; /* length of the block to be transmitted */
- unsigned char reserved_1 PACKED; /* reserved for internal use */
- unsigned long reserved_2 PACKED; /* reserved for internal use */
- unsigned long reserved_3 PACKED; /* reserved for internal use */
- unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
-} ASY_DATA_TX_STATUS_EL_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for Data reception
- * --------------------------------------------------------------------------*/
-
-/* the Data block receive status element configuration structure */
-typedef struct {
- unsigned short number_Rx_status_elements PACKED;/* number of receive status elements */
- unsigned long base_addr_Rx_status_elements PACKED;/* base address of the receive element list */
- unsigned long next_Rx_status_element_to_use PACKED;/* pointer to the next receive element to be used */
- unsigned long base_addr_Rx_buffer PACKED;/* base address of the receive data buffer */
- unsigned long end_addr_Rx_buffer PACKED;/* end address of the receive data buffer */
-} ASY_RX_STATUS_EL_CFG_STRUCT;
-
-/* the Data block receive status element structure */
-typedef struct {
- unsigned char opp_flag PACKED; /* opp flag */
- unsigned short data_length PACKED; /* length of the received data block */
- unsigned char reserved_1 PACKED; /* reserved for internal use */
- unsigned short time_stamp PACKED; /* receive time stamp (HDLC_STREAMING_MODE) */
- unsigned short data_buffered PACKED; /* the number of data bytes still buffered */
- unsigned long reserved_2 PACKED; /* reserved for internal use */
- unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
-} ASY_DATA_RX_STATUS_EL_STRUCT;
-
-#endif
diff --git a/include/linux/sdla_chdlc.h b/include/linux/sdla_chdlc.h
deleted file mode 100644
index d2e35a2990341..0000000000000
--- a/include/linux/sdla_chdlc.h
+++ /dev/null
@@ -1,813 +0,0 @@
-/*************************************************************************
- sdla_chdlc.h Sangoma Cisco HDLC firmware API definitions
-
- Author: Gideon Hack
- Nenad Corbic <ncorbic@sangoma.com>
-
- Copyright: (c) 1995-2000 Sangoma Technologies Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the term 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.
-
-===========================================================================
- Oct 04, 1999 Nenad Corbic Updated API support
- Jun 02, 1999 Gideon Hack Changes for S514 usage.
- Oct 28, 1998 Jaspreet Singh Made changes for Dual Port CHDLC.
- Jun 11, 1998 David Fong Initial version.
-===========================================================================
-
- Organization
- - Compatibility notes
- - Constants defining the shared memory control block (mailbox)
- - Interface commands
- - Return code from interface commands
- - Constants for the commands (structures for casting data)
- - UDP Management constants and structures
-
-*************************************************************************/
-
-#ifndef _SDLA_CHDLC_H
-# define _SDLC_CHDLC_H
-
-/*------------------------------------------------------------------------
- Notes:
-
- All structres defined in this file are byte-aligned.
-
- Compiler Platform
- ------------------------
- GNU C Linux
-
-------------------------------------------------------------------------*/
-
-#ifndef PACKED
-#define PACKED __attribute__((packed))
-#endif /* PACKED */
-
-
-/* ----------------------------------------------------------------------------
- * Constants defining the shared memory control block (mailbox)
- * --------------------------------------------------------------------------*/
-
-#define PRI_BASE_ADDR_MB_STRUCT 0xE000 /* the base address of the mailbox structure on the adapter */
-#define SEC_BASE_ADDR_MB_STRUCT 0xE800 /* the base address of the mailbox structure on the adapter */
-#define SIZEOF_MB_DATA_BFR 2032 /* the size of the actual mailbox data area */
-#define NUMBER_MB_RESERVED_BYTES 0x0B /* the number of reserved bytes in the mailbox header area */
-
-
-#define MIN_LGTH_CHDLC_DATA_CFG 300 /* min length of the CHDLC data field (for configuration purposes) */
-#define PRI_MAX_NO_DATA_BYTES_IN_FRAME 15354 /* PRIMARY - max length of the CHDLC data field */
-
-typedef struct {
- unsigned char opp_flag PACKED; /* the opp flag */
- unsigned char command PACKED; /* the user command */
- unsigned short buffer_length PACKED; /* the data length */
- unsigned char return_code PACKED; /* the return code */
- unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED; /* reserved for later */
- unsigned char data[SIZEOF_MB_DATA_BFR] PACKED; /* the data area */
-} CHDLC_MAILBOX_STRUCT;
-
-typedef struct {
- pid_t pid_num PACKED;
- CHDLC_MAILBOX_STRUCT cmdarea PACKED;
-
-} CMDBLOCK_STRUCT;
-
-
-
-
-/* ----------------------------------------------------------------------------
- * Interface commands
- * --------------------------------------------------------------------------*/
-
-/* global interface commands */
-#define READ_GLOBAL_EXCEPTION_CONDITION 0x01
-#define SET_GLOBAL_CONFIGURATION 0x02
-#define READ_GLOBAL_CONFIGURATION 0x03
-#define READ_GLOBAL_STATISTICS 0x04
-#define FLUSH_GLOBAL_STATISTICS 0x05
-#define SET_MODEM_STATUS 0x06 /* set status of DTR or RTS */
-#define READ_MODEM_STATUS 0x07 /* read status of CTS and DCD */
-#define READ_COMMS_ERROR_STATS 0x08
-#define FLUSH_COMMS_ERROR_STATS 0x09
-#define SET_TRACE_CONFIGURATION 0x0A /* set the line trace config */
-#define READ_TRACE_CONFIGURATION 0x0B /* read the line trace config */
-#define READ_TRACE_STATISTICS 0x0C /* read the trace statistics */
-#define FLUSH_TRACE_STATISTICS 0x0D /* flush the trace statistics */
-#define FT1_MONITOR_STATUS_CTRL 0x1C /* set the status of the S508/FT1 monitoring */
-#define SET_FT1_CONFIGURATION 0x18 /* set the FT1 configuration */
-#define READ_FT1_CONFIGURATION 0x19 /* read the FT1 configuration */
-#define TRANSMIT_ASYNC_DATA_TO_FT1 0x1A /* output asynchronous data to the FT1 */
-#define RECEIVE_ASYNC_DATA_FROM_FT1 0x1B /* receive asynchronous data from the FT1 */
-#define FT1_MONITOR_STATUS_CTRL 0x1C /* set the status of the FT1 monitoring */
-
-#define READ_FT1_OPERATIONAL_STATS 0x1D /* read the S508/FT1 operational statistics */
-#define SET_FT1_MODE 0x1E /* set the operational mode of the S508/FT1 module */
-
-/* CHDLC-level interface commands */
-#define READ_CHDLC_CODE_VERSION 0x20
-#define READ_CHDLC_EXCEPTION_CONDITION 0x21 /* read exception condition from the adapter */
-#define SET_CHDLC_CONFIGURATION 0x22
-#define READ_CHDLC_CONFIGURATION 0x23
-#define ENABLE_CHDLC_COMMUNICATIONS 0x24
-#define DISABLE_CHDLC_COMMUNICATIONS 0x25
-#define READ_CHDLC_LINK_STATUS 0x26
-#define READ_CHDLC_OPERATIONAL_STATS 0x27
-#define FLUSH_CHDLC_OPERATIONAL_STATS 0x28
-#define SET_CHDLC_INTERRUPT_TRIGGERS 0x30 /* set application interrupt triggers */
-#define READ_CHDLC_INTERRUPT_TRIGGERS 0x31 /* read application interrupt trigger configuration */
-
-/* Special UDP drivers management commands */
-#define CPIPE_ENABLE_TRACING 0x50
-#define CPIPE_DISABLE_TRACING 0x51
-#define CPIPE_GET_TRACE_INFO 0x52
-#define CPIPE_GET_IBA_DATA 0x53
-#define CPIPE_FT1_READ_STATUS 0x54
-#define CPIPE_DRIVER_STAT_IFSEND 0x55
-#define CPIPE_DRIVER_STAT_INTR 0x56
-#define CPIPE_DRIVER_STAT_GEN 0x57
-#define CPIPE_FLUSH_DRIVER_STATS 0x58
-#define CPIPE_ROUTER_UP_TIME 0x59
-
-/* Driver specific commands for API */
-#define CHDLC_READ_TRACE_DATA 0xE4 /* read trace data */
-#define TRACE_ALL 0x00
-#define TRACE_PROT 0x01
-#define TRACE_DATA 0x02
-
-#define DISCARD_RX_ERROR_FRAMES 0x0001
-
-/* ----------------------------------------------------------------------------
- * Return codes from interface commands
- * --------------------------------------------------------------------------*/
-
-#define COMMAND_OK 0x00
-
-/* return codes from global interface commands */
-#define NO_GLOBAL_EXCEP_COND_TO_REPORT 0x01 /* there is no CHDLC exception condition to report */
-#define LGTH_GLOBAL_CFG_DATA_INVALID 0x01 /* the length of the passed global configuration data is invalid */
-#define LGTH_TRACE_CFG_DATA_INVALID 0x01 /* the length of the passed trace configuration data is invalid */
-#define IRQ_TIMEOUT_VALUE_INVALID 0x02 /* an invalid application IRQ timeout value was selected */
-#define TRACE_CONFIG_INVALID 0x02 /* the passed line trace configuration is invalid */
-#define ADAPTER_OPERATING_FREQ_INVALID 0x03 /* an invalid adapter operating frequency was selected */
-#define TRC_DEAC_TMR_INVALID 0x03 /* the trace deactivation timer is invalid */
-#define S508_FT1_ADPTR_NOT_PRESENT 0x0C /* the S508/FT1 adapter is not present */
-#define INVALID_FT1_STATUS_SELECTION 0x0D /* the S508/FT1 status selection is invalid */
-#define FT1_OP_STATS_NOT_ENABLED 0x0D /* the FT1 operational statistics have not been enabled */
-#define FT1_OP_STATS_NOT_AVAILABLE 0x0E /* the FT1 operational statistics are not currently available */
-#define S508_FT1_MODE_SELECTION_BUSY 0x0E /* the S508/FT1 adapter is busy selecting the operational mode */
-
-/* return codes from command READ_GLOBAL_EXCEPTION_CONDITION */
-#define EXCEP_MODEM_STATUS_CHANGE 0x10 /* a modem status change occurred */
-#define EXCEP_TRC_DISABLED 0x11 /* the trace has been disabled */
-#define EXCEP_IRQ_TIMEOUT 0x12 /* IRQ timeout */
-
-/* return codes from CHDLC-level interface commands */
-#define NO_CHDLC_EXCEP_COND_TO_REPORT 0x21 /* there is no CHDLC exception condition to report */
-#define CHDLC_COMMS_DISABLED 0x21 /* communications are not currently enabled */
-#define CHDLC_COMMS_ENABLED 0x21 /* communications are currently enabled */
-#define DISABLE_CHDLC_COMMS_BEFORE_CFG 0x21 /* CHDLC communications must be disabled before setting the configuration */
-#define ENABLE_CHDLC_COMMS_BEFORE_CONN 0x21 /* communications must be enabled before using the CHDLC_CONNECT conmmand */
-#define CHDLC_CFG_BEFORE_COMMS_ENABLED 0x22 /* perform a SET_CHDLC_CONFIGURATION before enabling comms */
-#define LGTH_CHDLC_CFG_DATA_INVALID 0x22 /* the length of the passed CHDLC configuration data is invalid */
-#define LGTH_INT_TRIGGERS_DATA_INVALID 0x22 /* the length of the passed interrupt trigger data is invalid */
-#define INVALID_IRQ_SELECTED 0x23 /* in invalid IRQ was selected in the SET_CHDLC_INTERRUPT_TRIGGERS */
-#define INVALID_CHDLC_CFG_DATA 0x23 /* the passed CHDLC configuration data is invalid */
-#define IRQ_TMR_VALUE_INVALID 0x24 /* an invalid application IRQ timer value was selected */
-#define LARGER_PERCENT_TX_BFR_REQUIRED 0x24 /* a larger Tx buffer percentage is required */
-#define LARGER_PERCENT_RX_BFR_REQUIRED 0x25 /* a larger Rx buffer percentage is required */
-#define S514_BOTH_PORTS_SAME_CLK_MODE 0x26 /* S514 - both ports must have same clock mode */
-#define INVALID_CMND_HDLC_STREAM_MODE 0x4E /* the CHDLC interface command is invalid for HDLC streaming mode */
-#define INVALID_CHDLC_COMMAND 0x4F /* the defined CHDLC interface command is invalid */
-
-/* return codes from command READ_CHDLC_EXCEPTION_CONDITION */
-#define EXCEP_LINK_ACTIVE 0x30 /* the CHDLC link has become active */
-#define EXCEP_LINK_INACTIVE_MODEM 0x31 /* the CHDLC link has become inactive (modem status) */
-#define EXCEP_LINK_INACTIVE_KPALV 0x32 /* the CHDLC link has become inactive (keepalive status) */
-#define EXCEP_IP_ADDRESS_DISCOVERED 0x33 /* the IP address has been discovered */
-#define EXCEP_LOOPBACK_CONDITION 0x34 /* a loopback condition has occurred */
-
-
-/* return code from command CHDLC_SEND_WAIT and CHDLC_SEND_NO_WAIT */
-#define LINK_DISCONNECTED 0x21
-#define NO_TX_BFRS_AVAIL 0x24
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the SET_GLOBAL_CONFIGURATION/READ_GLOBAL_CONFIGURATION commands
- * --------------------------------------------------------------------------*/
-
-/* the global configuration structure */
-typedef struct {
- unsigned short adapter_config_options PACKED; /* adapter config options */
- unsigned short app_IRQ_timeout PACKED; /* application IRQ timeout */
- unsigned long adapter_operating_frequency PACKED; /* adapter operating frequency */
-} GLOBAL_CONFIGURATION_STRUCT;
-
-/* settings for the 'app_IRQ_timeout' */
-#define MAX_APP_IRQ_TIMEOUT_VALUE 5000 /* the maximum permitted IRQ timeout */
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the READ_GLOBAL_STATISTICS command
- * --------------------------------------------------------------------------*/
-
-/* the global statistics structure */
-typedef struct {
- unsigned short app_IRQ_timeout_count PACKED;
-} GLOBAL_STATS_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the READ_COMMS_ERROR_STATS command
- * --------------------------------------------------------------------------*/
-
-/* the communications error statistics structure */
-typedef struct {
- unsigned short Rx_overrun_err_count PACKED;
- unsigned short CRC_err_count PACKED; /* receiver CRC error count */
- unsigned short Rx_abort_count PACKED; /* abort frames recvd count */
- unsigned short Rx_dis_pri_bfrs_full_count PACKED;/* receiver disabled */
- unsigned short comms_err_stat_reserved_1 PACKED;/* reserved for later */
- unsigned short sec_Tx_abort_msd_Tx_int_count PACKED; /* secondary - abort frames transmitted count (missed Tx interrupt) */
- unsigned short missed_Tx_und_int_count PACKED; /* missed tx underrun interrupt count */
- unsigned short sec_Tx_abort_count PACKED; /*secondary-abort frames tx count */
- unsigned short DCD_state_change_count PACKED; /* DCD state change */
- unsigned short CTS_state_change_count PACKED; /* CTS state change */
-} COMMS_ERROR_STATS_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants used for line tracing
- * --------------------------------------------------------------------------*/
-
-/* the trace configuration structure (SET_TRACE_CONFIGURATION/READ_TRACE_CONFIGURATION commands) */
-typedef struct {
- unsigned char trace_config PACKED; /* trace configuration */
- unsigned short trace_deactivation_timer PACKED; /* trace deactivation timer */
- unsigned long ptr_trace_stat_el_cfg_struct PACKED; /* a pointer to the line trace element configuration structure */
-} LINE_TRACE_CONFIG_STRUCT;
-
-/* 'trace_config' bit settings */
-#define TRACE_INACTIVE 0x00 /* trace is inactive */
-#define TRACE_ACTIVE 0x01 /* trace is active */
-#define TRACE_DELAY_MODE 0x04 /* operate the trace in delay mode */
-#define TRACE_DATA_FRAMES 0x08 /* trace Data frames */
-#define TRACE_SLARP_FRAMES 0x10 /* trace SLARP frames */
-#define TRACE_CDP_FRAMES 0x20 /* trace CDP frames */
-
-/* the line trace status element configuration structure */
-typedef struct {
- unsigned short number_trace_status_elements PACKED; /* number of line trace elements */
- unsigned long base_addr_trace_status_elements PACKED; /* base address of the trace element list */
- unsigned long next_trace_element_to_use PACKED; /* pointer to the next trace element to be used */
- unsigned long base_addr_trace_buffer PACKED; /* base address of the trace data buffer */
- unsigned long end_addr_trace_buffer PACKED; /* end address of the trace data buffer */
-} TRACE_STATUS_EL_CFG_STRUCT;
-
-/* the line trace status element structure */
-typedef struct {
- unsigned char opp_flag PACKED; /* opp flag */
- unsigned short trace_length PACKED; /* trace length */
- unsigned char trace_type PACKED; /* trace type */
- unsigned short trace_time_stamp PACKED; /* time stamp */
- unsigned short trace_reserved_1 PACKED; /* reserved for later use */
- unsigned long trace_reserved_2 PACKED; /* reserved for later use */
- unsigned long ptr_data_bfr PACKED; /* ptr to the trace data buffer */
-} TRACE_STATUS_ELEMENT_STRUCT;
-
-/* "trace_type" bit settings */
-#define TRACE_INCOMING 0x00
-#define TRACE_OUTGOINGING 0x01
-#define TRACE_INCOMING_ABORTED 0x10
-#define TRACE_INCOMING_CRC_ERROR 0x20
-#define TRACE_INCOMING_OVERRUN_ERROR 0x40
-
-
-
-/* the line trace statistics structure */
-typedef struct {
- unsigned long frames_traced_count PACKED; /* number of frames traced */
- unsigned long trc_frms_not_recorded_count PACKED; /* number of trace frames discarded */
-} LINE_TRACE_STATS_STRUCT;
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the FT1_MONITOR_STATUS_CTRL command
- * --------------------------------------------------------------------------*/
-
-#define DISABLE_FT1_STATUS_STATISTICS 0x00 /* disable the FT1 status and statistics monitoring */
-#define ENABLE_READ_FT1_STATUS 0x01 /* read the FT1 operational status */
-#define ENABLE_READ_FT1_OP_STATS 0x02 /* read the FT1 operational statistics */
-#define FLUSH_FT1_OP_STATS 0x04 /* flush the FT1 operational statistics */
-
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the SET_CHDLC_CONFIGURATION command
- * --------------------------------------------------------------------------*/
-
-/* the CHDLC configuration structure */
-typedef struct {
- unsigned long baud_rate PACKED; /* the baud rate */
- unsigned short line_config_options PACKED; /* line configuration options */
- unsigned short modem_config_options PACKED; /* modem configration options */
- unsigned short modem_status_timer PACKED; /* timer for monitoring modem status changes */
- unsigned short CHDLC_API_options PACKED; /* CHDLC API options */
- unsigned short CHDLC_protocol_options PACKED; /* CHDLC protocol options */
- unsigned short percent_data_buffer_for_Tx PACKED; /* percentage data buffering used for Tx */
- unsigned short CHDLC_statistics_options PACKED; /* CHDLC operational statistics options */
- unsigned short max_CHDLC_data_field_length PACKED; /* the maximum length of the CHDLC Data field */
- unsigned short transmit_keepalive_timer PACKED; /* the transmit keepalive timer */
- unsigned short receive_keepalive_timer PACKED; /* the receive keepalive timer */
- unsigned short keepalive_error_tolerance PACKED; /* the receive keepalive error tolerance */
- unsigned short SLARP_request_timer PACKED; /* the SLARP request timer */
- unsigned long IP_address PACKED; /* the IP address */
- unsigned long IP_netmask PACKED; /* the IP netmask */
- unsigned long ptr_shared_mem_info_struct PACKED; /* a pointer to the shared memory area information structure */
- unsigned long ptr_CHDLC_Tx_stat_el_cfg_struct PACKED; /* a pointer to the transmit status element configuration structure */
- unsigned long ptr_CHDLC_Rx_stat_el_cfg_struct PACKED; /* a pointer to the receive status element configuration structure */
-} CHDLC_CONFIGURATION_STRUCT;
-
-/* settings for the 'line_config_options' */
-#define INTERFACE_LEVEL_V35 0x0000 /* V.35 interface level */
-#define INTERFACE_LEVEL_RS232 0x0001 /* RS-232 interface level */
-
-/* settings for the 'modem_config_options' */
-
-#define DONT_RAISE_DTR_RTS_ON_EN_COMMS 0x0001
-/* don't automatically raise DTR and RTS when performing an
- ENABLE_CHDLC_COMMUNICATIONS command */
-
-#define DONT_REPORT_CHG_IN_MODEM_STAT 0x0002
-/* don't report changes in modem status to the application */
-
-
-/* bit settings for the 'CHDLC_protocol_options' byte */
-
-#define IGNORE_DCD_FOR_LINK_STAT 0x0001
-/* ignore DCD in determining the CHDLC link status */
-
-#define IGNORE_CTS_FOR_LINK_STAT 0x0002
-/* ignore CTS in determining the CHDLC link status */
-
-#define IGNORE_KPALV_FOR_LINK_STAT 0x0004
-/* ignore keepalive frames in determining the CHDLC link status */
-
-#define SINGLE_TX_BUFFER 0x4000
-/* configure a single transmit buffer */
-
-#define HDLC_STREAMING_MODE 0x8000
-
-/* settings for the 'CHDLC_statistics_options' */
-
-#define CHDLC_TX_DATA_BYTE_COUNT_STAT 0x0001
-/* record the number of Data bytes transmitted */
-
-#define CHDLC_RX_DATA_BYTE_COUNT_STAT 0x0002
-/* record the number of Data bytes received */
-
-#define CHDLC_TX_THROUGHPUT_STAT 0x0004
-/* compute the Data frame transmit throughput */
-
-#define CHDLC_RX_THROUGHPUT_STAT 0x0008
-/* compute the Data frame receive throughput */
-
-
-/* permitted minimum and maximum values for setting the CHDLC configuration */
-#define PRI_MAX_BAUD_RATE_S508 2666666 /* PRIMARY - maximum baud rate (S508) */
-#define SEC_MAX_BAUD_RATE_S508 258064 /* SECONDARY - maximum baud rate (S508) */
-#define PRI_MAX_BAUD_RATE_S514 2750000 /* PRIMARY - maximum baud rate (S508) */
-#define SEC_MAX_BAUD_RATE_S514 515625 /* SECONDARY - maximum baud rate (S508) */
-
-#define MIN_MODEM_TIMER 0 /* minimum modem status timer */
-#define MAX_MODEM_TIMER 5000 /* maximum modem status timer */
-
-#define SEC_MAX_NO_DATA_BYTES_IN_FRAME 2048 /* SECONDARY - max length of the CHDLC data field */
-
-#define MIN_Tx_KPALV_TIMER 0 /* minimum transmit keepalive timer */
-#define MAX_Tx_KPALV_TIMER 60000 /* maximum transmit keepalive timer */
-#define DEFAULT_Tx_KPALV_TIMER 10000 /* default transmit keepalive timer */
-
-#define MIN_Rx_KPALV_TIMER 10 /* minimum receive keepalive timer */
-#define MAX_Rx_KPALV_TIMER 60000 /* maximum receive keepalive timer */
-#define DEFAULT_Rx_KPALV_TIMER 10000 /* default receive keepalive timer */
-
-#define MIN_KPALV_ERR_TOL 1 /* min kpalv error tolerance count */
-#define MAX_KPALV_ERR_TOL 20 /* max kpalv error tolerance count */
-#define DEFAULT_KPALV_ERR_TOL 3 /* default value */
-
-#define MIN_SLARP_REQ_TIMER 0 /* min transmit SLARP Request timer */
-#define MAX_SLARP_REQ_TIMER 60000 /* max transmit SLARP Request timer */
-#define DEFAULT_SLARP_REQ_TIMER 0 /* default value -- no SLARP */
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the READ_CHDLC_LINK_STATUS command
- * --------------------------------------------------------------------------*/
-
-/* the CHDLC status structure */
-typedef struct {
- unsigned char CHDLC_link_status PACKED; /* CHDLC link status */
- unsigned char no_Data_frms_for_app PACKED; /* number of Data frames available for the application */
- unsigned char receiver_status PACKED; /* enabled/disabled */
- unsigned char SLARP_state PACKED; /* internal SLARP state */
-} CHDLC_LINK_STATUS_STRUCT;
-
-/* settings for the 'CHDLC_link_status' variable */
-#define CHDLC_LINK_INACTIVE 0x00 /* the CHDLC link is inactive */
-#define CHDLC_LINK_ACTIVE 0x01 /* the CHDLC link is active */
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for the READ_CHDLC_OPERATIONAL_STATS command
- * --------------------------------------------------------------------------*/
-
-/* the CHDLC operational statistics structure */
-typedef struct {
-
- /* Data frame transmission statistics */
- unsigned long Data_frames_Tx_count PACKED; /* # of frames transmitted */
- unsigned long Data_bytes_Tx_count PACKED; /* # of bytes transmitted */
- unsigned long Data_Tx_throughput PACKED; /* transmit throughput */
- unsigned long no_ms_for_Data_Tx_thruput_comp PACKED; /* millisecond time used for the Tx throughput computation */
- unsigned long Tx_Data_discard_lgth_err_count PACKED; /* number of Data frames discarded (length error) */
- unsigned long reserved_Data_frm_Tx_stat1 PACKED; /* reserved for later */
- unsigned long reserved_Data_frm_Tx_stat2 PACKED; /* reserved for later */
- unsigned long reserved_Data_frm_Tx_stat3 PACKED; /* reserved for later */
-
- /* Data frame reception statistics */
- unsigned long Data_frames_Rx_count PACKED; /* number of frames received */
- unsigned long Data_bytes_Rx_count PACKED; /* number of bytes received */
- unsigned long Data_Rx_throughput PACKED; /* receive throughput */
- unsigned long no_ms_for_Data_Rx_thruput_comp PACKED; /* millisecond time used for the Rx throughput computation */
- unsigned long Rx_Data_discard_short_count PACKED; /* received Data frames discarded (too short) */
- unsigned long Rx_Data_discard_long_count PACKED; /* received Data frames discarded (too long) */
- unsigned long Rx_Data_discard_inactive_count PACKED; /* received Data frames discarded (link inactive) */
- unsigned long reserved_Data_frm_Rx_stat1 PACKED; /* reserved for later */
-
- /* SLARP frame transmission/reception statistics */
- unsigned long CHDLC_SLARP_REQ_Tx_count PACKED; /* number of SLARP Request frames transmitted */
- unsigned long CHDLC_SLARP_REQ_Rx_count PACKED; /* number of SLARP Request frames received */
- unsigned long CHDLC_SLARP_REPLY_Tx_count PACKED; /* number of SLARP Reply frames transmitted */
- unsigned long CHDLC_SLARP_REPLY_Rx_count PACKED; /* number of SLARP Reply frames received */
- unsigned long CHDLC_SLARP_KPALV_Tx_count PACKED; /* number of SLARP keepalive frames transmitted */
- unsigned long CHDLC_SLARP_KPALV_Rx_count PACKED; /* number of SLARP keepalive frames received */
- unsigned long reserved_SLARP_stat1 PACKED; /* reserved for later */
- unsigned long reserved_SLARP_stat2 PACKED; /* reserved for later */
-
- /* CDP frame transmission/reception statistics */
- unsigned long CHDLC_CDP_Tx_count PACKED; /* number of CDP frames transmitted */
- unsigned long CHDLC_CDP_Rx_count PACKED; /* number of CDP frames received */
- unsigned long reserved_CDP_stat1 PACKED; /* reserved for later */
- unsigned long reserved_CDP_stat2 PACKED; /* reserved for later */
- unsigned long reserved_CDP_stat3 PACKED; /* reserved for later */
- unsigned long reserved_CDP_stat4 PACKED; /* reserved for later */
- unsigned long reserved_CDP_stat5 PACKED; /* reserved for later */
- unsigned long reserved_CDP_stat6 PACKED; /* reserved for later */
-
- /* Incoming frames with a format error statistics */
- unsigned short Rx_frm_incomp_CHDLC_hdr_count PACKED; /* frames received of with incomplete Cisco HDLC header */
- unsigned short Rx_frms_too_long_count PACKED; /* frames received of excessive length count */
- unsigned short Rx_invalid_CHDLC_addr_count PACKED; /* frames received with an invalid CHDLC address count */
- unsigned short Rx_invalid_CHDLC_ctrl_count PACKED; /* frames received with an invalid CHDLC control field count */
- unsigned short Rx_invalid_CHDLC_type_count PACKED; /* frames received of an invalid CHDLC frame type count */
- unsigned short Rx_SLARP_invalid_code_count PACKED; /* SLARP frame received with an invalid packet code */
- unsigned short Rx_SLARP_Reply_bad_IP_addr PACKED; /* SLARP Reply received - bad IP address */
- unsigned short Rx_SLARP_Reply_bad_netmask PACKED; /* SLARP Reply received - bad netmask */
- unsigned long reserved_frm_format_err1 PACKED; /* reserved for later */
- unsigned long reserved_frm_format_err2 PACKED; /* reserved for later */
- unsigned long reserved_frm_format_err3 PACKED; /* reserved for later */
- unsigned long reserved_frm_format_err4 PACKED; /* reserved for later */
-
- /* CHDLC timeout/retry statistics */
- unsigned short SLARP_Rx_keepalive_TO_count PACKED; /* timeout count for incoming SLARP frames */
- unsigned short SLARP_Request_TO_count PACKED; /* timeout count for SLARP Request frames */
- unsigned long To_retry_reserved_stat1 PACKED; /* reserved for later */
- unsigned long To_retry_reserved_stat2 PACKED; /* reserved for later */
- unsigned long To_retry_reserved_stat3 PACKED; /* reserved for later */
-
- /* CHDLC link active/inactive and loopback statistics */
- unsigned short link_active_count PACKED; /* number of times that the link went active */
- unsigned short link_inactive_modem_count PACKED; /* number of times that the link went inactive (modem failure) */
- unsigned short link_inactive_keepalive_count PACKED; /* number of times that the link went inactive (keepalive failure) */
- unsigned short link_looped_count PACKED; /* link looped count */
- unsigned long link_status_reserved_stat1 PACKED; /* reserved for later use */
- unsigned long link_status_reserved_stat2 PACKED; /* reserved for later use */
-
- /* miscellaneous statistics */
- unsigned long reserved_misc_stat1 PACKED; /* reserved for later */
- unsigned long reserved_misc_stat2 PACKED; /* reserved for later */
- unsigned long reserved_misc_stat3 PACKED; /* reserved for later */
- unsigned long reserved_misc_stat4 PACKED; /* reserved for later */
-
-} CHDLC_OPERATIONAL_STATS_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for using application interrupts
- * --------------------------------------------------------------------------*/
-
-/* the structure used for the SET_CHDLC_INTERRUPT_TRIGGERS/READ_CHDLC_INTERRUPT_TRIGGERS command */
-typedef struct {
- unsigned char CHDLC_interrupt_triggers PACKED; /* CHDLC interrupt trigger configuration */
- unsigned char IRQ PACKED; /* IRQ to be used */
- unsigned short interrupt_timer PACKED; /* interrupt timer */
- unsigned short misc_interrupt_bits PACKED; /* miscellaneous bits */
-} CHDLC_INT_TRIGGERS_STRUCT;
-
-/* 'CHDLC_interrupt_triggers' bit settings */
-#define APP_INT_ON_RX_FRAME 0x01 /* interrupt on Data frame reception */
-#define APP_INT_ON_TX_FRAME 0x02 /* interrupt when an Data frame may be transmitted */
-#define APP_INT_ON_COMMAND_COMPLETE 0x04 /* interrupt when an interface command is complete */
-#define APP_INT_ON_TIMER 0x08 /* interrupt on a defined millisecond timeout */
-#define APP_INT_ON_GLOBAL_EXCEP_COND 0x10 /* interrupt on a global exception condition */
-#define APP_INT_ON_CHDLC_EXCEP_COND 0x20 /* interrupt on an CHDLC exception condition */
-#define APP_INT_ON_TRACE_DATA_AVAIL 0x80 /* interrupt when trace data is available */
-
-/* interrupt types indicated at 'interrupt_type' byte of the INTERRUPT_INFORMATION_STRUCT */
-#define NO_APP_INTS_PEND 0x00 /* no interrups are pending */
-#define RX_APP_INT_PEND 0x01 /* a receive interrupt is pending */
-#define TX_APP_INT_PEND 0x02 /* a transmit interrupt is pending */
-#define COMMAND_COMPLETE_APP_INT_PEND 0x04 /* a 'command complete' interrupt is pending */
-#define TIMER_APP_INT_PEND 0x08 /* a timer interrupt is pending */
-#define GLOBAL_EXCEP_COND_APP_INT_PEND 0x10 /* a global exception condition interrupt is pending */
-#define CHDLC_EXCEP_COND_APP_INT_PEND 0x20 /* an CHDLC exception condition interrupt is pending */
-#define TRACE_DATA_AVAIL_APP_INT_PEND 0x80 /* a trace data available interrupt is pending */
-
-
-/* modem status changes */
-#define DCD_HIGH 0x08
-#define CTS_HIGH 0x20
-
-
-/* ----------------------------------------------------------------------------
- * Constants for Data frame transmission
- * --------------------------------------------------------------------------*/
-
-/* the Data frame transmit status element configuration structure */
-typedef struct {
- unsigned short number_Tx_status_elements PACKED; /* number of transmit status elements */
- unsigned long base_addr_Tx_status_elements PACKED; /* base address of the transmit element list */
- unsigned long next_Tx_status_element_to_use PACKED; /* pointer to the next transmit element to be used */
-} CHDLC_TX_STATUS_EL_CFG_STRUCT;
-
-/* the Data frame transmit status element structure */
-typedef struct {
- unsigned char opp_flag PACKED; /* opp flag */
- unsigned short frame_length PACKED; /* length of the frame to be transmitted */
- unsigned char reserved_1 PACKED; /* reserved for internal use */
- unsigned long reserved_2 PACKED; /* reserved for internal use */
- unsigned long reserved_3 PACKED; /* reserved for internal use */
- unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
-} CHDLC_DATA_TX_STATUS_EL_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants for Data frame reception
- * --------------------------------------------------------------------------*/
-
-/* the Data frame receive status element configuration structure */
-typedef struct {
- unsigned short number_Rx_status_elements PACKED; /* number of receive status elements */
- unsigned long base_addr_Rx_status_elements PACKED; /* base address of the receive element list */
- unsigned long next_Rx_status_element_to_use PACKED; /* pointer to the next receive element to be used */
- unsigned long base_addr_Rx_buffer PACKED; /* base address of the receive data buffer */
- unsigned long end_addr_Rx_buffer PACKED; /* end address of the receive data buffer */
-} CHDLC_RX_STATUS_EL_CFG_STRUCT;
-
-/* the Data frame receive status element structure */
-typedef struct {
- unsigned char opp_flag PACKED; /* opp flag */
- unsigned short frame_length PACKED; /* length of the received frame */
- unsigned char error_flag PACKED; /* frame errors (HDLC_STREAMING_MODE)*/
- unsigned short time_stamp PACKED; /* receive time stamp (HDLC_STREAMING_MODE) */
- unsigned long reserved_1 PACKED; /* reserved for internal use */
- unsigned short reserved_2 PACKED; /* reserved for internal use */
- unsigned long ptr_data_bfr PACKED; /* pointer to the data area */
-} CHDLC_DATA_RX_STATUS_EL_STRUCT;
-
-
-
-/* ----------------------------------------------------------------------------
- * Constants defining the shared memory information area
- * --------------------------------------------------------------------------*/
-
-/* the global information structure */
-typedef struct {
- unsigned char global_status PACKED; /* global status */
- unsigned char modem_status PACKED; /* current modem status */
- unsigned char global_excep_conditions PACKED; /* global exception conditions */
- unsigned char glob_info_reserved[5] PACKED; /* reserved */
- unsigned char codename[4] PACKED; /* Firmware name */
- unsigned char codeversion[4] PACKED; /* Firmware version */
-} GLOBAL_INFORMATION_STRUCT;
-
-/* the CHDLC information structure */
-typedef struct {
- unsigned char CHDLC_status PACKED; /* CHDLC status */
- unsigned char CHDLC_excep_conditions PACKED; /* CHDLC exception conditions */
- unsigned char CHDLC_info_reserved[14] PACKED; /* reserved */
-} CHDLC_INFORMATION_STRUCT;
-
-/* the interrupt information structure */
-typedef struct {
- unsigned char interrupt_type PACKED; /* type of interrupt triggered */
- unsigned char interrupt_permission PACKED; /* interrupt permission mask */
- unsigned char int_info_reserved[14] PACKED; /* reserved */
-} INTERRUPT_INFORMATION_STRUCT;
-
-/* the S508/FT1 information structure */
-typedef struct {
- unsigned char parallel_port_A_input PACKED; /* input - parallel port A */
- unsigned char parallel_port_B_input PACKED; /* input - parallel port B */
- unsigned char FT1_info_reserved[14] PACKED; /* reserved */
-} FT1_INFORMATION_STRUCT;
-
-/* the shared memory area information structure */
-typedef struct {
- GLOBAL_INFORMATION_STRUCT global_info_struct PACKED; /* the global information structure */
- CHDLC_INFORMATION_STRUCT CHDLC_info_struct PACKED; /* the CHDLC information structure */
- INTERRUPT_INFORMATION_STRUCT interrupt_info_struct PACKED; /* the interrupt information structure */
- FT1_INFORMATION_STRUCT FT1_info_struct PACKED; /* the S508/FT1 information structure */
-} SHARED_MEMORY_INFO_STRUCT;
-
-/* ----------------------------------------------------------------------------
- * UDP Management constants and structures
- * --------------------------------------------------------------------------*/
-
-/* The embedded control block for UDP mgmt
- This is essentially a mailbox structure, without the large data field */
-
-typedef struct {
- unsigned char opp_flag PACKED; /* the opp flag */
- unsigned char command PACKED; /* the user command */
- unsigned short buffer_length PACKED; /* the data length */
- unsigned char return_code PACKED; /* the return code */
- unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED; /* reserved for later */
-} cblock_t;
-
-
-/* UDP management packet layout (data area of ip packet) */
-/*
-typedef struct {
- unsigned char signature[8] PACKED;
- unsigned char request_reply PACKED;
- unsigned char id PACKED;
- unsigned char reserved[6] PACKED;
- cblock_t cblock PACKED;
- unsigned char num_frames PACKED;
- unsigned char ismoredata PACKED;
- unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;
-} udp_management_packet_t;
-
-*/
-
-typedef struct {
- unsigned char num_frames PACKED;
- unsigned char ismoredata PACKED;
-} trace_info_t;
-
-typedef struct {
- ip_pkt_t ip_pkt PACKED;
- udp_pkt_t udp_pkt PACKED;
- wp_mgmt_t wp_mgmt PACKED;
- cblock_t cblock PACKED;
- trace_info_t trace_info PACKED;
- unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;
-} chdlc_udp_pkt_t;
-
-typedef struct ft1_exec_cmd{
- unsigned char command PACKED; /* the user command */
- unsigned short buffer_length PACKED; /* the data length */
- unsigned char return_code PACKED; /* the return code */
- unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED;
-} ft1_exec_cmd_t;
-
-typedef struct {
- unsigned char opp_flag PACKED;
- ft1_exec_cmd_t cmd PACKED;
- unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;
-} ft1_exec_t;
-
-#define UDPMGMT_SIGNATURE "CTPIPEAB"
-
-
-/* UDP/IP packet (for UDP management) layout */
-/*
-typedef struct {
- unsigned char reserved[2] PACKED;
- unsigned short ip_length PACKED;
- unsigned char reserved2[4] PACKED;
- unsigned char ip_ttl PACKED;
- unsigned char ip_protocol PACKED;
- unsigned short ip_checksum PACKED;
- unsigned long ip_src_address PACKED;
- unsigned long ip_dst_address PACKED;
- unsigned short udp_src_port PACKED;
- unsigned short udp_dst_port PACKED;
- unsigned short udp_length PACKED;
- unsigned short udp_checksum PACKED;
- udp_management_packet_t um_packet PACKED;
-} ip_packet_t;
-*/
-
-/* valid ip_protocol for UDP management */
-#define UDPMGMT_UDP_PROTOCOL 0x11
-
-
-typedef struct {
- unsigned char status PACKED;
- unsigned char data_avail PACKED;
- unsigned short real_length PACKED;
- unsigned short time_stamp PACKED;
- unsigned char data[1] PACKED;
-} trace_pkt_t;
-
-typedef struct {
- unsigned char error_flag PACKED;
- unsigned short time_stamp PACKED;
- unsigned char reserved[13] PACKED;
-} api_rx_hdr_t;
-
-typedef struct {
- api_rx_hdr_t api_rx_hdr PACKED;
- void * data PACKED;
-} api_rx_element_t;
-
-typedef struct {
- unsigned char attr PACKED;
- unsigned char reserved[15] PACKED;
-} api_tx_hdr_t;
-
-typedef struct {
- api_tx_hdr_t api_tx_hdr PACKED;
- void * data PACKED;
-} api_tx_element_t;
-
-/* ----------------------------------------------------------------------------
- * Constants for the SET_FT1_CONFIGURATION/READ_FT1_CONFIGURATION command
- * --------------------------------------------------------------------------*/
-
-/* the FT1 configuration structure */
-typedef struct {
- unsigned short framing_mode;
- unsigned short encoding_mode;
- unsigned short line_build_out;
- unsigned short channel_base;
- unsigned short baud_rate_kbps; /* the baud rate (in kbps) */
- unsigned short clock_mode;
-} ft1_config_t;
-
-/* settings for the 'framing_mode' */
-#define ESF_FRAMING 0x00 /* ESF framing */
-#define D4_FRAMING 0x01 /* D4 framing */
-
-/* settings for the 'encoding_mode' */
-#define B8ZS_ENCODING 0x00 /* B8ZS encoding */
-#define AMI_ENCODING 0x01 /* AMI encoding */
-
-/* settings for the 'line_build_out' */
-#define LN_BLD_CSU_0dB_DSX1_0_to_133 0x00 /* set build out to CSU (0db) or DSX-1 (0-133ft) */
-#define LN_BLD_DSX1_133_to_266 0x01 /* set build out DSX-1 (133-266ft) */
-#define LN_BLD_DSX1_266_to_399 0x02 /* set build out DSX-1 (266-399ft) */
-#define LN_BLD_DSX1_399_to_533 0x03 /* set build out DSX-1 (399-533ft) */
-#define LN_BLD_DSX1_533_to_655 0x04 /* set build out DSX-1 (533-655ft) */
-#define LN_BLD_CSU_NEG_7dB 0x05 /* set build out to CSU (-7.5db) */
-#define LN_BLD_CSU_NEG_15dB 0x06 /* set build out to CSU (-15db) */
-#define LN_BLD_CSU_NEG_22dB 0x07 /* set build out to CSU (-22.5db) */
-
-/* settings for the 'channel_base' */
-#define MIN_CHANNEL_BASE_VALUE 1 /* the minimum permitted channel base value */
-#define MAX_CHANNEL_BASE_VALUE 24 /* the maximum permitted channel base value */
-
-/* settings for the 'baud_rate_kbps' */
-#define MIN_BAUD_RATE_KBPS 0 /* the minimum permitted baud rate (kbps) */
-#define MAX_BAUD_RATE_KBPS 1536 /* the maximum permitted baud rate (kbps) */
-#define BAUD_RATE_FT1_AUTO_CONFIG 0xFFFF /* the baud rate used to trigger an automatic FT1 configuration */
-
-/* settings for the 'clock_mode' */
-#define CLOCK_MODE_NORMAL 0x00 /* clock mode set to normal (slave) */
-#define CLOCK_MODE_MASTER 0x01 /* clock mode set to master */
-
-
-#define BAUD_RATE_FT1_AUTO_CONFIG 0xFFFF
-#define AUTO_FT1_CONFIG_NOT_COMPLETE 0x08
-#define AUTO_FT1_CFG_FAIL_OP_MODE 0x0C
-#define AUTO_FT1_CFG_FAIL_INVALID_LINE 0x0D
-
-
-#ifdef _MSC_
-# pragma pack()
-#endif
-#endif /* _SDLA_CHDLC_H */
diff --git a/include/linux/sdla_ppp.h b/include/linux/sdla_ppp.h
deleted file mode 100644
index 6f3923179c29f..0000000000000
--- a/include/linux/sdla_ppp.h
+++ /dev/null
@@ -1,575 +0,0 @@
-/*****************************************************************************
-* sdla_ppp.h Sangoma PPP firmware API definitions.
-*
-* Author: Nenad Corbic <ncorbic@sangoma.com>
-*
-* Copyright: (c) 1995-1997 Sangoma Technologies 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.
-* ============================================================================
-* Feb 24, 2000 Nenad Corbic v2.1.2
-* Jan 06, 1997 Gene Kozin v2.0
-* Apr 11, 1996 Gene Kozin Initial version.
-*****************************************************************************/
-#ifndef _SDLA_PPP_H
-#define _SDLA_PPP_H
-
-/*----------------------------------------------------------------------------
- * Notes:
- * ------
- * 1. All structures defined in this file are byte-alined.
- *
- * Compiler Platform
- * -------- --------
- * GNU C Linux
- */
-
-#ifndef PACKED
-# define PACKED __attribute__((packed))
-#endif /* PACKED */
-
-/* Adapter memory layout and important constants */
-#define PPP508_MB_VECT 0xE000 /* mailbox window vector */
-#define PPP508_MB_OFFS 0 /* mailbox offset */
-#define PPP508_FLG_OFFS 0x1000 /* status flags offset */
-#define PPP508_BUF_OFFS 0x1100 /* buffer info block offset */
-#define PPP514_MB_OFFS 0xE000 /* mailbox offset */
-#define PPP514_FLG_OFFS 0xF000 /* status flags offset */
-#define PPP514_BUF_OFFS 0xF100 /* buffer info block offset */
-
-#define PPP_MAX_DATA 1008 /* command block data buffer length */
-
-/****** Data Structures *****************************************************/
-
-/*----------------------------------------------------------------------------
- * PPP Command Block.
- */
-typedef struct ppp_cmd{
- unsigned char command PACKED; /* command code */
- unsigned short length PACKED; /* length of data buffer */
- unsigned char result PACKED; /* return code */
- unsigned char rsrv[11] PACKED; /* reserved for future use */
-} ppp_cmd_t;
-
-typedef struct cblock{
- unsigned char opp_flag PACKED;
- unsigned char command PACKED; /* command code */
- unsigned short length PACKED; /* length of data buffer */
- unsigned char result PACKED; /* return code */
- unsigned char rsrv[11] PACKED; /* reserved for future use */
-} cblock_t;
-
-typedef struct ppp_udp_pkt{
- ip_pkt_t ip_pkt PACKED;
- udp_pkt_t udp_pkt PACKED;
- wp_mgmt_t wp_mgmt PACKED;
- cblock_t cblock PACKED;
- unsigned char data[MAX_LGTH_UDP_MGNT_PKT] PACKED;
-} ppp_udp_pkt_t;
-
-typedef struct {
- unsigned char status PACKED;
- unsigned char data_avail PACKED;
- unsigned short real_length PACKED;
- unsigned short time_stamp PACKED;
- unsigned char data[1] PACKED;
-} trace_pkt_t;
-
-
-typedef struct {
- unsigned char opp_flag PACKED;
- unsigned char trace_type PACKED;
- unsigned short trace_length PACKED;
- unsigned short trace_data_ptr PACKED;
- unsigned short trace_time_stamp PACKED;
-} trace_element_t;
-
-/* 'command' field defines */
-#define PPP_READ_CODE_VERSION 0x10 /* configuration commands */
-#define PPP_SET_CONFIG 0x05
-#define PPP_READ_CONFIG 0x06
-#define PPP_SET_INTR_FLAGS 0x20
-#define PPP_READ_INTR_FLAGS 0x21
-#define PPP_SET_INBOUND_AUTH 0x30
-#define PPP_SET_OUTBOUND_AUTH 0x31
-#define PPP_GET_CONNECTION_INFO 0x32
-
-#define PPP_COMM_ENABLE 0x03 /* operational commands */
-#define PPP_COMM_DISABLE 0x04
-#define PPP_SEND_SIGN_FRAME 0x23
-#define PPP_READ_SIGN_RESPONSE 0x24
-#define PPP_DATALINE_MONITOR 0x33
-
-#define PPP_READ_STATISTICS 0x07 /* statistics commands */
-#define PPP_FLUSH_STATISTICS 0x08
-#define PPP_READ_ERROR_STATS 0x09
-#define PPP_FLUSH_ERROR_STATS 0x0A
-#define PPP_READ_PACKET_STATS 0x12
-#define PPP_FLUSH_PACKET_STATS 0x13
-#define PPP_READ_LCP_STATS 0x14
-#define PPP_FLUSH_LCP_STATS 0x15
-#define PPP_READ_LPBK_STATS 0x16
-#define PPP_FLUSH_LPBK_STATS 0x17
-#define PPP_READ_IPCP_STATS 0x18
-#define PPP_FLUSH_IPCP_STATS 0x19
-#define PPP_READ_IPXCP_STATS 0x1A
-#define PPP_FLUSH_IPXCP_STATS 0x1B
-#define PPP_READ_PAP_STATS 0x1C
-#define PPP_FLUSH_PAP_STATS 0x1D
-#define PPP_READ_CHAP_STATS 0x1E
-#define PPP_FLUSH_CHAP_STATS 0x1F
-
-/* 'result' field defines */
-#define PPPRES_OK 0x00 /* command executed successfully */
-#define PPPRES_INVALID_STATE 0x09 /* invalid command in this context */
-
-/*----------------------------------------------------------------------------
- * PPP Mailbox.
- * This structure is located at offset PPP???_MB_OFFS into PPP???_MB_VECT
- */
-typedef struct ppp_mbox
-{
- unsigned char flag PACKED; /* 00h: command execution flag */
- ppp_cmd_t cmd PACKED; /* 01h: command block */
- unsigned char data[1] PACKED; /* 10h: variable length data buffer */
-} ppp_mbox_t;
-
-/*----------------------------------------------------------------------------
- * PPP Status Flags.
- * This structure is located at offset PPP???_FLG_OFFS into
- * PPP???_MB_VECT.
- */
-typedef struct ppp_flags
-{
- unsigned char iflag PACKED; /* 00: interrupt flag */
- unsigned char imask PACKED; /* 01: interrupt mask */
- unsigned char resrv PACKED;
- unsigned char mstatus PACKED; /* 03: modem status */
- unsigned char lcp_state PACKED; /* 04: LCP state */
- unsigned char ppp_phase PACKED; /* 05: PPP phase */
- unsigned char ip_state PACKED; /* 06: IPCP state */
- unsigned char ipx_state PACKED; /* 07: IPXCP state */
- unsigned char pap_state PACKED; /* 08: PAP state */
- unsigned char chap_state PACKED; /* 09: CHAP state */
- unsigned short disc_cause PACKED; /* 0A: disconnection cause */
-} ppp_flags_t;
-
-/* 'iflag' defines */
-#define PPP_INTR_RXRDY 0x01 /* Rx ready */
-#define PPP_INTR_TXRDY 0x02 /* Tx ready */
-#define PPP_INTR_MODEM 0x04 /* modem status change (DCD, CTS) */
-#define PPP_INTR_CMD 0x08 /* interface command completed */
-#define PPP_INTR_DISC 0x10 /* data link disconnected */
-#define PPP_INTR_OPEN 0x20 /* data link open */
-#define PPP_INTR_DROP_DTR 0x40 /* DTR drop timeout expired */
-#define PPP_INTR_TIMER 0x80 /* timer interrupt */
-
-
-/* 'mstatus' defines */
-#define PPP_MDM_DCD 0x08 /* mdm_status: DCD */
-#define PPP_MDM_CTS 0x20 /* mdm_status: CTS */
-
-/* 'disc_cause' defines */
-#define PPP_LOCAL_TERMINATION 0x0001 /* Local Request by PPP termination phase */
-#define PPP_DCD_CTS_DROP 0x0002 /* DCD and/or CTS dropped. Link down */
-#define PPP_REMOTE_TERMINATION 0x0800 /* Remote Request by PPP termination phase */
-
-/* 'misc_config_bits' defines */
-#define DONT_RE_TX_ABORTED_I_FRAMES 0x01
-#define TX_FRM_BYTE_COUNT_STATS 0x02
-#define RX_FRM_BYTE_COUNT_STATS 0x04
-#define TIME_STAMP_IN_RX_FRAMES 0x08
-#define NON_STD_ADPTR_FREQ 0x10
-#define INTERFACE_LEVEL_RS232 0x20
-#define AUTO_LINK_RECOVERY 0x100
-#define DONT_TERMINATE_LNK_MAX_CONFIG 0x200
-
-/* 'authentication options' defines */
-#define NO_AUTHENTICATION 0x00
-#define INBOUND_AUTH 0x80
-#define PAP_AUTH 0x01
-#define CHAP_AUTH 0x02
-
-/* 'ip options' defines */
-#define L_AND_R_IP_NO_ASSIG 0x00
-#define L_IP_LOCAL_ASSIG 0x01
-#define L_IP_REMOTE_ASSIG 0x02
-#define R_IP_LOCAL_ASSIG 0x04
-#define R_IP_REMOTE_ASSIG 0x08
-#define ENABLE_IP 0x80
-
-/* 'ipx options' defines */
-#define ROUTING_PROT_DEFAULT 0x20
-#define ENABLE_IPX 0x80
-#define DISABLE_IPX 0x00
-
-/*----------------------------------------------------------------------------
- * PPP Buffer Info.
- * This structure is located at offset PPP508_BUF_OFFS into
- * PPP508_MB_VECT.
- */
-typedef struct ppp508_buf_info
-{
- unsigned short txb_num PACKED; /* 00: number of transmit buffers */
- unsigned long txb_ptr PACKED; /* 02: pointer to the buffer ctl. */
- unsigned long txb_nxt PACKED;
- unsigned char rsrv1[22] PACKED;
- unsigned short rxb_num PACKED; /* 20: number of receive buffers */
- unsigned long rxb_ptr PACKED; /* 22: pointer to the buffer ctl. */
- unsigned long rxb1_ptr PACKED; /* 26: pointer to the first buf.ctl. */
- unsigned long rxb_base PACKED; /* 2A: pointer to the buffer base */
- unsigned char rsrv2[2] PACKED;
- unsigned long rxb_end PACKED; /* 30: pointer to the buffer end */
-} ppp508_buf_info_t;
-
-/*----------------------------------------------------------------------------
- * Transmit/Receive Buffer Control Block.
- */
-typedef struct ppp_buf_ctl
-{
- unsigned char flag PACKED; /* 00: 'buffer ready' flag */
- unsigned short length PACKED; /* 01: length of data */
- unsigned char reserved1[1] PACKED; /* 03: */
- unsigned char proto PACKED; /* 04: protocol */
- unsigned short timestamp PACKED; /* 05: time stamp (Rx only) */
- unsigned char reserved2[5] PACKED; /* 07: */
- union
- {
- unsigned short o_p[2]; /* 1C: buffer offset & page (S502) */
- unsigned long ptr; /* 1C: buffer pointer (S508) */
- } buf PACKED;
-} ppp_buf_ctl_t;
-
-/*----------------------------------------------------------------------------
- * S508 Adapter Configuration Block (passed to the PPP_SET_CONFIG command).
- */
-typedef struct ppp508_conf
-{
- unsigned long line_speed PACKED; /* 00: baud rate, bps */
- unsigned short txbuf_percent PACKED; /* 04: % of Tx buffer */
- unsigned short conf_flags PACKED; /* 06: configuration bits */
- unsigned short mtu_local PACKED; /* 08: local MTU */
- unsigned short mtu_remote PACKED; /* 0A: remote MTU */
- unsigned short restart_tmr PACKED; /* 0C: restart timer */
- unsigned short auth_rsrt_tmr PACKED; /* 0E: authentication timer */
- unsigned short auth_wait_tmr PACKED; /* 10: authentication timer */
- unsigned short mdm_fail_tmr PACKED; /* 12: modem failure timer */
- unsigned short dtr_drop_tmr PACKED; /* 14: DTR drop timer */
- unsigned short connect_tmout PACKED; /* 16: connection timeout */
- unsigned short conf_retry PACKED; /* 18: max. retry */
- unsigned short term_retry PACKED; /* 1A: max. retry */
- unsigned short fail_retry PACKED; /* 1C: max. retry */
- unsigned short auth_retry PACKED; /* 1E: max. retry */
- unsigned char auth_options PACKED; /* 20: authentication opt. */
- unsigned char ip_options PACKED; /* 21: IP options */
- unsigned long ip_local PACKED; /* 22: local IP address */
- unsigned long ip_remote PACKED; /* 26: remote IP address */
- unsigned char ipx_options PACKED; /* 2A: IPX options */
- unsigned char ipx_netno[4] PACKED; /* 2B: IPX net number */
- unsigned char ipx_local[6] PACKED; /* 2F: local IPX node number*/
- unsigned char ipx_remote[6] PACKED; /* 35: remote IPX node num.*/
- unsigned char ipx_router[48] PACKED; /* 3B: IPX router name*/
- unsigned long alt_cpu_clock PACKED; /* 6B: */
-} ppp508_conf_t;
-
-/*----------------------------------------------------------------------------
- * S508 Adapter Read Connection Information Block
- * Returned by the PPP_GET_CONNECTION_INFO command
- */
-typedef struct ppp508_connect_info
-{
- unsigned short mru PACKED; /* 00-01 Remote Max Rec' Unit */
- unsigned char ip_options PACKED; /* 02: Negotiated ip options */
- unsigned long ip_local PACKED; /* 03-06: local IP address */
- unsigned long ip_remote PACKED; /* 07-0A: remote IP address */
- unsigned char ipx_options PACKED; /* 0B: Negotiated ipx options */
- unsigned char ipx_netno[4] PACKED; /* 0C-0F: IPX net number */
- unsigned char ipx_local[6] PACKED; /* 10-1F: local IPX node # */
- unsigned char ipx_remote[6] PACKED; /* 16-1B: remote IPX node # */
- unsigned char ipx_router[48] PACKED; /* 1C-4B: IPX router name */
- unsigned char auth_status PACKED; /* 4C: Authentication Status */
- unsigned char inbd_auth_peerID[1] PACKED; /* 4D: variable length inbound authenticated peer ID */
-} ppp508_connect_info_t;
-
-/* 'line_speed' field */
-#define PPP_BITRATE_1200 0x01
-#define PPP_BITRATE_2400 0x02
-#define PPP_BITRATE_4800 0x03
-#define PPP_BITRATE_9600 0x04
-#define PPP_BITRATE_19200 0x05
-#define PPP_BITRATE_38400 0x06
-#define PPP_BITRATE_45000 0x07
-#define PPP_BITRATE_56000 0x08
-#define PPP_BITRATE_64000 0x09
-#define PPP_BITRATE_74000 0x0A
-#define PPP_BITRATE_112000 0x0B
-#define PPP_BITRATE_128000 0x0C
-#define PPP_BITRATE_156000 0x0D
-
-/* Defines for the 'conf_flags' field */
-#define PPP_IGNORE_TX_ABORT 0x01 /* don't re-transmit aborted frames */
-#define PPP_ENABLE_TX_STATS 0x02 /* enable Tx statistics */
-#define PPP_ENABLE_RX_STATS 0x04 /* enable Rx statistics */
-#define PPP_ENABLE_TIMESTAMP 0x08 /* enable timestamp */
-
-/* 'ip_options' defines */
-#define PPP_LOCAL_IP_LOCAL 0x01
-#define PPP_LOCAL_IP_REMOTE 0x02
-#define PPP_REMOTE_IP_LOCAL 0x04
-#define PPP_REMOTE_IP_REMOTE 0x08
-
-/* 'ipx_options' defines */
-#define PPP_REMOTE_IPX_NETNO 0x01
-#define PPP_REMOTE_IPX_LOCAL 0x02
-#define PPP_REMOTE_IPX_REMOTE 0x04
-#define PPP_IPX_ROUTE_RIP_SAP 0x08
-#define PPP_IPX_ROUTE_NLSP 0x10
-#define PPP_IPX_ROUTE_DEFAULT 0x20
-#define PPP_IPX_CONF_COMPLETE 0x40
-#define PPP_IPX_ENABLE 0x80
-
-/*----------------------------------------------------------------------------
- * S508 Adapter Configuration Block (returned by the PPP_READ_CONFIG command).
- */
-typedef struct ppp508_get_conf
-{
- unsigned long bps PACKED; /* 00: baud rate, bps */
- ppp508_conf_t conf PACKED; /* 04: requested config. */
- unsigned short txb_num PACKED; /* 6F: number of Tx buffers */
- unsigned short rxb_num PACKED; /* 71: number of Rx buffers */
-} ppp508_get_conf_t;
-
-/*----------------------------------------------------------------------------
- * S508 Operational Statistics (returned by the PPP_READ_STATISTIC command).
- */
-typedef struct ppp508_stats
-{
- unsigned short reserved1 PACKED; /* 00: */
- unsigned short rx_bad_len PACKED; /* 02: */
- unsigned short reserved2 PACKED; /* 04: */
- unsigned long tx_frames PACKED; /* 06: */
- unsigned long tx_bytes PACKED; /* 0A: */
- unsigned long rx_frames PACKED; /* 0E: */
- unsigned long rx_bytes PACKED; /* 12: */
-} ppp508_stats_t;
-
-/*----------------------------------------------------------------------------
- * Adapter Error Statistics (returned by the PPP_READ_ERROR_STATS command).
- */
-typedef struct ppp_err_stats
-{
- unsigned char rx_overrun PACKED; /* 00: Rx overrun errors */
- unsigned char rx_bad_crc PACKED; /* 01: Rx CRC errors */
- unsigned char rx_abort PACKED; /* 02: Rx aborted frames */
- unsigned char rx_lost PACKED; /* 03: Rx frames lost */
- unsigned char tx_abort PACKED; /* 04: Tx aborted frames */
- unsigned char tx_underrun PACKED; /* 05: Tx underrun errors */
- unsigned char tx_missed_intr PACKED; /* 06: Tx underruns missed */
- unsigned char reserved PACKED; /* 07: Tx underruns missed */
- unsigned char dcd_trans PACKED; /* 08: DCD transitions */
- unsigned char cts_trans PACKED; /* 09: CTS transitions */
-} ppp_err_stats_t;
-
-/*----------------------------------------------------------------------------
- * Packet Statistics (returned by the PPP_READ_PACKET_STATS command).
- */
-typedef struct ppp_pkt_stats
-{
- unsigned short rx_bad_header PACKED; /* 00: */
- unsigned short rx_prot_unknwn PACKED; /* 02: */
- unsigned short rx_too_large PACKED; /* 04: */
- unsigned short rx_lcp PACKED; /* 06: */
- unsigned short tx_lcp PACKED; /* 08: */
- unsigned short rx_ipcp PACKED; /* 0A: */
- unsigned short tx_ipcp PACKED; /* 0C: */
- unsigned short rx_ipxcp PACKED; /* 0E: */
- unsigned short tx_ipxcp PACKED; /* 10: */
- unsigned short rx_pap PACKED; /* 12: */
- unsigned short tx_pap PACKED; /* 14: */
- unsigned short rx_chap PACKED; /* 16: */
- unsigned short tx_chap PACKED; /* 18: */
- unsigned short rx_lqr PACKED; /* 1A: */
- unsigned short tx_lqr PACKED; /* 1C: */
- unsigned short rx_ip PACKED; /* 1E: */
- unsigned short tx_ip PACKED; /* 20: */
- unsigned short rx_ipx PACKED; /* 22: */
- unsigned short tx_ipx PACKED; /* 24: */
-} ppp_pkt_stats_t;
-
-/*----------------------------------------------------------------------------
- * LCP Statistics (returned by the PPP_READ_LCP_STATS command).
- */
-typedef struct ppp_lcp_stats
-{
- unsigned short rx_unknown PACKED; /* 00: unknown LCP type */
- unsigned short rx_conf_rqst PACKED; /* 02: Configure-Request */
- unsigned short rx_conf_ack PACKED; /* 04: Configure-Ack */
- unsigned short rx_conf_nak PACKED; /* 06: Configure-Nak */
- unsigned short rx_conf_rej PACKED; /* 08: Configure-Reject */
- unsigned short rx_term_rqst PACKED; /* 0A: Terminate-Request */
- unsigned short rx_term_ack PACKED; /* 0C: Terminate-Ack */
- unsigned short rx_code_rej PACKED; /* 0E: Code-Reject */
- unsigned short rx_proto_rej PACKED; /* 10: Protocol-Reject */
- unsigned short rx_echo_rqst PACKED; /* 12: Echo-Request */
- unsigned short rx_echo_reply PACKED; /* 14: Echo-Reply */
- unsigned short rx_disc_rqst PACKED; /* 16: Discard-Request */
- unsigned short tx_conf_rqst PACKED; /* 18: Configure-Request */
- unsigned short tx_conf_ack PACKED; /* 1A: Configure-Ack */
- unsigned short tx_conf_nak PACKED; /* 1C: Configure-Nak */
- unsigned short tx_conf_rej PACKED; /* 1E: Configure-Reject */
- unsigned short tx_term_rqst PACKED; /* 20: Terminate-Request */
- unsigned short tx_term_ack PACKED; /* 22: Terminate-Ack */
- unsigned short tx_code_rej PACKED; /* 24: Code-Reject */
- unsigned short tx_proto_rej PACKED; /* 26: Protocol-Reject */
- unsigned short tx_echo_rqst PACKED; /* 28: Echo-Request */
- unsigned short tx_echo_reply PACKED; /* 2A: Echo-Reply */
- unsigned short tx_disc_rqst PACKED; /* 2E: Discard-Request */
- unsigned short rx_too_large PACKED; /* 30: packets too large */
- unsigned short rx_ack_inval PACKED; /* 32: invalid Conf-Ack */
- unsigned short rx_rej_inval PACKED; /* 34: invalid Conf-Reject */
- unsigned short rx_rej_badid PACKED; /* 36: Conf-Reject w/bad ID */
-} ppp_lcp_stats_t;
-
-/*----------------------------------------------------------------------------
- * Loopback Error Statistics (returned by the PPP_READ_LPBK_STATS command).
- */
-typedef struct ppp_lpbk_stats
-{
- unsigned short conf_magic PACKED; /* 00: */
- unsigned short loc_echo_rqst PACKED; /* 02: */
- unsigned short rem_echo_rqst PACKED; /* 04: */
- unsigned short loc_echo_reply PACKED; /* 06: */
- unsigned short rem_echo_reply PACKED; /* 08: */
- unsigned short loc_disc_rqst PACKED; /* 0A: */
- unsigned short rem_disc_rqst PACKED; /* 0C: */
- unsigned short echo_tx_collsn PACKED; /* 0E: */
- unsigned short echo_rx_collsn PACKED; /* 10: */
-} ppp_lpbk_stats_t;
-
-/*----------------------------------------------------------------------------
- * Protocol Statistics (returned by the PPP_READ_IPCP_STATS and
- * PPP_READ_IPXCP_STATS commands).
- */
-typedef struct ppp_prot_stats
-{
- unsigned short rx_unknown PACKED; /* 00: unknown type */
- unsigned short rx_conf_rqst PACKED; /* 02: Configure-Request */
- unsigned short rx_conf_ack PACKED; /* 04: Configure-Ack */
- unsigned short rx_conf_nak PACKED; /* 06: Configure-Nak */
- unsigned short rx_conf_rej PACKED; /* 08: Configure-Reject */
- unsigned short rx_term_rqst PACKED; /* 0A: Terminate-Request */
- unsigned short rx_term_ack PACKED; /* 0C: Terminate-Ack */
- unsigned short rx_code_rej PACKED; /* 0E: Code-Reject */
- unsigned short reserved PACKED; /* 10: */
- unsigned short tx_conf_rqst PACKED; /* 12: Configure-Request */
- unsigned short tx_conf_ack PACKED; /* 14: Configure-Ack */
- unsigned short tx_conf_nak PACKED; /* 16: Configure-Nak */
- unsigned short tx_conf_rej PACKED; /* 18: Configure-Reject */
- unsigned short tx_term_rqst PACKED; /* 1A: Terminate-Request */
- unsigned short tx_term_ack PACKED; /* 1C: Terminate-Ack */
- unsigned short tx_code_rej PACKED; /* 1E: Code-Reject */
- unsigned short rx_too_large PACKED; /* 20: packets too large */
- unsigned short rx_ack_inval PACKED; /* 22: invalid Conf-Ack */
- unsigned short rx_rej_inval PACKED; /* 24: invalid Conf-Reject */
- unsigned short rx_rej_badid PACKED; /* 26: Conf-Reject w/bad ID */
-} ppp_prot_stats_t;
-
-/*----------------------------------------------------------------------------
- * PAP Statistics (returned by the PPP_READ_PAP_STATS command).
- */
-typedef struct ppp_pap_stats
-{
- unsigned short rx_unknown PACKED; /* 00: unknown type */
- unsigned short rx_auth_rqst PACKED; /* 02: Authenticate-Request */
- unsigned short rx_auth_ack PACKED; /* 04: Authenticate-Ack */
- unsigned short rx_auth_nak PACKED; /* 06: Authenticate-Nak */
- unsigned short reserved PACKED; /* 08: */
- unsigned short tx_auth_rqst PACKED; /* 0A: Authenticate-Request */
- unsigned short tx_auth_ack PACKED; /* 0C: Authenticate-Ack */
- unsigned short tx_auth_nak PACKED; /* 0E: Authenticate-Nak */
- unsigned short rx_too_large PACKED; /* 10: packets too large */
- unsigned short rx_bad_peerid PACKED; /* 12: invalid peer ID */
- unsigned short rx_bad_passwd PACKED; /* 14: invalid password */
-} ppp_pap_stats_t;
-
-/*----------------------------------------------------------------------------
- * CHAP Statistics (returned by the PPP_READ_CHAP_STATS command).
- */
-typedef struct ppp_chap_stats
-{
- unsigned short rx_unknown PACKED; /* 00: unknown type */
- unsigned short rx_challenge PACKED; /* 02: Authenticate-Request */
- unsigned short rx_response PACKED; /* 04: Authenticate-Ack */
- unsigned short rx_success PACKED; /* 06: Authenticate-Nak */
- unsigned short rx_failure PACKED; /* 08: Authenticate-Nak */
- unsigned short reserved PACKED; /* 0A: */
- unsigned short tx_challenge PACKED; /* 0C: Authenticate-Request */
- unsigned short tx_response PACKED; /* 0E: Authenticate-Ack */
- unsigned short tx_success PACKED; /* 10: Authenticate-Nak */
- unsigned short tx_failure PACKED; /* 12: Authenticate-Nak */
- unsigned short rx_too_large PACKED; /* 14: packets too large */
- unsigned short rx_bad_peerid PACKED; /* 16: invalid peer ID */
- unsigned short rx_bad_passwd PACKED; /* 18: invalid password */
- unsigned short rx_bad_md5 PACKED; /* 1A: invalid MD5 format */
- unsigned short rx_bad_resp PACKED; /* 1C: invalid response */
-} ppp_chap_stats_t;
-
-/*----------------------------------------------------------------------------
- * Connection Information (returned by the PPP_GET_CONNECTION_INFO command).
- */
-typedef struct ppp_conn_info
-{
- unsigned short remote_mru PACKED; /* 00: */
- unsigned char ip_options PACKED; /* 02: */
- unsigned char ip_local[4] PACKED; /* 03: */
- unsigned char ip_remote[4] PACKED; /* 07: */
- unsigned char ipx_options PACKED; /* 0B: */
- unsigned char ipx_network[4] PACKED; /* 0C: */
- unsigned char ipx_local[6] PACKED; /* 10: */
- unsigned char ipx_remote[6] PACKED; /* 16: */
- unsigned char ipx_router[48] PACKED; /* 1C: */
- unsigned char auth_status PACKED; /* 4C: */
- unsigned char peer_id[0] PACKED; /* 4D: */
-} ppp_conn_info_t;
-
-/* Data structure for SET_TRIGGER_INTR command
- */
-
-typedef struct ppp_intr_info{
- unsigned char i_enable PACKED; /* 0 Interrupt enable bits */
- unsigned char irq PACKED; /* 1 Irq number */
- unsigned short timer_len PACKED; /* 2 Timer delay */
-} ppp_intr_info_t;
-
-
-#define FT1_MONITOR_STATUS_CTRL 0x80
-#define SET_FT1_MODE 0x81
-
-
-
-/* Special UDP drivers management commands */
-#define PPIPE_ENABLE_TRACING 0x20
-#define PPIPE_DISABLE_TRACING 0x21
-#define PPIPE_GET_TRACE_INFO 0x22
-#define PPIPE_GET_IBA_DATA 0x23
-#define PPIPE_KILL_BOARD 0x24
-#define PPIPE_FT1_READ_STATUS 0x25
-#define PPIPE_DRIVER_STAT_IFSEND 0x26
-#define PPIPE_DRIVER_STAT_INTR 0x27
-#define PPIPE_DRIVER_STAT_GEN 0x28
-#define PPIPE_FLUSH_DRIVER_STATS 0x29
-#define PPIPE_ROUTER_UP_TIME 0x30
-
-#define DISABLE_TRACING 0x00
-#define TRACE_SIGNALLING_FRAMES 0x01
-#define TRACE_DATA_FRAMES 0x02
-
-
-
-#ifdef _MSC_
-# pragma pack()
-#endif
-#endif /* _SDLA_PPP_H */
diff --git a/include/linux/sdla_x25.h b/include/linux/sdla_x25.h
deleted file mode 100644
index 57db980e27ad8..0000000000000
--- a/include/linux/sdla_x25.h
+++ /dev/null
@@ -1,772 +0,0 @@
-/*****************************************************************************
-* sdla_x25.h Sangoma X.25 firmware API definitions.
-*
-* Author: Nenad Corbic <ncorbic@sangoma.com>
-*
-* Copyright: (c) 1995-2000 Sangoma Technologies 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.
-* ============================================================================
-* Feb 28, 2000 Nenad Corbic Updated for socket based x25api
-* Dec 13, 1996 Gene Kozin Initial version
-*****************************************************************************/
-#ifndef _SDLA_X25_H
-#define _SDLA_X25_H
-
-/*----------------------------------------------------------------------------
- * Notes:
- * ------
- * 1. All structures defined in this file are byte-alined.
- * Compiler Platform
- * -------- --------
- * GNU C Linux
- *
- */
-
-#ifndef PACKED
-# define PACKED __attribute__((packed))
-#endif /* PACKED */
-
-/****** CONSTANTS DEFINITIONS ***********************************************/
-
-#define X25_MAX_CHAN 255 /* max number of open X.25 circuits */
-#define X25_MAX_DATA 1024 /* max length of X.25 data buffer */
-/*
- * X.25 shared memory layout.
- */
-#define X25_MBOX_OFFS 0x16B0 /* general mailbox block */
-#define X25_RXMBOX_OFFS 0x1AD0 /* receive mailbox */
-#define X25_STATUS_OFFS 0x1EF0 /* X.25 status structure */
-#define X25_MB_VECTOR 0xE000 /* S514 mailbox window vecotr */
-#define X25_MISC_HDLC_BITS 0x1F00 /*X.25 miscallaneous HDLC bits */
-
-/* code levels */
-#define HDLC_LEVEL 0x01
-#define X25_LEVEL 0x02
-#define X25_AND_HDLC_LEVEL 0x03
-#define DO_HDLC_LEVEL_ERROR_CHECKING 0x04
-
-/****** DATA STRUCTURES *****************************************************/
-
-/*----------------------------------------------------------------------------
- * X.25 Command Block.
- */
-typedef struct X25Cmd
-{
- unsigned char command PACKED; /* command code */
- unsigned short length PACKED; /* transfer data length */
- unsigned char result PACKED; /* return code */
- unsigned char pf PACKED; /* P/F bit */
- unsigned short lcn PACKED; /* logical channel */
- unsigned char qdm PACKED; /* Q/D/M bits */
- unsigned char cause PACKED; /* cause field */
- unsigned char diagn PACKED; /* diagnostics */
- unsigned char pktType PACKED; /* packet type */
- unsigned char resrv[4] PACKED; /* reserved */
-} TX25Cmd;
-
-/*
- * Defines for the 'command' field.
- */
-/*----- General commands --------------*/
-#define X25_SET_GLOBAL_VARS 0x0B /* set global variables */
-#define X25_READ_MODEM_STATUS 0x0C /* read modem status */
-#define X25_READ_CODE_VERSION 0x15 /* read firmware version number */
-#define X25_TRACE_CONFIGURE 0x14 /* configure trace facility */
-#define X25_READ_TRACE_DATA 0x16 /* read trace data */
-#define X25_SET_INTERRUPT_MODE 0x17 /* set interrupt generation mode */
-#define X25_READ_INTERRUPT_MODE 0x18 /* read interrupt generation mode */
-/*----- HDLC-level commands -----------*/
-#define X25_HDLC_LINK_CONFIGURE 0x01 /* configure HDLC link level */
-#define X25_HDLC_LINK_OPEN 0x02 /* open HDLC link */
-#define X25_HDLC_LINK_CLOSE 0x03 /* close HDLC link */
-#define X25_HDLC_LINK_SETUP 0x04 /* set up HDLC link */
-#define X25_HDLC_LINK_DISC 0x05 /* disconnect DHLC link */
-#define X25_HDLC_LINK_STATUS 0x06 /* read DHLC link status */
-#define X25_HDLC_READ_STATS 0x07 /* read operational statistics */
-#define X25_HDLC_FLUSH_STATS 0x08 /* flush operational statistics */
-#define X25_HDLC_READ_COMM_ERR 0x09 /* read error statistics */
-#define X25_HDLC_FLUSH_COMM_ERR 0x0A /* flush error statistics */
-#define X25_HDLC_FLUSH_BUFFERS 0x0D /* flush HDLC-level data buffers */
-#define X25_HDLC_SPRVS_CNT_STAT 0x0F /* read surervisory count status */
-#define X25_HDLC_SEND_UI_FRAME 0x10 /* send unnumbered information frame */
-#define X25_HDLC_WRITE 0x11 /* send HDLC information frame */
-#define X25_HDLC_READ 0x21 /* read HDLC information frame */
-#define X25_HDLC_READ_CONFIG 0x12 /* read HDLC configuration */
-#define X25_HDLC_SET_CONFIG 0x13 /* set HDLC configuration */
-#define SET_PROTOCOL_LEVEL 0x1F /* set protocol level */
-/*----- X.25-level commands -----------*/
-#define X25_READ 0x22 /* read X.25 packet */
-#define X25_WRITE 0x23 /* send X.25 packet */
-#define X25_PLACE_CALL 0x30 /* place a call on SVC */
-#define X25_ACCEPT_CALL 0x31 /* accept incomming call */
-#define X25_CLEAR_CALL 0x32 /* clear call */
-#define X25_CLEAR_CONFRM 0x33 /* send clear confirmation packet */
-#define X25_RESET 0x34 /* send reset request packet */
-#define X25_RESET_CONFRM 0x35 /* send reset confirmation packet */
-#define X25_RESTART 0x36 /* send restart request packet */
-#define X25_RESTART_CONFRM 0x37 /* send restart confirmation packet */
-#define X25_INTERRUPT 0x38 /* send interrupt request packet */
-#define X25_INTERRUPT_CONFRM 0x39 /* send interrupt confirmation pkt */
-#define X25_REGISTRATION_RQST 0x3A /* send registration request packet */
-#define X25_REGISTRATION_CONFRM 0x3B /* send registration confirmation */
-#define X25_IS_DATA_AVAILABLE 0x40 /* querry receive queue */
-#define X25_INCOMMING_CALL_CTL 0x41 /* select incomming call options */
-#define X25_CONFIGURE_PVC 0x42 /* configure PVC */
-#define X25_GET_ACTIVE_CHANNELS 0x43 /* get a list of active circuits */
-#define X25_READ_CHANNEL_CONFIG 0x44 /* read virt. circuit configuration */
-#define X25_FLUSH_DATA_BUFFERS 0x45 /* flush X.25-level data buffers */
-#define X25_READ_HISTORY_TABLE 0x46 /* read asynchronous event log */
-#define X25_HISTORY_TABLE_CTL 0x47 /* control asynchronous event log */
-#define X25_GET_TX_D_BIT_STATUS 0x48 /* is packet with D-bit acknowleged */
-#define X25_READ_STATISTICS 0x49 /* read X.25-level statistics */
-#define X25_FLUSH_STATISTICS 0x4A /* flush X.25-level statistics */
-#define X25_READ_CONFIGURATION 0x50 /* read HDLC & X.25 configuration */
-#define X25_SET_CONFIGURATION 0x51 /* set HDLC & X.25 configuration */
-
-/*
- * Defines for the 'result' field.
- */
-/*----- General results ---------------*/
-#define X25RES_OK 0x00
-#define X25RES_ERROR 0x01
-#define X25RES_LINK_NOT_IN_ABM 0x02 /* link is not in ABM mode */
-#define X25RES_LINK_CLOSED 0x03
-#define X25RES_INVAL_LENGTH 0x04
-#define X25RES_INVAL_CMD 0x05
-#define X25RES_UNNUMBERED_FRAME 0x06 /* unnunbered frame received */
-#define X25RES_FRM_REJECT_MODE 0x07 /* link is in Frame Reject mode */
-#define X25RES_MODEM_FAILURE 0x08 /* DCD and/or CTS dropped */
-#define X25RES_N2_RETRY_LIMIT 0x09 /* N2 retry limit has been exceeded */
-#define X25RES_INVAL_LCN 0x30 /* invalid logical channel number */
-#define X25RES_INVAL_STATE 0x31 /* channel is not in data xfer mode */
-#define X25RES_INVAL_DATA_LEN 0x32 /* invalid data length */
-#define X25RES_NOT_READY 0x33 /* no data available / buffers full */
-#define X25RES_NETWORK_DOWN 0x34
-#define X25RES_CHANNEL_IN_USE 0x35 /* there is data queued on this LCN */
-#define X25RES_REGST_NOT_SUPPRT 0x36 /* registration not supported */
-#define X25RES_INVAL_FORMAT 0x37 /* invalid packet format */
-#define X25RES_D_BIT_NOT_SUPPRT 0x38 /* D-bit pragmatics not supported */
-#define X25RES_FACIL_NOT_SUPPRT 0x39 /* Call facility not supported */
-#define X25RES_INVAL_CALL_ARG 0x3A /* errorneous call arguments */
-#define X25RES_INVAL_CALL_DATA 0x3B /* errorneous call user data */
-#define X25RES_ASYNC_PACKET 0x40 /* asynchronous packet received */
-#define X25RES_PROTO_VIOLATION 0x41 /* protocol violation occurred */
-#define X25RES_PKT_TIMEOUT 0x42 /* X.25 packet time out */
-#define X25RES_PKT_RETRY_LIMIT 0x43 /* X.25 packet retry limit exceeded */
-/*----- Command-dependent results -----*/
-#define X25RES_LINK_DISC 0x00 /* HDLC_LINK_STATUS */
-#define X25RES_LINK_IN_ABM 0x01 /* HDLC_LINK_STATUS */
-#define X25RES_NO_DATA 0x01 /* HDLC_READ/READ_TRACE_DATA*/
-#define X25RES_TRACE_INACTIVE 0x02 /* READ_TRACE_DATA */
-#define X25RES_LINK_IS_OPEN 0x01 /* HDLC_LINK_OPEN */
-#define X25RES_LINK_IS_DISC 0x02 /* HDLC_LINK_DISC */
-#define X25RES_LINK_IS_CLOSED 0x03 /* HDLC_LINK_CLOSE */
-#define X25RES_INVAL_PARAM 0x31 /* INCOMMING_CALL_CTL */
-#define X25RES_INVAL_CONFIG 0x35 /* REGISTR_RQST/CONFRM */
-
-/*
- * Defines for the 'qdm_bits' field.
- */
-#define X25CMD_Q_BIT_MASK 0x04
-#define X25CMD_D_BIT_MASK 0x02
-#define X25CMD_M_BIT_MASK 0x01
-
-/*
- * Defines for the 'pkt_type' field.
- */
-/*----- Asynchronous events ------*/
-#define ASE_CLEAR_RQST 0x02
-#define ASE_RESET_RQST 0x04
-#define ASE_RESTART_RQST 0x08
-#define ASE_INTERRUPT 0x10
-#define ASE_DTE_REGISTR_RQST 0x20
-#define ASE_CALL_RQST 0x30
-#define ASE_CALL_ACCEPTED 0x31
-#define ASE_CLEAR_CONFRM 0x32
-#define ASE_RESET_CONFRM 0x33
-#define ASE_RESTART_CONFRM 0x34
-#define ASE_INTERRUPT_CONFRM 0x35
-#define ASE_DCE_REGISTR_CONFRM 0x36
-#define ASE_DIAGNOSTIC 0x37
-#define ASE_CALL_AUTO_CLEAR 0x38
-#define AUTO_RESPONSE_FLAG 0x80
-/*----- Time-Out events ----------*/
-#define TOE_RESTART_RQST 0x03
-#define TOE_CALL_RQST 0x05
-#define TOE_CLEAR_RQST 0x08
-#define TOE_RESET_RQST 0x0A
-/*----- Protocol Violation events */
-#define PVE_CLEAR_RQST 0x32
-#define PVE_RESET_RQST 0x33
-#define PVE_RESTART_RQST 0x34
-#define PVE_DIAGNOSTIC 0x37
-
-#define INTR_ON_RX_FRAME 0x01
-#define INTR_ON_TX_FRAME 0x02
-#define INTR_ON_MODEM_STATUS_CHANGE 0x04
-#define INTR_ON_COMMAND_COMPLETE 0x08
-#define INTR_ON_X25_ASY_TRANSACTION 0x10
-#define INTR_ON_TIMER 0x40
-#define DIRECT_RX_INTR_USAGE 0x80
-
-#define NO_INTR_PENDING 0x00
-#define RX_INTR_PENDING 0x01
-#define TX_INTR_PENDING 0x02
-#define MODEM_INTR_PENDING 0x04
-#define COMMAND_COMPLETE_INTR_PENDING 0x08
-#define X25_ASY_TRANS_INTR_PENDING 0x10
-#define TIMER_INTR_PENDING 0x40
-
-/*----------------------------------------------------------------------------
- * X.25 Mailbox.
- * This structure is located at offsets X25_MBOX_OFFS and X25_RXMBOX_OFFS
- * into shared memory window.
- */
-typedef struct X25Mbox
-{
- unsigned char opflag PACKED; /* 00h: execution flag */
- TX25Cmd cmd PACKED; /* 01h: command block */
- unsigned char data[1] PACKED; /* 10h: data buffer */
-} TX25Mbox;
-
-/*----------------------------------------------------------------------------
- * X.25 Time Stamp Structure.
- */
-typedef struct X25TimeStamp
-{
- unsigned char month PACKED;
- unsigned char date PACKED;
- unsigned char sec PACKED;
- unsigned char min PACKED;
- unsigned char hour PACKED;
-} TX25TimeStamp;
-
-/*----------------------------------------------------------------------------
- * X.25 Status Block.
- * This structure is located at offset X25_STATUS_OFF into shared memory
- * window.
- */
-typedef struct X25Status
-{
- unsigned short pvc_map PACKED; /* 00h: PVC map */
- unsigned short icc_map PACKED; /* 02h: Incomming Chan. map */
- unsigned short twc_map PACKED; /* 04h: Two-way Cnan. map */
- unsigned short ogc_map PACKED; /* 06h: Outgoing Chan. map */
- TX25TimeStamp tstamp PACKED; /* 08h: timestamp (BCD) */
- unsigned char iflags PACKED; /* 0Dh: interrupt flags */
- unsigned char imask PACKED; /* 0Eh: interrupt mask */
- unsigned char resrv PACKED; /* 0Eh: */
- unsigned char gflags PACKED; /* 10h: misc. HDLC/X25 flags */
- unsigned char cflags[X25_MAX_CHAN] PACKED; /* channel status bytes */
-} TX25Status;
-
-/*
- * Bitmasks for the 'iflags' field.
- */
-#define X25_RX_INTR 0x01 /* receive interrupt */
-#define X25_TX_INTR 0x02 /* transmit interrupt */
-#define X25_MODEM_INTR 0x04 /* modem status interrupt (CTS/DCD) */
-#define X25_EVENT_INTR 0x10 /* asyncronous event encountered */
-#define X25_CMD_INTR 0x08 /* interface command complete */
-
-/*
- * Bitmasks for the 'gflags' field.
- */
-#define X25_HDLC_ABM 0x01 /* HDLC is in ABM mode */
-#define X25_RX_READY 0x02 /* X.25 data available */
-#define X25_TRACE_READY 0x08 /* trace data available */
-#define X25_EVENT_IND 0x20 /* asynchronous event indicator */
-#define X25_TX_READY 0x40 /* space is available in Tx buf.*/
-
-/*
- * Bitmasks for the 'cflags' field.
- */
-#define X25_XFER_MODE 0x80 /* channel is in data transfer mode */
-#define X25_TXWIN_OPEN 0x40 /* transmit window open */
-#define X25_RXBUF_MASK 0x3F /* number of data buffers available */
-
-/*****************************************************************************
- * Following definitions structurize contents of the TX25Mbox.data field for
- * different X.25 interface commands.
- ****************************************************************************/
-
-/* ---------------------------------------------------------------------------
- * X25_SET_GLOBAL_VARS Command.
- */
-typedef struct X25GlobalVars
-{
- unsigned char resrv PACKED; /* 00h: reserved */
- unsigned char dtrCtl PACKED; /* 01h: DTR control code */
- unsigned char resErr PACKED; /* 01h: '1' - reset modem error */
-} TX25GlobalVars;
-
-/*
- * Defines for the 'dtrCtl' field.
- */
-#define X25_RAISE_DTR 0x01
-#define X25_DROP_DTR 0x02
-
-/* ---------------------------------------------------------------------------
- * X25_READ_MODEM_STATUS Command.
- */
-typedef struct X25ModemStatus
-{
- unsigned char status PACKED; /* 00h: modem status */
-} TX25ModemStatus;
-
-/*
- * Defines for the 'status' field.
- */
-#define X25_CTS_MASK 0x20
-#define X25_DCD_MASK 0x08
-
-/* ---------------------------------------------------------------------------
- * X25_HDLC_LINK_STATUS Command.
- */
-typedef struct X25LinkStatus
-{
- unsigned char txQueued PACKED; /* 00h: queued Tx I-frames*/
- unsigned char rxQueued PACKED; /* 01h: queued Rx I-frames*/
- unsigned char station PACKED; /* 02h: DTE/DCE config. */
- unsigned char reserved PACKED; /* 03h: reserved */
- unsigned char sfTally PACKED; /* 04h: supervisory frame tally */
-} TX25LinkStatus;
-
-/*
- * Defines for the 'station' field.
- */
-#define X25_STATION_DTE 0x01 /* station configured as DTE */
-#define X25_STATION_DCE 0x02 /* station configured as DCE */
-
-/* ---------------------------------------------------------------------------
- * X25_HDLC_READ_STATS Command.
- */
-typedef struct HdlcStats
-{ /* a number of ... */
- unsigned short rxIFrames PACKED; /* 00h: ready Rx I-frames */
- unsigned short rxNoseq PACKED; /* 02h: frms out-of-sequence */
- unsigned short rxNodata PACKED; /* 04h: I-frms without data */
- unsigned short rxDiscarded PACKED; /* 06h: discarded frames */
- unsigned short rxTooLong PACKED; /* 08h: frames too long */
- unsigned short rxBadAddr PACKED; /* 0Ah: frms with inval.addr*/
- unsigned short txAcked PACKED; /* 0Ch: acknowledged I-frms */
- unsigned short txRetransm PACKED; /* 0Eh: re-transmit. I-frms */
- unsigned short t1Timeout PACKED; /* 10h: T1 timeouts */
- unsigned short rxSABM PACKED; /* 12h: received SABM frames */
- unsigned short rxDISC PACKED; /* 14h: received DISC frames */
- unsigned short rxDM PACKED; /* 16h: received DM frames */
- unsigned short rxFRMR PACKED; /* 18h: FRMR frames received */
- unsigned short txSABM PACKED; /* 1Ah: transm. SABM frames*/
- unsigned short txDISC PACKED; /* 1Ch: transm. DISC frames*/
- unsigned short txDM PACKED; /* 1Eh: transm. DM frames */
- unsigned short txFRMR PACKED; /* 20h: transm. FRMR frames*/
-} THdlcStats;
-
-/* ---------------------------------------------------------------------------
- * X25_HDLC_READ_COMM_ERR Command.
- */
-typedef struct HdlcCommErr
-{ /* a number of ... */
- unsigned char rxOverrun PACKED; /* 00h: Rx overrun errors */
- unsigned char rxBadCrc PACKED; /* 01h: Rx CRC errors */
- unsigned char rxAborted PACKED; /* 02h: Rx aborted frames */
- unsigned char rxDropped PACKED; /* 03h: frames lost */
- unsigned char txAborted PACKED; /* 04h: Tx aborted frames */
- unsigned char txUnderrun PACKED; /* 05h: Tx underrun errors */
- unsigned char txMissIntr PACKED; /* 06h: missed underrun ints */
- unsigned char reserved PACKED; /* 07h: reserved */
- unsigned char droppedDCD PACKED; /* 08h: times DCD dropped */
- unsigned char droppedCTS PACKED; /* 09h: times CTS dropped */
-} THdlcCommErr;
-
-/* ---------------------------------------------------------------------------
- * X25_SET_CONFIGURATION & X25_READ_CONFIGURATION Commands.
- */
-typedef struct X25Config
-{
-unsigned char baudRate PACKED; /* 00h: */
- unsigned char t1 PACKED; /* 01h: */
- unsigned char t2 PACKED; /* 02h: */
- unsigned char n2 PACKED; /* 03h: */
- unsigned short hdlcMTU PACKED; /* 04h: */
- unsigned char hdlcWindow PACKED; /* 06h: */
- unsigned char t4 PACKED; /* 07h: */
- unsigned char autoModem PACKED; /* 08h: */
- unsigned char autoHdlc PACKED; /* 09h: */
- unsigned char hdlcOptions PACKED; /* 0Ah: */
- unsigned char station PACKED; /* 0Bh: */
- unsigned char pktWindow PACKED; /* 0Ch: */
- unsigned short defPktSize PACKED; /* 0Dh: */
- unsigned short pktMTU PACKED; /* 0Fh: */
- unsigned short loPVC PACKED; /* 11h: */
- unsigned short hiPVC PACKED; /* 13h: */
- unsigned short loIncommingSVC PACKED; /* 15h: */
- unsigned short hiIncommingSVC PACKED; /* 17h: */
- unsigned short loTwoWaySVC PACKED; /* 19h: */
- unsigned short hiTwoWaySVC PACKED; /* 1Bh: */
- unsigned short loOutgoingSVC PACKED; /* 1Dh: */
- unsigned short hiOutgoingSVC PACKED; /* 1Fh: */
- unsigned short options PACKED; /* 21h: */
- unsigned char responseOpt PACKED; /* 23h: */
- unsigned short facil1 PACKED; /* 24h: */
- unsigned short facil2 PACKED; /* 26h: */
- unsigned short ccittFacil PACKED; /* 28h: */
- unsigned short otherFacil PACKED; /* 2Ah: */
- unsigned short ccittCompat PACKED; /* 2Ch: */
- unsigned char t10t20 PACKED; /* 2Eh: */
- unsigned char t11t21 PACKED; /* 2Fh: */
- unsigned char t12t22 PACKED; /* 30h: */
- unsigned char t13t23 PACKED; /* 31h: */
- unsigned char t16t26 PACKED; /* 32H: */
- unsigned char t28 PACKED; /* 33h: */
- unsigned char r10r20 PACKED; /* 34h: */
- unsigned char r12r22 PACKED; /* 35h: */
- unsigned char r13r23 PACKED; /* 36h: */
-} TX25Config;
-
-/* ---------------------------------------------------------------------------
- * X25_READ_CHANNEL_CONFIG Command.
- */
-typedef struct X25ChanAlloc /*----- Channel allocation -*/
-{
- unsigned short loPVC PACKED; /* 00h: lowest PVC number */
- unsigned short hiPVC PACKED; /* 02h: highest PVC number */
- unsigned short loIncommingSVC PACKED; /* 04h: lowest incoming SVC */
- unsigned short hiIncommingSVC PACKED; /* 06h: highest incoming SVC */
- unsigned short loTwoWaySVC PACKED; /* 08h: lowest two-way SVC */
- unsigned short hiTwoWaySVC PACKED; /* 0Ah: highest two-way SVC */
- unsigned short loOutgoingSVC PACKED; /* 0Ch: lowest outgoing SVC */
- unsigned short hiOutgoingSVC PACKED; /* 0Eh: highest outgoing SVC */
-} TX25ChanAlloc;
-
-typedef struct X25ChanCfg /*------ Channel configuration -----*/
-{
- unsigned char type PACKED; /* 00h: channel type */
- unsigned char txConf PACKED; /* 01h: Tx packet and window sizes */
- unsigned char rxConf PACKED; /* 01h: Rx packet and window sizes */
-} TX25ChanCfg;
-
-/*
- * Defines for the 'type' field.
- */
-#define X25_PVC 0x01 /* PVC */
-#define X25_SVC_IN 0x03 /* Incoming SVC */
-#define X25_SVC_TWOWAY 0x07 /* Two-way SVC */
-#define X25_SVC_OUT 0x0B /* Outgoing SVC */
-
-/*----------------------------------------------------------------------------
- * X25_READ_STATISTICS Command.
- */
-typedef struct X25Stats
-{ /* number of packets Tx/Rx'ed */
- unsigned short txRestartRqst PACKED; /* 00h: Restart Request */
- unsigned short rxRestartRqst PACKED; /* 02h: Restart Request */
- unsigned short txRestartConf PACKED; /* 04h: Restart Confirmation */
- unsigned short rxRestartConf PACKED; /* 06h: Restart Confirmation */
- unsigned short txResetRqst PACKED; /* 08h: Reset Request */
- unsigned short rxResetRqst PACKED; /* 0Ah: Reset Request */
- unsigned short txResetConf PACKED; /* 0Ch: Reset Confirmation */
- unsigned short rxResetConf PACKED; /* 0Eh: Reset Confirmation */
- unsigned short txCallRequest PACKED; /* 10h: Call Request */
- unsigned short rxCallRequest PACKED; /* 12h: Call Request */
- unsigned short txCallAccept PACKED; /* 14h: Call Accept */
- unsigned short rxCallAccept PACKED; /* 16h: Call Accept */
- unsigned short txClearRqst PACKED; /* 18h: Clear Request */
- unsigned short rxClearRqst PACKED; /* 1Ah: Clear Request */
- unsigned short txClearConf PACKED; /* 1Ch: Clear Confirmation */
- unsigned short rxClearConf PACKED; /* 1Eh: Clear Confirmation */
- unsigned short txDiagnostic PACKED; /* 20h: Diagnostic */
- unsigned short rxDiagnostic PACKED; /* 22h: Diagnostic */
- unsigned short txRegRqst PACKED; /* 24h: Registration Request */
- unsigned short rxRegRqst PACKED; /* 26h: Registration Request */
- unsigned short txRegConf PACKED; /* 28h: Registration Confirm.*/
- unsigned short rxRegConf PACKED; /* 2Ah: Registration Confirm.*/
- unsigned short txInterrupt PACKED; /* 2Ch: Interrupt */
- unsigned short rxInterrupt PACKED; /* 2Eh: Interrupt */
- unsigned short txIntrConf PACKED; /* 30h: Interrupt Confirm. */
- unsigned short rxIntrConf PACKED; /* 32h: Interrupt Confirm. */
- unsigned short txData PACKED; /* 34h: Data */
- unsigned short rxData PACKED; /* 36h: Data */
- unsigned short txRR PACKED; /* 38h: RR */
- unsigned short rxRR PACKED; /* 3Ah: RR */
- unsigned short txRNR PACKED; /* 3Ch: RNR */
- unsigned short rxRNR PACKED; /* 3Eh: RNR */
-} TX25Stats;
-
-/*----------------------------------------------------------------------------
- * X25_READ_HISTORY_TABLE Command.
- */
-typedef struct X25EventLog
-{
- unsigned char type PACKED; /* 00h: transaction type */
- unsigned short lcn PACKED; /* 01h: logical channel num */
- unsigned char packet PACKED; /* 03h: async packet type */
- unsigned char cause PACKED; /* 04h: X.25 cause field */
- unsigned char diag PACKED; /* 05h: X.25 diag field */
- TX25TimeStamp ts PACKED; /* 06h: time stamp */
-} TX25EventLog;
-
-/*
- * Defines for the 'type' field.
- */
-#define X25LOG_INCOMMING 0x00
-#define X25LOG_APPLICATION 0x01
-#define X25LOG_AUTOMATIC 0x02
-#define X25LOG_ERROR 0x04
-#define X25LOG_TIMEOUT 0x08
-#define X25LOG_RECOVERY 0x10
-
-/*
- * Defines for the 'packet' field.
- */
-#define X25LOG_CALL_RQST 0x0B
-#define X25LOG_CALL_ACCEPTED 0x0F
-#define X25LOG_CLEAR_RQST 0x13
-#define X25LOG_CLEAR_CONFRM 0x17
-#define X25LOG_RESET_RQST 0x1B
-#define X25LOG_RESET_CONFRM 0x1F
-#define X25LOG_RESTART_RQST 0xFB
-#define X25LOG_RESTART_COMFRM 0xFF
-#define X25LOG_DIAGNOSTIC 0xF1
-#define X25LOG_DTE_REG_RQST 0xF3
-#define X25LOG_DTE_REG_COMFRM 0xF7
-
-/* ---------------------------------------------------------------------------
- * X25_TRACE_CONFIGURE Command.
- */
-typedef struct X25TraceCfg
-{
- unsigned char flags PACKED; /* 00h: trace configuration flags */
- unsigned char timeout PACKED; /* 01h: timeout for trace delay mode*/
-} TX25TraceCfg;
-
-/*
- * Defines for the 'flags' field.
- */
-#define X25_TRC_ENABLE 0x01 /* bit0: '1' - trace enabled */
-#define X25_TRC_TIMESTAMP 0x02 /* bit1: '1' - time stamping enabled*/
-#define X25_TRC_DELAY 0x04 /* bit2: '1' - trace delay enabled */
-#define X25_TRC_DATA 0x08 /* bit3: '1' - trace data packets */
-#define X25_TRC_SUPERVISORY 0x10 /* bit4: '1' - trace suprvisory pkts*/
-#define X25_TRC_ASYNCHRONOUS 0x20 /* bit5: '1' - trace asynch. packets*/
-#define X25_TRC_HDLC 0x40 /* bit6: '1' - trace all packets */
-#define X25_TRC_READ 0x80 /* bit7: '1' - get current config. */
-
-/* ---------------------------------------------------------------------------
- * X25_READ_TRACE_DATA Command.
- */
-typedef struct X25Trace /*----- Trace data structure -------*/
-{
- unsigned short length PACKED; /* 00h: trace data length */
- unsigned char type PACKED; /* 02h: trace type */
- unsigned char lost_cnt PACKED; /* 03h: N of traces lost */
- TX25TimeStamp tstamp PACKED; /* 04h: mon/date/sec/min/hour */
- unsigned short millisec PACKED; /* 09h: ms time stamp */
- unsigned char data[0] PACKED; /* 0Bh: traced frame */
-} TX25Trace;
-
-/*
- * Defines for the 'type' field.
- */
-#define X25_TRC_TYPE_MASK 0x0F /* bits 0..3: trace type */
-#define X25_TRC_TYPE_RX_FRAME 0x00 /* received frame trace */
-#define X25_TRC_TYPE_TX_FRAME 0x01 /* transmitted frame */
-#define X25_TRC_TYPE_ERR_FRAME 0x02 /* error frame */
-
-#define X25_TRC_ERROR_MASK 0xF0 /* bits 4..7: error code */
-#define X25_TRCERR_RX_ABORT 0x10 /* receive abort error */
-#define X25_TRCERR_RX_BADCRC 0x20 /* receive CRC error */
-#define X25_TRCERR_RX_OVERRUN 0x30 /* receiver overrun error */
-#define X25_TRCERR_RX_TOO_LONG 0x40 /* excessive frame length error */
-#define X25_TRCERR_TX_ABORT 0x70 /* aborted frame transmittion error */
-#define X25_TRCERR_TX_UNDERRUN 0x80 /* transmit underrun error */
-
-/*****************************************************************************
- * Following definitions describe HDLC frame and X.25 packet formats.
- ****************************************************************************/
-
-typedef struct HDLCFrame /*----- DHLC Frame Format ----------*/
-{
- unsigned char addr PACKED; /* address field */
- unsigned char cntl PACKED; /* control field */
- unsigned char data[0] PACKED;
-} THDLCFrame;
-
-typedef struct X25Pkt /*----- X.25 Paket Format ----------*/
-{
- unsigned char lcn_hi PACKED; /* 4 MSB of Logical Channel Number */
- unsigned char lcn_lo PACKED; /* 8 LSB of Logical Channel Number */
- unsigned char type PACKED;
- unsigned char data[0] PACKED;
-} TX25Pkt;
-
-/*
- * Defines for the 'lcn_hi' field.
- */
-#define X25_Q_BIT_MASK 0x80 /* Data Qualifier Bit mask */
-#define X25_D_BIT_MASK 0x40 /* Delivery Confirmation Bit mask */
-#define X25_M_BITS_MASK 0x30 /* Modulo Bits mask */
-#define X25_LCN_MSB_MASK 0x0F /* LCN most significant bits mask */
-
-/*
- * Defines for the 'type' field.
- */
-#define X25PKT_DATA 0x01 /* Data packet mask */
-#define X25PKT_SUPERVISORY 0x02 /* Supervisory packet mask */
-#define X25PKT_CALL_RQST 0x0B /* Call Request/Incoming */
-#define X25PKT_CALL_ACCEPTED 0x0F /* Call Accepted/Connected */
-#define X25PKT_CLEAR_RQST 0x13 /* Clear Request/Indication */
-#define X25PKT_CLEAR_CONFRM 0x17 /* Clear Confirmation */
-#define X25PKT_RESET_RQST 0x1B /* Reset Request/Indication */
-#define X25PKT_RESET_CONFRM 0x1F /* Reset Confirmation */
-#define X25PKT_RESTART_RQST 0xFB /* Restart Request/Indication */
-#define X25PKT_RESTART_CONFRM 0xFF /* Restart Confirmation */
-#define X25PKT_INTERRUPT 0x23 /* Interrupt */
-#define X25PKT_INTERRUPT_CONFRM 0x27 /* Interrupt Confirmation */
-#define X25PKT_DIAGNOSTIC 0xF1 /* Diagnostic */
-#define X25PKT_REGISTR_RQST 0xF3 /* Registration Request */
-#define X25PKT_REGISTR_CONFRM 0xF7 /* Registration Confirmation */
-#define X25PKT_RR_MASKED 0x01 /* Receive Ready packet after masking */
-#define X25PKT_RNR_MASKED 0x05 /* Receive Not Ready after masking */
-
-
-typedef struct {
- TX25Cmd cmd PACKED;
- char data[X25_MAX_DATA] PACKED;
-} mbox_cmd_t;
-
-
-typedef struct {
- unsigned char qdm PACKED; /* Q/D/M bits */
- unsigned char cause PACKED; /* cause field */
- unsigned char diagn PACKED; /* diagnostics */
- unsigned char pktType PACKED;
- unsigned short length PACKED;
- unsigned char result PACKED;
- unsigned short lcn PACKED;
- char reserved[7] PACKED;
-}x25api_hdr_t;
-
-
-typedef struct {
- x25api_hdr_t hdr PACKED;
- char data[X25_MAX_DATA] PACKED;
-}x25api_t;
-
-
-/*
- * XPIPEMON Definitions
- */
-
-/* valid ip_protocol for UDP management */
-#define UDPMGMT_UDP_PROTOCOL 0x11
-#define UDPMGMT_XPIPE_SIGNATURE "XLINK8ND"
-#define UDPMGMT_DRVRSTATS_SIGNATURE "DRVSTATS"
-
-/* values for request/reply byte */
-#define UDPMGMT_REQUEST 0x01
-#define UDPMGMT_REPLY 0x02
-#define UDP_OFFSET 12
-
-
-typedef struct {
- unsigned char opp_flag PACKED; /* the opp flag */
- unsigned char command PACKED; /* command code */
- unsigned short length PACKED; /* transfer data length */
- unsigned char result PACKED; /* return code */
- unsigned char pf PACKED; /* P/F bit */
- unsigned short lcn PACKED; /* logical channel */
- unsigned char qdm PACKED; /* Q/D/M bits */
- unsigned char cause PACKED; /* cause field */
- unsigned char diagn PACKED; /* diagnostics */
- unsigned char pktType PACKED; /* packet type */
- unsigned char resrv[4] PACKED; /* reserved */
-} cblock_t;
-
-typedef struct {
- ip_pkt_t ip_pkt PACKED;
- udp_pkt_t udp_pkt PACKED;
- wp_mgmt_t wp_mgmt PACKED;
- cblock_t cblock PACKED;
- unsigned char data[4080] PACKED;
-} x25_udp_pkt_t;
-
-
-typedef struct read_hdlc_stat {
- unsigned short inf_frames_rx_ok PACKED;
- unsigned short inf_frames_rx_out_of_seq PACKED;
- unsigned short inf_frames_rx_no_data PACKED;
- unsigned short inf_frames_rx_dropped PACKED;
- unsigned short inf_frames_rx_data_too_long PACKED;
- unsigned short inf_frames_rx_invalid_addr PACKED;
- unsigned short inf_frames_tx_ok PACKED;
- unsigned short inf_frames_tx_retransmit PACKED;
- unsigned short T1_timeouts PACKED;
- unsigned short SABM_frames_rx PACKED;
- unsigned short DISC_frames_rx PACKED;
- unsigned short DM_frames_rx PACKED;
- unsigned short FRMR_frames_rx PACKED;
- unsigned short SABM_frames_tx PACKED;
- unsigned short DISC_frames_tx PACKED;
- unsigned short DM_frames_tx PACKED;
- unsigned short FRMR_frames_tx PACKED;
-} read_hdlc_stat_t;
-
-typedef struct read_comms_err_stats{
- unsigned char overrun_err_rx PACKED;
- unsigned char CRC_err PACKED;
- unsigned char abort_frames_rx PACKED;
- unsigned char frames_dropped_buf_full PACKED;
- unsigned char abort_frames_tx PACKED;
- unsigned char transmit_underruns PACKED;
- unsigned char missed_tx_underruns_intr PACKED;
- unsigned char reserved PACKED;
- unsigned char DCD_drop PACKED;
- unsigned char CTS_drop PACKED;
-} read_comms_err_stats_t;
-
-typedef struct trace_data {
- unsigned short length PACKED;
- unsigned char type PACKED;
- unsigned char trace_dropped PACKED;
- unsigned char reserved[5] PACKED;
- unsigned short timestamp PACKED;
- unsigned char data PACKED;
-} trace_data_t;
-
-enum {UDP_XPIPE_TYPE};
-
-#define XPIPE_ENABLE_TRACING 0x14
-#define XPIPE_DISABLE_TRACING 0x14
-#define XPIPE_GET_TRACE_INFO 0x16
-#define XPIPE_FT1_READ_STATUS 0x74
-#define XPIPE_DRIVER_STAT_IFSEND 0x75
-#define XPIPE_DRIVER_STAT_INTR 0x76
-#define XPIPE_DRIVER_STAT_GEN 0x77
-#define XPIPE_FLUSH_DRIVER_STATS 0x78
-#define XPIPE_ROUTER_UP_TIME 0x79
-#define XPIPE_SET_FT1_MODE 0x81
-#define XPIPE_FT1_STATUS_CTRL 0x80
-
-
-/* error messages */
-#define NO_BUFFS_OR_CLOSED_WIN 0x33
-#define DATA_LENGTH_TOO_BIG 0x32
-#define NO_DATA_AVAILABLE 0x33
-#define Z80_TIMEOUT_ERROR 0x0a
-#define NO_BUFFS 0x08
-
-
-/* Trace options */
-#define TRACE_DEFAULT 0x03
-#define TRACE_SUPERVISOR_FRMS 0x10
-#define TRACE_ASYNC_FRMS 0x20
-#define TRACE_ALL_HDLC_FRMS 0x40
-#define TRACE_DATA_FRMS 0x08
-
-
-#endif /* _SDLA_X25_H */
diff --git a/include/linux/sdladrv.h b/include/linux/sdladrv.h
deleted file mode 100644
index c85e103d5e7b6..0000000000000
--- a/include/linux/sdladrv.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*****************************************************************************
-* sdladrv.h SDLA Support Module. Kernel API Definitions.
-*
-* Author: Gideon Hack
-*
-* Copyright: (c) 1995-2000 Sangoma Technologies 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.
-* ============================================================================
-* Jun 02, 1999 Gideon Hack Added support for the S514 PCI adapter.
-* Dec 11, 1996 Gene Kozin Complete overhaul.
-* Oct 17, 1996 Gene Kozin Minor bug fixes.
-* Jun 12, 1996 Gene Kozin Added support for S503 card.
-* Dec 06, 1995 Gene Kozin Initial version.
-*****************************************************************************/
-#ifndef _SDLADRV_H
-#define _SDLADRV_H
-
-
-#define SDLA_MAXIORANGE 4 /* maximum I/O port range */
-#define SDLA_WINDOWSIZE 0x2000 /* default dual-port memory window size */
-/****** Data Structures *****************************************************/
-
-/*----------------------------------------------------------------------------
- * Adapter hardware configuration. Pointer to this structure is passed to all
- * APIs.
- */
-typedef struct sdlahw
-{
- unsigned type; /* adapter type */
- unsigned fwid; /* firmware ID */
- unsigned port; /* adapter I/O port base */
- int irq; /* interrupt request level */
- char S514_cpu_no[1]; /* PCI CPU Number */
- unsigned char S514_slot_no; /* PCI Slot Number */
- char auto_pci_cfg; /* Autodetect PCI Slot */
- struct pci_dev *pci_dev; /* PCI device */
- void * dpmbase; /* dual-port memory base */
- unsigned dpmsize; /* dual-port memory size */
- unsigned pclk; /* CPU clock rate, kHz */
- unsigned long memory; /* memory size */
- unsigned long vector; /* local offset of the DPM window */
- unsigned io_range; /* I/O port range */
- unsigned char regs[SDLA_MAXIORANGE]; /* was written to registers */
- unsigned reserved[5];
-} sdlahw_t;
-
-/****** Function Prototypes *************************************************/
-
-extern int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len);
-extern int sdla_down (sdlahw_t* hw);
-extern void S514_intack (sdlahw_t* hw, u32 int_status);
-extern void read_S514_int_stat (sdlahw_t* hw, u32* int_status);
-extern int sdla_mapmem (sdlahw_t* hw, unsigned long addr);
-extern int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf,
- unsigned len);
-extern int sdla_poke (sdlahw_t* hw, unsigned long addr, void* buf,
- unsigned len);
-extern int sdla_exec (void* opflag);
-
-extern unsigned wanpipe_hw_probe(void);
-
-#endif /* _SDLADRV_H */
diff --git a/include/linux/sdlapci.h b/include/linux/sdlapci.h
deleted file mode 100644
index 6f7c904f188d3..0000000000000
--- a/include/linux/sdlapci.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************************
-* sdlapci.h WANPIPE(tm) Multiprotocol WAN Link Driver.
-* Definitions for the SDLA PCI adapter.
-*
-* Author: Gideon Hack <ghack@sangoma.com>
-*
-* Copyright: (c) 1999-2000 Sangoma Technologies 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.
-* ============================================================================
-* Jun 02, 1999 Gideon Hack Initial version.
-*****************************************************************************/
-#ifndef _SDLAPCI_H
-#define _SDLAPCI_H
-
-/****** Defines *************************************************************/
-
-/* Definitions for identifying and finding S514 PCI adapters */
-#define V3_VENDOR_ID 0x11B0 /* V3 vendor ID number */
-#define V3_DEVICE_ID 0x0002 /* V3 device ID number */
-#define SANGOMA_SUBSYS_VENDOR 0x4753 /* ID for Sangoma */
-#define PCI_DEV_SLOT_MASK 0x1F /* mask for slot numbering */
-#define PCI_IRQ_NOT_ALLOCATED 0xFF /* interrupt line for no IRQ */
-
-/* Local PCI register offsets */
-#define PCI_VENDOR_ID_WORD 0x00 /* vendor ID */
-#define PCI_IO_BASE_DWORD 0x10 /* IO base */
-#define PCI_MEM_BASE0_DWORD 0x14 /* memory base - apperture 0 */
-#define PCI_MEM_BASE1_DWORD 0x18 /* memory base - apperture 1 */
-#define PCI_SUBSYS_VENDOR_WORD 0x2C /* subsystem vendor ID */
-#define PCI_INT_LINE_BYTE 0x3C /* interrupt line */
-#define PCI_INT_PIN_BYTE 0x3D /* interrupt pin */
-#define PCI_MAP0_DWORD 0x40 /* PCI to local bus address 0 */
-#define PCI_MAP1_DWORD 0x44 /* PCI to local bus address 1 */
-#define PCI_INT_STATUS 0x48 /* interrupt status */
-#define PCI_INT_CONFIG 0x4C /* interrupt configuration */
-
-/* Local PCI register usage */
-#define PCI_MEMORY_ENABLE 0x00000003 /* enable PCI memory */
-#define PCI_CPU_A_MEM_DISABLE 0x00000002 /* disable CPU A memory */
-#define PCI_CPU_B_MEM_DISABLE 0x00100002 /* disable CPU B memory */
-#define PCI_ENABLE_IRQ_CPU_A 0x005A0004 /* enable IRQ for CPU A */
-#define PCI_ENABLE_IRQ_CPU_B 0x005A0008 /* enable IRQ for CPU B */
-#define PCI_DISABLE_IRQ_CPU_A 0x00000004 /* disable IRQ for CPU A */
-#define PCI_DISABLE_IRQ_CPU_B 0x00000008 /* disable IRQ for CPU B */
-
-/* Setting for the Interrupt Status register */
-#define IRQ_CPU_A 0x04 /* IRQ for CPU A */
-#define IRQ_CPU_B 0x08 /* IRQ for CPU B */
-
-/* The maximum size of the S514 memory */
-#define MAX_SIZEOF_S514_MEMORY (256 * 1024)
-
-/* S514 control register offsets within the memory address space */
-#define S514_CTRL_REG_BYTE 0x80000
-
-/* S514 adapter control bytes */
-#define S514_CPU_HALT 0x00
-#define S514_CPU_START 0x01
-
-/* The maximum number of S514 adapters supported */
-#define MAX_S514_CARDS 20
-
-#define PCI_CARD_TYPE 0x2E
-#define S514_DUAL_CPU 0x12
-#define S514_SINGLE_CPU 0x11
-
-#endif /* _SDLAPCI_H */
-
diff --git a/include/linux/sdlasfm.h b/include/linux/sdlasfm.h
deleted file mode 100644
index 94aaa8ada6670..0000000000000
--- a/include/linux/sdlasfm.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*****************************************************************************
-* sdlasfm.h WANPIPE(tm) Multiprotocol WAN Link Driver.
-* Definitions for the SDLA Firmware Module (SFM).
-*
-* Author: Gideon Hack
-*
-* Copyright: (c) 1995-1999 Sangoma Technologies 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.
-* ============================================================================
-* Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
-* Dec 11, 1996 Gene Kozin Cosmetic changes
-* Apr 16, 1996 Gene Kozin Changed adapter & firmware IDs. Version 2
-* Dec 15, 1995 Gene Kozin Structures chaned
-* Nov 09, 1995 Gene Kozin Initial version.
-*****************************************************************************/
-#ifndef _SDLASFM_H
-#define _SDLASFM_H
-
-/****** Defines *************************************************************/
-
-#define SFM_VERSION 2
-#define SFM_SIGNATURE "SFM - Sangoma SDLA Firmware Module"
-
-/* min/max */
-#define SFM_IMAGE_SIZE 0x8000 /* max size of SDLA code image file */
-#define SFM_DESCR_LEN 256 /* max length of description string */
-#define SFM_MAX_SDLA 16 /* max number of compatible adapters */
-
-/* Adapter types */
-#define SDLA_S502A 5020
-#define SDLA_S502E 5021
-#define SDLA_S503 5030
-#define SDLA_S508 5080
-#define SDLA_S507 5070
-#define SDLA_S509 5090
-#define SDLA_S514 5140
-
-/* S514 PCI adapter CPU numbers */
-#define S514_CPU_A 'A'
-#define S514_CPU_B 'B'
-
-
-/* Firmware identification numbers:
- * 0 .. 999 Test & Diagnostics
- * 1000 .. 1999 Streaming HDLC
- * 2000 .. 2999 Bisync
- * 3000 .. 3999 SDLC
- * 4000 .. 4999 HDLC
- * 5000 .. 5999 X.25
- * 6000 .. 6999 Frame Relay
- * 7000 .. 7999 PPP
- * 8000 .. 8999 Cisco HDLC
- */
-#define SFID_CALIB502 200
-#define SFID_STRM502 1200
-#define SFID_STRM508 1800
-#define SFID_BSC502 2200
-#define SFID_SDLC502 3200
-#define SFID_HDLC502 4200
-#define SFID_HDLC508 4800
-#define SFID_X25_502 5200
-#define SFID_X25_508 5800
-#define SFID_FR502 6200
-#define SFID_FR508 6800
-#define SFID_PPP502 7200
-#define SFID_PPP508 7800
-#define SFID_PPP514 7140
-#define SFID_CHDLC508 8800
-#define SFID_CHDLC514 8140
-
-/****** Data Types **********************************************************/
-
-typedef struct sfm_info /* firmware module information */
-{
- unsigned short codeid; /* firmware ID */
- unsigned short version; /* firmaware version number */
- unsigned short adapter[SFM_MAX_SDLA]; /* compatible adapter types */
- unsigned long memsize; /* minimum memory size */
- unsigned short reserved[2]; /* reserved */
- unsigned short startoffs; /* entry point offset */
- unsigned short winoffs; /* dual-port memory window offset */
- unsigned short codeoffs; /* code load offset */
- unsigned short codesize; /* code size */
- unsigned short dataoffs; /* configuration data load offset */
- unsigned short datasize; /* configuration data size */
-} sfm_info_t;
-
-typedef struct sfm /* SDLA firmware file structire */
-{
- char signature[80]; /* SFM file signature */
- unsigned short version; /* file format version */
- unsigned short checksum; /* info + image */
- unsigned short reserved[6]; /* reserved */
- char descr[SFM_DESCR_LEN]; /* description string */
- sfm_info_t info; /* firmware module info */
- unsigned char image[1]; /* code image (variable size) */
-} sfm_t;
-
-#endif /* _SDLASFM_H */
-
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index fca9b0fb5b4eb..5a095572881d0 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -73,7 +73,7 @@ static inline int write_tryseqlock(seqlock_t *sl)
}
/* Start of read calculation -- fetch last complete writer token */
-static inline unsigned read_seqbegin(const seqlock_t *sl)
+static __always_inline unsigned read_seqbegin(const seqlock_t *sl)
{
unsigned ret = sl->sequence;
smp_rmb();
@@ -88,7 +88,7 @@ static inline unsigned read_seqbegin(const seqlock_t *sl)
*
* Using xor saves one conditional branch.
*/
-static inline int read_seqretry(const seqlock_t *sl, unsigned iv)
+static __always_inline int read_seqretry(const seqlock_t *sl, unsigned iv)
{
smp_rmb();
return (iv & 1) | (sl->sequence ^ iv);
diff --git a/include/linux/string.h b/include/linux/string.h
index dee221429ad0b..c61306da8c525 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -13,11 +13,6 @@
extern "C" {
#endif
-extern char * strpbrk(const char *,const char *);
-extern char * strsep(char **,const char *);
-extern __kernel_size_t strspn(const char *,const char *);
-extern __kernel_size_t strcspn(const char *,const char *);
-
extern char *strndup_user(const char __user *, long);
/*
@@ -70,6 +65,18 @@ extern __kernel_size_t strlen(const char *);
#ifndef __HAVE_ARCH_STRNLEN
extern __kernel_size_t strnlen(const char *,__kernel_size_t);
#endif
+#ifndef __HAVE_ARCH_STRPBRK
+extern char * strpbrk(const char *,const char *);
+#endif
+#ifndef __HAVE_ARCH_STRSEP
+extern char * strsep(char **,const char *);
+#endif
+#ifndef __HAVE_ARCH_STRSPN
+extern __kernel_size_t strspn(const char *,const char *);
+#endif
+#ifndef __HAVE_ARCH_STRCSPN
+extern __kernel_size_t strcspn(const char *,const char *);
+#endif
#ifndef __HAVE_ARCH_MEMSET
extern void * memset(void *,int,__kernel_size_t);
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 50cab2a09f28c..5035643845452 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -197,15 +197,16 @@ svc_take_res_page(struct svc_rqst *rqstp)
return rqstp->rq_respages[rqstp->rq_resused++];
}
-static inline int svc_take_page(struct svc_rqst *rqstp)
+static inline void svc_take_page(struct svc_rqst *rqstp)
{
- if (rqstp->rq_arghi <= rqstp->rq_argused)
- return -ENOMEM;
+ if (rqstp->rq_arghi <= rqstp->rq_argused) {
+ WARN_ON(1);
+ return;
+ }
rqstp->rq_arghi--;
rqstp->rq_respages[rqstp->rq_resused] =
rqstp->rq_argpages[rqstp->rq_arghi];
rqstp->rq_resused++;
- return 0;
}
static inline void svc_pushback_allpages(struct svc_rqst *rqstp)
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 54eac8a39a4c1..5b1fdf1cff4f0 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -155,6 +155,7 @@ extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *
/* linux/mm/page_alloc.c */
extern unsigned long totalram_pages;
extern unsigned long totalhigh_pages;
+extern unsigned long totalreserve_pages;
extern long nr_swap_pages;
extern unsigned int nr_free_pages(void);
extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 5717147596b6c..f001bad28d9ac 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -569,9 +569,12 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
int flags, int mode);
asmlinkage long sys_unshare(unsigned long unshare_flags);
-asmlinkage long sys_splice(int fdin, int fdout, size_t len,
- unsigned int flags);
+
+asmlinkage long sys_splice(int fd_in, loff_t __user *off_in,
+ int fd_out, loff_t __user *off_out,
+ size_t len, unsigned int flags);
+
asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
- int flags);
+ unsigned int flags);
#endif
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 0976a163b459b..31548303ee376 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -6,9 +6,10 @@ extern int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *c
extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size);
extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);
extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size);
+void tty_schedule_flip(struct tty_struct *tty);
static inline int tty_insert_flip_char(struct tty_struct *tty,
- unsigned char ch, char flag)
+ unsigned char ch, char flag)
{
struct tty_buffer *tb = tty->buf.tail;
if (tb && tb->active && tb->used < tb->size) {
@@ -19,26 +20,4 @@ static inline int tty_insert_flip_char(struct tty_struct *tty,
return tty_insert_flip_string_flags(tty, &ch, &flag, 1);
}
-static inline void tty_schedule_flip(struct tty_struct *tty)
-{
- unsigned long flags;
- spin_lock_irqsave(&tty->buf.lock, flags);
- if (tty->buf.tail != NULL) {
- tty->buf.tail->active = 0;
- tty->buf.tail->commit = tty->buf.tail->used;
- }
- spin_unlock_irqrestore(&tty->buf.lock, flags);
- schedule_delayed_work(&tty->buf.work, 1);
-}
-
-#undef _INLINE_
-
-
#endif /* _LINUX_TTY_FLIP_H */
-
-
-
-
-
-
-
diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
index fadc535e29251..dc7c621e46471 100644
--- a/include/linux/vermagic.h
+++ b/include/linux/vermagic.h
@@ -12,6 +12,11 @@
#else
#define MODULE_VERMAGIC_PREEMPT ""
#endif
+#ifdef CONFIG_MODULE_UNLOAD
+#define MODULE_VERMAGIC_MODULE_UNLOAD "mod_unload "
+#else
+#define MODULE_VERMAGIC_MODULE_UNLOAD ""
+#endif
#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif
@@ -19,5 +24,5 @@
#define VERMAGIC_STRING \
UTS_RELEASE " " \
MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
- MODULE_ARCH_VERMAGIC \
+ MODULE_VERMAGIC_MODULE_UNLOAD MODULE_ARCH_VERMAGIC \
"gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__)
diff --git a/include/linux/wanpipe.h b/include/linux/wanpipe.h
deleted file mode 100644
index dae9860091ddc..0000000000000
--- a/include/linux/wanpipe.h
+++ /dev/null
@@ -1,483 +0,0 @@
-/*****************************************************************************
-* wanpipe.h WANPIPE(tm) Multiprotocol WAN Link Driver.
-* User-level API definitions.
-*
-* Author: Nenad Corbic <ncorbic@sangoma.com>
-* Gideon Hack
-*
-* Copyright: (c) 1995-2000 Sangoma Technologies 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.
-* ============================================================================
-* Nov 3, 2000 Nenad Corbic Added config_id to sdla_t structure.
-* Used to determine the protocol running.
-* Jul 13, 2000 Nenad Corbic Added SyncPPP Support
-* Feb 24, 2000 Nenad Corbic Added support for x25api driver
-* Oct 04, 1999 Nenad Corbic New CHDLC and FRAME RELAY code, SMP support
-* Jun 02, 1999 Gideon Hack Added 'update_call_count' for Cisco HDLC
-* support
-* Jun 26, 1998 David Fong Added 'ip_mode' in sdla_t.u.p for dynamic IP
-* routing mode configuration
-* Jun 12, 1998 David Fong Added Cisco HDLC union member in sdla_t
-* Dec 08, 1997 Jaspreet Singh Added 'authenticator' in union of 'sdla_t'
-* Nov 26, 1997 Jaspreet Singh Added 'load_sharing' structure. Also added
-* 'devs_struct','dev_to_devtint_next' to 'sdla_t'
-* Nov 24, 1997 Jaspreet Singh Added 'irq_dis_if_send_count',
-* 'irq_dis_poll_count' to 'sdla_t'.
-* Nov 06, 1997 Jaspreet Singh Added a define called 'INTR_TEST_MODE'
-* Oct 20, 1997 Jaspreet Singh Added 'buff_intr_mode_unbusy' and
-* 'dlci_intr_mode_unbusy' to 'sdla_t'
-* Oct 18, 1997 Jaspreet Singh Added structure to maintain global driver
-* statistics.
-* Jan 15, 1997 Gene Kozin Version 3.1.0
-* o added UDP management stuff
-* Jan 02, 1997 Gene Kozin Version 3.0.0
-*****************************************************************************/
-#ifndef _WANPIPE_H
-#define _WANPIPE_H
-
-#include <linux/wanrouter.h>
-
-/* Defines */
-
-#ifndef PACKED
-#define PACKED __attribute__((packed))
-#endif
-
-#define WANPIPE_MAGIC 0x414C4453L /* signature: 'SDLA' reversed */
-
-/* IOCTL numbers (up to 16) */
-#define WANPIPE_DUMP (ROUTER_USER+0) /* dump adapter's memory */
-#define WANPIPE_EXEC (ROUTER_USER+1) /* execute firmware command */
-
-#define TRACE_ALL 0x00
-#define TRACE_PROT 0x01
-#define TRACE_DATA 0x02
-
-/* values for request/reply byte */
-#define UDPMGMT_REQUEST 0x01
-#define UDPMGMT_REPLY 0x02
-#define UDP_OFFSET 12
-
-#define MAX_CMD_BUFF 10
-#define MAX_X25_LCN 255 /* Maximum number of x25 channels */
-#define MAX_LCN_NUM 4095 /* Maximum lcn number */
-#define MAX_FT1_RETRY 100
-
-#ifndef AF_WANPIPE
- #define AF_WANPIPE 25
- #ifndef PF_WANPIPE
- #define PF_WANPIPE AF_WANPIPE
- #endif
-#endif
-
-
-#define TX_TIMEOUT 5*HZ
-
-/* General Critical Flags */
-#define SEND_CRIT 0x00
-#define PERI_CRIT 0x01
-
-/* Chdlc and PPP polling critical flag */
-#define POLL_CRIT 0x03
-
-/* Frame Relay Tx IRQ send critical flag */
-#define SEND_TXIRQ_CRIT 0x02
-
-/* Frame Relay ARP critical flag */
-#define ARP_CRIT 0x03
-
-/* Bit maps for dynamic interface configuration
- * DYN_OPT_ON : turns this option on/off
- * DEV_DOWN : device was shutdown by the driver not
- * by user
- */
-#define DYN_OPT_ON 0x00
-#define DEV_DOWN 0x01
-
-/*
- * Data structures for IOCTL calls.
- */
-
-typedef struct sdla_dump /* WANPIPE_DUMP */
-{
- unsigned long magic; /* for verification */
- unsigned long offset; /* absolute adapter memory address */
- unsigned long length; /* block length */
- void* ptr; /* -> buffer */
-} sdla_dump_t;
-
-typedef struct sdla_exec /* WANPIPE_EXEC */
-{
- unsigned long magic; /* for verification */
- void* cmd; /* -> command structure */
- void* data; /* -> data buffer */
-} sdla_exec_t;
-
-/* UDP management stuff */
-
-typedef struct wum_header
-{
- unsigned char signature[8]; /* 00h: signature */
- unsigned char type; /* 08h: request/reply */
- unsigned char command; /* 09h: commnand */
- unsigned char reserved[6]; /* 0Ah: reserved */
-} wum_header_t;
-
-/*************************************************************************
- Data Structure for global statistics
-*************************************************************************/
-
-typedef struct global_stats
-{
- unsigned long isr_entry;
- unsigned long isr_already_critical;
- unsigned long isr_rx;
- unsigned long isr_tx;
- unsigned long isr_intr_test;
- unsigned long isr_spurious;
- unsigned long isr_enable_tx_int;
- unsigned long rx_intr_corrupt_rx_bfr;
- unsigned long rx_intr_on_orphaned_DLCI;
- unsigned long rx_intr_dev_not_started;
- unsigned long tx_intr_dev_not_started;
- unsigned long poll_entry;
- unsigned long poll_already_critical;
- unsigned long poll_processed;
- unsigned long poll_tbusy_bad_status;
- unsigned long poll_host_disable_irq;
- unsigned long poll_host_enable_irq;
-
-} global_stats_t;
-
-
-typedef struct{
- unsigned short udp_src_port PACKED;
- unsigned short udp_dst_port PACKED;
- unsigned short udp_length PACKED;
- unsigned short udp_checksum PACKED;
-} udp_pkt_t;
-
-
-typedef struct {
- unsigned char ver_inet_hdr_length PACKED;
- unsigned char service_type PACKED;
- unsigned short total_length PACKED;
- unsigned short identifier PACKED;
- unsigned short flags_frag_offset PACKED;
- unsigned char ttl PACKED;
- unsigned char protocol PACKED;
- unsigned short hdr_checksum PACKED;
- unsigned long ip_src_address PACKED;
- unsigned long ip_dst_address PACKED;
-} ip_pkt_t;
-
-
-typedef struct {
- unsigned char signature[8] PACKED;
- unsigned char request_reply PACKED;
- unsigned char id PACKED;
- unsigned char reserved[6] PACKED;
-} wp_mgmt_t;
-
-/*************************************************************************
- Data Structure for if_send statistics
-*************************************************************************/
-typedef struct if_send_stat{
- unsigned long if_send_entry;
- unsigned long if_send_skb_null;
- unsigned long if_send_broadcast;
- unsigned long if_send_multicast;
- unsigned long if_send_critical_ISR;
- unsigned long if_send_critical_non_ISR;
- unsigned long if_send_tbusy;
- unsigned long if_send_tbusy_timeout;
- unsigned long if_send_PIPE_request;
- unsigned long if_send_wan_disconnected;
- unsigned long if_send_dlci_disconnected;
- unsigned long if_send_no_bfrs;
- unsigned long if_send_adptr_bfrs_full;
- unsigned long if_send_bfr_passed_to_adptr;
- unsigned long if_send_protocol_error;
- unsigned long if_send_bfr_not_passed_to_adptr;
- unsigned long if_send_tx_int_enabled;
- unsigned long if_send_consec_send_fail;
-} if_send_stat_t;
-
-typedef struct rx_intr_stat{
- unsigned long rx_intr_no_socket;
- unsigned long rx_intr_dev_not_started;
- unsigned long rx_intr_PIPE_request;
- unsigned long rx_intr_bfr_not_passed_to_stack;
- unsigned long rx_intr_bfr_passed_to_stack;
-} rx_intr_stat_t;
-
-typedef struct pipe_mgmt_stat{
- unsigned long UDP_PIPE_mgmt_kmalloc_err;
- unsigned long UDP_PIPE_mgmt_direction_err;
- unsigned long UDP_PIPE_mgmt_adptr_type_err;
- unsigned long UDP_PIPE_mgmt_adptr_cmnd_OK;
- unsigned long UDP_PIPE_mgmt_adptr_cmnd_timeout;
- unsigned long UDP_PIPE_mgmt_adptr_send_passed;
- unsigned long UDP_PIPE_mgmt_adptr_send_failed;
- unsigned long UDP_PIPE_mgmt_not_passed_to_stack;
- unsigned long UDP_PIPE_mgmt_passed_to_stack;
- unsigned long UDP_PIPE_mgmt_no_socket;
- unsigned long UDP_PIPE_mgmt_passed_to_adptr;
-} pipe_mgmt_stat_t;
-
-
-typedef struct {
- struct sk_buff *skb;
-} bh_data_t, cmd_data_t;
-
-#define MAX_LGTH_UDP_MGNT_PKT 2000
-
-
-/* This is used for interrupt testing */
-#define INTR_TEST_MODE 0x02
-
-#define WUM_SIGNATURE_L 0x50495046
-#define WUM_SIGNATURE_H 0x444E3845
-
-#define WUM_KILL 0x50
-#define WUM_EXEC 0x51
-
-#define WANPIPE 0x00
-#define API 0x01
-#define BRIDGE 0x02
-#define BRIDGE_NODE 0x03
-
-#ifdef __KERNEL__
-/****** Kernel Interface ****************************************************/
-
-#include <linux/sdladrv.h> /* SDLA support module API definitions */
-#include <linux/sdlasfm.h> /* SDLA firmware module definitions */
-#include <linux/workqueue.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <linux/serial_reg.h>
-#include <asm/serial.h>
-#include <linux/tty.h>
-#include <linux/tty_driver.h>
-#include <linux/tty_flip.h>
-
-/****** Data Structures *****************************************************/
-
-/* Adapter Data Space.
- * This structure is needed because we handle multiple cards, otherwise
- * static data would do it.
- */
-typedef struct sdla
-{
- char devname[WAN_DRVNAME_SZ+1]; /* card name */
- sdlahw_t hw; /* hardware configuration */
- struct wan_device wandev; /* WAN device data space */
-
- unsigned open_cnt; /* number of open interfaces */
- unsigned long state_tick; /* link state timestamp */
- unsigned intr_mode; /* Type of Interrupt Mode */
- char in_isr; /* interrupt-in-service flag */
- char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
- char dlci_int_mode_unbusy; /* flag for carrying out dev_tint */
- long configured; /* flag for previous configurations */
-
- unsigned short irq_dis_if_send_count; /* Disabling irqs in if_send*/
- unsigned short irq_dis_poll_count; /* Disabling irqs in poll routine*/
- unsigned short force_enable_irq;
- char TracingEnabled; /* flag for enabling trace */
- global_stats_t statistics; /* global statistics */
- void* mbox; /* -> mailbox */
- void* rxmb; /* -> receive mailbox */
- void* flags; /* -> adapter status flags */
- void (*isr)(struct sdla* card); /* interrupt service routine */
- void (*poll)(struct sdla* card); /* polling routine */
- int (*exec)(struct sdla* card, void* u_cmd, void* u_data);
- /* Used by the listen() system call */
- /* Wanpipe Socket Interface */
- int (*func) (struct sk_buff *, struct sock *);
- struct sock *sk;
-
- /* Shutdown function */
- void (*disable_comm) (struct sdla *card);
-
- /* Secondary Port Device: Piggibacking */
- struct sdla *next;
-
- /* TTY driver variables */
- unsigned char tty_opt;
- struct tty_struct *tty;
- unsigned int tty_minor;
- unsigned int tty_open;
- unsigned char *tty_buf;
- unsigned char *tty_rx;
- struct work_struct tty_work;
-
- union
- {
- struct
- { /****** X.25 specific data **********/
- u32 lo_pvc;
- u32 hi_pvc;
- u32 lo_svc;
- u32 hi_svc;
- struct net_device *svc_to_dev_map[MAX_X25_LCN];
- struct net_device *pvc_to_dev_map[MAX_X25_LCN];
- struct net_device *tx_dev;
- struct net_device *cmd_dev;
- u32 no_dev;
- volatile u8 *hdlc_buf_status;
- u32 tx_interrupts_pending;
- u16 timer_int_enabled;
- struct net_device *poll_device;
- atomic_t command_busy;
-
- u16 udp_pkt_lgth;
- u32 udp_type;
- u8 udp_pkt_src;
- u32 udp_lcn;
- struct net_device *udp_dev;
- s8 udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
-
- u8 LAPB_hdlc; /* Option to turn off X25 and run only LAPB */
- u8 logging; /* Option to log call messages */
- u8 oob_on_modem; /* Option to send modem status to the api */
- u16 num_of_ch; /* Number of channels configured by the user */
-
- struct work_struct x25_poll_work;
- struct timer_list x25_timer;
- } x;
- struct
- { /****** frame relay specific data ***/
- void* rxmb_base; /* -> first Rx buffer */
- void* rxmb_last; /* -> last Rx buffer */
- unsigned rx_base; /* S508 receive buffer base */
- unsigned rx_top; /* S508 receive buffer end */
- unsigned short node_dlci[100];
- unsigned short dlci_num;
- struct net_device *dlci_to_dev_map[991 + 1];
- unsigned tx_interrupts_pending;
- unsigned short timer_int_enabled;
- unsigned short udp_pkt_lgth;
- int udp_type;
- char udp_pkt_src;
- unsigned udp_dlci;
- char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
- void* trc_el_base; /* first trace element */
- void* trc_el_last; /* last trace element */
- void *curr_trc_el; /* current trace element */
- unsigned short trc_bfr_space; /* trace buffer space */
- unsigned char update_comms_stats;
- struct net_device *arp_dev;
- spinlock_t if_send_lock;
- } f;
- struct /****** PPP-specific data ***********/
- {
- char if_name[WAN_IFNAME_SZ+1]; /* interface name */
- void* txbuf; /* -> current Tx buffer */
- void* txbuf_base; /* -> first Tx buffer */
- void* txbuf_last; /* -> last Tx buffer */
- void* rxbuf_base; /* -> first Rx buffer */
- void* rxbuf_last; /* -> last Rx buffer */
- unsigned rx_base; /* S508 receive buffer base */
- unsigned rx_top; /* S508 receive buffer end */
- char ip_mode; /* STATIC/HOST/PEER IP Mode */
- char authenticator; /* Authenticator for PAP/CHAP */
- unsigned char comm_enabled; /* Is comm enabled or not */
- unsigned char peer_route; /* Process Peer Route */
- unsigned long *txbuf_next; /* Next Tx buffer to use */
- unsigned long *rxbuf_next; /* Next Rx buffer to use */
- } p;
- struct /* Cisco HDLC-specific data */
- {
- char if_name[WAN_IFNAME_SZ+1]; /* interface name */
- unsigned char comm_port;/* Communication Port O or 1 */
- unsigned char usedby; /* Used by WANPIPE or API */
- void* rxmb; /* Receive mail box */
- void* flags; /* flags */
- void* tx_status; /* Tx status element */
- void* rx_status; /* Rx status element */
- void* txbuf; /* -> current Tx buffer */
- void* txbuf_base; /* -> first Tx buffer */
- void* txbuf_last; /* -> last Tx buffer */
- void* rxbuf_base; /* -> first Rx buffer */
- void* rxbuf_last; /* -> last Rx buffer */
- unsigned rx_base; /* S508 receive buffer base */
- unsigned rx_top; /* S508 receive buffer end */
- unsigned char receive_only; /* high speed receivers */
- unsigned short protocol_options;
- unsigned short kpalv_tx; /* Tx kpalv timer */
- unsigned short kpalv_rx; /* Rx kpalv timer */
- unsigned short kpalv_err; /* Error tolerance */
- unsigned short slarp_timer; /* SLARP req timer */
- unsigned state; /* state of the link */
- unsigned char api_status;
- unsigned char update_call_count;
- unsigned short api_options; /* for async config */
- unsigned char async_mode;
- unsigned short tx_bits_per_char;
- unsigned short rx_bits_per_char;
- unsigned short stop_bits;
- unsigned short parity;
- unsigned short break_timer;
- unsigned short inter_char_timer;
- unsigned short rx_complete_length;
- unsigned short xon_char;
- unsigned short xoff_char;
- unsigned char comm_enabled; /* Is comm enabled or not */
- unsigned char backup;
- } c;
- struct
- {
- void* tx_status; /* Tx status element */
- void* rx_status; /* Rx status element */
- void* trace_status; /* Trace status element */
- void* txbuf; /* -> current Tx buffer */
- void* txbuf_base; /* -> first Tx buffer */
- void* txbuf_last; /* -> last Tx buffer */
- void* rxbuf_base; /* -> first Rx buffer */
- void* rxbuf_last; /* -> last Rx buffer */
- void* tracebuf; /* -> current Trace buffer */
- void* tracebuf_base; /* -> current Trace buffer */
- void* tracebuf_last; /* -> current Trace buffer */
- unsigned rx_base; /* receive buffer base */
- unsigned rx_end; /* receive buffer end */
- unsigned trace_base; /* trace buffer base */
- unsigned trace_end; /* trace buffer end */
-
- } h;
- } u;
-} sdla_t;
-
-/****** Public Functions ****************************************************/
-
-void wanpipe_open (sdla_t* card); /* wpmain.c */
-void wanpipe_close (sdla_t* card); /* wpmain.c */
-void wanpipe_set_state (sdla_t* card, int state); /* wpmain.c */
-
-int wpx_init (sdla_t* card, wandev_conf_t* conf); /* wpx.c */
-int wpf_init (sdla_t* card, wandev_conf_t* conf); /* wpf.c */
-int wpp_init (sdla_t* card, wandev_conf_t* conf); /* wpp.c */
-int wpc_init (sdla_t* card, wandev_conf_t* conf); /* Cisco HDLC */
-int bsc_init (sdla_t* card, wandev_conf_t* conf); /* BSC streaming */
-int hdlc_init(sdla_t* card, wandev_conf_t* conf); /* HDLC support */
-int wpft1_init (sdla_t* card, wandev_conf_t* conf); /* FT1 Config support */
-int wsppp_init (sdla_t* card, wandev_conf_t* conf); /* Sync PPP on top of RAW CHDLC */
-
-extern sdla_t * wanpipe_find_card(char *);
-extern sdla_t * wanpipe_find_card_num (int);
-
-extern void wanpipe_queue_work (struct work_struct *);
-extern void wanpipe_mark_bh (void);
-extern void wakeup_sk_bh(struct net_device *dev);
-extern int change_dev_flags(struct net_device *dev, unsigned flags);
-extern unsigned long get_ip_address(struct net_device *dev, int option);
-extern void add_gateway(sdla_t *card, struct net_device *dev);
-
-
-#endif /* __KERNEL__ */
-#endif /* _WANPIPE_H */
-
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index 25f708ff020e9..59f0c83d55a24 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -48,31 +48,7 @@ static inline int inet6_sk_ehashfn(const struct sock *sk)
return inet6_ehashfn(laddr, lport, faddr, fport);
}
-static inline void __inet6_hash(struct inet_hashinfo *hashinfo,
- struct sock *sk)
-{
- struct hlist_head *list;
- rwlock_t *lock;
-
- BUG_TRAP(sk_unhashed(sk));
-
- if (sk->sk_state == TCP_LISTEN) {
- list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
- lock = &hashinfo->lhash_lock;
- inet_listen_wlock(hashinfo);
- } else {
- unsigned int hash;
- sk->sk_hash = hash = inet6_sk_ehashfn(sk);
- hash &= (hashinfo->ehash_size - 1);
- list = &hashinfo->ehash[hash].chain;
- lock = &hashinfo->ehash[hash].lock;
- write_lock(lock);
- }
-
- __sk_add_node(sk, list);
- sock_prot_inc_use(sk->sk_prot);
- write_unlock(lock);
-}
+extern void __inet6_hash(struct inet_hashinfo *hashinfo, struct sock *sk);
/*
* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
@@ -80,52 +56,12 @@ static inline void __inet6_hash(struct inet_hashinfo *hashinfo,
*
* The sockhash lock must be held as a reader here.
*/
-static inline struct sock *
- __inet6_lookup_established(struct inet_hashinfo *hashinfo,
+extern struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
const struct in6_addr *saddr,
const u16 sport,
const struct in6_addr *daddr,
const u16 hnum,
- const int dif)
-{
- struct sock *sk;
- const struct hlist_node *node;
- const __u32 ports = INET_COMBINED_PORTS(sport, hnum);
- /* Optimize here for direct hit, only listening connections can
- * have wildcards anyways.
- */
- unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport);
- struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
-
- prefetch(head->chain.first);
- read_lock(&head->lock);
- sk_for_each(sk, node, &head->chain) {
- /* For IPV6 do the cheaper port and family tests first. */
- if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif))
- goto hit; /* You sunk my battleship! */
- }
- /* Must check for a TIME_WAIT'er before going to listener hash. */
- sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
- const struct inet_timewait_sock *tw = inet_twsk(sk);
-
- if(*((__u32 *)&(tw->tw_dport)) == ports &&
- sk->sk_family == PF_INET6) {
- const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
-
- if (ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) &&
- ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) &&
- (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif))
- goto hit;
- }
- }
- read_unlock(&head->lock);
- return NULL;
-
-hit:
- sock_hold(sk);
- read_unlock(&head->lock);
- return sk;
-}
+ const int dif);
extern struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
const struct in6_addr *daddr,
diff --git a/include/net/ip.h b/include/net/ip.h
index 8fe6156ca9b08..3d2e5ca62a5af 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -95,6 +95,7 @@ extern int ip_local_deliver(struct sk_buff *skb);
extern int ip_mr_input(struct sk_buff *skb);
extern int ip_output(struct sk_buff *skb);
extern int ip_mc_output(struct sk_buff *skb);
+extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
extern int ip_do_nat(struct sk_buff *skb);
extern void ip_send_check(struct iphdr *ip);
extern int ip_queue_xmit(struct sk_buff *skb, int ipfragok);
diff --git a/include/net/x25device.h b/include/net/x25device.h
index 1a318374faefc..1d10c879f7e24 100644
--- a/include/net/x25device.h
+++ b/include/net/x25device.h
@@ -8,6 +8,7 @@
static inline __be16 x25_type_trans(struct sk_buff *skb, struct net_device *dev)
{
skb->mac.raw = skb->data;
+ skb->dev = dev;
skb->pkt_type = PACKET_HOST;
return htons(ETH_P_X25);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index dc6862d09e535..de6ce541a046c 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -140,7 +140,6 @@ struct scsi_host_template {
*
* Status: REQUIRED (at least one of them)
*/
- int (* eh_strategy_handler)(struct Scsi_Host *);
int (* eh_abort_handler)(struct scsi_cmnd *);
int (* eh_device_reset_handler)(struct scsi_cmnd *);
int (* eh_bus_reset_handler)(struct scsi_cmnd *);
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index b3657f111937a..cca1d4926d2aa 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -50,6 +50,11 @@ struct scsi_transport_template {
unsigned int create_work_queue : 1;
/*
+ * Allows a transport to override the default error handler.
+ */
+ void (* eh_strategy_handler)(struct Scsi_Host *);
+
+ /*
* This is an optional routine that allows the transport to become
* involved when a scsi io timer fires. The return value tells the
* timer routine how to finish the io timeout handling:
diff --git a/include/sound/core.h b/include/sound/core.h
index d1d043f6cb80c..5135147f20e89 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -176,7 +176,7 @@ int snd_power_wait(struct snd_card *card, unsigned int power_state);
#define snd_power_lock(card) do { (void)(card); } while (0)
#define snd_power_unlock(card) do { (void)(card); } while (0)
-static inline int snd_power_wait(struct snd_card *card, unsigned int state, struct file *file) { return 0; }
+static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; }
#define snd_power_get_state(card) SNDRV_CTL_POWER_D0
#define snd_power_change_state(card, state) do { (void)(card); } while (0)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 66b1f08b42b90..df70e7592ab5d 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -367,7 +367,7 @@ struct snd_pcm_substream {
struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */
struct snd_pcm_group *group; /* pointer to current group */
/* -- assigned files -- */
- struct snd_pcm_file *file;
+ void *file;
struct file *ffile;
void (*pcm_release)(struct snd_pcm_substream *);
#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
@@ -898,7 +898,6 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);
int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);
snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian);
-const char *snd_pcm_format_name(snd_pcm_format_t format);
void snd_pcm_set_ops(struct snd_pcm * pcm, int direction, struct snd_pcm_ops *ops);
void snd_pcm_set_sync(struct snd_pcm_substream *substream);
diff --git a/init/Kconfig b/init/Kconfig
index 3b36a1d536564..f1bc2f0e94e59 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -374,6 +374,15 @@ config SLAB
SLOB is more space efficient but does not scale well and is
more susceptible to fragmentation.
+config DOUBLEFAULT
+ default y
+ bool "Enable doublefault exception handler" if EMBEDDED && X86_32
+ help
+ This option allows trapping of rare doublefault exceptions that
+ would otherwise cause a system to silently reboot. Disabling this
+ option saves about 4k and might cause you much additional grey
+ hair.
+
endmenu # General setup
config TINY_SHMEM
diff --git a/kernel/exit.c b/kernel/exit.c
index 6c2eeb8f6390c..1a9787ac61733 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -34,6 +34,7 @@
#include <linux/mutex.h>
#include <linux/futex.h>
#include <linux/compat.h>
+#include <linux/pipe_fs_i.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
@@ -941,6 +942,9 @@ fastcall NORET_TYPE void do_exit(long code)
if (tsk->io_context)
exit_io_context();
+ if (tsk->splice_pipe)
+ __free_pipe_info(tsk->splice_pipe);
+
/* PF_DEAD causes final put_task_struct after we schedule. */
preempt_disable();
BUG_ON(tsk->flags & PF_DEAD);
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index f181ff4dd32ec..d2a7296c82519 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -501,6 +501,7 @@ int hrtimer_cancel(struct hrtimer *timer)
if (ret >= 0)
return ret;
+ cpu_relax();
}
}
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile
index 2b33f852be3ea..9f77f50d81431 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -1,4 +1,5 @@
-obj-y := handle.o manage.o spurious.o migration.o
+obj-y := handle.o manage.o spurious.o
obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
obj-$(CONFIG_PROC_FS) += proc.o
+obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index 52a8655fa0800..134f9f2e0e396 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -1,6 +1,5 @@
-#include <linux/irq.h>
-#if defined(CONFIG_GENERIC_PENDING_IRQ)
+#include <linux/irq.h>
void set_pending_irq(unsigned int irq, cpumask_t mask)
{
@@ -61,5 +60,3 @@ void move_native_irq(int irq)
}
cpus_clear(pending_irq_cpumask[irq]);
}
-
-#endif
diff --git a/kernel/panic.c b/kernel/panic.c
index f895c7c01d5b1..cc2a4c9c36ac2 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -27,7 +27,6 @@ static int pause_on_oops_flag;
static DEFINE_SPINLOCK(pause_on_oops_lock);
int panic_timeout;
-EXPORT_SYMBOL(panic_timeout);
ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
diff --git a/kernel/sched.c b/kernel/sched.c
index dd153d6f8a04b..365f0b90b4de5 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -665,13 +665,55 @@ static int effective_prio(task_t *p)
}
/*
+ * We place interactive tasks back into the active array, if possible.
+ *
+ * To guarantee that this does not starve expired tasks we ignore the
+ * interactivity of a task if the first expired task had to wait more
+ * than a 'reasonable' amount of time. This deadline timeout is
+ * load-dependent, as the frequency of array switched decreases with
+ * increasing number of running tasks. We also ignore the interactivity
+ * if a better static_prio task has expired, and switch periodically
+ * regardless, to ensure that highly interactive tasks do not starve
+ * the less fortunate for unreasonably long periods.
+ */
+static inline int expired_starving(runqueue_t *rq)
+{
+ int limit;
+
+ /*
+ * Arrays were recently switched, all is well
+ */
+ if (!rq->expired_timestamp)
+ return 0;
+
+ limit = STARVATION_LIMIT * rq->nr_running;
+
+ /*
+ * It's time to switch arrays
+ */
+ if (jiffies - rq->expired_timestamp >= limit)
+ return 1;
+
+ /*
+ * There's a better selection in the expired array
+ */
+ if (rq->curr->static_prio > rq->best_expired_prio)
+ return 1;
+
+ /*
+ * All is well
+ */
+ return 0;
+}
+
+/*
* __activate_task - move a task to the runqueue.
*/
static void __activate_task(task_t *p, runqueue_t *rq)
{
prio_array_t *target = rq->active;
- if (batch_task(p))
+ if (unlikely(batch_task(p) || (expired_starving(rq) && !rt_task(p))))
target = rq->expired;
enqueue_task(p, target);
rq->nr_running++;
@@ -2490,22 +2532,6 @@ unsigned long long current_sched_time(const task_t *tsk)
}
/*
- * We place interactive tasks back into the active array, if possible.
- *
- * To guarantee that this does not starve expired tasks we ignore the
- * interactivity of a task if the first expired task had to wait more
- * than a 'reasonable' amount of time. This deadline timeout is
- * load-dependent, as the frequency of array switched decreases with
- * increasing number of running tasks. We also ignore the interactivity
- * if a better static_prio task has expired:
- */
-#define EXPIRED_STARVING(rq) \
- ((STARVATION_LIMIT && ((rq)->expired_timestamp && \
- (jiffies - (rq)->expired_timestamp >= \
- STARVATION_LIMIT * ((rq)->nr_running) + 1))) || \
- ((rq)->curr->static_prio > (rq)->best_expired_prio))
-
-/*
* Account user cpu time to a process.
* @p: the process that the cpu time gets accounted to
* @hardirq_offset: the offset to subtract from hardirq_count()
@@ -2640,7 +2666,7 @@ void scheduler_tick(void)
if (!rq->expired_timestamp)
rq->expired_timestamp = jiffies;
- if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
+ if (!TASK_INTERACTIVE(p) || expired_starving(rq)) {
enqueue_task(p, rq->expired);
if (p->static_prio < rq->best_expired_prio)
rq->best_expired_prio = p->static_prio;
diff --git a/kernel/signal.c b/kernel/signal.c
index 5ccaac505e8da..b14f895027c34 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -868,7 +868,6 @@ __group_complete_signal(int sig, struct task_struct *p)
if (t == NULL)
/* restart balancing at this thread */
t = p->signal->curr_target = p;
- BUG_ON(t->tgid != p->tgid);
while (!wants_signal(sig, t)) {
t = next_thread(t);
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index d82864c4a6178..5433195040f19 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -120,3 +120,15 @@ cond_syscall(sys32_sysctl);
cond_syscall(ppc_rtas);
cond_syscall(sys_spu_run);
cond_syscall(sys_spu_create);
+
+/* mmu depending weak syscall entries */
+cond_syscall(sys_mprotect);
+cond_syscall(sys_msync);
+cond_syscall(sys_mlock);
+cond_syscall(sys_munlock);
+cond_syscall(sys_mlockall);
+cond_syscall(sys_munlockall);
+cond_syscall(sys_mincore);
+cond_syscall(sys_madvise);
+cond_syscall(sys_mremap);
+cond_syscall(sys_remap_file_pages);
diff --git a/kernel/timer.c b/kernel/timer.c
index c3a874f1393cd..8837737888361 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -81,9 +81,10 @@ struct tvec_t_base_s {
} ____cacheline_aligned_in_smp;
typedef struct tvec_t_base_s tvec_base_t;
-static DEFINE_PER_CPU(tvec_base_t *, tvec_bases);
+
tvec_base_t boot_tvec_bases;
EXPORT_SYMBOL(boot_tvec_bases);
+static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = { &boot_tvec_bases };
static inline void set_running_timer(tvec_base_t *base,
struct timer_list *timer)
@@ -1224,28 +1225,36 @@ static int __devinit init_timers_cpu(int cpu)
{
int j;
tvec_base_t *base;
+ static char __devinitdata tvec_base_done[NR_CPUS];
- base = per_cpu(tvec_bases, cpu);
- if (!base) {
+ if (!tvec_base_done[cpu]) {
static char boot_done;
- /*
- * Cannot do allocation in init_timers as that runs before the
- * allocator initializes (and would waste memory if there are
- * more possible CPUs than will ever be installed/brought up).
- */
if (boot_done) {
+ /*
+ * The APs use this path later in boot
+ */
base = kmalloc_node(sizeof(*base), GFP_KERNEL,
cpu_to_node(cpu));
if (!base)
return -ENOMEM;
memset(base, 0, sizeof(*base));
+ per_cpu(tvec_bases, cpu) = base;
} else {
- base = &boot_tvec_bases;
+ /*
+ * This is for the boot CPU - we use compile-time
+ * static initialisation because per-cpu memory isn't
+ * ready yet and because the memory allocators are not
+ * initialised either.
+ */
boot_done = 1;
+ base = &boot_tvec_bases;
}
- per_cpu(tvec_bases, cpu) = base;
+ tvec_base_done[cpu] = 1;
+ } else {
+ base = per_cpu(tvec_bases, cpu);
}
+
spin_lock_init(&base->lock);
for (j = 0; j < TVN_SIZE; j++) {
INIT_LIST_HEAD(base->tv5.vec + j);
@@ -1455,7 +1464,7 @@ static void time_interpolator_update(long delta_nsec)
*/
if (jiffies % INTERPOLATOR_ADJUST == 0)
{
- if (time_interpolator->skips == 0 && time_interpolator->offset > TICK_NSEC)
+ if (time_interpolator->skips == 0 && time_interpolator->offset > tick_nsec)
time_interpolator->nsec_per_cyc--;
if (time_interpolator->ns_skipped > INTERPOLATOR_MAX_SKIP && time_interpolator->offset == 0)
time_interpolator->nsec_per_cyc++;
diff --git a/lib/string.c b/lib/string.c
index b3c28a3f63322..064f6315b1c3e 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -362,6 +362,7 @@ size_t strspn(const char *s, const char *accept)
EXPORT_SYMBOL(strspn);
#endif
+#ifndef __HAVE_ARCH_STRCSPN
/**
* strcspn - Calculate the length of the initial substring of @s which does
* not contain letters in @reject
@@ -384,6 +385,7 @@ size_t strcspn(const char *s, const char *reject)
return count;
}
EXPORT_SYMBOL(strcspn);
+#endif
#ifndef __HAVE_ARCH_STRPBRK
/**
@@ -403,6 +405,7 @@ char *strpbrk(const char *cs, const char *ct)
}
return NULL;
}
+EXPORT_SYMBOL(strpbrk);
#endif
#ifndef __HAVE_ARCH_STRSEP
@@ -467,7 +470,7 @@ EXPORT_SYMBOL(memset);
void *memcpy(void *dest, const void *src, size_t count)
{
char *tmp = dest;
- char *s = src;
+ const char *s = src;
while (count--)
*tmp++ = *s++;
diff --git a/mm/bootmem.c b/mm/bootmem.c
index d3e3bd2ffceac..d213feded10df 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -401,7 +401,7 @@ unsigned long __init free_all_bootmem (void)
return(free_all_bootmem_core(NODE_DATA(0)));
}
-void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal)
+void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align, unsigned long goal)
{
bootmem_data_t *bdata;
void *ptr;
@@ -409,7 +409,14 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned
list_for_each_entry(bdata, &bdata_list, list)
if ((ptr = __alloc_bootmem_core(bdata, size, align, goal, 0)))
return(ptr);
+ return NULL;
+}
+void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal)
+{
+ void *mem = __alloc_bootmem_nopanic(size,align,goal);
+ if (mem)
+ return mem;
/*
* Whoops, we cannot satisfy the allocation request.
*/
diff --git a/mm/migrate.c b/mm/migrate.c
index 09f6e4aa87fc4..d444229f25992 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -16,8 +16,7 @@
#include <linux/module.h>
#include <linux/swap.h>
#include <linux/pagemap.h>
-#include <linux/buffer_head.h> /* for try_to_release_page(),
- buffer_heads_over_limit */
+#include <linux/buffer_head.h>
#include <linux/mm_inline.h>
#include <linux/pagevec.h>
#include <linux/rmap.h>
@@ -28,8 +27,6 @@
#include "internal.h"
-#include "internal.h"
-
/* The maximum number of pages to take off the LRU for migration */
#define MIGRATE_CHUNK_SIZE 256
@@ -176,7 +173,6 @@ unlock_retry:
retry:
return -EAGAIN;
}
-EXPORT_SYMBOL(swap_page);
/*
* Remove references for a page and establish the new page with the correct
@@ -234,7 +230,7 @@ int migrate_page_remove_references(struct page *newpage,
if (!page_mapping(page) || page_count(page) != nr_refs ||
*radix_pointer != page) {
write_unlock_irq(&mapping->tree_lock);
- return 1;
+ return -EAGAIN;
}
/*
diff --git a/mm/mmap.c b/mm/mmap.c
index e780d19aa2144..e6ee12344b139 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -121,14 +121,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
* only call if we're about to fail.
*/
n = nr_free_pages();
+
+ /*
+ * Leave reserved pages. The pages are not for anonymous pages.
+ */
+ if (n <= totalreserve_pages)
+ goto error;
+ else
+ n -= totalreserve_pages;
+
+ /*
+ * Leave the last 3% for root
+ */
if (!cap_sys_admin)
n -= n / 32;
free += n;
if (free > pages)
return 0;
- vm_unacct_memory(pages);
- return -ENOMEM;
+
+ goto error;
}
allowed = (totalram_pages - hugetlb_total_pages())
@@ -150,7 +162,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
*/
if (atomic_read(&vm_committed_space) < (long)allowed)
return 0;
-
+error:
vm_unacct_memory(pages);
return -ENOMEM;
@@ -220,6 +232,17 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
if (brk < mm->end_code)
goto out;
+
+ /*
+ * Check against rlimit here. If this check is done later after the test
+ * of oldbrk with newbrk then it can escape the test and let the data
+ * segment grow beyond its set limit the in case where the limit is
+ * not page aligned -Ram Gupta
+ */
+ rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
+ if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
+ goto out;
+
newbrk = PAGE_ALIGN(brk);
oldbrk = PAGE_ALIGN(mm->brk);
if (oldbrk == newbrk)
@@ -232,11 +255,6 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
goto out;
}
- /* Check against rlimit.. */
- rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
- if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
- goto out;
-
/* Check against existing mmap mappings. */
if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE))
goto out;
diff --git a/mm/nommu.c b/mm/nommu.c
index db45efac17cc2..029fadac0fb5d 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1147,14 +1147,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
* only call if we're about to fail.
*/
n = nr_free_pages();
+
+ /*
+ * Leave reserved pages. The pages are not for anonymous pages.
+ */
+ if (n <= totalreserve_pages)
+ goto error;
+ else
+ n -= totalreserve_pages;
+
+ /*
+ * Leave the last 3% for root
+ */
if (!cap_sys_admin)
n -= n / 32;
free += n;
if (free > pages)
return 0;
- vm_unacct_memory(pages);
- return -ENOMEM;
+
+ goto error;
}
allowed = totalram_pages * sysctl_overcommit_ratio / 100;
@@ -1175,7 +1187,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
*/
if (atomic_read(&vm_committed_space) < (long)allowed)
return 0;
-
+error:
vm_unacct_memory(pages);
return -ENOMEM;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 6dcce3a4bbdc6..75d7f48b79bba 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -72,13 +72,12 @@ int dirty_background_ratio = 10;
int vm_dirty_ratio = 40;
/*
- * The interval between `kupdate'-style writebacks, in centiseconds
- * (hundredths of a second)
+ * The interval between `kupdate'-style writebacks, in jiffies
*/
int dirty_writeback_interval = 5 * HZ;
/*
- * The longest number of centiseconds for which data is allowed to remain dirty
+ * The longest number of jiffies for which data is allowed to remain dirty
*/
int dirty_expire_interval = 30 * HZ;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dc523a1f270db..97d6827c7d669 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -51,6 +51,7 @@ nodemask_t node_possible_map __read_mostly = NODE_MASK_ALL;
EXPORT_SYMBOL(node_possible_map);
unsigned long totalram_pages __read_mostly;
unsigned long totalhigh_pages __read_mostly;
+unsigned long totalreserve_pages __read_mostly;
long nr_swap_pages;
int percpu_pagelist_fraction;
@@ -151,7 +152,8 @@ static void bad_page(struct page *page)
1 << PG_reclaim |
1 << PG_slab |
1 << PG_swapcache |
- 1 << PG_writeback );
+ 1 << PG_writeback |
+ 1 << PG_buddy );
set_page_count(page, 0);
reset_page_mapcount(page);
page->mapping = NULL;
@@ -236,12 +238,12 @@ static inline unsigned long page_order(struct page *page) {
static inline void set_page_order(struct page *page, int order) {
set_page_private(page, order);
- __SetPagePrivate(page);
+ __SetPageBuddy(page);
}
static inline void rmv_page_order(struct page *page)
{
- __ClearPagePrivate(page);
+ __ClearPageBuddy(page);
set_page_private(page, 0);
}
@@ -280,11 +282,13 @@ __find_combined_index(unsigned long page_idx, unsigned int order)
* This function checks whether a page is free && is the buddy
* we can do coalesce a page and its buddy if
* (a) the buddy is not in a hole &&
- * (b) the buddy is free &&
- * (c) the buddy is on the buddy system &&
- * (d) a page and its buddy have the same order.
- * for recording page's order, we use page_private(page) and PG_private.
+ * (b) the buddy is in the buddy system &&
+ * (c) a page and its buddy have the same order.
+ *
+ * For recording whether a page is in the buddy system, we use PG_buddy.
+ * Setting, clearing, and testing PG_buddy is serialized by zone->lock.
*
+ * For recording page's order, we use page_private(page).
*/
static inline int page_is_buddy(struct page *page, int order)
{
@@ -293,10 +297,10 @@ static inline int page_is_buddy(struct page *page, int order)
return 0;
#endif
- if (PagePrivate(page) &&
- (page_order(page) == order) &&
- page_count(page) == 0)
+ if (PageBuddy(page) && page_order(page) == order) {
+ BUG_ON(page_count(page) != 0);
return 1;
+ }
return 0;
}
@@ -313,7 +317,7 @@ static inline int page_is_buddy(struct page *page, int order)
* as necessary, plus some accounting needed to play nicely with other
* parts of the VM system.
* At each level, we keep a list of pages, which are heads of continuous
- * free pages of length of (1 << order) and marked with PG_Private.Page's
+ * free pages of length of (1 << order) and marked with PG_buddy. Page's
* order is recorded in page_private(page) field.
* So when we are allocating or freeing one, we can derive the state of the
* other. That is, if we allocate a small block, and both were
@@ -376,7 +380,8 @@ static inline int free_pages_check(struct page *page)
1 << PG_slab |
1 << PG_swapcache |
1 << PG_writeback |
- 1 << PG_reserved ))))
+ 1 << PG_reserved |
+ 1 << PG_buddy ))))
bad_page(page);
if (PageDirty(page))
__ClearPageDirty(page);
@@ -524,7 +529,8 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
1 << PG_slab |
1 << PG_swapcache |
1 << PG_writeback |
- 1 << PG_reserved ))))
+ 1 << PG_reserved |
+ 1 << PG_buddy ))))
bad_page(page);
/*
@@ -2472,6 +2478,38 @@ void __init page_alloc_init(void)
}
/*
+ * calculate_totalreserve_pages - called when sysctl_lower_zone_reserve_ratio
+ * or min_free_kbytes changes.
+ */
+static void calculate_totalreserve_pages(void)
+{
+ struct pglist_data *pgdat;
+ unsigned long reserve_pages = 0;
+ int i, j;
+
+ for_each_online_pgdat(pgdat) {
+ for (i = 0; i < MAX_NR_ZONES; i++) {
+ struct zone *zone = pgdat->node_zones + i;
+ unsigned long max = 0;
+
+ /* Find valid and maximum lowmem_reserve in the zone */
+ for (j = i; j < MAX_NR_ZONES; j++) {
+ if (zone->lowmem_reserve[j] > max)
+ max = zone->lowmem_reserve[j];
+ }
+
+ /* we treat pages_high as reserved pages. */
+ max += zone->pages_high;
+
+ if (max > zone->present_pages)
+ max = zone->present_pages;
+ reserve_pages += max;
+ }
+ }
+ totalreserve_pages = reserve_pages;
+}
+
+/*
* setup_per_zone_lowmem_reserve - called whenever
* sysctl_lower_zone_reserve_ratio changes. Ensures that each zone
* has a correct pages reserved value, so an adequate number of
@@ -2502,6 +2540,9 @@ static void setup_per_zone_lowmem_reserve(void)
}
}
}
+
+ /* update totalreserve_pages */
+ calculate_totalreserve_pages();
}
/*
@@ -2556,6 +2597,9 @@ void setup_per_zone_pages_min(void)
zone->pages_high = zone->pages_min + tmp / 2;
spin_unlock_irqrestore(&zone->lru_lock, flags);
}
+
+ /* update totalreserve_pages */
+ calculate_totalreserve_pages();
}
/*
diff --git a/mm/slab.c b/mm/slab.c
index f055c14202161..e6ef9bd52335b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -420,6 +420,7 @@ struct kmem_cache {
unsigned long max_freeable;
unsigned long node_allocs;
unsigned long node_frees;
+ unsigned long node_overflow;
atomic_t allochit;
atomic_t allocmiss;
atomic_t freehit;
@@ -465,6 +466,7 @@ struct kmem_cache {
#define STATS_INC_ERR(x) ((x)->errors++)
#define STATS_INC_NODEALLOCS(x) ((x)->node_allocs++)
#define STATS_INC_NODEFREES(x) ((x)->node_frees++)
+#define STATS_INC_ACOVERFLOW(x) ((x)->node_overflow++)
#define STATS_SET_FREEABLE(x, i) \
do { \
if ((x)->max_freeable < i) \
@@ -484,6 +486,7 @@ struct kmem_cache {
#define STATS_INC_ERR(x) do { } while (0)
#define STATS_INC_NODEALLOCS(x) do { } while (0)
#define STATS_INC_NODEFREES(x) do { } while (0)
+#define STATS_INC_ACOVERFLOW(x) do { } while (0)
#define STATS_SET_FREEABLE(x, i) do { } while (0)
#define STATS_INC_ALLOCHIT(x) do { } while (0)
#define STATS_INC_ALLOCMISS(x) do { } while (0)
@@ -1453,7 +1456,14 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
int i;
flags |= cachep->gfpflags;
+#ifndef CONFIG_MMU
+ /* nommu uses slab's for process anonymous memory allocations, so
+ * requires __GFP_COMP to properly refcount higher order allocations"
+ */
+ page = alloc_pages_node(nodeid, (flags | __GFP_COMP), cachep->gfporder);
+#else
page = alloc_pages_node(nodeid, flags, cachep->gfporder);
+#endif
if (!page)
return NULL;
addr = page_address(page);
@@ -2318,13 +2328,15 @@ EXPORT_SYMBOL(kmem_cache_destroy);
/* Get the memory for a slab management obj. */
static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
- int colour_off, gfp_t local_flags)
+ int colour_off, gfp_t local_flags,
+ int nodeid)
{
struct slab *slabp;
if (OFF_SLAB(cachep)) {
/* Slab management obj is off-slab. */
- slabp = kmem_cache_alloc(cachep->slabp_cache, local_flags);
+ slabp = kmem_cache_alloc_node(cachep->slabp_cache,
+ local_flags, nodeid);
if (!slabp)
return NULL;
} else {
@@ -2334,6 +2346,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
slabp->inuse = 0;
slabp->colouroff = colour_off;
slabp->s_mem = objp + colour_off;
+ slabp->nodeid = nodeid;
return slabp;
}
@@ -2519,7 +2532,7 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
goto failed;
/* Get slab management. */
- slabp = alloc_slabmgmt(cachep, objp, offset, local_flags);
+ slabp = alloc_slabmgmt(cachep, objp, offset, local_flags, nodeid);
if (!slabp)
goto opps1;
@@ -3080,9 +3093,11 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp)
if (l3->alien && l3->alien[nodeid]) {
alien = l3->alien[nodeid];
spin_lock(&alien->lock);
- if (unlikely(alien->avail == alien->limit))
+ if (unlikely(alien->avail == alien->limit)) {
+ STATS_INC_ACOVERFLOW(cachep);
__drain_alien_cache(cachep,
alien, nodeid);
+ }
alien->entry[alien->avail++] = objp;
spin_unlock(&alien->lock);
} else {
@@ -3760,7 +3775,7 @@ static void print_slabinfo_header(struct seq_file *m)
seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
#if STATS
seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
- "<error> <maxfreeable> <nodeallocs> <remotefrees>");
+ "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
#endif
seq_putc(m, '\n');
@@ -3874,11 +3889,12 @@ static int s_show(struct seq_file *m, void *p)
unsigned long max_freeable = cachep->max_freeable;
unsigned long node_allocs = cachep->node_allocs;
unsigned long node_frees = cachep->node_frees;
+ unsigned long overflows = cachep->node_overflow;
seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu \
- %4lu %4lu %4lu %4lu", allocs, high, grown,
+ %4lu %4lu %4lu %4lu %4lu", allocs, high, grown,
reaped, errors, max_freeable, node_allocs,
- node_frees);
+ node_frees, overflows);
}
/* cpu stats */
{
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 6b61323ce23ca..0c2d13ad69bbf 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -255,7 +255,7 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
}
if ((err = hci_send_sco(conn->hcon, skb)) < 0)
- goto fail;
+ return err;
return count;
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index b7766562d72c0..b0b7f55c1edd3 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -125,9 +125,6 @@ int br_handle_frame(struct net_bridge_port *p, struct sk_buff **pskb)
struct sk_buff *skb = *pskb;
const unsigned char *dest = eth_hdr(skb)->h_dest;
- if (p->state == BR_STATE_DISABLED)
- goto err;
-
if (!is_valid_ether_addr(eth_hdr(skb)->h_source))
goto err;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index f29450b788be1..3da9264449f79 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -765,6 +765,15 @@ out:
return NF_STOLEN;
}
+static int br_nf_dev_queue_xmit(struct sk_buff *skb)
+{
+ if (skb->protocol == htons(ETH_P_IP) &&
+ skb->len > skb->dev->mtu &&
+ !(skb_shinfo(skb)->ufo_size || skb_shinfo(skb)->tso_size))
+ return ip_fragment(skb, br_dev_queue_push_xmit);
+ else
+ return br_dev_queue_push_xmit(skb);
+}
/* PF_BRIDGE/POST_ROUTING ********************************************/
static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
@@ -824,7 +833,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
realoutdev = nf_bridge->netoutdev;
#endif
NF_HOOK(pf, NF_IP_POST_ROUTING, skb, NULL, realoutdev,
- br_dev_queue_push_xmit);
+ br_nf_dev_queue_xmit);
return NF_STOLEN;
@@ -869,7 +878,7 @@ static unsigned int ip_sabotage_out(unsigned int hook, struct sk_buff **pskb,
if ((out->hard_start_xmit == br_dev_xmit &&
okfn != br_nf_forward_finish &&
- okfn != br_nf_local_out_finish && okfn != br_dev_queue_push_xmit)
+ okfn != br_nf_local_out_finish && okfn != br_nf_dev_queue_xmit)
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
|| ((out->priv_flags & IFF_802_1Q_VLAN) &&
VLAN_DEV_INFO(out)->real_dev->hard_start_xmit == br_dev_xmit)
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 01eae97c53d9d..84b9af76f0a23 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -824,12 +824,12 @@ static int translate_table(struct ebt_replace *repl,
if (udc_cnt) {
/* this will get free'd in do_replace()/ebt_register_table()
if an error occurs */
- newinfo->chainstack = (struct ebt_chainstack **)
- vmalloc((highest_possible_processor_id()+1)
- * sizeof(struct ebt_chainstack));
+ newinfo->chainstack =
+ vmalloc((highest_possible_processor_id()+1)
+ * sizeof(*(newinfo->chainstack)));
if (!newinfo->chainstack)
return -ENOMEM;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
newinfo->chainstack[i] =
vmalloc(udc_cnt * sizeof(struct ebt_chainstack));
if (!newinfo->chainstack[i]) {
@@ -901,7 +901,7 @@ static void get_counters(struct ebt_counter *oldcounters,
sizeof(struct ebt_counter) * nentries);
/* add other counters to those of cpu 0 */
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
if (cpu == 0)
continue;
counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
@@ -1036,7 +1036,7 @@ static int do_replace(void __user *user, unsigned int len)
vfree(table->entries);
if (table->chainstack) {
- for_each_cpu(i)
+ for_each_possible_cpu(i)
vfree(table->chainstack[i]);
vfree(table->chainstack);
}
@@ -1054,7 +1054,7 @@ free_counterstmp:
vfree(counterstmp);
/* can be initialized in translate_table() */
if (newinfo->chainstack) {
- for_each_cpu(i)
+ for_each_possible_cpu(i)
vfree(newinfo->chainstack[i]);
vfree(newinfo->chainstack);
}
@@ -1201,7 +1201,7 @@ free_unlock:
mutex_unlock(&ebt_mutex);
free_chainstack:
if (newinfo->chainstack) {
- for_each_cpu(i)
+ for_each_possible_cpu(i)
vfree(newinfo->chainstack[i]);
vfree(newinfo->chainstack);
}
@@ -1224,7 +1224,7 @@ void ebt_unregister_table(struct ebt_table *table)
mutex_unlock(&ebt_mutex);
vfree(table->private->entries);
if (table->private->chainstack) {
- for_each_cpu(i)
+ for_each_possible_cpu(i)
vfree(table->private->chainstack[i]);
vfree(table->private->chainstack);
}
diff --git a/net/core/dev.c b/net/core/dev.c
index 434220d093aae..83231a27ae028 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3042,11 +3042,11 @@ void netdev_run_todo(void)
switch(dev->reg_state) {
case NETREG_REGISTERING:
+ dev->reg_state = NETREG_REGISTERED;
err = netdev_register_sysfs(dev);
if (err)
printk(KERN_ERR "%s: failed sysfs registration (%d)\n",
dev->name, err);
- dev->reg_state = NETREG_REGISTERED;
break;
case NETREG_UNREGISTERING:
@@ -3100,12 +3100,11 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *name,
alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST;
alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
- p = kmalloc(alloc_size, GFP_KERNEL);
+ p = kzalloc(alloc_size, GFP_KERNEL);
if (!p) {
printk(KERN_ERR "alloc_dev: Unable to allocate device.\n");
return NULL;
}
- memset(p, 0, alloc_size);
dev = (struct net_device *)
(((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
@@ -3347,7 +3346,7 @@ static int __init net_dev_init(void)
* Initialise the packet receive queues.
*/
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
struct softnet_data *queue;
queue = &per_cpu(softnet_data, i);
diff --git a/net/core/dv.c b/net/core/dv.c
index cf581407538c4..29ee77f159324 100644
--- a/net/core/dv.c
+++ b/net/core/dv.c
@@ -55,15 +55,12 @@ int alloc_divert_blk(struct net_device *dev)
dev->divert = NULL;
if (dev->type == ARPHRD_ETHER) {
- dev->divert = (struct divert_blk *)
- kmalloc(alloc_size, GFP_KERNEL);
+ dev->divert = kzalloc(alloc_size, GFP_KERNEL);
if (dev->divert == NULL) {
printk(KERN_INFO "divert: unable to allocate divert_blk for %s\n",
dev->name);
return -ENOMEM;
}
-
- memset(dev->divert, 0, sizeof(struct divert_blk));
dev_hold(dev);
}
diff --git a/net/core/flow.c b/net/core/flow.c
index 55789f832edad..2191af5f26acb 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -79,7 +79,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
{
int i;
- for_each_cpu(i)
+ for_each_possible_cpu(i)
flow_hash_rnd_recalc(i) = 1;
flow_hash_rnd_timer.expires = jiffies + FLOW_HASH_RND_PERIOD;
@@ -318,12 +318,10 @@ static void __devinit flow_cache_cpu_prepare(int cpu)
/* NOTHING */;
flow_table(cpu) = (struct flow_cache_entry **)
- __get_free_pages(GFP_KERNEL, order);
+ __get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
if (!flow_table(cpu))
panic("NET: failed to allocate flow cache order %lu\n", order);
- memset(flow_table(cpu), 0, PAGE_SIZE << order);
-
flow_hash_rnd_recalc(cpu) = 1;
flow_count(cpu) = 0;
@@ -363,7 +361,7 @@ static int __init flow_cache_init(void)
flow_hash_rnd_timer.expires = jiffies + FLOW_HASH_RND_PERIOD;
add_timer(&flow_hash_rnd_timer);
- for_each_cpu(i)
+ for_each_possible_cpu(i)
flow_cache_cpu_prepare(i);
hotcpu_notifier(flow_cache_cpu, 0);
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index b07c029e8219e..3cad026764f0c 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -159,11 +159,10 @@ int gen_new_estimator(struct gnet_stats_basic *bstats,
if (parm->interval < -2 || parm->interval > 3)
return -EINVAL;
- est = kmalloc(sizeof(*est), GFP_KERNEL);
+ est = kzalloc(sizeof(*est), GFP_KERNEL);
if (est == NULL)
return -ENOBUFS;
- memset(est, 0, sizeof(*est));
est->interval = parm->interval + 2;
est->bstats = bstats;
est->rate_est = rate_est;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 0c8666872d10f..4cf878efdb49e 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -284,14 +284,11 @@ static struct neighbour **neigh_hash_alloc(unsigned int entries)
struct neighbour **ret;
if (size <= PAGE_SIZE) {
- ret = kmalloc(size, GFP_ATOMIC);
+ ret = kzalloc(size, GFP_ATOMIC);
} else {
ret = (struct neighbour **)
- __get_free_pages(GFP_ATOMIC, get_order(size));
+ __get_free_pages(GFP_ATOMIC|__GFP_ZERO, get_order(size));
}
- if (ret)
- memset(ret, 0, size);
-
return ret;
}
@@ -1089,8 +1086,7 @@ static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst,
if (hh->hh_type == protocol)
break;
- if (!hh && (hh = kmalloc(sizeof(*hh), GFP_ATOMIC)) != NULL) {
- memset(hh, 0, sizeof(struct hh_cache));
+ if (!hh && (hh = kzalloc(sizeof(*hh), GFP_ATOMIC)) != NULL) {
rwlock_init(&hh->hh_lock);
hh->hh_type = protocol;
atomic_set(&hh->hh_refcnt, 0);
@@ -1366,13 +1362,11 @@ void neigh_table_init(struct neigh_table *tbl)
tbl->hash_buckets = neigh_hash_alloc(tbl->hash_mask + 1);
phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *);
- tbl->phash_buckets = kmalloc(phsize, GFP_KERNEL);
+ tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL);
if (!tbl->hash_buckets || !tbl->phash_buckets)
panic("cannot allocate neighbour cache hashes");
- memset(tbl->phash_buckets, 0, phsize);
-
get_random_bytes(&tbl->hash_rnd, sizeof(tbl->hash_rnd));
rwlock_init(&tbl->lock);
@@ -1633,7 +1627,7 @@ static int neightbl_fill_info(struct neigh_table *tbl, struct sk_buff *skb,
memset(&ndst, 0, sizeof(ndst));
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
struct neigh_statistics *st;
st = per_cpu_ptr(tbl->stats, cpu);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 21b68464cabbd..c12990c9c603e 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -165,7 +165,7 @@ static ssize_t show_operstate(struct class_device *dev, char *buf)
operstate = IF_OPER_DOWN;
read_unlock(&dev_base_lock);
- if (operstate >= sizeof(operstates))
+ if (operstate >= ARRAY_SIZE(operstates))
return -EINVAL; /* should not happen */
return sprintf(buf, "%s\n", operstates[operstate]);
diff --git a/net/core/request_sock.c b/net/core/request_sock.c
index 1e44eda1fda9f..79ebd75fbe4de 100644
--- a/net/core/request_sock.c
+++ b/net/core/request_sock.c
@@ -38,13 +38,11 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
{
const int lopt_size = sizeof(struct listen_sock) +
nr_table_entries * sizeof(struct request_sock *);
- struct listen_sock *lopt = kmalloc(lopt_size, GFP_KERNEL);
+ struct listen_sock *lopt = kzalloc(lopt_size, GFP_KERNEL);
if (lopt == NULL)
return -ENOMEM;
- memset(lopt, 0, lopt_size);
-
for (lopt->max_qlen_log = 6;
(1 << lopt->max_qlen_log) < sysctl_max_syn_backlog;
lopt->max_qlen_log++);
diff --git a/net/core/utils.c b/net/core/utils.c
index fdc4f38bc46cc..4f96f389243d7 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -121,7 +121,7 @@ void __init net_random_init(void)
{
int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
struct nrnd_state *state = &per_cpu(net_rand_state,i);
__net_srandom(state, i+jiffies);
}
@@ -133,7 +133,7 @@ static int net_random_reseed(void)
unsigned long seed[NR_CPUS];
get_random_bytes(seed, sizeof(seed));
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
struct nrnd_state *state = &per_cpu(net_rand_state,i);
__net_srandom(state, seed[i]);
}
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 29047995c6957..f2c011fd2ba12 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -498,7 +498,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
goto drop;
if (dccp_parse_options(sk, skb))
- goto drop;
+ goto drop_and_free;
dccp_openreq_init(req, &dp, skb);
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index ccd3efc6a173b..95a639f2e3dbc 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -50,7 +50,7 @@
* Patrick McHardy <kaber@trash.net>
*/
-#define VERSION "0.406"
+#define VERSION "0.407"
#include <linux/config.h>
#include <asm/uaccess.h>
@@ -314,11 +314,6 @@ static void __leaf_free_rcu(struct rcu_head *head)
kfree(container_of(head, struct leaf, rcu));
}
-static inline void free_leaf(struct leaf *leaf)
-{
- call_rcu(&leaf->rcu, __leaf_free_rcu);
-}
-
static void __leaf_info_free_rcu(struct rcu_head *head)
{
kfree(container_of(head, struct leaf_info, rcu));
@@ -357,7 +352,12 @@ static void __tnode_free_rcu(struct rcu_head *head)
static inline void tnode_free(struct tnode *tn)
{
- call_rcu(&tn->rcu, __tnode_free_rcu);
+ if(IS_LEAF(tn)) {
+ struct leaf *l = (struct leaf *) tn;
+ call_rcu_bh(&l->rcu, __leaf_free_rcu);
+ }
+ else
+ call_rcu(&tn->rcu, __tnode_free_rcu);
}
static struct leaf *leaf_new(void)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 9831fd2c73a0a..2a0455911ee0a 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -1107,7 +1107,7 @@ void __init icmp_init(struct net_proto_family *ops)
struct inet_sock *inet;
int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
int err;
err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_ICMP,
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 2a8adda15e119..da734c4391796 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -304,13 +304,17 @@ out:
/* Creation primitives. */
-static struct ipq *ip_frag_intern(unsigned int hash, struct ipq *qp_in)
+static struct ipq *ip_frag_intern(struct ipq *qp_in)
{
struct ipq *qp;
#ifdef CONFIG_SMP
struct hlist_node *n;
#endif
+ unsigned int hash;
+
write_lock(&ipfrag_lock);
+ hash = ipqhashfn(qp_in->id, qp_in->saddr, qp_in->daddr,
+ qp_in->protocol);
#ifdef CONFIG_SMP
/* With SMP race we have to recheck hash table, because
* such entry could be created on other cpu, while we
@@ -345,7 +349,7 @@ static struct ipq *ip_frag_intern(unsigned int hash, struct ipq *qp_in)
}
/* Add an entry to the 'ipq' queue for a newly received IP datagram. */
-static struct ipq *ip_frag_create(unsigned hash, struct iphdr *iph, u32 user)
+static struct ipq *ip_frag_create(struct iphdr *iph, u32 user)
{
struct ipq *qp;
@@ -371,7 +375,7 @@ static struct ipq *ip_frag_create(unsigned hash, struct iphdr *iph, u32 user)
spin_lock_init(&qp->lock);
atomic_set(&qp->refcnt, 1);
- return ip_frag_intern(hash, qp);
+ return ip_frag_intern(qp);
out_nomem:
LIMIT_NETDEBUG(KERN_ERR "ip_frag_create: no memory left !\n");
@@ -387,11 +391,12 @@ static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
__u32 saddr = iph->saddr;
__u32 daddr = iph->daddr;
__u8 protocol = iph->protocol;
- unsigned int hash = ipqhashfn(id, saddr, daddr, protocol);
+ unsigned int hash;
struct ipq *qp;
struct hlist_node *n;
read_lock(&ipfrag_lock);
+ hash = ipqhashfn(id, saddr, daddr, protocol);
hlist_for_each_entry(qp, n, &ipq_hash[hash], list) {
if(qp->id == id &&
qp->saddr == saddr &&
@@ -405,7 +410,7 @@ static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
}
read_unlock(&ipfrag_lock);
- return ip_frag_create(hash, iph, user);
+ return ip_frag_create(iph, user);
}
/* Is the fragment too far ahead to be part of ipq? */
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 9981dcd68f11e..ab99bebdcdc89 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -656,7 +656,7 @@ static int ipgre_rcv(struct sk_buff *skb)
read_unlock(&ipgre_lock);
return(0);
}
- icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PROT_UNREACH, 0);
+ icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
drop:
read_unlock(&ipgre_lock);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index f75ff1d96551d..8dcba3887f04e 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -86,8 +86,6 @@
int sysctl_ip_default_ttl = IPDEFTTL;
-static int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*));
-
/* Generate a checksum for an outgoing IP datagram. */
__inline__ void ip_send_check(struct iphdr *iph)
{
@@ -421,7 +419,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
* single device frame, and queue such a frame for sending.
*/
-static int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
+int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
{
struct iphdr *iph;
int raw = 0;
@@ -673,6 +671,8 @@ fail:
return err;
}
+EXPORT_SYMBOL(ip_fragment);
+
int
ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb)
{
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 0a1d86a0f6328..04a429465665c 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -290,7 +290,7 @@ static void ipcomp_free_scratches(void)
if (!scratches)
return;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
void *scratch = *per_cpu_ptr(scratches, i);
if (scratch)
vfree(scratch);
@@ -313,7 +313,7 @@ static void **ipcomp_alloc_scratches(void)
ipcomp_scratches = scratches;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE);
if (!scratch)
return NULL;
@@ -344,7 +344,7 @@ static void ipcomp_free_tfms(struct crypto_tfm **tfms)
if (!tfms)
return;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
crypto_free_tfm(tfm);
}
@@ -384,7 +384,7 @@ static struct crypto_tfm **ipcomp_alloc_tfms(const char *alg_name)
if (!tfms)
goto error;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0);
if (!tfm)
goto error;
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index eef07b0916a3d..ea398ee43f287 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -474,9 +474,6 @@ static int ipip_rcv(struct sk_buff *skb)
struct iphdr *iph;
struct ip_tunnel *tunnel;
- if (!pskb_may_pull(skb, sizeof(struct iphdr)))
- goto out;
-
iph = skb->nh.iph;
read_lock(&ipip_lock);
@@ -508,7 +505,6 @@ static int ipip_rcv(struct sk_buff *skb)
}
read_unlock(&ipip_lock);
-out:
return -1;
}
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index b5ad9ac2fbcc0..6a9e34b794bc7 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -133,7 +133,7 @@ struct ip_rt_info {
u_int8_t tos;
};
-static void queue_save(const struct sk_buff *skb, struct nf_info *info)
+static void nf_ip_saveroute(const struct sk_buff *skb, struct nf_info *info)
{
struct ip_rt_info *rt_info = nf_info_reroute(info);
@@ -146,7 +146,7 @@ static void queue_save(const struct sk_buff *skb, struct nf_info *info)
}
}
-static int queue_reroute(struct sk_buff **pskb, const struct nf_info *info)
+static int nf_ip_reroute(struct sk_buff **pskb, const struct nf_info *info)
{
const struct ip_rt_info *rt_info = nf_info_reroute(info);
@@ -161,20 +161,54 @@ static int queue_reroute(struct sk_buff **pskb, const struct nf_info *info)
return 0;
}
-static struct nf_queue_rerouter ip_reroute = {
- .rer_size = sizeof(struct ip_rt_info),
- .save = queue_save,
- .reroute = queue_reroute,
+unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
+ unsigned int dataoff, u_int8_t protocol)
+{
+ struct iphdr *iph = skb->nh.iph;
+ unsigned int csum = 0;
+
+ switch (skb->ip_summed) {
+ case CHECKSUM_HW:
+ if (hook != NF_IP_PRE_ROUTING && hook != NF_IP_LOCAL_IN)
+ break;
+ if ((protocol == 0 && !(u16)csum_fold(skb->csum)) ||
+ !csum_tcpudp_magic(iph->saddr, iph->daddr,
+ skb->len - dataoff, protocol,
+ skb->csum)) {
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ break;
+ }
+ /* fall through */
+ case CHECKSUM_NONE:
+ if (protocol == 0)
+ skb->csum = 0;
+ else
+ skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
+ skb->len - dataoff,
+ protocol, 0);
+ csum = __skb_checksum_complete(skb);
+ }
+ return csum;
+}
+
+EXPORT_SYMBOL(nf_ip_checksum);
+
+static struct nf_afinfo nf_ip_afinfo = {
+ .family = AF_INET,
+ .checksum = nf_ip_checksum,
+ .saveroute = nf_ip_saveroute,
+ .reroute = nf_ip_reroute,
+ .route_key_size = sizeof(struct ip_rt_info),
};
static int ipv4_netfilter_init(void)
{
- return nf_register_queue_rerouter(PF_INET, &ip_reroute);
+ return nf_register_afinfo(&nf_ip_afinfo);
}
static void ipv4_netfilter_fini(void)
{
- nf_unregister_queue_rerouter(PF_INET);
+ nf_unregister_afinfo(&nf_ip_afinfo);
}
module_init(ipv4_netfilter_init);
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index 77855ccd6b439..c60fd5c4ea1e5 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -69,6 +69,7 @@ config IP_NF_CONNTRACK_NETLINK
tristate 'Connection tracking netlink interface (EXPERIMENTAL)'
depends on EXPERIMENTAL && IP_NF_CONNTRACK && NETFILTER_NETLINK
depends on IP_NF_CONNTRACK!=y || NETFILTER_NETLINK!=m
+ depends on IP_NF_NAT=n || IP_NF_NAT
help
This option enables support for a netlink-based userspace interface
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index a44a5d73457da..c2d92f99a2b8b 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -646,7 +646,7 @@ static int translate_table(const char *name,
}
/* And one copy for every other CPU */
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
if (newinfo->entries[i] && newinfo->entries[i] != entry0)
memcpy(newinfo->entries[i], entry0, newinfo->size);
}
@@ -696,7 +696,7 @@ static void get_counters(const struct xt_table_info *t,
counters,
&i);
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
if (cpu == curcpu)
continue;
i = 0;
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index d0d379c7df9ab..d7c472faa53b9 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -181,33 +181,26 @@ static struct nf_hook_ops arpt_ops[] = {
static int __init arptable_filter_init(void)
{
- int ret, i;
+ int ret;
/* Register table */
ret = arpt_register_table(&packet_filter, &initial_table.repl);
if (ret < 0)
return ret;
- for (i = 0; i < ARRAY_SIZE(arpt_ops); i++)
- if ((ret = nf_register_hook(&arpt_ops[i])) < 0)
- goto cleanup_hooks;
+ ret = nf_register_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
+ if (ret < 0)
+ goto cleanup_table;
return ret;
-cleanup_hooks:
- while (--i >= 0)
- nf_unregister_hook(&arpt_ops[i]);
-
+cleanup_table:
arpt_unregister_table(&packet_filter);
return ret;
}
static void __exit arptable_filter_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(arpt_ops); i++)
- nf_unregister_hook(&arpt_ops[i]);
-
+ nf_unregister_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
arpt_unregister_table(&packet_filter);
}
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index ceaabc18202b7..979a2eac6f003 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -133,7 +133,7 @@ static void ip_ct_event_cache_flush(void)
struct ip_conntrack_ecache *ecache;
int cpu;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
ecache = &per_cpu(ip_conntrack_ecache, cpu);
if (ecache->ct)
ip_conntrack_put(ecache->ct);
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index daeb1395faa4d..2c2fb700d8353 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -9,37 +9,6 @@
* Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
*
* For more information, please see http://nath323.sourceforge.net/
- *
- * Changes:
- * 2006-02-01 - initial version 0.1
- *
- * 2006-02-20 - version 0.2
- * 1. Changed source format to follow kernel conventions
- * 2. Deleted some unnecessary structures
- * 3. Minor fixes
- *
- * 2006-03-10 - version 0.3
- * 1. Added support for multiple TPKTs in one packet (suggested by
- * Patrick McHardy)
- * 2. Avoid excessive stack usage (based on Patrick McHardy's patch)
- * 3. Added support for non-linear skb (based on Patrick McHardy's patch)
- * 4. Fixed missing H.245 module owner (Patrick McHardy)
- * 5. Avoid long RAS expectation chains (Patrick McHardy)
- * 6. Fixed incorrect __exit attribute (Patrick McHardy)
- * 7. Eliminated unnecessary return code
- * 8. Fixed incorrect use of NAT data from conntrack code (suggested by
- * Patrick McHardy)
- * 9. Fixed TTL calculation error in RCF
- * 10. Added TTL support in RRQ
- * 11. Better support for separate TPKT header and data
- *
- * 2006-03-15 - version 0.4
- * 1. Added support for T.120 channels
- * 2. Added parameter gkrouted_only (suggested by Patrick McHardy)
- * 3. Splitted ASN.1 code and data (suggested by Patrick McHardy)
- * 4. Sort ASN.1 data to avoid forwarding declarations (suggested by
- * Patrick McHardy)
- * 5. Reset next TPKT data length in get_tpkt_data()
*/
#include <linux/config.h>
@@ -54,8 +23,6 @@
#include <linux/netfilter_ipv4/ip_conntrack_h323.h>
#include <linux/moduleparam.h>
-#include "ip_conntrack_helper_h323_asn1.h"
-
#if 0
#define DEBUGP printk
#else
@@ -63,6 +30,10 @@
#endif
/* Parameters */
+static unsigned int default_rrq_ttl = 300;
+module_param(default_rrq_ttl, uint, 0600);
+MODULE_PARM_DESC(default_rrq_ttl, "use this TTL if it's missing in RRQ");
+
static int gkrouted_only = 1;
module_param(gkrouted_only, int, 0600);
MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper");
@@ -222,8 +193,8 @@ static int get_tpkt_data(struct sk_buff **pskb, struct ip_conntrack *ct,
}
/****************************************************************************/
-int get_h245_addr(unsigned char *data, H245_TransportAddress * addr,
- u_int32_t * ip, u_int16_t * port)
+static int get_h245_addr(unsigned char *data, H245_TransportAddress * addr,
+ u_int32_t * ip, u_int16_t * port)
{
unsigned char *p;
@@ -1302,7 +1273,7 @@ static int process_rrq(struct sk_buff **pskb, struct ip_conntrack *ct,
DEBUGP("ip_ct_ras: RRQ TTL = %u seconds\n", rrq->timeToLive);
info->timeout = rrq->timeToLive;
} else
- info->timeout = 0;
+ info->timeout = default_rrq_ttl;
return 0;
}
@@ -1713,18 +1684,17 @@ static int __init init(void)
module_init(init);
module_exit(fini);
-EXPORT_SYMBOL(get_h245_addr);
-EXPORT_SYMBOL(get_h225_addr);
-EXPORT_SYMBOL(ip_conntrack_h245_expect);
-EXPORT_SYMBOL(ip_conntrack_q931_expect);
-EXPORT_SYMBOL(set_h245_addr_hook);
-EXPORT_SYMBOL(set_h225_addr_hook);
-EXPORT_SYMBOL(set_sig_addr_hook);
-EXPORT_SYMBOL(set_ras_addr_hook);
-EXPORT_SYMBOL(nat_rtp_rtcp_hook);
-EXPORT_SYMBOL(nat_t120_hook);
-EXPORT_SYMBOL(nat_h245_hook);
-EXPORT_SYMBOL(nat_q931_hook);
+EXPORT_SYMBOL_GPL(get_h225_addr);
+EXPORT_SYMBOL_GPL(ip_conntrack_h245_expect);
+EXPORT_SYMBOL_GPL(ip_conntrack_q931_expect);
+EXPORT_SYMBOL_GPL(set_h245_addr_hook);
+EXPORT_SYMBOL_GPL(set_h225_addr_hook);
+EXPORT_SYMBOL_GPL(set_sig_addr_hook);
+EXPORT_SYMBOL_GPL(set_ras_addr_hook);
+EXPORT_SYMBOL_GPL(nat_rtp_rtcp_hook);
+EXPORT_SYMBOL_GPL(nat_t120_hook);
+EXPORT_SYMBOL_GPL(nat_h245_hook);
+EXPORT_SYMBOL_GPL(nat_q931_hook);
MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
MODULE_DESCRIPTION("H.323 connection tracking helper");
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c b/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
index afa525129b51a..48078002e4507 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
@@ -15,7 +15,7 @@
#else
#include <stdio.h>
#endif
-#include "ip_conntrack_helper_h323_asn1.h"
+#include <linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h>
/* Trace Flag */
#ifndef H323_TRACE
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
index 3021af0910f11..d8b14a9010a65 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -224,25 +224,14 @@ icmp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
}
/* See ip_conntrack_proto_tcp.c */
- if (hooknum != NF_IP_PRE_ROUTING)
- goto checksum_skipped;
-
- switch (skb->ip_summed) {
- case CHECKSUM_HW:
- if (!(u16)csum_fold(skb->csum))
- break;
- /* fall through */
- case CHECKSUM_NONE:
- skb->csum = 0;
- if (__skb_checksum_complete(skb)) {
- if (LOG_INVALID(IPPROTO_ICMP))
- nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
- "ip_ct_icmp: bad ICMP checksum ");
- return -NF_ACCEPT;
- }
+ if (hooknum == NF_IP_PRE_ROUTING &&
+ nf_ip_checksum(skb, hooknum, skb->nh.iph->ihl * 4, 0)) {
+ if (LOG_INVALID(IPPROTO_ICMP))
+ nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
+ "ip_ct_icmp: bad ICMP checksum ");
+ return -NF_ACCEPT;
}
-checksum_skipped:
/*
* 18 is the highest 'known' ICMP type. Anything else is a mystery
*
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index e0dc370635459..062b252b58ad2 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -870,11 +870,8 @@ static int tcp_error(struct sk_buff *skb,
* and moreover root might send raw packets.
*/
/* FIXME: Source route IP option packets --RR */
- if (hooknum == NF_IP_PRE_ROUTING
- && skb->ip_summed != CHECKSUM_UNNECESSARY
- && csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP,
- skb->ip_summed == CHECKSUM_HW ? skb->csum
- : skb_checksum(skb, iph->ihl*4, tcplen, 0))) {
+ if (hooknum == NF_IP_PRE_ROUTING &&
+ nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_TCP)) {
if (LOG_INVALID(IPPROTO_TCP))
nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
"ip_ct_tcp: bad TCP checksum ");
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_udp.c b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
index 55b7d3210adf9..70899868783bc 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
@@ -120,11 +120,8 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
* because the semantic of CHECKSUM_HW is different there
* and moreover root might send raw packets.
* FIXME: Source route IP option packets --RR */
- if (hooknum == NF_IP_PRE_ROUTING
- && skb->ip_summed != CHECKSUM_UNNECESSARY
- && csum_tcpudp_magic(iph->saddr, iph->daddr, udplen, IPPROTO_UDP,
- skb->ip_summed == CHECKSUM_HW ? skb->csum
- : skb_checksum(skb, iph->ihl*4, udplen, 0))) {
+ if (hooknum == NF_IP_PRE_ROUTING &&
+ nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_UDP)) {
if (LOG_INVALID(IPPROTO_UDP))
nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
"ip_ct_udp: bad UDP checksum ");
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 52076026db368..929d61f7be915 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -469,70 +469,63 @@ static unsigned int ip_conntrack_local(unsigned int hooknum,
/* Connection tracking may drop packets, but never alters them, so
make it the first hook. */
-static struct nf_hook_ops ip_conntrack_defrag_ops = {
- .hook = ip_conntrack_defrag,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_PRE_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
-};
-
-static struct nf_hook_ops ip_conntrack_in_ops = {
- .hook = ip_conntrack_in,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_PRE_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK,
-};
-
-static struct nf_hook_ops ip_conntrack_defrag_local_out_ops = {
- .hook = ip_conntrack_defrag,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_OUT,
- .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
-};
-
-static struct nf_hook_ops ip_conntrack_local_out_ops = {
- .hook = ip_conntrack_local,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_OUT,
- .priority = NF_IP_PRI_CONNTRACK,
-};
-
-/* helpers */
-static struct nf_hook_ops ip_conntrack_helper_out_ops = {
- .hook = ip_conntrack_help,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK_HELPER,
-};
-
-static struct nf_hook_ops ip_conntrack_helper_in_ops = {
- .hook = ip_conntrack_help,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_IN,
- .priority = NF_IP_PRI_CONNTRACK_HELPER,
-};
-
-/* Refragmenter; last chance. */
-static struct nf_hook_ops ip_conntrack_out_ops = {
- .hook = ip_confirm,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
-};
-
-static struct nf_hook_ops ip_conntrack_local_in_ops = {
- .hook = ip_confirm,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_IN,
- .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
+static struct nf_hook_ops ip_conntrack_ops[] = {
+ {
+ .hook = ip_conntrack_defrag,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_PRE_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
+ },
+ {
+ .hook = ip_conntrack_in,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_PRE_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK,
+ },
+ {
+ .hook = ip_conntrack_defrag,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_OUT,
+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
+ },
+ {
+ .hook = ip_conntrack_local,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_OUT,
+ .priority = NF_IP_PRI_CONNTRACK,
+ },
+ {
+ .hook = ip_conntrack_help,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK_HELPER,
+ },
+ {
+ .hook = ip_conntrack_help,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_IN,
+ .priority = NF_IP_PRI_CONNTRACK_HELPER,
+ },
+ {
+ .hook = ip_confirm,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
+ },
+ {
+ .hook = ip_confirm,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_IN,
+ .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
+ },
};
/* Sysctl support */
@@ -783,18 +776,46 @@ static ctl_table ip_ct_net_table[] = {
EXPORT_SYMBOL(ip_ct_log_invalid);
#endif /* CONFIG_SYSCTL */
-static int init_or_cleanup(int init)
+/* FIXME: Allow NULL functions and sub in pointers to generic for
+ them. --RR */
+int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
+{
+ int ret = 0;
+
+ write_lock_bh(&ip_conntrack_lock);
+ if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
+ ret = -EBUSY;
+ goto out;
+ }
+ ip_ct_protos[proto->proto] = proto;
+ out:
+ write_unlock_bh(&ip_conntrack_lock);
+ return ret;
+}
+
+void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
+{
+ write_lock_bh(&ip_conntrack_lock);
+ ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
+ write_unlock_bh(&ip_conntrack_lock);
+
+ /* Somebody could be still looking at the proto in bh. */
+ synchronize_net();
+
+ /* Remove all contrack entries for this protocol */
+ ip_ct_iterate_cleanup(kill_proto, &proto->proto);
+}
+
+static int __init ip_conntrack_standalone_init(void)
{
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc, *proc_exp, *proc_stat;
#endif
int ret = 0;
- if (!init) goto cleanup;
-
ret = ip_conntrack_init();
if (ret < 0)
- goto cleanup_nothing;
+ return ret;
#ifdef CONFIG_PROC_FS
ret = -ENOMEM;
@@ -813,78 +834,25 @@ static int init_or_cleanup(int init)
proc_stat->owner = THIS_MODULE;
#endif
- ret = nf_register_hook(&ip_conntrack_defrag_ops);
+ ret = nf_register_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
if (ret < 0) {
- printk("ip_conntrack: can't register pre-routing defrag hook.\n");
+ printk("ip_conntrack: can't register hooks.\n");
goto cleanup_proc_stat;
}
- ret = nf_register_hook(&ip_conntrack_defrag_local_out_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register local_out defrag hook.\n");
- goto cleanup_defragops;
- }
- ret = nf_register_hook(&ip_conntrack_in_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register pre-routing hook.\n");
- goto cleanup_defraglocalops;
- }
- ret = nf_register_hook(&ip_conntrack_local_out_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register local out hook.\n");
- goto cleanup_inops;
- }
- ret = nf_register_hook(&ip_conntrack_helper_in_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register local in helper hook.\n");
- goto cleanup_inandlocalops;
- }
- ret = nf_register_hook(&ip_conntrack_helper_out_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register postrouting helper hook.\n");
- goto cleanup_helperinops;
- }
- ret = nf_register_hook(&ip_conntrack_out_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register post-routing hook.\n");
- goto cleanup_helperoutops;
- }
- ret = nf_register_hook(&ip_conntrack_local_in_ops);
- if (ret < 0) {
- printk("ip_conntrack: can't register local in hook.\n");
- goto cleanup_inoutandlocalops;
- }
#ifdef CONFIG_SYSCTL
ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table, 0);
if (ip_ct_sysctl_header == NULL) {
printk("ip_conntrack: can't register to sysctl.\n");
ret = -ENOMEM;
- goto cleanup_localinops;
+ goto cleanup_hooks;
}
#endif
-
return ret;
- cleanup:
- synchronize_net();
#ifdef CONFIG_SYSCTL
- unregister_sysctl_table(ip_ct_sysctl_header);
- cleanup_localinops:
+ cleanup_hooks:
+ nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
#endif
- nf_unregister_hook(&ip_conntrack_local_in_ops);
- cleanup_inoutandlocalops:
- nf_unregister_hook(&ip_conntrack_out_ops);
- cleanup_helperoutops:
- nf_unregister_hook(&ip_conntrack_helper_out_ops);
- cleanup_helperinops:
- nf_unregister_hook(&ip_conntrack_helper_in_ops);
- cleanup_inandlocalops:
- nf_unregister_hook(&ip_conntrack_local_out_ops);
- cleanup_inops:
- nf_unregister_hook(&ip_conntrack_in_ops);
- cleanup_defraglocalops:
- nf_unregister_hook(&ip_conntrack_defrag_local_out_ops);
- cleanup_defragops:
- nf_unregister_hook(&ip_conntrack_defrag_ops);
cleanup_proc_stat:
#ifdef CONFIG_PROC_FS
remove_proc_entry("ip_conntrack", proc_net_stat);
@@ -895,48 +863,22 @@ static int init_or_cleanup(int init)
cleanup_init:
#endif /* CONFIG_PROC_FS */
ip_conntrack_cleanup();
- cleanup_nothing:
- return ret;
-}
-
-/* FIXME: Allow NULL functions and sub in pointers to generic for
- them. --RR */
-int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
-{
- int ret = 0;
-
- write_lock_bh(&ip_conntrack_lock);
- if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
- ret = -EBUSY;
- goto out;
- }
- ip_ct_protos[proto->proto] = proto;
- out:
- write_unlock_bh(&ip_conntrack_lock);
return ret;
}
-void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
-{
- write_lock_bh(&ip_conntrack_lock);
- ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
- write_unlock_bh(&ip_conntrack_lock);
-
- /* Somebody could be still looking at the proto in bh. */
- synchronize_net();
-
- /* Remove all contrack entries for this protocol */
- ip_ct_iterate_cleanup(kill_proto, &proto->proto);
-}
-
-static int __init ip_conntrack_standalone_init(void)
-{
- return init_or_cleanup(1);
-}
-
static void __exit ip_conntrack_standalone_fini(void)
{
- init_or_cleanup(0);
+ synchronize_net();
+#ifdef CONFIG_SYSCTL
+ unregister_sysctl_table(ip_ct_sysctl_header);
+#endif
+ nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("ip_conntrack", proc_net_stat);
+ proc_net_remove("ip_conntrack_expect");
+ proc_net_remove("ip_conntrack");
+#endif /* CONFIG_PROC_FS */
+ ip_conntrack_cleanup();
}
module_init(ip_conntrack_standalone_init);
diff --git a/net/ipv4/netfilter/ip_nat_helper_h323.c b/net/ipv4/netfilter/ip_nat_helper_h323.c
index a0bc883928c09..d45663d137a72 100644
--- a/net/ipv4/netfilter/ip_nat_helper_h323.c
+++ b/net/ipv4/netfilter/ip_nat_helper_h323.c
@@ -7,24 +7,6 @@
*
* Based on the 'brute force' H.323 NAT module by
* Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
- *
- * Changes:
- * 2006-02-01 - initial version 0.1
- *
- * 2006-02-20 - version 0.2
- * 1. Changed source format to follow kernel conventions
- * 2. Deleted some unnecessary structures
- * 3. Minor fixes
- *
- * 2006-03-10 - version 0.3
- * 1. Added support for multiple TPKTs in one packet (suggested by
- * Patrick McHardy)
- * 2. Added support for non-linear skb (based on Patrick McHardy's patch)
- * 3. Eliminated unnecessary return code
- *
- * 2006-03-15 - version 0.4
- * 1. Added support for T.120 channels
- * 2. Added parameter gkrouted_only (suggested by Patrick McHardy)
*/
#include <linux/module.h>
@@ -41,65 +23,12 @@
#include <linux/netfilter_ipv4/ip_conntrack_h323.h>
#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
-#include "ip_conntrack_helper_h323_asn1.h"
-
#if 0
#define DEBUGP printk
#else
#define DEBUGP(format, args...)
#endif
-extern int get_h245_addr(unsigned char *data, H245_TransportAddress * addr,
- u_int32_t * ip, u_int16_t * port);
-extern int get_h225_addr(unsigned char *data, TransportAddress * addr,
- u_int32_t * ip, u_int16_t * port);
-extern void ip_conntrack_h245_expect(struct ip_conntrack *new,
- struct ip_conntrack_expect *this);
-extern void ip_conntrack_q931_expect(struct ip_conntrack *new,
- struct ip_conntrack_expect *this);
-extern int (*set_h245_addr_hook) (struct sk_buff ** pskb,
- unsigned char **data, int dataoff,
- H245_TransportAddress * addr,
- u_int32_t ip, u_int16_t port);
-extern int (*set_h225_addr_hook) (struct sk_buff ** pskb,
- unsigned char **data, int dataoff,
- TransportAddress * addr,
- u_int32_t ip, u_int16_t port);
-extern int (*set_sig_addr_hook) (struct sk_buff ** pskb,
- struct ip_conntrack * ct,
- enum ip_conntrack_info ctinfo,
- unsigned char **data,
- TransportAddress * addr, int count);
-extern int (*set_ras_addr_hook) (struct sk_buff ** pskb,
- struct ip_conntrack * ct,
- enum ip_conntrack_info ctinfo,
- unsigned char **data,
- TransportAddress * addr, int count);
-extern int (*nat_rtp_rtcp_hook) (struct sk_buff ** pskb,
- struct ip_conntrack * ct,
- enum ip_conntrack_info ctinfo,
- unsigned char **data, int dataoff,
- H245_TransportAddress * addr,
- u_int16_t port, u_int16_t rtp_port,
- struct ip_conntrack_expect * rtp_exp,
- struct ip_conntrack_expect * rtcp_exp);
-extern int (*nat_t120_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
- enum ip_conntrack_info ctinfo,
- unsigned char **data, int dataoff,
- H245_TransportAddress * addr, u_int16_t port,
- struct ip_conntrack_expect * exp);
-extern int (*nat_h245_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
- enum ip_conntrack_info ctinfo,
- unsigned char **data, int dataoff,
- TransportAddress * addr, u_int16_t port,
- struct ip_conntrack_expect * exp);
-extern int (*nat_q931_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
- enum ip_conntrack_info ctinfo,
- unsigned char **data, TransportAddress * addr,
- int idx, u_int16_t port,
- struct ip_conntrack_expect * exp);
-
-
/****************************************************************************/
static int set_addr(struct sk_buff **pskb,
unsigned char **data, int dataoff,
diff --git a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
index efba8c4e42e03..1aba926c1cb05 100644
--- a/net/ipv4/netfilter/ip_nat_rule.c
+++ b/net/ipv4/netfilter/ip_nat_rule.c
@@ -279,7 +279,7 @@ static struct ipt_target ipt_dnat_reg = {
.target = ipt_dnat_target,
.targetsize = sizeof(struct ip_nat_multi_range_compat),
.table = "nat",
- .hooks = 1 << NF_IP_PRE_ROUTING,
+ .hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT),
.checkentry = ipt_dnat_checkentry,
};
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index 3505b0de2e046..8f760b28617e8 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -299,69 +299,63 @@ ip_nat_adjust(unsigned int hooknum,
/* We must be after connection tracking and before packet filtering. */
-/* Before packet filtering, change destination */
-static struct nf_hook_ops ip_nat_in_ops = {
- .hook = ip_nat_in,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_PRE_ROUTING,
- .priority = NF_IP_PRI_NAT_DST,
+static struct nf_hook_ops ip_nat_ops[] = {
+ /* Before packet filtering, change destination */
+ {
+ .hook = ip_nat_in,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_PRE_ROUTING,
+ .priority = NF_IP_PRI_NAT_DST,
+ },
+ /* After packet filtering, change source */
+ {
+ .hook = ip_nat_out,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_NAT_SRC,
+ },
+ /* After conntrack, adjust sequence number */
+ {
+ .hook = ip_nat_adjust,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
+ },
+ /* Before packet filtering, change destination */
+ {
+ .hook = ip_nat_local_fn,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_OUT,
+ .priority = NF_IP_PRI_NAT_DST,
+ },
+ /* After packet filtering, change source */
+ {
+ .hook = ip_nat_fn,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_IN,
+ .priority = NF_IP_PRI_NAT_SRC,
+ },
+ /* After conntrack, adjust sequence number */
+ {
+ .hook = ip_nat_adjust,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_IN,
+ .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
+ },
};
-/* After packet filtering, change source */
-static struct nf_hook_ops ip_nat_out_ops = {
- .hook = ip_nat_out,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_NAT_SRC,
-};
-
-/* After conntrack, adjust sequence number */
-static struct nf_hook_ops ip_nat_adjust_out_ops = {
- .hook = ip_nat_adjust,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
-};
-
-/* Before packet filtering, change destination */
-static struct nf_hook_ops ip_nat_local_out_ops = {
- .hook = ip_nat_local_fn,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_OUT,
- .priority = NF_IP_PRI_NAT_DST,
-};
-
-/* After packet filtering, change source for reply packets of LOCAL_OUT DNAT */
-static struct nf_hook_ops ip_nat_local_in_ops = {
- .hook = ip_nat_fn,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_IN,
- .priority = NF_IP_PRI_NAT_SRC,
-};
-
-/* After conntrack, adjust sequence number */
-static struct nf_hook_ops ip_nat_adjust_in_ops = {
- .hook = ip_nat_adjust,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_IN,
- .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
-};
-
-
-static int init_or_cleanup(int init)
+static int __init ip_nat_standalone_init(void)
{
int ret = 0;
need_conntrack();
- if (!init) goto cleanup;
-
#ifdef CONFIG_XFRM
BUG_ON(ip_nat_decode_session != NULL);
ip_nat_decode_session = nat_decode_session;
@@ -371,50 +365,13 @@ static int init_or_cleanup(int init)
printk("ip_nat_init: can't setup rules.\n");
goto cleanup_decode_session;
}
- ret = nf_register_hook(&ip_nat_in_ops);
+ ret = nf_register_hooks(ip_nat_ops, ARRAY_SIZE(ip_nat_ops));
if (ret < 0) {
- printk("ip_nat_init: can't register in hook.\n");
+ printk("ip_nat_init: can't register hooks.\n");
goto cleanup_rule_init;
}
- ret = nf_register_hook(&ip_nat_out_ops);
- if (ret < 0) {
- printk("ip_nat_init: can't register out hook.\n");
- goto cleanup_inops;
- }
- ret = nf_register_hook(&ip_nat_adjust_in_ops);
- if (ret < 0) {
- printk("ip_nat_init: can't register adjust in hook.\n");
- goto cleanup_outops;
- }
- ret = nf_register_hook(&ip_nat_adjust_out_ops);
- if (ret < 0) {
- printk("ip_nat_init: can't register adjust out hook.\n");
- goto cleanup_adjustin_ops;
- }
- ret = nf_register_hook(&ip_nat_local_out_ops);
- if (ret < 0) {
- printk("ip_nat_init: can't register local out hook.\n");
- goto cleanup_adjustout_ops;
- }
- ret = nf_register_hook(&ip_nat_local_in_ops);
- if (ret < 0) {
- printk("ip_nat_init: can't register local in hook.\n");
- goto cleanup_localoutops;
- }
return ret;
- cleanup:
- nf_unregister_hook(&ip_nat_local_in_ops);
- cleanup_localoutops:
- nf_unregister_hook(&ip_nat_local_out_ops);
- cleanup_adjustout_ops:
- nf_unregister_hook(&ip_nat_adjust_out_ops);
- cleanup_adjustin_ops:
- nf_unregister_hook(&ip_nat_adjust_in_ops);
- cleanup_outops:
- nf_unregister_hook(&ip_nat_out_ops);
- cleanup_inops:
- nf_unregister_hook(&ip_nat_in_ops);
cleanup_rule_init:
ip_nat_rule_cleanup();
cleanup_decode_session:
@@ -425,14 +382,14 @@ static int init_or_cleanup(int init)
return ret;
}
-static int __init ip_nat_standalone_init(void)
-{
- return init_or_cleanup(1);
-}
-
static void __exit ip_nat_standalone_fini(void)
{
- init_or_cleanup(0);
+ nf_unregister_hooks(ip_nat_ops, ARRAY_SIZE(ip_nat_ops));
+ ip_nat_rule_cleanup();
+#ifdef CONFIG_XFRM
+ ip_nat_decode_session = NULL;
+ synchronize_net();
+#endif
}
module_init(ip_nat_standalone_init);
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 896a244f8f91c..b93f0494362f8 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -662,15 +662,11 @@ static struct nf_queue_handler nfqh = {
.outfn = &ipq_enqueue_packet,
};
-static int
-init_or_cleanup(int init)
+static int __init ip_queue_init(void)
{
int status = -ENOMEM;
struct proc_dir_entry *proc;
- if (!init)
- goto cleanup;
-
netlink_register_notifier(&ipq_nl_notifier);
ipqnl = netlink_kernel_create(NETLINK_FIREWALL, 0, ipq_rcv_sk,
THIS_MODULE);
@@ -697,11 +693,6 @@ init_or_cleanup(int init)
}
return status;
-cleanup:
- nf_unregister_queue_handlers(&nfqh);
- synchronize_net();
- ipq_flush(NF_DROP);
-
cleanup_sysctl:
unregister_sysctl_table(ipq_sysctl_header);
unregister_netdevice_notifier(&ipq_dev_notifier);
@@ -717,15 +708,21 @@ cleanup_netlink_notifier:
return status;
}
-static int __init ip_queue_init(void)
-{
-
- return init_or_cleanup(1);
-}
-
static void __exit ip_queue_fini(void)
{
- init_or_cleanup(0);
+ nf_unregister_queue_handlers(&nfqh);
+ synchronize_net();
+ ipq_flush(NF_DROP);
+
+ unregister_sysctl_table(ipq_sysctl_header);
+ unregister_netdevice_notifier(&ipq_dev_notifier);
+ proc_net_remove(IPQ_PROC_FS_NAME);
+
+ sock_release(ipqnl->sk_socket);
+ mutex_lock(&ipqnl_mutex);
+ mutex_unlock(&ipqnl_mutex);
+
+ netlink_unregister_notifier(&ipq_nl_notifier);
}
MODULE_DESCRIPTION("IPv4 packet queue handler");
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index d5b8cdd361ce8..d25ac8ba6ebae 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -735,7 +735,7 @@ translate_table(const char *name,
}
/* And one copy for every other CPU */
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
if (newinfo->entries[i] && newinfo->entries[i] != entry0)
memcpy(newinfo->entries[i], entry0, newinfo->size);
}
@@ -788,7 +788,7 @@ get_counters(const struct xt_table_info *t,
counters,
&i);
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
if (cpu == curcpu)
continue;
i = 0;
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index e4768a31718b8..aad9d28c8d712 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -725,22 +725,17 @@ static struct file_operations clusterip_proc_fops = {
#endif /* CONFIG_PROC_FS */
-static int init_or_cleanup(int fini)
+static int __init ipt_clusterip_init(void)
{
int ret;
- if (fini)
- goto cleanup;
-
- if (ipt_register_target(&clusterip_tgt)) {
- ret = -EINVAL;
- goto cleanup_none;
- }
+ ret = ipt_register_target(&clusterip_tgt);
+ if (ret < 0)
+ return ret;
- if (nf_register_hook(&cip_arp_ops) < 0) {
- ret = -EINVAL;
+ ret = nf_register_hook(&cip_arp_ops);
+ if (ret < 0)
goto cleanup_target;
- }
#ifdef CONFIG_PROC_FS
clusterip_procdir = proc_mkdir("ipt_CLUSTERIP", proc_net);
@@ -753,31 +748,24 @@ static int init_or_cleanup(int fini)
printk(KERN_NOTICE "ClusterIP Version %s loaded successfully\n",
CLUSTERIP_VERSION);
-
return 0;
-cleanup:
- printk(KERN_NOTICE "ClusterIP Version %s unloading\n",
- CLUSTERIP_VERSION);
-#ifdef CONFIG_PROC_FS
- remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
-#endif
cleanup_hook:
nf_unregister_hook(&cip_arp_ops);
cleanup_target:
ipt_unregister_target(&clusterip_tgt);
-cleanup_none:
- return -EINVAL;
-}
-
-static int __init ipt_clusterip_init(void)
-{
- return init_or_cleanup(0);
+ return ret;
}
static void __exit ipt_clusterip_fini(void)
{
- init_or_cleanup(1);
+ printk(KERN_NOTICE "ClusterIP Version %s unloading\n",
+ CLUSTERIP_VERSION);
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
+#endif
+ nf_unregister_hook(&cip_arp_ops);
+ ipt_unregister_target(&clusterip_tgt);
}
module_init(ipt_clusterip_init);
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index 4269a5440d43a..0bba3c2bb786b 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -106,7 +106,6 @@ static void send_reset(struct sk_buff *oldskb, int hook)
struct rtable *rt;
u_int16_t tmp_port;
u_int32_t tmp_addr;
- unsigned int tcplen;
int needs_ack;
int hh_len;
@@ -124,13 +123,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
return;
/* Check checksum */
- tcplen = oldskb->len - iph->ihl * 4;
- if (((hook != NF_IP_LOCAL_IN && oldskb->ip_summed != CHECKSUM_HW) ||
- (hook == NF_IP_LOCAL_IN &&
- oldskb->ip_summed != CHECKSUM_UNNECESSARY)) &&
- csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP,
- oldskb->ip_summed == CHECKSUM_HW ? oldskb->csum :
- skb_checksum(oldskb, iph->ihl * 4, tcplen, 0)))
+ if (nf_ip_checksum(oldskb, hook, iph->ihl * 4, IPPROTO_TCP))
return;
if ((rt = route_reverse(oldskb, oth, hook)) == NULL)
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
index 3d80aefe9cfa7..7f417484bfbf3 100644
--- a/net/ipv4/netfilter/iptable_filter.c
+++ b/net/ipv4/netfilter/iptable_filter.c
@@ -157,37 +157,20 @@ static int __init iptable_filter_init(void)
return ret;
/* Register hooks */
- ret = nf_register_hook(&ipt_ops[0]);
+ ret = nf_register_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
if (ret < 0)
goto cleanup_table;
- ret = nf_register_hook(&ipt_ops[1]);
- if (ret < 0)
- goto cleanup_hook0;
-
- ret = nf_register_hook(&ipt_ops[2]);
- if (ret < 0)
- goto cleanup_hook1;
-
return ret;
- cleanup_hook1:
- nf_unregister_hook(&ipt_ops[1]);
- cleanup_hook0:
- nf_unregister_hook(&ipt_ops[0]);
cleanup_table:
ipt_unregister_table(&packet_filter);
-
return ret;
}
static void __exit iptable_filter_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(ipt_ops)/sizeof(struct nf_hook_ops); i++)
- nf_unregister_hook(&ipt_ops[i]);
-
+ nf_unregister_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
ipt_unregister_table(&packet_filter);
}
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index 412fc96cc8968..397b95cc026ba 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -211,49 +211,20 @@ static int __init iptable_mangle_init(void)
return ret;
/* Register hooks */
- ret = nf_register_hook(&ipt_ops[0]);
+ ret = nf_register_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
if (ret < 0)
goto cleanup_table;
- ret = nf_register_hook(&ipt_ops[1]);
- if (ret < 0)
- goto cleanup_hook0;
-
- ret = nf_register_hook(&ipt_ops[2]);
- if (ret < 0)
- goto cleanup_hook1;
-
- ret = nf_register_hook(&ipt_ops[3]);
- if (ret < 0)
- goto cleanup_hook2;
-
- ret = nf_register_hook(&ipt_ops[4]);
- if (ret < 0)
- goto cleanup_hook3;
-
return ret;
- cleanup_hook3:
- nf_unregister_hook(&ipt_ops[3]);
- cleanup_hook2:
- nf_unregister_hook(&ipt_ops[2]);
- cleanup_hook1:
- nf_unregister_hook(&ipt_ops[1]);
- cleanup_hook0:
- nf_unregister_hook(&ipt_ops[0]);
cleanup_table:
ipt_unregister_table(&packet_mangler);
-
return ret;
}
static void __exit iptable_mangle_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(ipt_ops)/sizeof(struct nf_hook_ops); i++)
- nf_unregister_hook(&ipt_ops[i]);
-
+ nf_unregister_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
ipt_unregister_table(&packet_mangler);
}
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 03cc79a6160a6..7912cce1e1b8d 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -101,18 +101,18 @@ ipt_hook(unsigned int hook,
/* 'raw' is the very first table. */
static struct nf_hook_ops ipt_ops[] = {
{
- .hook = ipt_hook,
- .pf = PF_INET,
- .hooknum = NF_IP_PRE_ROUTING,
- .priority = NF_IP_PRI_RAW,
- .owner = THIS_MODULE,
+ .hook = ipt_hook,
+ .pf = PF_INET,
+ .hooknum = NF_IP_PRE_ROUTING,
+ .priority = NF_IP_PRI_RAW,
+ .owner = THIS_MODULE,
},
{
- .hook = ipt_hook,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_OUT,
- .priority = NF_IP_PRI_RAW,
- .owner = THIS_MODULE,
+ .hook = ipt_hook,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_OUT,
+ .priority = NF_IP_PRI_RAW,
+ .owner = THIS_MODULE,
},
};
@@ -126,31 +126,20 @@ static int __init iptable_raw_init(void)
return ret;
/* Register hooks */
- ret = nf_register_hook(&ipt_ops[0]);
+ ret = nf_register_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
if (ret < 0)
goto cleanup_table;
- ret = nf_register_hook(&ipt_ops[1]);
- if (ret < 0)
- goto cleanup_hook0;
-
return ret;
- cleanup_hook0:
- nf_unregister_hook(&ipt_ops[0]);
cleanup_table:
ipt_unregister_table(&packet_raw);
-
return ret;
}
static void __exit iptable_raw_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(ipt_ops)/sizeof(struct nf_hook_ops); i++)
- nf_unregister_hook(&ipt_ops[i]);
-
+ nf_unregister_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
ipt_unregister_table(&packet_raw);
}
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 4afbc699d3ba4..5bc9f64d7b5b0 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -210,71 +210,63 @@ static unsigned int ipv4_conntrack_local(unsigned int hooknum,
/* Connection tracking may drop packets, but never alters them, so
make it the first hook. */
-static struct nf_hook_ops ipv4_conntrack_defrag_ops = {
- .hook = ipv4_conntrack_defrag,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_PRE_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
-};
-
-static struct nf_hook_ops ipv4_conntrack_in_ops = {
- .hook = ipv4_conntrack_in,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_PRE_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK,
-};
-
-static struct nf_hook_ops ipv4_conntrack_defrag_local_out_ops = {
- .hook = ipv4_conntrack_defrag,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_OUT,
- .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
-};
-
-static struct nf_hook_ops ipv4_conntrack_local_out_ops = {
- .hook = ipv4_conntrack_local,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_OUT,
- .priority = NF_IP_PRI_CONNTRACK,
-};
-
-/* helpers */
-static struct nf_hook_ops ipv4_conntrack_helper_out_ops = {
- .hook = ipv4_conntrack_help,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK_HELPER,
-};
-
-static struct nf_hook_ops ipv4_conntrack_helper_in_ops = {
- .hook = ipv4_conntrack_help,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_IN,
- .priority = NF_IP_PRI_CONNTRACK_HELPER,
-};
-
-
-/* Refragmenter; last chance. */
-static struct nf_hook_ops ipv4_conntrack_out_ops = {
- .hook = ipv4_confirm,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
-};
-
-static struct nf_hook_ops ipv4_conntrack_local_in_ops = {
- .hook = ipv4_confirm,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_LOCAL_IN,
- .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
+static struct nf_hook_ops ipv4_conntrack_ops[] = {
+ {
+ .hook = ipv4_conntrack_defrag,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_PRE_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
+ },
+ {
+ .hook = ipv4_conntrack_in,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_PRE_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK,
+ },
+ {
+ .hook = ipv4_conntrack_defrag,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_OUT,
+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
+ },
+ {
+ .hook = ipv4_conntrack_local,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_OUT,
+ .priority = NF_IP_PRI_CONNTRACK,
+ },
+ {
+ .hook = ipv4_conntrack_help,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK_HELPER,
+ },
+ {
+ .hook = ipv4_conntrack_help,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_IN,
+ .priority = NF_IP_PRI_CONNTRACK_HELPER,
+ },
+ {
+ .hook = ipv4_confirm,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
+ },
+ {
+ .hook = ipv4_confirm,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_LOCAL_IN,
+ .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
+ },
};
#ifdef CONFIG_SYSCTL
@@ -440,16 +432,20 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = {
extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp4;
extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4;
extern struct nf_conntrack_protocol nf_conntrack_protocol_icmp;
-static int init_or_cleanup(int init)
+
+MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
+MODULE_LICENSE("GPL");
+
+static int __init nf_conntrack_l3proto_ipv4_init(void)
{
int ret = 0;
- if (!init) goto cleanup;
+ need_conntrack();
ret = nf_register_sockopt(&so_getorigdst);
if (ret < 0) {
printk(KERN_ERR "Unable to register netfilter socket option\n");
- goto cleanup_nothing;
+ return ret;
}
ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp4);
@@ -476,84 +472,26 @@ static int init_or_cleanup(int init)
goto cleanup_icmp;
}
- ret = nf_register_hook(&ipv4_conntrack_defrag_ops);
+ ret = nf_register_hooks(ipv4_conntrack_ops,
+ ARRAY_SIZE(ipv4_conntrack_ops));
if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register pre-routing defrag hook.\n");
+ printk("nf_conntrack_ipv4: can't register hooks.\n");
goto cleanup_ipv4;
}
- ret = nf_register_hook(&ipv4_conntrack_defrag_local_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register local_out defrag hook.\n");
- goto cleanup_defragops;
- }
-
- ret = nf_register_hook(&ipv4_conntrack_in_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register pre-routing hook.\n");
- goto cleanup_defraglocalops;
- }
-
- ret = nf_register_hook(&ipv4_conntrack_local_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register local out hook.\n");
- goto cleanup_inops;
- }
-
- ret = nf_register_hook(&ipv4_conntrack_helper_in_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register local helper hook.\n");
- goto cleanup_inandlocalops;
- }
-
- ret = nf_register_hook(&ipv4_conntrack_helper_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register postrouting helper hook.\n");
- goto cleanup_helperinops;
- }
-
- ret = nf_register_hook(&ipv4_conntrack_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register post-routing hook.\n");
- goto cleanup_helperoutops;
- }
-
- ret = nf_register_hook(&ipv4_conntrack_local_in_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv4: can't register local in hook.\n");
- goto cleanup_inoutandlocalops;
- }
-
#ifdef CONFIG_SYSCTL
nf_ct_ipv4_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
if (nf_ct_ipv4_sysctl_header == NULL) {
printk("nf_conntrack: can't register to sysctl.\n");
ret = -ENOMEM;
- goto cleanup_localinops;
+ goto cleanup_hooks;
}
#endif
return ret;
- cleanup:
- synchronize_net();
#ifdef CONFIG_SYSCTL
- unregister_sysctl_table(nf_ct_ipv4_sysctl_header);
- cleanup_localinops:
+ cleanup_hooks:
+ nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
#endif
- nf_unregister_hook(&ipv4_conntrack_local_in_ops);
- cleanup_inoutandlocalops:
- nf_unregister_hook(&ipv4_conntrack_out_ops);
- cleanup_helperoutops:
- nf_unregister_hook(&ipv4_conntrack_helper_out_ops);
- cleanup_helperinops:
- nf_unregister_hook(&ipv4_conntrack_helper_in_ops);
- cleanup_inandlocalops:
- nf_unregister_hook(&ipv4_conntrack_local_out_ops);
- cleanup_inops:
- nf_unregister_hook(&ipv4_conntrack_in_ops);
- cleanup_defraglocalops:
- nf_unregister_hook(&ipv4_conntrack_defrag_local_out_ops);
- cleanup_defragops:
- nf_unregister_hook(&ipv4_conntrack_defrag_ops);
cleanup_ipv4:
nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
cleanup_icmp:
@@ -564,22 +502,21 @@ static int init_or_cleanup(int init)
nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4);
cleanup_sockopt:
nf_unregister_sockopt(&so_getorigdst);
- cleanup_nothing:
return ret;
}
-MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
-MODULE_LICENSE("GPL");
-
-static int __init nf_conntrack_l3proto_ipv4_init(void)
-{
- need_conntrack();
- return init_or_cleanup(1);
-}
-
static void __exit nf_conntrack_l3proto_ipv4_fini(void)
{
- init_or_cleanup(0);
+ synchronize_net();
+#ifdef CONFIG_SYSCTL
+ unregister_sysctl_table(nf_ct_ipv4_sysctl_header);
+#endif
+ nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
+ nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
+ nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmp);
+ nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp4);
+ nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4);
+ nf_unregister_sockopt(&so_getorigdst);
}
module_init(nf_conntrack_l3proto_ipv4_init);
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index 52dc175be39a6..4b0d361cc6e69 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -235,30 +235,14 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff,
}
/* See ip_conntrack_proto_tcp.c */
- if (hooknum != NF_IP_PRE_ROUTING)
- goto checksum_skipped;
-
- switch (skb->ip_summed) {
- case CHECKSUM_HW:
- if (!(u16)csum_fold(skb->csum))
- break;
+ if (hooknum == NF_IP_PRE_ROUTING &&
+ nf_ip_checksum(skb, hooknum, dataoff, 0)) {
if (LOG_INVALID(IPPROTO_ICMP))
nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
"nf_ct_icmp: bad HW ICMP checksum ");
return -NF_ACCEPT;
- case CHECKSUM_NONE:
- if ((u16)csum_fold(skb_checksum(skb, 0, skb->len, 0))) {
- if (LOG_INVALID(IPPROTO_ICMP))
- nf_log_packet(PF_INET, 0, skb, NULL, NULL,
- NULL,
- "nf_ct_icmp: bad ICMP checksum ");
- return -NF_ACCEPT;
- }
- default:
- break;
}
-checksum_skipped:
/*
* 18 is the highest 'known' ICMP type. Anything else is a mystery
*
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 1b167c4bb3beb..d61e2a9d394d2 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -49,7 +49,7 @@ static int fold_prot_inuse(struct proto *proto)
int res = 0;
int cpu;
- for_each_cpu(cpu)
+ for_each_possible_cpu(cpu)
res += proto->stats[cpu].inuse;
return res;
@@ -91,7 +91,7 @@ fold_field(void *mib[], int offt)
unsigned long res = 0;
int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
res += *(((unsigned long *) per_cpu_ptr(mib[0], i)) + offt);
res += *(((unsigned long *) per_cpu_ptr(mib[1], i)) + offt);
}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 94fcbc5e5a1b6..ff434821909f1 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3083,7 +3083,7 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
memcpy(dst, src, length);
/* Add the other cpus in, one int at a time */
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
unsigned int j;
src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index 0d7d386dac228..8d30c48f090e5 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -8,6 +8,8 @@
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
+#include <net/icmp.h>
+#include <net/ip.h>
#include <net/protocol.h>
#include <net/xfrm.h>
@@ -70,10 +72,16 @@ static int tunnel4_rcv(struct sk_buff *skb)
{
struct xfrm_tunnel *handler;
+ if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+ goto drop;
+
for (handler = tunnel4_handlers; handler; handler = handler->next)
if (!handler->handler(skb))
return 0;
+ icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
+
+drop:
kfree_skb(skb);
return 0;
}
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
index e1b8f4b90d802..3e174c83bfe7a 100644
--- a/net/ipv4/xfrm4_input.c
+++ b/net/ipv4/xfrm4_input.c
@@ -37,8 +37,6 @@ static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
{
switch (nexthdr) {
case IPPROTO_IPIP:
- if (!pskb_may_pull(skb, sizeof(struct iphdr)))
- return -EINVAL;
*spi = skb->nh.iph->saddr;
*seq = 0;
return 0;
@@ -90,7 +88,7 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
if (unlikely(x->km.state != XFRM_STATE_VALID))
goto drop_unlock;
- if (x->encap->encap_type != encap_type)
+ if ((x->encap ? x->encap->encap_type : 0) != encap_type)
goto drop_unlock;
if (x->props.replay_window && xfrm_replay_check(x, seq))
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 21eb725e885ff..1044b6fce0d5d 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -717,7 +717,7 @@ int __init icmpv6_init(struct net_proto_family *ops)
struct sock *sk;
int err, i, j;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
&per_cpu(__icmpv6_socket, i));
if (err < 0) {
@@ -763,7 +763,7 @@ void icmpv6_cleanup(void)
{
int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
sock_release(per_cpu(__icmpv6_socket, i));
}
inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index bb8ffb8a14c5d..2ae84c961678f 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -23,6 +23,86 @@
#include <net/inet6_hashtables.h>
#include <net/ip.h>
+void __inet6_hash(struct inet_hashinfo *hashinfo,
+ struct sock *sk)
+{
+ struct hlist_head *list;
+ rwlock_t *lock;
+
+ BUG_TRAP(sk_unhashed(sk));
+
+ if (sk->sk_state == TCP_LISTEN) {
+ list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
+ lock = &hashinfo->lhash_lock;
+ inet_listen_wlock(hashinfo);
+ } else {
+ unsigned int hash;
+ sk->sk_hash = hash = inet6_sk_ehashfn(sk);
+ hash &= (hashinfo->ehash_size - 1);
+ list = &hashinfo->ehash[hash].chain;
+ lock = &hashinfo->ehash[hash].lock;
+ write_lock(lock);
+ }
+
+ __sk_add_node(sk, list);
+ sock_prot_inc_use(sk->sk_prot);
+ write_unlock(lock);
+}
+EXPORT_SYMBOL(__inet6_hash);
+
+/*
+ * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
+ * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM
+ *
+ * The sockhash lock must be held as a reader here.
+ */
+struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
+ const struct in6_addr *saddr,
+ const u16 sport,
+ const struct in6_addr *daddr,
+ const u16 hnum,
+ const int dif)
+{
+ struct sock *sk;
+ const struct hlist_node *node;
+ const __u32 ports = INET_COMBINED_PORTS(sport, hnum);
+ /* Optimize here for direct hit, only listening connections can
+ * have wildcards anyways.
+ */
+ unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport);
+ struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
+
+ prefetch(head->chain.first);
+ read_lock(&head->lock);
+ sk_for_each(sk, node, &head->chain) {
+ /* For IPV6 do the cheaper port and family tests first. */
+ if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif))
+ goto hit; /* You sunk my battleship! */
+ }
+ /* Must check for a TIME_WAIT'er before going to listener hash. */
+ sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
+ const struct inet_timewait_sock *tw = inet_twsk(sk);
+
+ if(*((__u32 *)&(tw->tw_dport)) == ports &&
+ sk->sk_family == PF_INET6) {
+ const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
+
+ if (ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) &&
+ ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) &&
+ (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif))
+ goto hit;
+ }
+ }
+ read_unlock(&head->lock);
+ return NULL;
+
+hit:
+ sock_hold(sk);
+ read_unlock(&head->lock);
+ return sk;
+}
+EXPORT_SYMBOL(__inet6_lookup_established);
+
struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
const struct in6_addr *daddr,
const unsigned short hnum, const int dif)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index ff9040c92556d..a995796b5a577 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -519,9 +519,6 @@ ip6ip6_rcv(struct sk_buff *skb)
struct ipv6hdr *ipv6h;
struct ip6_tnl *t;
- if (!pskb_may_pull(skb, sizeof (*ipv6h)))
- goto discard;
-
ipv6h = skb->nh.ipv6h;
read_lock(&ip6ip6_lock);
@@ -529,8 +526,7 @@ ip6ip6_rcv(struct sk_buff *skb)
if ((t = ip6ip6_tnl_lookup(&ipv6h->saddr, &ipv6h->daddr)) != NULL) {
if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
read_unlock(&ip6ip6_lock);
- kfree_skb(skb);
- return 0;
+ goto discard;
}
if (!(t->parms.flags & IP6_TNL_F_CAP_RCV)) {
@@ -557,9 +553,11 @@ ip6ip6_rcv(struct sk_buff *skb)
return 0;
}
read_unlock(&ip6ip6_lock);
- icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0, skb->dev);
-discard:
return 1;
+
+discard:
+ kfree_skb(skb);
+ return 0;
}
static inline struct ipv6_txoptions *create_tel(__u8 encap_limit)
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 00f3fadfcca7f..05eb67def39f1 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -290,7 +290,7 @@ static void ipcomp6_free_scratches(void)
if (!scratches)
return;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
void *scratch = *per_cpu_ptr(scratches, i);
vfree(scratch);
@@ -313,7 +313,7 @@ static void **ipcomp6_alloc_scratches(void)
ipcomp6_scratches = scratches;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE);
if (!scratch)
return NULL;
@@ -344,7 +344,7 @@ static void ipcomp6_free_tfms(struct crypto_tfm **tfms)
if (!tfms)
return;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
crypto_free_tfm(tfm);
}
@@ -384,7 +384,7 @@ static struct crypto_tfm **ipcomp6_alloc_tfms(const char *alg_name)
if (!tfms)
goto error;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0);
if (!tfm)
goto error;
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index d750cfc019dca..395a417ba9554 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -7,6 +7,7 @@
#include <net/ipv6.h>
#include <net/ip6_route.h>
#include <net/xfrm.h>
+#include <net/ip6_checksum.h>
int ip6_route_me_harder(struct sk_buff *skb)
{
@@ -54,7 +55,7 @@ struct ip6_rt_info {
struct in6_addr saddr;
};
-static void save(const struct sk_buff *skb, struct nf_info *info)
+static void nf_ip6_saveroute(const struct sk_buff *skb, struct nf_info *info)
{
struct ip6_rt_info *rt_info = nf_info_reroute(info);
@@ -66,7 +67,7 @@ static void save(const struct sk_buff *skb, struct nf_info *info)
}
}
-static int reroute(struct sk_buff **pskb, const struct nf_info *info)
+static int nf_ip6_reroute(struct sk_buff **pskb, const struct nf_info *info)
{
struct ip6_rt_info *rt_info = nf_info_reroute(info);
@@ -79,15 +80,50 @@ static int reroute(struct sk_buff **pskb, const struct nf_info *info)
return 0;
}
-static struct nf_queue_rerouter ip6_reroute = {
- .rer_size = sizeof(struct ip6_rt_info),
- .save = &save,
- .reroute = &reroute,
+unsigned int nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
+ unsigned int dataoff, u_int8_t protocol)
+{
+ struct ipv6hdr *ip6h = skb->nh.ipv6h;
+ unsigned int csum = 0;
+
+ switch (skb->ip_summed) {
+ case CHECKSUM_HW:
+ if (hook != NF_IP6_PRE_ROUTING && hook != NF_IP6_LOCAL_IN)
+ break;
+ if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
+ skb->len - dataoff, protocol,
+ csum_sub(skb->csum,
+ skb_checksum(skb, 0,
+ dataoff, 0)))) {
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ break;
+ }
+ /* fall through */
+ case CHECKSUM_NONE:
+ skb->csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
+ skb->len - dataoff,
+ protocol,
+ csum_sub(0,
+ skb_checksum(skb, 0,
+ dataoff, 0)));
+ csum = __skb_checksum_complete(skb);
+ }
+ return csum;
+}
+
+EXPORT_SYMBOL(nf_ip6_checksum);
+
+static struct nf_afinfo nf_ip6_afinfo = {
+ .family = AF_INET6,
+ .checksum = nf_ip6_checksum,
+ .saveroute = nf_ip6_saveroute,
+ .reroute = nf_ip6_reroute,
+ .route_key_size = sizeof(struct ip6_rt_info),
};
int __init ipv6_netfilter_init(void)
{
- return nf_register_queue_rerouter(PF_INET6, &ip6_reroute);
+ return nf_register_afinfo(&nf_ip6_afinfo);
}
/* This can be called from inet6_init() on errors, so it cannot
@@ -95,5 +131,5 @@ int __init ipv6_netfilter_init(void)
*/
void ipv6_netfilter_fini(void)
{
- nf_unregister_queue_rerouter(PF_INET6);
+ nf_unregister_afinfo(&nf_ip6_afinfo);
}
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index e81c6a9dab81d..b4b7d441af254 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -658,15 +658,11 @@ static struct nf_queue_handler nfqh = {
.outfn = &ipq_enqueue_packet,
};
-static int
-init_or_cleanup(int init)
+static int __init ip6_queue_init(void)
{
int status = -ENOMEM;
struct proc_dir_entry *proc;
- if (!init)
- goto cleanup;
-
netlink_register_notifier(&ipq_nl_notifier);
ipqnl = netlink_kernel_create(NETLINK_IP6_FW, 0, ipq_rcv_sk,
THIS_MODULE);
@@ -693,11 +689,6 @@ init_or_cleanup(int init)
}
return status;
-cleanup:
- nf_unregister_queue_handlers(&nfqh);
- synchronize_net();
- ipq_flush(NF_DROP);
-
cleanup_sysctl:
unregister_sysctl_table(ipq_sysctl_header);
unregister_netdevice_notifier(&ipq_dev_notifier);
@@ -713,15 +704,21 @@ cleanup_netlink_notifier:
return status;
}
-static int __init ip6_queue_init(void)
-{
-
- return init_or_cleanup(1);
-}
-
static void __exit ip6_queue_fini(void)
{
- init_or_cleanup(0);
+ nf_unregister_queue_handlers(&nfqh);
+ synchronize_net();
+ ipq_flush(NF_DROP);
+
+ unregister_sysctl_table(ipq_sysctl_header);
+ unregister_netdevice_notifier(&ipq_dev_notifier);
+ proc_net_remove(IPQ_PROC_FS_NAME);
+
+ sock_release(ipqnl->sk_socket);
+ mutex_lock(&ipqnl_mutex);
+ mutex_unlock(&ipqnl_mutex);
+
+ netlink_unregister_notifier(&ipq_nl_notifier);
}
MODULE_DESCRIPTION("IPv6 packet queue handler");
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 3ecf2db841f80..642b4b11464f1 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -788,7 +788,7 @@ translate_table(const char *name,
}
/* And one copy for every other CPU */
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
if (newinfo->entries[i] && newinfo->entries[i] != entry0)
memcpy(newinfo->entries[i], entry0, newinfo->size);
}
@@ -841,7 +841,7 @@ get_counters(const struct xt_table_info *t,
counters,
&i);
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
if (cpu == curcpu)
continue;
i = 0;
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index e5e724d9ee60e..60976c0c58e81 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -177,37 +177,20 @@ static int __init ip6table_filter_init(void)
return ret;
/* Register hooks */
- ret = nf_register_hook(&ip6t_ops[0]);
+ ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
if (ret < 0)
goto cleanup_table;
- ret = nf_register_hook(&ip6t_ops[1]);
- if (ret < 0)
- goto cleanup_hook0;
-
- ret = nf_register_hook(&ip6t_ops[2]);
- if (ret < 0)
- goto cleanup_hook1;
-
return ret;
- cleanup_hook1:
- nf_unregister_hook(&ip6t_ops[1]);
- cleanup_hook0:
- nf_unregister_hook(&ip6t_ops[0]);
cleanup_table:
ip6t_unregister_table(&packet_filter);
-
return ret;
}
static void __exit ip6table_filter_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(ip6t_ops)/sizeof(struct nf_hook_ops); i++)
- nf_unregister_hook(&ip6t_ops[i]);
-
+ nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
ip6t_unregister_table(&packet_filter);
}
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index e1f0f6ae9841e..03a13eab1daef 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -238,49 +238,20 @@ static int __init ip6table_mangle_init(void)
return ret;
/* Register hooks */
- ret = nf_register_hook(&ip6t_ops[0]);
+ ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
if (ret < 0)
goto cleanup_table;
- ret = nf_register_hook(&ip6t_ops[1]);
- if (ret < 0)
- goto cleanup_hook0;
-
- ret = nf_register_hook(&ip6t_ops[2]);
- if (ret < 0)
- goto cleanup_hook1;
-
- ret = nf_register_hook(&ip6t_ops[3]);
- if (ret < 0)
- goto cleanup_hook2;
-
- ret = nf_register_hook(&ip6t_ops[4]);
- if (ret < 0)
- goto cleanup_hook3;
-
return ret;
- cleanup_hook3:
- nf_unregister_hook(&ip6t_ops[3]);
- cleanup_hook2:
- nf_unregister_hook(&ip6t_ops[2]);
- cleanup_hook1:
- nf_unregister_hook(&ip6t_ops[1]);
- cleanup_hook0:
- nf_unregister_hook(&ip6t_ops[0]);
cleanup_table:
ip6t_unregister_table(&packet_mangler);
-
return ret;
}
static void __exit ip6table_mangle_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(ip6t_ops)/sizeof(struct nf_hook_ops); i++)
- nf_unregister_hook(&ip6t_ops[i]);
-
+ nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
ip6t_unregister_table(&packet_mangler);
}
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index 54d1fffd62bac..61a7c58e99f88 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -152,31 +152,20 @@ static int __init ip6table_raw_init(void)
return ret;
/* Register hooks */
- ret = nf_register_hook(&ip6t_ops[0]);
+ ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
if (ret < 0)
goto cleanup_table;
- ret = nf_register_hook(&ip6t_ops[1]);
- if (ret < 0)
- goto cleanup_hook0;
-
return ret;
- cleanup_hook0:
- nf_unregister_hook(&ip6t_ops[0]);
cleanup_table:
ip6t_unregister_table(&packet_raw);
-
return ret;
}
static void __exit ip6table_raw_fini(void)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(ip6t_ops)/sizeof(struct nf_hook_ops); i++)
- nf_unregister_hook(&ip6t_ops[i]);
-
+ nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
ip6t_unregister_table(&packet_raw);
}
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index c8b5a96cbb0f5..93bae36f2663e 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -286,55 +286,49 @@ static unsigned int ipv6_conntrack_local(unsigned int hooknum,
return ipv6_conntrack_in(hooknum, pskb, in, out, okfn);
}
-/* Connection tracking may drop packets, but never alters them, so
- make it the first hook. */
-static struct nf_hook_ops ipv6_conntrack_defrag_ops = {
- .hook = ipv6_defrag,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_PRE_ROUTING,
- .priority = NF_IP6_PRI_CONNTRACK_DEFRAG,
-};
-
-static struct nf_hook_ops ipv6_conntrack_in_ops = {
- .hook = ipv6_conntrack_in,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_PRE_ROUTING,
- .priority = NF_IP6_PRI_CONNTRACK,
-};
-
-static struct nf_hook_ops ipv6_conntrack_local_out_ops = {
- .hook = ipv6_conntrack_local,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_LOCAL_OUT,
- .priority = NF_IP6_PRI_CONNTRACK,
-};
-
-static struct nf_hook_ops ipv6_conntrack_defrag_local_out_ops = {
- .hook = ipv6_defrag,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_LOCAL_OUT,
- .priority = NF_IP6_PRI_CONNTRACK_DEFRAG,
-};
-
-/* Refragmenter; last chance. */
-static struct nf_hook_ops ipv6_conntrack_out_ops = {
- .hook = ipv6_confirm,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_POST_ROUTING,
- .priority = NF_IP6_PRI_LAST,
-};
-
-static struct nf_hook_ops ipv6_conntrack_local_in_ops = {
- .hook = ipv6_confirm,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_LOCAL_IN,
- .priority = NF_IP6_PRI_LAST-1,
+static struct nf_hook_ops ipv6_conntrack_ops[] = {
+ {
+ .hook = ipv6_defrag,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_PRE_ROUTING,
+ .priority = NF_IP6_PRI_CONNTRACK_DEFRAG,
+ },
+ {
+ .hook = ipv6_conntrack_in,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_PRE_ROUTING,
+ .priority = NF_IP6_PRI_CONNTRACK,
+ },
+ {
+ .hook = ipv6_conntrack_local,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_LOCAL_OUT,
+ .priority = NF_IP6_PRI_CONNTRACK,
+ },
+ {
+ .hook = ipv6_defrag,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_LOCAL_OUT,
+ .priority = NF_IP6_PRI_CONNTRACK_DEFRAG,
+ },
+ {
+ .hook = ipv6_confirm,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_POST_ROUTING,
+ .priority = NF_IP6_PRI_LAST,
+ },
+ {
+ .hook = ipv6_confirm,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_LOCAL_IN,
+ .priority = NF_IP6_PRI_LAST-1,
+ },
};
#ifdef CONFIG_SYSCTL
@@ -470,16 +464,21 @@ extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6;
extern struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6;
extern int nf_ct_frag6_init(void);
extern void nf_ct_frag6_cleanup(void);
-static int init_or_cleanup(int init)
+
+MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6));
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>");
+
+static int __init nf_conntrack_l3proto_ipv6_init(void)
{
int ret = 0;
- if (!init) goto cleanup;
+ need_conntrack();
ret = nf_ct_frag6_init();
if (ret < 0) {
printk("nf_conntrack_ipv6: can't initialize frag6.\n");
- goto cleanup_nothing;
+ return ret;
}
ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp6);
if (ret < 0) {
@@ -505,71 +504,27 @@ static int init_or_cleanup(int init)
goto cleanup_icmpv6;
}
- ret = nf_register_hook(&ipv6_conntrack_defrag_ops);
+ ret = nf_register_hooks(ipv6_conntrack_ops,
+ ARRAY_SIZE(ipv6_conntrack_ops));
if (ret < 0) {
printk("nf_conntrack_ipv6: can't register pre-routing defrag "
"hook.\n");
goto cleanup_ipv6;
}
-
- ret = nf_register_hook(&ipv6_conntrack_defrag_local_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv6: can't register local_out defrag "
- "hook.\n");
- goto cleanup_defragops;
- }
-
- ret = nf_register_hook(&ipv6_conntrack_in_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv6: can't register pre-routing hook.\n");
- goto cleanup_defraglocalops;
- }
-
- ret = nf_register_hook(&ipv6_conntrack_local_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv6: can't register local out hook.\n");
- goto cleanup_inops;
- }
-
- ret = nf_register_hook(&ipv6_conntrack_out_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv6: can't register post-routing hook.\n");
- goto cleanup_inandlocalops;
- }
-
- ret = nf_register_hook(&ipv6_conntrack_local_in_ops);
- if (ret < 0) {
- printk("nf_conntrack_ipv6: can't register local in hook.\n");
- goto cleanup_inoutandlocalops;
- }
-
#ifdef CONFIG_SYSCTL
nf_ct_ipv6_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
if (nf_ct_ipv6_sysctl_header == NULL) {
printk("nf_conntrack: can't register to sysctl.\n");
ret = -ENOMEM;
- goto cleanup_localinops;
+ goto cleanup_hooks;
}
#endif
return ret;
- cleanup:
- synchronize_net();
#ifdef CONFIG_SYSCTL
- unregister_sysctl_table(nf_ct_ipv6_sysctl_header);
- cleanup_localinops:
+ cleanup_hooks:
+ nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops));
#endif
- nf_unregister_hook(&ipv6_conntrack_local_in_ops);
- cleanup_inoutandlocalops:
- nf_unregister_hook(&ipv6_conntrack_out_ops);
- cleanup_inandlocalops:
- nf_unregister_hook(&ipv6_conntrack_local_out_ops);
- cleanup_inops:
- nf_unregister_hook(&ipv6_conntrack_in_ops);
- cleanup_defraglocalops:
- nf_unregister_hook(&ipv6_conntrack_defrag_local_out_ops);
- cleanup_defragops:
- nf_unregister_hook(&ipv6_conntrack_defrag_ops);
cleanup_ipv6:
nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6);
cleanup_icmpv6:
@@ -580,23 +535,21 @@ static int init_or_cleanup(int init)
nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp6);
cleanup_frag6:
nf_ct_frag6_cleanup();
- cleanup_nothing:
return ret;
}
-MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6));
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>");
-
-static int __init nf_conntrack_l3proto_ipv6_init(void)
-{
- need_conntrack();
- return init_or_cleanup(1);
-}
-
static void __exit nf_conntrack_l3proto_ipv6_fini(void)
{
- init_or_cleanup(0);
+ synchronize_net();
+#ifdef CONFIG_SYSCTL
+ unregister_sysctl_table(nf_ct_ipv6_sysctl_header);
+#endif
+ nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops));
+ nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6);
+ nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmpv6);
+ nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp6);
+ nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp6);
+ nf_ct_frag6_cleanup();
}
module_init(nf_conntrack_l3proto_ipv6_init);
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 09945c3330552..86c6703265d09 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -233,21 +233,13 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff,
return -NF_ACCEPT;
}
- if (hooknum != NF_IP6_PRE_ROUTING)
- goto skipped;
-
- /* Ignore it if the checksum's bogus. */
- if (csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
- skb->len - dataoff, IPPROTO_ICMPV6,
- skb_checksum(skb, dataoff,
- skb->len - dataoff, 0))) {
+ if (hooknum == NF_IP6_PRE_ROUTING &&
+ nf_ip6_checksum(skb, hooknum, dataoff, IPPROTO_ICMPV6)) {
nf_log_packet(PF_INET6, 0, skb, NULL, NULL, NULL,
"nf_ct_icmpv6: ICMPv6 checksum failed\n");
return -NF_ACCEPT;
}
-skipped:
-
/* is not error message ? */
if (icmp6h->icmp6_type >= 128)
return NF_ACCEPT;
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 4238b1ed88601..779ddf77f4d41 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -38,7 +38,7 @@ static int fold_prot_inuse(struct proto *proto)
int res = 0;
int cpu;
- for_each_cpu(cpu)
+ for_each_possible_cpu(cpu)
res += proto->stats[cpu].inuse;
return res;
@@ -140,7 +140,7 @@ fold_field(void *mib[], int offt)
unsigned long res = 0;
int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt);
res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt);
}
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index b67a45fb93e9d..eef985e010ea7 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -121,6 +121,10 @@ static __inline__ void fq_unlink(struct frag_queue *fq)
write_unlock(&ip6_frag_lock);
}
+/*
+ * callers should be careful not to use the hash value outside the ipfrag_lock
+ * as doing so could race with ipfrag_hash_rnd being recalculated.
+ */
static unsigned int ip6qhashfn(u32 id, struct in6_addr *saddr,
struct in6_addr *daddr)
{
@@ -324,15 +328,16 @@ out:
/* Creation primitives. */
-static struct frag_queue *ip6_frag_intern(unsigned int hash,
- struct frag_queue *fq_in)
+static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in)
{
struct frag_queue *fq;
+ unsigned int hash;
#ifdef CONFIG_SMP
struct hlist_node *n;
#endif
write_lock(&ip6_frag_lock);
+ hash = ip6qhashfn(fq_in->id, &fq_in->saddr, &fq_in->daddr);
#ifdef CONFIG_SMP
hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) {
if (fq->id == fq_in->id &&
@@ -362,7 +367,7 @@ static struct frag_queue *ip6_frag_intern(unsigned int hash,
static struct frag_queue *
-ip6_frag_create(unsigned int hash, u32 id, struct in6_addr *src, struct in6_addr *dst)
+ip6_frag_create(u32 id, struct in6_addr *src, struct in6_addr *dst)
{
struct frag_queue *fq;
@@ -379,7 +384,7 @@ ip6_frag_create(unsigned int hash, u32 id, struct in6_addr *src, struct in6_addr
spin_lock_init(&fq->lock);
atomic_set(&fq->refcnt, 1);
- return ip6_frag_intern(hash, fq);
+ return ip6_frag_intern(fq);
oom:
IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
@@ -391,9 +396,10 @@ fq_find(u32 id, struct in6_addr *src, struct in6_addr *dst)
{
struct frag_queue *fq;
struct hlist_node *n;
- unsigned int hash = ip6qhashfn(id, src, dst);
+ unsigned int hash;
read_lock(&ip6_frag_lock);
+ hash = ip6qhashfn(id, src, dst);
hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) {
if (fq->id == id &&
ipv6_addr_equal(src, &fq->saddr) &&
@@ -405,7 +411,7 @@ fq_find(u32 id, struct in6_addr *src, struct in6_addr *dst)
}
read_unlock(&ip6_frag_lock);
- return ip6_frag_create(hash, id, src, dst);
+ return ip6_frag_create(id, src, dst);
}
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index c2d3e17beae60..6578c3080f477 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -397,7 +397,7 @@ static int ipip6_rcv(struct sk_buff *skb)
return 0;
}
- icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PROT_UNREACH, 0);
+ icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
kfree_skb(skb);
read_unlock(&ipip6_lock);
out:
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c
index 5659b52284bd5..0ef9a35798d13 100644
--- a/net/ipv6/tunnel6.c
+++ b/net/ipv6/tunnel6.c
@@ -19,11 +19,13 @@
* YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
*/
+#include <linux/icmpv6.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
+#include <net/ipv6.h>
#include <net/protocol.h>
#include <net/xfrm.h>
@@ -87,10 +89,16 @@ static int tunnel6_rcv(struct sk_buff **pskb)
struct sk_buff *skb = *pskb;
struct xfrm6_tunnel *handler;
+ if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
+ goto drop;
+
for (handler = tunnel6_handlers; handler; handler = handler->next)
if (!handler->handler(skb))
return 0;
+ icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, skb->dev);
+
+drop:
kfree_skb(skb);
return 0;
}
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 1ceb1a6c254b8..8455a32ea5c4d 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -27,6 +27,29 @@
#include "nf_internals.h"
+static DEFINE_SPINLOCK(afinfo_lock);
+
+struct nf_afinfo *nf_afinfo[NPROTO];
+EXPORT_SYMBOL(nf_afinfo);
+
+int nf_register_afinfo(struct nf_afinfo *afinfo)
+{
+ spin_lock(&afinfo_lock);
+ rcu_assign_pointer(nf_afinfo[afinfo->family], afinfo);
+ spin_unlock(&afinfo_lock);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(nf_register_afinfo);
+
+void nf_unregister_afinfo(struct nf_afinfo *afinfo)
+{
+ spin_lock(&afinfo_lock);
+ rcu_assign_pointer(nf_afinfo[afinfo->family], NULL);
+ spin_unlock(&afinfo_lock);
+ synchronize_rcu();
+}
+EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
+
/* In this code, we can be waiting indefinitely for userspace to
* service a packet if a hook returns NF_QUEUE. We could keep a count
* of skbuffs queued for userspace, and not deregister a hook unless
@@ -63,6 +86,34 @@ void nf_unregister_hook(struct nf_hook_ops *reg)
}
EXPORT_SYMBOL(nf_unregister_hook);
+int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n)
+{
+ unsigned int i;
+ int err = 0;
+
+ for (i = 0; i < n; i++) {
+ err = nf_register_hook(&reg[i]);
+ if (err)
+ goto err;
+ }
+ return err;
+
+err:
+ if (i > 0)
+ nf_unregister_hooks(reg, i);
+ return err;
+}
+EXPORT_SYMBOL(nf_register_hooks);
+
+void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++)
+ nf_unregister_hook(&reg[i]);
+}
+EXPORT_SYMBOL(nf_unregister_hooks);
+
unsigned int nf_iterate(struct list_head *head,
struct sk_buff **skb,
int hook,
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 56389c83557c6..e581190fb6c37 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -146,7 +146,7 @@ static void nf_ct_event_cache_flush(void)
struct nf_conntrack_ecache *ecache;
int cpu;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
ecache = &per_cpu(nf_conntrack_ecache, cpu);
if (ecache->ct)
nf_ct_put(ecache->ct);
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 6492ed66fb3c6..69899f27d26aa 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -799,8 +799,7 @@ static int tcp_error(struct sk_buff *skb,
unsigned int dataoff,
enum ip_conntrack_info *ctinfo,
int pf,
- unsigned int hooknum,
- int(*csum)(const struct sk_buff *,unsigned int))
+ unsigned int hooknum)
{
struct tcphdr _tcph, *th;
unsigned int tcplen = skb->len - dataoff;
@@ -830,9 +829,8 @@ static int tcp_error(struct sk_buff *skb,
*/
/* FIXME: Source route IP option packets --RR */
if (((pf == PF_INET && hooknum == NF_IP_PRE_ROUTING) ||
- (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING))
- && skb->ip_summed != CHECKSUM_UNNECESSARY
- && csum(skb, dataoff)) {
+ (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING)) &&
+ nf_checksum(skb, hooknum, dataoff, IPPROTO_TCP, pf)) {
if (LOG_INVALID(IPPROTO_TCP))
nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
"nf_ct_tcp: bad TCP checksum ");
@@ -851,44 +849,6 @@ static int tcp_error(struct sk_buff *skb,
return NF_ACCEPT;
}
-static int csum4(const struct sk_buff *skb, unsigned int dataoff)
-{
- return csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
- skb->len - dataoff, IPPROTO_TCP,
- skb->ip_summed == CHECKSUM_HW ? skb->csum
- : skb_checksum(skb, dataoff,
- skb->len - dataoff, 0));
-}
-
-static int csum6(const struct sk_buff *skb, unsigned int dataoff)
-{
- return csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
- skb->len - dataoff, IPPROTO_TCP,
- skb->ip_summed == CHECKSUM_HW
- ? csum_sub(skb->csum,
- skb_checksum(skb, 0, dataoff, 0))
- : skb_checksum(skb, dataoff, skb->len - dataoff,
- 0));
-}
-
-static int tcp_error4(struct sk_buff *skb,
- unsigned int dataoff,
- enum ip_conntrack_info *ctinfo,
- int pf,
- unsigned int hooknum)
-{
- return tcp_error(skb, dataoff, ctinfo, pf, hooknum, csum4);
-}
-
-static int tcp_error6(struct sk_buff *skb,
- unsigned int dataoff,
- enum ip_conntrack_info *ctinfo,
- int pf,
- unsigned int hooknum)
-{
- return tcp_error(skb, dataoff, ctinfo, pf, hooknum, csum6);
-}
-
/* Returns verdict for packet, or -1 for invalid. */
static int tcp_packet(struct nf_conn *conntrack,
const struct sk_buff *skb,
@@ -1218,7 +1178,7 @@ struct nf_conntrack_protocol nf_conntrack_protocol_tcp4 =
.print_conntrack = tcp_print_conntrack,
.packet = tcp_packet,
.new = tcp_new,
- .error = tcp_error4,
+ .error = tcp_error,
#if defined(CONFIG_NF_CT_NETLINK) || \
defined(CONFIG_NF_CT_NETLINK_MODULE)
.to_nfattr = tcp_to_nfattr,
@@ -1239,7 +1199,7 @@ struct nf_conntrack_protocol nf_conntrack_protocol_tcp6 =
.print_conntrack = tcp_print_conntrack,
.packet = tcp_packet,
.new = tcp_new,
- .error = tcp_error6,
+ .error = tcp_error,
#if defined(CONFIG_NF_CT_NETLINK) || \
defined(CONFIG_NF_CT_NETLINK_MODULE)
.to_nfattr = tcp_to_nfattr,
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 831d206344e01..d93edbfde9e30 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -103,8 +103,7 @@ static int udp_new(struct nf_conn *conntrack, const struct sk_buff *skb,
static int udp_error(struct sk_buff *skb, unsigned int dataoff,
enum ip_conntrack_info *ctinfo,
int pf,
- unsigned int hooknum,
- int (*csum)(const struct sk_buff *, unsigned int))
+ unsigned int hooknum)
{
unsigned int udplen = skb->len - dataoff;
struct udphdr _hdr, *hdr;
@@ -136,9 +135,8 @@ static int udp_error(struct sk_buff *skb, unsigned int dataoff,
* and moreover root might send raw packets.
* FIXME: Source route IP option packets --RR */
if (((pf == PF_INET && hooknum == NF_IP_PRE_ROUTING) ||
- (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING))
- && skb->ip_summed != CHECKSUM_UNNECESSARY
- && csum(skb, dataoff)) {
+ (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING)) &&
+ nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) {
if (LOG_INVALID(IPPROTO_UDP))
nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
"nf_ct_udp: bad UDP checksum ");
@@ -148,44 +146,6 @@ static int udp_error(struct sk_buff *skb, unsigned int dataoff,
return NF_ACCEPT;
}
-static int csum4(const struct sk_buff *skb, unsigned int dataoff)
-{
- return csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
- skb->len - dataoff, IPPROTO_UDP,
- skb->ip_summed == CHECKSUM_HW ? skb->csum
- : skb_checksum(skb, dataoff,
- skb->len - dataoff, 0));
-}
-
-static int csum6(const struct sk_buff *skb, unsigned int dataoff)
-{
- return csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
- skb->len - dataoff, IPPROTO_UDP,
- skb->ip_summed == CHECKSUM_HW
- ? csum_sub(skb->csum,
- skb_checksum(skb, 0, dataoff, 0))
- : skb_checksum(skb, dataoff, skb->len - dataoff,
- 0));
-}
-
-static int udp_error4(struct sk_buff *skb,
- unsigned int dataoff,
- enum ip_conntrack_info *ctinfo,
- int pf,
- unsigned int hooknum)
-{
- return udp_error(skb, dataoff, ctinfo, pf, hooknum, csum4);
-}
-
-static int udp_error6(struct sk_buff *skb,
- unsigned int dataoff,
- enum ip_conntrack_info *ctinfo,
- int pf,
- unsigned int hooknum)
-{
- return udp_error(skb, dataoff, ctinfo, pf, hooknum, csum6);
-}
-
struct nf_conntrack_protocol nf_conntrack_protocol_udp4 =
{
.l3proto = PF_INET,
@@ -197,7 +157,7 @@ struct nf_conntrack_protocol nf_conntrack_protocol_udp4 =
.print_conntrack = udp_print_conntrack,
.packet = udp_packet,
.new = udp_new,
- .error = udp_error4,
+ .error = udp_error,
#if defined(CONFIG_NF_CT_NETLINK) || \
defined(CONFIG_NF_CT_NETLINK_MODULE)
.tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
@@ -216,7 +176,7 @@ struct nf_conntrack_protocol nf_conntrack_protocol_udp6 =
.print_conntrack = udp_print_conntrack,
.packet = udp_packet,
.new = udp_new,
- .error = udp_error6,
+ .error = udp_error,
#if defined(CONFIG_NF_CT_NETLINK) || \
defined(CONFIG_NF_CT_NETLINK_MODULE)
.tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index c72aa3cd22e4a..408960c6a5444 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -649,63 +649,6 @@ static ctl_table nf_ct_net_table[] = {
EXPORT_SYMBOL(nf_ct_log_invalid);
#endif /* CONFIG_SYSCTL */
-static int init_or_cleanup(int init)
-{
-#ifdef CONFIG_PROC_FS
- struct proc_dir_entry *proc, *proc_exp, *proc_stat;
-#endif
- int ret = 0;
-
- if (!init) goto cleanup;
-
- ret = nf_conntrack_init();
- if (ret < 0)
- goto cleanup_nothing;
-
-#ifdef CONFIG_PROC_FS
- proc = proc_net_fops_create("nf_conntrack", 0440, &ct_file_ops);
- if (!proc) goto cleanup_init;
-
- proc_exp = proc_net_fops_create("nf_conntrack_expect", 0440,
- &exp_file_ops);
- if (!proc_exp) goto cleanup_proc;
-
- proc_stat = create_proc_entry("nf_conntrack", S_IRUGO, proc_net_stat);
- if (!proc_stat)
- goto cleanup_proc_exp;
-
- proc_stat->proc_fops = &ct_cpu_seq_fops;
- proc_stat->owner = THIS_MODULE;
-#endif
-#ifdef CONFIG_SYSCTL
- nf_ct_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
- if (nf_ct_sysctl_header == NULL) {
- printk("nf_conntrack: can't register to sysctl.\n");
- ret = -ENOMEM;
- goto cleanup_proc_stat;
- }
-#endif
-
- return ret;
-
- cleanup:
-#ifdef CONFIG_SYSCTL
- unregister_sysctl_table(nf_ct_sysctl_header);
- cleanup_proc_stat:
-#endif
-#ifdef CONFIG_PROC_FS
- remove_proc_entry("nf_conntrack", proc_net_stat);
- cleanup_proc_exp:
- proc_net_remove("nf_conntrack_expect");
- cleanup_proc:
- proc_net_remove("nf_conntrack");
- cleanup_init:
-#endif /* CNFIG_PROC_FS */
- nf_conntrack_cleanup();
- cleanup_nothing:
- return ret;
-}
-
int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto)
{
int ret = 0;
@@ -808,12 +751,66 @@ void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto)
static int __init nf_conntrack_standalone_init(void)
{
- return init_or_cleanup(1);
+#ifdef CONFIG_PROC_FS
+ struct proc_dir_entry *proc, *proc_exp, *proc_stat;
+#endif
+ int ret = 0;
+
+ ret = nf_conntrack_init();
+ if (ret < 0)
+ return ret;
+
+#ifdef CONFIG_PROC_FS
+ proc = proc_net_fops_create("nf_conntrack", 0440, &ct_file_ops);
+ if (!proc) goto cleanup_init;
+
+ proc_exp = proc_net_fops_create("nf_conntrack_expect", 0440,
+ &exp_file_ops);
+ if (!proc_exp) goto cleanup_proc;
+
+ proc_stat = create_proc_entry("nf_conntrack", S_IRUGO, proc_net_stat);
+ if (!proc_stat)
+ goto cleanup_proc_exp;
+
+ proc_stat->proc_fops = &ct_cpu_seq_fops;
+ proc_stat->owner = THIS_MODULE;
+#endif
+#ifdef CONFIG_SYSCTL
+ nf_ct_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
+ if (nf_ct_sysctl_header == NULL) {
+ printk("nf_conntrack: can't register to sysctl.\n");
+ ret = -ENOMEM;
+ goto cleanup_proc_stat;
+ }
+#endif
+ return ret;
+
+#ifdef CONFIG_SYSCTL
+ cleanup_proc_stat:
+#endif
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("nf_conntrack", proc_net_stat);
+ cleanup_proc_exp:
+ proc_net_remove("nf_conntrack_expect");
+ cleanup_proc:
+ proc_net_remove("nf_conntrack");
+ cleanup_init:
+#endif /* CNFIG_PROC_FS */
+ nf_conntrack_cleanup();
+ return ret;
}
static void __exit nf_conntrack_standalone_fini(void)
{
- init_or_cleanup(0);
+#ifdef CONFIG_SYSCTL
+ unregister_sysctl_table(nf_ct_sysctl_header);
+#endif
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("nf_conntrack", proc_net_stat);
+ proc_net_remove("nf_conntrack_expect");
+ proc_net_remove("nf_conntrack");
+#endif /* CNFIG_PROC_FS */
+ nf_conntrack_cleanup();
}
module_init(nf_conntrack_standalone_init);
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index d9f0d7ef103b6..ee8f70889f47d 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -17,7 +17,6 @@
* for queueing and must reinject all packets it receives, no matter what.
*/
static struct nf_queue_handler *queue_handler[NPROTO];
-static struct nf_queue_rerouter *queue_rerouter[NPROTO];
static DEFINE_RWLOCK(queue_handler_lock);
@@ -59,32 +58,6 @@ int nf_unregister_queue_handler(int pf)
}
EXPORT_SYMBOL(nf_unregister_queue_handler);
-int nf_register_queue_rerouter(int pf, struct nf_queue_rerouter *rer)
-{
- if (pf >= NPROTO)
- return -EINVAL;
-
- write_lock_bh(&queue_handler_lock);
- rcu_assign_pointer(queue_rerouter[pf], rer);
- write_unlock_bh(&queue_handler_lock);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(nf_register_queue_rerouter);
-
-int nf_unregister_queue_rerouter(int pf)
-{
- if (pf >= NPROTO)
- return -EINVAL;
-
- write_lock_bh(&queue_handler_lock);
- rcu_assign_pointer(queue_rerouter[pf], NULL);
- write_unlock_bh(&queue_handler_lock);
- synchronize_rcu();
- return 0;
-}
-EXPORT_SYMBOL_GPL(nf_unregister_queue_rerouter);
-
void nf_unregister_queue_handlers(struct nf_queue_handler *qh)
{
int pf;
@@ -116,7 +89,7 @@ int nf_queue(struct sk_buff **skb,
struct net_device *physindev = NULL;
struct net_device *physoutdev = NULL;
#endif
- struct nf_queue_rerouter *rerouter;
+ struct nf_afinfo *afinfo;
/* QUEUE == DROP if noone is waiting, to be safe. */
read_lock(&queue_handler_lock);
@@ -126,7 +99,14 @@ int nf_queue(struct sk_buff **skb,
return 1;
}
- info = kmalloc(sizeof(*info)+queue_rerouter[pf]->rer_size, GFP_ATOMIC);
+ afinfo = nf_get_afinfo(pf);
+ if (!afinfo) {
+ read_unlock(&queue_handler_lock);
+ kfree_skb(*skb);
+ return 1;
+ }
+
+ info = kmalloc(sizeof(*info) + afinfo->route_key_size, GFP_ATOMIC);
if (!info) {
if (net_ratelimit())
printk(KERN_ERR "OOM queueing packet %p\n",
@@ -158,10 +138,7 @@ int nf_queue(struct sk_buff **skb,
if (physoutdev) dev_hold(physoutdev);
}
#endif
- rerouter = rcu_dereference(queue_rerouter[pf]);
- if (rerouter)
- rerouter->save(*skb, info);
-
+ afinfo->saveroute(*skb, info);
status = queue_handler[pf]->outfn(*skb, info, queuenum,
queue_handler[pf]->data);
@@ -190,7 +167,7 @@ void nf_reinject(struct sk_buff *skb, struct nf_info *info,
{
struct list_head *elem = &info->elem->list;
struct list_head *i;
- struct nf_queue_rerouter *rerouter;
+ struct nf_afinfo *afinfo;
rcu_read_lock();
@@ -228,8 +205,8 @@ void nf_reinject(struct sk_buff *skb, struct nf_info *info,
}
if (verdict == NF_ACCEPT) {
- rerouter = rcu_dereference(queue_rerouter[info->pf]);
- if (rerouter && rerouter->reroute(&skb, info) < 0)
+ afinfo = nf_get_afinfo(info->pf);
+ if (!afinfo || afinfo->reroute(&skb, info) < 0)
verdict = NF_DROP;
}
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 3e3f5448bacb9..c60273cad778e 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -1033,17 +1033,13 @@ static struct file_operations nful_file_ops = {
#endif /* PROC_FS */
-static int
-init_or_cleanup(int init)
+static int __init nfnetlink_log_init(void)
{
int i, status = -ENOMEM;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nful;
#endif
- if (!init)
- goto cleanup;
-
for (i = 0; i < INSTANCE_BUCKETS; i++)
INIT_HLIST_HEAD(&instance_table[i]);
@@ -1066,30 +1062,25 @@ init_or_cleanup(int init)
goto cleanup_subsys;
proc_nful->proc_fops = &nful_file_ops;
#endif
-
return status;
-cleanup:
- nf_log_unregister_logger(&nfulnl_logger);
#ifdef CONFIG_PROC_FS
- remove_proc_entry("nfnetlink_log", proc_net_netfilter);
cleanup_subsys:
-#endif
nfnetlink_subsys_unregister(&nfulnl_subsys);
+#endif
cleanup_netlink_notifier:
netlink_unregister_notifier(&nfulnl_rtnl_notifier);
return status;
}
-static int __init nfnetlink_log_init(void)
-{
-
- return init_or_cleanup(1);
-}
-
static void __exit nfnetlink_log_fini(void)
{
- init_or_cleanup(0);
+ nf_log_unregister_logger(&nfulnl_logger);
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("nfnetlink_log", proc_net_netfilter);
+#endif
+ nfnetlink_subsys_unregister(&nfulnl_subsys);
+ netlink_unregister_notifier(&nfulnl_rtnl_notifier);
}
MODULE_DESCRIPTION("netfilter userspace logging");
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index d0e62f68139fe..86a4ac33de349 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -1071,17 +1071,13 @@ static struct file_operations nfqnl_file_ops = {
#endif /* PROC_FS */
-static int
-init_or_cleanup(int init)
+static int __init nfnetlink_queue_init(void)
{
int i, status = -ENOMEM;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfqueue;
#endif
- if (!init)
- goto cleanup;
-
for (i = 0; i < INSTANCE_BUCKETS; i++)
INIT_HLIST_HEAD(&instance_table[i]);
@@ -1101,31 +1097,26 @@ init_or_cleanup(int init)
#endif
register_netdevice_notifier(&nfqnl_dev_notifier);
-
return status;
-cleanup:
- nf_unregister_queue_handlers(&nfqh);
- unregister_netdevice_notifier(&nfqnl_dev_notifier);
#ifdef CONFIG_PROC_FS
- remove_proc_entry("nfnetlink_queue", proc_net_netfilter);
cleanup_subsys:
-#endif
nfnetlink_subsys_unregister(&nfqnl_subsys);
+#endif
cleanup_netlink_notifier:
netlink_unregister_notifier(&nfqnl_rtnl_notifier);
return status;
}
-static int __init nfnetlink_queue_init(void)
-{
-
- return init_or_cleanup(1);
-}
-
static void __exit nfnetlink_queue_fini(void)
{
- init_or_cleanup(0);
+ nf_unregister_queue_handlers(&nfqh);
+ unregister_netdevice_notifier(&nfqnl_dev_notifier);
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("nfnetlink_queue", proc_net_netfilter);
+#endif
+ nfnetlink_subsys_unregister(&nfqnl_subsys);
+ netlink_unregister_notifier(&nfqnl_rtnl_notifier);
}
MODULE_DESCRIPTION("netfilter packet queue handler");
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index feb8a9e066b08..00cf0a4f4d92a 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -413,7 +413,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
newinfo->size = size;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
if (size <= PAGE_SIZE)
newinfo->entries[cpu] = kmalloc_node(size,
GFP_KERNEL,
@@ -436,7 +436,7 @@ void xt_free_table_info(struct xt_table_info *info)
{
int cpu;
- for_each_cpu(cpu) {
+ for_each_possible_cpu(cpu) {
if (info->size <= PAGE_SIZE)
kfree(info->entries[cpu]);
else
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index fa877f8f652cb..24c348fa89222 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -66,7 +66,7 @@ static __inline__ struct tcf_police * tcf_police_lookup(u32 index)
}
#ifdef CONFIG_NET_CLS_ACT
-static int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
+static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *cb,
int type, struct tc_action *a)
{
struct tcf_police *p;
@@ -113,7 +113,7 @@ rtattr_failure:
}
static inline int
-tcf_hash_search(struct tc_action *a, u32 index)
+tcf_act_police_hash_search(struct tc_action *a, u32 index)
{
struct tcf_police *p = tcf_police_lookup(index);
@@ -387,9 +387,9 @@ static struct tc_action_ops act_police_ops = {
.act = tcf_act_police,
.dump = tcf_act_police_dump,
.cleanup = tcf_act_police_cleanup,
- .lookup = tcf_hash_search,
+ .lookup = tcf_act_police_hash_search,
.init = tcf_act_police_locate,
- .walk = tcf_generic_walker
+ .walk = tcf_act_police_walker
};
static int __init
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index d47a52c303a81..5b3b0e0ae7e50 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -69,7 +69,7 @@ fold_field(void *mib[], int nr)
unsigned long res = 0;
int i;
- for_each_cpu(i) {
+ for_each_possible_cpu(i) {
res +=
*((unsigned long *) (((void *) per_cpu_ptr(mib[0], i)) +
sizeof (unsigned long) * nr));
diff --git a/net/socket.c b/net/socket.c
index b807f360e02cc..23898f45f7137 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -119,10 +119,6 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector,
static ssize_t sock_sendpage(struct file *file, struct page *page,
int offset, size_t size, loff_t *ppos, int more);
-extern ssize_t generic_splice_sendpage(struct inode *inode, struct file *out,
- size_t len, unsigned int flags);
-
-
/*
* Socket files have a set of 'special' operations as well as the generic file ones. These don't appear
* in the operation structures but are done directly via the socketcall() multiplexor.
@@ -2136,7 +2132,7 @@ void socket_seq_show(struct seq_file *seq)
int cpu;
int counter = 0;
- for_each_cpu(cpu)
+ for_each_possible_cpu(cpu)
counter += per_cpu(sockets_in_use, cpu);
/* It can be negative, by the way. 8) */
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 4d7eb9e704da6..d51e316c58210 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -1122,18 +1122,20 @@ svcauth_gss_release(struct svc_rqst *rqstp)
integ_len))
BUG();
if (resbuf->page_len == 0
- && resbuf->tail[0].iov_len + RPC_MAX_AUTH_SIZE
+ && resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE
< PAGE_SIZE) {
BUG_ON(resbuf->tail[0].iov_len);
/* Use head for everything */
resv = &resbuf->head[0];
} else if (resbuf->tail[0].iov_base == NULL) {
- /* copied from nfsd4_encode_read */
- svc_take_page(rqstp);
- resbuf->tail[0].iov_base = page_address(rqstp
- ->rq_respages[rqstp->rq_resused-1]);
- rqstp->rq_restailpage = rqstp->rq_resused-1;
+ if (resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE
+ > PAGE_SIZE)
+ goto out_err;
+ resbuf->tail[0].iov_base =
+ resbuf->head[0].iov_base
+ + resbuf->head[0].iov_len;
resbuf->tail[0].iov_len = 0;
+ rqstp->rq_restailpage = 0;
resv = &resbuf->tail[0];
} else {
resv = &resbuf->tail[0];
diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
index 8b9bf4a763b55..b1265187b4a8f 100644
--- a/net/wanrouter/af_wanpipe.c
+++ b/net/wanrouter/af_wanpipe.c
@@ -55,12 +55,10 @@
#include <asm/uaccess.h>
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/wanpipe.h>
#include <linux/if_wanpipe.h>
#include <linux/pkt_sched.h>
#include <linux/tcp_states.h>
#include <linux/if_wanpipe_common.h>
-#include <linux/sdla_x25.h>
#ifdef CONFIG_INET
#include <net/inet_common.h>
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 59620b1554e02..b0d067be73905 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -87,6 +87,11 @@ cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
# $(Q)$(MAKE) $(build)=dir
build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+# Prefix -I with $(srctree) if it is not an absolute path
+addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
+# Find all -I options and call addtree
+flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
+
# If quiet is set, only print short version of command
cmd = @$(echo-cmd) $(cmd_$(1))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 550798f57da50..2cb4935e85d1b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -99,11 +99,6 @@ __a_flags = $(_a_flags)
__cpp_flags = $(_cpp_flags)
else
-# Prefix -I with $(srctree) if it is not an absolute path
-addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
-# Find all -I options and call addtree
-flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
-
# -I$(obj) locates generated .h files
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
# and locates generated .h files
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 75f21d843c1d5..75f21d843c1d5 100644..100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index dadfa20ffec01..dadfa20ffec01 100644..100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 6d411169bfa62..56b3bed1108f4 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -1,22 +1,55 @@
#!/bin/bash
# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
-# Released under the terms of the GNU GPL
-#
-# Generate a newline separated list of entries from the file/directory
-# supplied as an argument.
-#
-# If a file/directory is not supplied then generate a small dummy file.
+# Copyright (c) 2006 Sam Ravnborg <sam@ravnborg.org>
#
-# The output is suitable for gen_init_cpio built from usr/gen_init_cpio.c.
+# Released under the terms of the GNU GPL
#
+# Generate a cpio packed initramfs. It uses gen_init_cpio to generate
+# the cpio archive, and gzip to pack it.
+# The script may also be used to generate the inputfile used for gen_init_cpio
+# This script assumes that gen_init_cpio is located in usr/ directory
+
+# error out on errors
+set -e
+
+usage() {
+cat << EOF
+Usage:
+$0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
+ -o <file> Create gzipped initramfs file named <file> using
+ gen_init_cpio and gzip
+ -u <uid> User ID to map to user ID 0 (root).
+ <uid> is only meaningful if <cpio_source>
+ is a directory.
+ -g <gid> Group ID to map to group ID 0 (root).
+ <gid> is only meaningful if <cpio_source>
+ is a directory.
+ <cpio_source> File list or directory for cpio archive.
+ If <cpio_source> is a .cpio file it will be used
+ as direct input to initramfs.
+ -d Output the default cpio list.
+
+All options except -o and -l may be repeated and are interpreted
+sequentially and immediately. -u and -g states are preserved across
+<cpio_source> options so an explicit "-u 0 -g 0" is required
+to reset the root/group mapping.
+EOF
+}
+
+list_default_initramfs() {
+ # echo usr/kinit/kinit
+ :
+}
default_initramfs() {
- cat <<-EOF
+ cat <<-EOF >> ${output}
# This is a very simple, default initramfs
dir /dev 0755 0 0
nod /dev/console 0600 0 0 c 5 1
dir /root 0700 0 0
+ # file /kinit usr/kinit/kinit 0755 0 0
+ # slink /init kinit 0755 0 0
EOF
}
@@ -42,18 +75,28 @@ filetype() {
return 0
}
+list_print_mtime() {
+ :
+}
+
print_mtime() {
- local argv1="$1"
local my_mtime="0"
- if [ -e "${argv1}" ]; then
- my_mtime=$(find "${argv1}" -printf "%T@\n" | sort -r | head -n 1)
+ if [ -e "$1" ]; then
+ my_mtime=$(find "$1" -printf "%T@\n" | sort -r | head -n 1)
fi
-
- echo "# Last modified: ${my_mtime}"
- echo
+
+ echo "# Last modified: ${my_mtime}" >> ${output}
+ echo "" >> ${output}
+}
+
+list_parse() {
+ echo "$1 \\"
}
+# for each file print a line in following format
+# <filetype> <name> <path to file> <octal mode> <uid> <gid>
+# for links, devices etc the format differs. See gen_init_cpio for details
parse() {
local location="$1"
local name="${location/${srcdir}//}"
@@ -99,80 +142,112 @@ parse() {
;;
esac
- echo "${str}"
+ echo "${str}" >> ${output}
return 0
}
-usage() {
- printf "Usage:\n"
- printf "$0 [ [-u <root_uid>] [-g <root_gid>] [-d | <cpio_source>] ] . . .\n"
- printf "\n"
- printf -- "-u <root_uid> User ID to map to user ID 0 (root).\n"
- printf " <root_uid> is only meaningful if <cpio_source>\n"
- printf " is a directory.\n"
- printf -- "-g <root_gid> Group ID to map to group ID 0 (root).\n"
- printf " <root_gid> is only meaningful if <cpio_source>\n"
- printf " is a directory.\n"
- printf "<cpio_source> File list or directory for cpio archive.\n"
- printf " If <cpio_source> is not provided then a\n"
- printf " a default list will be output.\n"
- printf -- "-d Output the default cpio list. If no <cpio_source>\n"
- printf " is given then the default cpio list will be output.\n"
- printf "\n"
- printf "All options may be repeated and are interpreted sequentially\n"
- printf "and immediately. -u and -g states are preserved across\n"
- printf "<cpio_source> options so an explicit \"-u 0 -g 0\" is required\n"
- printf "to reset the root/group mapping.\n"
+unknown_option() {
+ printf "ERROR: unknown option \"$arg\"\n" >&2
+ printf "If the filename validly begins with '-', " >&2
+ printf "then it must be prefixed\n" >&2
+ printf "by './' so that it won't be interpreted as an option." >&2
+ printf "\n" >&2
+ usage >&2
+ exit 1
+}
+
+list_header() {
+ echo "deps_initramfs := \\"
+}
+
+header() {
+ printf "\n#####################\n# $1\n" >> ${output}
+}
+
+# process one directory (incl sub-directories)
+dir_filelist() {
+ ${dep_list}header "$1"
+
+ srcdir=$(echo "$1" | sed -e 's://*:/:g')
+ dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+ # If $dirlist is only one line, then the directory is empty
+ if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+ ${dep_list}print_mtime "$1"
+
+ echo "${dirlist}" | \
+ while read x; do
+ ${dep_list}parse ${x}
+ done
+ fi
}
-build_list() {
- printf "\n#####################\n# $cpio_source\n"
-
- if [ -f "$cpio_source" ]; then
- print_mtime "$cpio_source"
- cat "$cpio_source"
- elif [ -d "$cpio_source" ]; then
- srcdir=$(echo "$cpio_source" | sed -e 's://*:/:g')
- dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
-
- # If $dirlist is only one line, then the directory is empty
- if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
- print_mtime "$cpio_source"
-
- echo "${dirlist}" | \
- while read x; do
- parse ${x}
- done
+# if only one file is specified and it is .cpio file then use it direct as fs
+# if a directory is specified then add all files in given direcotry to fs
+# if a regular file is specified assume it is in gen_initramfs format
+input_file() {
+ source="$1"
+ if [ -f "$1" ]; then
+ ${dep_list}header "$1"
+ is_cpio="$(echo "$1" | sed 's/^.*\.cpio/cpio/')"
+ if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then
+ cpio_file=$1
+ [ ! -z ${dep_list} ] && echo "$1"
+ return 0
+ fi
+ if [ -z ${dep_list} ]; then
+ print_mtime "$1" >> ${output}
+ cat "$1" >> ${output}
else
- # Failsafe in case directory is empty
- default_initramfs
+ grep ^file "$1" | cut -d ' ' -f 3
fi
+ elif [ -d "$1" ]; then
+ dir_filelist "$1"
else
- echo " $0: Cannot open '$cpio_source'" >&2
+ echo " ${prog}: Cannot open '$1'" >&2
exit 1
fi
}
-
+prog=$0
root_uid=0
root_gid=0
+dep_list=
+cpio_file=
+cpio_list=
+output="/dev/stdout"
+output_file=""
+arg="$1"
+case "$arg" in
+ "-l") # files included in initramfs - used by kbuild
+ dep_list="list_"
+ shift
+ ;;
+ "-o") # generate gzipped cpio image named $1
+ shift
+ output_file="$1"
+ cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
+ output=${cpio_list}
+ shift
+ ;;
+esac
while [ $# -gt 0 ]; do
arg="$1"
shift
case "$arg" in
- "-u")
+ "-u") # map $1 to uid=0 (root)
root_uid="$1"
shift
;;
- "-g")
+ "-g") # map $1 to gid=0 (root)
root_gid="$1"
shift
;;
- "-d")
+ "-d") # display default initramfs list
default_list="$arg"
- default_initramfs
+ ${dep_list}default_initramfs
;;
"-h")
usage
@@ -181,23 +256,27 @@ while [ $# -gt 0 ]; do
*)
case "$arg" in
"-"*)
- printf "ERROR: unknown option \"$arg\"\n" >&2
- printf "If the filename validly begins with '-', then it must be prefixed\n" >&2
- printf "by './' so that it won't be interpreted as an option." >&2
- printf "\n" >&2
- usage >&2
- exit 1
+ unknown_option
;;
- *)
- cpio_source="$arg"
- build_list
+ *) # input file/dir - process it
+ input_file "$arg" "$#"
;;
esac
;;
esac
done
-# spit out the default cpio list if a source hasn't been specified
-[ -z "$cpio_source" -a -z "$default_list" ] && default_initramfs
-
+# If output_file is set we will generate cpio archive and gzip it
+# we are carefull to delete tmp files
+if [ ! -z ${output_file} ]; then
+ if [ -z ${cpio_file} ]; then
+ cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)"
+ usr/gen_init_cpio ${cpio_list} > ${cpio_tfile}
+ else
+ cpio_tfile=${cpio_file}
+ fi
+ rm ${cpio_list}
+ cat ${cpio_tfile} | gzip -f -9 - > ${output_file}
+ [ -z ${cpio_file} ] && rm ${cpio_tfile}
+fi
exit 0
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 10eeae53d827f..ae5ab981bb1d1 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -63,20 +63,6 @@ static void check_stdin(void)
}
}
-static char *fgets_check_stream(char *s, int size, FILE *stream)
-{
- char *ret = fgets(s, size, stream);
-
- if (ret == NULL && feof(stream)) {
- printf(_("aborted!\n\n"));
- printf(_("Console input is closed. "));
- printf(_("Run 'make oldconfig' to update configuration.\n\n"));
- exit(1);
- }
-
- return ret;
-}
-
static void conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
@@ -114,7 +100,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
check_stdin();
case ask_all:
fflush(stdout);
- fgets_check_stream(line, 128, stdin);
+ fgets(line, 128, stdin);
return;
case set_default:
printf("%s\n", def);
@@ -328,8 +314,7 @@ static int conf_choice(struct menu *menu)
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
- line[0] = '0';
- line[1] = 0;
+ line[0] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
@@ -370,7 +355,7 @@ static int conf_choice(struct menu *menu)
check_stdin();
case ask_all:
fflush(stdout);
- fgets_check_stream(line, 128, stdin);
+ fgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
printf("\n%s\n", menu->sym->help ?
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 1b8882ddbc74f..1b5df589f3aec 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -325,7 +325,7 @@ int conf_read(const char *name)
sym->flags |= e->right.sym->flags & SYMBOL_NEW;
}
- sym_change_count = conf_warnings && conf_unsaved;
+ sym_change_count = conf_warnings || conf_unsaved;
return 0;
}
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 09512b5443759..bf8052f4fd4ab 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -58,8 +58,7 @@
#include "dialog.h"
-#define ITEM_IDENT 1 /* Indent of menu entries. Fixed for all menus */
-static int menu_width;
+static int menu_width, item_x;
/*
* Print menu item
@@ -70,7 +69,7 @@ static void do_print_item(WINDOW * win, const char *item, int choice,
int j;
char *menu_item = malloc(menu_width + 1);
- strncpy(menu_item, item, menu_width - ITEM_IDENT);
+ strncpy(menu_item, item, menu_width - item_x);
menu_item[menu_width] = 0;
j = first_alpha(menu_item, "YyNnMmHh");
@@ -87,13 +86,13 @@ static void do_print_item(WINDOW * win, const char *item, int choice,
wclrtoeol(win);
#endif
wattrset(win, selected ? item_selected_attr : item_attr);
- mvwaddstr(win, choice, ITEM_IDENT, menu_item);
+ mvwaddstr(win, choice, item_x, menu_item);
if (hotkey) {
wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
- mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]);
+ mvwaddch(win, choice, item_x + j, menu_item[j]);
}
if (selected) {
- wmove(win, choice, ITEM_IDENT + 1);
+ wmove(win, choice, item_x + 1);
}
free(menu_item);
wrefresh(win);
@@ -227,6 +226,8 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
menubox_border_attr, menubox_attr);
+ item_x = (menu_width - 70) / 2;
+
/* Set choice to default item */
for (i = 0; i < item_no; i++)
if (strcmp(current, items[i * 2]) == 0)
@@ -263,10 +264,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
wnoutrefresh(menu);
print_arrows(dialog, item_no, scroll,
- box_y, box_x + ITEM_IDENT + 1, menu_height);
+ box_y, box_x + item_x + 1, menu_height);
print_buttons(dialog, height, width, 0);
- wmove(menu, choice, ITEM_IDENT + 1);
+ wmove(menu, choice, item_x + 1);
wrefresh(menu);
while (key != ESC) {
@@ -349,7 +350,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
print_item(scroll + choice, choice, TRUE);
print_arrows(dialog, item_no, scroll,
- box_y, box_x + ITEM_IDENT + 1, menu_height);
+ box_y, box_x + item_x + 1, menu_height);
wnoutrefresh(dialog);
wrefresh(menu);
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0b92ddff26fd1..7e8079a34adf0 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -658,7 +658,7 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
warn("%s - Section mismatch: reference to %s:%s from %s "
"before '%s' (at offset -0x%llx)\n",
modname, secname, refsymname, fromsec,
- elf->strtab + before->st_name,
+ elf->strtab + after->st_name,
(long long)r.r_offset);
} else {
warn("%s - Section mismatch: reference to %s:%s from %s "
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index f34373853ef84..f34373853ef84 100644..100755
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
diff --git a/scripts/show_delta b/scripts/show_delta
index 48a706ab3d0c3..48a706ab3d0c3 100644..100755
--- a/scripts/show_delta
+++ b/scripts/show_delta
diff --git a/scripts/ver_linux b/scripts/ver_linux
index beb43ef7f761f..84999f69773d6 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -39,10 +39,10 @@ tune2fs 2>&1 | grep "^tune2fs" | sed 's/,//' | awk \
fsck.jfs -V 2>&1 | grep version | sed 's/,//' | awk \
'NR==1 {print "jfsutils ", $3}'
-reiserfsck -V 2>&1 | grep reiserfsck | awk \
+reiserfsck -V 2>&1 | grep ^reiserfsck | awk \
'NR==1{print "reiserfsprogs ", $2}'
-fsck.reiser4 -V 2>&1 | grep fsck.reiser4 | awk \
+fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \
'NR==1{print "reiser4progs ", $2}'
xfs_db -V 2>&1 | grep version | awk \
diff --git a/security/keys/key.c b/security/keys/key.c
index a057e3311aad6..b6061fa29da7f 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -785,6 +785,10 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
key_check(keyring);
+ key_ref = ERR_PTR(-ENOTDIR);
+ if (keyring->type != &key_type_keyring)
+ goto error_2;
+
down_write(&keyring->sem);
/* if we're going to allocate a new key, we're going to have
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index d65a180f888d2..bffa924c1f882 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -437,6 +437,7 @@ EXPORT_SYMBOL(keyring_search);
/*
* search the given keyring only (no recursion)
* - keyring must be locked by caller
+ * - caller must guarantee that the keyring is a keyring
*/
key_ref_t __keyring_search_one(key_ref_t keyring_ref,
const struct key_type *ktype,
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index f6940618e3457..217a0bef3c82b 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -168,11 +168,12 @@ error:
*/
int install_process_keyring(struct task_struct *tsk)
{
- unsigned long flags;
struct key *keyring;
char buf[20];
int ret;
+ might_sleep();
+
if (!tsk->signal->process_keyring) {
sprintf(buf, "_pid.%u", tsk->tgid);
@@ -183,12 +184,12 @@ int install_process_keyring(struct task_struct *tsk)
}
/* attach keyring */
- spin_lock_irqsave(&tsk->sighand->siglock, flags);
+ spin_lock_irq(&tsk->sighand->siglock);
if (!tsk->signal->process_keyring) {
tsk->signal->process_keyring = keyring;
keyring = NULL;
}
- spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
+ spin_unlock_irq(&tsk->sighand->siglock);
key_put(keyring);
}
@@ -207,38 +208,37 @@ error:
static int install_session_keyring(struct task_struct *tsk,
struct key *keyring)
{
- unsigned long flags;
struct key *old;
char buf[20];
- int ret;
+
+ might_sleep();
/* create an empty session keyring */
if (!keyring) {
sprintf(buf, "_ses.%u", tsk->tgid);
keyring = keyring_alloc(buf, tsk->uid, tsk->gid, 1, NULL);
- if (IS_ERR(keyring)) {
- ret = PTR_ERR(keyring);
- goto error;
- }
+ if (IS_ERR(keyring))
+ return PTR_ERR(keyring);
}
else {
atomic_inc(&keyring->usage);
}
/* install the keyring */
- spin_lock_irqsave(&tsk->sighand->siglock, flags);
- old = rcu_dereference(tsk->signal->session_keyring);
+ spin_lock_irq(&tsk->sighand->siglock);
+ old = tsk->signal->session_keyring;
rcu_assign_pointer(tsk->signal->session_keyring, keyring);
- spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
+ spin_unlock_irq(&tsk->sighand->siglock);
- ret = 0;
+ /* we're using RCU on the pointer, but there's no point synchronising
+ * on it if it didn't previously point to anything */
+ if (old) {
+ synchronize_rcu();
+ key_put(old);
+ }
- /* we're using RCU on the pointer */
- synchronize_rcu();
- key_put(old);
-error:
- return ret;
+ return 0;
} /* end install_session_keyring() */
@@ -311,7 +311,6 @@ void exit_keys(struct task_struct *tsk)
*/
int exec_keys(struct task_struct *tsk)
{
- unsigned long flags;
struct key *old;
/* newly exec'd tasks don't get a thread keyring */
@@ -323,10 +322,10 @@ int exec_keys(struct task_struct *tsk)
key_put(old);
/* discard the process keyring from a newly exec'd task */
- spin_lock_irqsave(&tsk->sighand->siglock, flags);
+ spin_lock_irq(&tsk->sighand->siglock);
old = tsk->signal->process_keyring;
tsk->signal->process_keyring = NULL;
- spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
+ spin_unlock_irq(&tsk->sighand->siglock);
key_put(old);
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index dfab6c886698d..abe99d8813765 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -281,7 +281,7 @@ u32 selinux_socket_getpeer_dgram(struct sk_buff *skb)
int i;
for (i = sp->len-1; i >= 0; i--) {
- struct xfrm_state *x = sp->x[i].xvec;
+ struct xfrm_state *x = sp->xvec[i];
if (selinux_authorizable_xfrm(x)) {
struct xfrm_sec_ctx *ctx = x->security;
return ctx->ctx_sid;
@@ -314,7 +314,7 @@ int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb)
* Only need to verify the existence of an authorizable sp.
*/
for (i = 0; i < sp->len; i++) {
- struct xfrm_state *x = sp->x[i].xvec;
+ struct xfrm_state *x = sp->xvec[i];
if (x && selinux_authorizable_xfrm(x))
goto accept;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 91114c7aeff5a..c5978d6c60807 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1682,7 +1682,7 @@ static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream,
substream->oss.setup = *setup;
if (setup->nonblock)
substream->ffile->f_flags |= O_NONBLOCK;
- else
+ else if (setup->block)
substream->ffile->f_flags &= ~O_NONBLOCK;
runtime = substream->runtime;
runtime->oss.params = 1;
@@ -1757,10 +1757,11 @@ static int snd_pcm_oss_open_file(struct file *file,
}
pcm_oss_file->streams[idx] = substream;
+ substream->file = pcm_oss_file;
snd_pcm_oss_init_substream(substream, &setup[idx], minor);
}
- if (! pcm_oss_file->streams[0] && pcm_oss_file->streams[1]) {
+ if (!pcm_oss_file->streams[0] && !pcm_oss_file->streams[1]) {
snd_pcm_oss_release_file(pcm_oss_file);
return -EINVAL;
}
@@ -1809,7 +1810,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
err = -EFAULT;
goto __error;
}
- memset(setup, 0, sizeof(*setup));
+ memset(setup, 0, sizeof(setup));
if (file->f_mode & FMODE_WRITE)
snd_pcm_oss_look_for_setup(pcm, SNDRV_PCM_STREAM_PLAYBACK,
task_name, &setup[0]);
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 5d7eb123b9990..122e10a61ab9c 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -196,7 +196,7 @@ static char *snd_pcm_format_names[] = {
FORMAT(U18_3BE),
};
-const char *snd_pcm_format_name(snd_pcm_format_t format)
+static const char *snd_pcm_format_name(snd_pcm_format_t format)
{
return snd_pcm_format_names[format];
}
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 964e4c47a7f19..0860c5a84502f 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2007,14 +2007,16 @@ static void pcm_release_private(struct snd_pcm_substream *substream)
void snd_pcm_release_substream(struct snd_pcm_substream *substream)
{
snd_pcm_drop(substream);
- if (substream->pcm_release)
- substream->pcm_release(substream);
if (substream->hw_opened) {
if (substream->ops->hw_free != NULL)
substream->ops->hw_free(substream);
substream->ops->close(substream);
substream->hw_opened = 0;
}
+ if (substream->pcm_release) {
+ substream->pcm_release(substream);
+ substream->pcm_release = NULL;
+ }
snd_pcm_detach_substream(substream);
}
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 326a057f752ff..99908e44124da 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -193,9 +193,11 @@ static int __init alsa_card_ad1848_init(void)
continue;
device = platform_device_register_simple(SND_AD1848_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -204,14 +206,10 @@ static int __init alsa_card_ad1848_init(void)
#ifdef MODULE
printk(KERN_ERR "AD1848 soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_ad1848_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_ad1848_unregister_all();
- return err;
}
static void __exit alsa_card_ad1848_exit(void)
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c
index a253a14e6a45b..1124344ed948b 100644
--- a/sound/isa/adlib.c
+++ b/sound/isa/adlib.c
@@ -43,8 +43,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device)
struct snd_card *card;
struct snd_opl3 *opl3;
- int error;
- int i = device->id;
+ int error, i = device->id;
if (port[i] == SNDRV_AUTO_PORT) {
snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
@@ -95,8 +94,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device)
return 0;
out1: snd_card_free(card);
- out0: error = -EINVAL; /* FIXME: should be the original error code */
- return error;
+out0: return error;
}
static int __devexit snd_adlib_remove(struct platform_device *device)
@@ -134,6 +132,11 @@ static int __init alsa_card_adlib_init(void)
if (IS_ERR(device))
continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
+ }
+
devices[i] = device;
cards++;
}
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index bc0f5ebf5d3c8..3c1e9fd56fe00 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -699,9 +699,11 @@ static int __init alsa_card_cmi8330_init(void)
continue;
device = platform_device_register_simple(CMI8330_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
cards++;
@@ -719,14 +721,10 @@ static int __init alsa_card_cmi8330_init(void)
#ifdef MODULE
snd_printk(KERN_ERR "CMI8330 not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_cmi8330_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_cmi8330_unregister_all();
- return err;
}
static void __exit alsa_card_cmi8330_exit(void)
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index a30dcd9625252..397310f358b7c 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -209,9 +209,11 @@ static int __init alsa_card_cs4231_init(void)
continue;
device = platform_device_register_simple(SND_CS4231_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -220,14 +222,10 @@ static int __init alsa_card_cs4231_init(void)
#ifdef MODULE
printk(KERN_ERR "CS4231 soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_cs4231_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_cs4231_unregister_all();
- return err;
}
static void __exit alsa_card_cs4231_exit(void)
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 382bb17ef49f0..f7fa779347ffe 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -780,9 +780,11 @@ static int __init alsa_card_cs423x_init(void)
continue;
device = platform_device_register_simple(CS423X_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
snd_cs423x_devices++;
@@ -802,14 +804,10 @@ static int __init alsa_card_cs423x_init(void)
#ifdef MODULE
printk(KERN_ERR IDENT " soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_cs423x_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_cs423x_unregister_all();
- return err;
}
static void __exit alsa_card_cs423x_exit(void)
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 2b69fc829265d..e90689ee162fa 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -213,9 +213,11 @@ static int __init alsa_card_es1688_init(void)
continue;
device = platform_device_register_simple(ES1688_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -224,14 +226,10 @@ static int __init alsa_card_es1688_init(void)
#ifdef MODULE
printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_es1688_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_es1688_unregister_all();
- return err;
}
static void __exit alsa_card_es1688_exit(void)
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 9fbc185b4cc24..a36ec1daa5cb9 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -2391,9 +2391,11 @@ static int __init alsa_card_es18xx_init(void)
continue;
device = platform_device_register_simple(ES18XX_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
cards++;
@@ -2411,14 +2413,10 @@ static int __init alsa_card_es18xx_init(void)
#ifdef MODULE
snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_es18xx_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_es18xx_unregister_all();
- return err;
}
static void __exit alsa_card_es18xx_exit(void)
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index 26dccfea24374..37057a37dc30a 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -253,9 +253,11 @@ static int __init alsa_card_gusclassic_init(void)
continue;
device = platform_device_register_simple(GUSCLASSIC_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -264,14 +266,10 @@ static int __init alsa_card_gusclassic_init(void)
#ifdef MODULE
printk(KERN_ERR "GUS Classic soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_gusclassic_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_gusclassic_unregister_all();
- return err;
}
static void __exit alsa_card_gusclassic_exit(void)
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index 31dc20501d0c5..05852fcc613bd 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -363,9 +363,11 @@ static int __init alsa_card_gusextreme_init(void)
continue;
device = platform_device_register_simple(GUSEXTREME_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -374,14 +376,10 @@ static int __init alsa_card_gusextreme_init(void)
#ifdef MODULE
printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_gusextreme_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_gusextreme_unregister_all();
- return err;
}
static void __exit alsa_card_gusextreme_exit(void)
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index cafb9b67fa721..fcf2c8fe6f94b 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -390,9 +390,11 @@ static int __init alsa_card_gusmax_init(void)
continue;
device = platform_device_register_simple(GUSMAX_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -401,14 +403,10 @@ static int __init alsa_card_gusmax_init(void)
#ifdef MODULE
printk(KERN_ERR "GUS MAX soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_gusmax_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_gusmax_unregister_all();
- return err;
}
static void __exit alsa_card_gusmax_exit(void)
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index de71b7a99c83d..4298d339e786f 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -947,9 +947,11 @@ static int __init alsa_card_interwave_init(void)
#endif
device = platform_device_register_simple(INTERWAVE_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
cards++;
@@ -966,14 +968,10 @@ static int __init alsa_card_interwave_init(void)
#ifdef MODULE
printk(KERN_ERR "InterWave soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_interwave_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_interwave_unregister_all();
- return err;
}
static void __exit alsa_card_interwave_exit(void)
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index c906e205d7d52..6d889052c32c9 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -962,9 +962,11 @@ static int __init alsa_card_opl3sa2_init(void)
#endif
device = platform_device_register_simple(OPL3SA2_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
snd_opl3sa2_devices++;
@@ -983,14 +985,10 @@ static int __init alsa_card_opl3sa2_init(void)
#ifdef MODULE
snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_opl3sa2_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_opl3sa2_unregister_all();
- return err;
}
static void __exit alsa_card_opl3sa2_exit(void)
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c
index 09384d03dc31f..83d64bc07ff0f 100644
--- a/sound/isa/opti9xx/miro.c
+++ b/sound/isa/opti9xx/miro.c
@@ -1436,8 +1436,11 @@ static int __init alsa_card_miro_init(void)
if ((error = platform_driver_register(&snd_miro_driver)) < 0)
return error;
device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
- if (! IS_ERR(device))
- return 0;
+ if (! IS_ERR(device)) {
+ if (platform_get_drvdata(device))
+ return 0;
+ platform_device_unregister(device);
+ }
#ifdef MODULE
printk(KERN_ERR "no miro soundcard found\n");
#endif
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 65b28cbc0ebd7..8ee0d70536f9c 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -2099,8 +2099,11 @@ static int __init alsa_card_opti9xx_init(void)
return error;
device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
if (!IS_ERR(device)) {
- snd_opti9xx_platform_device = device;
- return 0;
+ if (platform_get_drvdata(device)) {
+ snd_opti9xx_platform_device = device;
+ return 0;
+ }
+ platform_device_unregister(device);
}
platform_driver_unregister(&snd_opti9xx_driver);
}
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 21ea65925a9ea..6333f900eaee6 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -720,9 +720,11 @@ static int __init alsa_card_sb16_init(void)
continue;
device = platform_device_register_simple(SND_SB16_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
cards++;
@@ -745,14 +747,10 @@ static int __init alsa_card_sb16_init(void)
snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n");
#endif
#endif
- err = -ENODEV;
- goto errout;
+ snd_sb16_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_sb16_unregister_all();
- return err;
}
static void __exit alsa_card_sb16_exit(void)
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index 3efa23d303c3b..141400c014261 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -264,9 +264,11 @@ static int __init alsa_card_sb8_init(void)
continue;
device = platform_device_register_simple(SND_SB8_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -275,14 +277,10 @@ static int __init alsa_card_sb8_init(void)
#ifdef MODULE
snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_sb8_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_sb8_unregister_all();
- return err;
}
static void __exit alsa_card_sb8_exit(void)
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
index a60e66afbf907..09c8e8c6b5e3c 100644
--- a/sound/isa/sgalaxy.c
+++ b/sound/isa/sgalaxy.c
@@ -366,9 +366,11 @@ static int __init alsa_card_sgalaxy_init(void)
continue;
device = platform_device_register_simple(SND_SGALAXY_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
devices[i] = device;
cards++;
@@ -377,14 +379,10 @@ static int __init alsa_card_sgalaxy_init(void)
#ifdef MODULE
snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_sgalaxy_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_sgalaxy_unregister_all();
- return err;
}
static void __exit alsa_card_sgalaxy_exit(void)
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 48e5552d34448..d2a856f0fde20 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -1427,8 +1427,8 @@ static int __init sscape_manual_probe(void)
dma[i] == SNDRV_AUTO_DMA) {
printk(KERN_INFO
"sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
- ret = -ENXIO;
- goto errout;
+ sscape_unregister_all();
+ return -ENXIO;
}
/*
@@ -1436,17 +1436,15 @@ static int __init sscape_manual_probe(void)
*/
device = platform_device_register_simple(SSCAPE_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- ret = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
}
return 0;
-
- errout:
- sscape_unregister_all();
- return ret;
}
static void sscape_exit(void)
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 2f13cd5d4dcbc..7ae86f82c3fa8 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -722,9 +722,11 @@ static int __init alsa_card_wavefront_init(void)
#endif
device = platform_device_register_simple(WAVEFRONT_DRIVER,
i, NULL, 0);
- if (IS_ERR(device)) {
- err = PTR_ERR(device);
- goto errout;
+ if (IS_ERR(device))
+ continue;
+ if (!platform_get_drvdata(device)) {
+ platform_device_unregister(device);
+ continue;
}
platform_devices[i] = device;
cards++;
@@ -742,14 +744,10 @@ static int __init alsa_card_wavefront_init(void)
#ifdef MODULE
printk (KERN_ERR "No WaveFront cards found or devices busy\n");
#endif
- err = -ENODEV;
- goto errout;
+ snd_wavefront_unregister_all();
+ return -ENODEV;
}
return 0;
-
- errout:
- snd_wavefront_unregister_all();
- return err;
}
static void __exit alsa_card_wavefront_exit(void)
diff --git a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
index 0cd44a6f7ac06..3721c5857b904 100644
--- a/sound/oss/emu10k1/main.c
+++ b/sound/oss/emu10k1/main.c
@@ -94,6 +94,7 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
+#include <linux/dma-mapping.h>
#include "hwaccess.h"
#include "8010.h"
@@ -119,7 +120,7 @@
/* the emu10k1 _seems_ to only supports 29 bit (512MiB) bit bus master */
-#define EMU10K1_DMA_MASK 0x1fffffff /* DMA buffer mask for pci_alloc_consist */
+#define EMU10K1_DMA_MASK DMA_29BIT_MASK /* DMA buffer mask for pci_alloc_consist */
#ifndef PCI_VENDOR_ID_CREATIVE
#define PCI_VENDOR_ID_CREATIVE 0x1102
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 278319bbdea19..d05200741ac37 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -160,6 +160,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
{ 0x54584e20, 0xffffffff, "TLC320AD9xC", NULL, NULL },
{ 0x56494161, 0xffffffff, "VIA1612A", NULL, NULL }, // modified ICE1232 with S/PDIF
{ 0x56494170, 0xffffffff, "VIA1617A", patch_vt1617a, NULL }, // modified VT1616 with S/PDIF
+{ 0x56494182, 0xffffffff, "VIA1618", NULL, NULL },
{ 0x57454301, 0xffffffff, "W83971D", NULL, NULL },
{ 0x574d4c00, 0xffffffff, "WM9701A", NULL, NULL },
{ 0x574d4C03, 0xffffffff, "WM9703,WM9707,WM9708,WM9717", patch_wolfson03, NULL},
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 37b80570a5c6e..91899f87f0376 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -35,6 +35,7 @@
#include <linux/init.h>
#include <linux/moduleparam.h>
#include <linux/pci.h>
+#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
@@ -691,8 +692,8 @@ static int __devinit snd_als300_create(snd_card_t *card,
if ((err = pci_enable_device(pci)) < 0)
return err;
- if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
- pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
+ if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
+ pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
printk(KERN_ERR "error setting 28bit DMA mask\n");
pci_disable_device(pci);
return -ENXIO;
diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h
index d65ccb1866a02..f078b716d2b05 100644
--- a/sound/pci/au88x0/au88x0.h
+++ b/sound/pci/au88x0/au88x0.h
@@ -19,7 +19,6 @@
#ifdef __KERNEL__
#include <sound/driver.h>
-#include <linux/init.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <sound/core.h>
@@ -277,14 +276,14 @@ static void vortex_Vort3D_InitializeSource(a3dsrc_t * a, int en);
#endif
/* Driver stuff. */
-static int __devinit vortex_gameport_register(vortex_t * card);
+static int vortex_gameport_register(vortex_t * card);
static void vortex_gameport_unregister(vortex_t * card);
#ifndef CHIP_AU8820
-static int __devinit vortex_eq_init(vortex_t * vortex);
-static int __devexit vortex_eq_free(vortex_t * vortex);
+static int vortex_eq_init(vortex_t * vortex);
+static int vortex_eq_free(vortex_t * vortex);
#endif
/* ALSA stuff. */
-static int __devinit snd_vortex_new_pcm(vortex_t * vortex, int idx, int nr);
-static int __devinit snd_vortex_mixer(vortex_t * vortex);
-static int __devinit snd_vortex_midi(vortex_t * vortex);
+static int snd_vortex_new_pcm(vortex_t * vortex, int idx, int nr);
+static int snd_vortex_mixer(vortex_t * vortex);
+static int snd_vortex_midi(vortex_t * vortex);
#endif
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 9cac02e93b256..4347e6abc1d54 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -2658,7 +2658,7 @@ static void vortex_spdif_init(vortex_t * vortex, int spdif_sr, int spdif_mode)
/* Initialization */
-static int vortex_core_init(vortex_t * vortex)
+static int __devinit vortex_core_init(vortex_t * vortex)
{
printk(KERN_INFO "Vortex: init.... ");
diff --git a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c
index 64fbfbbaf816f..0c86a31c43362 100644
--- a/sound/pci/au88x0/au88x0_eq.c
+++ b/sound/pci/au88x0/au88x0_eq.c
@@ -885,7 +885,7 @@ static char *EqBandLabels[10] __devinitdata = {
};
/* ALSA driver entry points. Init and exit. */
-static int vortex_eq_init(vortex_t * vortex)
+static int __devinit vortex_eq_init(vortex_t * vortex)
{
struct snd_kcontrol *kcontrol;
int err, i;
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c
index 6a13ca1d545e3..7b5baa1738597 100644
--- a/sound/pci/au88x0/au88x0_pcm.c
+++ b/sound/pci/au88x0/au88x0_pcm.c
@@ -506,7 +506,7 @@ static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr)
int i;
int err, nr_capt;
- if ((chip == 0) || (idx < 0) || (idx > VORTEX_PCM_LAST))
+ if ((chip == 0) || (idx < 0) || (idx >= VORTEX_PCM_LAST))
return -ENODEV;
/* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 31cb9b48bb593..6bfa08436efa2 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -843,8 +843,11 @@ static struct snd_emu_chip_details emu_chip_details[] = {
.spdif_bug = 1,
.ac97_chip = 1} ,
/* Tested by shane-alsa@cm.nu 5th Nov 2005 */
+ /* The 0x20061102 does have SB0350 written on it
+ * Just like 0x20021102
+ */
{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102,
- .driver = "Audigy2", .name = "Audigy 2 [2006]",
+ .driver = "Audigy2", .name = "Audigy 2 [SB0350b]",
.id = "Audigy2",
.emu10k2_chip = 1,
.ca0102_chip = 1,
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 2bfe37e8543cd..bcfca159c6a23 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -801,6 +801,10 @@ static struct hda_board_config ad1986a_cfg_tbl[] = {
.config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */
{ .pci_subvendor = 0x1043, .pci_subdevice = 0x1213,
.config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */
+ { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7,
+ .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */
+ { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af,
+ .config = AD1986A_LAPTOP_EAPD }, /* HP Compaq Presario B2800 */
{}
};
@@ -1330,6 +1334,8 @@ static struct hda_board_config ad1981_cfg_tbl[] = {
.config = AD1981_HP }, /* HP nx6320 */
{ .pci_subvendor = 0x103c, .pci_subdevice = 0x309f,
.config = AD1981_HP }, /* HP nx9420 AngelFire */
+ { .pci_subvendor = 0x103c, .pci_subdevice = 0x30a2,
+ .config = AD1981_HP }, /* HP nx9420 AngelFire */
{ .modelname = "basic", .config = AD1981_BASIC },
{}
};
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index abe9493f0a2ca..7152607879539 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -310,6 +310,9 @@ static struct hda_board_config stac922x_cfg_tbl[] = {
.pci_subdevice = 0x0b0b,
.config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack, 9221 A1 */
{ .pci_subvendor = PCI_VENDOR_ID_INTEL,
+ .pci_subdevice = 0x0707,
+ .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */
+ { .pci_subvendor = PCI_VENDOR_ID_INTEL,
.pci_subdevice = 0x0404,
.config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
{ .pci_subvendor = PCI_VENDOR_ID_INTEL,
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 1e7398de2865f..0f171dd1377b0 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2333,6 +2333,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
{ .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */
{ .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */
{ .subvendor = 0x1019, .subdevice = 0xa101, .action = VIA_DXS_SRC },
+ { .subvendor = 0x1019, .subdevice = 0xaa01, .action = VIA_DXS_SRC }, /* ECS K8T890-A */
{ .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */
{ .subvendor = 0x1025, .subdevice = 0x0046, .action = VIA_DXS_SRC }, /* Acer Aspire 1524 WLMi */
{ .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/
diff --git a/usr/Makefile b/usr/Makefile
index e2129cb570bba..19d74e6f2685e 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -1,65 +1,48 @@
+#
+# kbuild file for usr/ - including initramfs image
+#
-obj-y := initramfs_data.o
-
-hostprogs-y := gen_init_cpio
+klibcdirs:;
-clean-files := initramfs_data.cpio.gz initramfs_list
+# Generate builtin.o based on initramfs_data.o
+obj-y := initramfs_data.o
# initramfs_data.o contains the initramfs_data.cpio.gz image.
# The image is included using .incbin, a dependency which is not
# tracked automatically.
$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE
-ifdef CONFIG_INITRAMFS_ROOT_UID
-gen_initramfs_args += -u $(CONFIG_INITRAMFS_ROOT_UID)
-endif
-
-ifdef CONFIG_INITRAMFS_ROOT_GID
-gen_initramfs_args += -g $(CONFIG_INITRAMFS_ROOT_GID)
-endif
-
-# The $(shell echo $(CONFIG_INITRAMFS_SOURCE)) is to remove the
-# gratuitous begin and end quotes from the Kconfig string type.
-# Internal, escaped quotes in the Kconfig string will loose the
-# escape and become active quotes.
-quotefixed_initramfs_source := $(shell echo $(CONFIG_INITRAMFS_SOURCE))
-
-filechk_initramfs_list = $(CONFIG_SHELL) \
- $(srctree)/scripts/gen_initramfs_list.sh $(gen_initramfs_args) $(quotefixed_initramfs_source)
-
-$(obj)/initramfs_list: $(obj)/Makefile FORCE
- $(call filechk,initramfs_list)
-
-quiet_cmd_cpio = CPIO $@
- cmd_cpio = ./$< $(obj)/initramfs_list > $@
-
-
-# Check if the INITRAMFS_SOURCE is a cpio archive
-ifneq (,$(findstring .cpio,$(quotefixed_initramfs_source)))
-
-# INITRAMFS_SOURCE has a cpio archive - verify that it's a single file
-ifneq (1,$(words $(quotefixed_initramfs_source)))
-$(error Only a single file may be specified in CONFIG_INITRAMFS_SOURCE (="$(quotefixed_initramfs_source)") when a cpio archive is directly specified.)
-endif
-# Now use the cpio archive directly
-initramfs_data_cpio = $(quotefixed_initramfs_source)
-targets += $(quotefixed_initramfs_source)
-
-else
-
-# INITRAMFS_SOURCE is not a cpio archive - create one
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio \
- $(initramfs-y) $(obj)/initramfs_list FORCE
- $(call if_changed,cpio)
-
-targets += initramfs_data.cpio
-initramfs_data_cpio = $(obj)/initramfs_data.cpio
-
+#####
+# Generate the initramfs cpio archive
+
+hostprogs-y := gen_init_cpio
+initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
+ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
+ $(CONFIG_INITRAMFS_SOURCE),-d)
+ramfs-args := \
+ $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
+ $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
+ $(ramfs-input)
+
+# .initramfs_data.cpio.gz.d is used to identify all files included
+# in initramfs and to detect if any files are added/removed.
+# Removed files are identified by directory timestamp being updated
+# The dependency list is generated by gen_initramfs.sh -l
+ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),)
+ include $(obj)/.initramfs_data.cpio.gz.d
endif
-
-$(obj)/initramfs_data.cpio.gz: $(initramfs_data_cpio) FORCE
- $(call if_changed,gzip)
-
-targets += initramfs_data.cpio.gz
+quiet_cmd_initfs = GEN $@
+ cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
+
+targets := initramfs_data.cpio.gz
+$(deps_initramfs): klibcdirs
+# We rebuild initramfs_data.cpio.gz if:
+# 1) Any included file is newer then initramfs_data.cpio.gz
+# 2) There are changes in which files are included (added or deleted)
+# 3) If gen_init_cpio are newer than initramfs_data.cpio.gz
+# 4) arguments to gen_initramfs.sh changes
+$(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
+ $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d
+ $(call if_changed,initfs)