diff options
249 files changed, 3073 insertions, 17041 deletions
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 029e4281aa77..c08521ba749e 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -20,16 +20,18 @@ SECTION 1 - CREATING AND SENDING YOUR CHANGE -1) "diff -u" +1) "diff -up" ------------ -Use "diff -u" or "diff -urN" to create patches. +Use "diff -up" or "diff -uprN" to create patches. All changes to the Linux kernel occur in the form of patches, as generated by diff(1). When creating your patch, make sure to create it in "unified diff" format, as supplied by the '-u' argument to diff(1). -Patches should be based in the root kernel source directory, not in -any lower subdirectory. +Also, please use the '-p' argument which shows which C function each +change is in - that makes the resultant diff a lot easier to read. +Patches should be based in the root kernel source directory, +not in any lower subdirectory. To create a patch for a single file, it is often sufficient to do: @@ -39,7 +41,7 @@ To create a patch for a single file, it is often sufficient to do: cd $SRCTREE cp $MYFILE $MYFILE.orig vi $MYFILE # make your change - diff -u $MYFILE.orig $MYFILE > /tmp/patch + diff -up $MYFILE.orig $MYFILE > /tmp/patch To create a patch for multiple files, you should unpack a "vanilla", or unmodified kernel source tree, and generate a diff against your @@ -50,7 +52,7 @@ own source tree. For example: tar xvfz linux-2.4.0-test11.tar.gz mv linux linux-vanilla wget http://www.moses.uklinux.net/patches/dontdiff - diff -urN -X dontdiff linux-vanilla $MYSRC > /tmp/patch + diff -uprN -X dontdiff linux-vanilla $MYSRC > /tmp/patch rm -f dontdiff "dontdiff" is a list of files which are generated by the kernel during diff --git a/Documentation/fb/modedb.txt b/Documentation/fb/modedb.txt index 049c4cd84fa0..747b8a9d52ea 100644 --- a/Documentation/fb/modedb.txt +++ b/Documentation/fb/modedb.txt @@ -55,6 +55,7 @@ There may be more modes. aty128fb - ATI Rage128 / Pro frame buffer atyfb - ATI Mach64 frame buffer tdfx - 3D Fx frame buffer + tridentfb - Trident (Cyber)blade chipset frame buffer BTW, only a few drivers use this at the moment. Others are to follow (feel free to send patches). diff --git a/Documentation/fb/tridentfb.txt b/Documentation/fb/tridentfb.txt index c6289d2587bb..8a6c8a43e6a3 100644 --- a/Documentation/fb/tridentfb.txt +++ b/Documentation/fb/tridentfb.txt @@ -11,10 +11,15 @@ Only PCI/AGP based cards are supported, none of the older Tridents. How to use it? ============== -Just do your usual console work :) -When booting you can pass the following parameters -================================================== +When booting you can pass the video parameter. +video=tridentfb + +The parameters for tridentfb are concatenated with a ':' as in this example. + +video=tridentfb:800x600,bpp=16,noaccel + +The second level parameters that tridentfb understands are: noaccel - turns off acceleration (when it doesn't work for your card) accel - force text acceleration (for boards which by default are noacceled) diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt index c59eec748e13..afe9bb766f42 100644 --- a/Documentation/power/swsusp.txt +++ b/Documentation/power/swsusp.txt @@ -17,13 +17,30 @@ From kernel/suspend.c: You need to append resume=/dev/your_swap_partition to kernel command line. Then you suspend by echo 4 > /proc/acpi/sleep. -[Notice. Rest docs is pretty outdated (see date!) It should be safe to -use swsusp on ext3/reiserfs these days.] +Pavel's unreliable guide to swsusp mess +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are currently two versions of swap suspend in the kernel, the old +"Pavel's" version in kernel/power/swsusp.c and the new "Patrick's" +version in kernel/power/pmdisk.c. They provide the same functionality; +the old version looks ugly but was tested, while the new version looks +nicer but did not receive so much testing. echo 4 > /proc/acpi/sleep +calls the old version, echo disk > /sys/power/state calls the new one. + +[In the future, when the new version is stable enough, two things can +happen: + +* the new version is moved into swsusp.c, and swsusp is renamed to swap + suspend (Pavel prefers this) + +* pmdisk is kept as is and swsusp.c is removed from the kernel] + Article about goals and implementation of Software Suspend for Linux +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Author: G‚ábor Kuti -Last revised: 2002-04-08 +Last revised: 2003-10-20 by Pavel Machek Idea and goals to achieve @@ -36,84 +53,23 @@ real high when running from batteries. The other gain is that we don't have to interrupt our programs so processes that are calculating something for a long time shouldn't need to be written interruptible. -On desk machines the power saving function isn't as important as it is in -laptops but we really may benefit from the second one. Nowadays the number of -desk machines supporting suspend function in their APM is going up but there -are (and there will still be for a long time) machines that don't even support -APM of any kind. On the other hand it is reported that using APM's suspend -some irqs (e.g. ATA disk irq) is lost and it is annoying for the user until -the Linux kernel resets the device. - -So I started thinking about implementing Software Suspend which doesn't need -any APM support and - since it uses pretty near only high-level routines - is -supposed to be architecture independent code. - Using the code -The code is experimental right now - testers, extra eyes are welcome. To -compile this support into the kernel, you need CONFIG_EXPERIMENTAL, -and then CONFIG_SOFTWARE_SUSPEND in menu General Setup to be enabled. It -cannot be used as a module and I don't think it will ever be needed. - -You have two ways to use this code. The first one is if you've compiled in -sysrq support then you may press Sysrq-D to request suspend. The other way -is with a patched SysVinit (my patch is against 2.76 and available at my -home page). You might call 'swsusp' or 'shutdown -z <time>'. Next way is to -echo 4 > /proc/acpi/sleep. +You have two ways to use this code. The first one is is with a patched +SysVinit (my patch is against 2.76 and available at my home page). You +might call 'swsusp' or 'shutdown -z <time>'. Next way is to echo 4 > +/proc/acpi/sleep. Either way it saves the state of the machine into active swaps and then reboots. You must explicitly specify the swap partition to resume from with ``resume='' kernel option. If signature is found it loads and restores saved state. If the option ``noresume'' is specified as a boot parameter, it skips -the resuming. Warning! Look at section ``Things to implement'' to see what -isn't yet implemented. Also I strongly suggest you to list all active swaps -in /etc/fstab. Firstly because you don't have to specify anything to resume -and secondly if you have more than one swap area you can't decide which one -has the 'root' signature. +the resuming. In the meantime while the system is suspended you should not touch any of the hardware! About the code -Goals reached - -The code can be downloaded from -http://falcon.sch.bme.hu/~seasons/linux/. It mainly works but there are still -some of XXXs, TODOs, FIXMEs in the code which seem not to be too important. It -should work all right except for the problems listed in ``Things to -implement''. Notes about the code are really welcome. - -How the code works - -When suspending is triggered it immediately wakes up process bdflush. Bdflush -checks whether we have anything in our run queue tq_bdflush. Since we queued up -function do_software_suspend, it is called. Here we shrink everything including -dcache, inodes, buffers and memory (here mainly processes are swapped out). We -count how many pages we need to duplicate (we have to be atomical!) then we -create an appropriate sized page directory. It will point to the original and -the new (copied) address of the page. We get the free pages by -__get_free_pages() but since it changes state we have to be able to track it -later so it also flips in a bit in page's flags (a new Nosave flag). We -duplicate pages and then mark them as used (so atomicity is ensured). After -this we write out the image to swaps, do another sync and the machine may -reboot. We also save registers to stack. - -By resuming an ``inverse'' method is executed. The image if exists is loaded, -loadling is either triggered by ``resume='' kernel option. We -change our task to bdflush (it is needed because if we don't do this init does -an oops when it is waken up later) and then pages are copied back to their -original location. We restore registers, free previously allocated memory, -activate memory context and task information. Here we should restore hardware -state but even without this the machine is restored and processes are continued -to work. I think hardware state should be restored by some list (using -notify_chain) and probably by some userland program (run-parts?) for users' -pleasure. Check out my patch at the same location for the sysvinit patch. - -WARNINGS! -- It does not like pcmcia cards. And this is logical: pcmcia cards need - cardmgr to be initialized. they are not initialized during singleuser boot, - but "resumed" kernel does expect them to be initialized. That leads to - armagedon. You should eject any pcmcia cards before suspending. Things to implement - SMP support. I've done an SMP support but since I don't have access to a kind @@ -122,34 +78,14 @@ Things to implement interrupts AFAIK.. - We should only make a copy of data related to kernel segment, since any process data won't be changed. -- Hardware state restoring. Now there's support for notifying via the notify - chain, event handlers are welcome. Some devices may have microcodes loaded - into them. We should have event handlers for them as well. -- We should support other architectures (There are really only some arch - related functions..) -- We should also restore original state of swaps if the ``noresume'' kernel - option is specified.. Or do we need such a feature to save state for some - other time? Do we need some kind of ``several saved states''? (Linux-HA - people?). There's been some discussion about checkpointing on linux-future. - Should make more sanity checks. Or are these enough? Not so important ideas for implementing - If a real time process is running then don't suspend the machine. -- Support for power.conf file as in Solaris, autoshutdown, special - devicetypes support, maybe in sysctl. -- Introduce timeout for SMP locking. But first locking ought to work :O -- Pre-detect if we don't have enough swap space or free it instead of - calling panic. - Support for adding/removing hardware while suspended? - We should not free pages at the beginning so aggressively, most of them go there anyway.. -- If X is active while suspending then by resuming calling svgatextmode - corrupts the virtual console of X.. (Maybe this has been fixed AFAIK). - -Drivers we support -- IDE disks are okay -- vesafb Drivers that need support - pc_keyb -- perhaps we can wait for vojtech's input patches diff --git a/Documentation/power/video.txt b/Documentation/power/video.txt new file mode 100644 index 000000000000..e8cf4d432596 --- /dev/null +++ b/Documentation/power/video.txt @@ -0,0 +1,36 @@ + + Video issues with S3 resume + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 2003, Pavel Machek + +During S3 resume, hardware needs to be reinitialized. For most +devices, this is easy, and kernel driver knows how to do +it. Unfortunately there's one exception: video card. Those are usually +initialized by BIOS, and kernel does not have enough information to +boot video card. (Kernel usually does not even contain video card +driver -- vesafb and vgacon are widely used). + +This is not problem for swsusp, because during swsusp resume, BIOS is +run normally so video card is normally initialized. + +There are three types of systems where video works after S3 resume: + +* systems where video state is preserved over S3. (HP Omnibook xe3) + +* systems that initialize video card into vga text mode and where BIOS + works well enough to be able to set video mode. Use + acpi_sleep=s3_mode on these. (Toshiba 4030cdt) + +* systems where it is possible to call video bios during S3 + resume. Unfortunately, it is not correct to call video BIOS at that + point, but it happens to work on some machines. Use + acpi_sleep=s3_bios (Athlon64 desktop system) + +Now, if you pass acpi_sleep=something, and it does not work with your +bios, you'll get hard crash during resume. Be carefull. + +You may have system where none of above works. At that point you +either invent another ugly hack that works, or write proper driver for +your video card (good luck getting docs :-(). Maybe suspending from X +(proper X, knowing your hardware, not XF68_FBcon) might have better +chance of working. diff --git a/MAINTAINERS b/MAINTAINERS index b95e00174edf..fc34814fea99 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -637,8 +637,8 @@ W: http://www.sistina.com/lvm S: Maintained DEVICE NUMBER REGISTRY -P: H. Peter Anvin -M: hpa@zytor.com +P: John Cagle +M: device@lanana.org L: linux-kernel@vger.kernel.org S: Maintained @@ -1164,7 +1164,7 @@ KERNEL AUTOMOUNTER (AUTOFS) P: H. Peter Anvin M: hpa@zytor.com L: autofs@linux.kernel.org -S: Maintained +S: Odd Fixes KERNEL AUTOMOUNTER v4 (AUTOFS4) P: Jeremy Fitzhardinge @@ -1172,11 +1172,11 @@ M: jeremy@goop.org L: autofs@linux.kernel.org S: Maintained -KERNEL BUILD (Makefile, Rules.make, scripts/*) -P: Michael Elizabeth Chastain -M: mec@shout.net -L: kbuild-devel@lists.sourceforge.net -W: http://kbuild.sourceforge.net +KERNEL BUILD (kbuild: Makefile, scripts/Makefile.*) +P: Kai Germaschewski +M: kai@germaschewski.name +P: Sam Ravnborg +M: sam@ravnborg.org S: Maintained KERNEL JANITORS diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index e7766d3ec6d8..72ffe90d913c 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -509,6 +509,7 @@ config HAVE_DEC_LOCK config NR_CPUS int "Maximum number of CPUs (2-64)" + range 2 64 depends on SMP default "64" diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c index 425928769c1d..db7a87791efa 100644 --- a/arch/alpha/kernel/module.c +++ b/arch/alpha/kernel/module.c @@ -259,7 +259,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab, *(u64 *)location = value; break; case R_ALPHA_GPRELHIGH: - value = (value - gp + 0x8000) >> 16; + value = (long)(value - gp + 0x8000) >> 16; if ((short) value != value) goto reloc_overflow; *(u16 *)location = value; diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c index 175062133724..b244f40cd6cb 100644 --- a/arch/cris/arch-v10/drivers/ds1302.c +++ b/arch/cris/arch-v10/drivers/ds1302.c @@ -342,6 +342,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, { struct rtc_time rtc_tm; + memset(&rtc_tm, 0, sizeof (struct rtc_time)); get_rtc_time(&rtc_tm); if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) return -EFAULT; diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c index 7738454898dd..66e87cc7a4fd 100644 --- a/arch/cris/arch-v10/drivers/pcf8563.c +++ b/arch/cris/arch-v10/drivers/pcf8563.c @@ -219,6 +219,7 @@ pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned unsigned long flags; struct rtc_time tm; + memset(&tm, 0, sizeof (struct rtc_time)); if (!capable(CAP_SYS_TIME)) return -EPERM; diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig index 3217c7b98a62..a4f48859f23b 100644 --- a/arch/i386/Kconfig +++ b/arch/i386/Kconfig @@ -447,6 +447,7 @@ config SMP config NR_CPUS int "Maximum number of CPUs (2-255)" + range 2 255 depends on SMP default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000 default "8" diff --git a/arch/i386/kernel/acpi/wakeup.S b/arch/i386/kernel/acpi/wakeup.S index 51105a39c19f..5ae7dbef17c0 100644 --- a/arch/i386/kernel/acpi/wakeup.S +++ b/arch/i386/kernel/acpi/wakeup.S @@ -193,21 +193,12 @@ wakeup_pmode_return: # and restore the stack ... but you need gdt for this to work movl saved_context_esp, %esp - movw $0x0e00 + 'W', 0xb8018 - outl %eax, $0x80 - outl %eax, $0x80 - movw $0x0e00 + 'O', 0xb8018 - movl %cs:saved_magic, %eax cmpl $0x12345678, %eax jne bogus_magic # jump to place where we left off movl saved_eip,%eax - movw $0x0e00 + 'x', 0xb8018 - outl %eax, $0x80 - outl %eax, $0x80 - movw $0x0e00 + '!', 0xb801a jmp *%eax bogus_magic: diff --git a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig index 24cdcbdb6874..95f3fa5a235d 100644 --- a/arch/i386/kernel/cpu/cpufreq/Kconfig +++ b/arch/i386/kernel/cpu/cpufreq/Kconfig @@ -145,11 +145,6 @@ config X86_SPEEDSTEP_SMI If in doubt, say N. -config X86_SPEEDSTEP_LIB - tristate - depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI) - default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI) - config X86_P4_CLOCKMOD tristate "Intel Pentium 4 clock modulation" depends on CPU_FREQ_TABLE @@ -161,6 +156,11 @@ config X86_P4_CLOCKMOD If in doubt, say N. +config X86_SPEEDSTEP_LIB + tristate + depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD) + default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD) + config X86_LONGRUN tristate "Transmeta LongRun" depends on CPU_FREQ diff --git a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c index d8837afdf69d..89e24b25e126 100644 --- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c +++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c @@ -33,6 +33,8 @@ #include <asm/msr.h> #include <asm/timex.h> +#include "speedstep-lib.h" + #define PFX "cpufreq: " /* @@ -174,51 +176,30 @@ static int cpufreq_p4_verify(struct cpufreq_policy *policy) return cpufreq_frequency_table_verify(policy, &p4clockmod_table[0]); } -/* copied from speedstep_lib, made SMP-compatible */ + static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) { - u32 msr_lo, msr_hi, mult; - unsigned int fsb = 0; + if ((c->x86 == 0x06) && (c->x86_model == 0x09)) { + /* Pentium M */ + printk(KERN_DEBUG PFX "Warning: Pentium M detected. The speedstep_centrino module\n"); + printk(KERN_DEBUG PFX "offers voltage scaling in addition of frequency scaling. You\n"); + printk(KERN_DEBUG PFX "should use that instead of p4-clockmod, if possible.\n"); + return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PM); + } if (c->x86 != 0xF) { - printk(KERN_DEBUG PFX "Unknown P4. Please send an e-mail to <linux@brodo.de>\n"); + printk(KERN_DEBUG PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <linux@brodo.de>\n"); return 0; } - rdmsr(0x2c, msr_lo, msr_hi); - - /* printk(KERN_DEBUG PFX "P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi); */ - /* decode the FSB: see IA-32 Intel (C) Architecture Software - * Developer's Manual, Volume 3: System Prgramming Guide, - * revision #12 in Table B-1: MSRs in the Pentium 4 and - * Intel Xeon Processors, on page B-4 and B-5. - */ - if (c->x86_model < 2) - fsb = 100 * 1000; - else { - u8 fsb_code = (msr_lo >> 16) & 0x7; - switch (fsb_code) { - case 0: - fsb = 100 * 1000; - break; - case 1: - fsb = 13333 * 10; - break; - case 2: - fsb = 200 * 1000; - break; - } - } - - if (!fsb) { - printk(KERN_DEBUG PFX "couldn't detect FSB speed. Please send an e-mail to <linux@brodo.de>\n"); - printk(KERN_DEBUG PFX "P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi); + if (speedstep_detect_processor() == SPEEDSTEP_PROCESSOR_P4M) { + printk(KERN_DEBUG PFX "Warning: Pentium 4-M detected. The speedstep-ich or acpi cpufreq \n"); + printk(KERN_DEBUG PFX "modules offers voltage scaling in addition of frequency scaling. You\n"); + printk(KERN_DEBUG PFX "should use either one instead of p4-clockmod, if possible.\n"); + return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4M); } - /* Multiplier. */ - mult = msr_lo >> 24; - - return (fsb * mult); + return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4D); } @@ -315,6 +296,6 @@ MODULE_AUTHOR ("Zwane Mwaikambo <zwane@commfireservices.com>"); MODULE_DESCRIPTION ("cpufreq driver for Pentium(TM) 4/Xeon(TM)"); MODULE_LICENSE ("GPL"); -module_init(cpufreq_p4_init); +late_initcall(cpufreq_p4_init); module_exit(cpufreq_p4_exit); diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c index 927d3bebd6ff..6a3d0446592a 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c @@ -104,6 +104,26 @@ static unsigned int pentium3_get_frequency (unsigned int processor) } +static unsigned int pentiumM_get_frequency(void) +{ + u32 msr_lo, msr_tmp; + + rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); + dprintk(KERN_DEBUG "speedstep-lib: PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp); + + /* see table B-2 of 24547212.pdf */ + if (msr_lo & 0x00040000) { + printk(KERN_DEBUG "speedstep-lib: PM - invalid FSB: 0x%x 0x%x\n", msr_lo, msr_tmp); + return 0; + } + + msr_tmp = (msr_lo >> 22) & 0x1f; + dprintk(KERN_DEBUG "speedstep-lib: bits 22-26 are 0x%x\n", msr_tmp); + + return (msr_tmp * 100 * 10000); +} + + static unsigned int pentium4_get_frequency(void) { struct cpuinfo_x86 *c = &boot_cpu_data; @@ -151,6 +171,9 @@ static unsigned int pentium4_get_frequency(void) unsigned int speedstep_get_processor_frequency(unsigned int processor) { switch (processor) { + case SPEEDSTEP_PROCESSOR_PM: + return pentiumM_get_frequency(); + case SPEEDSTEP_PROCESSOR_P4D: case SPEEDSTEP_PROCESSOR_P4M: return pentium4_get_frequency(); case SPEEDSTEP_PROCESSOR_PIII_T: diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h index ff7521d0195d..851926d6139c 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h @@ -17,6 +17,12 @@ #define SPEEDSTEP_PROCESSOR_PIII_T 0x00000003 /* Tualatin core */ #define SPEEDSTEP_PROCESSOR_P4M 0x00000004 /* P4-M */ +/* the following processors are not speedstep-capable and are not auto-detected + * in speedstep_detect_processor(). However, their speed can be detected using + * the speedstep_get_processor_frequency() call. */ +#define SPEEDSTEP_PROCESSOR_PM 0xFFFFFF03 /* Pentium M */ +#define SPEEDSTEP_PROCESSOR_P4D 0xFFFFFF04 /* desktop P4 */ + /* speedstep states -- only two of them */ #define SPEEDSTEP_HIGH 0x00000000 diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c index ccdcfc8a5db9..c7e7125af2cb 100644 --- a/arch/i386/kernel/cpu/intel.c +++ b/arch/i386/kernel/cpu/intel.c @@ -1,5 +1,7 @@ +#include <linux/config.h> #include <linux/init.h> #include <linux/kernel.h> + #include <linux/string.h> #include <linux/bitops.h> #include <linux/smp.h> @@ -11,6 +13,12 @@ #include "cpu.h" +#ifdef CONFIG_X86_LOCAL_APIC +#include <asm/mpspec.h> +#include <asm/apic.h> +#include <mach_apic.h> +#endif + extern int trap_init_f00f_bug(void); #ifdef CONFIG_X86_INTEL_USERCOPY @@ -277,6 +285,7 @@ static void __init init_intel(struct cpuinfo_x86 *c) extern int phys_proc_id[NR_CPUS]; u32 eax, ebx, ecx, edx; + int index_lsb, index_msb, tmp; int cpu = smp_processor_id(); cpuid(1, &eax, &ebx, &ecx, &edx); @@ -285,6 +294,8 @@ static void __init init_intel(struct cpuinfo_x86 *c) if (smp_num_siblings == 1) { printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); } else if (smp_num_siblings > 1 ) { + index_lsb = 0; + index_msb = 31; /* * At this point we only support two siblings per * processor package. @@ -295,13 +306,19 @@ static void __init init_intel(struct cpuinfo_x86 *c) smp_num_siblings = 1; goto too_many_siblings; } - /* cpuid returns the value latched in the HW at reset, - * not the APIC ID register's value. For any box - * whose BIOS changes APIC IDs, like clustered APIC - * systems, we must use hard_smp_processor_id. - * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID. - */ - phys_proc_id[cpu] = hard_smp_processor_id() & ~(smp_num_siblings - 1); + tmp = smp_num_siblings; + while ((tmp & 1) == 0) { + tmp >>=1 ; + index_lsb++; + } + tmp = smp_num_siblings; + while ((tmp & 0x80000000 ) == 0) { + tmp <<=1 ; + index_msb--; + } + if (index_lsb != index_msb ) + index_msb++; + phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); printk(KERN_INFO "CPU: Physical Processor ID: %d\n", phys_proc_id[cpu]); diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c index 6b6e8713c91b..f40e516a782b 100644 --- a/arch/i386/kernel/dmi_scan.c +++ b/arch/i386/kernel/dmi_scan.c @@ -107,15 +107,7 @@ static int __init dmi_iterate(void (*decode)(struct dmi_header *)) u8 buf[15]; u32 fp=0xF0000; -#ifdef CONFIG_SIMNOW - /* - * Skip on x86/64 with simnow. Will eventually go away - * If you see this ifdef in 2.6pre mail me ! - */ - return -1; -#endif - - while( fp < 0xFFFFF) + while (fp < 0xFFFFF) { isa_memcpy_fromio(buf, fp, 15); if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf)) diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c index 310090d060ec..43a40b791ec4 100644 --- a/arch/i386/kernel/efi.c +++ b/arch/i386/kernel/efi.c @@ -174,7 +174,7 @@ phys_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) return status; } -int inline efi_set_rtc_mmss(unsigned long nowtime) +inline int efi_set_rtc_mmss(unsigned long nowtime) { int real_seconds, real_minutes; efi_status_t status; @@ -207,7 +207,7 @@ int inline efi_set_rtc_mmss(unsigned long nowtime) * services have been remapped, therefore, we'll need to call in physical * mode. Note, this call isn't used later, so mark it __init. */ -unsigned long inline __init efi_get_time(void) +inline unsigned long __init efi_get_time(void) { efi_status_t status; efi_time_t eft; diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index 65054ace1509..2a7f59c37977 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c @@ -307,7 +307,31 @@ unsigned long get_cmos_time(void) return retval; } +static long clock_cmos_diff; + +static int time_suspend(struct sys_device *dev, u32 state) +{ + /* + * Estimate time zone so that set_time can update the clock + */ + clock_cmos_diff = -get_cmos_time(); + clock_cmos_diff += get_seconds(); + return 0; +} + +static int time_resume(struct sys_device *dev) +{ + unsigned long sec = get_cmos_time() + clock_cmos_diff; + write_seqlock_irq(&xtime_lock); + xtime.tv_sec = sec; + xtime.tv_nsec = 0; + write_sequnlock_irq(&xtime_lock); + return 0; +} + static struct sysdev_class pit_sysclass = { + .resume = time_resume, + .suspend = time_suspend, set_kset_name("pit"), }; diff --git a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c index 3ea82f9731f4..a281711ecea7 100644 --- a/arch/i386/kernel/time_hpet.c +++ b/arch/i386/kernel/time_hpet.c @@ -91,10 +91,6 @@ int __init hpet_enable(void) !(id & HPET_ID_LEGSUP)) return -1; - if (((id & HPET_ID_VENDOR) >> HPET_ID_VENDOR_SHIFT) != - HPET_ID_VENDOR_8086) - return -1; - hpet_period = hpet_readl(HPET_PERIOD); if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD)) return -1; diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 4f514bae9d9f..d6a3503cb795 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -405,7 +405,8 @@ config EFI_VARS support" (CONFIG_PROC_FS) is enabled, too. config NR_CPUS - int "Maximum number of CPUs" + int "Maximum number of CPUs (2-512)" + range 2 512 depends on SMP default "64" help diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 1af40201af85..99f5f315fbc3 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -55,10 +55,6 @@ # error "struct cpuinfo_ia64 too big!" #endif -#ifdef CONFIG_EFI -int efi_enabled = 1; -#endif - #ifdef CONFIG_SMP unsigned long __per_cpu_offset[NR_CPUS]; EXPORT_SYMBOL(__per_cpu_offset); diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c index 50a5420d9e16..201b66e00863 100644 --- a/arch/m68k/bvme6000/rtc.c +++ b/arch/m68k/bvme6000/rtc.c @@ -53,6 +53,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, /* Ensure clock and real-time-mode-register are accessible */ msr = rtc->msr & 0xc0; rtc->msr = 0x40; + memset(&wtime, 0, sizeof(struct rtc_time)); do { wtime.tm_sec = BCD2BIN(rtc->bcd_sec); wtime.tm_min = BCD2BIN(rtc->bcd_min); diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c index 2869be097e69..1196442f80dc 100644 --- a/arch/m68k/mvme16x/rtc.c +++ b/arch/m68k/mvme16x/rtc.c @@ -51,6 +51,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, local_irq_save(flags); /* Ensure clock and real-time-mode-register are accessible */ rtc->ctrl = RTC_READ; + memset(&wtime, 0, sizeof(struct rtc_time)); wtime.tm_sec = BCD2BIN(rtc->bcd_sec); wtime.tm_min = BCD2BIN(rtc->bcd_min); wtime.tm_hour = BCD2BIN(rtc->bcd_hr); diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index edb286f9d483..f7dc991d1631 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -981,6 +981,7 @@ config SMP config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP default "32" help diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index d93e742d128a..7938686bbb32 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -154,6 +154,7 @@ config HPUX config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP default "32" diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig index 16d645ab3cea..ec25b00bfaaf 100644 --- a/arch/ppc/Kconfig +++ b/arch/ppc/Kconfig @@ -681,6 +681,7 @@ config IRQ_ALL_CPUS config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP default "4" diff --git a/arch/ppc/boot/prep/Makefile b/arch/ppc/boot/prep/Makefile index 81344c777654..5a5c80837282 100644 --- a/arch/ppc/boot/prep/Makefile +++ b/arch/ppc/boot/prep/Makefile @@ -27,9 +27,10 @@ utils := $(boot)/utils bootlib := $(boot)/lib images := $(boot)/images simple := $(boot)/simple +of1275 := $(boot)/of1275 OBJCOPYFLAGS := -O elf32-powerpc -LIBS := $(common)/lib.a $(bootlib)/lib.a +LIBS := $(common)/lib.a $(bootlib)/lib.a $(of1275)/lib.a targets := $(boot-y) dummy.o ../simple/legacy.o OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o diff --git a/arch/ppc/boot/prep/head.S b/arch/ppc/boot/prep/head.S index 33e354558da5..ef4e49c1f41c 100644 --- a/arch/ppc/boot/prep/head.S +++ b/arch/ppc/boot/prep/head.S @@ -35,9 +35,28 @@ start_: mr r11,r3 /* Save pointer to residual/board data */ - /* Establish default MSR value */ - li r3,MSR_IP|MSR_FP - mtmsr r3 +/* + * Save the OF pointer to r25, but only if the entry point is in a sane + * location; if not we store 0. If there is no entry point, or it is + * invalid, we establish the default MSR value immediately. Otherwise, + * we defer doing that, to allow OF functions to be called, until we + * begin uncompressing the kernel. + */ + lis r3,0x0fff /* r3 = 0x0fffffff */ + ori r3,r3,0xffff + + subc r3,r3,r5 /* r3 = (r5 <= r3) ? ~0 : 0 */ + subfe r3,r3,r3 + nand r3,r3,r3 + + and. r5,r5,r3 /* r5 will be cleared if (r5 > r3) */ + bne+ haveOF + + li r3,MSR_IP|MSR_FP /* Not OF: set MSR immediately */ + mtmsr r3 + isync +haveOF: + mr r25,r5 /* compute the size of the whole image in words. */ lis r4,start@h @@ -111,6 +130,7 @@ start_ldr: mr r4,r7 /* Program length */ mr r5,r6 /* Checksum */ mr r6,r11 /* Residual data */ + mr r7,r25 /* Validated OFW interface */ bl decompress_kernel /* diff --git a/arch/ppc/boot/prep/misc.c b/arch/ppc/boot/prep/misc.c index 9f84df4c850a..137f4c183e6a 100644 --- a/arch/ppc/boot/prep/misc.c +++ b/arch/ppc/boot/prep/misc.c @@ -19,7 +19,7 @@ #include <asm/bootinfo.h> #include <asm/mmu.h> #include <asm/byteorder.h> - +#include "of1275.h" #include "nonstdio.h" #include "zlib.h" @@ -114,17 +114,19 @@ scroll(void) unsigned long decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, - RESIDUAL *residual) + RESIDUAL *residual, void *OFW_interface) { int timer = 0; extern unsigned long start; char *cp, ch; unsigned long TotalMemory; - unsigned char board_type; - unsigned char base_mod; int start_multi = 0; unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base; + /* If we have Open Firmware, initialise it immediately */ + if (OFW_interface) + ofinit(OFW_interface); + serial_fixups(); #if defined(CONFIG_SERIAL_8250_CONSOLE) com_port = serial_init(0, NULL); @@ -163,7 +165,8 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, /* Is this Motorola PPCBug? */ if ((1 & residual->VitalProductData.FirmwareSupports) && (1 == residual->VitalProductData.FirmwareSupplier)) { - board_type = inb(0x800) & 0xF0; + unsigned char base_mod; + unsigned char board_type = inb(0x800) & 0xF0; /* * Reset the onboard 21x4x Ethernet @@ -229,8 +232,31 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, /* If it's not, see if we have anything in the residual data. */ else if (residual && residual->TotalMemory) TotalMemory = residual->TotalMemory; - /* Fall back to hard-coding 32MB. */ - else + else if (OFW_interface) { + /* + * This is a 'best guess' check. We want to make sure + * we don't try this on a PReP box without OF + * -- Cort + */ + while (OFW_interface) + { + phandle dev_handle; + int mem_info[2]; + + /* get handle to memory description */ + if (!(dev_handle = finddevice("/memory@0"))) + break; + + /* get the info */ + if (getprop(dev_handle, "reg", mem_info, + sizeof(mem_info)) != 8) + break; + + TotalMemory = mem_info[1]; + break; + } + } else + /* Fall back to hard-coding 32MB. */ TotalMemory = 32*1024*1024; @@ -304,6 +330,18 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, *cp = 0; puts("\nUncompressing Linux..."); + /* + * If we have OF, then we have deferred setting the MSR. + * We must set it now because we are about to overwrite + * the exception table. The new MSR value will disable + * machine check exceptions and point the exception table + * to the ROM. + */ + if (OFW_interface) { + mtmsr(MSR_IP | MSR_FP); + asm volatile("isync"); + } + gunzip(0, 0x400000, zimage_start, &zimage_size); puts("done.\n"); diff --git a/arch/ppc/kernel/syscalls.c b/arch/ppc/kernel/syscalls.c index 9fc171466316..2f0f5778538c 100644 --- a/arch/ppc/kernel/syscalls.c +++ b/arch/ppc/kernel/syscalls.c @@ -271,5 +271,3 @@ long ppc_fadvise64_64(int fd, int advice, loff_t offset, loff_t len) { return sys_fadvise64_64(fd, offset, len, advice); } - -cond_syscall(sys_pciconfig_iobase); diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig index 877e92374e08..da52c803e16f 100644 --- a/arch/ppc64/Kconfig +++ b/arch/ppc64/Kconfig @@ -112,6 +112,7 @@ config IRQ_ALL_CPUS config NR_CPUS int "Maximum number of CPUs (2-128)" + range 2 128 depends on SMP default "32" diff --git a/arch/ppc64/kernel/rtc.c b/arch/ppc64/kernel/rtc.c index 938c78f27a0b..eff800053c34 100644 --- a/arch/ppc64/kernel/rtc.c +++ b/arch/ppc64/kernel/rtc.c @@ -99,6 +99,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, switch (cmd) { case RTC_RD_TIME: /* Read the time/date from RTC */ { + memset(&wtime, 0, sizeof(struct rtc_time)); ppc_md.get_rtc_time(&wtime); break; } diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index f9f86dd0b5fb..a0f338a91eca 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -97,6 +97,7 @@ config SMP config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP && ARCH_S390X = 'n' default "32" help @@ -109,6 +110,7 @@ config NR_CPUS config NR_CPUS int "Maximum number of CPUs (2-64)" + range 2 64 depends on SMP && ARCH_S390X default "64" help diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 7d650503e52a..caf27cd4cce9 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -492,6 +492,7 @@ config SMP config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP default "2" help diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index c9d557f7e660..f29b3f98c648 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -112,6 +112,7 @@ config SMP config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP default "32" diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig index dfff0d578652..bc39ada548f3 100644 --- a/arch/sparc64/Kconfig +++ b/arch/sparc64/Kconfig @@ -128,6 +128,7 @@ config PREEMPT config NR_CPUS int "Maximum number of CPUs (2-64)" + range 2 64 depends on SMP default "64" diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 3fe585966686..aeb6e0ebd619 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -128,6 +128,7 @@ config SMP config NR_CPUS int "Maximum number of CPUs (2-32)" + range 2 32 depends on SMP default "32" diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index 3e928aa6c529..c29b7fe7fb23 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig @@ -233,6 +233,7 @@ config HAVE_DEC_LOCK # to use clustered mode or whatever your big iron needs config NR_CPUS int "Maximum number of CPUs (2-8)" + range 2 8 depends on SMP default "8" help diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c index b8d9ac66a2f9..997cf28f4b75 100644 --- a/drivers/acorn/char/i2c.c +++ b/drivers/acorn/char/i2c.c @@ -167,6 +167,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, break; case RTC_RD_TIME: + memset(&rtctm, 0, sizeof(struct rtc_time)); get_rtc_time(&rtc_raw, &year); rtctm.tm_sec = rtc_raw.secs; rtctm.tm_min = rtc_raw.mins; diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index f97f1ec6bc1b..c23382abd4f5 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -173,9 +173,11 @@ EXPORT_SYMBOL(blk_queue_prep_rq); * are dynamic, and thus we have to query the queue whether it is ok to * add a new bio_vec to a bio at a given offset or not. If the block device * has such limitations, it needs to register a merge_bvec_fn to control - * the size of bio's sent to it. Per default now merge_bvec_fn is defined for - * a queue, and only the fixed limits are honored. - * + * the size of bio's sent to it. Note that a block device *must* allow a + * single page to be added to an empty bio. The block device driver may want + * to use the bio_split() function to deal with these bio's. By default + * no merge_bvec_fn is defined for a queue, and only the fixed limits are + * honored. */ void blk_queue_merge_bvec(request_queue_t *q, merge_bvec_fn *mbfn) { @@ -2488,8 +2490,6 @@ static int __end_that_request_first(struct request *req, int uptodate, * not a complete bvec done */ if (unlikely(nbytes > nr_bytes)) { - bio_iovec_idx(bio, idx)->bv_offset += nr_bytes; - bio_iovec_idx(bio, idx)->bv_len -= nr_bytes; bio_nbytes += nr_bytes; total_bytes += nr_bytes; break; @@ -2525,7 +2525,9 @@ static int __end_that_request_first(struct request *req, int uptodate, */ if (bio_nbytes) { bio_endio(bio, bio_nbytes, error); - req->bio->bi_idx += next_idx; + bio->bi_idx += next_idx; + bio_iovec(bio)->bv_offset += nr_bytes; + bio_iovec(bio)->bv_len -= nr_bytes; } blk_recalc_rq_sectors(req, total_bytes >> 9); diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index 569f12605e0d..893716b679bc 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c @@ -118,6 +118,7 @@ convert_to_efi_time(struct rtc_time *wtime, efi_time_t *eft) static void convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) { + memset(wtime, 0, sizeof(*wtime)); wtime->tm_sec = eft->second; wtime->tm_min = eft->minute; wtime->tm_hour = eft->hour; diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index fcdc4eb0b9ac..dfe289eaef61 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -431,7 +431,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) * means "don't care" or "match all". Only the tm_hour, * tm_min, and tm_sec values are filled in. */ - + memset(&wtime, 0, sizeof(struct rtc_time)); get_rtc_alm_time(&wtime); break; } @@ -481,6 +481,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) } case RTC_RD_TIME: /* Read the time/date from RTC */ { + memset(&wtime, 0, sizeof(struct rtc_time)); rtc_get_rtc_time(&wtime); break; } diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index bd1e49780a86..249935804e71 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c @@ -271,11 +271,11 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = { }; /* key2index calculation, -1 on invalid index */ -static __inline__ int sysrq_key_table_key2index(int key) { +static int sysrq_key_table_key2index(int key) { int retval; - if ((key >= '0') & (key <= '9')) { + if ((key >= '0') && (key <= '9')) { retval = key - '0'; - } else if ((key >= 'a') & (key <= 'z')) { + } else if ((key >= 'a') && (key <= 'z')) { retval = key + 10 - 'a'; } else { retval = -1; diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 464c3404d4dc..dcb286822cbb 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -530,17 +530,22 @@ static void add_softcursor(int currcons) sw->con_putc(vc_cons[currcons].d, i, y, x); } -static void hide_cursor(int currcons) +static void hide_softcursor(int currcons) { - if (currcons == sel_cons) - clear_selection(); if (softcursor_original != -1) { scr_writew(softcursor_original,(u16 *) pos); if (DO_UPDATE) sw->con_putc(vc_cons[currcons].d, softcursor_original, y, x); softcursor_original = -1; } +} + +static void hide_cursor(int currcons) +{ + if (currcons == sel_cons) + clear_selection(); sw->con_cursor(vc_cons[currcons].d,CM_ERASE); + hide_softcursor(currcons); } static void set_cursor(int currcons) diff --git a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c index 08891c0947da..705ba5cb63ae 100644 --- a/drivers/char/watchdog/acquirewdt.c +++ b/drivers/char/watchdog/acquirewdt.c @@ -100,7 +100,7 @@ static ssize_t acq_write(struct file *file, const char *buf, size_t count, loff_ * five months ago... */ expect_close = 0; - /* scan to see wether or not we got the magic character */ + /* scan to see whether or not we got the magic character */ for (i = 0; i != count; i++) { char c; if (get_user(c, buf + i)) @@ -263,33 +263,33 @@ static int __init acq_init(void) goto unreg_stop; } - ret = register_reboot_notifier(&acq_notifier); - if (ret != 0) { - printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", - ret); - goto unreg_regions; - } - - ret = misc_register(&acq_miscdev); - if (ret != 0) { - printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", - WATCHDOG_MINOR, ret); - goto unreg_reboot; - } - - printk (KERN_INFO PFX "initialized. (nowayout=%d)\n", - nowayout); - + ret = register_reboot_notifier(&acq_notifier); + if (ret != 0) { + printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + ret); + goto unreg_regions; + } + + ret = misc_register(&acq_miscdev); + if (ret != 0) { + printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + WATCHDOG_MINOR, ret); + goto unreg_reboot; + } + + printk (KERN_INFO PFX "initialized. (nowayout=%d)\n", + nowayout); + out: - return ret; + return ret; unreg_reboot: - unregister_reboot_notifier(&acq_notifier); + unregister_reboot_notifier(&acq_notifier); unreg_regions: - release_region(wdt_start, 1); + release_region(wdt_start, 1); unreg_stop: - if (wdt_stop != wdt_start) - release_region(wdt_stop, 1); - goto out; + if (wdt_stop != wdt_start) + release_region(wdt_stop, 1); + goto out; } static void __exit acq_exit(void) diff --git a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c index b0cc38685253..cdaf1faf3002 100644 --- a/drivers/char/watchdog/advantechwdt.c +++ b/drivers/char/watchdog/advantechwdt.c @@ -183,7 +183,7 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, } default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; } diff --git a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c index 6c3ba56186be..45d823589a6c 100644 --- a/drivers/char/watchdog/alim1535_wdt.c +++ b/drivers/char/watchdog/alim1535_wdt.c @@ -153,7 +153,7 @@ static ssize_t ali_write(struct file *file, const char *data, * five months ago... */ ali_expect_release = 0; - /* scan to see wether or not we got the magic character */ + /* scan to see whether or not we got the magic character */ for (i = 0; i != len; i++) { char c; if(get_user(c, data+i)) @@ -402,7 +402,7 @@ static int __init watchdog_init(void) spin_lock_init(&ali_lock); - /* Check wether or not the hardware watchdog is there */ + /* Check whether or not the hardware watchdog is there */ if (ali_find_watchdog() != 0) { return -ENODEV; } diff --git a/drivers/char/watchdog/alim7101_wdt.c b/drivers/char/watchdog/alim7101_wdt.c index 323fc2019e2a..707b0cb7631e 100644 --- a/drivers/char/watchdog/alim7101_wdt.c +++ b/drivers/char/watchdog/alim7101_wdt.c @@ -374,7 +374,7 @@ static int __init alim7101_wdt_init(void) err_out_miscdev: misc_deregister(&wdt_miscdev); err_out: - return rc; + return rc; } module_init(alim7101_wdt_init); diff --git a/drivers/char/watchdog/amd7xx_tco.c b/drivers/char/watchdog/amd7xx_tco.c index 78240eeaa784..17316f34df47 100644 --- a/drivers/char/watchdog/amd7xx_tco.c +++ b/drivers/char/watchdog/amd7xx_tco.c @@ -19,6 +19,7 @@ #include <linux/config.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/watchdog.h> @@ -45,7 +46,7 @@ #define TCO_TIMEOUT_MASK 0x3f #define TCO_STATUS1_REG 0x44 #define TCO_STATUS2_REG 0x46 -#define NDTO_STS2 (1 << 1) /* we're interested in the second timeout */ +#define NDTO_STS2 (1 << 1) /* we're interested in the second timeout */ #define BOOT_STS (1 << 2) /* will be set if NDTO_STS2 was set before reboot */ #define TCO_CTRL1_REG 0x48 #define TCO_HALT (1 << 11) @@ -57,11 +58,20 @@ static u32 pmbase; /* PMxx I/O base */ static struct pci_dev *dev; static struct semaphore open_sem; static spinlock_t amdtco_lock; /* only for device access */ -static int expect_close = 0; +static char expect_close; -MODULE_PARM(timeout, "i"); +module_param(timeout, int, 0); MODULE_PARM_DESC(timeout, "range is 0-38 seconds, default is 38"); +#ifdef CONFIG_WATCHDOG_NOWAYOUT +static int nowayout = 1; +#else +static int nowayout = 0; +#endif + +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + static inline u8 seconds_to_ticks(int seconds) { /* the internal timer is stored as ticks which decrement @@ -124,7 +134,7 @@ static inline void amdtco_global_enable(void) static inline void amdtco_enable(void) { u16 reg; - + spin_lock(&amdtco_lock); reg = inw(pmbase+TCO_CTRL1_REG); reg &= ~TCO_HALT; @@ -152,13 +162,13 @@ static int amdtco_fop_open(struct inode *inode, struct file *file) timeout = MAX_TIMEOUT; amdtco_disable(); - amdtco_settimeout(timeout); + amdtco_settimeout(timeout); amdtco_global_enable(); amdtco_enable(); amdtco_ping(); printk(KERN_INFO PFX "Watchdog enabled, timeout = %ds of %ds\n", amdtco_gettimeout(), timeout); - + return 0; } @@ -170,12 +180,12 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int static struct watchdog_info ident = { .options = WDIOF_SETTIMEOUT | WDIOF_CARDRESET, - .identity = "AMD 766/768" + .identity = "AMD 766/768", }; switch (cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof ident)) @@ -184,7 +194,7 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int case WDIOC_GETSTATUS: return put_user(amdtco_status(), (int *)arg); - + case WDIOC_KEEPALIVE: amdtco_ping(); return 0; @@ -192,10 +202,10 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int case WDIOC_SETTIMEOUT: if (get_user(new_timeout, (int *)arg)) return -EFAULT; - + if (new_timeout < 0) return -EINVAL; - + if (new_timeout > MAX_TIMEOUT) new_timeout = MAX_TIMEOUT; @@ -205,17 +215,17 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int case WDIOC_GETTIMEOUT: return put_user(amdtco_gettimeout(), (int *)arg); - + case WDIOC_SETOPTIONS: if (copy_from_user(&tmp, (int *)arg, sizeof tmp)) - return -EFAULT; + return -EFAULT; if (tmp & WDIOS_DISABLECARD) amdtco_disable(); if (tmp & WDIOS_ENABLECARD) amdtco_enable(); - + return 0; } } @@ -223,14 +233,15 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int static int amdtco_fop_release(struct inode *inode, struct file *file) { - if (expect_close) { - amdtco_disable(); + if (expect_close == 42) { + amdtco_disable(); printk(KERN_INFO PFX "Watchdog disabled\n"); } else { amdtco_ping(); printk(KERN_CRIT PFX "Unexpected close!, timeout in %d seconds\n", timeout); - } - + } + + expect_close = 0; up(&open_sem); return 0; } @@ -240,21 +251,21 @@ static ssize_t amdtco_fop_write(struct file *file, const char *data, size_t len, { if (ppos != &file->f_pos) return -ESPIPE; - - if (len) { -#ifndef CONFIG_WATCHDOG_NOWAYOUT - size_t i; - char c; - expect_close = 0; - - for (i = 0; i != len; i++) { - if (get_user(c, data + i)) - return -EFAULT; - if (c == 'V') - expect_close = 1; + if (len) { + if (!nowayout) { + size_t i; + char c; + expect_close = 0; + + for (i = 0; i != len; i++) { + if (get_user(c, data + i)) + return -EFAULT; + + if (c == 'V') + expect_close = 42; + } } -#endif amdtco_ping(); } @@ -273,7 +284,7 @@ static int amdtco_notify_sys(struct notifier_block *this, unsigned long code, vo static struct notifier_block amdtco_notifier = { - .notifier_call = amdtco_notify_sys + .notifier_call = amdtco_notify_sys, }; static struct file_operations amdtco_fops = @@ -282,20 +293,20 @@ static struct file_operations amdtco_fops = .write = amdtco_fop_write, .ioctl = amdtco_fop_ioctl, .open = amdtco_fop_open, - .release = amdtco_fop_release + .release = amdtco_fop_release, }; static struct miscdevice amdtco_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &amdtco_fops + .fops = &amdtco_fops, }; static struct pci_device_id amdtco_pci_tbl[] = { /* AMD 766 PCI_IDs here */ { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_OPUS_7443, PCI_ANY_ID, PCI_ANY_ID, }, - { 0, } + { 0, }, }; MODULE_DEVICE_TABLE (pci, amdtco_pci_tbl); @@ -316,7 +327,7 @@ static int __init amdtco_init(void) return -ENODEV; found_one: - + if ((ret = register_reboot_notifier(&amdtco_notifier))) { printk(KERN_ERR PFX "Unable to register reboot notifier err = %d\n", ret); goto out_clean; diff --git a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c index 36897e1ad3e0..b68f2e682e18 100644 --- a/drivers/char/watchdog/cpu5wdt.c +++ b/drivers/char/watchdog/cpu5wdt.c @@ -105,8 +105,8 @@ static void cpu5wdt_start(void) { if ( !cpu5wdt_device.queue ) { cpu5wdt_device.queue = 1; - outb(0, port + CPU5WDT_TIME_A_REG); - outb(0, port + CPU5WDT_TIME_B_REG); + outb(0, port + CPU5WDT_TIME_A_REG); + outb(0, port + CPU5WDT_TIME_B_REG); outb(1, port + CPU5WDT_MODE_REG); outb(0, port + CPU5WDT_RESET_REG); outb(0, port + CPU5WDT_ENABLE_REG); @@ -134,23 +134,15 @@ static int cpu5wdt_stop(void) static int cpu5wdt_open(struct inode *inode, struct file *file) { - switch(iminor(inode)) { - case WATCHDOG_MINOR: - if ( test_and_set_bit(0, &cpu5wdt_device.inuse) ) - return -EBUSY; - break; - default: - return -ENODEV; - } + if ( test_and_set_bit(0, &cpu5wdt_device.inuse) ) + return -EBUSY; return 0; } static int cpu5wdt_release(struct inode *inode, struct file *file) { - if(iminor(inode)==WATCHDOG_MINOR) { - clear_bit(0, &cpu5wdt_device.inuse); - } + clear_bit(0, &cpu5wdt_device.inuse); return 0; } @@ -160,15 +152,15 @@ static int cpu5wdt_ioctl(struct inode *inode, struct file *file, unsigned int cm static struct watchdog_info ident = { .options = WDIOF_CARDRESET, - .identity = "CPU5 WDT" + .identity = "CPU5 WDT", }; - + switch(cmd) { case WDIOC_KEEPALIVE: cpu5wdt_reset(); break; - case WDIOC_GETSTATUS: - value = inb(port + CPU5WDT_STATUS_REG); + case WDIOC_GETSTATUS: + value = inb(port + CPU5WDT_STATUS_REG); value = (value >> 2) & 1; if ( copy_to_user((int *)arg, (int *)&value, sizeof(int)) ) return -EFAULT; @@ -191,7 +183,7 @@ static int cpu5wdt_ioctl(struct inode *inode, struct file *file, unsigned int cm } break; default: - return -EINVAL; + return -ENOIOCTLCMD; } return 0; } @@ -200,7 +192,7 @@ static ssize_t cpu5wdt_write(struct file *file, const char *buf, size_t count, l { if ( !count ) return -EIO; - + cpu5wdt_reset(); return count; @@ -217,7 +209,7 @@ static struct file_operations cpu5wdt_fops = { static struct miscdevice cpu5wdt_misc = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &cpu5wdt_fops + .fops = &cpu5wdt_fops, }; /* init/exit function */ @@ -242,7 +234,7 @@ static int __devinit cpu5wdt_init(void) } /* watchdog reboot? */ - val = inb(port + CPU5WDT_STATUS_REG); + val = inb(port + CPU5WDT_STATUS_REG); val = (val >> 2) & 1; if ( !val ) printk(KERN_INFO PFX "sorry, was my fault\n"); diff --git a/drivers/char/watchdog/eurotechwdt.c b/drivers/char/watchdog/eurotechwdt.c index 050317b26360..b7b2dc934418 100644 --- a/drivers/char/watchdog/eurotechwdt.c +++ b/drivers/char/watchdog/eurotechwdt.c @@ -1,5 +1,5 @@ /* - * Eurotech CPU-1220/1410 on board WDT driver for Linux 2.4.x + * Eurotech CPU-1220/1410 on board WDT driver * * (c) Copyright 2001 Ascensit <support@ascensit.com> * (c) Copyright 2001 Rodolfo Giometti <giometti@ascensit.com> @@ -64,11 +64,11 @@ static char eur_expect_close; * You must set these - there is no sane way to probe for this board. * You can use eurwdt=x,y to set these now. */ - + static int io = 0x3f0; static int irq = 10; static char *ev = "int"; - + #define WDT_TIMEOUT 60 /* 1 minute */ #ifdef CONFIG_WATCHDOG_NOWAYOUT @@ -81,7 +81,7 @@ MODULE_PARM(nowayout,"i"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); /* - * Some symbolic names + * Some symbolic names */ #define WDT_CTRL_REG 0x30 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON #define WDT_UNIT_SECS 0x80 #define WDT_TIMEOUT_VAL 0xf2 #define WDT_TIMER_CFG 0xf3 - + #ifndef MODULE @@ -104,26 +104,26 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON * get the user to tell us the configuration. Sane people build it * modular but the others come here. */ - + static int __init eurwdt_setup(char *str) { int ints[4]; - + str = get_options (str, ARRAY_SIZE(ints), ints); - + if (ints[0] > 0) { io = ints[1]; if (ints[0] > 1) irq = ints[2]; } - + return 1; } - + __setup("eurwdt=", eurwdt_setup); #endif /* !MODULE */ - + MODULE_PARM(io, "i"); MODULE_PARM_DESC(io, "Eurotech WDT io port (default=0x3f0)"); MODULE_PARM(irq, "i"); @@ -162,7 +162,7 @@ static inline void eurwdt_disable_timer(void) { eurwdt_set_timeout(0); } - + static void eurwdt_activate_timer(void) { eurwdt_disable_timer(); @@ -180,18 +180,18 @@ static void eurwdt_activate_timer(void) eurwdt_write_reg(WDT_TIMER_CFG, irq<<4); eurwdt_write_reg(WDT_UNIT_SEL, WDT_UNIT_SECS); /* we use seconds */ - eurwdt_set_timeout(0); /* the default timeout */ + eurwdt_set_timeout(0); /* the default timeout */ } /* * Kernel methods. */ - + static irqreturn_t eurwdt_interrupt(int irq, void *dev_id, struct pt_regs *regs) { printk(KERN_CRIT "timeout WDT timeout\n"); - + #ifdef ONLY_TESTING printk(KERN_CRIT "Would Reboot.\n"); #else @@ -207,13 +207,13 @@ static irqreturn_t eurwdt_interrupt(int irq, void *dev_id, struct pt_regs *regs) * * Reload counter one with the watchdog timeout. */ - + static void eurwdt_ping(void) { /* Write the watchdog default value */ eurwdt_set_timeout(eurwdt_timeout); } - + /** * eurwdt_write: * @file: file handle to the watchdog @@ -224,14 +224,14 @@ static void eurwdt_ping(void) * A write to a watchdog device is defined as a keepalive signal. Any * write of data will do, as we we don't define content meaning. */ - + static ssize_t eurwdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { /* Can't seek (pwrite) on this device */ if (ppos != &file->f_pos) return -ESPIPE; - + if (count) { if (!nowayout) { size_t i; @@ -262,7 +262,7 @@ loff_t *ppos) * The watchdog API defines a common set of functions for all watchdogs * according to their available features. */ - + static int eurwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { @@ -274,15 +274,15 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, int time; int options, retval = -EINVAL; - + switch(cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)) ? -EFAULT : 0; - + case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0, (int *) arg); @@ -299,8 +299,8 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, if (time < 0 || time > 255) return -EINVAL; - eurwdt_timeout = time; - eurwdt_set_timeout(time); + eurwdt_timeout = time; + eurwdt_set_timeout(time); /* Fall */ case WDIOC_GETTIMEOUT: @@ -330,7 +330,7 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, * The misc device has been opened. The watchdog device is single * open and on opening we load the counter. */ - + static int eurwdt_open(struct inode *inode, struct file *file) { if (test_and_set_bit(0, &eurwdt_is_open)) @@ -340,7 +340,7 @@ static int eurwdt_open(struct inode *inode, struct file *file) eurwdt_activate_timer(); return 0; } - + /** * eurwdt_release: * @inode: inode to board @@ -352,7 +352,7 @@ static int eurwdt_open(struct inode *inode, struct file *file) * reboots. In the former case we disable the counters, in the latter * case you have to open it again very soon. */ - + static int eurwdt_release(struct inode *inode, struct file *file) { if (eur_expect_close == 42) { @@ -360,12 +360,12 @@ static int eurwdt_release(struct inode *inode, struct file *file) } else { printk(KERN_CRIT "eurwdt: Unexpected close, not stopping watchdog!\n"); eurwdt_ping(); - } + } clear_bit(0, &eurwdt_is_open); eur_expect_close = 0; return 0; } - + /** * eurwdt_notify_sys: * @this: our notifier block @@ -377,7 +377,7 @@ static int eurwdt_release(struct inode *inode, struct file *file) * test or worse yet during the following fsck. This would suck, in fact * trust me - if it happens it does suck. */ - + static int eurwdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { @@ -388,12 +388,12 @@ static int eurwdt_notify_sys(struct notifier_block *this, unsigned long code, return NOTIFY_DONE; } - + /* * Kernel Interfaces */ - - + + static struct file_operations eurwdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, @@ -406,18 +406,18 @@ static struct file_operations eurwdt_fops = { static struct miscdevice eurwdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &eurwdt_fops + .fops = &eurwdt_fops, }; - + /* * The WDT card needs to learn about soft shutdowns in order to * turn the timebomb registers off. */ - + static struct notifier_block eurwdt_notifier = { .notifier_call = eurwdt_notify_sys, }; - + /** * cleanup_module: * @@ -427,7 +427,7 @@ static struct notifier_block eurwdt_notifier = { * will not touch PC memory so all is fine. You just have to load a new * module in 60 seconds or reboot. */ - + static void __exit eurwdt_exit(void) { eurwdt_lock_chip(); @@ -438,15 +438,15 @@ static void __exit eurwdt_exit(void) release_region(io, 2); free_irq(irq, NULL); } - + /** * eurwdt_init: * - * Set up the WDT watchdog board. After grabbing the resources + * Set up the WDT watchdog board. After grabbing the resources * we require we need also to unlock the device. * The open() function will actually kick the board off. */ - + static int __init eurwdt_init(void) { int ret; @@ -477,15 +477,15 @@ static int __init eurwdt_init(void) } eurwdt_unlock_chip(); - + ret = 0; printk(KERN_INFO "Eurotech WDT driver 0.01 at %X (Interrupt %d)" - " - timeout event: %s\n", + " - timeout event: %s\n", io, irq, (!strcmp("int", ev) ? "int" : "reboot")); out: return ret; - + outreg: release_region(io, 2); @@ -496,10 +496,10 @@ outmisc: misc_deregister(&eurwdt_miscdev); goto out; } - + module_init(eurwdt_init); module_exit(eurwdt_exit); - + MODULE_AUTHOR("Rodolfo Giometti"); MODULE_DESCRIPTION("Driver for Eurotech CPU-1220/1410 on board watchdog"); MODULE_LICENSE("GPL"); diff --git a/drivers/char/watchdog/i810-tco.c b/drivers/char/watchdog/i810-tco.c index f5d1400fafde..230a485ae364 100644 --- a/drivers/char/watchdog/i810-tco.c +++ b/drivers/char/watchdog/i810-tco.c @@ -8,7 +8,7 @@ * 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. - * + * * Neither kernel concepts nor Nils Faerber admit liability nor provide * warranty for any of this software. This material is provided * "AS-IS" and at no charge. @@ -112,7 +112,7 @@ static int tco_timer_start (void) outb (val, TCO1_CNT + 1); val = inb (TCO1_CNT + 1); spin_unlock(&tco_lock); - + if (val & 0x08) return -1; return 0; @@ -131,7 +131,7 @@ static int tco_timer_stop (void) outb (val, TCO1_CNT + 1); val = inb (TCO1_CNT + 1); spin_unlock(&tco_lock); - + if ((val & 0x08) == 0) return -1; return 0; @@ -148,7 +148,7 @@ static int tco_timer_settimer (unsigned char tmrval) /* "Values of 0h-3h are ignored and should not be attempted" */ if (tmrval > 0x3f || tmrval < 0x04) return -1; - + spin_lock(&tco_lock); val = inb (TCO1_TMR); val &= 0xc0; @@ -156,7 +156,7 @@ static int tco_timer_settimer (unsigned char tmrval) outb (val, TCO1_TMR); val = inb (TCO1_TMR); spin_unlock(&tco_lock); - + if ((val & 0x3f) != tmrval) return -1; @@ -197,7 +197,7 @@ static int i810tco_release (struct inode *inode, struct file *file) /* * Shut off the timer. */ - if (tco_expect_close == 42 && !nowayout) { + if (tco_expect_close == 42) { tco_timer_stop (); } else { tco_timer_reload (); @@ -217,17 +217,21 @@ static ssize_t i810tco_write (struct file *file, const char *data, /* See if we got the magic character 'V' and reload the timer */ if (len) { - size_t i; - - tco_expect_close = 0; - - /* scan to see whether or not we got the magic character */ - for (i = 0; i != len; i++) { - u8 c; - if(get_user(c, data+i)) - return -EFAULT; - if (c == 'V') - tco_expect_close = 42; + if (!nowayout) { + size_t i; + + /* note: just in case someone wrote the magic character + * five months ago... */ + tco_expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for (i = 0; i != len; i++) { + u8 c; + if(get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + tco_expect_close = 42; + } } /* someone wrote to us, we should reload the timer */ @@ -251,7 +255,7 @@ static int i810tco_ioctl (struct inode *inode, struct file *file, }; switch (cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: if (copy_to_user ((struct watchdog_info *) arg, &ident, sizeof (ident))) diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c index 6a6289dcc39f..7832ef9f973c 100644 --- a/drivers/char/watchdog/ib700wdt.c +++ b/drivers/char/watchdog/ib700wdt.c @@ -1,5 +1,5 @@ /* - * IB700 Single Board Computer WDT driver for Linux 2.4.x + * IB700 Single Board Computer WDT driver * * (c) Copyright 2001 Charles Howes <chowes@vsol.net> * @@ -28,7 +28,7 @@ * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * Added timeout module option to override default - * + * */ #include <linux/config.h> @@ -48,9 +48,9 @@ #include <asm/uaccess.h> #include <asm/system.h> -static int ibwdt_is_open; +static unsigned long ibwdt_is_open; static spinlock_t ibwdt_lock; -static int expect_close = 0; +static char expect_close; #define PFX "ib700wdt: " @@ -157,7 +157,7 @@ ibwdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos) if (get_user(c, buf + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } ibwdt_ping(); @@ -174,7 +174,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .firmware_version = 1, - .identity = "IB700 WDT" + .identity = "IB700 WDT", }; switch (cmd) { @@ -184,9 +184,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, break; case WDIOC_GETSTATUS: - if (copy_to_user((int *)arg, &ibwdt_is_open, sizeof(int))) - return -EFAULT; - break; + return put_user(0, (int *) arg); case WDIOC_KEEPALIVE: ibwdt_ping(); @@ -209,7 +207,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, break; default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; } @@ -217,38 +215,32 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int ibwdt_open(struct inode *inode, struct file *file) { - if (iminor(inode) == WATCHDOG_MINOR) { - spin_lock(&ibwdt_lock); - if (ibwdt_is_open) { - spin_unlock(&ibwdt_lock); - return -EBUSY; - } - if (nowayout) - __module_get(THIS_MODULE); - - /* Activate */ - ibwdt_is_open = 1; - ibwdt_ping(); + spin_lock(&ibwdt_lock); + if (test_and_set_bit(0, &ibwdt_is_open)) { spin_unlock(&ibwdt_lock); - return 0; - } else { - return -ENODEV; + return -EBUSY; } + if (nowayout) + __module_get(THIS_MODULE); + + /* Activate */ + ibwdt_ping(); + spin_unlock(&ibwdt_lock); + return 0; } static int ibwdt_close(struct inode *inode, struct file *file) { - if (iminor(inode) == WATCHDOG_MINOR) { - spin_lock(&ibwdt_lock); - if (expect_close) - outb_p(wd_times[wd_margin], WDT_STOP); - else - printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); - - ibwdt_is_open = 0; - spin_unlock(&ibwdt_lock); - } + spin_lock(&ibwdt_lock); + if (expect_close == 42) + outb_p(wd_times[wd_margin], WDT_STOP); + else + printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); + + clear_bit(0, &ibwdt_is_open); + expect_close = 0; + spin_unlock(&ibwdt_lock); return 0; } @@ -282,7 +274,7 @@ static struct file_operations ibwdt_fops = { static struct miscdevice ibwdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &ibwdt_fops + .fops = &ibwdt_fops, }; /* @@ -293,7 +285,7 @@ static struct miscdevice ibwdt_miscdev = { static struct notifier_block ibwdt_notifier = { .notifier_call = ibwdt_notify_sys, .next = NULL, - .priority = 0 + .priority = 0, }; static int __init ibwdt_init(void) diff --git a/drivers/char/watchdog/indydog.c b/drivers/char/watchdog/indydog.c index 6f4ec157d646..3ebcfa0204d4 100644 --- a/drivers/char/watchdog/indydog.c +++ b/drivers/char/watchdog/indydog.c @@ -7,10 +7,10 @@ * 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. - * + * * based on softdog.c by Alan Cox <alan@redhat.com> */ - + #include <linux/module.h> #include <linux/config.h> #include <linux/types.h> @@ -25,8 +25,8 @@ #include <asm/sgi/sgimc.h> static unsigned long indydog_alive; -static struct sgimc_misc_ctrl *mcmisc_regs; -static int expect_close = 0; +static struct sgimc_misc_ctrl *mcmisc_regs; +static char expect_close; #ifdef CONFIG_WATCHDOG_NOWAYOUT static int nowayout = 1; @@ -50,7 +50,7 @@ static void indydog_ping() static int indydog_open(struct inode *inode, struct file *file) { u32 mc_ctrl0; - + if( test_and_set_bit(0,&indydog_alive) ) return -EBUSY; @@ -65,7 +65,7 @@ static int indydog_open(struct inode *inode, struct file *file) mc_ctrl0 = mcmisc_regs->cpuctrl0 | SGIMC_CCTRL0_WDOG; mcmisc_regs->cpuctrl0 = mc_ctrl0; indydog_ping(); - + printk("Started watchdog timer.\n"); return 0; } @@ -77,8 +77,8 @@ static int indydog_release(struct inode *inode, struct file *file) * Lock it in if it's a module and we set nowayout */ - if (expect_close) { - u32 mc_ctrl0 = mcmisc_regs->cpuctrl0; + if (expect_close == 42) { + u32 mc_ctrl0 = mcmisc_regs->cpuctrl0; mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG; mcmisc_regs->cpuctrl0 = mc_ctrl0; printk("Stopped watchdog timer.\n"); @@ -86,6 +86,7 @@ static int indydog_release(struct inode *inode, struct file *file) printk(KERN_CRIT "WDT device closed unexpectedly. WDT will not stop!\n"); } clear_bit(0,&indydog_alive); + expect_close = 0; return 0; } @@ -109,7 +110,7 @@ static ssize_t indydog_write(struct file *file, const char *data, size_t len, lo if (get_user(c, data + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } indydog_ping(); diff --git a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c index b46cbda00940..0abd90275d6c 100644 --- a/drivers/char/watchdog/machzwd.c +++ b/drivers/char/watchdog/machzwd.c @@ -1,7 +1,7 @@ /* * MachZ ZF-Logic Watchdog Timer driver for Linux - * - * + * + * * 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 @@ -14,14 +14,14 @@ * Author: Fernando Fuganti <fuganti@conectiva.com.br> * * Based on sbc60xxwdt.c by Jakob Oestergaard - * * - * We have two timers (wd#1, wd#2) driven by a 32 KHz clock with the + * + * We have two timers (wd#1, wd#2) driven by a 32 KHz clock with the * following periods: * wd#1 - 2 seconds; * wd#2 - 7.2 ms; - * After the expiration of wd#1, it can generate a NMI, SCI, SMI, or - * a system RESET and it starts wd#2 that unconditionaly will RESET + * After the expiration of wd#1, it can generate a NMI, SCI, SMI, or + * a system RESET and it starts wd#2 that unconditionaly will RESET * the system when the counter reaches zero. * * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> @@ -55,7 +55,7 @@ /* indexes */ /* size */ #define ZFL_VERSION 0x02 /* 16 */ -#define CONTROL 0x10 /* 16 */ +#define CONTROL 0x10 /* 16 */ #define STATUS 0x12 /* 8 */ #define COUNTER_1 0x0C /* 16 */ #define COUNTER_2 0x0E /* 8 */ @@ -111,9 +111,9 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON #define PFX "machzwd" static struct watchdog_info zf_info = { - .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, - .firmware_version = 1, - .identity = "ZF-Logic watchdog" + .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "ZF-Logic watchdog", }; @@ -130,8 +130,8 @@ module_param(action, int, 0); MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI"); static int zf_action = GEN_RESET; -static int zf_is_open = 0; -static int zf_expect_close = 0; +static unsigned long zf_is_open; +static char zf_expect_close; static spinlock_t zf_lock; static spinlock_t zf_port_lock; static struct timer_list zf_timer; @@ -225,7 +225,7 @@ static void zf_timer_off(void) del_timer_sync(&zf_timer); spin_lock_irqsave(&zf_port_lock, flags); - /* stop watchdog timer */ + /* stop watchdog timer */ ctrl_reg = zf_get_control(); ctrl_reg |= (ENABLE_WD1|ENABLE_WD2); /* disable wd1 and wd2 */ ctrl_reg &= ~(ENABLE_WD1|ENABLE_WD2); @@ -237,13 +237,13 @@ static void zf_timer_off(void) /* - * start hardware timer + * start hardware timer */ static void zf_timer_on(void) { unsigned int ctrl_reg = 0; unsigned long flags; - + spin_lock_irqsave(&zf_port_lock, flags); zf_writeb(PULSE_LEN, 0xff); @@ -272,26 +272,26 @@ static void zf_ping(unsigned long data) { unsigned int ctrl_reg = 0; unsigned long flags; - + zf_writeb(COUNTER_2, 0xff); if(time_before(jiffies, next_heartbeat)){ dprintk("time_before: %ld\n", next_heartbeat - jiffies); - - /* + + /* * reset event is activated by transition from 0 to 1 on * RESET_WD1 bit and we assume that it is already zero... */ spin_lock_irqsave(&zf_port_lock, flags); - ctrl_reg = zf_get_control(); - ctrl_reg |= RESET_WD1; - zf_set_control(ctrl_reg); - + ctrl_reg = zf_get_control(); + ctrl_reg |= RESET_WD1; + zf_set_control(ctrl_reg); + /* ...and nothing changes until here */ ctrl_reg &= ~(RESET_WD1); - zf_set_control(ctrl_reg); + zf_set_control(ctrl_reg); spin_unlock_irqrestore(&zf_port_lock, flags); zf_timer.expires = jiffies + ZF_HW_TIMEO; @@ -301,7 +301,7 @@ static void zf_ping(unsigned long data) } } -static ssize_t zf_write(struct file *file, const char *buf, size_t count, +static ssize_t zf_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { /* Can't seek (pwrite) on this device */ @@ -317,21 +317,21 @@ static ssize_t zf_write(struct file *file, const char *buf, size_t count, */ if (!nowayout) { size_t ofs; - - /* + + /* * note: just in case someone wrote the magic character * five months ago... */ zf_expect_close = 0; - + /* now scan */ for (ofs = 0; ofs != count; ofs++){ char c; if (get_user(c, buf + ofs)) return -EFAULT; if (c == 'V'){ - zf_expect_close = 1; - dprintk("zf_expect_close 1\n"); + zf_expect_close = 42; + dprintk("zf_expect_close = 42\n"); } } } @@ -342,7 +342,7 @@ static ssize_t zf_write(struct file *file, const char *buf, size_t count, */ next_heartbeat = jiffies + ZF_USER_TIMEO; dprintk("user ping at %ld\n", jiffies); - + } return count; @@ -353,22 +353,20 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, { switch(cmd){ case WDIOC_GETSUPPORT: - if (copy_to_user((struct watchdog_info *)arg, + if (copy_to_user((struct watchdog_info *)arg, &zf_info, sizeof(zf_info))) return -EFAULT; break; - + case WDIOC_GETSTATUS: - if (copy_to_user((int *)arg, &zf_is_open, sizeof(int))) - return -EFAULT; - break; + return put_user(0, (int *) arg); case WDIOC_KEEPALIVE: zf_ping(0); break; default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; @@ -376,47 +374,37 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int zf_open(struct inode *inode, struct file *file) { - switch(iminor(inode)){ - case WATCHDOG_MINOR: - spin_lock(&zf_lock); - if(zf_is_open){ - spin_unlock(&zf_lock); - return -EBUSY; - } - - if (nowayout) - __module_get(THIS_MODULE); + spin_lock(&zf_lock); + if(test_and_set_bit(0, &zf_is_open)) { + spin_unlock(&zf_lock); + return -EBUSY; + } - zf_is_open = 1; + if (nowayout) + __module_get(THIS_MODULE); - spin_unlock(&zf_lock); + spin_unlock(&zf_lock); - zf_timer_on(); + zf_timer_on(); - return 0; - default: - return -ENODEV; - } + return 0; } static int zf_close(struct inode *inode, struct file *file) { - if(iminor(inode) == WATCHDOG_MINOR){ + if(zf_expect_close == 42){ + zf_timer_off(); + } else { + del_timer(&zf_timer); + printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n"); + } - if(zf_expect_close){ - zf_timer_off(); - } else { - del_timer(&zf_timer); - printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n"); - } - - spin_lock(&zf_lock); - zf_is_open = 0; - spin_unlock(&zf_lock); + spin_lock(&zf_lock); + clear_bit(0, &zf_is_open); + spin_unlock(&zf_lock); + + zf_expect_close = 0; - zf_expect_close = 0; - } - return 0; } @@ -428,9 +416,9 @@ static int zf_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { if(code == SYS_DOWN || code == SYS_HALT){ - zf_timer_off(); + zf_timer_off(); } - + return NOTIFY_DONE; } @@ -448,9 +436,9 @@ static struct file_operations zf_fops = { static struct miscdevice zf_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &zf_fops + .fops = &zf_fops, }; - + /* * The device needs to learn about soft shutdowns in order to @@ -459,20 +447,20 @@ static struct miscdevice zf_miscdev = { static struct notifier_block zf_notifier = { .notifier_call = zf_notify_sys, .next = NULL, - .priority = 0 + .priority = 0, }; static void __init zf_show_action(int act) { char *str[] = { "RESET", "SMI", "NMI", "SCI" }; - + printk(KERN_INFO PFX ": Watchdog using action = %s\n", str[act]); } static int __init zf_init(void) { int ret; - + printk(KERN_INFO PFX ": MachZ ZF-Logic Watchdog driver initializing.\n"); ret = zf_get_ZFL_version(); @@ -486,12 +474,12 @@ static int __init zf_init(void) zf_action = zf_action>>action; } else action = 0; - + zf_show_action(action); spin_lock_init(&zf_lock); spin_lock_init(&zf_port_lock); - + ret = misc_register(&zf_miscdev); if (ret){ printk(KERN_ERR "can't misc_register on minor=%d\n", @@ -512,7 +500,7 @@ static int __init zf_init(void) ret); goto no_reboot; } - + zf_set_status(0); zf_set_control(0); @@ -520,7 +508,7 @@ static int __init zf_init(void) init_timer(&zf_timer); zf_timer.function = zf_ping; zf_timer.data = 0; - + return 0; no_reboot: @@ -531,11 +519,11 @@ out: return ret; } - + void __exit zf_exit(void) { zf_timer_off(); - + misc_deregister(&zf_miscdev); unregister_reboot_notifier(&zf_notifier); release_region(ZF_IOBASE, 3); diff --git a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c index 91a6bd367e35..018dcfb4085b 100644 --- a/drivers/char/watchdog/mixcomwd.c +++ b/drivers/char/watchdog/mixcomwd.c @@ -30,11 +30,11 @@ * * Version 0.5 (2001/12/14) Matt Domsch <Matt_Domsch@dell.com> * - added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT - * + * */ -#define VERSION "0.5" - +#define VERSION "0.5" + #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/config.h> @@ -55,12 +55,12 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 }; #define FLASHCOM_WATCHDOG_OFFSET 0x4 #define FLASHCOM_ID 0x18 -static long mixcomwd_opened; /* long req'd for setbit --RR */ +static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */ static int watchdog_port; static int mixcomwd_timer_alive; static struct timer_list mixcomwd_timer = TIMER_INITIALIZER(NULL, 0, 0); -static int expect_close = 0; +static char expect_close; #ifdef CONFIG_WATCHDOG_NOWAYOUT static int nowayout = 1; @@ -80,21 +80,21 @@ static void mixcomwd_ping(void) static void mixcomwd_timerfun(unsigned long d) { mixcomwd_ping(); - + mod_timer(&mixcomwd_timer,jiffies+ 5*HZ); } /* * Allow only one person to hold it open */ - + static int mixcomwd_open(struct inode *inode, struct file *file) { if(test_and_set_bit(0,&mixcomwd_opened)) { return -EBUSY; } mixcomwd_ping(); - + if (nowayout) { /* * fops_get() code via open() has already done @@ -113,7 +113,7 @@ static int mixcomwd_open(struct inode *inode, struct file *file) static int mixcomwd_release(struct inode *inode, struct file *file) { - if (expect_close) { + if (expect_close == 42) { if(mixcomwd_timer_alive) { printk(KERN_ERR "mixcomwd: release called while internal timer alive"); return -EBUSY; @@ -129,6 +129,7 @@ static int mixcomwd_release(struct inode *inode, struct file *file) } clear_bit(0,&mixcomwd_opened); + expect_close=0; return 0; } @@ -152,7 +153,7 @@ static ssize_t mixcomwd_write(struct file *file, const char *data, size_t len, l if (get_user(c, data + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } mixcomwd_ping(); @@ -167,9 +168,9 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file, static struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .firmware_version = 1, - .identity = "MixCOM watchdog" + .identity = "MixCOM watchdog", }; - + switch(cmd) { case WDIOC_GETSTATUS: @@ -182,7 +183,7 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file, } break; case WDIOC_GETSUPPORT: - if (copy_to_user((struct watchdog_info *)arg, &ident, + if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))) { return -EFAULT; } @@ -191,7 +192,7 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file, mixcomwd_ping(); break; default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; } @@ -207,9 +208,9 @@ static struct file_operations mixcomwd_fops= static struct miscdevice mixcomwd_miscdev= { - WATCHDOG_MINOR, - "watchdog", - &mixcomwd_fops + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &mixcomwd_fops, }; static int __init mixcomwd_checkcard(int port) @@ -220,7 +221,7 @@ static int __init mixcomwd_checkcard(int port) if (!request_region(port, 1, "MixCOM watchdog")) { return 0; } - + id=inb_p(port) & 0x3f; if(id!=MIXCOM_ID) { release_region(port, 1); @@ -232,12 +233,12 @@ static int __init mixcomwd_checkcard(int port) static int __init flashcom_checkcard(int port) { int id; - + port += FLASHCOM_WATCHDOG_OFFSET; if (!request_region(port, 1, "MixCOM watchdog")) { return 0; } - + id=inb_p(port); if(id!=FLASHCOM_ID) { release_region(port, 1); @@ -245,7 +246,7 @@ static int __init flashcom_checkcard(int port) } return port; } - + static int __init mixcomwd_init(void) { int i; @@ -258,7 +259,7 @@ static int __init mixcomwd_init(void) found = 1; } } - + /* The FlashCOM card can be set up at 0x300 -> 0x378, in 0x8 jumps */ for (i = 0x300; !found && i < 0x380; i+=0x8) { watchdog_port = flashcom_checkcard(i); @@ -266,7 +267,7 @@ static int __init mixcomwd_init(void) found = 1; } } - + if (!found) { printk("mixcomwd: No card detected, or port not available.\n"); return -ENODEV; @@ -278,11 +279,11 @@ static int __init mixcomwd_init(void) release_region(watchdog_port, 1); return ret; } - + printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n",VERSION,watchdog_port); return 0; -} +} static void __exit mixcomwd_exit(void) { diff --git a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c index c84a738bb478..f5dd9be70972 100644 --- a/drivers/char/watchdog/pcwd.c +++ b/drivers/char/watchdog/pcwd.c @@ -34,7 +34,7 @@ * 971222 Changed open/close for temperature handling * Michael Meskes <meskes@debian.org>. * 980112 Used minor numbers from include/linux/miscdevice.h - * 990403 Clear reset status after reading control status register in + * 990403 Clear reset status after reading control status register in * pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>] * 990605 Made changes to code to support Firmware 1.22a, added * fairly useless proc entry. @@ -86,10 +86,10 @@ static int pcwd_ioports[] = { 0x270, 0x350, 0x370, 0x000 }; #define WD_TIMEOUT 4 /* 2 seconds for a timeout */ static int timeout_val = WD_TIMEOUT; static int timeout = 2; -static int expect_close = 0; +static char expect_close; module_param(timeout, int, 0); -MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=2)"); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=2)"); #ifdef CONFIG_WATCHDOG_NOWAYOUT static int nowayout = 1; @@ -248,14 +248,14 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, int cdat, rv; static struct watchdog_info ident= { - WDIOF_OVERHEAT|WDIOF_CARDRESET, - 1, - "PCWD" + .options = WDIOF_OVERHEAT|WDIOF_CARDRESET, + .firmware_version = 1, + .identity = "PCWD", }; switch(cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: if(copy_to_user((void*)arg, &ident, sizeof(ident))) @@ -264,19 +264,19 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, case WDIOC_GETSTATUS: spin_lock(&io_lock); - if (revision == PCWD_REVISION_A) + if (revision == PCWD_REVISION_A) cdat = inb(current_readport); else cdat = inb(current_readport + 1 ); spin_unlock(&io_lock); rv = WDIOF_MAGICCLOSE; - if (revision == PCWD_REVISION_A) + if (revision == PCWD_REVISION_A) { if (cdat & WD_WDRST) rv |= WDIOF_CARDRESET; - if (cdat & WD_T110) + if (cdat & WD_T110) { rv |= WDIOF_OVERHEAT; @@ -286,12 +286,12 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, } } } - else + else { if (cdat & 0x01) rv |= WDIOF_CARDRESET; - if (cdat & 0x04) + if (cdat & 0x04) { rv |= WDIOF_OVERHEAT; @@ -309,7 +309,7 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, case WDIOC_GETBOOTSTATUS: rv = 0; - if (revision == PCWD_REVISION_A) + if (revision == PCWD_REVISION_A) { if (initial_status & WD_WDRST) rv |= WDIOF_CARDRESET; @@ -333,7 +333,7 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, case WDIOC_GETTEMP: rv = 0; - if ((supports_temp) && (mode_debug == 0)) + if ((supports_temp) && (mode_debug == 0)) { spin_lock(&io_lock); rv = inb(current_readport); @@ -345,19 +345,19 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, return 0; case WDIOC_SETOPTIONS: - if (revision == PCWD_REVISION_C) + if (revision == PCWD_REVISION_C) { if(copy_from_user(&rv, (int*) arg, sizeof(int))) return -EFAULT; - if (rv & WDIOS_DISABLECARD) + if (rv & WDIOS_DISABLECARD) { spin_lock(&io_lock); outb_p(0xA5, current_readport + 3); outb_p(0xA5, current_readport + 3); cdat = inb_p(current_readport + 2); spin_unlock(&io_lock); - if ((cdat & 0x10) == 0) + if ((cdat & 0x10) == 0) { printk(KERN_INFO "pcwd: Could not disable card.\n"); return -EIO; @@ -366,13 +366,13 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, return 0; } - if (rv & WDIOS_ENABLECARD) + if (rv & WDIOS_ENABLECARD) { spin_lock(&io_lock); outb_p(0x00, current_readport + 3); cdat = inb_p(current_readport + 2); spin_unlock(&io_lock); - if (cdat & 0x10) + if (cdat & 0x10) { printk(KERN_INFO "pcwd: Could not enable card.\n"); return -EIO; @@ -380,13 +380,13 @@ static int pcwd_ioctl(struct inode *inode, struct file *file, return 0; } - if (rv & WDIOS_TEMPPANIC) + if (rv & WDIOS_TEMPPANIC) { temp_panic = 1; } } return -EINVAL; - + case WDIOC_KEEPALIVE: pcwd_send_heartbeat(); return 0; @@ -415,7 +415,7 @@ static ssize_t pcwd_write(struct file *file, const char *buf, size_t len, if (get_user(c, buf + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } pcwd_send_heartbeat(); @@ -456,14 +456,14 @@ static ssize_t pcwd_read(struct file *file, char *buf, size_t count, /* Can't seek (pread) on this device */ if (ppos != &file->f_pos) return -ESPIPE; - switch(iminor(file->f_dentry->d_inode)) + switch(iminor(file->f_dentry->d_inode)) { case TEMP_MINOR: /* * Convert metric to Fahrenheit, since this was * the decided 'standard' for this return value. */ - + c = inb(current_readport); cp = (c * 9 / 5) + 32; if(copy_to_user(buf, &cp, 1)) @@ -477,7 +477,7 @@ static ssize_t pcwd_read(struct file *file, char *buf, size_t count, static int pcwd_close(struct inode *ino, struct file *filep) { if (iminor(ino)==WATCHDOG_MINOR) { - if (expect_close) { + if (expect_close == 42) { /* Disable the board */ if (revision == PCWD_REVISION_C) { spin_lock(&io_lock); @@ -488,6 +488,7 @@ static int pcwd_close(struct inode *ino, struct file *filep) atomic_inc( &open_allowed ); } } + expect_close = 0; return 0; } @@ -500,7 +501,7 @@ static inline void get_support(void) static inline int get_revision(void) { int r = PCWD_REVISION_C; - + spin_lock(&io_lock); if ((inb(current_readport + 2) == 0xFF) || (inb(current_readport + 3) == 0xFF)) @@ -576,29 +577,29 @@ static struct file_operations pcwd_fops = { }; static struct miscdevice pcwd_miscdev = { - WATCHDOG_MINOR, - "watchdog", - &pcwd_fops + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &pcwd_fops, }; static struct miscdevice temp_miscdev = { - TEMP_MINOR, - "temperature", - &pcwd_fops + .minor = TEMP_MINOR, + .name = "temperature", + .fops = &pcwd_fops, }; - + static void __init pcwd_validate_timeout(void) { timeout_val = timeout * 2; } - + static int __init pcwatchdog_init(void) { char *firmware; int i, found = 0; pcwd_validate_timeout(); spin_lock_init(&io_lock); - + revision = PCWD_REVISION_A; printk(KERN_INFO "pcwd: v%s Ken Hollis (kenji@bitgate.com)\n", WD_VER); @@ -660,11 +661,11 @@ static int __init pcwatchdog_init(void) if (misc_register(&pcwd_miscdev)) return -ENODEV; - + if (supports_temp) if (misc_register(&temp_miscdev)) { misc_deregister(&pcwd_miscdev); - return -ENODEV; + return -ENODEV; } @@ -673,10 +674,10 @@ static int __init pcwatchdog_init(void) misc_deregister(&pcwd_miscdev); if (supports_temp) misc_deregister(&pcwd_miscdev); - return -EIO; + return -EIO; } } - else + else if (!request_region(current_readport, 4, "PCWD Rev.C (Berkshire)")) { misc_deregister(&pcwd_miscdev); if (supports_temp) diff --git a/drivers/char/watchdog/sa1100_wdt.c b/drivers/char/watchdog/sa1100_wdt.c index 8d1bdc504b4e..14e4f249cc31 100644 --- a/drivers/char/watchdog/sa1100_wdt.c +++ b/drivers/char/watchdog/sa1100_wdt.c @@ -77,6 +77,7 @@ static int sa1100dog_release(struct inode *inode, struct file *file) } clear_bit(1, &sa1100wdt_users); + expect_close = 0; return 0; } diff --git a/drivers/char/watchdog/sbc60xxwdt.c b/drivers/char/watchdog/sbc60xxwdt.c index 3e39706542eb..345dea2202ea 100644 --- a/drivers/char/watchdog/sbc60xxwdt.c +++ b/drivers/char/watchdog/sbc60xxwdt.c @@ -183,7 +183,7 @@ static ssize_t fop_write(struct file * file, const char * buf, size_t count, lof * five months ago... */ wdt_expect_close = 0; - /* scan to see wether or not we got the magic character */ + /* scan to see whether or not we got the magic character */ for(ofs = 0; ofs != count; ofs++) { char c; diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c index 973eae51c868..fac22e3815c7 100644 --- a/drivers/char/watchdog/sc1200wdt.c +++ b/drivers/char/watchdog/sc1200wdt.c @@ -175,12 +175,12 @@ static int sc1200wdt_ioctl(struct inode *inode, struct file *file, unsigned int static struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .firmware_version = 0, - .identity = "PC87307/PC97307" + .identity = "PC87307/PC97307", }; switch (cmd) { default: - return -ENOTTY; /* Keep Pavel Machek amused ;) */ + return -ENOIOCTLCMD; /* Keep Pavel Machek amused ;) */ case WDIOC_GETSUPPORT: if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof ident)) @@ -256,7 +256,7 @@ static ssize_t sc1200wdt_write(struct file *file, const char *data, size_t len, { if (ppos != &file->f_pos) return -ESPIPE; - + if (len) { if (!nowayout) { size_t i; @@ -292,7 +292,7 @@ static int sc1200wdt_notify_sys(struct notifier_block *this, unsigned long code, static struct notifier_block sc1200wdt_notifier = { - notifier_call: sc1200wdt_notify_sys + .notifier_call = sc1200wdt_notify_sys, }; static struct file_operations sc1200wdt_fops = @@ -301,7 +301,7 @@ static struct file_operations sc1200wdt_fops = .write = sc1200wdt_write, .ioctl = sc1200wdt_ioctl, .open = sc1200wdt_open, - .release = sc1200wdt_release + .release = sc1200wdt_release, }; static struct miscdevice sc1200wdt_miscdev = @@ -320,7 +320,7 @@ static int __init sc1200wdt_probe(void) * Nb. This could be done with accuracy by reading the SID registers, but * we don't have access to those io regions. */ - + unsigned char reg; sc1200wdt_read_data(PMC3, ®); @@ -334,7 +334,7 @@ static int __init sc1200wdt_probe(void) struct pnp_device_id scl200wdt_pnp_devices[] = { /* National Semiconductor PC87307/PC97307 watchdog component */ {.id = "NSC0800", .driver_data = 0}, - {.id = ""} + {.id = ""}, }; static int scl200wdt_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) @@ -409,7 +409,7 @@ static int __init sc1200wdt_init(void) ret = -EBUSY; goto out_clean; } - + ret = sc1200wdt_probe(); if (ret) goto out_io; @@ -438,7 +438,7 @@ out_io: release_region(io, io_len); goto out_clean; -} +} static void __exit sc1200wdt_exit(void) diff --git a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c index 9877c5f24a3f..edca41fe835f 100644 --- a/drivers/char/watchdog/scx200_wdt.c +++ b/drivers/char/watchdog/scx200_wdt.c @@ -1,4 +1,4 @@ -/* linux/drivers/char/scx200_wdt.c +/* drivers/char/watchdog/scx200_wdt.c National Semiconductor SCx200 Watchdog support @@ -51,7 +51,7 @@ MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); static u16 wdto_restart; static struct semaphore open_semaphore; -static unsigned expect_close; +static char expect_close; /* Bits of the WDCNFG register */ #define W_ENABLE 0x00fa /* Enable watchdog */ @@ -73,7 +73,7 @@ static void scx200_wdt_update_margin(void) static void scx200_wdt_enable(void) { - printk(KERN_DEBUG NAME ": enabling watchdog timer, wdto_restart = %d\n", + printk(KERN_DEBUG NAME ": enabling watchdog timer, wdto_restart = %d\n", wdto_restart); outw(0, SCx200_CB_BASE + SCx200_WDT_WDTO); @@ -86,7 +86,7 @@ static void scx200_wdt_enable(void) static void scx200_wdt_disable(void) { printk(KERN_DEBUG NAME ": disabling watchdog timer\n"); - + outw(0, SCx200_CB_BASE + SCx200_WDT_WDTO); outb(SCx200_WDT_WDSTS_WDOVF, SCx200_CB_BASE + SCx200_WDT_WDSTS); outw(W_DISABLE, SCx200_CB_BASE + SCx200_WDT_WDCNFG); @@ -94,50 +94,50 @@ static void scx200_wdt_disable(void) static int scx200_wdt_open(struct inode *inode, struct file *file) { - /* only allow one at a time */ - if (down_trylock(&open_semaphore)) - return -EBUSY; + /* only allow one at a time */ + if (down_trylock(&open_semaphore)) + return -EBUSY; scx200_wdt_enable(); - expect_close = 0; return 0; } static int scx200_wdt_release(struct inode *inode, struct file *file) { - if (!expect_close) { + if (expect_close != 42) { printk(KERN_WARNING NAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n"); } else if (!nowayout) { scx200_wdt_disable(); } - up(&open_semaphore); + expect_close = 0; + up(&open_semaphore); return 0; } -static int scx200_wdt_notify_sys(struct notifier_block *this, +static int scx200_wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { - if (code == SYS_HALT || code == SYS_POWER_OFF) + if (code == SYS_HALT || code == SYS_POWER_OFF) if (!nowayout) scx200_wdt_disable(); - return NOTIFY_DONE; + return NOTIFY_DONE; } static struct notifier_block scx200_wdt_notifier = { - .notifier_call = scx200_wdt_notify_sys + .notifier_call = scx200_wdt_notify_sys, }; -static ssize_t scx200_wdt_write(struct file *file, const char *data, +static ssize_t scx200_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) { if (ppos != &file->f_pos) return -ESPIPE; /* check for a magic close character */ - if (len) + if (len) { size_t i; @@ -149,7 +149,7 @@ static ssize_t scx200_wdt_write(struct file *file, const char *data, if (get_user(c, data+i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } return len; @@ -163,16 +163,16 @@ static int scx200_wdt_ioctl(struct inode *inode, struct file *file, { static struct watchdog_info ident = { .identity = "NatSemi SCx200 Watchdog", - .firmware_version = 1, + .firmware_version = 1, .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING), }; int new_margin; - + switch (cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: - if(copy_to_user((struct watchdog_info *)arg, &ident, + if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))) return -EFAULT; return 0; @@ -220,7 +220,7 @@ static int __init scx200_wdt_init(void) printk(KERN_DEBUG NAME ": NatSemi SCx200 Watchdog Driver\n"); /* First check that this really is a NatSemi SCx200 CPU */ - if ((pci_find_device(PCI_VENDOR_ID_NS, + if ((pci_find_device(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE, NULL)) == NULL) return -ENODEV; @@ -231,8 +231,8 @@ static int __init scx200_wdt_init(void) return -ENODEV; } - if (!request_region(SCx200_CB_BASE + SCx200_WDT_OFFSET, - SCx200_WDT_SIZE, + if (!request_region(SCx200_CB_BASE + SCx200_WDT_OFFSET, + SCx200_WDT_SIZE, "NatSemi SCx200 Watchdog")) { printk(KERN_WARNING NAME ": watchdog I/O region busy\n"); return -EBUSY; @@ -251,20 +251,20 @@ static int __init scx200_wdt_init(void) } r = register_reboot_notifier(&scx200_wdt_notifier); - if (r) { - printk(KERN_ERR NAME ": unable to register reboot notifier"); + if (r) { + printk(KERN_ERR NAME ": unable to register reboot notifier"); misc_deregister(&scx200_wdt_miscdev); release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET, SCx200_WDT_SIZE); - return r; - } + return r; + } return 0; } static void __exit scx200_wdt_cleanup(void) { - unregister_reboot_notifier(&scx200_wdt_notifier); + unregister_reboot_notifier(&scx200_wdt_notifier); misc_deregister(&scx200_wdt_miscdev); release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET, SCx200_WDT_SIZE); diff --git a/drivers/char/watchdog/shwdt.c b/drivers/char/watchdog/shwdt.c index 5b394584a02f..a9b0052a77d1 100644 --- a/drivers/char/watchdog/shwdt.c +++ b/drivers/char/watchdog/shwdt.c @@ -36,7 +36,7 @@ /* * Default clock division ratio is 5.25 msecs. For an additional table of * values, consult the asm-sh/watchdog.h. Overload this at module load - * time. + * time. * * In order for this to work reliably we need to have HZ set to 1000 or * something quite higher than 100 (or we need a proper high-res timer @@ -122,7 +122,7 @@ static void sh_wdt_start(void) csr = sh_wdt_read_rstcsr(); csr &= ~RSTCSR_RSTS; sh_wdt_write_rstcsr(csr); -#endif +#endif } /** @@ -202,7 +202,7 @@ static int sh_wdt_close(struct inode *inode, struct file *file) clear_bit(0, &shwdt_is_open); shwdt_expect_close = 0; - + return 0; } @@ -264,7 +264,7 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file, sizeof(sh_wdt_info))) { return -EFAULT; } - + break; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: @@ -299,11 +299,11 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file, sh_wdt_start(); retval = 0; } - + return retval; } default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; @@ -311,7 +311,7 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file, /** * sh_wdt_notify_sys - Notifier Handler - * + * * @this: notifier block * @code: notifier event * @unused: unused diff --git a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c index 9262c4e2d2d5..59f84a311ae5 100644 --- a/drivers/char/watchdog/softdog.c +++ b/drivers/char/watchdog/softdog.c @@ -8,10 +8,10 @@ * 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. - * - * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide - * warranty for any of this software. This material is provided - * "AS-IS" and at no charge. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. * * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * @@ -28,14 +28,14 @@ * Made SMP safe for 2.3.x * * 20011127 Joel Becker (jlbec@evilplan.org> - * Added soft_noboot; Allows testing the softdog trigger without + * Added soft_noboot; Allows testing the softdog trigger without * requiring a recompile. * Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT. * * 20020530 Joel Becker <joel.becker@oracle.com> * Added Matt Domsch's nowayout module option. */ - + #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/config.h> @@ -49,7 +49,7 @@ #define TIMER_MARGIN 60 /* (secs) Default is 1 minute */ -static int expect_close = 0; +static char expect_close; static int soft_margin = TIMER_MARGIN; /* in seconds */ #ifdef ONLY_TESTING static int soft_noboot = 1; @@ -73,7 +73,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON /* * Our timer */ - + static void watchdog_fire(unsigned long); static struct timer_list watchdog_ticktock = @@ -84,7 +84,7 @@ static unsigned long timer_alive; /* * If the timer expires.. */ - + static void watchdog_fire(unsigned long data) { if (soft_noboot) @@ -100,12 +100,12 @@ static void watchdog_fire(unsigned long data) /* * Allow only one person to hold it open */ - + static int softdog_open(struct inode *inode, struct file *file) { if(test_and_set_bit(0, &timer_alive)) return -EBUSY; - if (nowayout) + if (nowayout) __module_get(THIS_MODULE); /* * Activate timer @@ -120,12 +120,13 @@ static int softdog_release(struct inode *inode, struct file *file) * Shut off the timer. * Lock it in if it's a module and we set nowayout */ - if (expect_close) { + if (expect_close == 42) { del_timer(&watchdog_ticktock); } else { printk(KERN_CRIT "SOFTDOG: WDT device closed unexpectedly. WDT will not stop!\n"); } clear_bit(0, &timer_alive); + expect_close = 0; return 0; } @@ -151,7 +152,7 @@ static ssize_t softdog_write(struct file *file, const char *data, size_t len, lo if (get_user(c, data + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } mod_timer(&watchdog_ticktock, jiffies+(soft_margin*HZ)); @@ -169,7 +170,7 @@ static int softdog_ioctl(struct inode *inode, struct file *file, }; switch (cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))) return -EFAULT; diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c index 4b113a22e2fd..f83c5bf5524e 100644 --- a/drivers/char/watchdog/w83627hf_wdt.c +++ b/drivers/char/watchdog/w83627hf_wdt.c @@ -184,7 +184,7 @@ wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, } default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; } diff --git a/drivers/char/watchdog/w83877f_wdt.c b/drivers/char/watchdog/w83877f_wdt.c index f7661dd5e1b2..4756f551a915 100644 --- a/drivers/char/watchdog/w83877f_wdt.c +++ b/drivers/char/watchdog/w83877f_wdt.c @@ -205,7 +205,7 @@ static ssize_t fop_write(struct file * file, const char * buf, size_t count, lof * five months ago... */ wdt_expect_close = 0; - /* scan to see wether or not we got the magic character */ + /* scan to see whether or not we got the magic character */ for(ofs = 0; ofs != count; ofs++) { char c; diff --git a/drivers/char/watchdog/wafer5823wdt.c b/drivers/char/watchdog/wafer5823wdt.c index 98cac9f1211e..8d3dc561c64b 100644 --- a/drivers/char/watchdog/wafer5823wdt.c +++ b/drivers/char/watchdog/wafer5823wdt.c @@ -109,7 +109,7 @@ static ssize_t wafwdt_write(struct file *file, const char *buf, size_t count, lo /* In case it was set long ago */ expect_close = 0; - /* scan to see wether or not we got the magic character */ + /* scan to see whether or not we got the magic character */ for (i = 0; i != count; i++) { char c; if (get_user(c, buf + i)) @@ -182,7 +182,7 @@ static int wafwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd } default: - return -ENOTTY; + return -ENOIOCTLCMD; } return 0; } diff --git a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c index 26df63a04a27..a35fa13e3820 100644 --- a/drivers/char/watchdog/wdt.c +++ b/drivers/char/watchdog/wdt.c @@ -8,10 +8,10 @@ * 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. - * - * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide - * warranty for any of this software. This material is provided - * "AS-IS" and at no charge. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. * * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * @@ -49,13 +49,13 @@ #include "wd501p.h" static unsigned long wdt_is_open; -static int expect_close; +static char expect_close; /* * You must set these - there is no sane way to probe for this board. * You can use wdt=x,y to set these now. */ - + static int io=0x240; static int irq=11; @@ -80,10 +80,10 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON * @str: command line string * * Setup options. The board isn't really probe-able so we have to - * get the user to tell us the configuration. Sane people build it + * get the user to tell us the configuration. Sane people build it * modular but the others come here. */ - + static int __init wdt_setup(char *str) { int ints[4]; @@ -108,11 +108,11 @@ MODULE_PARM(io, "i"); MODULE_PARM_DESC(io, "WDT io port (default=0x240)"); MODULE_PARM(irq, "i"); MODULE_PARM_DESC(irq, "WDT irq (default=11)"); - + /* * Programming support */ - + static void wdt_ctr_mode(int ctr, int mode) { ctr<<=6; @@ -130,29 +130,29 @@ static void wdt_ctr_load(int ctr, int val) /* * Kernel methods. */ - - + + /** * wdt_status: - * + * * Extract the status information from a WDT watchdog device. There are * several board variants so we have to know which bits are valid. Some * bits default to one and some to zero in order to be maximally painful. * * we then map the bits onto the status ioctl flags. */ - + static int wdt_status(void) { /* * Status register to bit flags */ - + int flag=0; unsigned char status=inb_p(WDT_SR); status|=FEATUREMAP1; - status&=~FEATUREMAP2; - + status&=~FEATUREMAP2; + if(!(status&WDC_SR_TGOOD)) flag|=WDIOF_OVERHEAT; if(!(status&WDC_SR_PSUOVER)) @@ -178,21 +178,21 @@ static int wdt_status(void) * map changes in what the board considers an interesting way. That means * a failure condition occurring. */ - + static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs) { /* * Read the status register see what is up and - * then printk it. + * then printk it. */ - + unsigned char status=inb_p(WDT_SR); - + status|=FEATUREMAP1; - status&=~FEATUREMAP2; - + status&=~FEATUREMAP2; + printk(KERN_CRIT "WDT status %d\n", status); - + if(!(status&WDC_SR_TGOOD)) printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT)); if(!(status&WDC_SR_PSUOVER)) @@ -205,10 +205,10 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs) #ifdef SOFTWARE_REBOOT #ifdef ONLY_TESTING printk(KERN_CRIT "Would Reboot.\n"); -#else +#else printk(KERN_CRIT "Initiating system reboot.\n"); machine_restart(NULL); -#endif +#endif #else printk(KERN_CRIT "Reset in 5ms.\n"); #endif @@ -220,9 +220,9 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs) * wdt_ping: * * Reload counter one with the watchdog timeout. We don't bother reloading - * the cascade counter. + * the cascade counter. */ - + static void wdt_ping(void) { /* Write a watchdog value */ @@ -235,14 +235,14 @@ static void wdt_ping(void) /** * wdt_write: * @file: file handle to the watchdog - * @buf: buffer to write (unused as data does not matter here + * @buf: buffer to write (unused as data does not matter here * @count: count of bytes * @ppos: pointer to the position to write. No seeks allowed * * A write to a watchdog device is defined as a keepalive signal. Any * write of data will do, as we we don't define content meaning. */ - + static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { /* Can't seek (pwrite) on this device */ @@ -261,7 +261,7 @@ static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_ if (get_user(c, buf + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } wdt_ping(); @@ -279,12 +279,12 @@ static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_ * Read reports the temperature in degrees Fahrenheit. The API is in * farenheit. It was designed by an imperial measurement luddite. */ - + static ssize_t wdt_read(struct file *file, char *buf, size_t count, loff_t *ptr) { unsigned short c=inb_p(WDT_RT); unsigned char cp; - + /* Can't seek (pread) on this device */ if (ptr != &file->f_pos) return -ESPIPE; @@ -312,9 +312,9 @@ static ssize_t wdt_read(struct file *file, char *buf, size_t count, loff_t *ptr) * * The watchdog API defines a common set of functions for all watchdogs * according to their available features. We only actually usefully support - * querying capabilities and current status. + * querying capabilities and current status. */ - + static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { @@ -326,14 +326,14 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, |WDIOF_EXTERN1|WDIOF_EXTERN2|WDIOF_FANFAULT |WDIOF_SETTIMEOUT|WDIOF_MAGICCLOSE, .firmware_version = 1, - .identity = "WDT500/501" + .identity = "WDT500/501", }; - + ident.options&=WDT_OPTION_MASK; /* Mask down to the card we have */ switch(cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0; @@ -364,12 +364,12 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, * @file: file handle to device * * One of our two misc devices has been opened. The watchdog device is - * single open and on opening we load the counters. Counter zero is a + * single open and on opening we load the counters. Counter zero is a * 100Hz cascade, into counter 1 which downcounts to reboot. When the * counter triggers counter 2 downcounts the length of the reset pulse - * which set set to be as long as possible. + * which set set to be as long as possible. */ - + static int wdt_open(struct inode *inode, struct file *file) { switch(iminor(inode)) @@ -378,9 +378,9 @@ static int wdt_open(struct inode *inode, struct file *file) if(test_and_set_bit(0, &wdt_is_open)) return -EBUSY; /* - * Activate + * Activate */ - + wdt_is_open=1; inb_p(WDT_DC); /* Disable */ wdt_ctr_mode(0,3); @@ -403,24 +403,25 @@ static int wdt_open(struct inode *inode, struct file *file) * @inode: inode to board * @file: file handle to board * - * The watchdog has a configurable API. There is a religious dispute - * between people who want their watchdog to be able to shut down and + * The watchdog has a configurable API. There is a religious dispute + * between people who want their watchdog to be able to shut down and * those who want to be sure if the watchdog manager dies the machine * reboots. In the former case we disable the counters, in the latter * case you have to open it again very soon. */ - + static int wdt_release(struct inode *inode, struct file *file) { if(iminor(inode)==WATCHDOG_MINOR) { - if (expect_close) { + if (expect_close == 42) { inb_p(WDT_DC); /* Disable counters */ wdt_ctr_load(2,0); /* 0 length reset pulses now */ } else { printk(KERN_CRIT "wdt: WDT device closed unexpectedly. WDT will not stop!\n"); } clear_bit(0, &wdt_is_open); + expect_close = 0; } return 0; } @@ -448,12 +449,12 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code, } return NOTIFY_DONE; } - + /* * Kernel Interfaces */ - - + + static struct file_operations wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, @@ -468,7 +469,7 @@ static struct miscdevice wdt_miscdev= { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &wdt_fops + .fops = &wdt_fops, }; #ifdef CONFIG_WDT_501 @@ -476,20 +477,20 @@ static struct miscdevice temp_miscdev= { .minor = TEMP_MINOR, .name = "temperature", - .fops = &wdt_fops + .fops = &wdt_fops, }; #endif /* * The WDT card needs to learn about soft shutdowns in order to - * turn the timebomb registers off. + * turn the timebomb registers off. */ - + static struct notifier_block wdt_notifier= { .notifier_call = wdt_notify_sys, .next = NULL, - .priority = 0 + .priority = 0, }; /** @@ -501,13 +502,13 @@ static struct notifier_block wdt_notifier= * will not touch PC memory so all is fine. You just have to load a new * module in 60 seconds or reboot. */ - + static void __exit wdt_exit(void) { misc_deregister(&wdt_miscdev); -#ifdef CONFIG_WDT_501 +#ifdef CONFIG_WDT_501 misc_deregister(&temp_miscdev); -#endif +#endif unregister_reboot_notifier(&wdt_notifier); release_region(io,8); free_irq(irq, NULL); @@ -520,7 +521,7 @@ static void __exit wdt_exit(void) * resources we require and bitch if anyone beat us to them. * The open() function will actually kick the board off. */ - + static int __init wdt_init(void) { int ret; diff --git a/drivers/char/watchdog/wdt285.c b/drivers/char/watchdog/wdt285.c index f1e8b52eb551..3ea756ebc70f 100644 --- a/drivers/char/watchdog/wdt285.c +++ b/drivers/char/watchdog/wdt285.c @@ -12,9 +12,9 @@ * 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/module.h> #include <linux/moduleparam.h> #include <linux/types.h> @@ -79,7 +79,7 @@ static int watchdog_open(struct inode *inode, struct file *file) *CSR_TIMER4_CLR = 0; watchdog_ping(); - *CSR_TIMER4_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD + *CSR_TIMER4_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV256; #ifdef ONLY_TESTING @@ -132,7 +132,7 @@ watchdog_write(struct file *file, const char *data, size_t len, loff_t *ppos) static struct watchdog_info ident = { .options = WDIOF_SETTIMEOUT, - .identity = "Footbridge Watchdog" + .identity = "Footbridge Watchdog", }; static int @@ -192,7 +192,7 @@ static struct file_operations watchdog_fops = { static struct miscdevice watchdog_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &watchdog_fops + .fops = &watchdog_fops, }; static int __init footbridge_watchdog_init(void) @@ -206,7 +206,7 @@ static int __init footbridge_watchdog_init(void) if (retval < 0) return retval; - printk("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n", + printk("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n", soft_margin); if (machine_is_cats()) diff --git a/drivers/char/watchdog/wdt977.c b/drivers/char/watchdog/wdt977.c index ef88636c4bdd..05218282040d 100644 --- a/drivers/char/watchdog/wdt977.c +++ b/drivers/char/watchdog/wdt977.c @@ -43,7 +43,7 @@ static int timeout = DEFAULT_TIMEOUT*60; /* TO in seconds from user */ static int timeoutM = DEFAULT_TIMEOUT; /* timeout in minutes */ static unsigned long timer_alive; static int testmode; -static int expect_close = 0; +static char expect_close; module_param(timeout, int, 0); MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (60..15300), default=60"); @@ -165,7 +165,7 @@ static int wdt977_release(struct inode *inode, struct file *file) * Shut off the timer. * Lock it in if it's a module and we set nowayout */ - if (!nowayout) + if (expect_close == 42) { /* unlock the SuperIO chip */ outb(0x87,0x370); @@ -202,6 +202,7 @@ static int wdt977_release(struct inode *inode, struct file *file) } else { printk(KERN_CRIT "WDT device closed unexpectedly. WDT will not stop!\n"); } + expect_close = 0; return 0; } @@ -235,7 +236,7 @@ static ssize_t wdt977_write(struct file *file, const char *buf, size_t count, lo if (get_user(c, buf + i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } @@ -257,18 +258,18 @@ static ssize_t wdt977_write(struct file *file, const char *buf, size_t count, lo static struct watchdog_info ident = { .options = WDIOF_SETTIMEOUT, - .identity = "Winbond 83977" + .identity = "Winbond 83977", }; static int wdt977_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { int temp; switch(cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: return copy_to_user((struct watchdog_info *)arg, &ident, @@ -341,7 +342,7 @@ static struct miscdevice wdt977_miscdev= { .minor = WATCHDOG_MINOR, .name = "watchdog", - .fops = &wdt977_fops + .fops = &wdt977_fops, }; static int __init nwwatchdog_init(void) diff --git a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c index 540c086e1090..a0fbd24a8745 100644 --- a/drivers/char/watchdog/wdt_pci.c +++ b/drivers/char/watchdog/wdt_pci.c @@ -8,10 +8,10 @@ * 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. - * - * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide - * warranty for any of this software. This material is provided - * "AS-IS" and at no charge. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. * * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * @@ -72,7 +72,7 @@ static struct semaphore open_sem; static spinlock_t wdtpci_lock; -static int expect_close = 0; +static char expect_close; static int io; static int irq; @@ -95,7 +95,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON /* * Programming support */ - + static void wdtpci_ctr_mode(int ctr, int mode) { ctr<<=6; @@ -113,29 +113,29 @@ static void wdtpci_ctr_load(int ctr, int val) /* * Kernel methods. */ - - + + /** * wdtpci_status: - * + * * Extract the status information from a WDT watchdog device. There are * several board variants so we have to know which bits are valid. Some * bits default to one and some to zero in order to be maximally painful. * * we then map the bits onto the status ioctl flags. */ - + static int wdtpci_status(void) { /* * Status register to bit flags */ - + int flag=0; unsigned char status=inb_p(WDT_SR); status|=FEATUREMAP1; - status&=~FEATUREMAP2; - + status&=~FEATUREMAP2; + if(!(status&WDC_SR_TGOOD)) flag|=WDIOF_OVERHEAT; if(!(status&WDC_SR_PSUOVER)) @@ -161,21 +161,21 @@ static int wdtpci_status(void) * map changes in what the board considers an interesting way. That means * a failure condition occurring. */ - + static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs) { /* * Read the status register see what is up and - * then printk it. + * then printk it. */ - + unsigned char status=inb_p(WDT_SR); - + status|=FEATUREMAP1; - status&=~FEATUREMAP2; - + status&=~FEATUREMAP2; + printk(KERN_CRIT "WDT status %d\n", status); - + if(!(status&WDC_SR_TGOOD)) printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT)); if(!(status&WDC_SR_PSUOVER)) @@ -188,10 +188,10 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs) #ifdef SOFTWARE_REBOOT #ifdef ONLY_TESTING printk(KERN_CRIT "Would Reboot.\n"); -#else +#else printk(KERN_CRIT "Initiating system reboot.\n"); machine_restart(NULL); -#endif +#endif #else printk(KERN_CRIT "Reset in 5ms.\n"); #endif @@ -203,9 +203,9 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs) * wdtpci_ping: * * Reload counter one with the watchdog timeout. We don't bother reloading - * the cascade counter. + * the cascade counter. */ - + static void wdtpci_ping(void) { unsigned long flags; @@ -222,14 +222,14 @@ static void wdtpci_ping(void) /** * wdtpci_write: * @file: file handle to the watchdog - * @buf: buffer to write (unused as data does not matter here + * @buf: buffer to write (unused as data does not matter here * @count: count of bytes * @ppos: pointer to the position to write. No seeks allowed * * A write to a watchdog device is defined as a keepalive signal. Any * write of data will do, as we we don't define content meaning. */ - + static ssize_t wdtpci_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { /* Can't seek (pwrite) on this device */ @@ -247,7 +247,7 @@ static ssize_t wdtpci_write(struct file *file, const char *buf, size_t count, lo if(get_user(c, buf+i)) return -EFAULT; if (c == 'V') - expect_close = 1; + expect_close = 42; } } wdtpci_ping(); @@ -266,12 +266,12 @@ static ssize_t wdtpci_write(struct file *file, const char *buf, size_t count, lo * Read reports the temperature in degrees Fahrenheit. The API is in * fahrenheit. It was designed by an imperial measurement luddite. */ - + static ssize_t wdtpci_read(struct file *file, char *buf, size_t count, loff_t *ptr) { unsigned short c=inb_p(WDT_RT); unsigned char cp; - + /* Can't seek (pread) on this device */ if (ptr != &file->f_pos) return -ESPIPE; @@ -299,9 +299,9 @@ static ssize_t wdtpci_read(struct file *file, char *buf, size_t count, loff_t *p * * The watchdog API defines a common set of functions for all watchdogs * according to their available features. We only actually usefully support - * querying capabilities and current status. + * querying capabilities and current status. */ - + static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { @@ -314,12 +314,12 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd .firmware_version = 1, .identity = "WDT500/501PCI", }; - + ident.options&=WDT_OPTION_MASK; /* Mask down to the card we have */ switch(cmd) { default: - return -ENOTTY; + return -ENOIOCTLCMD; case WDIOC_GETSUPPORT: return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0; @@ -351,12 +351,12 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd * @file: file handle to device * * One of our two misc devices has been opened. The watchdog device is - * single open and on opening we load the counters. Counter zero is a + * single open and on opening we load the counters. Counter zero is a * 100Hz cascade, into counter 1 which downcounts to reboot. When the * counter triggers counter 2 downcounts the length of the reset pulse - * which set set to be as long as possible. + * which set set to be as long as possible. */ - + static int wdtpci_open(struct inode *inode, struct file *file) { unsigned long flags; @@ -371,17 +371,17 @@ static int wdtpci_open(struct inode *inode, struct file *file) __module_get(THIS_MODULE); } /* - * Activate + * Activate */ spin_lock_irqsave(&wdtpci_lock, flags); - + inb_p(WDT_DC); /* Disable */ /* * "pet" the watchdog, as Access says. * This resets the clock outputs. */ - + wdtpci_ctr_mode(2,0); outb_p(0, WDT_DC); @@ -413,19 +413,19 @@ static int wdtpci_open(struct inode *inode, struct file *file) * @inode: inode to board * @file: file handle to board * - * The watchdog has a configurable API. There is a religious dispute - * between people who want their watchdog to be able to shut down and + * The watchdog has a configurable API. There is a religious dispute + * between people who want their watchdog to be able to shut down and * those who want to be sure if the watchdog manager dies the machine * reboots. In the former case we disable the counters, in the latter * case you have to open it again very soon. */ - + static int wdtpci_release(struct inode *inode, struct file *file) { if (iminor(inode)==WATCHDOG_MINOR) { unsigned long flags; - if (expect_close) { + if (expect_close == 42) { spin_lock_irqsave(&wdtpci_lock, flags); inb_p(WDT_DC); /* Disable counters */ wdtpci_ctr_load(2,0); /* 0 length reset pulses now */ @@ -434,6 +434,7 @@ static int wdtpci_release(struct inode *inode, struct file *file) printk(KERN_CRIT PFX "Unexpected close, not stopping timer!"); wdtpci_ping(); } + expect_close = 0; up(&open_sem); } return 0; @@ -465,12 +466,12 @@ static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code, } return NOTIFY_DONE; } - + /* * Kernel Interfaces */ - - + + static struct file_operations wdtpci_fops = { .owner = THIS_MODULE, .llseek = no_llseek, @@ -497,9 +498,9 @@ static struct miscdevice temp_miscdev = { /* * The WDT card needs to learn about soft shutdowns in order to - * turn the timebomb registers off. + * turn the timebomb registers off. */ - + static struct notifier_block wdtpci_notifier = { .notifier_call = wdtpci_notify_sys, }; @@ -584,7 +585,7 @@ static void __devexit wdtpci_remove_one (struct pci_dev *pdev) unregister_reboot_notifier(&wdtpci_notifier); #ifdef CONFIG_WDT_501_PCI misc_deregister(&temp_miscdev); -#endif +#endif misc_deregister(&wdtpci_miscdev); free_irq(irq, &wdtpci_miscdev); release_region(io, 16); @@ -620,7 +621,7 @@ static struct pci_driver wdtpci_driver = { * will not touch PC memory so all is fine. You just have to load a new * module in 60 seconds or reboot. */ - + static void __exit wdtpci_cleanup(void) { pci_unregister_driver (&wdtpci_driver); @@ -634,14 +635,14 @@ static void __exit wdtpci_cleanup(void) * resources we require and bitch if anyone beat us to them. * The open() function will actually kick the board off. */ - + static int __init wdtpci_init(void) { int rc = pci_register_driver (&wdtpci_driver); - + if (rc < 1) return -ENODEV; - + return 0; } diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 06735cf72cd3..7889c28de3db 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -747,7 +747,7 @@ config BLK_DEV_SVWKS config BLK_DEV_SGIIOC4 tristate "Silicon Graphics IOC4 chipset support" - depends on IA64_SGI_SN2 + depends on IA64_SGI_SN2 || IA64_GENERIC help This driver adds PIO & MultiMode DMA-2 support for the SGI IOC4 chipset, which has one channel and can support two devices. diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 68b1273b6b8c..4d5ad566a40c 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -277,7 +277,7 @@ static void ide_multwrite(ide_drive_t *drive, unsigned int mcount) * all bvecs in this one. */ if (++bio->bi_idx >= bio->bi_vcnt) { - bio->bi_idx = 0; + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; bio = bio->bi_next; } @@ -286,7 +286,8 @@ static void ide_multwrite(ide_drive_t *drive, unsigned int mcount) mcount = 0; } else { rq->bio = bio; - rq->current_nr_sectors = bio_iovec(bio)->bv_len >> 9; + rq->nr_cbio_segments = bio_segments(bio); + rq->current_nr_sectors = bio_cur_sectors(bio); rq->hard_cur_sectors = rq->current_nr_sectors; } } @@ -308,6 +309,7 @@ static ide_startstop_t multwrite_intr (ide_drive_t *drive) ide_hwgroup_t *hwgroup = HWGROUP(drive); ide_hwif_t *hwif = HWIF(drive); struct request *rq = &hwgroup->wrq; + struct bio *bio = rq->bio; u8 stat; stat = hwif->INB(IDE_STATUS_REG); @@ -328,14 +330,17 @@ static ide_startstop_t multwrite_intr (ide_drive_t *drive) * we can end the original request. */ if (!rq->nr_sectors) { /* all done? */ + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; rq = hwgroup->rq; ide_end_request(drive, 1, rq->nr_sectors); return ide_stopped; } } + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; /* the original code did this here (?) */ return ide_stopped; } + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; return DRIVER(drive)->error(drive, "multwrite_intr", stat); } diff --git a/drivers/ide/legacy/pdc4030.c b/drivers/ide/legacy/pdc4030.c index ca7b5a6118d1..58d8be2f40cc 100644 --- a/drivers/ide/legacy/pdc4030.c +++ b/drivers/ide/legacy/pdc4030.c @@ -443,7 +443,12 @@ read_next: static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive) { ide_hwgroup_t *hwgroup = HWGROUP(drive); +#ifdef CONFIG_IDE_TASKFILE_IO struct request *rq = hwgroup->rq; +#else + struct request *rq = &hwgroup->wrq; + struct bio *bio = rq->bio; +#endif if ((HWIF(drive)->INB(IDE_STATUS_REG)) & BUSY_STAT) { if (time_before(jiffies, hwgroup->poll_timeout)) { @@ -472,6 +477,8 @@ static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive) while (rq->bio != rq->cbio) (void) DRIVER(drive)->end_request(drive, 1, bio_sectors(rq->bio)); #else + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; + rq = hwgroup->rq; DRIVER(drive)->end_request(drive, 1, rq->hard_nr_sectors); #endif return ide_stopped; @@ -530,7 +537,7 @@ static void promise_multwrite (ide_drive_t *drive, unsigned int mcount) * all bvecs in this one. */ if (++bio->bi_idx >= bio->bi_vcnt) { - bio->bi_idx = 0; + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; bio = bio->bi_next; } @@ -539,7 +546,8 @@ static void promise_multwrite (ide_drive_t *drive, unsigned int mcount) mcount = 0; } else { rq->bio = bio; - rq->current_nr_sectors = bio_iovec(bio)->bv_len >> 9; + rq->nr_cbio_segments = bio_segments(bio); + rq->current_nr_sectors = bio_cur_sectors(bio); rq->hard_cur_sectors = rq->current_nr_sectors; } } @@ -561,6 +569,9 @@ static ide_startstop_t promise_write_pollfunc (ide_drive_t *drive) ide_hwgroup_t *hwgroup = HWGROUP(drive); #ifdef CONFIG_IDE_TASKFILE_IO struct request *rq = hwgroup->rq; +#else + struct request *rq = &hwgroup->wrq; + struct bio *bio = rq->bio; #endif if (HWIF(drive)->INB(IDE_NSECTOR_REG) != 0) { @@ -575,6 +586,9 @@ static ide_startstop_t promise_write_pollfunc (ide_drive_t *drive) } hwgroup->poll_timeout = 0; printk(KERN_ERR "%s: write timed-out!\n",drive->name); +#ifndef CONFIG_IDE_TASKFILE_IO + bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments; +#endif return DRIVER(drive)->error(drive, "write timeout", HWIF(drive)->INB(IDE_STATUS_REG)); } diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 44e8baacf5cb..4d8332a9437f 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c @@ -23,7 +23,6 @@ * http://oss.sgi.com/projects/GenInfo/NoticeExplan */ -#include <linux/config.h> #include <linux/module.h> #include <linux/types.h> #include <linux/pci.h> @@ -686,7 +685,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) "0x%p to 0x%p ALREADY in use\n", __FUNCTION__, hwif->name, (void *) base, (void *) base + IOC4_CMD_CTL_BLK_SIZE); - return 1; + return -ENOMEM; } if (hwif->io_ports[IDE_DATA_OFFSET] != base) { @@ -726,20 +725,21 @@ typedef enum pciio_endian_e { PCIDMA_ENDIAN_BIG, PCIDMA_ENDIAN_LITTLE } pciio_endian_t; -pciio_endian_t __attribute__ ((weak)) snia_pciio_endian_set(struct pci_dev - *pci_dev, pciio_endian_t device_end, - pciio_endian_t desired_end); +pciio_endian_t snia_pciio_endian_set(struct pci_dev + *pci_dev, pciio_endian_t device_end, + pciio_endian_t desired_end); static unsigned int __init pci_init_sgiioc4(struct pci_dev *dev, ide_pci_device_t * d) { unsigned int class_rev; + pciio_endian_t endian_status; if (pci_enable_device(dev)) { printk(KERN_ERR "Failed to enable device %s at slot %s\n", d->name, dev->slot_name); - return 1; + return -ENODEV; } pci_set_master(dev); @@ -751,18 +751,17 @@ pci_init_sgiioc4(struct pci_dev *dev, ide_pci_device_t * d) printk(KERN_ERR "Skipping %s IDE controller in slot %s: " "firmware is obsolete - please upgrade to revision" "46 or higher\n", d->name, dev->slot_name); - return 1; + return -ENODEV; } /* Enable Byte Swapping in the PIC... */ - if (snia_pciio_endian_set) { - snia_pciio_endian_set(dev, PCIDMA_ENDIAN_LITTLE, - PCIDMA_ENDIAN_BIG); - } else { + endian_status = snia_pciio_endian_set(dev, PCIDMA_ENDIAN_LITTLE, + PCIDMA_ENDIAN_BIG); + if (endian_status != PCIDMA_ENDIAN_BIG) { printk(KERN_ERR "Failed to set endianness for device %s at slot %s\n", d->name, dev->slot_name); - return 1; + return -ENODEV; } return sgiioc4_ide_setup_pci_device(dev, d); diff --git a/drivers/isdn/Makefile b/drivers/isdn/Makefile index fb53d7251b20..ead616444e4b 100644 --- a/drivers/isdn/Makefile +++ b/drivers/isdn/Makefile @@ -12,6 +12,5 @@ obj-$(CONFIG_ISDN_DRV_PCBIT) += pcbit/ obj-$(CONFIG_ISDN_DRV_SC) += sc/ obj-$(CONFIG_ISDN_DRV_LOOP) += isdnloop/ obj-$(CONFIG_ISDN_DRV_ACT2000) += act2000/ -obj-$(CONFIG_ISDN_DRV_EICON) += eicon/ obj-$(CONFIG_HYSDN) += hysdn/ obj-$(CONFIG_ISDN_DRV_TPAM) += tpam/ diff --git a/drivers/isdn/eicon/Divas_mod.c b/drivers/isdn/eicon/Divas_mod.c deleted file mode 100644 index 9f28ff9b65c2..000000000000 --- a/drivers/isdn/eicon/Divas_mod.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/config.h> -#include <linux/init.h> -#include <linux/fs.h> -#undef N_DATA - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/ioport.h> -#include <linux/slab.h> -#include <linux/errno.h> - -#include "adapter.h" -#include "uxio.h" - - -MODULE_DESCRIPTION("ISDN4Linux: Driver for Eicon Diva Server cards"); -MODULE_AUTHOR("Armin Schindler"); -MODULE_LICENSE("GPL"); - -void DivasInitDpc(void); - -#ifdef MODULE -#include "idi.h" -void DIVA_DIDD_Write(DESCRIPTOR *, int); -EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Read); -EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Write); -EXPORT_SYMBOL_NOVERS(DivasPrintf); -#endif - -int DivasCardsDiscover(void); - -static int __init -divas_init(void) -{ - printk(KERN_DEBUG "DIVA Server Driver - initialising\n"); - - printk(KERN_DEBUG "DIVA Server Driver - Version 2.0.16\n"); - -#if !defined(CONFIG_PCI) - printk(KERN_WARNING "CONFIG_PCI is not defined!\n"); - return -ENODEV; -#endif - - DivasInitDpc(); - - if (DivasCardsDiscover() < 0) - { - printk(KERN_WARNING "Divas: Not loaded\n"); - return -ENODEV; - } - - return 0; -} - -static void __exit -divas_exit(void) -{ - card_t *pCard; - word wCardIndex; - extern int Divas_major; - - printk(KERN_DEBUG "DIVA Server Driver - unloading\n"); - - pCard = DivasCards; - for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++) - { - if ((pCard->hw) && (pCard->hw->in_use)) - { - - (*pCard->card_reset)(pCard); - - UxIsrRemove(pCard->hw, pCard); - UxCardHandleFree(pCard->hw); - - if(pCard->e_tbl != NULL) - { - kfree(pCard->e_tbl); - } - - - if(pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_B) - { - release_region(pCard->hw->io_base,0x20); - release_region(pCard->hw->reset_base,0x80); - } - - // If this is a 4BRI ... - if (pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q) - { - // Skip over the next 3 virtual adapters - wCardIndex += 3; - - // But free their handles - pCard++; - UxCardHandleFree(pCard->hw); - - if(pCard->e_tbl != NULL) - { - kfree(pCard->e_tbl); - } - - pCard++; - UxCardHandleFree(pCard->hw); - - if(pCard->e_tbl != NULL) - { - kfree(pCard->e_tbl); - } - - pCard++; - UxCardHandleFree(pCard->hw); - - if(pCard->e_tbl != NULL) - { - kfree(pCard->e_tbl); - } - } - } - pCard++; - } - - unregister_chrdev(Divas_major, "Divas"); -} - -module_init(divas_init); -module_exit(divas_exit); - diff --git a/drivers/isdn/eicon/Kconfig b/drivers/isdn/eicon/Kconfig deleted file mode 100644 index ce30805a7d61..000000000000 --- a/drivers/isdn/eicon/Kconfig +++ /dev/null @@ -1,53 +0,0 @@ -# -# Config.in for Eicon active ISDN support -# -config ISDN_DRV_EICON - bool "Eicon active card support" - help - Say Y here if you have an Eicon active ISDN card. In order to use - this card, additional firmware is necessary, which has to be loaded - into the card using the eiconctrl utility which is part of the - latest isdn4k-utils package. Please read the file - <file:Documentation/isdn/README.eicon> for more information. - -choice - prompt "Eicon active card support" - optional - depends on ISDN_DRV_EICON && ISDN && m - -config ISDN_DRV_EICON_DIVAS - tristate "Eicon driver" - depends on PCI - help - Enable this option if you want the eicon driver as standalone - version with no interface to the ISDN4Linux isdn module. If you - say Y here, the eicon module only supports the Diva Server PCI - cards and will provide its own IDI interface. You should say N - here. - -config ISDN_DRV_EICON_OLD - tristate "Legacy driver" - help - Say Y here to use your Eicon active ISDN card with ISDN4Linux - isdn module. - -config ISDN_DRV_EICON_PCI - bool "Eicon PCI DIVA Server BRI/PRI/4BRI support" - depends on ISDN_DRV_EICON_OLD && PCI - help - Say Y here if you have an Eicon Diva Server (BRI/PRI/4BRI) ISDN - card. Please read <file:Documentation/isdn/README.eicon> for more - information. - -config ISDN_DRV_EICON_ISA - bool "Eicon S,SX,SCOM,Quadro,S2M support" - depends on ISDN_DRV_EICON_OLD - help - Say Y here if you have an old-type Eicon active ISDN card. In order - to use this card, additional firmware is necessary, which has to be - loaded into the card using the eiconctrl utility which is part of - the latest isdn4k-utils package. Please read the file - <file:Documentation/isdn/README.eicon> for more information. - -endchoice - diff --git a/drivers/isdn/eicon/Makefile b/drivers/isdn/eicon/Makefile deleted file mode 100644 index fd96828ae34b..000000000000 --- a/drivers/isdn/eicon/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Makefile for the eicon ISDN device driver - -# Each configuration option enables a list of files. - -obj-$(CONFIG_ISDN_DRV_EICON_OLD) += eicon.o -obj-$(CONFIG_ISDN_DRV_EICON_DIVAS) += divas.o - -# Multipart objects. - -eicon-y := eicon_mod.o eicon_isa.o eicon_pci.o \ - eicon_idi.o eicon_io.o -eicon-$(CONFIG_ISDN_DRV_EICON_PCI) += common.o idi.o bri.o pri.o log.o \ - xlog.o kprintf.o fpga.o fourbri.o lincfg.o \ - linchr.o linsys.o linio.o - -divas-y := common.o idi.o bri.o pri.o log.o xlog.o \ - kprintf.o fpga.o fourbri.o lincfg.o \ - linchr.o linsys.o linio.o Divas_mod.o - diff --git a/drivers/isdn/eicon/adapter.h b/drivers/isdn/eicon/adapter.h deleted file mode 100644 index fd0b79ab7103..000000000000 --- a/drivers/isdn/eicon/adapter.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Main internal include file for Diva Server driver - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.7 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#if !defined(ADAPTER_H) -#define ADAPTER_H - -#include "sys.h" -#include "idi.h" -#include "divas.h" -#undef ID_MASK -#include "pc.h" - -#define XMOREC 0x1f -#define XMOREF 0x20 -#define XBUSY 0x40 -#define RMORE 0x80 - - /* structure for all information we have to keep on a per */ - /* adapater basis */ - -typedef struct adapter_s ADAPTER; - -struct adapter_s { - void * io; - - byte IdTable[256]; - byte ReadyInt; - - byte (* ram_in)(ADAPTER * a, void * adr); - word (* ram_inw)(ADAPTER * a, void * adr); - void (* ram_in_buffer)(ADAPTER * a, void * adr, void * P, word length); - void (* ram_look_ahead)(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e); - - void (* ram_out)(ADAPTER * a, void * adr, byte data); - void (* ram_outw)(ADAPTER * a, void * adr, word data); - void (* ram_out_buffer)(ADAPTER * a, void * adr, void * P, word length); - - void (* ram_inc)(ADAPTER * a, void * adr); -}; - -typedef struct card card_t; - -typedef int card_load_fn_t(card_t *card, dia_load_t *load); -typedef int card_config_fn_t(card_t *card, dia_config_t *config); -typedef int card_start_fn_t(card_t *card, byte *channels); -typedef int card_reset_fn_t(card_t *card); -typedef int card_mem_get_fn_t(card_t *card, mem_block_t *mem_block); - -#define MAX_PENTITIES 256 /* Number of entities primary adapter */ -#define MAX_ENTITIES 16 /* Number of entities standard adapter */ - -typedef struct e_info_s E_INFO; - -struct e_info_s -{ - ENTITY *e; /* entity pointer */ - byte next; /* chaining index */ - word assign_ref; /* assign reference */ -}; - -/* DIVA card info (details hidden from user) */ - -typedef struct ux_diva_card_s ux_diva_card_t; - -/* card info */ - -struct card -{ - ADAPTER a; /* per-adapter information */ - dia_card_t cfg; /* card configuration */ - int state; /* State of the adapter */ - dword serial_no; /* serial number */ - int test_int_pend; /* set for interrupt testing */ - ux_diva_card_t *hw; /* O/S-specific handle */ - card_reset_fn_t *card_reset; /* call this to reset card */ - card_load_fn_t *card_load; /* call this to load card */ - card_config_fn_t *card_config; /* call this to config card */ - card_start_fn_t *card_start; /* call this to start card */ - card_mem_get_fn_t *card_mem_get; /* call this to get card memory */ - E_INFO *e_tbl; /* table of ENTITY pointers */ - byte e_head; /* list of active ENTITIES */ - byte e_tail; /* list of active ENTITIES */ - int e_count; /* # of active ENTITIES */ - int e_max; /* total # of ENTITIES */ - byte assign; /* assign queue entry */ - PBUFFER RBuffer; /* Copy of receive lookahead buffer */ - int log_types; /* bit-mask of active logs */ - word xlog_offset; /* offset to XLOG buffer on card */ - void (*out)(ADAPTER *a); - byte (*dpc)(ADAPTER * a); - byte (*test_int)(ADAPTER * a); - void (*clear_int)(ADAPTER * a); - void (*reset_int)(card_t *c); - int is_live; - - int (*card_isr)(card_t *card); - - int int_pend; /* interrupt pending */ - long interrupt_reentered; - long dpc_reentered; - int set_xlog_request; - -} ; - -/* card information */ - -#define MAX_CARDS 20 /* max number of cards on a system */ - -extern -card_t DivasCards[]; - -extern -int DivasCardNext; - -extern -dia_config_t DivasCardConfigs[]; - -extern -byte DivasFlavourConfig[]; - -/*------------------------------------------------------------------*/ -/* public functions of IDI common code */ -/*------------------------------------------------------------------*/ - -void DivasOut(ADAPTER * a); -byte DivasDpc(ADAPTER * a); -byte DivasTestInt(ADAPTER * a); -void DivasClearInt(ADAPTER * a); - -/*------------------------------------------------------------------*/ -/* public functions of configuration platform-specific code */ -/*------------------------------------------------------------------*/ - -int DivasConfigGet(dia_card_t *card); - -/*------------------------------------------------------------------*/ -/* public functions of LOG related code */ -/*------------------------------------------------------------------*/ - -void DivasXlogReq(int card_num); -int DivasXlogRetrieve(card_t *card); -void DivasLog(dia_log_t *log); -void DivasLogIdi(card_t *card, ENTITY *e, int request); - -/*------------------------------------------------------------------*/ -/* public functions to initialise cards for each type supported */ -/*------------------------------------------------------------------*/ - -int DivasPriInit(card_t *card, dia_card_t *cfg); - -int DivasBriInit(card_t *card, dia_card_t *cfg); -int Divas4BriInit(card_t *card, dia_card_t *cfg); -void DivasBriPatch(card_t *card); - -/*------------------------------------------------------------------*/ -/* public functions of log common code */ -/*------------------------------------------------------------------*/ - -extern char *DivasLogFifoRead(void); -extern void DivasLogFifoWrite(char *entry, int length); -extern int DivasLogFifoEmpty(void); -extern int DivasLogFifoFull(void); -extern void DivasLogAdd(void *buffer, int length); - -/*------------------------------------------------------------------*/ -/* public functions of misc. platform-specific code */ -/*------------------------------------------------------------------*/ - -int DivasDpcSchedule(void); -void DivasDoDpc(unsigned long); -int DivasScheduleRequestDpc(void); - -/* table of IDI request functions */ - -extern -IDI_CALL DivasIdiRequest[]; - -/* - * initialisation entry point - */ - -int DivasInit(void); - -/* - * Get information on the number and type of cards present - */ - -extern -int DivasCardsDiscover(void); - -/* - * initialise a new card - */ - -int DivasCardNew(dia_card_t *card); - -/* - * configure specified card - */ - -int DivasCardConfig(dia_config_t *config); - -/* - * load specified binary code onto card - */ - -int DivasCardLoad(dia_load_t *load); - -/* - * start specified card running - */ - -int DivasCardStart(int card_id); - -/* - * ISR for card - * Returns 0 if specified card was interrupting - */ - -int DivasIsr(void *arg); - -/* - * Get number of active cards - */ - -int DivasGetNum(void); - -/* - * Get list of active cards - */ - -int DivasGetList(dia_card_list_t *card_list); - -/* definitions common to several card types */ - -#define DIVAS_SHARED_OFFSET (0x1000) - -#endif /* ADAPTER_H */ diff --git a/drivers/isdn/eicon/bri.c b/drivers/isdn/eicon/bri.c deleted file mode 100644 index aa56bf85b017..000000000000 --- a/drivers/isdn/eicon/bri.c +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.8 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "eicon.h" -#include "sys.h" -#include "idi.h" -#include "divas.h" -#include "pc.h" -#include "pr_pc.h" -#include "dsp_defs.h" - -#include "adapter.h" -#include "uxio.h" - -#define PCI_BADDR0 0x10 -#define PCI_BADDR1 0x14 -#define PCI_BADDR2 0x18 - -#define DIVAS_SIGNATURE 0x4447 - -/* offset to start of MAINT area (used by xlog) */ - -#define DIVAS_MAINT_OFFSET 0xff00 /* value for BRI card */ - -#define PROTCAP_TELINDUS 0x1 -#define PROTCAP_V90D 0x8 - -word GetProtFeatureValue(char *sw_id); -byte io_in(ADAPTER *a, void *adr); -word io_inw(ADAPTER *a, void *adr); -void io_in_buffer(ADAPTER *a, void *adr, void *P, word length); -void io_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e); -void io_out(ADAPTER *a, void *adr, byte data); -void io_outw(ADAPTER *a, void *adr, word data); -void io_out_buffer(ADAPTER *a, void *adr, void *P, word length); -void io_inc(ADAPTER *a, void *adr); - -static int diva_server_bri_test_int(card_t *card); -static int bri_ISR (card_t* card); - -#define PLX_IOBASE 0 -#define DIVAS_IOBASE 1 - -#define REG_DATA 0x00 -#define REG_ADDRLO 0x04 -#define REG_ADDRHI 0x0C -#define REG_IOCTRL 0x10 - -#define M_PCI_RESET 0x10 - -byte UxCardPortIoIn(ux_diva_card_t *card, byte *base, int offset); -word UxCardPortIoInW(ux_diva_card_t *card, byte *base, int offset); -void UxCardPortIoOut(ux_diva_card_t *card, byte *base, int offset, byte); -void UxCardPortIoOutW(ux_diva_card_t *card, byte *base, int offset, word); - -int DivasBRIInitPCI(card_t *card, dia_card_t *cfg); - -static -int diva_server_bri_reset(card_t *card) -{ - byte *DivasIOBase; - word i; - dword dwWait; - - UxCardLog(0); - - DPRINTF(("divas: resetting BRI adapter")); - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0); - - for (i=0; i < 50000; i++) - ; - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_DATA , 0); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x0000); - - for (i=0; i<0x8000; i++) - { - UxCardPortIoOutW(card->hw, DivasIOBase, REG_DATA , 0); - } - - for (dwWait=0; dwWait < 0x00FFFFFF; dwWait++) - ; - - UxCardMemDetach(card->hw, DivasIOBase); - - return 0; -} - -static -void diva_server_bri_reset_int(card_t *card) -{ - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0x08); - - UxCardMemDetach(card->hw, DivasIOBase); - - return; -} - -static -int diva_server_bri_start(card_t *card, byte *channels) -{ - byte *DivasIOBase, *PLXIOBase; - word wSig = 0; - word i; - dword dwSerialNum; - byte bPLX9060 = FALSE; - - DPRINTF(("divas: starting Diva Server BRI card")); - - card->is_live = FALSE; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x1E); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA , 0); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA , 0); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0x08); - - /* wait for signature to indicate card has started */ - for (i = 0; i < 300; i++) - { - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x1E); - wSig = UxCardPortIoInW(card->hw, DivasIOBase, REG_DATA); - - if (wSig == DIVAS_SIGNATURE) - { - DPRINTF(("divas: card started after %d ms", i * 10)); - break; - } - UxPause(10); - } - - if (wSig != DIVAS_SIGNATURE) - { - DPRINTF(("divas: card failed to start (Sig=0x%x)", wSig)); - UxCardMemDetach(card->hw, DivasIOBase); - return -1; - } - - card->is_live = TRUE; - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x3F6); - *channels = UxCardPortIoInW(card->hw, DivasIOBase, REG_DATA); - - UxCardMemDetach(card->hw, DivasIOBase); - - PLXIOBase = UxCardMemAttach(card->hw, PLX_IOBASE); - - bPLX9060 = UxCardPortIoInW(card->hw, PLXIOBase, 0x6C) | UxCardPortIoInW(card->hw, PLXIOBase, 0x6E); - - if (bPLX9060) - { - dwSerialNum = (UxCardPortIoInW(card->hw, PLXIOBase, 0x1E) << 16) | - (UxCardPortIoInW(card->hw, PLXIOBase, 0x22)); - DPRINTF(("divas: PLX9060 in use. Serial number 0x%04X", dwSerialNum)); - } - else - { - dwSerialNum = (UxCardPortIoInW(card->hw, PLXIOBase, 0x22) << 16) | - (UxCardPortIoInW(card->hw, PLXIOBase, 0x26)); - DPRINTF(("divas: PLX9050 in use. Serial number 0x%04X", dwSerialNum)); - } - - UxCardMemDetach(card->hw, PLXIOBase); - - card->serial_no = dwSerialNum; - - diva_server_bri_test_int(card); - - return 0; -} - -static -int diva_server_bri_load(card_t *card, dia_load_t *load) -{ - byte *DivasIOBase; - dword r3000_base; - dword dwAddr, dwLength, i; - word wTest, aWord; - - DPRINTF(("divas: loading Diva Server BRI card")); - - switch (load->code_type) - { - case DIA_CPU_CODE: - DPRINTF(("divas: loading RISC %s", &load->code[0x80])); - - card->hw->features = GetProtFeatureValue((char *)&load->code[0x80]); - DPRINTF(("divas: features 0x%x", card->hw->features)); - if (card->hw->features == 0xFFFF) - { - DPRINTF(("divas: invalid feature string failed load\n")); - return -1; - } - - r3000_base = 0; - break; - - case DIA_DSP_CODE: - DPRINTF(("divas: DSP code \"%s\"", load->code)); - - if ((card->hw->features) && (!(card->hw->features & PROTCAP_TELINDUS))) - { - DPRINTF(("divas: only Telindus style binaries supported")); - return -1; - } - - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - DPRINTF(("divas: V.90 DSP binary")); - r3000_base = (0xBF790000 + (((sizeof(dword) + (sizeof(t_dsp_download_desc)* DSP_MAX_DOWNLOAD_COUNT)) + 3) & 0xFFFFFFFC)); - } - else - { - DPRINTF(("divas: non-V.90 DSP binary")); - r3000_base = (0xBF7A0000 + (((sizeof(dword) + (sizeof(t_dsp_download_desc)* DSP_MAX_DOWNLOAD_COUNT)) + 3) & 0xFFFFFFFC)); - } - DPRINTF(("divas: loading at 0x%x", r3000_base)); - break; - - case DIA_TABLE_CODE: - DPRINTF(("divas: TABLE code")); - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - r3000_base = 0xBF790000 + sizeof(dword); - } - else - { - r3000_base = 0xBF7A0000 + sizeof(dword); - } - - break; - - case DIA_DLOAD_CNT: - DPRINTF(("divas: COUNT code")); - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - r3000_base = 0xBF790000; - } - else - { - r3000_base = 0xBF7A0000; - } - break; - - default: - DPRINTF(("divas: unknown code type %d", load->code_type)); - return -1; - break; - } - - DPRINTF(("divas: Writing %d bytes to adapter, address 0x%x", load->length, r3000_base)); - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - DPRINTF(("divas: Attached to 0x%04X", DivasIOBase)); - - dwLength = load->length; - - for (i=0; i < dwLength; i++) - { - dwAddr = r3000_base + i; - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, dwAddr >> 16); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, dwAddr); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, load->code[i]); - } - - DPRINTF(("divas: Verifying")); - - for (i=0; i<dwLength; i++) - { - dwAddr = r3000_base + i; - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, dwAddr >> 16); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, dwAddr); - - wTest = UxCardPortIoIn(card->hw, DivasIOBase, REG_DATA); - - aWord = load->code[i]; - - if (wTest != aWord) - { - DPRINTF(("divas: load verify failed on byte %d", i)); - DPRINTF(("divas: RAM 0x%x File 0x%x",wTest,aWord)); - - UxCardMemDetach(card->hw, DivasIOBase); - - return -1; - } - } - - DPRINTF(("divas: Loaded and verified. Detaching from adapter")); - - UxCardMemDetach(card->hw, DivasIOBase); - - UxCardLog(0); - - return 0; -} - -static -int diva_server_bri_config(card_t *card, dia_config_t *config) -{ - byte *DivasIOBase, i; - - DPRINTF(("divas: configuring Diva Server BRI card")); - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 8); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->tei); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 9); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->nt2); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 10); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->sig_flags); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 11); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->watchdog); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 12); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->permanent); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 13); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 14); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->stable_l2); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 15); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->no_order_check); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 16); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 17); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 18); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->low_channel); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 19); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->prot_version); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 20); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->crc4); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 21); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0); - - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - DPRINTF(("divas: Signifying V.90")); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 22); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 4); - } - else - { - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 22); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0); - } - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 23); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, card->serial_no & 0xFF); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 24); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, (card->serial_no >> 8) & 0xFF); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 25); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, (card->serial_no >> 16) & 0xFF); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 26); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 21); - - for (i=0; i<32; i++) - { - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 32+i); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[0].oad[i]); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 64+i); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[0].osa[i]); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 96+i); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[0].spid[i]); - - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 128+i); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[1].oad[i]); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 160+i); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[1].osa[i]); - - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 192+i); - UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[1].spid[i]); - } - - UxCardMemDetach(card->hw, DivasIOBase); - - return 0; -} - -void DivasBriPatch(card_t *card) -{ - dword PLXIOBase = 0; - dword DivasIOBase = 0; - - PLXIOBase = card->cfg.reset_base; - DivasIOBase = card->cfg.io_base; - - if(card->hw == NULL) - { - DPRINTF(("Divas: BRI PATCH (PLX chip) card->hw is null")); - return; - } - - if (PLXIOBase == 0) - { - DPRINTF(("Divas: BRI (PLX chip) cannot be patched. The BRI adapter may")); - DPRINTF(("Divas: not function properly. If you do encounter problems,")); - DPRINTF(("Divas: ensure that your machine is using the latest BIOS.")); - return; - } - - DPRINTF(("Divas: PLX I/O Base 0x%x", PLXIOBase)); - DPRINTF(("Divas: Divas I/O Base 0x%x", DivasIOBase)); - - if (PLXIOBase & 0x80) - { - dword dwSize, dwSerialNum, dwCmd; - boolean_t bPLX9060; - word wSerHi, wSerLo; - - DPRINTF(("Divas: Patch required")); - dwCmd = 0; - UxPciConfigWrite(card->hw, 4, PCI_COMMAND, &dwCmd); - - PLXIOBase &= ~0x80; - UxPciConfigWrite(card->hw, 4, PCI_BADDR1, &PLXIOBase); - - dwSize = 0xFFFFFFFF; - UxPciConfigWrite(card->hw, 4, PCI_BADDR1, &dwSize); - UxPciConfigRead(card->hw, 4, PCI_BADDR1, &dwSize); - - dwSize = (~ (dwSize & ~7)) + 1; - - DivasIOBase = PLXIOBase + dwSize; - - card->cfg.reset_base = PLXIOBase; - card->cfg.io_base = DivasIOBase; - UxPciConfigWrite(card->hw, 4, PCI_BADDR1, &card->cfg.reset_base); - UxPciConfigWrite(card->hw, 4, PCI_BADDR2, &card->cfg.io_base); - - dwCmd = 5; - UxPciConfigWrite(card->hw, 4, PCI_COMMAND, &dwCmd); - - bPLX9060 = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6C) | - UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6E); - - if (bPLX9060) - { - wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x1E); - wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22); - dwSerialNum = (wSerHi << 16) | wSerLo; - UxCardLog(0); - } - else - { - wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22); - wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x26); - dwSerialNum = (wSerHi << 16) | wSerLo; - UxCardLog(0); - } - } - else - { - word wSerHi, wSerLo; - boolean_t bPLX9060; - dword dwSerialNum; - - DPRINTF(("divas: No patch required")); - - bPLX9060 = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6C) | - UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6E); - - if (bPLX9060) - { - wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x1E); - wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22); - dwSerialNum = (wSerHi << 16) | wSerLo; - } - else - { - wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22); - wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x26); - dwSerialNum = (wSerHi << 16) | wSerLo; - } - } - DPRINTF(("Divas: After patching:")); - DPRINTF(("Divas: PLX I/O Base 0x%x", PLXIOBase)); - DPRINTF(("Divas: Divas I/O Base 0x%x", DivasIOBase)); - -} - -#define TEST_INT_DIVAS_BRI 0x12 -static -int diva_server_bri_test_int(card_t *card) -{ - boolean_t bPLX9060 = FALSE; - byte *PLXIOBase = NULL, *DivasIOBase = NULL; - - DPRINTF(("divas: test interrupt for Diva Server BRI card")); - - PLXIOBase = UxCardMemAttach(card->hw, PLX_IOBASE); - - bPLX9060 = UxCardPortIoInW(card->hw, PLXIOBase, 0x6C) || UxCardPortIoInW(card->hw, PLXIOBase, 0x6E); - - if (bPLX9060) - { /* PLX9060 */ - UxCardPortIoOut(card->hw, PLXIOBase, 0x69, 0x09); - } - else - { /* PLX9050 */ - UxCardPortIoOut(card->hw, PLXIOBase, 0x4C, 0x41); - } - - card->test_int_pend = TEST_INT_DIVAS_BRI; - - UxCardMemDetach(card->hw, PLXIOBase); - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0x89); - - UxCardMemDetach(card->hw, DivasIOBase); - - return 0; -} - -static -int diva_server_bri_mem_get(card_t *card, mem_block_t *mem_block) -{ - dword user_addr = mem_block->addr; - word length = 0; - dword addr; - word i; - byte *DivasIOBase; - - DPRINTF(("divas: Retrieving memory from 0x%x", user_addr)); - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - addr = user_addr; - - for (i=0; i < (16 * 8); i++) - { - addr = user_addr + i; - - UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, addr >> 16); - UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, (word) addr); - - mem_block->data[i] = UxCardPortIoIn(card->hw, DivasIOBase, REG_DATA); - length++; - } - - UxCardMemDetach(card->hw, DivasIOBase); - - return length; -} - -int DivasBriInit(card_t *card, dia_card_t *cfg) -{ - DPRINTF(("divas: initialise Diva Server BRI card")); - - if (DivasBRIInitPCI(card, cfg) == -1) - { - return -1; - } - - card->card_reset = diva_server_bri_reset; - card->card_start = diva_server_bri_start; - card->card_load = diva_server_bri_load; - card->card_config = diva_server_bri_config; - card->reset_int = diva_server_bri_reset_int; - card->card_mem_get = diva_server_bri_mem_get; - - card->xlog_offset = DIVAS_MAINT_OFFSET; - - card->out = DivasOut; - card->test_int = DivasTestInt; - card->dpc = DivasDpc; - card->clear_int = DivasClearInt; - card->card_isr = bri_ISR; - - card->a.ram_out = io_out; - card->a.ram_outw = io_outw; - card->a.ram_out_buffer = io_out_buffer; - card->a.ram_inc = io_inc; - - card->a.ram_in = io_in; - card->a.ram_inw = io_inw; - card->a.ram_in_buffer = io_in_buffer; - card->a.ram_look_ahead = io_look_ahead; - - return 0; -} - -word GetProtFeatureValue(char *sw_id) -{ - word features = 0; - - while ((*sw_id) && (sw_id[0] != '[')) - sw_id++; - - if (sw_id == NULL) - { - DPRINTF(("divas: no feature string present")); - features = -1; - } - else - { - byte i, shifter; - - sw_id += 3; - - for (i=0, shifter=12; i<4; i++, shifter-=4) - { - if ((sw_id[i] >= '0') && (sw_id[i] <= '9')) - { - features |= (sw_id[i] - '0') << shifter; - } - else if ((sw_id[i] >= 'a') && (sw_id[i] <= 'f')) - { - features |= (sw_id[i] - 'a' + 10) << shifter; - } - else if ((sw_id[i] >= 'A') && (sw_id[i] <= 'F')) - { - features |= (sw_id[i] - 'A' + 10) << shifter; - } - else - { - DPRINTF(("divas: invalid feature string")); - return -1; - } - } - } - - return features; -} - - -int bri_ISR (card_t* card) -{ - int served = 0; - byte *DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - if (UxCardPortIoIn (card->hw, DivasIOBase, M_PCI_RESET) & 0x01) - { - served = 1; - card->int_pend += 1; - DivasDpcSchedule(); /* ISR DPC */ - UxCardPortIoOut (card->hw, DivasIOBase, M_PCI_RESET, 0x08); - } - - UxCardMemDetach(card->hw, DivasIOBase); - - return (served != 0); -} - - diff --git a/drivers/isdn/eicon/common.c b/drivers/isdn/eicon/common.c deleted file mode 100644 index b9ec4041d3b3..000000000000 --- a/drivers/isdn/eicon/common.c +++ /dev/null @@ -1,867 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.15 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "eicon.h" -#include "sys.h" -#include "idi.h" -#include "constant.h" -#include "divas.h" -#include "pc.h" -#include "pr_pc.h" - -#include "uxio.h" - -#define DIVAS_LOAD_CMD 0x02 -#define DIVAS_START_CMD 0x03 -#define DIVAS_IRQ_RESET 0xC18 -#define DIVAS_IRQ_RESET_VAL 0xFE - -#define TEST_INT_DIVAS 0x11 -#define TEST_INT_DIVAS_BRI 0x12 -#define TEST_INT_DIVAS_Q 0x13 - -#define DIVAS_RESET 0x81 -#define DIVAS_LED1 0x04 -#define DIVAS_LED2 0x08 -#define DIVAS_LED3 0x20 -#define DIVAS_LED4 0x40 - -#define DIVAS_SIGNATURE 0x4447 - -#define MP_PROTOCOL_ADDR 0xA0011000 - -#define PLX_IOBASE 0 -#define DIVAS_IOBASE 1 - -typedef struct { - dword cmd; - dword addr; - dword len; - dword err; - dword live; - dword reserved[(0x1020>>2)-6]; - dword signature; - byte data[1]; -} diva_server_boot_t; - -int DivasCardNext; -card_t DivasCards[MAX_CARDS]; - -dia_config_t *DivasConfig(card_t *, dia_config_t *); - -static -DESCRIPTOR DIDD_Table[32]; - -void DIVA_DIDD_Read( DESCRIPTOR *table, int tablelength ) -{ - memset(table, 0, tablelength); - - if (tablelength > sizeof(DIDD_Table)) - tablelength = sizeof(DIDD_Table); - - if(tablelength % sizeof(DESCRIPTOR)) { - tablelength /= sizeof(DESCRIPTOR); - tablelength *= sizeof(DESCRIPTOR); - } - - if (tablelength > 0) - memcpy((void *)table, (void *)DIDD_Table, tablelength); - - return; -} - -void DIVA_DIDD_Write(DESCRIPTOR *table, int tablelength) -{ - if (tablelength > sizeof(DIDD_Table)) - tablelength = sizeof(DIDD_Table); - - memcpy((void *)DIDD_Table, (void *)table, tablelength); - - return; -} - -static -void init_idi_tab(void) -{ - DESCRIPTOR d[32]; - - memset(d, 0, sizeof(d)); - - d[0].type = IDI_DIMAINT; /* identify the DIMAINT entry */ - d[0].channels = 0; /* zero channels associated with dimaint*/ - d[0].features = 0; /* no features associated with dimaint */ - d[0].request = (IDI_CALL) DivasPrintf; - - DIVA_DIDD_Write(d, sizeof(d)); - - return; -} - -/* - * I/O routines for memory mapped cards - */ - -byte mem_in(ADAPTER *a, void *adr) -{ - card_t *card = a->io; - unsigned char *b, *m; - byte value; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - value = UxCardMemIn(card->hw, m); - - UxCardMemDetach(card->hw, b); - - return value; -} - -word mem_inw(ADAPTER *a, void *adr) -{ - card_t *card = a->io; - unsigned char *b, *m; - word value; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - value = UxCardMemInW(card->hw, m); - - UxCardMemDetach(card->hw, b); - - return value; -} - -void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length) -{ - card_t *card = a->io; - unsigned char *b, *m; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - UxCardMemInBuffer(card->hw, m, P, length); - - UxCardMemDetach(card->hw, b); - - return; -} - -void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) -{ - card_t *card = a->io; - unsigned char *b, *m; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (dword) &RBuffer->length; - card->RBuffer.length = UxCardMemInW(card->hw, m); - - m = b; - m += (dword) &RBuffer->P; - UxCardMemInBuffer(card->hw, m, card->RBuffer.P, card->RBuffer.length); - - e->RBuffer = (DBUFFER *) &card->RBuffer; - - UxCardMemDetach(card->hw, b); - - return; -} - -void mem_out(ADAPTER *a, void *adr, byte data) -{ - card_t *card = a->io; - unsigned char *b, *m; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - UxCardMemOut(card->hw, m, data); - - UxCardMemDetach(card->hw, b); - - return; -} - -void mem_outw(ADAPTER *a, void *adr, word data) -{ - card_t *card = a->io; - unsigned char *b, *m; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - UxCardMemOutW(card->hw, m, data); - - UxCardMemDetach(card->hw, b); - - return; -} - -void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length) -{ - card_t *card = a->io; - unsigned char *b, *m; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - UxCardMemOutBuffer(card->hw, m, P, length); - - UxCardMemDetach(card->hw, b); - - return; -} - -void mem_inc(ADAPTER *a, void *adr) -{ - word value; - card_t *card = a->io; - unsigned char *b, *m; - - m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - m += (unsigned int) adr; - - value = UxCardMemInW(card->hw, m); - value++; - UxCardMemOutW(card->hw, m, value); - - UxCardMemDetach(card->hw, b); - - return; -} - -/* - * I/O routines for I/O mapped cards - */ - -byte io_in(ADAPTER *a, void *adr) -{ - card_t *card = a->io; - byte value; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - value = UxCardIoIn(card->hw, DivasIOBase, adr); - - UxCardMemDetach(card->hw, DivasIOBase); - - return value; -} - -word io_inw(ADAPTER *a, void *adr) -{ - card_t *card = a->io; - word value; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - value = UxCardIoInW(card->hw, DivasIOBase, adr); - - UxCardMemDetach(card->hw, DivasIOBase); - - return value; -} - -void io_in_buffer(ADAPTER *a, void *adr, void *P, word length) -{ - card_t *card = a->io; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardIoInBuffer(card->hw, DivasIOBase, adr, P,length); - - UxCardMemDetach(card->hw, DivasIOBase); - - return; -} - -void io_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) -{ - card_t *card = a->io; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - card->RBuffer.length = UxCardIoInW(card->hw, DivasIOBase, (byte *) RBuffer); - - UxCardIoInBuffer(card->hw, DivasIOBase, &RBuffer->P, card->RBuffer.P, card->RBuffer.length); - - UxCardMemDetach(card->hw, DivasIOBase); - - e->RBuffer = (DBUFFER *) &card->RBuffer; - - return; -} - -void io_out(ADAPTER *a, void *adr, byte data) -{ - card_t *card = a->io; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardIoOut(card->hw, DivasIOBase, adr, data); - - UxCardMemDetach(card->hw, DivasIOBase); - - return; -} - -void io_outw(ADAPTER *a, void *adr, word data) -{ - card_t *card = a->io; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardIoOutW(card->hw, DivasIOBase, adr, data); - - UxCardMemDetach(card->hw, DivasIOBase); - - return; -} - -void io_out_buffer(ADAPTER *a, void *adr, void *P, word length) -{ - card_t *card = a->io; - byte *DivasIOBase = NULL; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - UxCardIoOutBuffer(card->hw, DivasIOBase, adr, P, length); - - UxCardMemDetach(card->hw, DivasIOBase); - - return; -} - -void io_inc(ADAPTER *a, void *adr) -{ - word value; - card_t *card = a->io; - byte *DivasIOBase; - - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - value = UxCardIoInW(card->hw, DivasIOBase, adr); - - value++; - - UxCardIoOutW(card->hw, DivasIOBase, adr, value); - - UxCardMemDetach(card->hw, DivasIOBase); - - return; -} - -static -void test_int(card_t *card) - -{ - byte *shared, *DivasIOBase; - - switch (card->test_int_pend) - { - case TEST_INT_DIVAS: - DPRINTF(("divas: test interrupt pending")); - shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - if (UxCardMemIn(card->hw, &shared[0x3FE])) - { - UxCardMemOut(card->hw, - &(((struct pr_ram *)shared)->RcOutput), 0); - UxCardMemDetach(card->hw, shared); - (*card->reset_int)(card); - shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - UxCardMemOut(card->hw, &shared[0x3FE], 0); - DPRINTF(("divas: test interrupt cleared")); - } - - UxCardMemDetach(card->hw, shared); - - card->test_int_pend = 0; - break; - - case TEST_INT_DIVAS_BRI: - DPRINTF(("divas: BRI test interrupt pending")); - (*card->reset_int)(card); - DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - UxCardIoOutW(card->hw, DivasIOBase, (void *) 0x3FE, 0); - UxCardMemDetach(card->hw, DivasIOBase); - DPRINTF(("divas: test interrupt cleared")); - card->test_int_pend = 0; - break; - - case TEST_INT_DIVAS_Q: - DPRINTF(("divas: 4BRI test interrupt pending")); - (*card->reset_int)(card); - card->test_int_pend = 0; - break; - - default: - DPRINTF(("divas: unknown test interrupt pending")); - return; - } - return; -} - -void card_isr (void *dev_id) -{ - card_t *card = (card_t *) dev_id; - ADAPTER *a = &card->a; - int ipl; - - if (card->test_int_pend) - { - ipl = UxCardLock(card->hw); - card->int_pend=0; - test_int(card); - UxCardUnlock(card->hw,ipl); - return; - } - - if(card->card_isr) - { - (*(card->card_isr))(card); - } - else - { - ipl = UxCardLock(card->hw); - - if ((card->test_int)(a)) - { - (card->reset_int)(card); - } - - UxCardUnlock(card->hw,ipl); - - } - -} - -int DivasCardNew(dia_card_t *card_info) -{ - card_t *card; - static boolean_t first_call = TRUE; - boolean_t NeedISRandReset = FALSE; - - DPRINTF(("divas: new card ")); - - if (first_call) - { - first_call = FALSE; - init_idi_tab(); - } - - DivasConfigGet(card_info); - - if (DivasCardNext == DIM(DivasCards)) - { - KDPRINTF((KERN_WARNING "Divas: no space available for new card")); - return -1; - } - - card = &DivasCards[DivasCardNext]; - - card->state = DIA_UNKNOWN; - - card->cfg = *card_info; - - card->a.io = card; - - if (UxCardHandleGet(&card->hw, card_info)) - { - KDPRINTF((KERN_WARNING "Divas: cannot get OS specific handle for card")); - return -1; - } - - if (card_info->card_type == DIA_CARD_TYPE_DIVA_SERVER_B) - { - DivasBriPatch(card); - card_info->io_base = card->cfg.io_base; - } - - switch (card_info->card_type) - { - case DIA_CARD_TYPE_DIVA_SERVER: - if (DivasPriInit(card, card_info)) - { - return -1; - } - NeedISRandReset = TRUE; - break; - - case DIA_CARD_TYPE_DIVA_SERVER_B: - if (DivasBriInit(card, card_info)) - { - return -1; - } - NeedISRandReset = TRUE; - break; - - case DIA_CARD_TYPE_DIVA_SERVER_Q: - if (Divas4BriInit(card, card_info)) - { - return -1; - } - - if (card_info->name[6] == '0') - { - NeedISRandReset = TRUE; - } - else // Need to set paramater for ISR anyway - { - card->hw->user_isr_arg = card; - card->hw->user_isr = card_isr; - } - break; - - default: - KDPRINTF((KERN_WARNING "Divas: unsupported card type (%d)", card_info->card_type)); - return -1; - } - - if (NeedISRandReset) - { - if (UxIsrInstall(card->hw, card_isr, card)) - { - KDPRINTF((KERN_WARNING "Divas: Install ISR failed (IRQ %d)", card->cfg.irq)); - UxCardHandleFree(card->hw); - return -1; - } - - if (card_info->card_type != DIA_CARD_TYPE_DIVA_SERVER_Q) - { - if ((*card->card_reset)(card)) - { - KDPRINTF((KERN_WARNING "Divas: Adapter reset failed")); - return -1; - } - card->state = DIA_RESET; - } - - NeedISRandReset = FALSE; - } - - DivasCardNext++; - - return 0; -} - -void *get_card(int card_id) -{ - int i; - - for (i=0; i < DivasCardNext; i++) - { - if (DivasCards[i].cfg.card_id == card_id) - { - return(&DivasCards[i]); - } - } - - DPRINTF(("divas: get_card() : no such card id (%d)", card_id)); - - return NULL; -} - -int DivasCardConfig(dia_config_t *config) -{ - card_t *card; - int status; - - DPRINTF(("divas: configuring card")); - - card = get_card(config->card_id); - if (!card) - { - return -1; - } - - config = DivasConfig(card, config); - - status = (*card->card_config)(card, config); - - if (!status) - { - card->state = DIA_CONFIGURED; - } - return status; -} - -int DivasCardLoad(dia_load_t *load) -{ - card_t *card; - int status; - - card = get_card(load->card_id); - if (!card) - { - return -1; - } - - if (card->state == DIA_RUNNING) - { - (*card->card_reset)(card); - } - - status = (*card->card_load)(card, load); - if (!status) - { - card->state = DIA_LOADED; - } - return status; -} - -static int idi_register(card_t *card, byte channels) -{ - DESCRIPTOR d[32]; - int length, num_entities; - - DPRINTF(("divas: registering card with IDI")); - - num_entities = (channels > 2) ? MAX_PENTITIES : MAX_ENTITIES; - card->e_tbl = UxAlloc(sizeof(E_INFO) * num_entities); - - if (!card->e_tbl) - { - KDPRINTF((KERN_WARNING "Divas: IDI register failed - no memory available")); - return -1; - } - - memset(card->e_tbl, 0, sizeof(E_INFO) * num_entities); - card->e_max = num_entities; - - DIVA_DIDD_Read(d, sizeof(d)); - - for(length=0; length < DIM(d); length++) - if (d[length].type == 0) break; - - if (length >= DIM(d)) - { - KDPRINTF((KERN_WARNING "Divas: IDI register failed - table full")); - return -1; - } - - switch (card->cfg.card_type) - { - case DIA_CARD_TYPE_DIVA_SERVER: - d[length].type = IDI_ADAPTER_PR; - /* d[length].serial = card->serial_no; */ - break; - - case DIA_CARD_TYPE_DIVA_SERVER_B: - d[length].type = IDI_ADAPTER_MAESTRA; - /* d[length].serial = card->serial_no; */ - break; - - // 4BRI is treated as 4 BRI adapters - case DIA_CARD_TYPE_DIVA_SERVER_Q: - d[length].type = IDI_ADAPTER_MAESTRA; - /* d[length].serial = card->cfg.serial; */ - } - - d[length].features = 0; - d[length].features |= DI_FAX3|DI_MODEM|DI_POST|DI_V110|DI_V120; - - if ( card->hw->features & PROTCAP_MANIF ) - { - d[length].features |= DI_MANAGE ; - } - if ( card->hw->features & PROTCAP_V_42 ) - { - d[length].features |= DI_V_42 ; - } - if ( card->hw->features & PROTCAP_EXTD_FAX ) - { - d[length].features |= DI_EXTD_FAX ; - } - - d[length].channels = channels; - d[length].request = DivasIdiRequest[card - DivasCards]; - - length++; - - DIVA_DIDD_Write(d, sizeof(d)); - - return 0; -} - -int DivasCardStart(int card_id) -{ - card_t *card; - byte channels; - int status; - - DPRINTF(("divas: starting card")); - - card = get_card(card_id); - if (!card) - { - return -1; - } - - status = (*card->card_start)(card, &channels); - if (status) - { - return status; - } - - /* 4BRI == 4 x BRI so call idi_register 4 times each with 2 channels */ - if (card->cfg.card_type == DIA_CARD_TYPE_DIVA_SERVER_Q) - { - int i; - card_t *FourBRISlave; - - for (i=3; i >= 0; i--) - { - FourBRISlave = get_card(card_id - i); /* 0, 1, 2, 3 */ - if (FourBRISlave) - { - idi_register(FourBRISlave, 2); - FourBRISlave->state = DIA_RUNNING; - } - } - card->serial_no = card->cfg.serial; - - DPRINTF(("divas: card id %d (4BRI), serial no. 0x%x ready with %d channels", - card_id - 3, card->serial_no, (int) channels)); - } - else - { - status = idi_register(card, channels); - if (!status) - { - card->state = DIA_RUNNING; - DPRINTF(("divas: card id %d, serial no. 0x%x ready with %d channels", - card_id, card->serial_no, (int) channels)); - } - } - - return status; -} - -int DivasGetMem(mem_block_t *mem_block) -{ - card_t *card; - word card_id = mem_block->card_id; - - card = get_card(card_id); - if (!card) - { - return 0; - } - - return (*card->card_mem_get)(card, mem_block); -} - - -/* - * Deleyed Procedure Call for handling interrupts from card - */ - -void DivaDoCardDpc(card_t *card) -{ - ADAPTER *a; - - a = &card->a; - - if(UxInterlockedIncrement(card->hw, &card->dpc_reentered) > 1) - { - return; - } - - do{ - if((*(card->test_int))(a)) - { - (*(card->dpc))(a); - (*(card->clear_int))(a); - } - (*(card->out))(a); - }while(UxInterlockedDecrement(card->hw, &card->dpc_reentered)); - -} - -void DivasDoDpc(unsigned long dummy) -{ - card_t *card = DivasCards; - int i = DivasCardNext; - - while(i--) - { - if (card->state == DIA_RUNNING) - DivaDoCardDpc(card); - card++; - } -} - -/* - * DivasGetNum - * Returns the number of active adapters - */ - -int DivasGetNum(void) -{ - return(DivasCardNext); -} - -/* - * DivasGetList - * Returns a list of active adapters - */ -int DivasGetList(dia_card_list_t *card_list) -{ - int i; - - memset(card_list, 0, sizeof(dia_card_list_t)); - - for(i = 0; i < DivasCardNext; i++) - { - card_list->card_type = DivasCards[i].cfg.card_type; - card_list->card_slot = DivasCards[i].cfg.slot; - card_list->state = DivasCards[i].state; - card_list++; - } - - return 0; - -} - -/* - * control logging for specified card - */ - -void DivasLog(dia_log_t *log) -{ - card_t *card; - - card = get_card(log->card_id); - if (!card) - { - return; - } - - card->log_types = log->log_types; - - return; -} - diff --git a/drivers/isdn/eicon/constant.h b/drivers/isdn/eicon/constant.h deleted file mode 100644 index b389cb92b30a..000000000000 --- a/drivers/isdn/eicon/constant.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -/*------------------------------------------------------------------*/ -/* Q.931 information elements maximum length */ -/* excluding the identifier, including the length field */ -/*------------------------------------------------------------------*/ - -#define MAX_LEN_BC 13 -#define MAX_LEN_LLC 19 /* ctr3 */ -#define MAX_LEN_HLC 6 /* ctr3 */ -#define MAX_LEN_UUI 200 /* Hicom USBS req */ -#define MAX_LEN_NUM 24 -#define MAX_LEN_DSP 83 /* ctr3 */ -#define MAX_LEN_NI 4 -#define MAX_LEN_PI 5 -#define MAX_LEN_SIN 3 -#define MAX_LEN_CST 4 -#define MAX_LEN_SIG 2 -#define MAX_LEN_SPID 32 -#define MAX_LEN_EID 3 -#define MAX_LEN_CHI 35 /* ctr3 */ -#define MAX_LEN_CAU 33 -#define MAX_LEN_FTY 130 -#define MAX_LEN_KEY 83 /* ctr3 */ -#define MAX_LEN_RSI 4 -#define MAX_LEN_CAI 11 -#define MAX_NUM_SPID 4 -#define MAX_LEN_USERID 9 -#define MAX_LEN_APPLID 5 -#define MAX_LEN_NTTCIF 15 - -/*------------------------------------------------------------------*/ -/* decision return values */ -/*------------------------------------------------------------------*/ - -#define YES 1 -#define NO 0 - - -/*-------------------------------------------------------------------*/ -/* w element coding */ -/*-------------------------------------------------------------------*/ - -#define NTTCIF 0x01 -#define BC 0x04 -#define CAU 0x08 -#define CAD 0x0c -#define CAI 0x10 -#define CST 0x14 -#define CHI 0x18 -#define LLI 0x19 -#define CHA 0x1a -#define FTY 0x1c -#define PI 0x1e -#define NFAC 0x20 -#define TC 0x24 -#define ATT_EID 0x26 -#define NI 0x27 -#define DSP 0x28 -#define DT 0x29 -#define KEY 0x2c -#define KP 0x2c -#define UID 0x2d -#define SIG 0x34 -#define FI 0x39 -#define SPID 0x3a -#define EID 0x3b -#define DSPF 0x3c -#define ECAD 0x4c -#define OAD 0x6c -#define OSA 0x6d -#define DAD 0x70 -#define CPN 0x70 -#define DSA 0x71 -#define RDX 0x73 -#define RAD 0x74 -#define RDN 0x74 -#define RSI 0x79 -#define SCR 0x7A /* internal unscreened CPN */ -#define MIE 0x7a /* internal management info element */ -#define LLC 0x7c -#define HLC 0x7d -#define UUI 0x7e -#define ESC 0x7f - -#define SHIFT 0x90 -#define MORE 0xa0 -#define CL 0xb0 - -/* information elements used on the spid interface */ -#define SPID_CMD 0xc0 -#define SPID_LINK 0x10 -#define SPID_DN 0x70 -#define SPID_BC 0x04 -#define SPID_SWITCH 0x11 - -/*------------------------------------------------------------------*/ -/* global configuration parameters, defined in exec.c */ -/* these parameters are configured with program loading */ -/*------------------------------------------------------------------*/ - -#define PROT_1TR6 0 -#define PROT_ETSI 1 -#define PROT_FRANC 2 -#define PROT_BELG 3 -#define PROT_SWED 4 -#define PROT_NI 5 -#define PROT_5ESS 6 -#define PROT_JAPAN 7 -#define PROT_ATEL 8 -#define PROT_US 9 -#define PROT_ITALY 10 -#define PROT_TWAN 11 -#define PROT_AUSTRAL 12 - -#define INIT_PROT_1TR6 0x80|PROT_1TR6 -#define INIT_PROT_ETSI 0x80|PROT_ETSI -#define INIT_PROT_FRANC 0x80|PROT_FRANC -#define INIT_PROT_BELG 0x80|PROT_BELG -#define INIT_PROT_SWED 0x80|PROT_SWED -#define INIT_PROT_NI 0x80|PROT_NI -#define INIT_PROT_5ESS 0x80|PROT_5ESS -#define INIT_PROT_JAPAN 0x80|PROT_JAPAN -#define INIT_PROT_ATEL 0x80|PROT_ATEL -#define INIT_PROT_ITALY 0x80|PROT_ITALY -#define INIT_PROT_TWAN 0x80|PROT_TWAN -#define INIT_PROT_AUSTRAL 0x80|PROT_AUSTRAL - - -/* -----------------------------------------------------------** -** The PROTOCOL_FEATURE_STRING in feature.h (included ** -** in prstart.sx and astart.sx) defines capabilities and ** -** features of the actual protocol code. It's used as a bit ** -** mask. ** -** The following Bits are defined: ** -** -----------------------------------------------------------*/ - -#define PROTCAP_TELINDUS 0x0001 /* Telindus Variant of protocol code */ -#define PROTCAP_MANIF 0x0002 /* Management interface implemented */ -#define PROTCAP_V_42 0x0004 /* V42 implemented */ -#define PROTCAP_V90D 0x0008 /* V.90D (implies up to 384k DSP code) */ -#define PROTCAP_EXTD_FAX 0x0010 /* Extended FAX (ECM, 2D, T6, Polling) */ -#define PROTCAP_FREE4 0x0020 /* not used */ -#define PROTCAP_FREE5 0x0040 /* not used */ -#define PROTCAP_FREE6 0x0080 /* not used */ -#define PROTCAP_FREE7 0x0100 /* not used */ -#define PROTCAP_FREE8 0x0200 /* not used */ -#define PROTCAP_FREE9 0x0400 /* not used */ -#define PROTCAP_FREE10 0x0800 /* not used */ -#define PROTCAP_FREE11 0x1000 /* not used */ -#define PROTCAP_FREE12 0x2000 /* not used */ -#define PROTCAP_FREE13 0x4000 /* not used */ -#define PROTCAP_EXTENSION 0x8000 /* used for future extentions */ diff --git a/drivers/isdn/eicon/divalog.h b/drivers/isdn/eicon/divalog.h deleted file mode 100644 index e46ee1d6517f..000000000000 --- a/drivers/isdn/eicon/divalog.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Include file for defining the kernel logger messages - * These definitions are shared between the klog driver and the - * klogd daemon process - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#if !defined(_KLOGMSG_H) -#define _KLOGMSG_H - -/* define a type for a log entry */ - -#define KLOG_TEXT_MSG (0) -#define KLOG_XLOG_MSG (1) -#define KLOG_XTXT_MSG (2) -#define KLOG_IDI_REQ (4) -#define KLOG_IDI_CALLBACK (5) -#define KLOG_CAPI_MSG (6) - -typedef struct -{ - unsigned long time_stamp; /* in ms since last system boot */ - int card; /* card number (-1 for all) */ - unsigned int type; /* type of log message (0 is text) */ - unsigned int length; /* message length (non-text messages only) */ - unsigned short code; /* message code (non-text messages only) */ - char buffer[110];/* text/data to log */ -} klog_t; - -void DivasLogAdd(void *buffer, int length); -#endif /* of _KLOGMSG_H */ diff --git a/drivers/isdn/eicon/divas.h b/drivers/isdn/eicon/divas.h deleted file mode 100644 index 63441a6d8ab4..000000000000 --- a/drivers/isdn/eicon/divas.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * External Diva Server driver include file - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.5 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#if !defined(DIVAS_H) -#define DIVAS_H - -#include "sys.h" - - -/* IOCTL commands */ - -#define DIA_IOCTL_INIT (0) -#define DIA_IOCTL_LOAD (1) -#define DIA_IOCTL_CONFIG (2) -#define DIA_IOCTL_START (3) -#define DIA_IOCTL_GET_NUM (4) -#define DIA_IOCTL_GET_LIST (5) -#define DIA_IOCTL_LOG (6) -#define DIA_IOCTL_DETECT (7) -#define DIA_IOCTL_SPACE (8) -#define DIA_IOCTL_GET_MEM (9) -#define DIA_IOCTL_FLAVOUR (10) -#define DIA_IOCTL_XLOG_REQ (11) - -/* Error codes */ - -#define XLOG_ERR_CARD_NUM (13) -#define XLOG_ERR_DONE (14) -#define XLOG_ERR_CMD (15) -#define XLOG_ERR_TIMEOUT (16) -#define XLOG_ERR_CARD_STATE (17) -#define XLOG_ERR_UNKNOWN (18) -#define XLOG_OK (0) - -/* Adapter states */ - -#define DIA_UNKNOWN (0) -#define DIA_RESET (1) -#define DIA_LOADED (2) -#define DIA_CONFIGURED (3) -#define DIA_RUNNING (4) - -/* Stucture for getting card specific information from active cad driver */ - -typedef struct -{ - int card_type; - int card_slot; - int state; -} dia_card_list_t; - -/* use following to select which logging to have active */ - -#define DIVAS_LOG_DEBUG (1 << 0) -#define DIVAS_LOG_XLOG (1 << 1) -#define DIVAS_LOG_IDI (1 << 2) -#define DIVAS_LOG_CAPI (1 << 3) - -/* stucture for DIA_IOCTL_LOG to get information from adapter */ - -typedef struct -{ - int card_id; - int log_types; /* bit mask of log types: use DIVAS_LOG_XXX */ -} dia_log_t; - -/* list of cards supported by this driver */ - -#define DIA_CARD_TYPE_DIVA_SERVER (0) /* Diva Server PRI */ -#define DIA_CARD_TYPE_DIVA_SERVER_B (1) /* Diva Server BRI */ -#define DIA_CARD_TYPE_DIVA_SERVER_Q (2) /* Diva Server 4-BRI */ - -/* bus types */ - -#define DIA_BUS_TYPE_ISA (0) -#define DIA_BUS_TYPE_ISA_PNP (1) -#define DIA_BUS_TYPE_PCI (2) -#define DIA_BUS_TYPE_MCA (3) - -/* types of memory used (index for memory array below) */ - -#define DIVAS_RAM_MEMORY 0 -#define DIVAS_REG_MEMORY 1 -#define DIVAS_CFG_MEMORY 2 -#define DIVAS_SHARED_MEMORY 3 -#define DIVAS_CTL_MEMORY 4 -/* - * card config information - * passed as parameter to DIA_IOCTL_INIT ioctl to initialise new card - */ - -typedef struct -{ - int card_id; /* unique id assigned to this card */ - int card_type; /* use DIA_CARD_TYPE_xxx above */ - int bus_type; /* use DIA_BUS_TYPE_xxx above */ - struct pci_dev *pdev; - int slot; /* slot number in bus */ - unsigned char irq; /* IRQ number */ - int reset_base; /* Reset register for I/O mapped cards */ - int io_base; /* I/O base for I/O mapped cards */ - void *memory[5]; /* memory base addresses for memory mapped cards */ - char name[9]; /* name of adapter */ - int serial; /* serial number */ - unsigned char int_priority; /* Interrupt priority */ -} dia_card_t; - -/* - * protocol configuration information - * passed as parameter to DIA_IOCTL_CONFIG ioctl to configure card - */ - -typedef struct -{ - int card_id; /* to identify particular card */ - unsigned char tei; - unsigned char nt2; - unsigned char watchdog; - unsigned char permanent; - unsigned char x_interface; - unsigned char stable_l2; - unsigned char no_order_check; - unsigned char handset_type; - unsigned char sig_flags; - unsigned char low_channel; - unsigned char prot_version; - unsigned char crc4; - struct - { - unsigned char oad[32]; - unsigned char osa[32]; - unsigned char spid[32]; - }terminal[2]; -} dia_config_t; - -/* - * code configuration - * passed as parameter to DIA_IOCTL_LOAD ioctl - * one of these ioctl per code file to load - */ - -typedef struct -{ - int card_id; /* card to load */ - enum - { - DIA_CPU_CODE, /* CPU code */ - DIA_DSP_CODE, /* DSP code */ - DIA_CONT_CODE, /* continuation of code */ - DIA_TABLE_CODE, /* code table */ - DIA_DLOAD_CNT, /* number of downloads*/ - DIA_FPGA_CODE - } code_type; /* code for CPU or DSP ? */ - int length; /* length of code */ - unsigned char *code; /* pointer (in user-space) to code */ -} dia_load_t; - -/* - * start configuration - * passed as parameter to DIA_IOCTL_START ioctl - */ - -typedef struct -{ - int card_id; /* card to start */ -} dia_start_t; - -/* used for retrieving memory from the card */ - -typedef struct { - word card_id; - dword addr; - byte data[16 * 8]; -} mem_block_t; - -/* DIVA Server specific addresses */ - -#define DIVAS_CPU_START_ADDR (0x0) -#define ORG_MAX_PROTOCOL_CODE_SIZE 0x000A0000 -#define ORG_MAX_DSP_CODE_SIZE (0x000F0000 - ORG_MAX_PROTOCOL_CODE_SIZE) -#define ORG_DSP_CODE_BASE (0xBF7F0000 - ORG_MAX_DSP_CODE_SIZE) -#define DIVAS_DSP_START_ADDR (0xBF7A0000) -#define DIVAS_SHARED_OFFSET (0x1000) -#define MP_DSP_CODE_BASE 0xa03a0000 -#define MQ_PROTCODE_OFFSET 0x100000 -#define MQ_SM_OFFSET 0X0f0000 - -#define V90D_MAX_PROTOCOL_CODE_SIZE 0x00090000 -#define V90D_MAX_DSP_CODE_SIZE (0x000F0000 - V90D_MAX_PROTOCOL_CODE_SIZE) -#define V90D_DSP_CODE_BASE (0xBF7F0000 - V90D_MAX_DSP_CODE_SIZE) - -#define MQ_ORG_MAX_PROTOCOL_CODE_SIZE 0x000a0000 /* max 640K Protocol-Code */ -#define MQ_ORG_MAX_DSP_CODE_SIZE 0x00050000 /* max 320K DSP-Code */ -#define MQ_ORG_DSP_CODE_BASE (MQ_MAX_DSP_DOWNLOAD_ADDR \ - - MQ_ORG_MAX_DSP_CODE_SIZE) -#define MQ_V90D_MAX_PROTOCOL_CODE_SIZE 0x00090000 /* max 576K Protocol-Code */ -#define MQ_V90D_MAX_DSP_CODE_SIZE 0x00060000 /* max 384K DSP-Code if V.90D included */ -#define MQ_MAX_DSP_DOWNLOAD_ADDR 0xa03f0000 -#define MQ_V90D_DSP_CODE_BASE (MQ_MAX_DSP_DOWNLOAD_ADDR \ - - MQ_V90D_MAX_DSP_CODE_SIZE) - - -#define ALIGNMENT_MASK_MAESTRA 0xfffffffc - -#endif /* DIVAS_H */ diff --git a/drivers/isdn/eicon/dsp_defs.h b/drivers/isdn/eicon/dsp_defs.h deleted file mode 100644 index 20d3c08f3304..000000000000 --- a/drivers/isdn/eicon/dsp_defs.h +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef DSP_DEFS_H_ -#define DSP_DEFS_H_ - -#ifndef DSPDIDS_H_ -#include "dspdids.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif -/*---------------------------------------------------------------------------*/ - -#ifndef NULL -#define NULL 0 -#endif -#ifndef TRUE -#define TRUE (0 == 0) -#endif -#ifndef FALSE -#define FALSE (0 != 0) -#endif - - -/*---------------------------------------------------------------------------*/ - -#define DSP_MEMORY_TYPE_EXTERNAL_DM 0 -#define DSP_MEMORY_TYPE_EXTERNAL_PM 1 -#define DSP_MEMORY_TYPE_INTERNAL_DM 2 -#define DSP_MEMORY_TYPE_INTERNAL_PM 3 - -#define DSP_DOWNLOAD_FLAG_BOOTABLE 0x0001 -#define DSP_DOWNLOAD_FLAG_2181 0x0002 -#define DSP_DOWNLOAD_FLAG_TIMECRITICAL 0x0004 -#define DSP_DOWNLOAD_FLAG_COMPAND 0x0008 - -#define DSP_MEMORY_BLOCK_COUNT 16 - -#define DSP_SEGMENT_PM_FLAG 0x0001 -#define DSP_SEGMENT_SHARED_FLAG 0x0002 - -#define DSP_SEGMENT_EXTERNAL_DM DSP_MEMORY_TYPE_EXTERNAL_DM -#define DSP_SEGMENT_EXTERNAL_PM DSP_MEMORY_TYPE_EXTERNAL_PM -#define DSP_SEGMENT_INTERNAL_DM DSP_MEMORY_TYPE_INTERNAL_DM -#define DSP_SEGMENT_INTERNAL_PM DSP_MEMORY_TYPE_INTERNAL_PM -#define DSP_SEGMENT_FIRST_RELOCATABLE 4 - -#define DSP_DATA_BLOCK_PM_FLAG 0x0001 -#define DSP_DATA_BLOCK_DWORD_FLAG 0x0002 -#define DSP_DATA_BLOCK_RESOLVE_FLAG 0x0004 - -#define DSP_RELOC_NONE 0x00 -#define DSP_RELOC_SEGMENT_MASK 0x3f -#define DSP_RELOC_TYPE_MASK 0xc0 -#define DSP_RELOC_TYPE_0 0x00 /* relocation of address in DM word / high part of PM word */ -#define DSP_RELOC_TYPE_1 0x40 /* relocation of address in low part of PM data word */ -#define DSP_RELOC_TYPE_2 0x80 /* relocation of address in standard command */ -#define DSP_RELOC_TYPE_3 0xc0 /* relocation of address in call/jump on flag in */ - -#define DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE 48 -#define DSP_COMBIFILE_FORMAT_VERSION_BCD 0x0100 - -#define DSP_FILE_FORMAT_IDENTIFICATION_SIZE 48 -#define DSP_FILE_FORMAT_VERSION_BCD 0x0100 - - -typedef struct tag_dsp_combifile_header -{ - char format_identification[DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE]; - word format_version_bcd; - word header_size; - word combifile_description_size; - word directory_entries; - word directory_size; - word download_count; - word usage_mask_size; -} t_dsp_combifile_header; - -typedef struct tag_dsp_combifile_directory_entry -{ - word card_type_number; - word file_set_number; -} t_dsp_combifile_directory_entry; - -typedef struct tag_dsp_file_header -{ - char format_identification[DSP_FILE_FORMAT_IDENTIFICATION_SIZE]; - word format_version_bcd; - word download_id; - word download_flags; - word required_processing_power; - word interface_channel_count; - word header_size; - word download_description_size; - word memory_block_table_size; - word memory_block_count; - word segment_table_size; - word segment_count; - word symbol_table_size; - word symbol_count; - word total_data_size_dm; - word data_block_count_dm; - word total_data_size_pm; - word data_block_count_pm; -} t_dsp_file_header; - -typedef struct tag_dsp_memory_block_desc -{ - word alias_memory_block; - word memory_type; - word address; - word size; /* DSP words */ -} t_dsp_memory_block_desc; - -typedef struct tag_dsp_segment_desc -{ - word memory_block; - word attributes; - word base; - word size; - word alignment; /* ==0 -> no other legal start address than base */ -} t_dsp_segment_desc; - -typedef struct tag_dsp_symbol_desc -{ - word symbol_id; - word segment; - word offset; - word size; /* DSP words */ -} t_dsp_symbol_desc; - -typedef struct tag_dsp_data_block_header -{ - word attributes; - word segment; - word offset; - word size; /* DSP words */ -} t_dsp_data_block_header; - -typedef struct tag_dsp_download_desc /* be sure to keep native alignment for MAESTRA's */ -{ - word download_id; - word download_flags; - word required_processing_power; - word interface_channel_count; - word excess_header_size; - word memory_block_count; - word segment_count; - word symbol_count; - word data_block_count_dm; - word data_block_count_pm; - byte *p_excess_header_data; - char *p_download_description; - t_dsp_memory_block_desc *p_memory_block_table; - t_dsp_segment_desc *p_segment_table; - t_dsp_symbol_desc *p_symbol_table; - word *p_data_blocks_dm; - word *p_data_blocks_pm; -} t_dsp_download_desc; - -#define DSP_DOWNLOAD_INDEX_KERNEL 0 -#define DSP30TX_DOWNLOAD_INDEX_KERNEL 1 -#define DSP30RX_DOWNLOAD_INDEX_KERNEL 2 -#define DSP_MAX_DOWNLOAD_COUNT 35 - - -#define DSP_DOWNLOAD_MAX_SEGMENTS 16 - -#define DSP_UDATA_REQUEST_RECONFIGURE 0 -/* -parameters: - <word> reconfigure delay (in 8kHz samples) - <word> reconfigure code - <byte> reconfigure hdlc preamble flags -*/ - -#define DSP_RECONFIGURE_TX_FLAG 0x8000 -#define DSP_RECONFIGURE_SHORT_TRAIN_FLAG 0x4000 -#define DSP_RECONFIGURE_ECHO_PROTECT_FLAG 0x2000 -#define DSP_RECONFIGURE_HDLC_FLAG 0x1000 -#define DSP_RECONFIGURE_SYNC_FLAG 0x0800 -#define DSP_RECONFIGURE_PROTOCOL_MASK 0x00ff -#define DSP_RECONFIGURE_IDLE 0 -#define DSP_RECONFIGURE_V25 1 -#define DSP_RECONFIGURE_V21_CH2 2 -#define DSP_RECONFIGURE_V27_2400 3 -#define DSP_RECONFIGURE_V27_4800 4 -#define DSP_RECONFIGURE_V29_7200 5 -#define DSP_RECONFIGURE_V29_9600 6 -#define DSP_RECONFIGURE_V33_12000 7 -#define DSP_RECONFIGURE_V33_14400 8 -#define DSP_RECONFIGURE_V17_7200 9 -#define DSP_RECONFIGURE_V17_9600 10 -#define DSP_RECONFIGURE_V17_12000 11 -#define DSP_RECONFIGURE_V17_14400 12 - -/* -data indications if transparent framer - <byte> data 0 - <byte> data 1 - ... - -data indications if HDLC framer - <byte> data 0 - <byte> data 1 - ... - <byte> CRC 0 - <byte> CRC 1 - <byte> preamble flags -*/ - -#define DSP_UDATA_INDICATION_SYNC 0 -/* -returns: - <word> time of sync (sampled from counter at 8kHz) -*/ - -#define DSP_UDATA_INDICATION_DCD_OFF 1 -/* -returns: - <word> time of DCD off (sampled from counter at 8kHz) -*/ - -#define DSP_UDATA_INDICATION_DCD_ON 2 -/* -returns: - <word> time of DCD on (sampled from counter at 8kHz) - <byte> connected norm - <word> connected options - <dword> connected speed (bit/s) -*/ - -#define DSP_UDATA_INDICATION_CTS_OFF 3 -/* -returns: - <word> time of CTS off (sampled from counter at 8kHz) -*/ - -#define DSP_UDATA_INDICATION_CTS_ON 4 -/* -returns: - <word> time of CTS on (sampled from counter at 8kHz) - <byte> connected norm - <word> connected options - <dword> connected speed (bit/s) -*/ - -#define DSP_CONNECTED_NORM_UNSPECIFIED 0 -#define DSP_CONNECTED_NORM_V21 1 -#define DSP_CONNECTED_NORM_V23 2 -#define DSP_CONNECTED_NORM_V22 3 -#define DSP_CONNECTED_NORM_V22_BIS 4 -#define DSP_CONNECTED_NORM_V32_BIS 5 -#define DSP_CONNECTED_NORM_V34 6 -#define DSP_CONNECTED_NORM_V8 7 -#define DSP_CONNECTED_NORM_BELL_212A 8 -#define DSP_CONNECTED_NORM_BELL_103 9 -#define DSP_CONNECTED_NORM_V29_LEASED_LINE 10 -#define DSP_CONNECTED_NORM_V33_LEASED_LINE 11 -#define DSP_CONNECTED_NORM_TFAST 12 -#define DSP_CONNECTED_NORM_V21_CH2 13 -#define DSP_CONNECTED_NORM_V27_TER 14 -#define DSP_CONNECTED_NORM_V29 15 -#define DSP_CONNECTED_NORM_V33 16 -#define DSP_CONNECTED_NORM_V17 17 - -#define DSP_CONNECTED_OPTION_TRELLIS 0x0001 - - -/*---------------------------------------------------------------------------*/ -#ifdef __cplusplus -} -#endif - -#endif - -/*---------------------------------------------------------------------------*/ diff --git a/drivers/isdn/eicon/dspdids.h b/drivers/isdn/eicon/dspdids.h deleted file mode 100644 index 000a8ba1b2fb..000000000000 --- a/drivers/isdn/eicon/dspdids.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef DSPDIDS_H_ -#define DSPDIDS_H_ - - -/*---------------------------------------------------------------------------*/ - -#define DSP_DID_INVALID 0 -#define DSP_DID_DIVA 1 -#define DSP_DID_DIVA_PRO 2 -#define DSP_DID_DIVA_PRO_20 3 -#define DSP_DID_DIVA_PRO_PCCARD 4 -#define DSP_DID_DIVA_SERVER_BRI_1M 5 -#define DSP_DID_DIVA_SERVER_BRI_2M 6 -#define DSP_DID_DIVA_SERVER_PRI_2M_TX 7 -#define DSP_DID_DIVA_SERVER_PRI_2M_RX 8 -#define DSP_DID_DIVA_SERVER_PRI_30M 9 -#define DSP_DID_TASK_HSCX 100 -#define DSP_DID_TASK_HSCX_PRI_2M_TX 101 -#define DSP_DID_TASK_HSCX_PRI_2M_RX 102 -#define DSP_DID_TASK_V110KRNL 200 -#define DSP_DID_OVERLAY_V1100 201 -#define DSP_DID_OVERLAY_V1101 202 -#define DSP_DID_OVERLAY_V1102 203 -#define DSP_DID_OVERLAY_V1103 204 -#define DSP_DID_OVERLAY_V1104 205 -#define DSP_DID_OVERLAY_V1105 206 -#define DSP_DID_OVERLAY_V1106 207 -#define DSP_DID_OVERLAY_V1107 208 -#define DSP_DID_OVERLAY_V1108 209 -#define DSP_DID_OVERLAY_V1109 210 -#define DSP_DID_TASK_V110_PRI_2M_TX 220 -#define DSP_DID_TASK_V110_PRI_2M_RX 221 -#define DSP_DID_TASK_MODEM 300 -#define DSP_DID_TASK_FAX05 400 -#define DSP_DID_TASK_VOICE 500 -#define DSP_DID_TASK_TIKRNL81 600 -#define DSP_DID_OVERLAY_DIAL 601 -#define DSP_DID_OVERLAY_V22 602 -#define DSP_DID_OVERLAY_V32 603 -#define DSP_DID_OVERLAY_FSK 604 -#define DSP_DID_OVERLAY_FAX 605 -#define DSP_DID_OVERLAY_VXX 606 -#define DSP_DID_OVERLAY_V8 607 -#define DSP_DID_OVERLAY_INFO 608 -#define DSP_DID_OVERLAY_V34 609 -#define DSP_DID_OVERLAY_DFX 610 -#define DSP_DID_PARTIAL_OVERLAY_DIAL 611 -#define DSP_DID_PARTIAL_OVERLAY_FSK 612 -#define DSP_DID_PARTIAL_OVERLAY_FAX 613 -#define DSP_DID_TASK_TIKRNL05 700 - - -/*---------------------------------------------------------------------------*/ - -#endif - -/*---------------------------------------------------------------------------*/ diff --git a/drivers/isdn/eicon/eicon.h b/drivers/isdn/eicon/eicon.h deleted file mode 100644 index 4fe92f63de07..000000000000 --- a/drivers/isdn/eicon/eicon.h +++ /dev/null @@ -1,386 +0,0 @@ -/* $Id: eicon.h,v 1.1.4.1.2.3 2002/10/01 11:29:13 armin Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * - * Copyright 1998 by Fritz Elfert (fritz@isdn4linux.de) - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef eicon_h -#define eicon_h - -#include <linux/interrupt.h> - -#define EICON_IOCTL_SETMMIO 0 -#define EICON_IOCTL_GETMMIO 1 -#define EICON_IOCTL_SETIRQ 2 -#define EICON_IOCTL_GETIRQ 3 -#define EICON_IOCTL_LOADBOOT 4 -#define EICON_IOCTL_ADDCARD 5 -#define EICON_IOCTL_GETTYPE 6 -#define EICON_IOCTL_LOADPCI 7 -#define EICON_IOCTL_LOADISA 8 -#define EICON_IOCTL_GETVER 9 -#define EICON_IOCTL_GETXLOG 10 - -#define EICON_IOCTL_MANIF 90 - -#define EICON_IOCTL_FREEIT 97 -#define EICON_IOCTL_TEST 98 -#define EICON_IOCTL_DEBUGVAR 99 - -#define EICON_IOCTL_DIA_OFFSET 100 - -/* Bus types */ -#define EICON_BUS_ISA 1 -#define EICON_BUS_MCA 2 -#define EICON_BUS_PCI 3 - -/* Constants for describing Card-Type */ -#define EICON_CTYPE_S 0 -#define EICON_CTYPE_SX 1 -#define EICON_CTYPE_SCOM 2 -#define EICON_CTYPE_QUADRO 3 -#define EICON_CTYPE_S2M 4 -#define EICON_CTYPE_MAESTRA 5 -#define EICON_CTYPE_MAESTRAQ 6 -#define EICON_CTYPE_MAESTRAQ_U 7 -#define EICON_CTYPE_MAESTRAP 8 -#define EICON_CTYPE_ISABRI 0x10 -#define EICON_CTYPE_ISAPRI 0x20 -#define EICON_CTYPE_MASK 0x0f -#define EICON_CTYPE_QUADRO_NR(n) (n<<4) - -#define MAX_HEADER_LEN 10 - -#define MAX_STATUS_BUFFER 150 - -/* Struct for adding new cards */ -typedef struct eicon_cdef { - int membase; - int irq; - char id[10]; -} eicon_cdef; - -#define EICON_ISA_BOOT_MEMCHK 1 -#define EICON_ISA_BOOT_NORMAL 2 - -/* Struct for downloading protocol via ioctl for ISA cards */ -/* same struct for downloading protocol via ioctl for MCA cards */ -typedef struct { - /* start-up parameters */ - unsigned char tei; - unsigned char nt2; - unsigned char skip1; - unsigned char WatchDog; - unsigned char Permanent; - unsigned char XInterface; - unsigned char StableL2; - unsigned char NoOrderCheck; - unsigned char HandsetType; - unsigned char skip2; - unsigned char LowChannel; - unsigned char ProtVersion; - unsigned char Crc4; - unsigned char Loopback; - unsigned char oad[32]; - unsigned char osa[32]; - unsigned char spid[32]; - unsigned char boot_opt; - unsigned long bootstrap_len; - unsigned long firmware_len; - unsigned char code[1]; /* Rest (bootstrap- and firmware code) will be allocated */ -} eicon_isa_codebuf; - -/* Data for downloading protocol via ioctl */ -typedef union { - eicon_isa_codebuf isa; - eicon_isa_codebuf mca; -} eicon_codebuf; - -/* Data for Management interface */ -typedef struct { - int count; - int pos; - int length[50]; - unsigned char data[700]; -} eicon_manifbuf; - -#define TRACE_OK (1) - -#ifdef __KERNEL__ - -/* Kernel includes */ -#include <linux/config.h> -#include <linux/sched.h> -#include <linux/string.h> -#include <linux/workqueue.h> -#include <linux/interrupt.h> -#include <linux/skbuff.h> -#include <linux/errno.h> -#include <linux/fs.h> -#include <linux/major.h> -#include <asm/io.h> -#include <linux/kernel.h> -#include <linux/signal.h> -#include <linux/slab.h> -#include <linux/mm.h> -#include <linux/mman.h> -#include <linux/ioport.h> -#include <linux/timer.h> -#include <linux/wait.h> -#include <linux/delay.h> -#include <linux/ctype.h> -#include <linux/pci.h> - -#include <linux/isdn.h> -#include <linux/isdnif.h> - - -typedef struct { - __u16 length __attribute__ ((packed)); /* length of data/parameter field */ - __u8 P[1]; /* data/parameter field */ -} eicon_PBUFFER; - -#include "eicon_isa.h" - -#include "idi.h" - -typedef struct { - __u16 NextReq __attribute__ ((packed)); /* pointer to next Req Buffer */ - __u16 NextRc __attribute__ ((packed)); /* pointer to next Rc Buffer */ - __u16 NextInd __attribute__ ((packed)); /* pointer to next Ind Buffer */ - __u8 ReqInput __attribute__ ((packed)); /* number of Req Buffers sent */ - __u8 ReqOutput __attribute__ ((packed)); /* number of Req Buffers returned */ - __u8 ReqReserved __attribute__ ((packed));/*number of Req Buffers reserved */ - __u8 Int __attribute__ ((packed)); /* ISDN-P interrupt */ - __u8 XLock __attribute__ ((packed)); /* Lock field for arbitration */ - __u8 RcOutput __attribute__ ((packed)); /* number of Rc buffers received */ - __u8 IndOutput __attribute__ ((packed)); /* number of Ind buffers received */ - __u8 IMask __attribute__ ((packed)); /* Interrupt Mask Flag */ - __u8 Reserved1[2] __attribute__ ((packed)); /* reserved field, do not use */ - __u8 ReadyInt __attribute__ ((packed)); /* request field for ready int */ - __u8 Reserved2[12] __attribute__ ((packed)); /* reserved field, do not use */ - __u8 InterfaceType __attribute__ ((packed)); /* interface type 1=16K */ - __u16 Signature __attribute__ ((packed)); /* ISDN-P initialized ind */ - __u8 B[1]; /* buffer space for Req,Ind and Rc */ -} eicon_pr_ram; - -/* Macro for delay via schedule() */ -#define SLEEP(j) { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - schedule_timeout(j); \ -} - -typedef struct { - __u8 Req; /* pending request */ - __u8 Rc; /* return code received */ - __u8 Ind; /* indication received */ - __u8 ReqCh; /* channel of current Req */ - __u8 RcCh; /* channel of current Rc */ - __u8 IndCh; /* channel of current Ind */ - __u8 D3Id; /* ID used by this entity */ - __u8 B2Id; /* ID used by this entity */ - __u8 GlobalId; /* reserved field */ - __u8 XNum; /* number of X-buffers */ - __u8 RNum; /* number of R-buffers */ - struct sk_buff_head X; /* X-buffer queue */ - struct sk_buff_head R; /* R-buffer queue */ - __u8 RNR; /* receive not ready flag */ - __u8 complete; /* receive complete status */ - __u8 busy; /* busy flag */ - __u16 ref; /* saved reference */ -} entity; - -#define FAX_MAX_SCANLINE 256 - -typedef struct { - __u8 PrevObject; - __u8 NextObject; - __u8 abLine[FAX_MAX_SCANLINE]; - __u8 abFrame[FAX_MAX_SCANLINE]; - unsigned int LineLen; - unsigned int LineDataLen; - __u32 LineData; - unsigned int NullBytesPos; - __u8 NullByteExist; - int PageCount; - __u8 Dle; - __u8 Eop; -} eicon_ch_fax_buf; - -typedef struct { - int No; /* Channel Number */ - unsigned short fsm_state; /* Current D-Channel state */ - unsigned short statectrl; /* State controling bits */ - unsigned short eazmask; /* EAZ-Mask for this Channel */ - int queued; /* User-Data Bytes in TX queue */ - int pqueued; /* User-Data Packets in TX queue */ - int waitq; /* User-Data Bytes in wait queue */ - int waitpq; /* User-Data Bytes in packet queue */ - struct sk_buff *tskb1; /* temp skb 1 */ - struct sk_buff *tskb2; /* temp skb 2 */ - unsigned char l2prot; /* Layer 2 protocol */ - unsigned char l3prot; /* Layer 3 protocol */ -#ifdef CONFIG_ISDN_TTY_FAX - T30_s *fax; /* pointer to fax data in LL */ - eicon_ch_fax_buf fax2; /* fax related struct */ -#endif - entity e; /* Native Entity */ - ENTITY de; /* Divas D Entity */ - ENTITY be; /* Divas B Entity */ - char cpn[32]; /* remember cpn */ - char oad[32]; /* remember oad */ - char dsa[32]; /* remember dsa */ - char osa[32]; /* remember osa */ - unsigned char cause[2]; /* Last Cause */ - unsigned char si1; - unsigned char si2; - unsigned char plan; - unsigned char screen; -} eicon_chan; - -typedef struct { - eicon_chan *ptr; -} eicon_chan_ptr; - -#include "eicon_pci.h" - -#define EICON_FLAGS_RUNNING 1 /* Cards driver activated */ -#define EICON_FLAGS_PVALID 2 /* Cards port is valid */ -#define EICON_FLAGS_IVALID 4 /* Cards irq is valid */ -#define EICON_FLAGS_MVALID 8 /* Cards membase is valid */ -#define EICON_FLAGS_LOADED 8 /* Firmware loaded */ - -/* D-Channel states */ -#define EICON_STATE_NULL 0 -#define EICON_STATE_ICALL 1 -#define EICON_STATE_OCALL 2 -#define EICON_STATE_IWAIT 3 -#define EICON_STATE_OWAIT 4 -#define EICON_STATE_IBWAIT 5 -#define EICON_STATE_OBWAIT 6 -#define EICON_STATE_BWAIT 7 -#define EICON_STATE_BHWAIT 8 -#define EICON_STATE_BHWAIT2 9 -#define EICON_STATE_DHWAIT 10 -#define EICON_STATE_DHWAIT2 11 -#define EICON_STATE_BSETUP 12 -#define EICON_STATE_ACTIVE 13 -#define EICON_STATE_ICALLW 14 -#define EICON_STATE_LISTEN 15 -#define EICON_STATE_WMCONN 16 - -#define EICON_MAX_QUEUE 2138 - -typedef union { - eicon_isa_card isa; - eicon_pci_card pci; - eicon_isa_card mca; -} eicon_hwif; - -typedef struct { - __u8 ret; - __u8 id; - __u8 ch; -} eicon_ack; - -typedef struct { - __u8 code; - __u8 id; - __u8 ch; -} eicon_req; - -typedef struct { - __u8 ret; - __u8 id; - __u8 ch; - __u8 more; -} eicon_indhdr; - -/* - * Per card driver data - */ -typedef struct eicon_card { - eicon_hwif hwif; /* Hardware dependent interface */ - DESCRIPTOR *d; /* IDI Descriptor */ - u_char ptype; /* Protocol type (1TR6 or Euro) */ - u_char bus; /* Bustype (ISA, MCA, PCI) */ - u_char type; /* Cardtype (EICON_CTYPE_...) */ - struct eicon_card *qnext; /* Pointer to next quadro adapter */ - int Feature; /* Protocol Feature Value */ - struct eicon_card *next; /* Pointer to next device struct */ - int myid; /* Driver-Nr. assigned by linklevel */ - unsigned long flags; /* Statusflags */ - struct sk_buff_head rcvq; /* Receive-Message queue */ - struct sk_buff_head sndq; /* Send-Message queue */ - struct sk_buff_head rackq; /* Req-Ack-Message queue */ - struct sk_buff_head sackq; /* Data-Ack-Message queue */ - struct sk_buff_head statq; /* Status-Message queue */ - int statq_entries; - struct tasklet_struct snd_tq; /* Task struct for xmit bh */ - struct tasklet_struct rcv_tq; /* Task struct for rcv bh */ - struct tasklet_struct ack_tq; /* Task struct for ack bh */ - eicon_chan* IdTable[256]; /* Table to find entity */ - __u16 ref_in; - __u16 ref_out; - int nchannels; /* Number of B-Channels */ - int ReadyInt; /* Ready Interrupt */ - eicon_chan *bch; /* B-Channel status/control */ - DBUFFER *dbuf; /* Dbuffer for Diva Server */ - BUFFERS *sbuf; /* Buffer for Diva Server */ - char *sbufp; /* Data Buffer for Diva Server */ - isdn_if interface; /* Interface to upper layer */ - char regname[35]; /* Drivers card name */ -#ifdef CONFIG_MCA - int mca_slot; /* # of cards MCA slot */ - int mca_io; /* MCA cards IO port */ -#endif /* CONFIG_MCA */ -} eicon_card; - -#include "eicon_idi.h" - -extern eicon_card *cards; -extern char *eicon_ctype_name[]; - - -extern __inline__ void eicon_schedule_tx(eicon_card *card) -{ - tasklet_schedule(&card->snd_tq); -} - -extern __inline__ void eicon_schedule_rx(eicon_card *card) -{ - tasklet_schedule(&card->rcv_tq); -} - -extern __inline__ void eicon_schedule_ack(eicon_card *card) -{ - tasklet_schedule(&card->ack_tq); -} - -extern int eicon_addcard(int, int, int, char *, int); -extern void eicon_io_transmit(eicon_card *card); -extern irqreturn_t eicon_irq(int irq, void *dev_id, struct pt_regs *regs); -extern void eicon_io_rcv_dispatch(eicon_card *ccard); -extern void eicon_io_ack_dispatch(eicon_card *ccard); -#ifdef CONFIG_MCA -extern int eicon_mca_find_card(int, int, int, char *); -extern int eicon_mca_probe(int, int, int, int, char *); -extern int eicon_info(char *, int , void *); -#endif /* CONFIG_MCA */ - -extern ulong DebugVar; -extern void eicon_log(eicon_card * card, int level, const char *fmt, ...); -extern void eicon_putstatus(eicon_card * card, char * buf); - -extern spinlock_t eicon_lock; - -#endif /* __KERNEL__ */ - -#endif /* eicon_h */ diff --git a/drivers/isdn/eicon/eicon_dsp.h b/drivers/isdn/eicon/eicon_dsp.h deleted file mode 100644 index 299edcaab27b..000000000000 --- a/drivers/isdn/eicon/eicon_dsp.h +++ /dev/null @@ -1,285 +0,0 @@ -/* $Id: eicon_dsp.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $ - * - * ISDN lowlevel-module for Eicon active cards. - * DSP definitions - * - * Copyright 1999,2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef DSP_H -#define DSP_H - -#include "dsp_defs.h" - - -#define DSP_UDATA_REQUEST_SWITCH_FRAMER 1 -/* -parameters: - <byte> transmit framer type - <byte> receive framer type -*/ - -#define DSP_REQUEST_SWITCH_FRAMER_HDLC 0 -#define DSP_REQUEST_SWITCH_FRAMER_TRANSPARENT 1 -#define DSP_REQUEST_SWITCH_FRAMER_ASYNC 2 - - -#define DSP_UDATA_REQUEST_CLEARDOWN 2 -/* -parameters: - - none - -*/ - - -#define DSP_UDATA_REQUEST_TX_CONFIRMATION_ON 3 -/* -parameters: - - none - -*/ - - -#define DSP_UDATA_REQUEST_TX_CONFIRMATION_OFF 4 -/* -parameters: - - none - -*/ - -typedef struct eicon_dsp_ind { - __u16 time __attribute__ ((packed)); - __u8 norm __attribute__ ((packed)); - __u16 options __attribute__ ((packed)); - __u32 speed __attribute__ ((packed)); - __u16 delay __attribute__ ((packed)); - __u32 txspeed __attribute__ ((packed)); - __u32 rxspeed __attribute__ ((packed)); -} eicon_dsp_ind; - -#define DSP_CONNECTED_OPTION_V42_TRANS 0x0002 -#define DSP_CONNECTED_OPTION_V42_LAPM 0x0004 -#define DSP_CONNECTED_OPTION_SHORT_TRAIN 0x0008 -#define DSP_CONNECTED_OPTION_TALKER_ECHO_PROTECT 0x0010 - -#define DSP_UDATA_INDICATION_DISCONNECT 5 -/* -returns: - <byte> cause -*/ - -#define DSP_DISCONNECT_CAUSE_NONE 0x00 -#define DSP_DISCONNECT_CAUSE_BUSY_TONE 0x01 -#define DSP_DISCONNECT_CAUSE_CONGESTION_TONE 0x02 -#define DSP_DISCONNECT_CAUSE_INCOMPATIBILITY 0x03 -#define DSP_DISCONNECT_CAUSE_CLEARDOWN 0x04 -#define DSP_DISCONNECT_CAUSE_TRAINING_TIMEOUT 0x05 - -#define DSP_UDATA_INDICATION_TX_CONFIRMATION 6 -/* -returns: - <word> confirmation number -*/ - - -#define DSP_UDATA_REQUEST_SEND_DTMF_DIGITS 16 -/* -parameters: - <word> tone duration (ms) - <word> gap duration (ms) - <byte> digit 0 tone code - ... - <byte> digit n tone code -*/ - -#define DSP_SEND_DTMF_DIGITS_HEADER_LENGTH 5 - -#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_697_HZ 0x00 -#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_770_HZ 0x01 -#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_852_HZ 0x02 -#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_941_HZ 0x03 -#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_MASK 0x03 -#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1209_HZ 0x00 -#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1336_HZ 0x04 -#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1477_HZ 0x08 -#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1633_HZ 0x0c -#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_MASK 0x0c - -#define DSP_DTMF_DIGIT_TONE_CODE_0 0x07 -#define DSP_DTMF_DIGIT_TONE_CODE_1 0x00 -#define DSP_DTMF_DIGIT_TONE_CODE_2 0x04 -#define DSP_DTMF_DIGIT_TONE_CODE_3 0x08 -#define DSP_DTMF_DIGIT_TONE_CODE_4 0x01 -#define DSP_DTMF_DIGIT_TONE_CODE_5 0x05 -#define DSP_DTMF_DIGIT_TONE_CODE_6 0x09 -#define DSP_DTMF_DIGIT_TONE_CODE_7 0x02 -#define DSP_DTMF_DIGIT_TONE_CODE_8 0x06 -#define DSP_DTMF_DIGIT_TONE_CODE_9 0x0a -#define DSP_DTMF_DIGIT_TONE_CODE_STAR 0x03 -#define DSP_DTMF_DIGIT_TONE_CODE_HASHMARK 0x0b -#define DSP_DTMF_DIGIT_TONE_CODE_A 0x0c -#define DSP_DTMF_DIGIT_TONE_CODE_B 0x0d -#define DSP_DTMF_DIGIT_TONE_CODE_C 0x0e -#define DSP_DTMF_DIGIT_TONE_CODE_D 0x0f - - -#define DSP_UDATA_INDICATION_DTMF_DIGITS_SENT 16 -/* -returns: - - none - - One indication will be sent for every request. -*/ - - -#define DSP_UDATA_REQUEST_ENABLE_DTMF_RECEIVER 17 -/* -parameters: - <word> tone duration (ms) - <word> gap duration (ms) -*/ -typedef struct enable_dtmf_s { - __u16 tone; - __u16 gap; -} enable_dtmf_s; - -#define DSP_UDATA_REQUEST_DISABLE_DTMF_RECEIVER 18 -/* -parameters: - - none - -*/ - -#define DSP_UDATA_INDICATION_DTMF_DIGITS_RECEIVED 17 -/* -returns: - <byte> digit 0 tone code - ... - <byte> digit n tone code -*/ - -#define DSP_DTMF_DIGITS_RECEIVED_HEADER_LENGTH 1 - - -#define DSP_UDATA_INDICATION_MODEM_CALLING_TONE 18 -/* -returns: - - none - -*/ - -#define DSP_UDATA_INDICATION_FAX_CALLING_TONE 19 -/* -returns: - - none - -*/ - -#define DSP_UDATA_INDICATION_ANSWER_TONE 20 -/* -returns: - - none - -*/ - -/* ============= FAX ================ */ - -#define EICON_FAXID_LEN 20 - -typedef struct eicon_t30_s { - __u8 code; - __u8 rate; - __u8 resolution; - __u8 format; - __u8 pages_low; - __u8 pages_high; - __u8 atf; - __u8 control_bits_low; - __u8 control_bits_high; - __u8 feature_bits_low; - __u8 feature_bits_high; - __u8 universal_5; - __u8 universal_6; - __u8 universal_7; - __u8 station_id_len; - __u8 head_line_len; - __u8 station_id[EICON_FAXID_LEN]; -/* __u8 head_line[]; */ -} eicon_t30_s; - - /* EDATA transmit messages */ -#define EDATA_T30_DIS 0x01 -#define EDATA_T30_FTT 0x02 -#define EDATA_T30_MCF 0x03 - - /* EDATA receive messages */ -#define EDATA_T30_DCS 0x81 -#define EDATA_T30_TRAIN_OK 0x82 -#define EDATA_T30_EOP 0x83 -#define EDATA_T30_MPS 0x84 -#define EDATA_T30_EOM 0x85 -#define EDATA_T30_DTC 0x86 - -#define T30_FORMAT_SFF 0 -#define T30_FORMAT_ASCII 1 -#define T30_FORMAT_COUNT 2 - -#define T30_CONTROL_BIT_DISABLE_FINE 0x0001 -#define T30_CONTROL_BIT_ENABLE_ECM 0x0002 -#define T30_CONTROL_BIT_ECM_64_BYTES 0x0004 -#define T30_CONTROL_BIT_ENABLE_2D_CODING 0x0008 -#define T30_CONTROL_BIT_ENABLE_T6_CODING 0x0010 -#define T30_CONTROL_BIT_ENABLE_UNCOMPR 0x0020 -#define T30_CONTROL_BIT_ACCEPT_POLLING 0x0040 -#define T30_CONTROL_BIT_REQUEST_POLLING 0x0080 -#define T30_CONTROL_BIT_MORE_DOCUMENTS 0x0100 - -#define T30_CONTROL_BIT_ALL_FEATURES\ - (T30_CONTROL_BIT_ENABLE_ECM | T30_CONTROL_BIT_ENABLE_2D_CODING |\ - T30_CONTROL_BIT_ENABLE_T6_CODING | T30_CONTROL_BIT_ENABLE_UNCOMPR) - -#define T30_FEATURE_BIT_FINE 0x0001 -#define T30_FEATURE_BIT_ECM 0x0002 -#define T30_FEATURE_BIT_ECM_64_BYTES 0x0004 -#define T30_FEATURE_BIT_2D_CODING 0x0008 -#define T30_FEATURE_BIT_T6_CODING 0x0010 -#define T30_FEATURE_BIT_UNCOMPR_ENABLED 0x0020 -#define T30_FEATURE_BIT_POLLING 0x0040 - -#define FAX_OBJECT_DOCU 1 -#define FAX_OBJECT_PAGE 2 -#define FAX_OBJECT_LINE 3 - -#define T4_EOL 0x800 -#define T4_EOL_BITSIZE 12 -#define T4_EOL_DWORD (T4_EOL << (32 - T4_EOL_BITSIZE)) -#define T4_EOL_MASK_DWORD ((__u32) -1 << (32 - T4_EOL_BITSIZE)) - -#define SFF_LEN_FLD_SIZE 3 - -#define _DLE_ 0x10 -#define _ETX_ 0x03 - -typedef struct eicon_sff_dochead { - __u32 id __attribute__ ((packed)); - __u8 version __attribute__ ((packed)); - __u8 reserved1 __attribute__ ((packed)); - __u16 userinfo __attribute__ ((packed)); - __u16 pagecount __attribute__ ((packed)); - __u16 off1pagehead __attribute__ ((packed)); - __u32 offnpagehead __attribute__ ((packed)); - __u32 offdocend __attribute__ ((packed)); -} eicon_sff_dochead; - -typedef struct eicon_sff_pagehead { - __u8 pageheadid __attribute__ ((packed)); - __u8 pageheadlen __attribute__ ((packed)); - __u8 resvert __attribute__ ((packed)); - __u8 reshoriz __attribute__ ((packed)); - __u8 coding __attribute__ ((packed)); - __u8 reserved2 __attribute__ ((packed)); - __u16 linelength __attribute__ ((packed)); - __u16 pagelength __attribute__ ((packed)); - __u32 offprevpage __attribute__ ((packed)); - __u32 offnextpage __attribute__ ((packed)); -} eicon_sff_pagehead; - -#endif /* DSP_H */ - diff --git a/drivers/isdn/eicon/eicon_idi.c b/drivers/isdn/eicon/eicon_idi.c deleted file mode 100644 index 4bfce7f82814..000000000000 --- a/drivers/isdn/eicon/eicon_idi.c +++ /dev/null @@ -1,3197 +0,0 @@ -/* $Id: eicon_idi.c,v 1.1.4.1.2.4 2002/10/01 11:29:13 armin Exp $ - * - * ISDN lowlevel-module for Eicon active cards. - * IDI interface - * - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * Thanks to Deutsche Mailbox Saar-Lor-Lux GmbH - * for sponsoring and testing fax - * capabilities with Diva Server cards. - * (dor@deutschemailbox.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/config.h> -#include "eicon.h" -#include "eicon_idi.h" -#include "eicon_dsp.h" -#include "uxio.h" - -#undef EICON_FULL_SERVICE_OKTETT - -char *eicon_idi_revision = "$Revision: 1.1.4.1.2.4 $"; - -eicon_manifbuf *manbuf; - -int eicon_idi_manage_assign(eicon_card *card); -int eicon_idi_manage_remove(eicon_card *card); -int idi_fill_in_T30(eicon_chan *chan, unsigned char *buffer); - -int -idi_assign_req(eicon_REQ *reqbuf, int signet, eicon_chan *chan) -{ - int l = 0; - int tmp; - - tmp = 0; - if (!signet) { - /* Signal Layer */ - reqbuf->XBuffer.P[l++] = CAI; - reqbuf->XBuffer.P[l++] = 1; - reqbuf->XBuffer.P[l++] = 0; - reqbuf->XBuffer.P[l++] = KEY; - reqbuf->XBuffer.P[l++] = 3; - reqbuf->XBuffer.P[l++] = 'I'; - reqbuf->XBuffer.P[l++] = '4'; - reqbuf->XBuffer.P[l++] = 'L'; - reqbuf->XBuffer.P[l++] = SHIFT|6; - reqbuf->XBuffer.P[l++] = SIN; - reqbuf->XBuffer.P[l++] = 2; - reqbuf->XBuffer.P[l++] = 0; - reqbuf->XBuffer.P[l++] = 0; - reqbuf->XBuffer.P[l++] = 0; /* end */ - reqbuf->Req = ASSIGN; - reqbuf->ReqCh = 0; - reqbuf->ReqId = DSIG_ID; - reqbuf->XBuffer.length = l; - reqbuf->Reference = 0; /* Sig Entity */ - } - else { - /* Network Layer */ - reqbuf->XBuffer.P[l++] = CAI; - reqbuf->XBuffer.P[l++] = 1; - reqbuf->XBuffer.P[l++] = chan->e.D3Id; - reqbuf->XBuffer.P[l++] = LLC; - reqbuf->XBuffer.P[l++] = 2; - switch(chan->l2prot) { - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: - case ISDN_PROTO_L2_TRANS: - reqbuf->XBuffer.P[l++] = 2; /* transparent */ - break; - case ISDN_PROTO_L2_X75I: - case ISDN_PROTO_L2_X75UI: - case ISDN_PROTO_L2_X75BUI: - reqbuf->XBuffer.P[l++] = 5; /* X.75 */ - break; - case ISDN_PROTO_L2_MODEM: - if (chan->fsm_state == EICON_STATE_IWAIT) - reqbuf->XBuffer.P[l++] = 9; /* V.42 incoming */ - else - reqbuf->XBuffer.P[l++] = 10; /* V.42 */ - break; - case ISDN_PROTO_L2_HDLC: - case ISDN_PROTO_L2_FAX: - if (chan->fsm_state == EICON_STATE_IWAIT) - reqbuf->XBuffer.P[l++] = 3; /* autoconnect on incoming */ - else - reqbuf->XBuffer.P[l++] = 2; /* transparent */ - break; - default: - reqbuf->XBuffer.P[l++] = 1; - } - switch(chan->l3prot) { - case ISDN_PROTO_L3_FCLASS2: -#ifdef CONFIG_ISDN_TTY_FAX - reqbuf->XBuffer.P[l++] = 6; - reqbuf->XBuffer.P[l++] = NLC; - tmp = idi_fill_in_T30(chan, &reqbuf->XBuffer.P[l+1]); - reqbuf->XBuffer.P[l++] = tmp; - l += tmp; - break; -#endif - case ISDN_PROTO_L3_TRANS: - default: - reqbuf->XBuffer.P[l++] = 4; - } - reqbuf->XBuffer.P[l++] = 0; /* end */ - reqbuf->Req = ASSIGN; - reqbuf->ReqCh = 0; - reqbuf->ReqId = NL_ID; - reqbuf->XBuffer.length = l; - reqbuf->Reference = 1; /* Net Entity */ - } - return(0); -} - -int -idi_put_req(eicon_REQ *reqbuf, int rq, int signet, int Ch) -{ - reqbuf->Req = rq; - reqbuf->ReqCh = Ch; - reqbuf->ReqId = 1; - reqbuf->XBuffer.length = 1; - reqbuf->XBuffer.P[0] = 0; - reqbuf->Reference = signet; - return(0); -} - -int -idi_put_suspend_req(eicon_REQ *reqbuf, eicon_chan *chan) -{ - reqbuf->Req = SUSPEND; - reqbuf->ReqCh = 0; - reqbuf->ReqId = 1; - reqbuf->XBuffer.P[0] = CAI; - reqbuf->XBuffer.P[1] = 1; - reqbuf->XBuffer.P[2] = chan->No; - reqbuf->XBuffer.P[3] = 0; - reqbuf->XBuffer.length = 4; - reqbuf->Reference = 0; /* Sig Entity */ - return(0); -} - -int -idi_call_res_req(eicon_REQ *reqbuf, eicon_chan *chan) -{ - int l = 9; - reqbuf->Req = CALL_RES; - reqbuf->ReqCh = 0; - reqbuf->ReqId = 1; - reqbuf->XBuffer.P[0] = CAI; - reqbuf->XBuffer.P[1] = 6; - reqbuf->XBuffer.P[2] = 9; - reqbuf->XBuffer.P[3] = 0; - reqbuf->XBuffer.P[4] = 0; - reqbuf->XBuffer.P[5] = 0; - reqbuf->XBuffer.P[6] = 32; - reqbuf->XBuffer.P[7] = 0; - switch(chan->l2prot) { - case ISDN_PROTO_L2_X75I: - case ISDN_PROTO_L2_X75UI: - case ISDN_PROTO_L2_X75BUI: - case ISDN_PROTO_L2_HDLC: - reqbuf->XBuffer.P[1] = 1; - reqbuf->XBuffer.P[2] = 0x05; - l = 4; - break; - case ISDN_PROTO_L2_V11096: - reqbuf->XBuffer.P[2] = 0x0d; - reqbuf->XBuffer.P[3] = 5; - reqbuf->XBuffer.P[4] = 0; - break; - case ISDN_PROTO_L2_V11019: - reqbuf->XBuffer.P[2] = 0x0d; - reqbuf->XBuffer.P[3] = 6; - reqbuf->XBuffer.P[4] = 0; - break; - case ISDN_PROTO_L2_V11038: - reqbuf->XBuffer.P[2] = 0x0d; - reqbuf->XBuffer.P[3] = 7; - reqbuf->XBuffer.P[4] = 0; - break; - case ISDN_PROTO_L2_MODEM: - reqbuf->XBuffer.P[2] = 0x11; - reqbuf->XBuffer.P[3] = 7; - reqbuf->XBuffer.P[4] = 0; - reqbuf->XBuffer.P[5] = 0; - reqbuf->XBuffer.P[6] = 128; - reqbuf->XBuffer.P[7] = 0; - break; - case ISDN_PROTO_L2_FAX: - reqbuf->XBuffer.P[2] = 0x10; - reqbuf->XBuffer.P[3] = 0; - reqbuf->XBuffer.P[4] = 0; - reqbuf->XBuffer.P[5] = 0; - reqbuf->XBuffer.P[6] = 128; - reqbuf->XBuffer.P[7] = 0; - break; - case ISDN_PROTO_L2_TRANS: - switch(chan->l3prot) { - case ISDN_PROTO_L3_TRANSDSP: - reqbuf->XBuffer.P[2] = 22; /* DTMF, audio events on */ - } - break; - } - reqbuf->XBuffer.P[8] = 0; - reqbuf->XBuffer.length = l; - reqbuf->Reference = 0; /* Sig Entity */ - eicon_log(NULL, 8, "idi_req: Ch%d: Call_Res\n", chan->No); - return(0); -} - -int -idi_do_req(eicon_card *card, eicon_chan *chan, int cmd, int layer) -{ - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan_ptr *chan2; - - skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in do_req()\n", chan->No); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ)); - eicon_log(card, 8, "idi_req: Ch%d: req %x (%s)\n", chan->No, cmd, (layer)?"Net":"Sig"); - if (layer) cmd |= 0x700; - switch(cmd) { - case ASSIGN: - case ASSIGN|0x700: - idi_assign_req(reqbuf, layer, chan); - break; - case REMOVE: - case REMOVE|0x700: - idi_put_req(reqbuf, REMOVE, layer, 0); - break; - case INDICATE_REQ: - idi_put_req(reqbuf, INDICATE_REQ, 0, 0); - break; - case HANGUP: - idi_put_req(reqbuf, HANGUP, 0, 0); - break; - case SUSPEND: - idi_put_suspend_req(reqbuf, chan); - break; - case RESUME: - idi_put_req(reqbuf, RESUME, 0 ,0); - break; - case REJECT: - idi_put_req(reqbuf, REJECT, 0 ,0); - break; - case CALL_ALERT: - idi_put_req(reqbuf, CALL_ALERT, 0, 0); - break; - case CALL_RES: - idi_call_res_req(reqbuf, chan); - break; - case CALL_HOLD: - idi_put_req(reqbuf, CALL_HOLD, 0, 0); - break; - case N_CONNECT|0x700: - idi_put_req(reqbuf, N_CONNECT, 1, 0); - break; - case N_CONNECT_ACK|0x700: - idi_put_req(reqbuf, N_CONNECT_ACK, 1, 0); - break; - case N_DISC|0x700: - idi_put_req(reqbuf, N_DISC, 1, chan->e.IndCh); - break; - case N_DISC_ACK|0x700: - idi_put_req(reqbuf, N_DISC_ACK, 1, chan->e.IndCh); - break; - default: - eicon_log(card, 1, "idi_req: Ch%d: Unknown request\n", chan->No); - dev_kfree_skb(skb); - dev_kfree_skb(skb2); - return(-1); - } - - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - eicon_schedule_tx(card); - return(0); -} - -int -eicon_idi_listen_req(eicon_card *card, eicon_chan *chan) -{ - if ((!card) || (!chan)) - return 1; - - eicon_log(card, 16, "idi_req: Ch%d: Listen_Req eazmask=0x%x\n",chan->No, chan->eazmask); - if (!chan->e.D3Id) { - idi_do_req(card, chan, ASSIGN, 0); - } - if (chan->fsm_state == EICON_STATE_NULL) { - if (!(chan->statectrl & HAVE_CONN_REQ)) { - idi_do_req(card, chan, INDICATE_REQ, 0); - chan->fsm_state = EICON_STATE_LISTEN; - } - } - return(0); -} - -unsigned char -idi_si2bc(int si1, int si2, char *bc, char *hlc) -{ - hlc[0] = 0; - switch(si1) { - case 1: - bc[0] = 0x90; /* 3,1 kHz audio */ - bc[1] = 0x90; /* 64 kbit/s */ - bc[2] = 0xa3; /* G.711 A-law */ -#ifdef EICON_FULL_SERVICE_OKTETT - if (si2 == 1) { - bc[0] = 0x80; /* Speech */ - hlc[0] = 0x02; /* hlc len */ - hlc[1] = 0x91; /* first hic */ - hlc[2] = 0x81; /* Telephony */ - } -#endif - return(3); - case 2: - bc[0] = 0x90; /* 3,1 kHz audio */ - bc[1] = 0x90; /* 64 kbit/s */ - bc[2] = 0xa3; /* G.711 A-law */ -#ifdef EICON_FULL_SERVICE_OKTETT - if (si2 == 2) { - hlc[0] = 0x02; /* hlc len */ - hlc[1] = 0x91; /* first hic */ - hlc[2] = 0x84; /* Fax Gr.2/3 */ - } -#endif - return(3); - case 5: - case 7: - default: - bc[0] = 0x88; - bc[1] = 0x90; - return(2); - } - return (0); -} - -int -idi_hangup(eicon_card *card, eicon_chan *chan) -{ - if ((!card) || (!chan)) - return 1; - - if ((chan->fsm_state == EICON_STATE_ACTIVE) || - (chan->fsm_state == EICON_STATE_WMCONN)) { - if (chan->e.B2Id) idi_do_req(card, chan, N_DISC, 1); - } - if (chan->e.B2Id) idi_do_req(card, chan, REMOVE, 1); - if (chan->fsm_state != EICON_STATE_NULL) { - chan->statectrl |= WAITING_FOR_HANGUP; - idi_do_req(card, chan, HANGUP, 0); - chan->fsm_state = EICON_STATE_NULL; - } - eicon_log(card, 8, "idi_req: Ch%d: Hangup\n", chan->No); -#ifdef CONFIG_ISDN_TTY_FAX - chan->fax = 0; -#endif - return(0); -} - -int -capipmsg(eicon_card *card, eicon_chan *chan, capi_msg *cm) -{ - if ((cm->para[0] != 3) || (cm->para[1] != 0)) - return -1; - if (cm->para[2] < 3) - return -1; - if (cm->para[4] != 0) - return -1; - switch(cm->para[3]) { - case 4: /* Suspend */ - eicon_log(card, 8, "idi_req: Ch%d: Call Suspend\n", chan->No); - if (cm->para[5]) { - idi_do_req(card, chan, SUSPEND, 0); - } else { - idi_do_req(card, chan, CALL_HOLD, 0); - } - break; - case 5: /* Resume */ - eicon_log(card, 8, "idi_req: Ch%d: Call Resume\n", chan->No); - idi_do_req(card, chan, RESUME, 0); - break; - } - return 0; -} - -int -idi_connect_res(eicon_card *card, eicon_chan *chan) -{ - if ((!card) || (!chan)) - return 1; - - chan->fsm_state = EICON_STATE_IWAIT; - - /* check if old NetID has been removed */ - if (chan->e.B2Id) { - eicon_log(card, 1, "eicon: Ch%d: old net_id %x still exist, removing.\n", - chan->No, chan->e.B2Id); - idi_do_req(card, chan, REMOVE, 1); - } - - idi_do_req(card, chan, ASSIGN, 1); - idi_do_req(card, chan, CALL_RES, 0); - return(0); -} - -int -idi_connect_req(eicon_card *card, eicon_chan *chan, char *phone, - char *eazmsn, int si1, int si2) -{ - int l = 0; - int i; - unsigned char tmp; - unsigned char *sub, *sp; - unsigned char bc[5]; - unsigned char hlc[5]; - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan_ptr *chan2; - - if ((!card) || (!chan)) - return 1; - - skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in connect_req()\n", chan->No); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ)); - reqbuf->Req = CALL_REQ; - reqbuf->ReqCh = 0; - reqbuf->ReqId = 1; - - sub = NULL; - sp = phone; - while (*sp) { - if (*sp == '.') { - sub = sp + 1; - *sp = 0; - } else - sp++; - } - reqbuf->XBuffer.P[l++] = CPN; - reqbuf->XBuffer.P[l++] = strlen(phone) + 1; - reqbuf->XBuffer.P[l++] = 0x81; - for(i=0; i<strlen(phone);i++) - reqbuf->XBuffer.P[l++] = phone[i] & 0x7f; - if (sub) { - reqbuf->XBuffer.P[l++] = DSA; - reqbuf->XBuffer.P[l++] = strlen(sub) + 2; - reqbuf->XBuffer.P[l++] = 0x80; /* NSAP coded */ - reqbuf->XBuffer.P[l++] = 0x50; /* local IDI format */ - while (*sub) - reqbuf->XBuffer.P[l++] = *sub++ & 0x7f; - } - - sub = NULL; - sp = eazmsn; - while (*sp) { - if (*sp == '.') { - sub = sp + 1; - *sp = 0; - } else - sp++; - } - reqbuf->XBuffer.P[l++] = OAD; - reqbuf->XBuffer.P[l++] = strlen(eazmsn) + 2; - reqbuf->XBuffer.P[l++] = 0x01; - reqbuf->XBuffer.P[l++] = 0x80; - for(i=0; i<strlen(eazmsn);i++) - reqbuf->XBuffer.P[l++] = eazmsn[i] & 0x7f; - if (sub) { - reqbuf->XBuffer.P[l++] = OSA; - reqbuf->XBuffer.P[l++] = strlen(sub) + 2; - reqbuf->XBuffer.P[l++] = 0x80; /* NSAP coded */ - reqbuf->XBuffer.P[l++] = 0x50; /* local IDI format */ - while (*sub) - reqbuf->XBuffer.P[l++] = *sub++ & 0x7f; - } - - if (si2 > 2) { - reqbuf->XBuffer.P[l++] = SHIFT|6; - reqbuf->XBuffer.P[l++] = SIN; - reqbuf->XBuffer.P[l++] = 2; - reqbuf->XBuffer.P[l++] = si1; - reqbuf->XBuffer.P[l++] = si2; - } - else if ((tmp = idi_si2bc(si1, si2, bc, hlc)) > 0) { - reqbuf->XBuffer.P[l++] = BC; - reqbuf->XBuffer.P[l++] = tmp; - for(i=0; i<tmp;i++) - reqbuf->XBuffer.P[l++] = bc[i]; - if ((tmp=hlc[0])) { - reqbuf->XBuffer.P[l++] = HLC; - reqbuf->XBuffer.P[l++] = tmp; - for(i=1; i<=tmp;i++) - reqbuf->XBuffer.P[l++] = hlc[i]; - } - } - - reqbuf->XBuffer.P[l++] = CAI; - reqbuf->XBuffer.P[l++] = 6; - reqbuf->XBuffer.P[l++] = 0x09; - reqbuf->XBuffer.P[l++] = 0; - reqbuf->XBuffer.P[l++] = 0; - reqbuf->XBuffer.P[l++] = 0; - reqbuf->XBuffer.P[l++] = 32; - reqbuf->XBuffer.P[l++] = 0; - switch(chan->l2prot) { - case ISDN_PROTO_L2_X75I: - case ISDN_PROTO_L2_X75UI: - case ISDN_PROTO_L2_X75BUI: - case ISDN_PROTO_L2_HDLC: - reqbuf->XBuffer.P[l-6] = 5; - reqbuf->XBuffer.P[l-7] = 1; - l -= 5; - break; - case ISDN_PROTO_L2_V11096: - reqbuf->XBuffer.P[l-7] = 3; - reqbuf->XBuffer.P[l-6] = 0x0d; - reqbuf->XBuffer.P[l-5] = 5; - reqbuf->XBuffer.P[l-4] = 0; - l -= 3; - break; - case ISDN_PROTO_L2_V11019: - reqbuf->XBuffer.P[l-7] = 3; - reqbuf->XBuffer.P[l-6] = 0x0d; - reqbuf->XBuffer.P[l-5] = 6; - reqbuf->XBuffer.P[l-4] = 0; - l -= 3; - break; - case ISDN_PROTO_L2_V11038: - reqbuf->XBuffer.P[l-7] = 3; - reqbuf->XBuffer.P[l-6] = 0x0d; - reqbuf->XBuffer.P[l-5] = 7; - reqbuf->XBuffer.P[l-4] = 0; - l -= 3; - break; - case ISDN_PROTO_L2_MODEM: - reqbuf->XBuffer.P[l-6] = 0x11; - reqbuf->XBuffer.P[l-5] = 7; - reqbuf->XBuffer.P[l-4] = 0; - reqbuf->XBuffer.P[l-3] = 0; - reqbuf->XBuffer.P[l-2] = 128; - reqbuf->XBuffer.P[l-1] = 0; - break; - case ISDN_PROTO_L2_FAX: - reqbuf->XBuffer.P[l-6] = 0x10; - reqbuf->XBuffer.P[l-5] = 0; - reqbuf->XBuffer.P[l-4] = 0; - reqbuf->XBuffer.P[l-3] = 0; - reqbuf->XBuffer.P[l-2] = 128; - reqbuf->XBuffer.P[l-1] = 0; - break; - case ISDN_PROTO_L2_TRANS: - switch(chan->l3prot) { - case ISDN_PROTO_L3_TRANSDSP: - reqbuf->XBuffer.P[l-6] = 22; /* DTMF, audio events on */ - } - break; - } - - reqbuf->XBuffer.P[l++] = 0; /* end */ - reqbuf->XBuffer.length = l; - reqbuf->Reference = 0; /* Sig Entity */ - - if (chan->statectrl & WAITING_FOR_HANGUP) { - /* If the line did not disconnect yet, - we have to delay this command */ - eicon_log(card, 32, "idi_req: Ch%d: delaying conn_req\n", chan->No); - chan->statectrl |= HAVE_CONN_REQ; - chan->tskb1 = skb; - chan->tskb2 = skb2; - } else { - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - eicon_schedule_tx(card); - } - - eicon_log(card, 8, "idi_req: Ch%d: Conn_Req %s -> %s\n",chan->No, eazmsn, phone); - return(0); -} - - -void -idi_IndParse(eicon_card *ccard, eicon_chan *chan, idi_ind_message *message, unsigned char *buffer, int len) -{ - int i,j; - int pos = 0; - int codeset = 0; - int wlen = 0; - int lock = 0; - __u8 w; - __u16 code; - isdn_ctrl cmd; - - memset(message, 0, sizeof(idi_ind_message)); - - if ((!len) || (!buffer[pos])) return; - - while(pos <= len) { - w = buffer[pos++]; - if (!w) return; - if (w & 0x80) { - wlen = 0; - } - else { - wlen = buffer[pos++]; - } - - if (pos > len) return; - - if (lock & 0x80) lock &= 0x7f; - else codeset = lock; - - if((w&0xf0) == SHIFT) { - codeset = w; - if(!(codeset & 0x08)) lock = codeset & 7; - codeset &= 7; - lock |= 0x80; - } - else { - if (w==ESC && wlen >=2) { - code = buffer[pos++]|0x800; - wlen--; - } - else code = w; - code |= (codeset<<8); - - if (pos + wlen > len) { - eicon_log(ccard, 1, "idi_err: Ch%d: IElen %d of %x exceeds Ind_Length (+%d)\n", chan->No, - wlen, code, (pos + wlen) - len); - return; - } - - switch(code) { - case OAD: - if (wlen > sizeof(message->oad)) { - pos += wlen; - break; - } - j = 1; - if (wlen) { - message->plan = buffer[pos++]; - if (message->plan &0x80) - message->screen = 0; - else { - message->screen = buffer[pos++]; - j = 2; - } - } - for(i=0; i < wlen-j; i++) - message->oad[i] = buffer[pos++]; - eicon_log(ccard, 2, "idi_inf: Ch%d: OAD=(0x%02x,0x%02x) %s\n", chan->No, - message->plan, message->screen, message->oad); - break; - case RDN: - if (wlen > sizeof(message->rdn)) { - pos += wlen; - break; - } - j = 1; - if (wlen) { - if (!(buffer[pos++] & 0x80)) { - pos++; - j = 2; - } - } - for(i=0; i < wlen-j; i++) - message->rdn[i] = buffer[pos++]; - eicon_log(ccard, 2, "idi_inf: Ch%d: RDN= %s\n", chan->No, - message->rdn); - break; - case CPN: - if (wlen > sizeof(message->cpn)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->cpn[i] = buffer[pos++]; - eicon_log(ccard, 2, "idi_inf: Ch%d: CPN=(0x%02x) %s\n", chan->No, - (__u8)message->cpn[0], message->cpn + 1); - break; - case DSA: - if (wlen > sizeof(message->dsa)) { - pos += wlen; - break; - } - pos += 2; - for(i=0; i < wlen-2; i++) - message->dsa[i] = buffer[pos++]; - eicon_log(ccard, 2, "idi_inf: Ch%d: DSA=%s\n", chan->No, message->dsa); - break; - case OSA: - if (wlen > sizeof(message->osa)) { - pos += wlen; - break; - } - pos += 2; - for(i=0; i < wlen-2; i++) - message->osa[i] = buffer[pos++]; - eicon_log(ccard, 2, "idi_inf: Ch%d: OSA=%s\n", chan->No, message->osa); - break; - case CAD: - pos += wlen; - eicon_log(ccard, 2, "idi_inf: Ch%d: Connected Address in ind, len:%x\n", - chan->No, wlen); - break; - case BC: - if (wlen > sizeof(message->bc)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->bc[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: BC = 0x%02x 0x%02x 0x%02x\n", chan->No, - message->bc[0],message->bc[1],message->bc[2]); - break; - case 0x800|BC: - if (wlen > sizeof(message->e_bc)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->e_bc[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: ESC/BC=%d\n", chan->No, message->bc[0]); - break; - case LLC: - if (wlen > sizeof(message->llc)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->llc[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: LLC=%d %d %d %d ...\n", chan->No, message->llc[0], - message->llc[1],message->llc[2],message->llc[3]); - break; - case HLC: - if (wlen > sizeof(message->hlc)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->hlc[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: HLC=%x %x %x %x %x ...\n", chan->No, - message->hlc[0], message->hlc[1], - message->hlc[2], message->hlc[3], message->hlc[4]); - break; - case DSP: - case 0x600|DSP: - if (wlen > sizeof(message->display)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->display[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: Display: %s\n", chan->No, - message->display); - break; - case 0x600|KEY: - if (wlen > sizeof(message->keypad)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->keypad[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: Keypad: %s\n", chan->No, - message->keypad); - break; - case NI: - case 0x600|NI: - if (wlen) { - switch(buffer[pos] & 127) { - case 0: - eicon_log(ccard, 4, "idi_inf: Ch%d: User suspended.\n", chan->No); - break; - case 1: - eicon_log(ccard, 4, "idi_inf: Ch%d: User resumed.\n", chan->No); - break; - case 2: - eicon_log(ccard, 4, "idi_inf: Ch%d: Bearer service change.\n", chan->No); - break; - default: - eicon_log(ccard, 4, "idi_inf: Ch%d: Unknown Notification %x.\n", - chan->No, buffer[pos] & 127); - } - pos += wlen; - } - break; - case PI: - case 0x600|PI: - if (wlen > 1) { - switch(buffer[pos+1] & 127) { - case 1: - eicon_log(ccard, 4, "idi_inf: Ch%d: Call is not end-to-end ISDN.\n", chan->No); - break; - case 2: - eicon_log(ccard, 4, "idi_inf: Ch%d: Destination address is non ISDN.\n", chan->No); - break; - case 3: - eicon_log(ccard, 4, "idi_inf: Ch%d: Origination address is non ISDN.\n", chan->No); - break; - case 4: - eicon_log(ccard, 4, "idi_inf: Ch%d: Call has returned to the ISDN.\n", chan->No); - break; - case 5: - eicon_log(ccard, 4, "idi_inf: Ch%d: Interworking has occurred.\n", chan->No); - break; - case 8: - eicon_log(ccard, 4, "idi_inf: Ch%d: In-band information available.\n", chan->No); - break; - default: - eicon_log(ccard, 4, "idi_inf: Ch%d: Unknown Progress %x.\n", - chan->No, buffer[pos+1] & 127); - } - } - pos += wlen; - break; - case CAU: - if (wlen > sizeof(message->cau)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->cau[i] = buffer[pos++]; - memcpy(&chan->cause, &message->cau, 2); - eicon_log(ccard, 4, "idi_inf: Ch%d: CAU=%d %d\n", chan->No, - message->cau[0],message->cau[1]); - break; - case 0x800|CAU: - if (wlen > sizeof(message->e_cau)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->e_cau[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: ECAU=%d %d\n", chan->No, - message->e_cau[0],message->e_cau[1]); - break; - case 0x800|CHI: - if (wlen > sizeof(message->e_chi)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->e_chi[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: ESC/CHI=%d\n", chan->No, - message->e_cau[0]); - break; - case 0x800|0x7a: - pos ++; - message->e_mt=buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: EMT=0x%x\n", chan->No, message->e_mt); - break; - case DT: - if (wlen > sizeof(message->dt)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->dt[i] = buffer[pos++]; - eicon_log(ccard, 4, "idi_inf: Ch%d: DT: %02d.%02d.%02d %02d:%02d:%02d\n", chan->No, - message->dt[2], message->dt[1], message->dt[0], - message->dt[3], message->dt[4], message->dt[5]); - break; - case 0x600|SIN: - if (wlen > sizeof(message->sin)) { - pos += wlen; - break; - } - for(i=0; i < wlen; i++) - message->sin[i] = buffer[pos++]; - eicon_log(ccard, 2, "idi_inf: Ch%d: SIN=%d %d\n", chan->No, - message->sin[0],message->sin[1]); - break; - case 0x600|CPS: - eicon_log(ccard, 2, "idi_inf: Ch%d: Called Party Status in ind\n", chan->No); - pos += wlen; - break; - case 0x600|CIF: - for (i = 0; i < wlen; i++) - if (buffer[pos + i] != '0') break; - memcpy(&cmd.parm.num, &buffer[pos + i], wlen - i); - cmd.parm.num[wlen - i] = 0; - eicon_log(ccard, 2, "idi_inf: Ch%d: CIF=%s\n", chan->No, cmd.parm.num); - pos += wlen; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_CINF; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); - break; - case 0x600|DATE: - eicon_log(ccard, 2, "idi_inf: Ch%d: Date in ind\n", chan->No); - pos += wlen; - break; - case 0xa1: - eicon_log(ccard, 2, "idi_inf: Ch%d: Sending Complete in ind.\n", chan->No); - pos += wlen; - break; - case 0xe08: - case 0xe7a: - case 0xe04: - case 0xe00: - /* *** TODO *** */ - case CHA: - /* Charge advice */ - case FTY: - case 0x600|FTY: - case CHI: - case 0x800: - /* Not yet interested in this */ - pos += wlen; - break; - case 0x880: - /* Managment Information Element */ - if (!manbuf) { - eicon_log(ccard, 1, "idi_err: manbuf not allocated\n"); - } - else { - memcpy(&manbuf->data[manbuf->pos], &buffer[pos], wlen); - manbuf->length[manbuf->count] = wlen; - manbuf->count++; - manbuf->pos += wlen; - } - pos += wlen; - break; - default: - pos += wlen; - eicon_log(ccard, 6, "idi_inf: Ch%d: unknown information element 0x%x in ind, len:%x\n", - chan->No, code, wlen); - } - } - } -} - -void -idi_bc2si(unsigned char *bc, unsigned char *hlc, unsigned char *sin, unsigned char *si1, unsigned char *si2) -{ - si1[0] = 0; - si2[0] = 0; - - switch (bc[0] & 0x7f) { - case 0x00: /* Speech */ - si1[0] = 1; -#ifdef EICON_FULL_SERVICE_OKTETT - si1[0] = sin[0]; - si2[0] = sin[1]; -#endif - break; - case 0x10: /* 3.1 Khz audio */ - si1[0] = 1; -#ifdef EICON_FULL_SERVICE_OKTETT - si1[0] = sin[0]; - si2[0] = sin[1]; -#endif - break; - case 0x08: /* Unrestricted digital information */ - si1[0] = 7; - si2[0] = sin[1]; - break; - case 0x09: /* Restricted digital information */ - si1[0] = 2; - break; - case 0x11: - /* Unrestr. digital information with - * tones/announcements ( or 7 kHz audio - */ - si1[0] = 3; - break; - case 0x18: /* Video */ - si1[0] = 4; - break; - } - switch (bc[1] & 0x7f) { - case 0x40: /* packed mode */ - si1[0] = 8; - break; - case 0x10: /* 64 kbit */ - case 0x11: /* 2*64 kbit */ - case 0x13: /* 384 kbit */ - case 0x15: /* 1536 kbit */ - case 0x17: /* 1920 kbit */ - /* moderate = bc[1] & 0x7f; */ - break; - } -} - -/********************* FAX stuff ***************************/ - -#ifdef CONFIG_ISDN_TTY_FAX - -int -idi_fill_in_T30(eicon_chan *chan, unsigned char *buffer) -{ - eicon_t30_s *t30 = (eicon_t30_s *) buffer; - - if (!chan->fax) { - eicon_log(NULL, 1,"idi_T30: fill_in with NULL fax struct, ERROR\n"); - return 0; - } - memset(t30, 0, sizeof(eicon_t30_s)); - t30->station_id_len = EICON_FAXID_LEN; - memcpy(&t30->station_id[0], &chan->fax->id[0], EICON_FAXID_LEN); - t30->resolution = chan->fax->resolution; - t30->rate = chan->fax->rate + 1; /* eicon rate starts with 1 */ - t30->format = T30_FORMAT_SFF; - t30->pages_low = 0; - t30->pages_high = 0; - t30->atf = 1; /* optimised for AT+F command set */ - t30->code = 0; - t30->feature_bits_low = 0; - t30->feature_bits_high = 0; - t30->control_bits_low = 0; - t30->control_bits_high = 0; - - if (chan->fax->nbc) { - /* set compression by DCC value */ - switch(chan->fax->compression) { - case (0): /* 1-D modified */ - break; - case (1): /* 2-D modified Read */ - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING; - t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING; - break; - case (2): /* 2-D uncompressed */ - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_UNCOMPR; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING; - t30->feature_bits_low |= T30_FEATURE_BIT_UNCOMPR_ENABLED; - t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING; - break; - case (3): /* 2-D modified Read */ - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_T6_CODING; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_UNCOMPR; - t30->feature_bits_low |= T30_FEATURE_BIT_UNCOMPR_ENABLED; - t30->feature_bits_low |= T30_FEATURE_BIT_T6_CODING; - t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM; - t30->feature_bits_low |= T30_FEATURE_BIT_ECM; - break; - } - } else { - /* set compression to best */ - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_T6_CODING; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_UNCOMPR; - t30->feature_bits_low |= T30_FEATURE_BIT_UNCOMPR_ENABLED; - t30->feature_bits_low |= T30_FEATURE_BIT_T6_CODING; - t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING; - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM; - t30->feature_bits_low |= T30_FEATURE_BIT_ECM; - } - switch(chan->fax->ecm) { - case (0): /* disable ECM */ - break; - case (1): - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM; - t30->control_bits_low |= T30_CONTROL_BIT_ECM_64_BYTES; - t30->feature_bits_low |= T30_FEATURE_BIT_ECM; - t30->feature_bits_low |= T30_FEATURE_BIT_ECM_64_BYTES; - break; - case (2): - t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM; - t30->feature_bits_low |= T30_FEATURE_BIT_ECM; - break; - } - - if (DebugVar & 128) { - char st[40]; - eicon_log(NULL, 128, "sT30:code = %x\n", t30->code); - eicon_log(NULL, 128, "sT30:rate = %x\n", t30->rate); - eicon_log(NULL, 128, "sT30:res = %x\n", t30->resolution); - eicon_log(NULL, 128, "sT30:format = %x\n", t30->format); - eicon_log(NULL, 128, "sT30:pages_low = %x\n", t30->pages_low); - eicon_log(NULL, 128, "sT30:pages_high = %x\n", t30->pages_high); - eicon_log(NULL, 128, "sT30:atf = %x\n", t30->atf); - eicon_log(NULL, 128, "sT30:control_bits_low = %x\n", t30->control_bits_low); - eicon_log(NULL, 128, "sT30:control_bits_high = %x\n", t30->control_bits_high); - eicon_log(NULL, 128, "sT30:feature_bits_low = %x\n", t30->feature_bits_low); - eicon_log(NULL, 128, "sT30:feature_bits_high = %x\n", t30->feature_bits_high); - //eicon_log(NULL, 128, "sT30:universal_5 = %x\n", t30->universal_5); - //eicon_log(NULL, 128, "sT30:universal_6 = %x\n", t30->universal_6); - //eicon_log(NULL, 128, "sT30:universal_7 = %x\n", t30->universal_7); - eicon_log(NULL, 128, "sT30:station_id_len = %x\n", t30->station_id_len); - eicon_log(NULL, 128, "sT30:head_line_len = %x\n", t30->head_line_len); - strlcpy(st, t30->station_id, t30->station_id_len + 1); - eicon_log(NULL, 128, "sT30:station_id = <%s>\n", st); - } - return(sizeof(eicon_t30_s)); -} - -/* send fax struct */ -int -idi_send_edata(eicon_card *card, eicon_chan *chan) -{ - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan_ptr *chan2; - - if ((chan->fsm_state == EICON_STATE_NULL) || (chan->fsm_state == EICON_STATE_LISTEN)) { - eicon_log(card, 1, "idi_snd: Ch%d: send edata on state %d !\n", chan->No, chan->fsm_state); - return -ENODEV; - } - eicon_log(card, 128, "idi_snd: Ch%d: edata (fax)\n", chan->No); - - skb = alloc_skb(sizeof(eicon_REQ) + sizeof(eicon_t30_s), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in send_edata()\n", chan->No); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, sizeof(eicon_t30_s) + sizeof(eicon_REQ)); - - reqbuf->Req = N_EDATA; - reqbuf->ReqCh = chan->e.IndCh; - reqbuf->ReqId = 1; - - reqbuf->XBuffer.length = idi_fill_in_T30(chan, reqbuf->XBuffer.P); - reqbuf->Reference = 1; /* Net Entity */ - - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - eicon_schedule_tx(card); - return (0); -} - -void -idi_parse_edata(eicon_card *ccard, eicon_chan *chan, unsigned char *buffer, int len) -{ - eicon_t30_s *p = (eicon_t30_s *)buffer; - int i; - - if (DebugVar & 128) { - char st[40]; - eicon_log(ccard, 128, "rT30:len %d , size %d\n", len, sizeof(eicon_t30_s)); - eicon_log(ccard, 128, "rT30:code = %x\n", p->code); - eicon_log(ccard, 128, "rT30:rate = %x\n", p->rate); - eicon_log(ccard, 128, "rT30:res = %x\n", p->resolution); - eicon_log(ccard, 128, "rT30:format = %x\n", p->format); - eicon_log(ccard, 128, "rT30:pages_low = %x\n", p->pages_low); - eicon_log(ccard, 128, "rT30:pages_high = %x\n", p->pages_high); - eicon_log(ccard, 128, "rT30:atf = %x\n", p->atf); - eicon_log(ccard, 128, "rT30:control_bits_low = %x\n", p->control_bits_low); - eicon_log(ccard, 128, "rT30:control_bits_high = %x\n", p->control_bits_high); - eicon_log(ccard, 128, "rT30:feature_bits_low = %x\n", p->feature_bits_low); - eicon_log(ccard, 128, "rT30:feature_bits_high = %x\n", p->feature_bits_high); - //eicon_log(ccard, 128, "rT30:universal_5 = %x\n", p->universal_5); - //eicon_log(ccard, 128, "rT30:universal_6 = %x\n", p->universal_6); - //eicon_log(ccard, 128, "rT30:universal_7 = %x\n", p->universal_7); - eicon_log(ccard, 128, "rT30:station_id_len = %x\n", p->station_id_len); - eicon_log(ccard, 128, "rT30:head_line_len = %x\n", p->head_line_len); - strlcpy(st, p->station_id, p->station_id_len + 1); - eicon_log(ccard, 128, "rT30:station_id = <%s>\n", st); - } - if (!chan->fax) { - eicon_log(ccard, 1, "idi_edata: parse to NULL fax struct, ERROR\n"); - return; - } - chan->fax->code = p->code; - i = (p->station_id_len < FAXIDLEN) ? p->station_id_len : (FAXIDLEN - 1); - memcpy(chan->fax->r_id, p->station_id, i); - chan->fax->r_id[i] = 0; - chan->fax->r_resolution = p->resolution; - chan->fax->r_rate = p->rate - 1; - chan->fax->r_binary = 0; /* no binary support */ - chan->fax->r_width = 0; - chan->fax->r_length = 2; - chan->fax->r_scantime = 0; - chan->fax->r_compression = 0; - chan->fax->r_ecm = 0; - if (p->feature_bits_low & T30_FEATURE_BIT_2D_CODING) { - chan->fax->r_compression = 1; - if (p->feature_bits_low & T30_FEATURE_BIT_UNCOMPR_ENABLED) { - chan->fax->r_compression = 2; - } - } - if (p->feature_bits_low & T30_FEATURE_BIT_T6_CODING) { - chan->fax->r_compression = 3; - } - - if (p->feature_bits_low & T30_FEATURE_BIT_ECM) { - chan->fax->r_ecm = 2; - if (p->feature_bits_low & T30_FEATURE_BIT_ECM_64_BYTES) - chan->fax->r_ecm = 1; - } -} - -void -idi_fax_send_header(eicon_card *card, eicon_chan *chan, int header) -{ - static __u16 wd2sff[] = { - 1728, 2048, 2432, 1216, 864 - }; - static __u16 ln2sff[2][3] = { - { 1143, 1401, 0 } , { 2287, 2802, 0 } - }; - struct sk_buff *skb; - eicon_sff_dochead *doc; - eicon_sff_pagehead *page; - u_char *docp; - - if (!chan->fax) { - eicon_log(card, 1, "idi_fax: send head with NULL fax struct, ERROR\n"); - return; - } - if (header == 2) { /* DocHeader + PageHeader */ - skb = alloc_skb(sizeof(eicon_sff_dochead) + sizeof(eicon_sff_pagehead), GFP_ATOMIC); - } else { - skb = alloc_skb(sizeof(eicon_sff_pagehead), GFP_ATOMIC); - } - if (!skb) { - eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in fax_send_header()\n", chan->No); - return; - } - - if (header == 2) { /* DocHeader + PageHeader */ - docp = skb_put(skb, sizeof(eicon_sff_dochead) + sizeof(eicon_sff_pagehead)); - doc = (eicon_sff_dochead *) docp; - page = (eicon_sff_pagehead *) (docp + sizeof(eicon_sff_dochead)); - memset(docp, 0,sizeof(eicon_sff_dochead) + sizeof(eicon_sff_pagehead)); - doc->id = 0x66666653; - doc->version = 0x01; - doc->off1pagehead = sizeof(eicon_sff_dochead); - } else { - page = (eicon_sff_pagehead *)skb_put(skb, sizeof(eicon_sff_pagehead)); - memset(page, 0, sizeof(eicon_sff_pagehead)); - } - - switch(header) { - case 1: /* PageHeaderEnd */ - page->pageheadid = 254; - page->pageheadlen = 0; - break; - case 0: /* PageHeader */ - case 2: /* DocHeader + PageHeader */ - page->pageheadid = 254; - page->pageheadlen = sizeof(eicon_sff_pagehead) - 2; - page->resvert = chan->fax->resolution; - page->reshoriz = 0; /* always 203 dpi */ - page->coding = 0; /* always 1D */ - page->linelength = wd2sff[chan->fax->width]; - page->pagelength = ln2sff[chan->fax->resolution][chan->fax->length]; - eicon_log(card, 128, "sSFF-Head: linelength = %d\n", page->linelength); - eicon_log(card, 128, "sSFF-Head: pagelength = %d\n", page->pagelength); - break; - } - idi_send_data(card, chan, 0, skb, 0, 0); -} - -void -idi_fax_cmd(eicon_card *card, eicon_chan *chan) -{ - isdn_ctrl cmd; - - if ((!card) || (!chan)) - return; - - if (!chan->fax) { - eicon_log(card, 1, "idi_fax: cmd with NULL fax struct, ERROR\n"); - return; - } - switch (chan->fax->code) { - case ISDN_TTY_FAX_DT: - if (chan->fax->phase == ISDN_FAX_PHASE_B) { - idi_send_edata(card, chan); - break; - } - if (chan->fax->phase == ISDN_FAX_PHASE_D) { - idi_send_edata(card, chan); - break; - } - break; - - case ISDN_TTY_FAX_DR: - if (chan->fax->phase == ISDN_FAX_PHASE_B) { - idi_send_edata(card, chan); - - cmd.driver = card->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_CFR; - card->interface.statcallb(&cmd); - - cmd.driver = card->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_RID; - card->interface.statcallb(&cmd); - - /* telling 1-D compression */ - chan->fax->r_compression = 0; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_DCS; - card->interface.statcallb(&cmd); - - chan->fax2.NextObject = FAX_OBJECT_DOCU; - chan->fax2.PrevObject = FAX_OBJECT_DOCU; - - break; - } - if (chan->fax->phase == ISDN_FAX_PHASE_D) { - idi_send_edata(card, chan); - break; - } - break; - - case ISDN_TTY_FAX_ET: - switch(chan->fax->fet) { - case 0: - case 1: - idi_fax_send_header(card, chan, 0); - break; - case 2: - idi_fax_send_header(card, chan, 1); - break; - } - break; - } -} - -void -idi_edata_rcveop(eicon_card *card, eicon_chan *chan) -{ - isdn_ctrl cmd; - - if (!chan->fax) { - eicon_log(card, 1, "idi_edata: rcveop with NULL fax struct, ERROR\n"); - return; - } - cmd.driver = card->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_ET; - card->interface.statcallb(&cmd); -} - -void -idi_reset_fax_stat(eicon_chan *chan) -{ - chan->fax2.LineLen = 0; - chan->fax2.LineData = 0; - chan->fax2.LineDataLen = 0; - chan->fax2.NullByteExist = 0; - chan->fax2.Dle = 0; - chan->fax2.PageCount = 0; - chan->fax2.Eop = 0; -} - -void -idi_edata_action(eicon_card *ccard, eicon_chan *chan, char *buffer, int len) -{ - isdn_ctrl cmd; - - if (!chan->fax) { - eicon_log(ccard, 1, "idi_edata: action with NULL fax struct, ERROR\n"); - return; - } - if (chan->fax->direction == ISDN_TTY_FAX_CONN_OUT) { - idi_parse_edata(ccard, chan, buffer, len); - - if (chan->fax->phase == ISDN_FAX_PHASE_A) { - idi_reset_fax_stat(chan); - - chan->fsm_state = EICON_STATE_ACTIVE; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BCONN; - cmd.arg = chan->No; - strcpy(cmd.parm.num, ""); - ccard->interface.statcallb(&cmd); - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_FCON; - ccard->interface.statcallb(&cmd); - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_RID; - ccard->interface.statcallb(&cmd); - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_DIS; - ccard->interface.statcallb(&cmd); - - if (chan->fax->r_compression != 0) { - /* telling fake compression in second DIS message */ - chan->fax->r_compression = 0; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_DIS; - ccard->interface.statcallb(&cmd); - } - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_SENT; /* OK message */ - ccard->interface.statcallb(&cmd); - } else - if (chan->fax->phase == ISDN_FAX_PHASE_D) { - - if ((chan->fax->code == EDATA_T30_MCF) && - (chan->fax->fet != 2)) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_PTS; - ccard->interface.statcallb(&cmd); - } - - switch(chan->fax->fet) { - case 0: /* new page */ - /* stay in phase D , wait on cmd +FDT */ - break; - case 1: /* new document */ - /* link-level switch to phase B */ - break; - case 2: /* session end */ - default: - /* send_edata produces error on some */ - /* fax-machines here, so we don't */ - /* idi_send_edata(ccard, chan); */ - break; - } - } - } - - if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) { - idi_parse_edata(ccard, chan, buffer, len); - - if ((chan->fax->code == EDATA_T30_DCS) && - (chan->fax->phase == ISDN_FAX_PHASE_A)) { - idi_reset_fax_stat(chan); - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BCONN; - cmd.arg = chan->No; - strcpy(cmd.parm.num, ""); - ccard->interface.statcallb(&cmd); - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_FCON_I; - ccard->interface.statcallb(&cmd); - } else - if ((chan->fax->code == EDATA_T30_TRAIN_OK) && - (chan->fax->phase == ISDN_FAX_PHASE_A)) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_RID; - ccard->interface.statcallb(&cmd); - - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_TRAIN_OK; - ccard->interface.statcallb(&cmd); - } else - if ((chan->fax->code == EDATA_T30_TRAIN_OK) && - (chan->fax->phase == ISDN_FAX_PHASE_B)) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_TRAIN_OK; - ccard->interface.statcallb(&cmd); - } else - if (chan->fax->phase == ISDN_FAX_PHASE_C) { - switch(chan->fax->code) { - case EDATA_T30_TRAIN_OK: - idi_send_edata(ccard, chan); - break; - case EDATA_T30_MPS: - chan->fax->fet = 0; - idi_edata_rcveop(ccard, chan); - break; - case EDATA_T30_EOM: - chan->fax->fet = 1; - idi_edata_rcveop(ccard, chan); - break; - case EDATA_T30_EOP: - chan->fax->fet = 2; - idi_edata_rcveop(ccard, chan); - break; - } - } - } -} - -void -fax_put_rcv(eicon_card *ccard, eicon_chan *chan, u_char *Data, int len) -{ - struct sk_buff *skb; - - skb = alloc_skb(len + MAX_HEADER_LEN, GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "idi_err: Ch%d: alloc_skb failed in fax_put_rcv()\n", chan->No); - return; - } - skb_reserve(skb, MAX_HEADER_LEN); - memcpy(skb_put(skb, len), Data, len); - ccard->interface.rcvcallb_skb(ccard->myid, chan->No, skb); -} - -void -idi_faxdata_rcv(eicon_card *ccard, eicon_chan *chan, struct sk_buff *skb) -{ - eicon_OBJBUFFER InBuf; - eicon_OBJBUFFER LineBuf; - unsigned int Length = 0; - unsigned int aLength = 0; - unsigned int ObjectSize = 0; - unsigned int ObjHeadLen = 0; - unsigned int ObjDataLen = 0; - __u8 Recordtype; - __u8 PageHeaderLen; - __u8 Event; - eicon_sff_pagehead *ob_page; - - __u16 Cl2Eol = 0x8000; - -# define EVENT_NONE 0 -# define EVENT_NEEDDATA 1 - - if (!chan->fax) { - eicon_log(ccard, 1, "idi_fax: rcvdata with NULL fax struct, ERROR\n"); - return; - } - - - - if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) { - InBuf.Data = skb->data; - InBuf.Size = skb->len; - InBuf.Len = 0; - InBuf.Next = InBuf.Data; - LineBuf.Data = chan->fax2.abLine; - LineBuf.Size = sizeof(chan->fax2.abLine); - LineBuf.Len = chan->fax2.LineLen; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - - Event = EVENT_NONE; - while (Event == EVENT_NONE) { - switch(chan->fax2.NextObject) { - case FAX_OBJECT_DOCU: - Length = LineBuf.Len + (InBuf.Size - InBuf.Len); - if (Length < sizeof(eicon_sff_dochead)) { - Event = EVENT_NEEDDATA; - break; - } - ObjectSize = sizeof(eicon_sff_dochead); - Length = ObjectSize; - if (LineBuf.Len < Length) { - Length -= LineBuf.Len; - LineBuf.Len = 0; - LineBuf.Next = LineBuf.Data; - InBuf.Len += Length; - InBuf.Next += Length; - } else { - LineBuf.Len -= Length; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - memmove(LineBuf.Data, LineBuf.Data + Length, LineBuf.Len); - } - chan->fax2.PrevObject = FAX_OBJECT_DOCU; - chan->fax2.NextObject = FAX_OBJECT_PAGE; - break; - - case FAX_OBJECT_PAGE: - Length = LineBuf.Len + (InBuf.Size - InBuf.Len); - if (Length < 2) { - Event = EVENT_NEEDDATA; - break; - } - if (LineBuf.Len == 0) { - *LineBuf.Next++ = *InBuf.Next++; - LineBuf.Len++; - InBuf.Len++; - } - if (LineBuf.Len == 1) { - *LineBuf.Next++ = *InBuf.Next++; - LineBuf.Len++; - InBuf.Len++; - } - PageHeaderLen = *(LineBuf.Data + 1); - ObjectSize = (PageHeaderLen == 0) ? 2 : sizeof(eicon_sff_pagehead); - if (Length < ObjectSize) { - Event = EVENT_NEEDDATA; - break; - } - Length = ObjectSize; - /* extract page dimensions */ - if (LineBuf.Len < Length) { - aLength = Length - LineBuf.Len; - memcpy(LineBuf.Next, InBuf.Next, aLength); - LineBuf.Next += aLength; - InBuf.Next += aLength; - LineBuf.Len += aLength; - InBuf.Len += aLength; - } - if (Length > 2) { - ob_page = (eicon_sff_pagehead *)LineBuf.Data; - switch(ob_page->linelength) { - case 2048: - chan->fax->r_width = 1; - break; - case 2432: - chan->fax->r_width = 2; - break; - case 1216: - chan->fax->r_width = 3; - break; - case 864: - chan->fax->r_width = 4; - break; - case 1728: - default: - chan->fax->r_width = 0; - } - switch(ob_page->pagelength) { - case 1143: - case 2287: - chan->fax->r_length = 0; - break; - case 1401: - case 2802: - chan->fax->r_length = 1; - break; - default: - chan->fax->r_length = 2; - } - eicon_log(ccard, 128, "rSFF-Head: linelength = %d\n", ob_page->linelength); - eicon_log(ccard, 128, "rSFF-Head: pagelength = %d\n", ob_page->pagelength); - } - LineBuf.Len -= Length; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - memmove(LineBuf.Data, LineBuf.Data + Length, LineBuf.Len); - - chan->fax2.PrevObject = FAX_OBJECT_PAGE; - chan->fax2.NextObject = FAX_OBJECT_LINE; - break; - - case FAX_OBJECT_LINE: - Length = LineBuf.Len + (InBuf.Size - InBuf.Len); - if (Length < 1) { - Event = EVENT_NEEDDATA; - break; - } - if (LineBuf.Len == 0) { - *LineBuf.Next++ = *InBuf.Next++; - LineBuf.Len++; - InBuf.Len++; - } - Recordtype = *LineBuf.Data; - if (Recordtype == 0) { - /* recordtype pixel row (2 byte length) */ - ObjHeadLen = 3; - if (Length < ObjHeadLen) { - Event = EVENT_NEEDDATA; - break; - } - while (LineBuf.Len < ObjHeadLen) { - *LineBuf.Next++ = *InBuf.Next++; - LineBuf.Len++; - InBuf.Len++; - } - ObjDataLen = *((__u16*) (LineBuf.Data + 1)); - ObjectSize = ObjHeadLen + ObjDataLen; - if (Length < ObjectSize) { - Event = EVENT_NEEDDATA; - break; - } - } else - if ((Recordtype >= 1) && (Recordtype <= 216)) { - /* recordtype pixel row (1 byte length) */ - ObjHeadLen = 1; - ObjDataLen = Recordtype; - ObjectSize = ObjHeadLen + ObjDataLen; - if (Length < ObjectSize) { - Event = EVENT_NEEDDATA; - break; - } - } else - if ((Recordtype >= 217) && (Recordtype <= 253)) { - /* recordtype empty lines */ - ObjHeadLen = 1; - ObjDataLen = 0; - ObjectSize = ObjHeadLen + ObjDataLen; - LineBuf.Len--; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - memmove(LineBuf.Data, LineBuf.Data + 1, LineBuf.Len); - break; - } else - if (Recordtype == 254) { - /* recordtype page header */ - chan->fax2.PrevObject = FAX_OBJECT_LINE; - chan->fax2.NextObject = FAX_OBJECT_PAGE; - break; - } else { - /* recordtype user information */ - ObjHeadLen = 2; - if (Length < ObjHeadLen) { - Event = EVENT_NEEDDATA; - break; - } - while (LineBuf.Len < ObjHeadLen) { - *LineBuf.Next++ = *InBuf.Next++; - LineBuf.Len++; - InBuf.Len++; - } - ObjDataLen = *(LineBuf.Data + 1); - ObjectSize = ObjHeadLen + ObjDataLen; - if (ObjDataLen == 0) { - /* illegal line coding */ - LineBuf.Len -= ObjHeadLen; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - memmove(LineBuf.Data, LineBuf.Data + ObjHeadLen, LineBuf.Len); - break; - } else { - /* user information */ - if (Length < ObjectSize) { - Event = EVENT_NEEDDATA; - break; - } - Length = ObjectSize; - if (LineBuf.Len < Length) { - Length -= LineBuf.Len; - LineBuf.Len = 0; - LineBuf.Next = LineBuf.Data; - InBuf.Len += Length; - InBuf.Next += Length; - } else { - LineBuf.Len -= Length; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - memmove(LineBuf.Data, LineBuf.Data + Length, LineBuf.Len); - } - } - break; - } - Length = ObjectSize; - if (LineBuf.Len > ObjHeadLen) { - fax_put_rcv(ccard, chan, LineBuf.Data + ObjHeadLen, - (LineBuf.Len - ObjHeadLen)); - } - Length -= LineBuf.Len; - LineBuf.Len = 0; - LineBuf.Next = LineBuf.Data; - if (Length > 0) { - fax_put_rcv(ccard, chan, InBuf.Next, Length); - InBuf.Len += Length; - InBuf.Next += Length; - } - fax_put_rcv(ccard, chan, (__u8 *)&Cl2Eol, sizeof(Cl2Eol)); - break; - } /* end of switch (chan->fax2.NextObject) */ - } /* end of while (Event==EVENT_NONE) */ - if (InBuf.Len < InBuf.Size) { - Length = InBuf.Size - InBuf.Len; - if ((LineBuf.Len + Length) > LineBuf.Size) { - eicon_log(ccard, 1, "idi_fax: Ch%d: %d bytes dropping, small buffer\n", chan->No, - Length); - } else { - memcpy(LineBuf.Next, InBuf.Next, Length); - LineBuf.Len += Length; - } - } - chan->fax2.LineLen = LineBuf.Len; - } else { /* CONN_OUT */ - /* On CONN_OUT we do not need incoming data, drop it */ - /* maybe later for polling */ - } - -# undef EVENT_NONE -# undef EVENT_NEEDDATA - - return; -} - -int -idi_fax_send_outbuf(eicon_card *ccard, eicon_chan *chan, eicon_OBJBUFFER *OutBuf) -{ - struct sk_buff *skb; - - skb = alloc_skb(OutBuf->Len, GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "idi_err: Ch%d: alloc_skb failed in fax_send_outbuf()\n", chan->No); - return(-1); - } - memcpy(skb_put(skb, OutBuf->Len), OutBuf->Data, OutBuf->Len); - - OutBuf->Len = 0; - OutBuf->Next = OutBuf->Data; - - return(idi_send_data(ccard, chan, 0, skb, 1, 0)); -} - -int -idi_faxdata_send(eicon_card *ccard, eicon_chan *chan, struct sk_buff *skb) -{ - isdn_ctrl cmd; - eicon_OBJBUFFER InBuf; - __u8 InData; - __u8 InMask; - eicon_OBJBUFFER OutBuf; - eicon_OBJBUFFER LineBuf; - __u32 LineData; - unsigned int LineDataLen; - __u8 Byte; - __u8 Event; - int ret = 1; - -# define EVENT_NONE 0 -# define EVENT_EOD 1 -# define EVENT_EOL 2 -# define EVENT_EOP 3 - - if ((!ccard) || (!chan)) - return -1; - - if (!chan->fax) { - eicon_log(ccard, 1, "idi_fax: senddata with NULL fax struct, ERROR\n"); - return -1; - } - - if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) { - /* Simply ignore any data written in data mode when receiving a fax. */ - /* This is not completely correct because only XON's should come here. */ - dev_kfree_skb(skb); - return 1; - } - - if (chan->fax->phase != ISDN_FAX_PHASE_C) { - dev_kfree_skb(skb); - return 1; - } - - if (chan->queued + skb->len > 1200) - return 0; - if (chan->pqueued > 1) - return 0; - - InBuf.Data = skb->data; - InBuf.Size = skb->len; - InBuf.Len = 0; - InBuf.Next = InBuf.Data; - InData = 0; - InMask = 0; - - LineBuf.Data = chan->fax2.abLine; - LineBuf.Size = sizeof(chan->fax2.abLine); - LineBuf.Len = chan->fax2.LineLen; - LineBuf.Next = LineBuf.Data + LineBuf.Len; - LineData = chan->fax2.LineData; - LineDataLen = chan->fax2.LineDataLen; - - OutBuf.Data = chan->fax2.abFrame; - OutBuf.Size = sizeof(chan->fax2.abFrame); - OutBuf.Len = 0; - OutBuf.Next = OutBuf.Data; - - Event = EVENT_NONE; - - chan->fax2.Eop = 0; - - for (;;) { - for (;;) { - if (InMask == 0) { - if (InBuf.Len >= InBuf.Size) { - Event = EVENT_EOD; - break; - } - if ((chan->fax2.Dle != _DLE_) && *InBuf.Next == _DLE_) { - chan->fax2.Dle = _DLE_; - InBuf.Next++; - InBuf.Len++; - if (InBuf.Len >= InBuf.Size) { - Event = EVENT_EOD; - break; - } - } - if (chan->fax2.Dle == _DLE_) { - chan->fax2.Dle = 0; - if (*InBuf.Next == _ETX_) { - Event = EVENT_EOP; - break; - } else - if (*InBuf.Next == _DLE_) { - /* do nothing */ - } else { - eicon_log(ccard, 1, - "idi_err: Ch%d: unknown DLE escape %02x found\n", - chan->No, *InBuf.Next); - InBuf.Next++; - InBuf.Len++; - if (InBuf.Len >= InBuf.Size) { - Event = EVENT_EOD; - break; - } - } - } - InBuf.Len++; - InData = *InBuf.Next++; - InMask = (chan->fax->bor) ? 0x80 : 0x01; - } - while (InMask) { - LineData >>= 1; - LineDataLen++; - if (InData & InMask) - LineData |= 0x80000000; - if (chan->fax->bor) - InMask >>= 1; - else - InMask <<= 1; - - if ((LineDataLen >= T4_EOL_BITSIZE) && - ((LineData & T4_EOL_MASK_DWORD) == T4_EOL_DWORD)) { - Event = EVENT_EOL; - if (LineDataLen > T4_EOL_BITSIZE) { - Byte = (__u8) - ((LineData & ~T4_EOL_MASK_DWORD) >> - (32 - LineDataLen)); - if (Byte == 0) { - if (! chan->fax2.NullByteExist) { - chan->fax2.NullBytesPos = LineBuf.Len; - chan->fax2.NullByteExist = 1; - } - } else { - chan->fax2.NullByteExist = 0; - } - if (LineBuf.Len < LineBuf.Size) { - *LineBuf.Next++ = Byte; - LineBuf.Len++; - } - } - LineDataLen = 0; - break; - } - if (LineDataLen >= T4_EOL_BITSIZE + 8) { - Byte = (__u8) - ((LineData & ~T4_EOL_MASK_DWORD) >> - (32 - T4_EOL_BITSIZE - 8)); - LineData &= T4_EOL_MASK_DWORD; - LineDataLen = T4_EOL_BITSIZE; - if (Byte == 0) { - if (! chan->fax2.NullByteExist) { - chan->fax2.NullBytesPos = LineBuf.Len; - chan->fax2.NullByteExist = 1; - } - } else { - chan->fax2.NullByteExist = 0; - } - if (LineBuf.Len < LineBuf.Size) { - *LineBuf.Next++ = Byte; - LineBuf.Len++; - } - } - } - if (Event != EVENT_NONE) - break; - } - - if ((Event != EVENT_EOL) && (Event != EVENT_EOP)) - break; - - if ((Event == EVENT_EOP) && (LineDataLen > 0)) { - LineData >>= 32 - LineDataLen; - LineDataLen = 0; - while (LineData != 0) { - Byte = (__u8) LineData; - LineData >>= 8; - if (Byte == 0) { - if (! chan->fax2.NullByteExist) { - chan->fax2.NullBytesPos = LineBuf.Len; - chan->fax2.NullByteExist = 1; - } - } else { - chan->fax2.NullByteExist = 0; - } - if (LineBuf.Len < LineBuf.Size) { - *LineBuf.Next++ = Byte; - LineBuf.Len++; - } - - } - } - if (chan->fax2.NullByteExist) { - if (chan->fax2.NullBytesPos == 0) { - LineBuf.Len = 0; - } else { - LineBuf.Len = chan->fax2.NullBytesPos + 1; - } - } - if (LineBuf.Len > 0) { - if (OutBuf.Len + LineBuf.Len + SFF_LEN_FLD_SIZE > OutBuf.Size) { - ret = idi_fax_send_outbuf(ccard, chan, &OutBuf); - } - if (LineBuf.Len <= 216) { - *OutBuf.Next++ = (__u8) LineBuf.Len; - OutBuf.Len++; - } else { - *OutBuf.Next++ = 0; - *((__u16 *) OutBuf.Next)++ = (__u16) LineBuf.Len; - OutBuf.Len += 3; - } - memcpy(OutBuf.Next, LineBuf.Data, LineBuf.Len); - OutBuf.Next += LineBuf.Len; - OutBuf.Len += LineBuf.Len; - } - LineBuf.Len = 0; - LineBuf.Next = LineBuf.Data; - chan->fax2.NullByteExist = 0; - if (Event == EVENT_EOP) - break; - - Event = EVENT_NONE; - } - - if (Event == EVENT_EOP) { - chan->fax2.Eop = 1; - chan->fax2.PageCount++; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_EOP; - ccard->interface.statcallb(&cmd); - } - if (OutBuf.Len > 0) { - ret = idi_fax_send_outbuf(ccard, chan, &OutBuf); - } - - chan->fax2.LineLen = LineBuf.Len; - chan->fax2.LineData = LineData; - chan->fax2.LineDataLen = LineDataLen; - -# undef EVENT_NONE -# undef EVENT_EOD -# undef EVENT_EOL -# undef EVENT_EOP - - if (ret >= 0) - dev_kfree_skb(skb); - if (ret == 0) - ret = 1; - return(ret); -} - -void -idi_fax_hangup(eicon_card *ccard, eicon_chan *chan) -{ - isdn_ctrl cmd; - - if (!chan->fax) { - eicon_log(ccard, 1, "idi_fax: hangup with NULL fax struct, ERROR\n"); - return; - } - if ((chan->fax->direction == ISDN_TTY_FAX_CONN_OUT) && - (chan->fax->code == 0)) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_PTS; - ccard->interface.statcallb(&cmd); - } - if ((chan->fax->code > 1) && (chan->fax->code < 120)) - chan->fax->code += 120; - eicon_log(ccard, 8, "idi_fax: Ch%d: Hangup (code=%d)\n", chan->No, chan->fax->code); - chan->fax->r_code = ISDN_TTY_FAX_HNG; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); -} - -#endif /******** FAX ********/ - -int -idi_send_udata(eicon_card *card, eicon_chan *chan, int UReq, u_char *buffer, int len) -{ - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan_ptr *chan2; - - if ((chan->fsm_state == EICON_STATE_NULL) || (chan->fsm_state == EICON_STATE_LISTEN)) { - eicon_log(card, 1, "idi_snd: Ch%d: send udata on state %d !\n", chan->No, chan->fsm_state); - return -ENODEV; - } - eicon_log(card, 8, "idi_snd: Ch%d: udata 0x%x: %d %d %d %d\n", chan->No, - UReq, buffer[0], buffer[1], buffer[2], buffer[3]); - - skb = alloc_skb(sizeof(eicon_REQ) + len + 1, GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in send_udata()\n", chan->No); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, 1 + len + sizeof(eicon_REQ)); - - reqbuf->Req = N_UDATA; - reqbuf->ReqCh = chan->e.IndCh; - reqbuf->ReqId = 1; - - reqbuf->XBuffer.length = len + 1; - reqbuf->XBuffer.P[0] = UReq; - memcpy(&reqbuf->XBuffer.P[1], buffer, len); - reqbuf->Reference = 1; /* Net Entity */ - - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - eicon_schedule_tx(card); - return (0); -} - -void -idi_audio_cmd(eicon_card *ccard, eicon_chan *chan, int cmd, u_char *value) -{ - u_char buf[6]; - struct enable_dtmf_s *dtmf_buf = (struct enable_dtmf_s *)buf; - - if ((!ccard) || (!chan)) - return; - - memset(buf, 0, 6); - switch(cmd) { - case ISDN_AUDIO_SETDD: - if (value[0]) { - dtmf_buf->tone = (__u16) (value[1] * 5); - dtmf_buf->gap = (__u16) (value[1] * 5); - idi_send_udata(ccard, chan, - DSP_UDATA_REQUEST_ENABLE_DTMF_RECEIVER, - buf, 4); - } else { - idi_send_udata(ccard, chan, - DSP_UDATA_REQUEST_DISABLE_DTMF_RECEIVER, - buf, 0); - } - break; - } -} - -void -idi_parse_udata(eicon_card *ccard, eicon_chan *chan, unsigned char *buffer, int len) -{ - isdn_ctrl cmd; - eicon_dsp_ind *p = (eicon_dsp_ind *) (&buffer[1]); - static char *connmsg[] = - {"", "V.21", "V.23", "V.22", "V.22bis", "V.32bis", "V.34", - "V.8", "Bell 212A", "Bell 103", "V.29 Leased", "V.33 Leased", "V.90", - "V.21 CH2", "V.27ter", "V.29", "V.33", "V.17", "V.32", "K56Flex", - "X2", "V.18", "V.18LH", "V.18HL", "V.21LH", "V.21HL", - "Bell 103LH", "Bell 103HL", "V.23", "V.23", "EDT 110", - "Baudot45", "Baudot47", "Baudot50", "DTMF" }; - static u_char dtmf_code[] = { - '1','4','7','*','2','5','8','0','3','6','9','#','A','B','C','D' - }; - - if ((!ccard) || (!chan)) - return; - - switch (buffer[0]) { - case DSP_UDATA_INDICATION_SYNC: - eicon_log(ccard, 16, "idi_ind: Ch%d: UDATA_SYNC time %d\n", chan->No, p->time); - break; - case DSP_UDATA_INDICATION_DCD_OFF: - eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DCD_OFF time %d\n", chan->No, p->time); - break; - case DSP_UDATA_INDICATION_DCD_ON: - if ((chan->l2prot == ISDN_PROTO_L2_MODEM) && - (chan->fsm_state == EICON_STATE_WMCONN)) { - chan->fsm_state = EICON_STATE_ACTIVE; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BCONN; - cmd.arg = chan->No; - if (p->norm > 34) { - sprintf(cmd.parm.num, "%d/(%d)", p->speed, p->norm); - } else { - sprintf(cmd.parm.num, "%d/%s", p->speed, connmsg[p->norm]); - } - ccard->interface.statcallb(&cmd); - } - eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DCD_ON time %d\n", chan->No, p->time); - eicon_log(ccard, 8, "idi_ind: Ch%d: %d %d %d %d\n", chan->No, - p->norm, p->options, p->speed, p->delay); - break; - case DSP_UDATA_INDICATION_CTS_OFF: - eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_CTS_OFF time %d\n", chan->No, p->time); - break; - case DSP_UDATA_INDICATION_CTS_ON: - eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_CTS_ON time %d\n", chan->No, p->time); - eicon_log(ccard, 8, "idi_ind: Ch%d: %d %d %d %d\n", chan->No, - p->norm, p->options, p->speed, p->delay); - break; - case DSP_UDATA_INDICATION_DISCONNECT: - eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DISCONNECT cause %d\n", chan->No, buffer[1]); - break; - case DSP_UDATA_INDICATION_DTMF_DIGITS_RECEIVED: - eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DTMF_REC '%c'\n", chan->No, - dtmf_code[buffer[1]]); - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_AUDIO; - cmd.parm.num[0] = ISDN_AUDIO_DTMF; - cmd.parm.num[1] = dtmf_code[buffer[1]]; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); - break; - default: - eicon_log(ccard, 8, "idi_ind: Ch%d: UNHANDLED UDATA Indication 0x%02x\n", chan->No, buffer[0]); - } -} - -void -eicon_parse_trace(eicon_card *ccard, unsigned char *buffer, int len) -{ - int i,j,n; - int buflen = len * 3 + 30; - char *p; - struct trace_s { - unsigned long time; - unsigned short size; - unsigned short code; - unsigned char data[1]; - } *q; - - if (!(p = kmalloc(buflen, GFP_ATOMIC))) { - eicon_log(ccard, 1, "idi_err: Ch??: could not allocate trace buffer\n"); - return; - } - memset(p, 0, buflen); - q = (struct trace_s *)buffer; - - if (DebugVar & 512) { - if ((q->code == 3) || (q->code == 4)) { - n = (short) *(q->data); - if (n) { - j = sprintf(p, "DTRC:"); - for (i = 0; i < n; i++) { - j += sprintf(p + j, "%02x ", q->data[i+2]); - } - j += sprintf(p + j, "\n"); - } - } - } else { - j = sprintf(p, "XLOG: %lx %04x %04x ", - q->time, q->size, q->code); - - for (i = 0; i < q->size; i++) { - j += sprintf(p + j, "%02x ", q->data[i]); - } - j += sprintf(p + j, "\n"); - } - if (strlen(p)) - eicon_putstatus(ccard, p); - kfree(p); -} - -void -idi_handle_ind(eicon_card *ccard, struct sk_buff *skb) -{ - int tmp; - char tnum[64]; - int dlev; - int free_buff; - ulong flags; - struct sk_buff *skb2; - eicon_IND *ind = (eicon_IND *)skb->data; - eicon_chan *chan; - idi_ind_message message; - isdn_ctrl cmd; - - if (!ccard) { - eicon_log(ccard, 1, "idi_err: Ch??: null card in handle_ind\n"); - dev_kfree_skb(skb); - return; - } - - if ((chan = ccard->IdTable[ind->IndId]) == NULL) { - eicon_log(ccard, 1, "idi_err: Ch??: null chan in handle_ind\n"); - dev_kfree_skb(skb); - return; - } - - if ((ind->Ind != 8) && (ind->Ind != 0xc)) - dlev = 144; - else - dlev = 128; - - eicon_log(ccard, dlev, "idi_hdl: Ch%d: Ind=%x Id=%x Ch=%x MInd=%x MLen=%x Len=%x\n", chan->No, - ind->Ind,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,ind->RBuffer.length); - - free_buff = 1; - /* Signal Layer */ - if (chan->e.D3Id == ind->IndId) { - idi_IndParse(ccard, chan, &message, ind->RBuffer.P, ind->RBuffer.length); - switch(ind->Ind) { - case HANGUP: - eicon_log(ccard, 8, "idi_ind: Ch%d: Hangup\n", chan->No); - while((skb2 = skb_dequeue(&chan->e.X))) { - dev_kfree_skb(skb2); - } - spin_lock_irqsave(&eicon_lock, flags); - chan->queued = 0; - chan->pqueued = 0; - chan->waitq = 0; - chan->waitpq = 0; - spin_unlock_irqrestore(&eicon_lock, flags); - if (message.e_cau[0] & 0x7f) { - cmd.driver = ccard->myid; - cmd.arg = chan->No; - sprintf(cmd.parm.num,"E%02x%02x", - chan->cause[0]&0x7f, message.e_cau[0]&0x7f); - cmd.command = ISDN_STAT_CAUSE; - ccard->interface.statcallb(&cmd); - } - chan->cause[0] = 0; - if (((chan->fsm_state == EICON_STATE_ACTIVE) || - (chan->fsm_state == EICON_STATE_WMCONN)) || - ((chan->l2prot == ISDN_PROTO_L2_FAX) && - (chan->fsm_state == EICON_STATE_OBWAIT))) { - chan->fsm_state = EICON_STATE_NULL; - } else { - if (chan->e.B2Id) - idi_do_req(ccard, chan, REMOVE, 1); - chan->statectrl &= ~WAITING_FOR_HANGUP; - chan->statectrl &= ~IN_HOLD; - if (chan->statectrl & HAVE_CONN_REQ) { - eicon_log(ccard, 32, "idi_req: Ch%d: queueing delayed conn_req\n", chan->No); - chan->statectrl &= ~HAVE_CONN_REQ; - if ((chan->tskb1) && (chan->tskb2)) { - skb_queue_tail(&chan->e.X, chan->tskb1); - skb_queue_tail(&ccard->sndq, chan->tskb2); - eicon_schedule_tx(ccard); - } - chan->tskb1 = NULL; - chan->tskb2 = NULL; - } else { - chan->fsm_state = EICON_STATE_NULL; - cmd.driver = ccard->myid; - cmd.arg = chan->No; - cmd.command = ISDN_STAT_DHUP; - ccard->interface.statcallb(&cmd); - eicon_idi_listen_req(ccard, chan); -#ifdef CONFIG_ISDN_TTY_FAX - chan->fax = 0; -#endif - } - } - break; - case INDICATE_IND: - eicon_log(ccard, 8, "idi_ind: Ch%d: Indicate_Ind\n", chan->No); - if (chan->fsm_state != EICON_STATE_LISTEN) { - eicon_log(ccard, 1, "idi_err: Ch%d: Incoming call on wrong state (%d).\n", - chan->No, chan->fsm_state); - idi_do_req(ccard, chan, HANGUP, 0); - break; - } - chan->fsm_state = EICON_STATE_ICALL; - idi_bc2si(message.bc, message.hlc, message.sin, &chan->si1, &chan->si2); - strcpy(chan->cpn, message.cpn + 1); - strcpy(chan->oad, message.oad); - strcpy(chan->dsa, message.dsa); - strcpy(chan->osa, message.osa); - chan->plan = message.plan; - chan->screen = message.screen; - try_stat_icall_again: - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_ICALL; - cmd.arg = chan->No; - cmd.parm.setup.si1 = chan->si1; - cmd.parm.setup.si2 = chan->si2; - strcpy(tnum, chan->cpn); - if (strlen(chan->dsa)) { - strcat(tnum, "."); - strcat(tnum, chan->dsa); - } - tnum[ISDN_MSNLEN - 1] = 0; - strcpy(cmd.parm.setup.eazmsn, tnum); - strcpy(tnum, chan->oad); - if (strlen(chan->osa)) { - strcat(tnum, "."); - strcat(tnum, chan->osa); - } - tnum[ISDN_MSNLEN - 1] = 0; - strcpy(cmd.parm.setup.phone, tnum); - cmd.parm.setup.plan = chan->plan; - cmd.parm.setup.screen = chan->screen; - tmp = ccard->interface.statcallb(&cmd); - switch(tmp) { - case 0: /* no user responding */ - idi_do_req(ccard, chan, HANGUP, 0); - chan->fsm_state = EICON_STATE_NULL; - break; - case 1: /* alert */ - eicon_log(ccard, 8, "idi_req: Ch%d: Call Alert\n", chan->No); - if ((chan->fsm_state == EICON_STATE_ICALL) || (chan->fsm_state == EICON_STATE_ICALLW)) { - chan->fsm_state = EICON_STATE_ICALL; - idi_do_req(ccard, chan, CALL_ALERT, 0); - } - break; - case 2: /* reject */ - eicon_log(ccard, 8, "idi_req: Ch%d: Call Reject\n", chan->No); - idi_do_req(ccard, chan, REJECT, 0); - break; - case 3: /* incomplete number */ - eicon_log(ccard, 8, "idi_req: Ch%d: Incomplete Number\n", chan->No); - chan->fsm_state = EICON_STATE_ICALLW; - break; - } - break; - case INFO_IND: - eicon_log(ccard, 8, "idi_ind: Ch%d: Info_Ind\n", chan->No); - if ((chan->fsm_state == EICON_STATE_ICALLW) && - (message.cpn[0])) { - strcat(chan->cpn, message.cpn + 1); - goto try_stat_icall_again; - } - break; - case CALL_IND: - eicon_log(ccard, 8, "idi_ind: Ch%d: Call_Ind\n", chan->No); - if ((chan->fsm_state == EICON_STATE_ICALL) || (chan->fsm_state == EICON_STATE_IWAIT)) { - chan->fsm_state = EICON_STATE_IBWAIT; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_DCONN; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); - switch(chan->l2prot) { - case ISDN_PROTO_L2_FAX: -#ifdef CONFIG_ISDN_TTY_FAX - if (chan->fax) - chan->fax->phase = ISDN_FAX_PHASE_A; -#endif - break; - case ISDN_PROTO_L2_MODEM: - /* do nothing, wait for connect */ - break; - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: - case ISDN_PROTO_L2_TRANS: - idi_do_req(ccard, chan, N_CONNECT, 1); - break; - default:; - /* On most incoming calls we use automatic connect */ - /* idi_do_req(ccard, chan, N_CONNECT, 1); */ - } - } else { - if (chan->fsm_state != EICON_STATE_ACTIVE) - idi_hangup(ccard, chan); - } - break; - case CALL_CON: - eicon_log(ccard, 8, "idi_ind: Ch%d: Call_Con\n", chan->No); - if (chan->fsm_state == EICON_STATE_OCALL) { - /* check if old NetID has been removed */ - if (chan->e.B2Id) { - eicon_log(ccard, 1, "eicon: Ch%d: old net_id %x still exist, removing.\n", - chan->No, chan->e.B2Id); - idi_do_req(ccard, chan, REMOVE, 1); - } -#ifdef CONFIG_ISDN_TTY_FAX - if (chan->l2prot == ISDN_PROTO_L2_FAX) { - if (chan->fax) { - chan->fax->phase = ISDN_FAX_PHASE_A; - } else { - eicon_log(ccard, 1, "idi_ind: Call_Con with NULL fax struct, ERROR\n"); - idi_hangup(ccard, chan); - break; - } - } -#endif - chan->fsm_state = EICON_STATE_OBWAIT; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_DCONN; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); - - idi_do_req(ccard, chan, ASSIGN, 1); - idi_do_req(ccard, chan, N_CONNECT, 1); - } else - idi_hangup(ccard, chan); - break; - case AOC_IND: - eicon_log(ccard, 8, "idi_ind: Ch%d: Advice of Charge\n", chan->No); - break; - case CALL_HOLD_ACK: - chan->statectrl |= IN_HOLD; - eicon_log(ccard, 8, "idi_ind: Ch%d: Call Hold Ack\n", chan->No); - break; - case SUSPEND_REJ: - eicon_log(ccard, 8, "idi_ind: Ch%d: Suspend Rejected\n", chan->No); - break; - case SUSPEND: - eicon_log(ccard, 8, "idi_ind: Ch%d: Suspend Ack\n", chan->No); - break; - case RESUME: - eicon_log(ccard, 8, "idi_ind: Ch%d: Resume Ack\n", chan->No); - break; - default: - eicon_log(ccard, 8, "idi_ind: Ch%d: UNHANDLED SigIndication 0x%02x\n", chan->No, ind->Ind); - } - } - /* Network Layer */ - else if (chan->e.B2Id == ind->IndId) { - - if (chan->No == ccard->nchannels) { - /* Management Indication */ - if (ind->Ind == 0x04) { /* Trace_Ind */ - eicon_parse_trace(ccard, ind->RBuffer.P, ind->RBuffer.length); - } else { - idi_IndParse(ccard, chan, &message, ind->RBuffer.P, ind->RBuffer.length); - chan->fsm_state = 1; - } - } - else - switch(ind->Ind) { - case N_CONNECT_ACK: - eicon_log(ccard, 16, "idi_ind: Ch%d: N_Connect_Ack\n", chan->No); - if (chan->l2prot == ISDN_PROTO_L2_MODEM) { - chan->fsm_state = EICON_STATE_WMCONN; - break; - } - if (chan->l2prot == ISDN_PROTO_L2_FAX) { -#ifdef CONFIG_ISDN_TTY_FAX - chan->fsm_state = EICON_STATE_ACTIVE; - idi_parse_edata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length); - if (chan->fax) { - if (chan->fax->phase == ISDN_FAX_PHASE_B) { - idi_fax_send_header(ccard, chan, 2); - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_DCS; - ccard->interface.statcallb(&cmd); - } - } - else { - eicon_log(ccard, 1, "idi_ind: N_Connect_Ack with NULL fax struct, ERROR\n"); - } -#endif - break; - } - chan->fsm_state = EICON_STATE_ACTIVE; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BCONN; - cmd.arg = chan->No; - strcpy(cmd.parm.num, "64000"); - ccard->interface.statcallb(&cmd); - break; - case N_CONNECT: - eicon_log(ccard, 16,"idi_ind: Ch%d: N_Connect\n", chan->No); - chan->e.IndCh = ind->IndCh; - if (chan->e.B2Id) idi_do_req(ccard, chan, N_CONNECT_ACK, 1); - if (chan->l2prot == ISDN_PROTO_L2_FAX) { - break; - } - if (chan->l2prot == ISDN_PROTO_L2_MODEM) { - chan->fsm_state = EICON_STATE_WMCONN; - break; - } - chan->fsm_state = EICON_STATE_ACTIVE; - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BCONN; - cmd.arg = chan->No; - strcpy(cmd.parm.num, "64000"); - ccard->interface.statcallb(&cmd); - break; - case N_DISC: - eicon_log(ccard, 16, "idi_ind: Ch%d: N_Disc\n", chan->No); - if (chan->e.B2Id) { - while((skb2 = skb_dequeue(&chan->e.X))) { - dev_kfree_skb(skb2); - } - idi_do_req(ccard, chan, N_DISC_ACK, 1); - idi_do_req(ccard, chan, REMOVE, 1); - } -#ifdef CONFIG_ISDN_TTY_FAX - if ((chan->l2prot == ISDN_PROTO_L2_FAX) && (chan->fax)){ - idi_parse_edata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length); - idi_fax_hangup(ccard, chan); - } -#endif - chan->e.IndCh = 0; - spin_lock_irqsave(&eicon_lock, flags); - chan->queued = 0; - chan->pqueued = 0; - chan->waitq = 0; - chan->waitpq = 0; - spin_unlock_irqrestore(&eicon_lock, flags); - if (!(chan->statectrl & IN_HOLD)) { - idi_do_req(ccard, chan, HANGUP, 0); - } - if (chan->fsm_state == EICON_STATE_ACTIVE) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BHUP; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); - chan->fsm_state = EICON_STATE_NULL; - if (!(chan->statectrl & IN_HOLD)) { - chan->statectrl |= WAITING_FOR_HANGUP; - } - } -#ifdef CONFIG_ISDN_TTY_FAX - chan->fax = 0; -#endif - break; - case N_DISC_ACK: - eicon_log(ccard, 16, "idi_ind: Ch%d: N_Disc_Ack\n", chan->No); -#ifdef CONFIG_ISDN_TTY_FAX - if (chan->l2prot == ISDN_PROTO_L2_FAX) { - idi_parse_edata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length); - idi_fax_hangup(ccard, chan); - } -#endif - break; - case N_DATA_ACK: - eicon_log(ccard, 128, "idi_ind: Ch%d: N_Data_Ack\n", chan->No); - break; - case N_DATA: - skb_pull(skb, sizeof(eicon_IND) - 1); - eicon_log(ccard, 128, "idi_rcv: Ch%d: %d bytes\n", chan->No, skb->len); - if (chan->l2prot == ISDN_PROTO_L2_FAX) { -#ifdef CONFIG_ISDN_TTY_FAX - idi_faxdata_rcv(ccard, chan, skb); -#endif - } else { - ccard->interface.rcvcallb_skb(ccard->myid, chan->No, skb); - free_buff = 0; - } - break; - case N_UDATA: - idi_parse_udata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length); - break; -#ifdef CONFIG_ISDN_TTY_FAX - case N_EDATA: - idi_edata_action(ccard, chan, ind->RBuffer.P, ind->RBuffer.length); - break; -#endif - default: - eicon_log(ccard, 8, "idi_ind: Ch%d: UNHANDLED NetIndication 0x%02x\n", chan->No, ind->Ind); - } - } - else { - eicon_log(ccard, 1, "idi_ind: Ch%d: Ind is neither SIG nor NET !\n", chan->No); - } - if (free_buff) - dev_kfree_skb(skb); -} - -int -idi_handle_ack_ok(eicon_card *ccard, eicon_chan *chan, eicon_RC *ack) -{ - ulong flags; - isdn_ctrl cmd; - int tqueued = 0; - int twaitpq = 0; - - if (ack->RcId != ((chan->e.ReqCh) ? chan->e.B2Id : chan->e.D3Id)) { - /* I don't know why this happens, should not ! */ - /* just ignoring this RC */ - eicon_log(ccard, 16, "idi_ack: Ch%d: RcId %d not equal to last %d\n", chan->No, - ack->RcId, (chan->e.ReqCh) ? chan->e.B2Id : chan->e.D3Id); - return 1; - } - - /* Management Interface */ - if (chan->No == ccard->nchannels) { - /* Managementinterface: changing state */ - if (chan->e.Req != 0x02) - chan->fsm_state = 1; - } - - /* Remove an Id */ - if (chan->e.Req == REMOVE) { - if (ack->Reference != chan->e.ref) { - /* This should not happen anymore */ - eicon_log(ccard, 16, "idi_ack: Ch%d: Rc-Ref %d not equal to stored %d\n", chan->No, - ack->Reference, chan->e.ref); - } - spin_lock_irqsave(&eicon_lock, flags); - ccard->IdTable[ack->RcId] = NULL; - if (!chan->e.ReqCh) - chan->e.D3Id = 0; - else - chan->e.B2Id = 0; - spin_unlock_irqrestore(&eicon_lock, flags); - eicon_log(ccard, 16, "idi_ack: Ch%d: Removed : Id=%x Ch=%d (%s)\n", chan->No, - ack->RcId, ack->RcCh, (chan->e.ReqCh)? "Net":"Sig"); - return 1; - } - - /* Signal layer */ - if (!chan->e.ReqCh) { - eicon_log(ccard, 16, "idi_ack: Ch%d: RC OK Id=%x Ch=%d (ref:%d)\n", chan->No, - ack->RcId, ack->RcCh, ack->Reference); - } else { - /* Network layer */ - switch(chan->e.Req & 0x0f) { - case N_CONNECT: - chan->e.IndCh = ack->RcCh; - eicon_log(ccard, 16, "idi_ack: Ch%d: RC OK Id=%x Ch=%d (ref:%d)\n", chan->No, - ack->RcId, ack->RcCh, ack->Reference); - break; - case N_MDATA: - case N_DATA: - tqueued = chan->queued; - twaitpq = chan->waitpq; - if ((chan->e.Req & 0x0f) == N_DATA) { - spin_lock_irqsave(&eicon_lock, flags); - chan->waitpq = 0; - if(chan->pqueued) - chan->pqueued--; - spin_unlock_irqrestore(&eicon_lock, flags); -#ifdef CONFIG_ISDN_TTY_FAX - if (chan->l2prot == ISDN_PROTO_L2_FAX) { - if (((chan->queued - chan->waitq) < 1) && - (chan->fax2.Eop)) { - chan->fax2.Eop = 0; - if (chan->fax) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_FAXIND; - cmd.arg = chan->No; - chan->fax->r_code = ISDN_TTY_FAX_SENT; - ccard->interface.statcallb(&cmd); - } - else { - eicon_log(ccard, 1, "idi_ack: Sent with NULL fax struct, ERROR\n"); - } - } - } -#endif - } - spin_lock_irqsave(&eicon_lock, flags); - chan->queued -= chan->waitq; - if (chan->queued < 0) chan->queued = 0; - spin_unlock_irqrestore(&eicon_lock, flags); - if (((chan->e.Req & 0x0f) == N_DATA) && (tqueued)) { - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_BSENT; - cmd.arg = chan->No; - cmd.parm.length = twaitpq; - ccard->interface.statcallb(&cmd); - } - break; - default: - eicon_log(ccard, 16, "idi_ack: Ch%d: RC OK Id=%x Ch=%d (ref:%d)\n", chan->No, - ack->RcId, ack->RcCh, ack->Reference); - } - } - return 1; -} - -void -idi_handle_ack(eicon_card *ccard, struct sk_buff *skb) -{ - int j; - ulong flags; - eicon_RC *ack = (eicon_RC *)skb->data; - eicon_chan *chan; - isdn_ctrl cmd; - int dCh = -1; - - if (!ccard) { - eicon_log(ccard, 1, "idi_err: Ch??: null card in handle_ack\n"); - dev_kfree_skb(skb); - return; - } - - spin_lock_irqsave(&eicon_lock, flags); - if ((chan = ccard->IdTable[ack->RcId]) != NULL) - dCh = chan->No; - spin_unlock_irqrestore(&eicon_lock, flags); - - switch (ack->Rc) { - case OK_FC: - case N_FLOW_CONTROL: - case ASSIGN_RC: - eicon_log(ccard, 1, "idi_ack: Ch%d: unhandled RC 0x%x\n", - dCh, ack->Rc); - break; - case READY_INT: - case TIMER_INT: - /* we do nothing here */ - break; - - case OK: - if (!chan) { - eicon_log(ccard, 1, "idi_ack: Ch%d: OK on chan without Id\n", dCh); - break; - } - if (!idi_handle_ack_ok(ccard, chan, ack)) - chan = NULL; - break; - - case ASSIGN_OK: - if (chan) { - eicon_log(ccard, 1, "idi_ack: Ch%d: ASSIGN-OK on chan already assigned (%x,%x)\n", - chan->No, chan->e.D3Id, chan->e.B2Id); - } - spin_lock_irqsave(&eicon_lock, flags); - for(j = 0; j < ccard->nchannels + 1; j++) { - if ((ccard->bch[j].e.ref == ack->Reference) && - (ccard->bch[j].e.Req == ASSIGN)) { - if (!ccard->bch[j].e.ReqCh) - ccard->bch[j].e.D3Id = ack->RcId; - else - ccard->bch[j].e.B2Id = ack->RcId; - ccard->IdTable[ack->RcId] = &ccard->bch[j]; - chan = &ccard->bch[j]; - break; - } - } - spin_unlock_irqrestore(&eicon_lock, flags); - eicon_log(ccard, 16, "idi_ack: Ch%d: Id %x assigned (%s)\n", j, - ack->RcId, (ccard->bch[j].e.ReqCh)? "Net":"Sig"); - if (j > ccard->nchannels) { - eicon_log(ccard, 24, "idi_ack: Ch??: ref %d not found for Id %d\n", - ack->Reference, ack->RcId); - } - break; - - case OUT_OF_RESOURCES: - case UNKNOWN_COMMAND: - case WRONG_COMMAND: - case WRONG_ID: - case ADAPTER_DEAD: - case WRONG_CH: - case UNKNOWN_IE: - case WRONG_IE: - default: - if (!chan) { - eicon_log(ccard, 1, "idi_ack: Ch%d: Not OK !! on chan without Id\n", dCh); - break; - } else - switch (chan->e.Req) { - case 12: /* Alert */ - eicon_log(ccard, 2, "eicon_err: Ch%d: Alert Not OK : Rc=%d Id=%x Ch=%d\n", - dCh, ack->Rc, ack->RcId, ack->RcCh); - break; - default: - if (dCh != ccard->nchannels) - eicon_log(ccard, 1, "eicon_err: Ch%d: Ack Not OK !!: Rc=%d Id=%x Ch=%d Req=%d\n", - dCh, ack->Rc, ack->RcId, ack->RcCh, chan->e.Req); - } - if (dCh == ccard->nchannels) { /* Management */ - chan->fsm_state = 2; - eicon_log(ccard, 8, "eicon_err: Ch%d: Ack Not OK !!: Rc=%d Id=%x Ch=%d Req=%d\n", - dCh, ack->Rc, ack->RcId, ack->RcCh, chan->e.Req); - } else if (dCh >= 0) { - /* any other channel */ - /* card reports error: we hangup */ - idi_hangup(ccard, chan); - cmd.driver = ccard->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg = chan->No; - ccard->interface.statcallb(&cmd); - } - } - spin_lock_irqsave(&eicon_lock, flags); - if (chan) { - chan->e.ref = 0; - chan->e.busy = 0; - } - spin_unlock_irqrestore(&eicon_lock, flags); - dev_kfree_skb(skb); - eicon_schedule_tx(ccard); -} - -int -idi_send_data(eicon_card *card, eicon_chan *chan, int ack, struct sk_buff *skb, int que, int chk) -{ - struct sk_buff *xmit_skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan_ptr *chan2; - int len, plen = 0, offset = 0; - unsigned long flags; - - if ((!card) || (!chan)) { - eicon_log(card, 1, "idi_err: Ch??: null card/chan in send_data\n"); - return -1; - } - - if (chan->fsm_state != EICON_STATE_ACTIVE) { - eicon_log(card, 1, "idi_snd: Ch%d: send bytes on state %d !\n", chan->No, chan->fsm_state); - return -ENODEV; - } - - len = skb->len; - if (len > EICON_MAX_QUEUE) /* too much for the shared memory */ - return -1; - if (!len) - return 0; - - if ((chk) && (chan->pqueued > 1)) - return 0; - - eicon_log(card, 128, "idi_snd: Ch%d: %d bytes (Pqueue=%d)\n", - chan->No, len, chan->pqueued); - - spin_lock_irqsave(&eicon_lock, flags); - while(offset < len) { - - plen = ((len - offset) > 270) ? 270 : len - offset; - - xmit_skb = alloc_skb(plen + sizeof(eicon_REQ), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!xmit_skb) || (!skb2)) { - spin_unlock_irqrestore(&eicon_lock, flags); - eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in send_data()\n", chan->No); - if (xmit_skb) - dev_kfree_skb(xmit_skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(xmit_skb, plen + sizeof(eicon_REQ)); - if ((len - offset) > 270) { - reqbuf->Req = N_MDATA; - } else { - reqbuf->Req = N_DATA; - /* if (ack) reqbuf->Req |= N_D_BIT; */ - } - reqbuf->ReqCh = chan->e.IndCh; - reqbuf->ReqId = 1; - memcpy(&reqbuf->XBuffer.P, skb->data + offset, plen); - reqbuf->XBuffer.length = plen; - reqbuf->Reference = 1; /* Net Entity */ - - skb_queue_tail(&chan->e.X, xmit_skb); - skb_queue_tail(&card->sndq, skb2); - - offset += plen; - } - if (que) { - chan->queued += len; - chan->pqueued++; - } - spin_unlock_irqrestore(&eicon_lock, flags); - eicon_schedule_tx(card); - dev_kfree_skb(skb); - return len; -} - - -int -eicon_idi_manage_assign(eicon_card *card) -{ - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan *chan; - eicon_chan_ptr *chan2; - - chan = &(card->bch[card->nchannels]); - - skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err: alloc_skb failed in manage_assign()\n"); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ)); - - reqbuf->XBuffer.P[0] = 0; - reqbuf->Req = ASSIGN; - reqbuf->ReqCh = 0; - reqbuf->ReqId = MAN_ID; - reqbuf->XBuffer.length = 1; - reqbuf->Reference = 2; /* Man Entity */ - - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - eicon_schedule_tx(card); - return(0); -} - - -int -eicon_idi_manage_remove(eicon_card *card) -{ - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan *chan; - eicon_chan_ptr *chan2; - - chan = &(card->bch[card->nchannels]); - - skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err: alloc_skb failed in manage_remove()\n"); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ)); - - reqbuf->Req = REMOVE; - reqbuf->ReqCh = 0; - reqbuf->ReqId = 1; - reqbuf->XBuffer.length = 0; - reqbuf->Reference = 2; /* Man Entity */ - - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - eicon_schedule_tx(card); - return(0); -} - - -int -eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb) -{ - int l = 0; - int ret = 0; - unsigned long timeout; - int i; - struct sk_buff *skb; - struct sk_buff *skb2; - eicon_REQ *reqbuf; - eicon_chan *chan; - eicon_chan_ptr *chan2; - - chan = &(card->bch[card->nchannels]); - - if (!(chan->e.D3Id)) { - chan->e.D3Id = 1; - while((skb2 = skb_dequeue(&chan->e.X))) - dev_kfree_skb(skb2); - chan->e.busy = 0; - - if ((ret = eicon_idi_manage_assign(card))) { - chan->e.D3Id = 0; - return(ret); - } - - timeout = jiffies + HZ / 2; - while (time_before(jiffies, timeout)) { - if (chan->e.B2Id) break; - SLEEP(10); - } - if (!chan->e.B2Id) { - chan->e.D3Id = 0; - return -EIO; - } - } - - chan->fsm_state = 0; - - if (!(manbuf = kmalloc(sizeof(eicon_manifbuf), GFP_KERNEL))) { - eicon_log(card, 1, "idi_err: alloc_manifbuf failed\n"); - return -ENOMEM; - } - if (copy_from_user(manbuf, mb, sizeof(eicon_manifbuf))) { - kfree(manbuf); - return -EFAULT; - } - - skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC); - skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC); - - if ((!skb) || (!skb2)) { - eicon_log(card, 1, "idi_err_manif: alloc_skb failed in manage()\n"); - if (skb) - dev_kfree_skb(skb); - if (skb2) - dev_kfree_skb(skb2); - kfree(manbuf); - return -ENOMEM; - } - - chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr)); - chan2->ptr = chan; - - reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ)); - - reqbuf->XBuffer.P[l++] = ESC; - reqbuf->XBuffer.P[l++] = 6; - reqbuf->XBuffer.P[l++] = 0x80; - for (i = 0; i < manbuf->length[0]; i++) - reqbuf->XBuffer.P[l++] = manbuf->data[i]; - reqbuf->XBuffer.P[1] = manbuf->length[0] + 1; - - reqbuf->XBuffer.P[l++] = 0; - reqbuf->Req = (manbuf->count) ? manbuf->count : MAN_READ; - reqbuf->ReqCh = 0; - reqbuf->ReqId = 1; - reqbuf->XBuffer.length = l; - reqbuf->Reference = 2; /* Man Entity */ - - skb_queue_tail(&chan->e.X, skb); - skb_queue_tail(&card->sndq, skb2); - - manbuf->count = 0; - manbuf->pos = 0; - - eicon_schedule_tx(card); - - timeout = jiffies + HZ / 2; - while (time_before(jiffies, timeout)) { - if (chan->fsm_state) break; - SLEEP(10); - } - if ((!chan->fsm_state) || (chan->fsm_state == 2)) { - kfree(manbuf); - return -EIO; - } - if (copy_to_user(mb, manbuf, sizeof(eicon_manifbuf))) { - kfree(manbuf); - return -EFAULT; - } - - kfree(manbuf); - return(0); -} diff --git a/drivers/isdn/eicon/eicon_idi.h b/drivers/isdn/eicon/eicon_idi.h deleted file mode 100644 index d39484be78ce..000000000000 --- a/drivers/isdn/eicon/eicon_idi.h +++ /dev/null @@ -1,119 +0,0 @@ -/* $Id: eicon_idi.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $ - * - * ISDN lowlevel-module for the Eicon active cards. - * IDI-Interface - * - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef E_IDI_H -#define E_IDI_H - -#include <linux/config.h> - -#undef N_DATA -#undef ID_MASK - -#include "pc.h" - -#define AOC_IND 26 /* Advice of Charge */ -#define PI 0x1e /* Progress Indicator */ -#define NI 0x27 /* Notification Indicator */ - -#define CALL_HOLD 0x22 -#define CALL_HOLD_ACK 0x24 - -/* defines for statectrl */ -#define WAITING_FOR_HANGUP 0x01 -#define HAVE_CONN_REQ 0x02 -#define IN_HOLD 0x04 - -typedef struct { - char cpn[32]; - char oad[32]; - char dsa[32]; - char osa[32]; - __u8 plan; - __u8 screen; - __u8 sin[4]; - __u8 chi[4]; - __u8 e_chi[4]; - __u8 bc[12]; - __u8 e_bc[12]; - __u8 llc[18]; - __u8 hlc[5]; - __u8 cau[4]; - __u8 e_cau[2]; - __u8 e_mt; - __u8 dt[6]; - char display[83]; - char keypad[35]; - char rdn[32]; -} idi_ind_message; - -typedef struct { - __u16 next __attribute__ ((packed)); - __u8 Req __attribute__ ((packed)); - __u8 ReqId __attribute__ ((packed)); - __u8 ReqCh __attribute__ ((packed)); - __u8 Reserved1 __attribute__ ((packed)); - __u16 Reference __attribute__ ((packed)); - __u8 Reserved[8] __attribute__ ((packed)); - eicon_PBUFFER XBuffer; -} eicon_REQ; - -typedef struct { - __u16 next __attribute__ ((packed)); - __u8 Rc __attribute__ ((packed)); - __u8 RcId __attribute__ ((packed)); - __u8 RcCh __attribute__ ((packed)); - __u8 Reserved1 __attribute__ ((packed)); - __u16 Reference __attribute__ ((packed)); - __u8 Reserved2[8] __attribute__ ((packed)); -} eicon_RC; - -typedef struct { - __u16 next __attribute__ ((packed)); - __u8 Ind __attribute__ ((packed)); - __u8 IndId __attribute__ ((packed)); - __u8 IndCh __attribute__ ((packed)); - __u8 MInd __attribute__ ((packed)); - __u16 MLength __attribute__ ((packed)); - __u16 Reference __attribute__ ((packed)); - __u8 RNR __attribute__ ((packed)); - __u8 Reserved __attribute__ ((packed)); - __u32 Ack __attribute__ ((packed)); - eicon_PBUFFER RBuffer; -} eicon_IND; - -typedef struct { - __u8 *Data; - unsigned int Size; - unsigned int Len; - __u8 *Next; -} eicon_OBJBUFFER; - -extern int idi_do_req(eicon_card *card, eicon_chan *chan, int cmd, int layer); -extern int idi_hangup(eicon_card *card, eicon_chan *chan); -extern int idi_connect_res(eicon_card *card, eicon_chan *chan); -extern int eicon_idi_listen_req(eicon_card *card, eicon_chan *chan); -extern int idi_connect_req(eicon_card *card, eicon_chan *chan, char *phone, - char *eazmsn, int si1, int si2); - -extern void idi_handle_ack(eicon_card *card, struct sk_buff *skb); -extern void idi_handle_ind(eicon_card *card, struct sk_buff *skb); -extern int eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb); -extern int idi_send_data(eicon_card *card, eicon_chan *chan, int ack, struct sk_buff *skb, int que, int chk); -extern void idi_audio_cmd(eicon_card *ccard, eicon_chan *chan, int cmd, u_char *value); -extern int capipmsg(eicon_card *card, eicon_chan *chan, capi_msg *cm); -#ifdef CONFIG_ISDN_TTY_FAX -extern void idi_fax_cmd(eicon_card *card, eicon_chan *chan); -extern int idi_faxdata_send(eicon_card *ccard, eicon_chan *chan, struct sk_buff *skb); -#endif - -#endif diff --git a/drivers/isdn/eicon/eicon_io.c b/drivers/isdn/eicon/eicon_io.c deleted file mode 100644 index 2da72309e0e4..000000000000 --- a/drivers/isdn/eicon/eicon_io.c +++ /dev/null @@ -1,749 +0,0 @@ -/* $Id: eicon_io.c,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * Code for communicating with hardware. - * - * Copyright 1999,2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - * Thanks to Eicon Networks for - * documents, informations and hardware. - * - */ - -#include <linux/config.h> -#include "eicon.h" -#include "uxio.h" - -void -eicon_io_rcv_dispatch(eicon_card *ccard) { - ulong flags; - struct sk_buff *skb, *skb2, *skb_new; - eicon_IND *ind, *ind2, *ind_new; - eicon_chan *chan; - - if (!ccard) { - eicon_log(ccard, 1, "eicon_err: NULL card in rcv_dispatch !\n"); - return; - } - - while((skb = skb_dequeue(&ccard->rcvq))) { - ind = (eicon_IND *)skb->data; - - spin_lock_irqsave(&eicon_lock, flags); - if ((chan = ccard->IdTable[ind->IndId]) == NULL) { - spin_unlock_irqrestore(&eicon_lock, flags); - if (DebugVar & 1) { - switch(ind->Ind) { - case N_DISC_ACK: - /* doesn't matter if this happens */ - break; - default: - eicon_log(ccard, 1, "idi: Indication for unknown channel Ind=%d Id=%x\n", ind->Ind, ind->IndId); - eicon_log(ccard, 1, "idi_hdl: Ch??: Ind=%d Id=%x Ch=%d MInd=%d MLen=%d Len=%d\n", - ind->Ind,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,ind->RBuffer.length); - } - } - dev_kfree_skb(skb); - continue; - } - spin_unlock_irqrestore(&eicon_lock, flags); - - if (chan->e.complete) { /* check for rec-buffer chaining */ - if (ind->MLength == ind->RBuffer.length) { - chan->e.complete = 1; - idi_handle_ind(ccard, skb); - continue; - } - else { - chan->e.complete = 0; - ind->Ind = ind->MInd; - skb_queue_tail(&chan->e.R, skb); - continue; - } - } - else { - if (!(skb2 = skb_dequeue(&chan->e.R))) { - chan->e.complete = 1; - eicon_log(ccard, 1, "eicon: buffer incomplete, but 0 in queue\n"); - dev_kfree_skb(skb); - continue; - } - ind2 = (eicon_IND *)skb2->data; - skb_new = alloc_skb(((sizeof(eicon_IND)-1)+ind->RBuffer.length+ind2->RBuffer.length), - GFP_ATOMIC); - if (!skb_new) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in rcv_dispatch()\n"); - dev_kfree_skb(skb); - dev_kfree_skb(skb2); - continue; - } - ind_new = (eicon_IND *)skb_put(skb_new, - ((sizeof(eicon_IND)-1)+ind->RBuffer.length+ind2->RBuffer.length)); - ind_new->Ind = ind2->Ind; - ind_new->IndId = ind2->IndId; - ind_new->IndCh = ind2->IndCh; - ind_new->MInd = ind2->MInd; - ind_new->MLength = ind2->MLength; - ind_new->RBuffer.length = ind2->RBuffer.length + ind->RBuffer.length; - memcpy(&ind_new->RBuffer.P, &ind2->RBuffer.P, ind2->RBuffer.length); - memcpy((&ind_new->RBuffer.P)+ind2->RBuffer.length, &ind->RBuffer.P, ind->RBuffer.length); - dev_kfree_skb(skb); - dev_kfree_skb(skb2); - if (ind->MLength == ind->RBuffer.length) { - chan->e.complete = 2; - idi_handle_ind(ccard, skb_new); - continue; - } - else { - chan->e.complete = 0; - skb_queue_tail(&chan->e.R, skb_new); - continue; - } - } - } -} - -void -eicon_io_ack_dispatch(eicon_card *ccard) { - struct sk_buff *skb; - - if (!ccard) { - eicon_log(ccard, 1, "eicon_err: NULL card in ack_dispatch!\n"); - return; - } - while((skb = skb_dequeue(&ccard->rackq))) { - idi_handle_ack(ccard, skb); - } -} - - -/* - * IO-Functions for ISA cards - */ - -u8 ram_inb(eicon_card *card, void *adr) { - u32 addr = (u32) adr; - - return(readb(addr)); -} - -u16 ram_inw(eicon_card *card, void *adr) { - u32 addr = (u32) adr; - - return(readw(addr)); -} - -void ram_outb(eicon_card *card, void *adr, u8 data) { - u32 addr = (u32) adr; - - writeb(data, addr); -} - -void ram_outw(eicon_card *card, void *adr , u16 data) { - u32 addr = (u32) adr; - - writew(data, addr); -} - -void ram_copyfromcard(eicon_card *card, void *adrto, void *adr, int len) { - memcpy_fromio(adrto, adr, len); -} - -void ram_copytocard(eicon_card *card, void *adrto, void *adr, int len) { - memcpy_toio(adrto, adr, len); -} - - -#ifdef CONFIG_ISDN_DRV_EICON_PCI -/* - * IDI-Callback function - */ -void -eicon_idi_callback(ENTITY *de) -{ - eicon_card *ccard = (eicon_card *)de->R; - struct sk_buff *skb; - eicon_RC *ack; - eicon_IND *ind; - int len = 0; - - if (de->complete == 255) { - /* Return Code */ - skb = alloc_skb(sizeof(eicon_RC), GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _idi_callback()\n"); - } else { - ack = (eicon_RC *)skb_put(skb, sizeof(eicon_RC)); - ack->Rc = de->Rc; - if (de->Rc == ASSIGN_OK) { - ack->RcId = de->Id; - de->user[1] = de->Id; - } else { - ack->RcId = de->user[1]; - } - ack->RcCh = de->RcCh; - ack->Reference = de->user[0]; - skb_queue_tail(&ccard->rackq, skb); - eicon_schedule_ack(ccard); - eicon_log(ccard, 128, "idi_cbk: Ch%d: Rc=%x Id=%x RLen=%x compl=%x\n", - de->user[0], de->Rc, ack->RcId, de->RLength, de->complete); - } - } else { - /* Indication */ - if (de->complete) { - len = de->RLength; - } else { - len = 270; - if (de->RLength <= 270) - eicon_log(ccard, 1, "eicon_cbk: ind not complete but <= 270\n"); - } - skb = alloc_skb((sizeof(eicon_IND) + len - 1), GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _idi_callback()\n"); - } else { - ind = (eicon_IND *)skb_put(skb, (sizeof(eicon_IND) + len - 1)); - ind->Ind = de->Ind; - ind->IndId = de->user[1]; - ind->IndCh = de->IndCh; - ind->MInd = de->Ind; - ind->RBuffer.length = len; - ind->MLength = de->RLength; - memcpy(&ind->RBuffer.P, &de->RBuffer->P, len); - skb_queue_tail(&ccard->rcvq, skb); - eicon_schedule_rx(ccard); - eicon_log(ccard, 128, "idi_cbk: Ch%d: Ind=%x Id=%x RLen=%x compl=%x\n", - de->user[0], de->Ind, ind->IndId, de->RLength, de->complete); - } - } - - de->RNum = 0; - de->RNR = 0; - de->Rc = 0; - de->Ind = 0; -} -#endif /* CONFIG_ISDN_DRV_EICON_PCI */ - -/* - * Transmit-Function - */ -void -eicon_io_transmit(eicon_card *ccard) { - eicon_isa_card *isa_card; - struct sk_buff *skb; - struct sk_buff *skb2; - unsigned long flags; - eicon_pr_ram *prram = 0; - eicon_isa_com *com = 0; - eicon_REQ *ReqOut = 0; - eicon_REQ *reqbuf = 0; - eicon_chan *chan; - eicon_chan_ptr *chan2; - int ReqCount; - int scom = 0; - int tmp = 0; - int tmpid = 0; - int quloop = 1; - int dlev = 0; - ENTITY *ep = 0; - - isa_card = &ccard->hwif.isa; - - if (!ccard) { - eicon_log(ccard, 1, "eicon_transmit: NULL card!\n"); - return; - } - - switch(ccard->type) { -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_QUADRO: - scom = 1; - com = (eicon_isa_com *)isa_card->shmem; - break; - case EICON_CTYPE_S2M: - scom = 0; - prram = (eicon_pr_ram *)isa_card->shmem; - break; -#endif -#ifdef CONFIG_ISDN_DRV_EICON_PCI - case EICON_CTYPE_MAESTRAP: - scom = 2; - break; - case EICON_CTYPE_MAESTRAQ: - scom = 2; - break; - case EICON_CTYPE_MAESTRA: - scom = 2; - break; -#endif - default: - eicon_log(ccard, 1, "eicon_transmit: unsupported card-type!\n"); - return; - } - - ReqCount = 0; - if (!(skb2 = skb_dequeue(&ccard->sndq))) - quloop = 0; - while(quloop) { - spin_lock_irqsave(&eicon_lock, flags); - switch (scom) { - case 1: - if ((ram_inb(ccard, &com->Req)) || (ccard->ReadyInt)) { - if (!ccard->ReadyInt) { - tmp = ram_inb(ccard, &com->ReadyInt) + 1; - ram_outb(ccard, &com->ReadyInt, tmp); - ccard->ReadyInt++; - } - spin_unlock_irqrestore(&eicon_lock, flags); - skb_queue_head(&ccard->sndq, skb2); - eicon_log(ccard, 32, "eicon: transmit: Card not ready\n"); - return; - } - break; - case 0: - if (!(ram_inb(ccard, &prram->ReqOutput) - ram_inb(ccard, &prram->ReqInput))) { - spin_unlock_irqrestore(&eicon_lock, flags); - skb_queue_head(&ccard->sndq, skb2); - eicon_log(ccard, 32, "eicon: transmit: Card not ready\n"); - return; - } - break; - } - spin_unlock_irqrestore(&eicon_lock, flags); - - chan2 = (eicon_chan_ptr *)skb2->data; - chan = chan2->ptr; - if (!chan->e.busy) { - if((skb = skb_dequeue(&chan->e.X))) { - - reqbuf = (eicon_REQ *)skb->data; - if ((reqbuf->Reference) && (chan->e.B2Id == 0) && (reqbuf->ReqId & 0x1f)) { - eicon_log(ccard, 16, "eicon: transmit: error Id=0 on %d (Net)\n", chan->No); - } else { - spin_lock_irqsave(&eicon_lock, flags); - - switch (scom) { - case 1: - ram_outw(ccard, &com->XBuffer.length, reqbuf->XBuffer.length); - ram_copytocard(ccard, &com->XBuffer.P, &reqbuf->XBuffer.P, reqbuf->XBuffer.length); - ram_outb(ccard, &com->ReqCh, reqbuf->ReqCh); - break; - case 0: - /* get address of next available request buffer */ - ReqOut = (eicon_REQ *)&prram->B[ram_inw(ccard, &prram->NextReq)]; - ram_outw(ccard, &ReqOut->XBuffer.length, reqbuf->XBuffer.length); - ram_copytocard(ccard, &ReqOut->XBuffer.P, &reqbuf->XBuffer.P, reqbuf->XBuffer.length); - ram_outb(ccard, &ReqOut->ReqCh, reqbuf->ReqCh); - ram_outb(ccard, &ReqOut->Req, reqbuf->Req); - break; - } - - dlev = 160; - - if (reqbuf->ReqId & 0x1f) { /* if this is no ASSIGN */ - - if (!reqbuf->Reference) { /* Signal Layer */ - switch (scom) { - case 1: - ram_outb(ccard, &com->ReqId, chan->e.D3Id); - break; - case 0: - ram_outb(ccard, &ReqOut->ReqId, chan->e.D3Id); - break; - case 2: - ep = &chan->de; - break; - } - tmpid = chan->e.D3Id; - chan->e.ReqCh = 0; - } - else { /* Net Layer */ - switch(scom) { - case 1: - ram_outb(ccard, &com->ReqId, chan->e.B2Id); - break; - case 0: - ram_outb(ccard, &ReqOut->ReqId, chan->e.B2Id); - break; - case 2: - ep = &chan->be; - break; - } - tmpid = chan->e.B2Id; - chan->e.ReqCh = 1; - if (((reqbuf->Req & 0x0f) == 0x08) || - ((reqbuf->Req & 0x0f) == 0x01)) { /* Send Data */ - chan->waitq = reqbuf->XBuffer.length; - chan->waitpq += reqbuf->XBuffer.length; - dlev = 128; - } - } - - } else { /* It is an ASSIGN */ - - switch(scom) { - case 1: - ram_outb(ccard, &com->ReqId, reqbuf->ReqId); - break; - case 0: - ram_outb(ccard, &ReqOut->ReqId, reqbuf->ReqId); - break; - case 2: - if (!reqbuf->Reference) - ep = &chan->de; - else - ep = &chan->be; - ep->Id = reqbuf->ReqId; - break; - } - tmpid = reqbuf->ReqId; - - if (!reqbuf->Reference) - chan->e.ReqCh = 0; - else - chan->e.ReqCh = 1; - } - - switch(scom) { - case 1: - chan->e.ref = ccard->ref_out++; - break; - case 0: - chan->e.ref = ram_inw(ccard, &ReqOut->Reference); - break; - case 2: - chan->e.ref = chan->No; - break; - } - - chan->e.Req = reqbuf->Req; - ReqCount++; - - switch (scom) { - case 1: - ram_outb(ccard, &com->Req, reqbuf->Req); - break; - case 0: - ram_outw(ccard, &prram->NextReq, ram_inw(ccard, &ReqOut->next)); - break; - case 2: -#ifdef CONFIG_ISDN_DRV_EICON_PCI - if (!ep) break; - ep->callback = eicon_idi_callback; - ep->R = (BUFFERS *)ccard; - ep->user[0] = (word)chan->No; - ep->user[1] = (word)tmpid; - ep->XNum = 1; - ep->RNum = 0; - ep->RNR = 0; - ep->Rc = 0; - ep->Ind = 0; - ep->X->PLength = reqbuf->XBuffer.length; - memcpy(ep->X->P, &reqbuf->XBuffer.P, reqbuf->XBuffer.length); - ep->ReqCh = reqbuf->ReqCh; - ep->Req = reqbuf->Req; -#endif - break; - } - - chan->e.busy = 1; - spin_unlock_irqrestore(&eicon_lock, flags); - eicon_log(ccard, dlev, "eicon: Req=%d Id=%x Ch=%d Len=%d Ref=%d\n", - reqbuf->Req, tmpid, - reqbuf->ReqCh, reqbuf->XBuffer.length, - chan->e.ref); -#ifdef CONFIG_ISDN_DRV_EICON_PCI - if (scom == 2) { - if (ep) { - ccard->d->request(ep); - if (ep->Rc) - eicon_idi_callback(ep); - } - } -#endif - } - dev_kfree_skb(skb); - } - dev_kfree_skb(skb2); - } - else { - skb_queue_tail(&ccard->sackq, skb2); - eicon_log(ccard, 128, "eicon: transmit: busy chan %d\n", chan->No); - } - - switch(scom) { - case 1: - quloop = 0; - break; - case 0: - case 2: - if (!(skb2 = skb_dequeue(&ccard->sndq))) - quloop = 0; - break; - } - - } - if (!scom) - ram_outb(ccard, &prram->ReqInput, (__u8)(ram_inb(ccard, &prram->ReqInput) + ReqCount)); - - while((skb = skb_dequeue(&ccard->sackq))) { - skb_queue_tail(&ccard->sndq, skb); - } -} - -#ifdef CONFIG_ISDN_DRV_EICON_ISA -/* - * IRQ handler - */ -irqreturn_t -eicon_irq(int irq, void *dev_id, struct pt_regs *regs) { - eicon_card *ccard = (eicon_card *)dev_id; - eicon_isa_card *isa_card; - eicon_pr_ram *prram = 0; - eicon_isa_com *com = 0; - eicon_RC *RcIn; - eicon_IND *IndIn; - struct sk_buff *skb; - int Count = 0; - int Rc = 0; - int Ind = 0; - unsigned char *irqprobe = 0; - int scom = 0; - int tmp = 0; - int dlev = 0; - - - if (!ccard) { - eicon_log(ccard, 1, "eicon_irq: spurious interrupt %d\n", irq); - return IRQ_NONE; - } - - if (ccard->type == EICON_CTYPE_QUADRO) { - tmp = 4; - while(tmp) { - com = (eicon_isa_com *)ccard->hwif.isa.shmem; - if ((readb(ccard->hwif.isa.intack))) { /* quadro found */ - break; - } - ccard = ccard->qnext; - tmp--; - } - } - - isa_card = &ccard->hwif.isa; - - switch(ccard->type) { - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_QUADRO: - scom = 1; - com = (eicon_isa_com *)isa_card->shmem; - irqprobe = &isa_card->irqprobe; - break; - case EICON_CTYPE_S2M: - scom = 0; - prram = (eicon_pr_ram *)isa_card->shmem; - irqprobe = &isa_card->irqprobe; - break; - default: - eicon_log(ccard, 1, "eicon_irq: unsupported card-type!\n"); - return IRQ_NONE; - } - - if (*irqprobe) { - switch(ccard->type) { - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_QUADRO: - if (readb(isa_card->intack)) { - writeb(0, &com->Rc); - writeb(0, isa_card->intack); - } - (*irqprobe)++; - break; - case EICON_CTYPE_S2M: - if (readb(isa_card->intack)) { - writeb(0, &prram->RcOutput); - writeb(0, isa_card->intack); - } - (*irqprobe)++; - break; - } - return IRQ_HANDLED; - } - - switch(ccard->type) { - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_QUADRO: - case EICON_CTYPE_S2M: - if (!(readb(isa_card->intack))) { /* card did not interrupt */ - eicon_log(ccard, 1, "eicon: IRQ: card reports no interrupt!\n"); - return IRQ_NONE; - } - break; - } - - if (scom) { - - /* if a return code is available ... */ - if ((tmp = ram_inb(ccard, &com->Rc))) { - eicon_RC *ack; - if (tmp == READY_INT) { - eicon_log(ccard, 64, "eicon: IRQ Rc=READY_INT\n"); - if (ccard->ReadyInt) { - ccard->ReadyInt--; - ram_outb(ccard, &com->Rc, 0); - eicon_schedule_tx(ccard); - } - } else { - skb = alloc_skb(sizeof(eicon_RC), GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n"); - } else { - ack = (eicon_RC *)skb_put(skb, sizeof(eicon_RC)); - ack->Rc = tmp; - ack->RcId = ram_inb(ccard, &com->RcId); - ack->RcCh = ram_inb(ccard, &com->RcCh); - ack->Reference = ccard->ref_in++; - eicon_log(ccard, 128, "eicon: IRQ Rc=%d Id=%x Ch=%d Ref=%d\n", - tmp,ack->RcId,ack->RcCh,ack->Reference); - skb_queue_tail(&ccard->rackq, skb); - eicon_schedule_ack(ccard); - } - ram_outb(ccard, &com->Req, 0); - ram_outb(ccard, &com->Rc, 0); - } - - } else { - - /* if an indication is available ... */ - if ((tmp = ram_inb(ccard, &com->Ind))) { - eicon_IND *ind; - int len = ram_inw(ccard, &com->RBuffer.length); - skb = alloc_skb((sizeof(eicon_IND) + len - 1), GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n"); - } else { - ind = (eicon_IND *)skb_put(skb, (sizeof(eicon_IND) + len - 1)); - ind->Ind = tmp; - ind->IndId = ram_inb(ccard, &com->IndId); - ind->IndCh = ram_inb(ccard, &com->IndCh); - ind->MInd = ram_inb(ccard, &com->MInd); - ind->MLength = ram_inw(ccard, &com->MLength); - ind->RBuffer.length = len; - if ((tmp == 1) || (tmp == 8)) - dlev = 128; - else - dlev = 192; - eicon_log(ccard, dlev, "eicon: IRQ Ind=%d Id=%x Ch=%d MInd=%d MLen=%d Len=%d\n", - tmp,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,len); - ram_copyfromcard(ccard, &ind->RBuffer.P, &com->RBuffer.P, len); - skb_queue_tail(&ccard->rcvq, skb); - eicon_schedule_rx(ccard); - } - ram_outb(ccard, &com->Ind, 0); - } - } - - } else { - - /* if return codes are available ... */ - if((Count = ram_inb(ccard, &prram->RcOutput))) { - eicon_RC *ack; - /* get the buffer address of the first return code */ - RcIn = (eicon_RC *)&prram->B[ram_inw(ccard, &prram->NextRc)]; - /* for all return codes do ... */ - while(Count--) { - - if((Rc=ram_inb(ccard, &RcIn->Rc))) { - skb = alloc_skb(sizeof(eicon_RC), GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n"); - } else { - ack = (eicon_RC *)skb_put(skb, sizeof(eicon_RC)); - ack->Rc = Rc; - ack->RcId = ram_inb(ccard, &RcIn->RcId); - ack->RcCh = ram_inb(ccard, &RcIn->RcCh); - ack->Reference = ram_inw(ccard, &RcIn->Reference); - eicon_log(ccard, 128, "eicon: IRQ Rc=%d Id=%x Ch=%d Ref=%d\n", - Rc,ack->RcId,ack->RcCh,ack->Reference); - skb_queue_tail(&ccard->rackq, skb); - eicon_schedule_ack(ccard); - } - ram_outb(ccard, &RcIn->Rc, 0); - } - /* get buffer address of next return code */ - RcIn = (eicon_RC *)&prram->B[ram_inw(ccard, &RcIn->next)]; - } - /* clear all return codes (no chaining!) */ - ram_outb(ccard, &prram->RcOutput, 0); - } - - /* if indications are available ... */ - if((Count = ram_inb(ccard, &prram->IndOutput))) { - eicon_IND *ind; - /* get the buffer address of the first indication */ - IndIn = (eicon_IND *)&prram->B[ram_inw(ccard, &prram->NextInd)]; - /* for all indications do ... */ - while(Count--) { - Ind = ram_inb(ccard, &IndIn->Ind); - if(Ind) { - int len = ram_inw(ccard, &IndIn->RBuffer.length); - skb = alloc_skb((sizeof(eicon_IND) + len - 1), GFP_ATOMIC); - if (!skb) { - eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n"); - } else { - ind = (eicon_IND *)skb_put(skb, (sizeof(eicon_IND) + len - 1)); - ind->Ind = Ind; - ind->IndId = ram_inb(ccard, &IndIn->IndId); - ind->IndCh = ram_inb(ccard, &IndIn->IndCh); - ind->MInd = ram_inb(ccard, &IndIn->MInd); - ind->MLength = ram_inw(ccard, &IndIn->MLength); - ind->RBuffer.length = len; - if ((Ind == 1) || (Ind == 8)) - dlev = 128; - else - dlev = 192; - eicon_log(ccard, dlev, "eicon: IRQ Ind=%d Id=%x Ch=%d MInd=%d MLen=%d Len=%d\n", - Ind,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,len); - ram_copyfromcard(ccard, &ind->RBuffer.P, &IndIn->RBuffer.P, len); - skb_queue_tail(&ccard->rcvq, skb); - eicon_schedule_rx(ccard); - } - ram_outb(ccard, &IndIn->Ind, 0); - } - /* get buffer address of next indication */ - IndIn = (eicon_IND *)&prram->B[ram_inw(ccard, &IndIn->next)]; - } - ram_outb(ccard, &prram->IndOutput, 0); - } - - } - - /* clear interrupt */ - switch(ccard->type) { - case EICON_CTYPE_QUADRO: - writeb(0, isa_card->intack); - writeb(0, &com[0x401]); - break; - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_S2M: - writeb(0, isa_card->intack); - break; - } - - return IRQ_HANDLED; -} -#endif diff --git a/drivers/isdn/eicon/eicon_isa.c b/drivers/isdn/eicon/eicon_isa.c deleted file mode 100644 index a2853ceac994..000000000000 --- a/drivers/isdn/eicon/eicon_isa.c +++ /dev/null @@ -1,454 +0,0 @@ -/* $Id: eicon_isa.c,v 1.1.4.1.2.3 2002/10/01 11:29:13 armin Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * Hardware-specific code for old ISA cards. - * - * Copyright 1998 by Fritz Elfert (fritz@isdn4linux.de) - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/config.h> -#include "eicon.h" -#include "eicon_isa.h" - -#define check_shmem check_region -#define release_shmem release_region -#define request_shmem request_region - -char *eicon_isa_revision = "$Revision: 1.1.4.1.2.3 $"; - -#undef EICON_MCA_DEBUG - -#ifdef CONFIG_ISDN_DRV_EICON_ISA - -/* Mask for detecting invalid IRQ parameter */ -static int eicon_isa_valid_irq[] = { - 0x1c1c, /* 2, 3, 4, 10, 11, 12 (S)*/ - 0x1c1c, /* 2, 3, 4, 10, 11, 12 (SX) */ - 0x1cbc, /* 2, 3, 4, 5, 7, 10, 11, 12 (SCOM) */ - 0x1cbc, /* 2, 3, 4, 5, 6, 10, 11, 12 (Quadro) */ - 0x1cbc /* 2, 3, 4, 5, 7, 10, 11, 12 (S2M) */ -}; - -static void -eicon_isa_release_shmem(eicon_isa_card *card) { - if (card->mvalid) { - iounmap(card->shmem); - release_mem_region(card->physmem, card->ramsize); - } - card->mvalid = 0; -} - -static void -eicon_isa_release_irq(eicon_isa_card *card) { - if (!card->master) - return; - if (card->ivalid) - free_irq(card->irq, card); - card->ivalid = 0; -} - -void -eicon_isa_release(eicon_isa_card *card) { - eicon_isa_release_irq(card); - eicon_isa_release_shmem(card); -} - -void -eicon_isa_printpar(eicon_isa_card *card) { - switch (card->type) { - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_QUADRO: - case EICON_CTYPE_S2M: - printk(KERN_INFO "Eicon %s at 0x%lx, irq %d.\n", - eicon_ctype_name[card->type], - card->physmem, - card->irq); - } -} - -int -eicon_isa_find_card(int Mem, int Irq, char * Id) -{ - int primary = 1; - unsigned long amem; - - if (!strlen(Id)) - return -1; - - if (Mem == -1) - return -1; - - /* Check for valid membase address */ - if ((Mem < 0x0c0000) || - (Mem > 0x0fc000) || - (Mem & 0xfff)) { - printk(KERN_WARNING "eicon_isa: invalid membase 0x%x for %s\n", - Mem, Id); - return -1; - } - if (check_mem_region(Mem, RAMSIZE)) { - printk(KERN_WARNING "eicon_isa_boot: memory at 0x%x already in use.\n", Mem); - return -1; - } - - amem = (unsigned long) ioremap(Mem, RAMSIZE); - writew(0x55aa, amem + 0x402); - if (readw(amem + 0x402) != 0x55aa) primary = 0; - writew(0, amem + 0x402); - if (readw(amem + 0x402) != 0) primary = 0; - - printk(KERN_INFO "Eicon: Driver-ID: %s\n", Id); - if (primary) { - printk(KERN_INFO "Eicon: assuming pri card at 0x%x\n", Mem); - writeb(0, amem + 0x3ffe); - iounmap((unsigned char *)amem); - return EICON_CTYPE_ISAPRI; - } else { - printk(KERN_INFO "Eicon: assuming bri card at 0x%x\n", Mem); - writeb(0, amem + 0x400); - iounmap((unsigned char *)amem); - return EICON_CTYPE_ISABRI; - } - return -1; -} - -int -eicon_isa_bootload(eicon_isa_card *card, eicon_isa_codebuf *cb) { - int tmp; - unsigned long timeout; - eicon_isa_codebuf cbuf; - unsigned char *code; - eicon_isa_boot *boot; - - if (copy_from_user(&cbuf, cb, sizeof(eicon_isa_codebuf))) - return -EFAULT; - - /* Allocate code-buffer and copy code from userspace */ - if (cbuf.bootstrap_len > 1024) { - printk(KERN_WARNING "eicon_isa_boot: Invalid startup-code size %ld\n", - cbuf.bootstrap_len); - return -EINVAL; - } - if (!(code = kmalloc(cbuf.bootstrap_len, GFP_KERNEL))) { - printk(KERN_WARNING "eicon_isa_boot: Couldn't allocate code buffer\n"); - return -ENOMEM; - } - if (copy_from_user(code, &cb->code, cbuf.bootstrap_len)) { - kfree(code); - return -EFAULT; - } - - if (card->type == EICON_CTYPE_ISAPRI) - card->ramsize = RAMSIZE_P; - else - card->ramsize = RAMSIZE; - - if (check_mem_region(card->physmem, card->ramsize)) { - printk(KERN_WARNING "eicon_isa_boot: memory at 0x%lx already in use.\n", - card->physmem); - kfree(code); - return -EBUSY; - } - request_mem_region(card->physmem, card->ramsize, "Eicon ISA ISDN"); - card->shmem = (eicon_isa_shmem *) ioremap(card->physmem, card->ramsize); -#ifdef EICON_MCA_DEBUG - printk(KERN_INFO "eicon_isa_boot: card->ramsize = %d.\n", card->ramsize); -#endif - card->mvalid = 1; - - switch(card->type) { - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - case EICON_CTYPE_QUADRO: - case EICON_CTYPE_ISABRI: - card->intack = (__u8 *)card->shmem + INTACK; - card->startcpu = (__u8 *)card->shmem + STARTCPU; - card->stopcpu = (__u8 *)card->shmem + STOPCPU; - break; - case EICON_CTYPE_S2M: - case EICON_CTYPE_ISAPRI: - card->intack = (__u8 *)card->shmem + INTACK_P; - card->startcpu = (__u8 *)card->shmem + STARTCPU_P; - card->stopcpu = (__u8 *)card->shmem + STOPCPU_P; - break; - default: - printk(KERN_WARNING "eicon_isa_boot: Invalid card type %d\n", card->type); - eicon_isa_release_shmem(card); - kfree(code); - return -EINVAL; - } - - /* clear any pending irq's */ - readb(card->intack); -#ifdef CONFIG_MCA - if (MCA_bus) { - if (card->type == EICON_CTYPE_SCOM) { - outb_p(0,card->io+1); - } - else { - printk(KERN_WARNING "eicon_isa_boot: Card type not supported yet.\n"); - eicon_isa_release_shmem(card); - return -EINVAL; - }; - -#ifdef EICON_MCA_DEBUG - printk(KERN_INFO "eicon_isa_boot: card->io = %x.\n", card->io); - printk(KERN_INFO "eicon_isa_boot: card->irq = %d.\n", (int)card->irq); -#endif - } -#else - /* set reset-line active */ - writeb(0, card->stopcpu); -#endif /* CONFIG_MCA */ - /* clear irq-requests */ - writeb(0, card->intack); - readb(card->intack); - - /* Copy code into card */ - memcpy_toio(&card->shmem->c, code, cbuf.bootstrap_len); - - /* Check for properly loaded code */ - if (!check_signature((unsigned long)&card->shmem->c, code, 1020)) { - printk(KERN_WARNING "eicon_isa_boot: Could not load startup-code\n"); - eicon_isa_release_shmem(card); - kfree(code); - return -EIO; - } - /* if 16k-ramsize, duplicate the reset-jump-code */ - if (card->ramsize == RAMSIZE_P) - memcpy_toio((__u8 *)card->shmem + 0x3ff0, &code[0x3f0], 12); - - kfree(code); - boot = &card->shmem->boot; - - /* Delay 0.2 sec. */ - SLEEP(HZ / 5); - - /* Start CPU */ - writeb(cbuf.boot_opt, &boot->ctrl); -#ifdef CONFIG_MCA - if (MCA_bus) { - outb_p(0, card->io); - } -#else - writeb(0, card->startcpu); -#endif /* CONFIG_MCA */ - - /* Delay 0.2 sec. */ - SLEEP(HZ / 5); - - timeout = jiffies + (HZ * 22); - while (time_before(jiffies, timeout)) { - if (readb(&boot->ctrl) == 0) - break; - SLEEP(10); - } - if (readb(&boot->ctrl) != 0) { - printk(KERN_WARNING "eicon_isa_boot: CPU test failed.\n"); -#ifdef EICON_MCA_DEBUG - printk(KERN_INFO "eicon_isa_boot: &boot->ctrl = %d.\n", - readb(&boot->ctrl)); -#endif - eicon_isa_release_shmem(card); - return -EIO; - } - - /* Check for memory-test errors */ - if (readw(&boot->ebit)) { - printk(KERN_WARNING "eicon_isa_boot: memory test failed (bit 0x%04x at 0x%08x)\n", - readw(&boot->ebit), readl(&boot->eloc)); - eicon_isa_release_shmem(card); - return -EIO; - } - - /* Check card type and memory size */ - tmp = readb(&boot->card); - if ((tmp < 0) || (tmp > 4)) { - printk(KERN_WARNING "eicon_isa_boot: Type detect failed\n"); - eicon_isa_release_shmem(card); - return -EIO; - } - card->type = tmp; - ((eicon_card *)card->card)->type = tmp; - - tmp = readb(&boot->msize); - if (tmp != 8 && tmp != 16 && tmp != 24 && - tmp != 32 && tmp != 48 && tmp != 60) { - printk(KERN_WARNING "eicon_isa_boot: invalid memsize\n"); - eicon_isa_release_shmem(card); - return -EIO; - } - printk(KERN_INFO "%s: startup-code loaded\n", eicon_ctype_name[card->type]); - if ((card->type == EICON_CTYPE_QUADRO) && (card->master)) { - tmp = eicon_addcard(card->type, card->physmem, card->irq, - ((eicon_card *)card->card)->regname, 0); - printk(KERN_INFO "Eicon: %d adapters added\n", tmp); - } - return 0; -} - -int -eicon_isa_load(eicon_isa_card *card, eicon_isa_codebuf *cb) { - eicon_isa_boot *boot; - int tmp; - unsigned long timeout; - int j; - eicon_isa_codebuf cbuf; - unsigned char *code; - unsigned char *p; - - if (copy_from_user(&cbuf, cb, sizeof(eicon_isa_codebuf))) - return -EFAULT; - - if (!(code = kmalloc(cbuf.firmware_len, GFP_KERNEL))) { - printk(KERN_WARNING "eicon_isa_load: Couldn't allocate code buffer\n"); - return -ENOMEM; - } - - if (copy_from_user(code, &cb->code, cbuf.firmware_len)) { - kfree(code); - return -EFAULT; - } - - boot = &card->shmem->boot; - - if ((!card->ivalid) && card->master) { - card->irqprobe = 1; - /* Check for valid IRQ */ - if ((card->irq < 0) || (card->irq > 15) || - (!((1 << card->irq) & eicon_isa_valid_irq[card->type & 0x0f]))) { - printk(KERN_WARNING "eicon_isa_load: invalid irq: %d\n", card->irq); - eicon_isa_release_shmem(card); - kfree(code); - return -EINVAL; - } - /* Register irq */ - if (!request_irq(card->irq, &eicon_irq, 0, "Eicon ISA ISDN", card)) - card->ivalid = 1; - else { - printk(KERN_WARNING "eicon_isa_load: irq %d already in use.\n", - card->irq); - eicon_isa_release_shmem(card); - kfree(code); - return -EBUSY; - } - } - - tmp = readb(&boot->msize); - if (tmp != 8 && tmp != 16 && tmp != 24 && - tmp != 32 && tmp != 48 && tmp != 60) { - printk(KERN_WARNING "eicon_isa_load: invalid memsize\n"); - eicon_isa_release_shmem(card); - return -EIO; - } - - eicon_isa_printpar(card); - - /* Download firmware */ - printk(KERN_INFO "%s %dkB, loading firmware ...\n", - eicon_ctype_name[card->type], - tmp * 16); - tmp = cbuf.firmware_len >> 8; - p = code; - while (tmp--) { - memcpy_toio(&boot->b, p, 256); - writeb(1, &boot->ctrl); - timeout = jiffies + HZ / 10; - while (time_before(jiffies, timeout)) { - if (readb(&boot->ctrl) == 0) - break; - SLEEP(2); - } - if (readb(&boot->ctrl)) { - printk(KERN_WARNING "eicon_isa_load: download timeout at 0x%x\n", p-code); - eicon_isa_release(card); - kfree(code); - return -EIO; - } - p += 256; - } - kfree(code); - - /* Initialize firmware parameters */ - memcpy_toio(&card->shmem->c[8], &cbuf.tei, 14); - memcpy_toio(&card->shmem->c[32], &cbuf.oad, 96); - memcpy_toio(&card->shmem->c[128], &cbuf.oad, 96); - - /* Start firmware, wait for signature */ - writeb(2, &boot->ctrl); - timeout = jiffies + (5*HZ); - while (time_before(jiffies, timeout)) { - if (readw(&boot->signature) == 0x4447) - break; - SLEEP(2); - } - if (readw(&boot->signature) != 0x4447) { - printk(KERN_WARNING "eicon_isa_load: firmware selftest failed %04x\n", - readw(&boot->signature)); - eicon_isa_release(card); - return -EIO; - } - - card->channels = readb(&card->shmem->c[0x3f6]); - - /* clear irq-requests, reset irq-count */ - readb(card->intack); - writeb(0, card->intack); - - if (card->master) { - card->irqprobe = 1; - /* Trigger an interrupt and check if it is delivered */ - tmp = readb(&card->shmem->com.ReadyInt); - tmp ++; - writeb(tmp, &card->shmem->com.ReadyInt); - timeout = jiffies + HZ / 5; - while (time_before(jiffies, timeout)) { - if (card->irqprobe > 1) - break; - SLEEP(2); - } - if (card->irqprobe == 1) { - printk(KERN_WARNING "eicon_isa_load: IRQ # %d test failed\n", card->irq); - eicon_isa_release(card); - return -EIO; - } - } -#ifdef EICON_MCA_DEBUG - printk(KERN_INFO "eicon_isa_load: IRQ # %d test succeeded.\n", card->irq); -#endif - - writeb(card->irq, &card->shmem->com.Int); - - /* initializing some variables */ - ((eicon_card *)card->card)->ReadyInt = 0; - ((eicon_card *)card->card)->ref_in = 1; - ((eicon_card *)card->card)->ref_out = 1; - for(j=0; j<256; j++) ((eicon_card *)card->card)->IdTable[j] = NULL; - for(j=0; j< (card->channels + 1); j++) { - ((eicon_card *)card->card)->bch[j].e.busy = 0; - ((eicon_card *)card->card)->bch[j].e.D3Id = 0; - ((eicon_card *)card->card)->bch[j].e.B2Id = 0; - ((eicon_card *)card->card)->bch[j].e.ref = 0; - ((eicon_card *)card->card)->bch[j].e.Req = 0; - ((eicon_card *)card->card)->bch[j].e.complete = 1; - ((eicon_card *)card->card)->bch[j].fsm_state = EICON_STATE_NULL; - } - - printk(KERN_INFO "Eicon: Supported channels: %d\n", card->channels); - printk(KERN_INFO "%s successfully started\n", eicon_ctype_name[card->type]); - - /* Enable normal IRQ processing */ - card->irqprobe = 0; - return 0; -} - -#endif /* CONFIG_ISDN_DRV_EICON_ISA */ diff --git a/drivers/isdn/eicon/eicon_isa.h b/drivers/isdn/eicon/eicon_isa.h deleted file mode 100644 index 47aa5650601e..000000000000 --- a/drivers/isdn/eicon/eicon_isa.h +++ /dev/null @@ -1,121 +0,0 @@ -/* $Id: eicon_isa.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * - * Copyright 1998 by Fritz Elfert (fritz@isdn4linux.de) - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef eicon_isa_h -#define eicon_isa_h - -#ifdef __KERNEL__ -#include <linux/config.h> - -/* Factory defaults for ISA-Cards */ -#define EICON_ISA_MEMBASE 0xd0000 -#define EICON_ISA_IRQ 3 -/* shmem offset for Quadro parts */ -#define EICON_ISA_QOFFSET 0x0800 - -typedef struct { - __u16 length __attribute__ ((packed)); /* length of data/parameter field */ - __u8 P[270]; /* data/parameter field */ -} eicon_scom_PBUFFER; - -/* General communication buffer */ -typedef struct { - __u8 Req; /* request register */ - __u8 ReqId; /* request task/entity identification */ - __u8 Rc; /* return code register */ - __u8 RcId; /* return code task/entity identification */ - __u8 Ind; /* Indication register */ - __u8 IndId; /* Indication task/entity identification */ - __u8 IMask; /* Interrupt Mask Flag */ - __u8 RNR; /* Receiver Not Ready (set by PC) */ - __u8 XLock; /* XBuffer locked Flag */ - __u8 Int; /* ISDN interrupt */ - __u8 ReqCh; /* Channel field for layer-3 Requests */ - __u8 RcCh; /* Channel field for layer-3 Returncodes */ - __u8 IndCh; /* Channel field for layer-3 Indications */ - __u8 MInd; /* more data indication field */ - __u16 MLength; /* more data total packet length */ - __u8 ReadyInt; /* request field for ready interrupt */ - __u8 Reserved[12]; /* reserved space */ - __u8 IfType; /* 1 = 16k-Interface */ - __u16 Signature __attribute__ ((packed)); /* ISDN adapter Signature */ - eicon_scom_PBUFFER XBuffer; /* Transmit Buffer */ - eicon_scom_PBUFFER RBuffer; /* Receive Buffer */ -} eicon_isa_com; - -/* struct for downloading firmware */ -typedef struct { - __u8 ctrl; - __u8 card; - __u8 msize; - __u8 fill0; - __u16 ebit __attribute__ ((packed)); - __u32 eloc __attribute__ ((packed)); - __u8 reserved[20]; - __u16 signature __attribute__ ((packed)); - __u8 fill[224]; - __u8 b[256]; -} eicon_isa_boot; - -/* Shared memory */ -typedef union { - unsigned char c[0x400]; - eicon_isa_com com; - eicon_isa_boot boot; -} eicon_isa_shmem; - -/* - * card's description - */ -typedef struct { - int ramsize; - int irq; /* IRQ */ - unsigned long physmem; /* physical memory address */ -#ifdef CONFIG_MCA - int io; /* IO-port for MCA brand */ -#endif /* CONFIG_MCA */ - void* card; - eicon_isa_shmem* shmem; /* Shared-memory area */ - unsigned char* intack; /* Int-Acknowledge */ - unsigned char* stopcpu; /* Writing here stops CPU */ - unsigned char* startcpu; /* Writing here starts CPU */ - unsigned char type; /* card type */ - int channels; /* No. of channels */ - unsigned char irqprobe; /* Flag: IRQ-probing */ - unsigned char mvalid; /* Flag: Memory is valid */ - unsigned char ivalid; /* Flag: IRQ is valid */ - unsigned char master; /* Flag: Card ist Quadro 1/4 */ -} eicon_isa_card; - -/* Offsets for special locations on standard cards */ -#define INTACK 0x03fe -#define STOPCPU 0x0400 -#define STARTCPU 0x0401 -#define RAMSIZE 0x0400 -/* Offsets for special location on PRI card */ -#define INTACK_P 0x3ffc -#define STOPCPU_P 0x3ffe -#define STARTCPU_P 0x3fff -#define RAMSIZE_P 0x4000 - - -extern int eicon_isa_load(eicon_isa_card *card, eicon_isa_codebuf *cb); -extern int eicon_isa_bootload(eicon_isa_card *card, eicon_isa_codebuf *cb); -extern void eicon_isa_release(eicon_isa_card *card); -extern void eicon_isa_printpar(eicon_isa_card *card); -extern void eicon_isa_transmit(eicon_isa_card *card); -extern int eicon_isa_find_card(int Mem, int Irq, char * Id); - -#endif /* __KERNEL__ */ - -#endif /* eicon_isa_h */ diff --git a/drivers/isdn/eicon/eicon_mod.c b/drivers/isdn/eicon/eicon_mod.c deleted file mode 100644 index ceba6d16fbca..000000000000 --- a/drivers/isdn/eicon/eicon_mod.c +++ /dev/null @@ -1,1642 +0,0 @@ -/* $Id: eicon_mod.c,v 1.1.4.1.2.4 2002/10/01 11:29:13 armin Exp $ - * - * ISDN lowlevel-module for Eicon active cards. - * - * Copyright 1997 by Fritz Elfert (fritz@isdn4linux.de) - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - * Thanks to Eicon Networks for - * documents, informations and hardware. - * - * Deutsche Mailbox Saar-Lor-Lux GmbH - * for sponsoring and testing fax - * capabilities with Diva Server cards. - * (dor@deutschemailbox.de) - * - */ - -#define DRIVERNAME "Eicon active ISDN driver" -#define DRIVERRELEASE "2.0" -#define DRIVERPATCH ".16" - - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/init.h> -#ifdef CONFIG_MCA -#include <linux/mca.h> -#include <linux/mca-legacy.h> -#endif /* CONFIG_MCA */ - -#include "eicon.h" - -#include <linux/isdn/capicmd.h> - -#undef N_DATA -#include "adapter.h" -#include "uxio.h" - -#define INCLUDE_INLINE_FUNCS - -static eicon_card *cards = (eicon_card *) NULL; /* glob. var , contains - start of card-list */ - -static char *eicon_revision = "$Revision: 1.1.4.1.2.4 $"; - -extern char *eicon_pci_revision; -extern char *eicon_isa_revision; -extern char *eicon_idi_revision; - -extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, - unsigned int command, unsigned long arg); -extern void eicon_pci_init_conf(eicon_card *card); - -#define EICON_CTRL_VERSION 2 - -ulong DebugVar; - -spinlock_t eicon_lock; - -DESCRIPTOR idi_d[32]; - -/* Parameters to be set by insmod */ -#ifdef CONFIG_ISDN_DRV_EICON_ISA -static int membase = -1; -static int irq = -1; -#endif -static char *id = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - -MODULE_DESCRIPTION( "ISDN4Linux: Driver for Eicon active ISDN cards"); -MODULE_AUTHOR( "Armin Schindler"); -MODULE_LICENSE( "GPL"); -MODULE_PARM_DESC(id, "ID-String of first card"); -MODULE_PARM(id, "s"); -#ifdef CONFIG_ISDN_DRV_EICON_ISA -MODULE_PARM_DESC(membase, "Base address of first ISA card"); -MODULE_PARM_DESC(irq, "IRQ of first card"); -MODULE_PARM(membase, "i"); -MODULE_PARM(irq, "i"); -#endif - -char *eicon_ctype_name[] = { - "ISDN-S", - "ISDN-SX", - "ISDN-SCOM", - "ISDN-QUADRO", - "ISDN-S2M", - "DIVA Server BRI/PCI", - "DIVA Server 4BRI/PCI", - "DIVA Server 4BRI/PCI", - "DIVA Server PRI/PCI" -}; - -static char * -eicon_getrev(const char *revision) -{ - char *rev; - char *p; - if ((p = strchr(revision, ':'))) { - rev = p + 2; - p = strchr(rev, '$'); - *--p = 0; - } else rev = "?.??"; - return rev; - -} - -static eicon_chan * -find_channel(eicon_card *card, int channel) -{ - if ((channel >= 0) && (channel < card->nchannels)) - return &(card->bch[channel]); - eicon_log(card, 1, "eicon: Invalid channel %d\n", channel); - return NULL; -} - -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI -/* - * Find pcicard with given card number - */ -static inline eicon_card * -eicon_findnpcicard(int driverid) -{ - eicon_card *p = cards; - - while (p) { - if ((p->regname[strlen(p->regname)-1] == (driverid + '0')) && - (p->bus == EICON_BUS_PCI)) - return p; - p = p->next; - } - return (eicon_card *) 0; -} -#endif -#endif /* CONFIG_PCI */ - -static void -eicon_rcv_dispatch(unsigned long context) -{ - struct eicon_card *card = (struct eicon_card *)context; - - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - case EICON_BUS_PCI: - eicon_io_rcv_dispatch(card); - break; - default: - eicon_log(card, 1, - "eicon_rcv_dispatch: Illegal bustype %d\n", card->bus); - } -} - -static void -eicon_ack_dispatch(unsigned long context) -{ - struct eicon_card *card = (struct eicon_card *)context; - - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - case EICON_BUS_PCI: - eicon_io_ack_dispatch(card); - break; - default: - eicon_log(card, 1, - "eicon_ack_dispatch: Illegal bustype %d\n", card->bus); - } -} - -static void -eicon_transmit(unsigned long context) -{ - struct eicon_card *card = (struct eicon_card *)context; - - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - case EICON_BUS_PCI: - eicon_io_transmit(card); - break; - default: - eicon_log(card, 1, - "eicon_transmit: Illegal bustype %d\n", card->bus); - } -} - -static int -eicon_command(eicon_card * card, isdn_ctrl * c) -{ - ulong a; - eicon_chan *chan; - eicon_cdef cdef; -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - dia_start_t dstart; - int idi_length = 0; -#endif -#endif - isdn_ctrl cmd; - int ret = 0; - unsigned long flags; - - eicon_log(card, 16, "eicon_cmd 0x%x with arg 0x%lx (0x%lx)\n", - c->command, c->arg, (ulong) *c->parm.num); - - switch (c->command) { - case ISDN_CMD_IOCTL: - memcpy(&a, c->parm.num, sizeof(ulong)); - switch (c->arg) { - case EICON_IOCTL_GETVER: - return(EICON_CTRL_VERSION); - case EICON_IOCTL_GETTYPE: - if (card->bus == EICON_BUS_PCI) { - if (copy_to_user((char *)a, - &card->hwif.pci.master, - sizeof(int))) - return -EFAULT; - } - return(card->type); - case EICON_IOCTL_GETMMIO: - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - return (int)card->hwif.isa.shmem; - default: - eicon_log(card, 1, - "eicon: Illegal BUS type %d\n", - card->bus); - ret = -ENODEV; - } -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_IOCTL_SETMMIO: - if (card->flags & EICON_FLAGS_LOADED) - return -EBUSY; - switch (card->bus) { - case EICON_BUS_ISA: - if (eicon_isa_find_card(a, - card->hwif.isa.irq, - card->regname) < 0) - return -EFAULT; - card->hwif.isa.shmem = (eicon_isa_shmem *)a; - return 0; - case EICON_BUS_MCA: -#ifdef CONFIG_MCA - if (eicon_mca_find_card( - 0, a, - card->hwif.isa.irq, - card->regname) < 0) - return -EFAULT; - card->hwif.isa.shmem = (eicon_isa_shmem *)a; - return 0; -#endif /* CONFIG_MCA */ - default: - eicon_log(card, 1, - "eicon: Illegal BUS type %d\n", - card->bus); - ret = -ENODEV; - } -#endif - case EICON_IOCTL_GETIRQ: - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - return card->hwif.isa.irq; - default: - eicon_log(card, 1, - "eicon: Illegal BUS type %d\n", - card->bus); - ret = -ENODEV; - } - case EICON_IOCTL_SETIRQ: - if (card->flags & EICON_FLAGS_LOADED) - return -EBUSY; - if ((a < 2) || (a > 15)) - return -EFAULT; - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - card->hwif.isa.irq = a; - return 0; - default: - eicon_log(card, 1, - "eicon: Illegal BUS type %d\n", - card->bus); - ret = -ENODEV; - } -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_IOCTL_LOADBOOT: - if (card->flags & EICON_FLAGS_RUNNING) - return -EBUSY; - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - ret = eicon_isa_bootload( - &(card->hwif.isa), - &(((eicon_codebuf *)a)->isa)); - break; - default: - eicon_log(card, 1, - "eicon: Illegal BUS type %d\n", - card->bus); - ret = -ENODEV; - } - return ret; -#endif -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_IOCTL_LOADISA: - if (card->flags & EICON_FLAGS_RUNNING) - return -EBUSY; - switch (card->bus) { - case EICON_BUS_ISA: - case EICON_BUS_MCA: - ret = eicon_isa_load( - &(card->hwif.isa), - &(((eicon_codebuf *)a)->isa)); - if (!ret) { - card->flags |= EICON_FLAGS_LOADED; - card->flags |= EICON_FLAGS_RUNNING; - if (card->hwif.isa.channels > 1) { - cmd.command = ISDN_STAT_ADDCH; - cmd.driver = card->myid; - cmd.arg = card->hwif.isa.channels - 1; - card->interface.statcallb(&cmd); - } - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } - break; - default: - eicon_log(card, 1, - "eicon: Illegal BUS type %d\n", - card->bus); - ret = -ENODEV; - } - return ret; -#endif - case EICON_IOCTL_MANIF: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!card->d) - return -ENODEV; - if (!card->d->features & DI_MANAGE) - return -ENODEV; - ret = eicon_idi_manage( - card, - (eicon_manifbuf *)a); - return ret; - - case EICON_IOCTL_GETXLOG: - return -ENODEV; - - case EICON_IOCTL_ADDCARD: - if (copy_from_user(&cdef, (char *)a, - sizeof(cdef))) - return -EFAULT; - if (!(eicon_addcard(0, cdef.membase, cdef.irq, cdef.id, 0))) - return -EIO; - return 0; - case EICON_IOCTL_DEBUGVAR: - DebugVar = a; - eicon_log(card, 1, "Eicon: Debug Value set to %ld\n", DebugVar); - return 0; - case EICON_IOCTL_LOADPCI: - eicon_log(card, 1, "Eicon: Wrong version of load-utility,\n"); - eicon_log(card, 1, "Eicon: re-compile eiconctrl !\n"); - eicon_log(card, 1, "Eicon: Maybe update of utility is necessary !\n"); - return -EINVAL; - default: -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - if (c->arg < EICON_IOCTL_DIA_OFFSET) - return -EINVAL; - if (copy_from_user(&dstart, (char *)a, - sizeof(dstart))) - return -EFAULT; - if (!(card = eicon_findnpcicard(dstart.card_id))) - return -EINVAL; - ret = do_ioctl(NULL, NULL, - c->arg - EICON_IOCTL_DIA_OFFSET, - (unsigned long) a); - if (((c->arg - EICON_IOCTL_DIA_OFFSET)==DIA_IOCTL_START) && (!ret)) { - if (card->type != EICON_CTYPE_MAESTRAQ) { - DIVA_DIDD_Read(idi_d, sizeof(idi_d)); - for(idi_length = 0; idi_length < 32; idi_length++) { - if (idi_d[idi_length].type == 0) break; - } - if ((idi_length < 1) || (idi_length >= 32)) { - eicon_log(card, 1, "eicon: invalid idi table length.\n"); - break; - } - card->d = &idi_d[idi_length - 1]; - card->flags |= EICON_FLAGS_LOADED; - card->flags |= EICON_FLAGS_RUNNING; - eicon_pci_init_conf(card); - if (card->d->channels > 1) { - cmd.command = ISDN_STAT_ADDCH; - cmd.driver = card->myid; - cmd.arg = card->d->channels - 1; - card->interface.statcallb(&cmd); - } - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - eicon_log(card, 1, "Eicon: %s started, %d channels (feat. 0x%x)\n", - (card->type == EICON_CTYPE_MAESTRA) ? "BRI" : "PRI", - card->d->channels, card->d->features); - } else { - int i; - DIVA_DIDD_Read(idi_d, sizeof(idi_d)); - for(idi_length = 0; idi_length < 32; idi_length++) - if (idi_d[idi_length].type == 0) break; - if ((idi_length < 1) || (idi_length >= 32)) { - eicon_log(card, 1, "eicon: invalid idi table length.\n"); - break; - } - for(i = 3; i >= 0; i--) { - if (!(card = eicon_findnpcicard(dstart.card_id - i))) - return -EINVAL; - - card->flags |= EICON_FLAGS_LOADED; - card->flags |= EICON_FLAGS_RUNNING; - card->d = &idi_d[idi_length - (i+1)]; - eicon_pci_init_conf(card); - if (card->d->channels > 1) { - cmd.command = ISDN_STAT_ADDCH; - cmd.driver = card->myid; - cmd.arg = card->d->channels - 1; - card->interface.statcallb(&cmd); - } - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - eicon_log(card, 1, "Eicon: %d/4BRI started, %d channels (feat. 0x%x)\n", - 4-i, card->d->channels, card->d->features); - } - } - } - return ret; -#else - return -EINVAL; -#endif -#endif /* CONFIG_PCI */ - } - break; - case ISDN_CMD_DIAL: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - spin_lock_irqsave(&eicon_lock, flags); - if ((chan->fsm_state != EICON_STATE_NULL) && (chan->fsm_state != EICON_STATE_LISTEN)) { - spin_unlock_irqrestore(&eicon_lock, flags); - eicon_log(card, 1, "Dial on channel %d with state %d\n", - chan->No, chan->fsm_state); - return -EBUSY; - } - chan->fsm_state = EICON_STATE_OCALL; - spin_unlock_irqrestore(&eicon_lock, flags); - - ret = idi_connect_req(card, chan, c->parm.setup.phone, - c->parm.setup.eazmsn, - c->parm.setup.si1, - c->parm.setup.si2); - if (ret) { - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg &= 0x1f; - card->interface.statcallb(&cmd); - } - return ret; - case ISDN_CMD_ACCEPTD: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - if (chan->fsm_state == EICON_STATE_ICALL) { - idi_connect_res(card, chan); - } - return 0; - case ISDN_CMD_ACCEPTB: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - return 0; - case ISDN_CMD_HANGUP: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - idi_hangup(card, chan); - return 0; - case ISDN_CMD_SETEAZ: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - chan->eazmask = 0x3ff; - eicon_idi_listen_req(card, chan); - return 0; - case ISDN_CMD_CLREAZ: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - chan->eazmask = 0; - eicon_idi_listen_req(card, chan); - return 0; - case ISDN_CMD_SETL2: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - chan->l2prot = (c->arg >> 8); - return 0; - case ISDN_CMD_SETL3: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - chan->l3prot = (c->arg >> 8); -#ifdef CONFIG_ISDN_TTY_FAX - if (chan->l3prot == ISDN_PROTO_L3_FCLASS2) { - chan->fax = c->parm.fax; - eicon_log(card, 128, "idi_cmd: Ch%d: SETL3 struct fax=0x%x\n",chan->No, chan->fax); - } -#endif - return 0; -#ifdef CONFIG_ISDN_TTY_FAX - case ISDN_CMD_FAXCMD: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - if (!chan->fax) - break; - idi_fax_cmd(card, chan); - return 0; -#endif - case ISDN_CMD_AUDIO: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - idi_audio_cmd(card, chan, c->arg >> 8, c->parm.num); - return 0; - case CAPI_PUT_MESSAGE: - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x1f))) - break; - if (c->parm.cmsg.Length < 8) - break; - switch(c->parm.cmsg.Command) { - case CAPI_FACILITY: - if (c->parm.cmsg.Subcommand == CAPI_REQ) - return(capipmsg(card, chan, &c->parm.cmsg)); - break; - case CAPI_MANUFACTURER: - default: - break; - } - return 0; - } - - return -EINVAL; -} - -/* - * Find card with given driverId - */ -static inline eicon_card * -eicon_findcard(int driverid) -{ - eicon_card *p = cards; - - while (p) { - if (p->myid == driverid) - return p; - p = p->next; - } - return (eicon_card *) 0; -} - -/* - * Wrapper functions for interface to linklevel - */ -static int -if_command(isdn_ctrl * c) -{ - eicon_card *card = eicon_findcard(c->driver); - - if (card) - return (eicon_command(card, c)); - printk(KERN_ERR - "eicon: if_command %d called with invalid driverId %d!\n", - c->command, c->driver); - return -ENODEV; -} - -static int -if_writecmd(const u_char * buf, int len, int user, int id, int channel) -{ - return (len); -} - -static int -if_readstatus(u_char * buf, int len, int user, int id, int channel) -{ - int count = 0; - int cnt = 0; - ulong flags = 0; - u_char *p = buf; - struct sk_buff *skb; - - eicon_card *card = eicon_findcard(id); - - if (card) { - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - - spin_lock_irqsave(&eicon_lock, flags); - while((skb = skb_dequeue(&card->statq))) { - - if ((skb->len + count) > len) - cnt = len - count; - else - cnt = skb->len; - - if (user) { - spin_unlock_irqrestore(&eicon_lock, flags); - if (copy_to_user(p, skb->data, cnt)) - return -EFAULT; - spin_lock_irqsave(&eicon_lock, flags); - } - else - memcpy(p, skb->data, cnt); - - count += cnt; - p += cnt; - - if (cnt == skb->len) { - dev_kfree_skb(skb); - if (card->statq_entries > 0) - card->statq_entries--; - } else { - skb_pull(skb, cnt); - skb_queue_head(&card->statq, skb); - spin_unlock_irqrestore(&eicon_lock, flags); - return count; - } - } - card->statq_entries = 0; - spin_unlock_irqrestore(&eicon_lock, flags); - return count; - } - printk(KERN_ERR - "eicon: if_readstatus called with invalid driverId!\n"); - return 0; -} - -static int -if_sendbuf(int id, int channel, int ack, struct sk_buff *skb) -{ - eicon_card *card = eicon_findcard(id); - eicon_chan *chan; - int ret = 0; - int len; - - len = skb->len; - - if (card) { - if (!card->flags & EICON_FLAGS_RUNNING) - return -ENODEV; - if (!(chan = find_channel(card, channel))) - return -ENODEV; - - if (chan->fsm_state == EICON_STATE_ACTIVE) { -#ifdef CONFIG_ISDN_TTY_FAX - if (chan->l2prot == ISDN_PROTO_L2_FAX) { - if ((ret = idi_faxdata_send(card, chan, skb)) > 0) - ret = len; - } - else -#endif - ret = idi_send_data(card, chan, ack, skb, 1, 1); - return (ret); - } else { - return -ENODEV; - } - } - printk(KERN_ERR - "eicon: if_sendbuf called with invalid driverId!\n"); - return -ENODEV; -} - -/* jiftime() copied from HiSax */ -static inline int jiftime(char *s, long mark) -{ - s += 8; - - *s-- = '\0'; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = '.'; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = mark % 6 + '0'; - mark /= 6; - *s-- = ':'; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = mark % 10 + '0'; - return(8); -} - -void -eicon_putstatus(eicon_card * card, char * buf) -{ - ulong flags; - int count; - isdn_ctrl cmd; - u_char *p; - struct sk_buff *skb; - - if (!card) { - if (!(card = cards)) - return; - } - - spin_lock_irqsave(&eicon_lock, flags); - count = strlen(buf); - skb = alloc_skb(count, GFP_ATOMIC); - if (!skb) { - spin_unlock_irqrestore(&eicon_lock, flags); - printk(KERN_ERR "eicon: could not alloc skb in putstatus\n"); - return; - } - p = skb_put(skb, count); - memcpy(p, buf, count); - - skb_queue_tail(&card->statq, skb); - - if (card->statq_entries >= MAX_STATUS_BUFFER) { - if ((skb = skb_dequeue(&card->statq))) { - count -= skb->len; - dev_kfree_skb(skb); - } else - count = 0; - } else - card->statq_entries++; - - spin_unlock_irqrestore(&eicon_lock, flags); - if (count) { - cmd.command = ISDN_STAT_STAVAIL; - cmd.driver = card->myid; - cmd.arg = count; - card->interface.statcallb(&cmd); - } -} - -/* - * Debug and Log - */ -void -eicon_log(eicon_card * card, int level, const char *fmt, ...) -{ - va_list args; - char Line[160]; - u_char *p; - - - if ((DebugVar & level) || (DebugVar & 256)) { - va_start(args, fmt); - - if (DebugVar & level) { - if (DebugVar & 256) { - /* log-buffer */ - p = Line; - p += jiftime(p, jiffies); - *p++ = 32; - p += vsprintf(p, fmt, args); - *p = 0; - eicon_putstatus(card, Line); - } else { - /* printk, syslogd */ - vsprintf(Line, fmt, args); - printk(KERN_DEBUG "%s", Line); - } - } - - va_end(args); - } -} - - -/* - * Allocate a new card-struct, initialize it - * link it into cards-list. - */ -static void -eicon_alloccard(int Type, int membase, int irq, char *id, int card_id) -{ - int i; - int j; - int qloop; -#ifdef CONFIG_ISDN_DRV_EICON_ISA - char qid[5]; -#endif - eicon_card *card; - - qloop = (Type == EICON_CTYPE_QUADRO)?2:0; - for (i = 0; i <= qloop; i++) { - if (!(card = (eicon_card *) kmalloc(sizeof(eicon_card), GFP_KERNEL))) { - eicon_log(card, 1, - "eicon: (%s) Could not allocate card-struct.\n", id); - return; - } - memset((char *) card, 0, sizeof(eicon_card)); - skb_queue_head_init(&card->sndq); - skb_queue_head_init(&card->rcvq); - skb_queue_head_init(&card->rackq); - skb_queue_head_init(&card->sackq); - skb_queue_head_init(&card->statq); - card->statq_entries = 0; - tasklet_init(&card->snd_tq, eicon_transmit, (unsigned long)card); - tasklet_init(&card->rcv_tq, eicon_rcv_dispatch, (unsigned long)card); - tasklet_init(&card->ack_tq, eicon_ack_dispatch, (unsigned long)card); - card->interface.owner = THIS_MODULE; - card->interface.maxbufsize = 4000; - card->interface.command = if_command; - card->interface.writebuf_skb = if_sendbuf; - card->interface.writecmd = if_writecmd; - card->interface.readstat = if_readstatus; - card->interface.features = - ISDN_FEATURE_L2_X75I | - ISDN_FEATURE_L2_HDLC | - ISDN_FEATURE_L2_TRANS | - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_UNKNOWN; - card->interface.hl_hdrlen = 20; - card->ptype = ISDN_PTYPE_UNKNOWN; - strlcpy(card->interface.id, id, sizeof(card->interface.id)); - card->myid = -1; - card->type = Type; - switch (Type) { -#ifdef CONFIG_ISDN_DRV_EICON_ISA -#ifdef CONFIG_MCA /* only needed for MCA */ - case EICON_CTYPE_S: - case EICON_CTYPE_SX: - case EICON_CTYPE_SCOM: - if (MCA_bus) { - if (membase == -1) - membase = EICON_ISA_MEMBASE; - if (irq == -1) - irq = EICON_ISA_IRQ; - card->bus = EICON_BUS_MCA; - card->hwif.isa.card = (void *)card; - card->hwif.isa.shmem = (eicon_isa_shmem *)membase; - card->hwif.isa.physmem = (unsigned long)membase; - card->hwif.isa.master = 1; - - card->hwif.isa.irq = irq; - card->hwif.isa.type = Type; - card->nchannels = 2; - card->interface.channels = 1; - } else { - printk(KERN_WARNING - "eicon (%s): no MCA bus detected.\n", - card->interface.id); - kfree(card); - return; - } - break; -#endif /* CONFIG_MCA */ - case EICON_CTYPE_QUADRO: - if (membase == -1) - membase = EICON_ISA_MEMBASE; - if (irq == -1) - irq = EICON_ISA_IRQ; - card->bus = EICON_BUS_ISA; - card->hwif.isa.card = (void *)card; - card->hwif.isa.shmem = (eicon_isa_shmem *)(membase + (i+1) * EICON_ISA_QOFFSET); - card->hwif.isa.physmem = (unsigned long)(membase + (i+1) * EICON_ISA_QOFFSET); - card->hwif.isa.master = 0; - strcpy(card->interface.id, id); - if (id[strlen(id) - 1] == 'a') { - card->interface.id[strlen(id) - 1] = 'a' + i + 1; - } else { - sprintf(qid, "_%c",'2' + i); - strcat(card->interface.id, qid); - } - printk(KERN_INFO "Eicon: Quadro: Driver-Id %s added.\n", - card->interface.id); - if (i == 0) { - eicon_card *p = cards; - while(p) { - if ((p->hwif.isa.master) && (p->hwif.isa.irq == irq)) { - p->qnext = card; - break; - } - p = p->next; - } - if (!p) { - eicon_log(card, 1, "eicon_alloccard: Quadro Master not found.\n"); - kfree(card); - return; - } - } else { - cards->qnext = card; - } - card->hwif.isa.irq = irq; - card->hwif.isa.type = Type; - card->nchannels = 2; - card->interface.channels = 1; - break; -#endif -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - case EICON_CTYPE_MAESTRA: - card->bus = EICON_BUS_PCI; - card->interface.features |= - ISDN_FEATURE_L2_V11096 | - ISDN_FEATURE_L2_V11019 | - ISDN_FEATURE_L2_V11038 | - ISDN_FEATURE_L2_MODEM | - ISDN_FEATURE_L2_FAX | - ISDN_FEATURE_L3_TRANSDSP | - ISDN_FEATURE_L3_FCLASS2; - card->hwif.pci.card = (void *)card; - card->hwif.pci.master = card_id; - card->hwif.pci.irq = irq; - card->hwif.pci.type = Type; - card->flags = 0; - card->nchannels = 2; - card->interface.channels = 1; - break; - - case EICON_CTYPE_MAESTRAQ: - card->bus = EICON_BUS_PCI; - card->interface.features |= - ISDN_FEATURE_L2_V11096 | - ISDN_FEATURE_L2_V11019 | - ISDN_FEATURE_L2_V11038 | - ISDN_FEATURE_L2_MODEM | - ISDN_FEATURE_L2_FAX | - ISDN_FEATURE_L3_TRANSDSP | - ISDN_FEATURE_L3_FCLASS2; - card->hwif.pci.card = (void *)card; - card->hwif.pci.master = card_id; - card->hwif.pci.irq = irq; - card->hwif.pci.type = Type; - card->flags = 0; - card->nchannels = 2; - card->interface.channels = 1; - break; - - case EICON_CTYPE_MAESTRAP: - card->bus = EICON_BUS_PCI; - card->interface.features |= - ISDN_FEATURE_L2_V11096 | - ISDN_FEATURE_L2_V11019 | - ISDN_FEATURE_L2_V11038 | - ISDN_FEATURE_L2_MODEM | - ISDN_FEATURE_L2_FAX | - ISDN_FEATURE_L3_TRANSDSP | - ISDN_FEATURE_L3_FCLASS2; - card->hwif.pci.card = (void *)card; - card->hwif.pci.master = card_id; - card->hwif.pci.irq = irq; - card->hwif.pci.type = Type; - card->flags = 0; - card->nchannels = 30; - card->interface.channels = 1; - break; -#endif -#endif -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_CTYPE_ISABRI: - if (membase == -1) - membase = EICON_ISA_MEMBASE; - if (irq == -1) - irq = EICON_ISA_IRQ; - card->bus = EICON_BUS_ISA; - card->hwif.isa.card = (void *)card; - card->hwif.isa.shmem = (eicon_isa_shmem *)membase; - card->hwif.isa.physmem = (unsigned long)membase; - card->hwif.isa.master = 1; - card->hwif.isa.irq = irq; - card->hwif.isa.type = Type; - card->nchannels = 2; - card->interface.channels = 1; - break; - case EICON_CTYPE_ISAPRI: - if (membase == -1) - membase = EICON_ISA_MEMBASE; - if (irq == -1) - irq = EICON_ISA_IRQ; - card->bus = EICON_BUS_ISA; - card->hwif.isa.card = (void *)card; - card->hwif.isa.shmem = (eicon_isa_shmem *)membase; - card->hwif.isa.physmem = (unsigned long)membase; - card->hwif.isa.master = 1; - card->hwif.isa.irq = irq; - card->hwif.isa.type = Type; - card->nchannels = 30; - card->interface.channels = 1; - break; -#endif - default: - eicon_log(card, 1, "eicon_alloccard: Invalid type %d\n", Type); - kfree(card); - return; - } - if (!(card->bch = (eicon_chan *) kmalloc(sizeof(eicon_chan) * (card->nchannels + 1) - , GFP_KERNEL))) { - eicon_log(card, 1, - "eicon: (%s) Could not allocate bch-struct.\n", id); - kfree(card); - return; - } - for (j=0; j< (card->nchannels + 1); j++) { - memset((char *)&card->bch[j], 0, sizeof(eicon_chan)); - card->bch[j].statectrl = 0; - card->bch[j].l2prot = ISDN_PROTO_L2_X75I; - card->bch[j].l3prot = ISDN_PROTO_L3_TRANS; - card->bch[j].e.D3Id = 0; - card->bch[j].e.B2Id = 0; - card->bch[j].e.Req = 0; - card->bch[j].No = j; - card->bch[j].tskb1 = NULL; - card->bch[j].tskb2 = NULL; - skb_queue_head_init(&card->bch[j].e.X); - skb_queue_head_init(&card->bch[j].e.R); - } - -#ifdef CONFIG_ISDN_DRV_EICON_PCI - /* *** Diva Server *** */ - if (!(card->dbuf = (DBUFFER *) kmalloc((sizeof(DBUFFER) * (card->nchannels + 1))*2 - , GFP_KERNEL))) { - eicon_log(card, 1, - "eicon: (%s) Could not allocate DBUFFER-struct.\n", id); - kfree(card); - kfree(card->bch); - return; - } - if (!(card->sbuf = (BUFFERS *) kmalloc((sizeof(BUFFERS) * (card->nchannels + 1)) * 2, GFP_KERNEL))) { - eicon_log(card, 1, - "eicon: (%s) Could not allocate BUFFERS-struct.\n", id); - kfree(card); - kfree(card->bch); - kfree(card->dbuf); - return; - } - if (!(card->sbufp = (char *) kmalloc((270 * (card->nchannels + 1)) * 2, GFP_KERNEL))) { - eicon_log(card, 1, - "eicon: (%s) Could not allocate BUFFERSP-struct.\n", id); - kfree(card); - kfree(card->bch); - kfree(card->dbuf); - kfree(card->sbuf); - return; - } - for (j=0; j< (card->nchannels + 1); j++) { - memset((char *)&card->dbuf[j], 0, sizeof(DBUFFER)); - card->bch[j].de.RBuffer = (DBUFFER *)&card->dbuf[j]; - memset((char *)&card->dbuf[j+(card->nchannels+1)], 0, sizeof(BUFFERS)); - card->bch[j].be.RBuffer = (DBUFFER *)&card->dbuf[j+(card->nchannels+1)]; - - memset((char *)&card->sbuf[j], 0, sizeof(BUFFERS)); - card->bch[j].de.X = (BUFFERS *)&card->sbuf[j]; - memset((char *)&card->sbuf[j+(card->nchannels+1)], 0, sizeof(BUFFERS)); - card->bch[j].be.X = (BUFFERS *)&card->sbuf[j+(card->nchannels+1)]; - - memset((char *)&card->sbufp[j], 0, 270); - card->bch[j].de.X->P = (char *)&card->sbufp[j * 270]; - memset((char *)&card->sbufp[j+(card->nchannels+1)], 0, 270); - card->bch[j].be.X->P = (char *)&card->sbufp[(j+(card->nchannels+1)) * 270]; - } - /* *** */ -#endif /* CONFIG_ISDN_DRV_EICON_PCI */ - - card->next = cards; - cards = card; - } -} - -/* - * register card at linklevel - */ -static int -eicon_registercard(eicon_card * card) -{ - switch (card->bus) { -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_BUS_ISA: - /* TODO something to print */ - break; -#ifdef CONFIG_MCA - case EICON_BUS_MCA: - eicon_isa_printpar(&card->hwif.isa); - break; -#endif /* CONFIG_MCA */ -#endif - case EICON_BUS_PCI: - break; - default: - eicon_log(card, 1, - "eicon_registercard: Illegal BUS type %d\n", - card->bus); - return -1; - } - if (!register_isdn(&card->interface)) { - printk(KERN_WARNING - "eicon_registercard: Unable to register %s\n", - card->interface.id); - return -1; - } - card->myid = card->interface.channels; - sprintf(card->regname, "%s", card->interface.id); - return 0; -} - -static void __exit -unregister_card(eicon_card * card) -{ - isdn_ctrl cmd; - - cmd.command = ISDN_STAT_UNLOAD; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - switch (card->bus) { -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_BUS_ISA: -#ifdef CONFIG_MCA - case EICON_BUS_MCA: -#endif /* CONFIG_MCA */ - eicon_isa_release(&card->hwif.isa); - break; -#endif - case EICON_BUS_PCI: - break; - default: - eicon_log(card, 1, - "eicon: Invalid BUS type %d\n", - card->bus); - break; - } -} - -static void -eicon_freecard(eicon_card *card) { - int i; - - for(i = 0; i < (card->nchannels + 1); i++) { - skb_queue_purge(&card->bch[i].e.X); - skb_queue_purge(&card->bch[i].e.R); - } - skb_queue_purge(&card->sndq); - skb_queue_purge(&card->rcvq); - skb_queue_purge(&card->rackq); - skb_queue_purge(&card->sackq); - skb_queue_purge(&card->statq); - -#ifdef CONFIG_ISDN_DRV_EICON_PCI - kfree(card->sbufp); - kfree(card->sbuf); - kfree(card->dbuf); -#endif - kfree(card->bch); - kfree(card); -} - -int -eicon_addcard(int Type, int membase, int irq, char *id, int card_id) -{ - eicon_card *p; - eicon_card *q = NULL; - int registered; - int added = 0; - int failed = 0; - -#ifdef CONFIG_ISDN_DRV_EICON_ISA - if (!Type) /* ISA */ - if ((Type = eicon_isa_find_card(membase, irq, id)) < 0) - return 0; -#endif - eicon_alloccard(Type, membase, irq, id, card_id); - p = cards; - while (p) { - registered = 0; - if (!p->interface.statcallb) { - /* Not yet registered. - * Try to register and activate it. - */ - added++; - switch (p->bus) { -#ifdef CONFIG_ISDN_DRV_EICON_ISA - case EICON_BUS_ISA: - case EICON_BUS_MCA: - if (eicon_registercard(p)) - break; - registered = 1; - break; -#endif - case EICON_BUS_PCI: -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - if (eicon_registercard(p)) - break; - registered = 1; - break; -#endif -#endif - default: - printk(KERN_ERR - "eicon: addcard: Invalid BUS type %d\n", - p->bus); - } - } else - /* Card already registered */ - registered = 1; - if (registered) { - /* Init OK, next card ... */ - q = p; - p = p->next; - } else { - /* registering failed, remove card from list, free memory */ - printk(KERN_ERR - "eicon: Initialization of %s failed\n", - p->interface.id); - if (q) { - q->next = p->next; - eicon_freecard(p); - p = q->next; - } else { - cards = p->next; - eicon_freecard(p); - p = cards; - } - failed++; - } - } - return (added - failed); -} - - -static int __init -eicon_init(void) -{ - int card_count = 0; - char tmprev[50]; - - DebugVar = 1; - eicon_lock = (spinlock_t) SPIN_LOCK_UNLOCKED; - - printk(KERN_INFO "%s Rev: ", DRIVERNAME); - strcpy(tmprev, eicon_revision); - printk("%s/", eicon_getrev(tmprev)); - strcpy(tmprev, eicon_pci_revision); -#ifdef CONFIG_ISDN_DRV_EICON_PCI - printk("%s/", eicon_getrev(tmprev)); -#else - printk("---/"); -#endif - strcpy(tmprev, eicon_isa_revision); -#ifdef CONFIG_ISDN_DRV_EICON_ISA - printk("%s/", eicon_getrev(tmprev)); -#else - printk("---/"); -#endif - strcpy(tmprev, eicon_idi_revision); - printk("%s\n", eicon_getrev(tmprev)); - printk(KERN_INFO "%s Release: %s%s\n", DRIVERNAME, - DRIVERRELEASE, DRIVERPATCH); - -#ifdef CONFIG_ISDN_DRV_EICON_ISA -#ifdef CONFIG_MCA - /* Check if we have MCA-bus */ - if (!MCA_bus) - { - printk(KERN_INFO - "eicon: No MCA bus, ISDN-interfaces not probed.\n"); - } else { - eicon_log(NULL, 8, - "eicon_mca_find_card, irq=%d.\n", - irq); - if (!eicon_mca_find_card(0, membase, irq, id)) - card_count++; - }; -#else - card_count = eicon_addcard(0, membase, irq, id, 0); -#endif /* CONFIG_MCA */ -#endif /* CONFIG_ISDN_DRV_EICON_ISA */ - -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - DivasCardsDiscover(); - card_count += eicon_pci_find_card(id); -#endif -#endif - - if (!cards) { -#ifdef MODULE -#ifndef CONFIG_ISDN_DRV_EICON_PCI -#ifndef CONFIG_ISDN_DRV_EICON_ISA - printk(KERN_INFO "Eicon: Driver is neither ISA nor PCI compiled !\n"); - printk(KERN_INFO "Eicon: Driver not loaded !\n"); -#else - printk(KERN_INFO "Eicon: No cards defined, driver not loaded !\n"); -#endif -#else - printk(KERN_INFO "Eicon: No PCI-cards found, driver not loaded !\n"); -#endif -#endif /* MODULE */ - return -ENODEV; - - } else - printk(KERN_INFO "Eicon: %d card%s added\n", card_count, - (card_count>1)?"s":""); - return 0; -} - -#ifdef CONFIG_ISDN_DRV_EICON_PCI -void DIVA_DIDD_Write(DESCRIPTOR *, int); -EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Read); -EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Write); -EXPORT_SYMBOL_NOVERS(DivasPrintf); -#else -int DivasCardNext; -card_t DivasCards[1]; -#endif - -static void __exit -eicon_exit(void) -{ -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - card_t *pCard; - word wCardIndex; - extern int Divas_major; - int iTmp = 0; -#endif -#endif - - eicon_card *card = cards; - eicon_card *last; - - while (card) { -#ifdef CONFIG_ISDN_DRV_EICON_ISA -#ifdef CONFIG_MCA - if (MCA_bus) - { - mca_mark_as_unused (card->mca_slot); - mca_set_adapter_procfn(card->mca_slot, NULL, NULL); - }; -#endif /* CONFIG_MCA */ -#endif - unregister_card(card); - card = card->next; - } - card = cards; - while (card) { - last = card; - card = card->next; - eicon_freecard(last); - } - -#ifdef CONFIG_PCI -#ifdef CONFIG_ISDN_DRV_EICON_PCI - pCard = DivasCards; - for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++) - { - if ((pCard->hw) && (pCard->hw->in_use)) - { - (*pCard->card_reset)(pCard); - - UxIsrRemove(pCard->hw, pCard); - UxCardHandleFree(pCard->hw); - - if(pCard->e_tbl != NULL) - { - kfree(pCard->e_tbl); - } - - if(pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_B) - { - release_region(pCard->hw->io_base,0x20); - release_region(pCard->hw->reset_base,0x80); - } - - // If this is a 4BRI ... - if (pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q) - { - // Skip over the next 3 virtual adapters - wCardIndex += 3; - - // But free their handles - for (iTmp = 0; iTmp < 3; iTmp++) - { - pCard++; - UxCardHandleFree(pCard->hw); - - if(pCard->e_tbl != NULL) - { - kfree(pCard->e_tbl); - } - } - } - } - pCard++; - } - unregister_chrdev(Divas_major, "Divas"); -#endif -#endif /* CONFIG_PCI */ - printk(KERN_INFO "%s unloaded\n", DRIVERNAME); -} - -#ifndef MODULE - -static int __init -eicon_setup(char *line) -{ - int i, argc; - int ints[5]; - char *str; - - str = get_options(line, 4, ints); - - argc = ints[0]; - i = 1; -#ifdef CONFIG_ISDN_DRV_EICON_ISA - if (argc) { - membase = irq = -1; - if (argc) { - membase = ints[i]; - i++; - argc--; - } - if (argc) { - irq = ints[i]; - i++; - argc--; - } - if (strlen(str)) { - strcpy(id, str); - } else { - strcpy(id, "eicon"); - } - printk(KERN_INFO "Eicon ISDN active driver setup (id=%s membase=0x%x irq=%d)\n", - id, membase, irq); - } -#else - printk(KERN_INFO "Eicon ISDN active driver setup\n"); -#endif - return(1); -} -__setup("eicon=", eicon_setup); - -#endif /* MODULE */ - -#ifdef CONFIG_ISDN_DRV_EICON_ISA -#ifdef CONFIG_MCA - -struct eicon_mca_adapters_struct { - char * name; - int adf_id; -}; -/* possible MCA-brands of eicon cards */ -struct eicon_mca_adapters_struct eicon_mca_adapters[] = { - { "ISDN-P/2 Adapter", 0x6abb }, - { "ISDN-[S|SX|SCOM]/2 Adapter", 0x6a93 }, - { "DIVA /MCA", 0x6336 }, - { NULL, 0 }, -}; - -int eicon_mca_find_card(int type, /* type-idx of eicon-card */ - int membase, - int irq, - char * id) /* name of eicon-isdn-dev */ -{ - int j, curr_slot = 0; - - eicon_log(NULL, 8, - "eicon_mca_find_card type: %d, membase: %#x, irq %d \n", - type, membase, irq); - /* find a no-driver-assigned eicon card */ - for (j=0; eicon_mca_adapters[j].adf_id != 0; j++) - { - for ( curr_slot=0; curr_slot<=MCA_MAX_SLOT_NR; curr_slot++) - { - curr_slot = mca_find_unused_adapter( - eicon_mca_adapters[j].adf_id, curr_slot); - if (curr_slot != MCA_NOTFOUND) - { - /* check if pre-set parameters match - these of the card, check cards memory */ - if (!(int) eicon_mca_probe(curr_slot, - j, - membase, - irq, - id)) - { - return 0; - /* means: adapter parms did match */ - }; - }; - break; - /* MCA_NOTFOUND-branch: no matching adapter of - THIS flavor found, next flavor */ - - }; - }; - /* all adapter flavors checked without match, finito with: */ - return -ENODEV; -}; - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * stolen from 3c523.c/elmc_getinfo, ewe, 10.5.1999 - */ -int eicon_info(char * buf, int slot, void *d) -{ - int len = 0; - struct eicon_card *dev; - - dev = (struct eicon_card *) d; - - if (dev == NULL) - return len; - len += sprintf(buf+len, "eicon ISDN adapter, type %d.\n",dev->type); - len += sprintf(buf+len, "IRQ: %d\n", dev->hwif.isa.irq); - len += sprintf(buf+len, "MEMBASE: %#lx\n", (unsigned long)dev->hwif.isa.shmem); - - return len; -}; - -int eicon_mca_probe(int slot, /* slot-nr where the card was detected */ - int a_idx, /* idx-nr of probed card in eicon_mca_adapters */ - int membase, - int irq, - char * id) /* name of eicon-isdn-dev */ -{ - unsigned char adf_pos0; - int cards_irq, cards_membase, cards_io; - int type = EICON_CTYPE_S; - int irq_array[]={0,3,4,2}; - int irq_array1[]={3,4,0,0,2,10,11,12}; - - adf_pos0 = mca_read_stored_pos(slot,2); - eicon_log(NULL, 8, - "eicon_mca_probe irq=%d, membase=%d\n", - irq, - membase); - switch (a_idx) { - case 0: /* P/2-Adapter (== PRI/S2M ? ) */ - cards_membase= 0xC0000+((adf_pos0>>4)*0x4000); - if (membase == -1) { - membase = cards_membase; - } else { - if (membase != cards_membase) - return -ENODEV; - }; - cards_irq=irq_array[((adf_pos0 & 0xC)>>2)]; - if (irq == -1) { - irq = cards_irq; - } else { - if (irq != cards_irq) - return -ENODEV; - }; - cards_io= 0xC00 + ((adf_pos0>>4)*0x10); - type = EICON_CTYPE_ISAPRI; - break; - - case 1: /* [S|SX|SCOM]/2 */ - cards_membase= 0xC0000+((adf_pos0>>4)*0x2000); - if (membase == -1) { - membase = cards_membase; - } else { - if (membase != cards_membase) - return -ENODEV; - }; - cards_irq=irq_array[((adf_pos0 & 0xC)>>2)]; - if (irq == -1) { - irq = cards_irq; - } else { - if (irq != cards_irq) - return -ENODEV; - }; - - cards_io= 0xC00 + ((adf_pos0>>4)*0x10); - type = EICON_CTYPE_SCOM; - break; - - case 2: /* DIVA/MCA */ - cards_io = 0x200+ ((adf_pos0>>4)* 0x20); - cards_irq = irq_array1[(adf_pos0 & 0x7)]; - if (irq == -1) { - irq = cards_irq; - } else { - if (irq != cards_irq) - return -ENODEV; - }; - type = 0; - break; - default: - return -ENODEV; - }; - /* matching membase & irq */ - if ( 1 == eicon_addcard(type, membase, irq, id, 0)) { - mca_set_adapter_name(slot, eicon_mca_adapters[a_idx].name); - mca_set_adapter_procfn(slot, (MCA_ProcFn) eicon_info, cards); - - mca_mark_as_used(slot); - cards->mca_slot = slot; - /* card->io noch setzen oder ?? */ - cards->mca_io = cards_io; - cards->hwif.isa.io = cards_io; - /* reset card */ - outb_p(0,cards_io+1); - - eicon_log(NULL, 8, "eicon_addcard: successful for slot # %d.\n", - cards->mca_slot+1); - return 0 ; /* eicon_addcard added a card */ - } else { - return -ENODEV; - }; -}; -#endif /* CONFIG_MCA */ -#endif /* CONFIG_ISDN_DRV_EICON_ISA */ - -module_init(eicon_init); -module_exit(eicon_exit); diff --git a/drivers/isdn/eicon/eicon_pci.c b/drivers/isdn/eicon/eicon_pci.c deleted file mode 100644 index 926816358ef2..000000000000 --- a/drivers/isdn/eicon/eicon_pci.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $Id: eicon_pci.c,v 1.1.4.1.2.3 2002/10/01 11:29:13 armin Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards. - * Hardware-specific code for PCI cards. - * - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - * Thanks to Eicon Networks for - * documents, informations and hardware. - * - */ - -#include <linux/config.h> -#include <linux/pci.h> - -#include "eicon.h" -#include "eicon_pci.h" - -#undef N_DATA -#include "adapter.h" -#include "uxio.h" - -char *eicon_pci_revision = "$Revision: 1.1.4.1.2.3 $"; - -#ifdef CONFIG_PCI /* entire stuff is only for PCI */ -#ifdef CONFIG_ISDN_DRV_EICON_PCI - -int eicon_pci_find_card(char *ID) -{ - int pci_cards = 0; - int card_id = 0; - int had_q = 0; - int ctype = 0; - char did[20]; - card_t *pCard; - word wCardIndex; - - pCard = DivasCards; - for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++) - { - if ((pCard->hw) && (pCard->hw->in_use)) - { - switch(pCard->hw->card_type) { - case DIA_CARD_TYPE_DIVA_SERVER: - ctype = EICON_CTYPE_MAESTRAP; - card_id++; - had_q = 0; - break; - case DIA_CARD_TYPE_DIVA_SERVER_B: - ctype = EICON_CTYPE_MAESTRA; - card_id++; - had_q = 0; - break; - case DIA_CARD_TYPE_DIVA_SERVER_Q: - ctype = EICON_CTYPE_MAESTRAQ; - if (!had_q) - card_id++; - if (++had_q >=4) - had_q = 0; - break; - default: - printk(KERN_ERR "eicon_pci: unknown card type %d !\n", - pCard->hw->card_type); - goto err; - } - sprintf(did, "%s%d", (strlen(ID) < 1) ? "eicon":ID, pci_cards); - if ((!ctype) || (!(eicon_addcard(ctype, 0, pCard->hw->irq, did, card_id)))) { - printk(KERN_ERR "eicon_pci: Card could not be added !\n"); - } else { - pci_cards++; - printk(KERN_INFO "%s: DriverID='%s' CardID=%d\n", - eicon_ctype_name[ctype], did, card_id); - } -err:; - } - pCard++; - } - return pci_cards; -} - -void -eicon_pci_init_conf(eicon_card *card) -{ - int j; - - /* initializing some variables */ - card->ReadyInt = 0; - - for(j = 0; j < 256; j++) - card->IdTable[j] = NULL; - - for(j = 0; j < (card->d->channels + 1); j++) { - card->bch[j].e.busy = 0; - card->bch[j].e.D3Id = 0; - card->bch[j].e.B2Id = 0; - card->bch[j].e.ref = 0; - card->bch[j].e.Req = 0; - card->bch[j].e.complete = 1; - card->bch[j].fsm_state = EICON_STATE_NULL; - } -} - -#endif -#endif /* CONFIG_PCI */ - diff --git a/drivers/isdn/eicon/eicon_pci.h b/drivers/isdn/eicon/eicon_pci.h deleted file mode 100644 index 7f58e9b636b3..000000000000 --- a/drivers/isdn/eicon/eicon_pci.h +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: eicon_pci.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $ - * - * ISDN low-level module for Eicon active ISDN-Cards (PCI part). - * - * Copyright 1998-2000 by Armin Schindler (mac@melware.de) - * Copyright 1999,2000 Cytronics & Melware (info@melware.de) - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef eicon_pci_h -#define eicon_pci_h - -#ifdef __KERNEL__ - -/* - * card's description - */ -typedef struct { - int irq; /* IRQ */ - int channels; /* No. of supported channels */ - void* card; - unsigned char type; /* card type */ - unsigned char master; /* Flag: Card is Quadro 1/4 */ -} eicon_pci_card; - -extern int eicon_pci_find_card(char *ID); - -#endif /* __KERNEL__ */ - -#endif /* eicon_pci_h */ - diff --git a/drivers/isdn/eicon/fourbri.c b/drivers/isdn/eicon/fourbri.c deleted file mode 100644 index 42c4c0a09561..000000000000 --- a/drivers/isdn/eicon/fourbri.c +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Diva Server 4BRI specific part of initialisation - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.7 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "sys.h" -#include "idi.h" -#include "divas.h" -#include "pc.h" -#include "pr_pc.h" -#include "dsp_defs.h" -#include "constant.h" -#include "adapter.h" -#include "uxio.h" - -#define TEST_INT_DIVAS_Q 0x13 - -#define DIVAS_MAINT_OFFSET 0xff00 /* value for 4BRI card */ -#define MQ_BOARD_DSP_OFFSET 0x00a00000 -#define MQ_DSP1_ADDR_OFFSET 0x00000008 -#define MQ_DSP_JUNK_OFFSET 0x00000400 -#define MQ_DSP1_DATA_OFFSET 0x00000000 -#define MQ_BOARD_ISAC_DSP_RESET 0x00800028 -#define MQ_BREG_RISC 0x1200 /* RISC Reset */ -#define MQ_ISAC_DSP_RESET 0x0028 /* ISAC and DSP reset address offset */ -#define MQ_RISC_COLD_RESET_MASK 0x0001 /* RISC Cold reset */ -#define MQ_RISC_WARM_RESET_MASK 0x0002 /* RISC Warm reset */ -#define MQ_IRQ_REQ_ON 0x1 -#define MQ_IRQ_REQ_OFF 0x0 -#define MQ_BREG_IRQ_TEST 0x0608 -#define PLX9054_INTCSR 0x69 -#define PLX9054_INT_ENA 0x09 - -#define DIVAS_IOBASE 0x01 -#define M_PCI_RESET 0x10 - -byte mem_in(ADAPTER *a, void *adr); -word mem_inw(ADAPTER *a, void *adr); -void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length); -void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e); -void mem_out(ADAPTER *a, void *adr, byte data); -void mem_outw(ADAPTER *a, void *adr, word data); -void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length); -void mem_inc(ADAPTER *a, void *adr); - -int Divas4BRIInitPCI(card_t *card, dia_card_t *cfg); -static int fourbri_ISR (card_t* card); - -int FPGA_Download(word, dword, byte *, byte *, int); -extern byte FPGA_Bytes[]; -extern void *get_card(int); - -byte UxCardPortIoIn(ux_diva_card_t *card, byte *base, int offset); -void UxCardPortIoOut(ux_diva_card_t *card, byte *base, int offset, byte); -word GetProtFeatureValue(char *sw_id); - -void memcp(byte *dst, byte *src, dword dwLen); -int memcm(byte *dst, byte *src, dword dwLen); - -static int diva_server_4bri_reset(card_t *card) -{ - byte *ctl; - - DPRINTF(("divas: reset Diva Server 4BRI")); - - ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY); - - /* stop RISC, DSP's and ISAC */ - UxCardMemOut(card->hw, &ctl[MQ_BREG_RISC], 0); - UxCardMemOut(card->hw, &ctl[MQ_ISAC_DSP_RESET], 0); - - UxCardMemDetach(card->hw, ctl); - - return 0; -} - -static int diva_server_4bri_config(card_t *card, dia_config_t *config) -{ - byte *shared; - int i, j; - - DPRINTF(("divas: configure Diva Server 4BRI")); - - shared = (byte *) UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - for (i=0; i<256; i++) - { - UxCardMemOut(card->hw, &shared[i], 0); - } - - UxCardMemOut(card->hw, &shared[ 8], config->tei); - UxCardMemOut(card->hw, &shared[ 9], config->nt2); - UxCardMemOut(card->hw, &shared[10], config->sig_flags); - UxCardMemOut(card->hw, &shared[11], config->watchdog); - UxCardMemOut(card->hw, &shared[12], config->permanent); - UxCardMemOut(card->hw, &shared[13], config->x_interface); - UxCardMemOut(card->hw, &shared[14], config->stable_l2); - UxCardMemOut(card->hw, &shared[15], config->no_order_check); - UxCardMemOut(card->hw, &shared[16], config->handset_type); - UxCardMemOut(card->hw, &shared[17], 0); - UxCardMemOut(card->hw, &shared[18], config->low_channel); - UxCardMemOut(card->hw, &shared[19], config->prot_version); - UxCardMemOut(card->hw, &shared[20], config->crc4); - - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - DPRINTF(("divas: Signifying V.90")); - UxCardMemOut(card->hw, &shared[22], 4); - } - else - { - UxCardMemOut(card->hw, &shared[22], 0); - } - - for (i=0; i<2; i++) - { - for (j=0; j<32; j++) - { - UxCardMemOut(card->hw, &shared[32+(i*96)+j],config->terminal[i].oad[j]); - } - - for (j=0; j<32; j++) - { - UxCardMemOut(card->hw, &shared[64+(i*96)+j],config->terminal[i].osa[j]); - } - - for (j=0; j<32; j++) - { - UxCardMemOut(card->hw, &shared[96+(i*96)+j],config->terminal[i].spid[j]); - } - } - - UxCardMemDetach(card->hw, shared); - - return 0; -} - -static -void diva_server_4bri_reset_int(card_t *card) -{ - byte *ctl; - - ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY); - - UxCardMemOut(card->hw, &ctl[MQ_BREG_IRQ_TEST], MQ_IRQ_REQ_OFF); - - UxCardMemDetach(card->hw, ctl); - - return; -} - - -static int diva_server_4bri_test_int(card_t *card) -{ - byte *ctl, i; - byte *reg; - - DPRINTF(("divas: test interrupt for Diva Server 4BRI")); - - /* We get the last (dummy) adapter in so we need to go back to the first */ - - card = get_card(card->cfg.card_id - 3); - - /* Enable interrupts on PLX chip */ - - reg = UxCardMemAttach(card->hw, DIVAS_REG_MEMORY); - - UxCardPortIoOut(card->hw, reg, PLX9054_INTCSR, PLX9054_INT_ENA); - - UxCardMemDetach(card->hw, reg); - - /* Set the test interrupt flag */ - card->test_int_pend = TEST_INT_DIVAS_Q; - - /* Now to trigger the interrupt */ - - ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY); - - UxCardMemOut(card->hw, &ctl[MQ_BREG_IRQ_TEST], MQ_IRQ_REQ_ON); - - UxCardMemDetach(card->hw, ctl); - - for (i = 0; i < 50; i++) - { - if (!card->test_int_pend) - { - break; - } - UxPause(10); - } - - if (card->test_int_pend) - { - DPRINTF(("active: timeout waiting for card to interrupt")); - return (-1); - } - - return 0; -} - - -static void print_hdr(unsigned char *code, int offset) -{ - unsigned char hdr[80]; - int i; - - i = 0; - - while ((i < (DIM(hdr) -1)) && - (code[offset + i] != '\0') && - (code[offset + i] != '\r') && - (code[offset + i] != '\n')) - { - hdr[i] = code[offset + i]; - i++; - } - - hdr[i] = '\0'; - - DPRINTF(("divas: loading %s", hdr)); -} - -static int diva_server_4bri_load(card_t *card, dia_load_t *load) -{ - byte *pRAM=NULL; - int download_offset=0; - card_t *FirstCard; - byte sw_id[80]; - - DPRINTF(("divas: loading Diva Server 4BRI[%d]", load->card_id)); - - switch(load->code_type) - { - case DIA_CPU_CODE: - DPRINTF(("divas: RISC code")); - print_hdr(load->code, 0x80); - card->hw->features = GetProtFeatureValue((char *)&load->code[0x80]); - download_offset = 0; // Protocol code written to offset 0 - pRAM = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY); - break; - - case DIA_DSP_CODE: - DPRINTF(("divas: DSP code")); - print_hdr(load->code, 0x0); - FirstCard = get_card(load->card_id - 3); - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - download_offset = MQ_V90D_DSP_CODE_BASE; - } - else - { - download_offset = MQ_ORG_DSP_CODE_BASE; - } - pRAM = UxCardMemAttach(FirstCard->hw, DIVAS_RAM_MEMORY); - download_offset += (((sizeof(dword) + (sizeof(t_dsp_download_desc)* DSP_MAX_DOWNLOAD_COUNT)) + 3) & 0xFFFFFFFC); - - break; - - case DIA_TABLE_CODE: - DPRINTF(("divas: TABLE code")); - FirstCard = get_card(load->card_id - 3); - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - download_offset = MQ_V90D_DSP_CODE_BASE + sizeof(dword); - } - else - { - download_offset = MQ_ORG_DSP_CODE_BASE + sizeof(dword); - } - pRAM = UxCardMemAttach(FirstCard->hw, DIVAS_RAM_MEMORY); - break; - - case DIA_CONT_CODE: - DPRINTF(("divas: continuation code")); - break; - - case DIA_DLOAD_CNT: - DPRINTF(("divas: COUNT code")); - FirstCard = get_card(load->card_id - 3); - if ((card->hw->features) && (card->hw->features & PROTCAP_V90D)) - { - download_offset = MQ_V90D_DSP_CODE_BASE; - } - else - { - download_offset = MQ_ORG_DSP_CODE_BASE; - } - pRAM = UxCardMemAttach(FirstCard->hw, DIVAS_RAM_MEMORY); - break; - - case DIA_FPGA_CODE: - DPRINTF(("divas: 4BRI FPGA download - %d bytes", load->length)); - if (FPGA_Download(IDI_ADAPTER_MAESTRAQ, - card->hw->io_base, - sw_id, - load->code, - load->length - ) == -1) - { - DPRINTF(("divas: FPGA download failed")); - return -1; - } - - /* NOW reset the 4BRI */ - diva_server_4bri_reset(card); - return 0; // No need for anything further loading - - default: - DPRINTF(("divas: unknown code type")); - return -1; - } - - memcp(pRAM + (download_offset & 0x3FFFFF), load->code, load->length); - - { - int mism_off; - if ((mism_off = memcm(pRAM + (download_offset & 0x3FFFFF), load->code, load->length))) - { - DPRINTF(("divas: memory mismatch at offset %d", mism_off)); - UxCardMemDetach(card->hw, pRAM); - return -1; - } - } - - UxCardMemDetach(card->hw, pRAM); - - return 0; -} - -static int diva_server_4bri_start(card_t *card, byte *channels) -{ - byte *ctl; - byte *shared, i; - int adapter_num; - - DPRINTF(("divas: start Diva Server 4BRI")); - *channels = 0; - card->is_live = FALSE; - - ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY); - - UxCardMemOutW(card->hw, &ctl[MQ_BREG_RISC], MQ_RISC_COLD_RESET_MASK); - - UxPause(2); - - UxCardMemOutW(card->hw, &ctl[MQ_BREG_RISC], MQ_RISC_WARM_RESET_MASK | MQ_RISC_COLD_RESET_MASK); - - UxPause(10); - - UxCardMemDetach(card->hw, ctl); - - shared = (byte *) UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - for ( i = 0 ; i < 300 ; ++i ) - { - UxPause (10) ; - - if ( UxCardMemInW(card->hw, &shared[0x1E]) == 0x4447 ) - { - DPRINTF(("divas: Protocol startup time %d.%02d seconds", - (i / 100), (i % 100) )); - - break; - } - } - - if (i==300) - { - DPRINTF(("divas: Timeout starting card")); - DPRINTF(("divas: Signature == 0x%04X", UxCardMemInW(card->hw, &shared[0x1E]))); - - UxCardMemDetach(card->hw, shared); - return -1; - } - - UxCardMemDetach(card->hw, shared); - - for (adapter_num=3; adapter_num >= 0; adapter_num--) - { - card_t *qbri_card; - - qbri_card = get_card(card->cfg.card_id - adapter_num); - - if (qbri_card) - { - qbri_card->is_live = TRUE; - shared = UxCardMemAttach(qbri_card->hw, DIVAS_SHARED_MEMORY); - *channels += UxCardMemIn(qbri_card->hw, &shared[0x3F6]); - UxCardMemDetach(qbri_card->hw, shared); - } - else - { - DPRINTF(("divas: Couldn't get card info %d", card->cfg.card_id)); - } - } - - diva_server_4bri_test_int(card); - - return 0; -} - -static -int diva_server_4bri_mem_get(card_t *card, mem_block_t *mem_block) - -{ - byte *a; - byte *card_addr; - word length = 0; - int i; - - a = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY); - - card_addr = a; - card_addr += mem_block->addr; - - for (i=0; i < sizeof(mem_block->data); i++) - { - mem_block->data[i] = UxCardMemIn(card->hw, card_addr); - card_addr++; - length++; - } - - UxCardMemDetach(card->hw, a); - - return length; -} - -/* - * Initialise 4BRI specific entry points - */ - -int Divas4BriInit(card_t *card, dia_card_t *cfg) -{ -// byte sw_id[80]; -// extern int FPGA_Done; - - DPRINTF(("divas: initialise Diva Server 4BRI")); - - if (Divas4BRIInitPCI(card, cfg) == -1) - { - return -1; - } - - /* Need to download the FPGA */ -/* if (!FPGA_Done) - { - int retVal; - - retVal=FPGA_Download(IDI_ADAPTER_MAESTRAQ, - cfg->io_base, - sw_id, - FPGA_Bytes - ); - if(retVal==-1) - { - - DPRINTF(("divas: FPGA Download Failed")); - return -1; - - } - FPGA_Done = 1; - } */ - - card->card_reset = diva_server_4bri_reset; - card->card_load = diva_server_4bri_load; - card->card_config = diva_server_4bri_config; - card->card_start = diva_server_4bri_start; - card->reset_int = diva_server_4bri_reset_int; - card->card_mem_get = diva_server_4bri_mem_get; - - card->xlog_offset = DIVAS_MAINT_OFFSET; - - card->out = DivasOut; - card->test_int = DivasTestInt; - card->dpc = DivasDpc; - card->clear_int = DivasClearInt; - card->card_isr = fourbri_ISR; - - card->a.ram_out = mem_out; - card->a.ram_outw = mem_outw; - card->a.ram_out_buffer = mem_out_buffer; - card->a.ram_inc = mem_inc; - - card->a.ram_in = mem_in; - card->a.ram_inw = mem_inw; - card->a.ram_in_buffer = mem_in_buffer; - card->a.ram_look_ahead = mem_look_ahead; - - return 0; -} - -void memcp(byte *dst, byte *src, dword dwLen) -{ - while (dwLen) - { - *dst = *src; - dst++; src++; - dwLen--; - } -} - -int memcm(byte *dst, byte *src, dword dwLen) -{ - int offset = 0; - - while (offset < dwLen) - { - if(*dst != *src) - return (offset+1); - - offset++; - src++; - dst++; - } - - return 0; -} - - - -/*int fourbri_ISR (card_t* card) -{ - int served = 0; - byte *DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE); - - - if (UxCardPortIoIn (card->hw, DivasIOBase, M_PCI_RESET) & 0x01) - { - served = 1; - card->int_pend += 1; - DivasDpcSchedule(); - UxCardPortIoOut (card->hw, DivasIOBase, M_PCI_RESET, 0x08); - } - - UxCardMemDetach(card->hw, DivasIOBase); - - return (served != 0); -}*/ - - -static int fourbri_ISR (card_t* card) -{ - byte *ctl; - - card->int_pend += 1; - DivasDpcSchedule(); /* ISR DPC */ - - ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY); - UxCardMemOut(card->hw, &ctl[MQ_BREG_IRQ_TEST], MQ_IRQ_REQ_OFF); - UxCardMemDetach(card->hw, ctl); - - return (1); -} diff --git a/drivers/isdn/eicon/fpga.c b/drivers/isdn/eicon/fpga.c deleted file mode 100644 index be858533804b..000000000000 --- a/drivers/isdn/eicon/fpga.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.2 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "sys.h" -#include "idi.h" -#include "uxio.h" - -#define FPGA_PORT 0x6E -#define FPGA_DLOAD_BUFLEN 256 -#define NAME_OFFSET 0x10 -#define NAME_MAXLEN 12 -#define DATE_OFFSET 0x2c -#define DATE_MAXLEN 10 - -word UxCardPortIoInW(ux_diva_card_t *card, byte *base, int offset); -void UxCardPortIoOutW(ux_diva_card_t *card, byte *base, int offset, word); -void UxPause(long int); - -/*-------------------------------------------------------------------------*/ -/* Loads the FPGA configuration file onto the hardware. */ -/* Function returns 0 on success, else an error number. */ -/* On success, an identifier string is returned in the buffer */ -/* */ -/* A buffer of FPGA_BUFSIZE, a handle to the already opened bitstream */ -/* file and a file read function has to be provided by the operating */ -/* system part. */ -/* ----------------------------------------------------------------------- */ -int FPGA_Download( word cardtype, - dword RegBase, - byte *strbuf, - byte FPGA_SRC[], - int FPGA_LEN - ) -{ - word i, j, k; - word baseval, Mask_PROGRAM, Mask_DONE, Mask_CCLK, Mask_DIN; - dword addr; - byte *pFPGA; - - //--- check for legal cardtype - switch (cardtype) - { - case IDI_ADAPTER_MAESTRAQ: - addr = RegBase ; // address where to access FPGA - Mask_PROGRAM = 0x0001; // FPGA pins at address - Mask_DONE = 0x0002; - Mask_CCLK = 0x0100; - Mask_DIN = 0x0400; - baseval = 0x000d; // PROGRAM hi, CCLK lo, DIN lo by default - break; - - default: - - DPRINTF(("divas: FPGA Download ,Illegal Card")); - return -1; // illegal card - } - - //--- generate id string from file content - for (j=NAME_OFFSET, k=0; j<(NAME_OFFSET+NAME_MAXLEN); j++, k++) //name - { - if (!FPGA_SRC[j]) break; - strbuf[k] = FPGA_SRC[j]; - } - strbuf[k++] = ' '; - for (j=DATE_OFFSET; j<(DATE_OFFSET+DATE_MAXLEN); j++, k++) // date - { - if (!FPGA_SRC[j]) break; - strbuf[k] = FPGA_SRC[j]; - } - strbuf[k] = 0; - - DPRINTF(("divas: FPGA Download - %s", strbuf)); - - //--- prepare download, Pulse PROGRAM pin down. - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval &~Mask_PROGRAM); // PROGRAM low pulse - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval); // release - UxPause(50); // wait until FPGA finised internal memory clear - - //--- check done pin, must be low - if (UxCardPortIoInW(NULL, (byte *) addr, FPGA_PORT) &Mask_DONE) - { - DPRINTF(("divas: FPGA_ERR_DONE_WRONG_LEVEL")); - return -1; - } - - pFPGA = FPGA_SRC; - - i = 0; - /* Move past the header */ - while ((FPGA_SRC[i] != 0xFF) && (i < FPGA_LEN)) - { - i++; - } - - // We've hit the 0xFF so move on to the next byte - // i++; - DPRINTF(("divas: FPGA Code starts at offset %d", i)); - - //--- put data onto the FPGA - for (;i<FPGA_LEN; i++) - { - //--- put byte onto FPGA - for (j=0; j<8; j++) - { - if (FPGA_SRC[i] &(0x80>>j)) baseval |= Mask_DIN; // write a hi - else baseval &=~Mask_DIN; // write a lo - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval); - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval | Mask_CCLK); // set CCLK hi - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval); // set CCLK lo - } - } - - //--- add some additional startup clock cycles and check done pin - for (i=0; i<5; i++) - { - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval | Mask_CCLK); // set CCLK hi - UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval); // set CCLK lo - } - - UxPause(100); - - if (UxCardPortIoInW(NULL, (byte *) addr, FPGA_PORT) &Mask_DONE) - { - DPRINTF(("divas: FPGA download successful")); - } - else - { - DPRINTF(("divas: FPGA download failed - 0x%x", UxCardPortIoInW(NULL, (byte *) addr, FPGA_PORT))); - return -1; - } - -return 0; -} - diff --git a/drivers/isdn/eicon/idi.c b/drivers/isdn/eicon/idi.c deleted file mode 100644 index 6a675dbcc21e..000000000000 --- a/drivers/isdn/eicon/idi.c +++ /dev/null @@ -1,854 +0,0 @@ -/* - * Core driver for Diva Server cards - * Implements the IDI interface - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.8 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "idi.h" -#include "adapter.h" -#include "pc.h" -#include "pr_pc.h" -#include "sys.h" -#include "uxio.h" - -/* IDI request functions */ - -static void request(card_t *card, ENTITY *e); - -static void req_0(ENTITY *e) { request(&DivasCards[ 0], e); } -static void req_1(ENTITY *e) { request(&DivasCards[ 1], e); } -static void req_2(ENTITY *e) { request(&DivasCards[ 2], e); } -static void req_3(ENTITY *e) { request(&DivasCards[ 3], e); } -static void req_4(ENTITY *e) { request(&DivasCards[ 4], e); } -static void req_5(ENTITY *e) { request(&DivasCards[ 5], e); } -static void req_6(ENTITY *e) { request(&DivasCards[ 6], e); } -static void req_7(ENTITY *e) { request(&DivasCards[ 7], e); } -static void req_8(ENTITY *e) { request(&DivasCards[ 8], e); } -static void req_9(ENTITY *e) { request(&DivasCards[ 9], e); } -static void req_10(ENTITY *e) { request(&DivasCards[10], e); } -static void req_11(ENTITY *e) { request(&DivasCards[11], e); } -static void req_12(ENTITY *e) { request(&DivasCards[12], e); } -static void req_13(ENTITY *e) { request(&DivasCards[13], e); } -static void req_14(ENTITY *e) { request(&DivasCards[14], e); } -static void req_15(ENTITY *e) { request(&DivasCards[15], e); } - -IDI_CALL DivasIdiRequest[16] = -{ - &req_0, &req_1, &req_2, &req_3, - &req_4, &req_5, &req_6, &req_7, - &req_8, &req_9, &req_10, &req_11, - &req_12, &req_13, &req_14, &req_15 -}; - -#define PR_RAM ((struct pr_ram *)0) -#define RAM ((struct dual *)0) - -/*------------------------------------------------------------------*/ -/* local function prototypes */ -/*------------------------------------------------------------------*/ - -static byte isdn_rc(ADAPTER *, byte, byte, byte, word); -static byte isdn_ind(ADAPTER *, byte, byte, byte, PBUFFER *, byte, word); - -/* - * IDI related functions - */ - -static -ENTITY *entity_ptr(ADAPTER *a, byte e_no) -{ - card_t *card; - - card = a->io; - - return card->e_tbl[e_no].e; -} - -static -void CALLBACK(ADAPTER *a, ENTITY *e) -{ - card_t *card = a->io; - - if (card->log_types & DIVAS_LOG_IDI) - { - DivasLogIdi(card, e, FALSE); - } - - (*e->callback)(e); -} - -static -void *PTR_P(ADAPTER *a, ENTITY *e, void *P) -{ - return(P); -} - -static -void *PTR_R(ADAPTER *a, ENTITY *e) -{ - return((void*)e->R); -} - -static -void *PTR_X(ADAPTER *a, ENTITY *e) -{ - return((void*)e->X); -} - -static -void free_entity(ADAPTER *a, byte e_no) -{ - card_t *card; - int ipl; - - card = a->io; - - ipl = UxCardLock(card->hw); - - card->e_tbl[e_no].e = NULL; - card->e_count--; - - UxCardUnlock(card->hw, ipl); - - return; -} - -static -void assign_queue(ADAPTER * a, byte e_no, word ref) -{ - card_t *card; - int ipl; - - card = a->io; - - ipl = UxCardLock(card->hw); - - card->e_tbl[e_no].assign_ref = ref; - card->e_tbl[e_no].next = card->assign; - card->assign = e_no; - - UxCardUnlock(card->hw, ipl); - - return; -} - -static -byte get_assign(ADAPTER *a, word ref) -{ - card_t *card; - byte e_no; - int ipl; - - card = a->io; - - ipl = UxCardLock(card->hw); - - e_no = (byte)card->assign; - while (e_no) - { - if (card->e_tbl[e_no].assign_ref == ref) - { - break; - } - e_no = card->e_tbl[e_no].next; - } - - UxCardUnlock(card->hw, ipl); - - return e_no; -} - -static -void req_queue(ADAPTER * a, byte e_no) -{ - card_t *card; - int ipl; - - card = a->io; - - ipl = UxCardLock(card->hw); - - card->e_tbl[e_no].next = 0; - - if (card->e_head) - { - card->e_tbl[card->e_tail].next = e_no; - card->e_tail = e_no; - } - else - { - card->e_head = e_no; - card->e_tail = e_no; - } - - UxCardUnlock(card->hw, ipl); - - return; -} - -static -byte look_req(ADAPTER * a) -{ - card_t *card; - - card = a->io; - - return(card->e_head); -} - -static -void next_req(ADAPTER * a) -{ - card_t *card; - int ipl; - - - card = a->io; - - ipl = UxCardLock(card->hw); - - card->e_head = card->e_tbl[card->e_head].next; - if (!card->e_head) - { - card->e_tail = 0; - } - - UxCardUnlock(card->hw, ipl); - - return; -} - - -/* - * IDI request function for active cards - */ -static -void request(card_t *card, ENTITY *e) -{ - word *special_req; - int i; - int ipl; - - - if (card->log_types & DIVAS_LOG_IDI) - { - DivasLogIdi(card, e, TRUE); - } - - if (!e->Req) - { - special_req = (word *) e; - - switch (*special_req) - { - case REQ_REMOVE: - return; - - case REQ_NAME: - for (i=0; i < DIM(card->cfg.name); i++) - { - ((struct get_name_s *) e)->name[i] = card->cfg.name[i]; - } - return; - - case REQ_SERIAL: - case REQ_XLOG: - DPRINTF(("IDI: attempted REQ_SERIAL or REQ_XLOG")); - return; - - default: - return; - } - } - - ipl = UxCardLock(card->hw); - - if (!(e->Id & 0x1f)) - { - DPRINTF(("IDI: ASSIGN req")); - - for (i = 1; i < card->e_max; i++) - { - if (!card->e_tbl[i].e) - { - break; - } - } - - if (i == card->e_max) - { - DPRINTF(("IDI: request all ids in use (IDI req ignored)")); - UxCardUnlock(card->hw, ipl); - e->Rc = OUT_OF_RESOURCES; - return; - } - - card->e_tbl[i].e = e; - card->e_count++; - - e->No = (byte) i; - e->More = 0; - e->RCurrent = 0xff; - } - else - { - i = e->No; - } - - if (e->More & XBUSY) - { - DPRINTF(("IDI: request - entity is busy")); - UxCardUnlock(card->hw, ipl); - return; - } - - e->More |= XBUSY; - e->More &= ~ XMOREF; - e->XCurrent = 0; - e->XOffset = 0; - - card->e_tbl[i].next = 0; - - if(card->e_head) - { - card->e_tbl[card->e_tail].next = i; - card->e_tail = i; - } - else - { - card->e_head = i; - card->e_tail = i; - } - - UxCardUnlock(card->hw, ipl); - - DivasScheduleRequestDpc(); - - return; -} - -static byte pr_ready(ADAPTER * a) -{ - byte ReadyCount; - - ReadyCount = (byte)(a->ram_in(a, &PR_RAM->ReqOutput) - - a->ram_in(a, &PR_RAM->ReqInput)); - - if(!ReadyCount) { - if(!a->ReadyInt) { - a->ram_inc(a, &PR_RAM->ReadyInt); - a->ReadyInt++; - } - } - return ReadyCount; -} - -/*------------------------------------------------------------------*/ -/* output function */ -/*------------------------------------------------------------------*/ - -void DivasOut(ADAPTER * a) -{ - byte e_no; - ENTITY * this = NULL; - BUFFERS *X; - word length; - word i; - word clength; - REQ * ReqOut; - byte more; - byte ReadyCount; - byte ReqCount; - byte Id; - - /* while a request is pending ... */ - e_no = look_req(a); - if(!e_no) - { - return; - } - - ReadyCount = pr_ready(a); - if(!ReadyCount) - { - DPRINTF(("IDI: card not ready for next request")); - return; - } - - ReqCount = 0; - while(e_no && ReadyCount) { - - next_req(a); - - this = entity_ptr(a, e_no); - -#ifdef USE_EXTENDED_DEBUGS - if ( !this ) - { - ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ; - DBG_FTL(("!A%d ==> NULL entity ptr - try to ignore", (int)io->ANum)) - e_no = look_req(a) ; - ReadyCount-- ; - continue ; - } - { - ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ; - DPRINTF(("IDI: >A%d Id=0x%x Req=0x%x", io->ANum, this->Id, this->Req)) - } -#else - DPRINTF(("IDI: >REQ=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh)); -#endif - - /* get address of next available request buffer */ - ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)]; - - /* now copy the data from the current data buffer into the */ - /* adapters request buffer */ - length = 0; - i = this->XCurrent; - X = PTR_X(a,this); - while(i<this->XNum && length<270) { - clength = (word)(270-length); - if (clength > X[i].PLength-this->XOffset) - clength = X[i].PLength-this->XOffset; - a->ram_out_buffer(a, - &ReqOut->XBuffer.P[length], - PTR_P(a,this,&X[i].P[this->XOffset]), - clength); - - length +=clength; - this->XOffset +=clength; - if(this->XOffset==X[i].PLength) { - this->XCurrent = (byte)++i; - this->XOffset = 0; - } - } - - a->ram_outw(a, &ReqOut->XBuffer.length, length); - a->ram_out(a, &ReqOut->ReqId, this->Id); - a->ram_out(a, &ReqOut->ReqCh, this->ReqCh); - - /* if it's a specific request (no ASSIGN) ... */ - - if(this->Id &0x1f) { - - /* if buffers are left in the list of data buffers do */ - /* do chaining (LL_MDATA, N_MDATA) */ - - this->More++; - if(i<this->XNum && this->MInd) { - a->ram_out(a, &ReqOut->Req, this->MInd); - more = TRUE; - } - else { - this->More |=XMOREF; - a->ram_out(a, &ReqOut->Req, this->Req); - more = FALSE; - } - - /* if we did chaining, this entity is put back into the */ - /* request queue */ - - if(more) { - req_queue(a,this->No); - } - } - - /* else it's a ASSIGN */ - - else { - - /* save the request code used for buffer chaining */ - - this->MInd = 0; - if (this->Id==BLLC_ID) this->MInd = LL_MDATA; - if (this->Id==NL_ID || - this->Id==TASK_ID || - this->Id==MAN_ID - ) this->MInd = N_MDATA; - - /* send the ASSIGN */ - - this->More |=XMOREF; - a->ram_out(a, &ReqOut->Req, this->Req); - - /* save the reference of the ASSIGN */ - - assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference)); - } - a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next)); - ReadyCount--; - ReqCount++; - - e_no = look_req(a); - } - - /* send the filled request buffers to the ISDN adapter */ - - a->ram_out(a, &PR_RAM->ReqInput, - (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount)); - - /* if it is a 'unreturncoded' UREMOVE request, remove the */ - /* Id from our table after sending the request */ - if(this->Req==UREMOVE && this->Id) { - Id = this->Id; - e_no = a->IdTable[Id]; - free_entity(a, e_no); - a->IdTable[Id] = 0; - this->Id = 0; - } - -} - -/*------------------------------------------------------------------*/ -/* isdn interrupt handler */ -/*------------------------------------------------------------------*/ - -byte DivasDpc(ADAPTER * a) -{ - byte Count; - RC * RcIn; - IND * IndIn; - byte c; - byte RNRId; - byte Rc; - byte Ind; - - /* if return codes are available ... */ - if((Count = a->ram_in(a, &PR_RAM->RcOutput))) { - - DPRINTF(("IDI: #Rc=%x",Count)); - - /* get the buffer address of the first return code */ - RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextRc)]; - - /* for all return codes do ... */ - while(Count--) { - - if((Rc=a->ram_in(a, &RcIn->Rc))) { - - /* call return code handler, if it is not our return code */ - /* the handler returns 2 */ - /* for all return codes we process, we clear the Rc field */ - isdn_rc(a, - Rc, - a->ram_in(a, &RcIn->RcId), - a->ram_in(a, &RcIn->RcCh), - a->ram_inw(a, &RcIn->Reference)); - - a->ram_out(a, &RcIn->Rc, 0); - } - - /* get buffer address of next return code */ - RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &RcIn->next)]; - } - - /* clear all return codes (no chaining!) */ - a->ram_out(a, &PR_RAM->RcOutput ,0); - - /* call output function */ - DivasOut(a); - } - - /* clear RNR flag */ - RNRId = 0; - - /* if indications are available ... */ - if((Count = a->ram_in(a, &PR_RAM->IndOutput))) { - - DPRINTF(("IDI: #Ind=%x",Count)); - - /* get the buffer address of the first indication */ - IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextInd)]; - - /* for all indications do ... */ - while(Count--) { - - /* if the application marks an indication as RNR, all */ - /* indications from the same Id delivered in this interrupt */ - /* are marked RNR */ - if(RNRId && RNRId==a->ram_in(a, &IndIn->IndId)) { - a->ram_out(a, &IndIn->Ind, 0); - a->ram_out(a, &IndIn->RNR, TRUE); - } - else { - Ind = a->ram_in(a, &IndIn->Ind); - if(Ind) { - RNRId = 0; - - /* call indication handler, a return value of 2 means chain */ - /* a return value of 1 means RNR */ - /* for all indications we process, we clear the Ind field */ - c = isdn_ind(a, - Ind, - a->ram_in(a, &IndIn->IndId), - a->ram_in(a, &IndIn->IndCh), - &IndIn->RBuffer, - a->ram_in(a, &IndIn->MInd), - a->ram_inw(a, &IndIn->MLength)); - - if(c==1) { - DPRINTF(("IDI: RNR")); - a->ram_out(a, &IndIn->Ind, 0); - RNRId = a->ram_in(a, &IndIn->IndId); - a->ram_out(a, &IndIn->RNR, TRUE); - } - } - } - - /* get buffer address of next indication */ - IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &IndIn->next)]; - } - - a->ram_out(a, &PR_RAM->IndOutput, 0); - } - return FALSE; -} - -byte DivasTestInt(ADAPTER * a) -{ - return a->ram_in(a,(void *)0x3fe); -} - -void DivasClearInt(ADAPTER * a) -{ - a->ram_out(a,(void *)0x3fe,0); -} - -/*------------------------------------------------------------------*/ -/* return code handler */ -/*------------------------------------------------------------------*/ - -static -byte isdn_rc(ADAPTER * a, - byte Rc, - byte Id, - byte Ch, - word Ref) -{ - ENTITY * this; - byte e_no; - -#ifdef USE_EXTENDED_DEBUGS - { - ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ; - DPRINTF(("IDI: <A%d Id=0x%x Rc=0x%x", io->ANum, Id, Rc)) - } -#else - DPRINTF(("IDI: <RC(Rc=%x,Id=%x,Ch=%x)",Rc,Id,Ch)); -#endif - - /* check for ready interrupt */ - if(Rc==READY_INT) { - if(a->ReadyInt) { - a->ReadyInt--; - return 0; - } - return 2; - } - - /* if we know this Id ... */ - e_no = a->IdTable[Id]; - if(e_no) { - - this = entity_ptr(a,e_no); - - this->RcCh = Ch; - - /* if it is a return code to a REMOVE request, remove the */ - /* Id from our table */ - if(this->Req==REMOVE && Rc==OK) { - free_entity(a, e_no); - a->IdTable[Id] = 0; - this->Id = 0; -/**************************************************************/ - if ((this->More & XMOREC) > 1) { - this->More &= ~XMOREC; - this->More |= 1; - DPRINTF(("isdn_rc, Id=%x, correct More on REMOVE", Id)); - } - } - - if (Rc==OK_FC) { - this->Rc = Rc; - this->More = (this->More & (~XBUSY | XMOREC)) | 1; - this->complete = 0xFF; - CALLBACK(a, this); - return 0; - } - if(this->More &XMOREC) - this->More--; - - /* call the application callback function */ - if(this->More &XMOREF && !(this->More &XMOREC)) { - this->Rc = Rc; - this->More &=~XBUSY; - this->complete=0xff; - CALLBACK(a, this); - } - return 0; - } - - /* if it's an ASSIGN return code check if it's a return */ - /* code to an ASSIGN request from us */ - if((Rc &0xf0)==ASSIGN_RC) { - - e_no = get_assign(a, Ref); - - if(e_no) { - - this = entity_ptr(a,e_no); - - this->Id = Id; - - /* call the application callback function */ - this->Rc = Rc; - this->More &=~XBUSY; - this->complete=0xff; - CALLBACK(a, this); - - if(Rc==ASSIGN_OK) { - a->IdTable[Id] = e_no; - } - else - { - free_entity(a, e_no); - a->IdTable[Id] = 0; - this->Id = 0; - } - return 1; - } - } - return 2; -} - -/*------------------------------------------------------------------*/ -/* indication handler */ -/*------------------------------------------------------------------*/ - -static -byte isdn_ind(ADAPTER * a, - byte Ind, - byte Id, - byte Ch, - PBUFFER * RBuffer, - byte MInd, - word MLength) -{ - ENTITY * this; - word clength; - word offset; - BUFFERS *R; - -#ifdef USE_EXTENDED_DEBUGS - { - ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ; - DPRINTF(("IDI: <A%d Id=0x%x Ind=0x%x", io->ANum, Id, Ind)) - } -#else - DPRINTF(("IDI: <IND(Ind=%x,Id=%x,Ch=%x)",Ind,Id,Ch)); -#endif - - if(a->IdTable[Id]) { - - this = entity_ptr(a,a->IdTable[Id]); - - this->IndCh = Ch; - - /* if the Receive More flag is not yet set, this is the */ - /* first buffer of the packet */ - if(this->RCurrent==0xff) { - - /* check for receive buffer chaining */ - if(Ind==this->MInd) { - this->complete = 0; - this->Ind = MInd; - } - else { - this->complete = 1; - this->Ind = Ind; - } - - /* call the application callback function for the receive */ - /* look ahead */ - this->RLength = MLength; - - a->ram_look_ahead(a, RBuffer, this); - - this->RNum = 0; - CALLBACK(a, this); - - /* map entity ptr, selector could be re-mapped by call to */ - /* IDI from within callback */ - this = entity_ptr(a,a->IdTable[Id]); - - /* check for RNR */ - if(this->RNR==1) { - this->RNR = 0; - return 1; - } - - /* if no buffers are provided by the application, the */ - /* application want to copy the data itself including */ - /* N_MDATA/LL_MDATA chaining */ - if(!this->RNR && !this->RNum) { - return 0; - } - - /* if there is no RNR, set the More flag */ - this->RCurrent = 0; - this->ROffset = 0; - } - - if(this->RNR==2) { - if(Ind!=this->MInd) { - this->RCurrent = 0xff; - this->RNR = 0; - } - return 0; - } - /* if we have received buffers from the application, copy */ - /* the data into these buffers */ - offset = 0; - R = PTR_R(a,this); - do { - if(this->ROffset==R[this->RCurrent].PLength) { - this->ROffset = 0; - this->RCurrent++; - } - clength = a->ram_inw(a, &RBuffer->length)-offset; - if (clength > R[this->RCurrent].PLength-this->ROffset) - clength = R[this->RCurrent].PLength-this->ROffset; - if(R[this->RCurrent].P) { - a->ram_in_buffer(a, - &RBuffer->P[offset], - PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]), - clength); - } - offset +=clength; - this->ROffset +=clength; - } while(offset<(a->ram_inw(a, &RBuffer->length))); - - /* if it's the last buffer of the packet, call the */ - /* application callback function for the receive complete */ - /* call */ - if(Ind!=this->MInd) { - R[this->RCurrent].PLength = this->ROffset; - if(this->ROffset) this->RCurrent++; - this->RNum = this->RCurrent; - this->RCurrent = 0xff; - this->Ind = Ind; - this->complete = 2; - CALLBACK(a, this); - } - return 0; - } - return 2; -} diff --git a/drivers/isdn/eicon/idi.h b/drivers/isdn/eicon/idi.h deleted file mode 100644 index 2dde67d2502d..000000000000 --- a/drivers/isdn/eicon/idi.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * External IDI interface - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#if !defined(IDI_H) -#define IDI_H - -#include "sys.h" - -/* typedefs for our data structures */ - -typedef struct get_name_s GET_NAME; -typedef struct entity_s ENTITY; -typedef struct buffers_s BUFFERS; - -/* IDI request/callback function pointer */ - -typedef void (* IDI_CALL)(ENTITY *); - -typedef struct { - word length; /* length of data/parameter field */ - byte P[270]; /* data/parameter field */ -} DBUFFER; - -#define REQ_NAME 0x0100 -#define BOARD_NAME_LENGTH 9 -struct get_name_s { - word command; /* command = 0x0100 */ - byte name[BOARD_NAME_LENGTH]; -}; - -#define REQ_REMOVE 0x0000 /* pointer to word which is 0 */ -#define REQ_SERIAL 0x0200 -struct get_serial_s { - word command; /* command = 0x0200 */ - dword serial; /* serial number */ -}; - -#define REQ_POSTCALL 0x0300 -struct postcall_s { - word command; /* command = 0x0300 */ - word dummy; /* not used */ - IDI_CALL callback; /* routine address to call back */ - ENTITY *contxt; /* ptr to entity to use */ -}; - -#define REQ_XLOG 0x0400 /* structure is card dependent/defined locally */ - -struct buffers_s { - word PLength; - byte *P; -}; - -struct entity_s { - byte Req; /* pending request */ - byte Rc; /* return code received */ - byte Ind; /* indication received */ - byte ReqCh; /* channel of current Req */ - byte RcCh; /* channel of current Rc */ - byte IndCh; /* channel of current Ind */ - byte Id; /* ID used by this entity */ - byte GlobalId; /* reserved field */ - byte XNum; /* number of X-buffers */ - byte RNum; /* number of R-buffers */ - BUFFERS *X; /* pointer to X-buffer list */ - BUFFERS *R; /* pointer to R-buffer list */ - word RLength; /* length of current R-data */ - DBUFFER *RBuffer; /* buffer of current R-data */ - byte RNR; /* receive not ready flag */ - byte complete; /* receive complete status */ - IDI_CALL callback; - - word user[2]; - - /* fields used by the driver internally */ - byte No; /* entity number */ - byte reserved2; /* reserved field */ - byte More; /* R/X More flags */ - byte MInd; /* MDATA coding for this ID */ - byte XCurrent; /* current transmit buffer */ - byte RCurrent; /* current receive buffer */ - word XOffset; /* offset in x-buffer */ - word ROffset; /* offset in r-buffer */ -}; - -typedef struct { - byte type; - byte channels; - word features; - /* dword serial; */ - IDI_CALL request; -} DESCRIPTOR; - -extern void DIVA_DIDD_Read(DESCRIPTOR *, int); - - /* descriptor type field coding */ -#define IDI_ADAPTER_S 1 -#define IDI_ADAPTER_PR 2 -#define IDI_ADAPTER_DIVA 3 -#define IDI_ADAPTER_MAESTRA 4 -#define IDI_ADAPTER_MAESTRAQ 5 -#define IDI_ADAPTER_MAESTRAP 6 -#define IDI_VADAPTER 0x40 -#define IDI_DRIVER 0x80 -#define IDI_DIMAINT 0xff - -/* feature bit mask values */ - -#define DI_VOICE 0x0 /* obsolete define */ -#define DI_FAX3 0x1 -#define DI_MODEM 0x2 -#define DI_POST 0x4 -#define DI_V110 0x8 -#define DI_V120 0x10 -#define DI_POTS 0x20 -#define DI_CODEC 0x40 -#define DI_MANAGE 0x80 -#define DI_V_42 0x0100 -#define DI_EXTD_FAX 0x0200 /* Extended FAX (ECM, 2D, T.6, Polling) */ - -#endif /* IDI_H */ diff --git a/drivers/isdn/eicon/kprintf.c b/drivers/isdn/eicon/kprintf.c deleted file mode 100644 index a21d66cc5262..000000000000 --- a/drivers/isdn/eicon/kprintf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Source file for kernel interface to kernel log facility - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.3 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "eicon.h" -#include "sys.h" -#include <stdarg.h> - -#include "divas.h" -#include "divalog.h" -#include "uxio.h" - -void DivasPrintf(char *fmt, ...) - -{ - klog_t log; /* log entry buffer */ - - va_list argptr; /* pointer to additional args */ - - va_start(argptr, fmt); - - /* clear log entry */ - - memset((void *) &log, 0, sizeof(klog_t)); - - log.card = -1; - log.type = KLOG_TEXT_MSG; - - /* time stamp the entry */ - - log.time_stamp = UxTimeGet(); - - /* call vsprintf to format the user's information */ - - vsnprintf(log.buffer, DIM(log.buffer), fmt, argptr); - - va_end(argptr); - - /* send to the log streams driver and return */ - - DivasLogAdd(&log, sizeof(klog_t)); - - return; -} diff --git a/drivers/isdn/eicon/lincfg.c b/drivers/isdn/eicon/lincfg.c deleted file mode 100644 index ab578a053220..000000000000 --- a/drivers/isdn/eicon/lincfg.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.9 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/fs.h> -#undef N_DATA /* Because we have our own definition */ - -#include <asm/io.h> - -#include "sys.h" -#include "idi.h" -#include "constant.h" -#include "divas.h" -#undef ID_MASK -#include "pc.h" -#include "pr_pc.h" - -#include "adapter.h" -#include "uxio.h" - -#include <linux/pci.h> -#include <linux/kernel.h> -#include <linux/ioport.h> - -struct file_operations Divas_fops; -int Divas_major; - -extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, - unsigned int command, unsigned long arg); -extern unsigned int do_poll(struct file *pFile, struct poll_table_struct *pPollTable); -extern ssize_t do_read(struct file *pFile, char *pUserBuffer, size_t BufferSize, loff_t *pOffset); -extern int do_open(struct inode *, struct file *); -extern int do_release(struct inode *, struct file *); - -int FPGA_Done=0; - -int DivasCardsDiscover(void) -{ - struct pci_dev *pdev = NULL; - word wNumCards = 0, wDeviceIndex = 0; - word PCItmp; - dword j, i; - unsigned int PCIserial; - dia_card_t Card; - byte *b; - - while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_MAESTRAQ, - pdev))) { - dword dwRAM, dwDivasIOBase, dwCFG, dwCTL; - - printk(KERN_DEBUG "Divas: DIVA Server 4BRI Found\n"); - - dwRAM = pci_resource_start(pdev, 2); - dwDivasIOBase = pci_resource_start(pdev, 1); - dwCFG = pci_resource_start(pdev, 0); - dwCTL = pci_resource_start(pdev, 3); - - /* Retrieve the serial number */ - pci_write_config_word(pdev, 0x4E, 0x00FC); - for (j=0, PCItmp=0; j<10000 && !PCItmp; j++) { - pci_read_config_word(pdev, 0x4E, &PCItmp); - PCItmp &= 0x8000; // extract done flag - } - pci_read_config_dword(pdev, 0x50, &PCIserial); - - Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x400000); - Card.memory[DIVAS_CTL_MEMORY] = ioremap(dwCTL, 0x2000); - Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x100); - Card.io_base=dwDivasIOBase; - - Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_Q; - Card.bus_type = DIA_BUS_TYPE_PCI; - Card.pdev = pdev; - Card.irq = pdev->irq; - - FPGA_Done = 0; - - /* Create four virtual card structures as we want to treat - the 4Bri card as 4 Bri cards*/ - for(i=0;i<4;i++) { - b=Card.memory[DIVAS_RAM_MEMORY]; - b+=(MQ_PROTCODE_OFFSET) * (i==0?0:1); - DPRINTF(("divas: offset = 0x%x", i* MQ_PROTCODE_OFFSET)); - Card.memory[DIVAS_RAM_MEMORY]=b; - - b = Card.memory[DIVAS_RAM_MEMORY]; - b += MQ_SM_OFFSET; - Card.memory[DIVAS_SHARED_MEMORY] = b; - - Card.slot = -1; - - sprintf(Card.name, "DIVASQ%ld", i); - - Card.serial = PCIserial; - - Card.card_id = wNumCards; - - if (DivasCardNew(&Card) != 0) { - break; - } - wNumCards++; - - } - } - - pdev = NULL; - while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_MAESTRA, - pdev))) { - dword dwPLXIOBase, dwDivasIOBase; - - printk(KERN_DEBUG "Divas: DIVA Server BRI (S/T) Found\n"); - dwPLXIOBase = pci_resource_start(pdev, 1); - dwDivasIOBase = pci_resource_start(pdev, 2); - - Card.card_id = wNumCards; - Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B; - Card.bus_type = DIA_BUS_TYPE_PCI; - Card.pdev = pdev; - Card.irq = pdev->irq; - Card.reset_base = dwPLXIOBase; - Card.io_base = dwDivasIOBase; - Card.slot = -1; - strcpy(Card.name, "DIVASB"); - - if (check_region(Card.io_base, 0x20)) { - printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F); - } - - if (check_region(Card.reset_base, 0x80)) { - printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F); - continue; - } - - if (DivasCardNew(&Card) != 0) { - continue; - } - wNumCards++; - } - - pdev = NULL; - while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_MAESTRAQ_U, - pdev))) { - dword dwPLXIOBase, dwDivasIOBase; - - printk(KERN_DEBUG "Divas: DIVA Server BRI (U) Found\n"); - - dwPLXIOBase = pci_resource_start(pdev, 1); - dwDivasIOBase = pci_resource_start(pdev, 2); - - Card.card_id = wNumCards; - Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B; - Card.bus_type = DIA_BUS_TYPE_PCI; - Card.pdev = pdev; - Card.irq = pdev->irq; - Card.reset_base = dwPLXIOBase; - Card.io_base = dwDivasIOBase; - Card.slot = -1; - strcpy(Card.name, "DIVASB"); - - if (check_region(Card.io_base, 0x20)) { - printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F); - continue; - } - - if (check_region(Card.reset_base, 0x80)) { - printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F); - continue; - } - - if (DivasCardNew(&Card) != 0) { - continue; - } - wNumCards++; - } - - wDeviceIndex = 0; - - pdev = NULL; - while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_MAESTRAQ_U, - pdev))) { - dword dwRAM, dwREG, dwCFG; - - printk(KERN_DEBUG "Divas: DIVA Server PRI Found\n"); - - dwRAM = pci_resource_start(pdev, 0); - dwREG = pci_resource_start(pdev, 2); - dwCFG = pci_resource_start(pdev, 4); - - Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x10000); - Card.memory[DIVAS_REG_MEMORY] = ioremap(dwREG, 0x4000); - Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x1000); - Card.memory[DIVAS_SHARED_MEMORY] = Card.memory[DIVAS_RAM_MEMORY] + DIVAS_SHARED_OFFSET; - - Card.card_id = wNumCards; - Card.card_type = DIA_CARD_TYPE_DIVA_SERVER; - Card.bus_type = DIA_BUS_TYPE_PCI; - Card.pdev = pdev; - Card.irq = pdev->irq; - Card.slot = -1; - strcpy(Card.name, "DIVASP"); - if (DivasCardNew(&Card) != 0) { - continue; - } - wNumCards++; - } - - - printk(KERN_INFO "Divas: %d cards detected\n", wNumCards); - - if(wNumCards == 0) { - return -1; - } - - Divas_fops.ioctl = do_ioctl; - Divas_fops.poll = do_poll; - Divas_fops.read = do_read; - Divas_fops.open = do_open; - Divas_fops.release = do_release; - - Divas_major = register_chrdev(0, "Divas", &Divas_fops); - - if (Divas_major < 0) { - printk(KERN_WARNING "Divas: Unable to register character driver\n"); - return -1; - } - - return 0; -} - -/* Error return -1 */ -int DivasConfigGet(dia_card_t *card) -{ - /* Retrieve Config from O/S? Not in Linux */ - return 0; -} - -dia_config_t *DivasConfig(card_t *card, dia_config_t *config) -{ - /* If config retrieved from OS then copy the data into a dia_config_t structure here - and return the pointer here. If the config 'came from above' then just - - return config; - */ - - return config; -} - diff --git a/drivers/isdn/eicon/linchr.c b/drivers/isdn/eicon/linchr.c deleted file mode 100644 index 5f8922173ebc..000000000000 --- a/drivers/isdn/eicon/linchr.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.12 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/module.h> - -#include <linux/kernel.h> -#include <linux/poll.h> -#include <linux/fs.h> -#include <linux/slab.h> - -#undef N_DATA - -#include "adapter.h" -#include "divas.h" -#include "divalog.h" - -extern int DivasCardNext; -void UxPause(long ms); -int DivasGetMem(mem_block_t *); - -#define DIA_IOCTL_UNLOCK 12 -void UnlockDivas(void); - -int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, - unsigned int command, unsigned long arg) -{ - byte *pUserCards, card_i; - word wCardNum; - - switch (command) - { - case DIA_IOCTL_CONFIG: - { - dia_config_t DivaConfig; - if (copy_from_user(&DivaConfig, (void *)arg, sizeof(dia_config_t))) - return -EFAULT; - DivasCardConfig(&DivaConfig); - return 0; - } - - case DIA_IOCTL_DETECT: - pUserCards = (byte *) arg; - - if (!verify_area(VERIFY_WRITE, pUserCards, 20)) - { - if(__put_user(DivasCardNext, pUserCards++)) - return -EFAULT; - - for (card_i=1; card_i < 20; card_i++) - { - if(__put_user((byte) DivasCards[card_i - 1].cfg.card_type, pUserCards++)) - return -EFAULT; - } - } - else return -EFAULT; - - return 0; - - case DIA_IOCTL_START: - { - dia_start_t DivaStart; - if (copy_from_user(&DivaStart, (void *)arg, sizeof(dia_start_t))) - return -EFAULT; - return DivasCardStart(DivaStart.card_id); - } - - case DIA_IOCTL_FLAVOUR: - return 0; - - case DIA_IOCTL_LOAD: - { - dia_load_t DivaLoad; - if(copy_from_user(&DivaLoad, (void *)arg, sizeof(dia_load_t))) - return -EFAULT; - if (!verify_area(VERIFY_READ, DivaLoad.code,DivaLoad.length)) - { - if (DivasCardLoad(&DivaLoad)) - { - printk(KERN_WARNING "Divas: Error loading DIVA Server adapter\n"); - return -EINVAL; - } - return 0; - } - return -EFAULT; - } - case DIA_IOCTL_LOG: - { - dia_log_t DivaLog; - if (copy_from_user(&DivaLog, (void *) arg, sizeof(dia_log_t))) - return -EFAULT; - DivasLog(&DivaLog); - return 0; - } - - case DIA_IOCTL_XLOG_REQ: - if(get_user(wCardNum, (word *) arg)) - return -EFAULT; - DivasXlogReq(wCardNum); - return 0; - - case DIA_IOCTL_GET_NUM: - if(put_user(DivasCardNext, (int *)arg)) - return -EFAULT; - return 0; - - case DIA_IOCTL_GET_LIST: - { - dia_card_list_t cards; - DPRINTF(("divas: DIA_IOCTL_GET_LIST")); - DivasGetList(&cards); - if(copy_to_user((void *)arg, &cards, sizeof(cards))) - return -EFAULT; - return 0; - } - case DIA_IOCTL_GET_MEM: - { - mem_block_t mem_block; - if (copy_from_user(&mem_block, (void *)arg, sizeof(mem_block_t))) - return -EFAULT; - DivasGetMem(&mem_block); - return 0; - } - - case DIA_IOCTL_UNLOCK: - UnlockDivas(); - return 0; - - default: - return -EINVAL; - } - return -EINVAL; -} - -unsigned int do_poll(struct file *pFile, struct poll_table_struct *pPollTable) -{ - word wMask = 0; - - if (!DivasLogFifoEmpty()) - wMask |= POLLIN | POLLRDNORM; - return wMask; -} - -ssize_t do_read(struct file *pFile, char *pUserBuffer, size_t BufferSize, loff_t *pOffset) -{ - klog_t *pClientLogBuffer = (klog_t *) pUserBuffer; - klog_t *pHeadItem; - - if (BufferSize < sizeof(klog_t)) - return -EIO; - - pHeadItem = (klog_t *) DivasLogFifoRead(); - - if (pHeadItem) { - if (copy_to_user(pClientLogBuffer, pHeadItem, sizeof(klog_t))) { - kfree(pHeadItem); - return -EFAULT; - } - kfree(pHeadItem); - return sizeof(klog_t); - } - - return 0; -} -static int private_usage_count; - -int do_open(struct inode *pInode, struct file *pFile) -{ - MOD_INC_USE_COUNT; -#ifdef MODULE - private_usage_count++; -#endif - return 0; -} - -int do_release(struct inode *pInode, struct file *pFile) -{ - MOD_DEC_USE_COUNT; -#ifdef MODULE - private_usage_count--; -#endif - return 0; -} - -void UnlockDivas(void) -{ - while (private_usage_count > 0) - { - private_usage_count--; - MOD_DEC_USE_COUNT; - } -} diff --git a/drivers/isdn/eicon/linio.c b/drivers/isdn/eicon/linio.c deleted file mode 100644 index 3f131a1ee187..000000000000 --- a/drivers/isdn/eicon/linio.c +++ /dev/null @@ -1,729 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.16 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#define N_DATA - -#include <linux/config.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/interrupt.h> -#include <linux/smp_lock.h> -#include <asm/io.h> -#include <asm/system.h> -#include <linux/slab.h> -#include <linux/pci.h> -#include <linux/delay.h> -#undef N_DATA - -#include "uxio.h" - -static -int log_on=0; - -int Divasdevflag = 0; - -spinlock_t diva_lock = SPIN_LOCK_UNLOCKED; - -static -ux_diva_card_t card_pool[MAX_CARDS]; - -void UxPause(long int ms) -{ - unsigned long timeout = jiffies + ((ms * HZ) / 1000); - - while (time_before(jiffies, timeout)); -} - -int UxCardHandleGet(ux_diva_card_t **card, dia_card_t *cfg) -{ - int i; - ux_diva_card_t *c; - - if (cfg->bus_type != DIA_BUS_TYPE_PCI) - { - DPRINTF(("divas hw: type not PCI (%d)", cfg->bus_type)); - return -1; - } - - for (i = 0; (i < DIM(card_pool)) && (card_pool[i].in_use); i++) - { - ; - } - - if (i == DIM(card_pool)) - { - DPRINTF(("divas hw: card_pool exhausted")); - return -1; - } - - c = *card = &card_pool[i]; - - switch (cfg->bus_type) - { - case DIA_BUS_TYPE_PCI: - c->pdev = cfg->pdev; - c->io_base = cfg->io_base; - c->reset_base = cfg->reset_base; - c->card_type = cfg->card_type; - c->mapped = NULL; - c->slot = cfg->slot; - c->irq = (int) cfg->irq; - c->pDRAM = cfg->memory[DIVAS_RAM_MEMORY]; - c->pDEVICES = cfg->memory[DIVAS_REG_MEMORY]; - c->pCONFIG = cfg->memory[DIVAS_CFG_MEMORY]; - c->pSHARED = cfg->memory[DIVAS_SHARED_MEMORY]; - c->pCONTROL = cfg->memory[DIVAS_CTL_MEMORY]; - - /* c->bus_type = DIA_BUS_TYPE_PCI; - c->bus_num = cfg->bus_num & 0x3f; - c->slot = cfg->slot; - c->irq = (int) cfg->irq; - c->int_priority = (int) cfg->int_priority; - c->card_type = cfg->card_type; - c->io_base = cfg->io_base; - c->reset_base = cfg->reset_base; - c->pDRAM = cfg->memory[DIVAS_RAM_MEMORY]; - c->pDEVICES = cfg->memory[DIVAS_REG_MEMORY]; - c->pCONFIG = cfg->memory[DIVAS_CFG_MEMORY]; - c->pSHARED = cfg->memory[DIVAS_SHARED_MEMORY]; - DPRINTF(("divas hw: pDRAM is 0x%x", c->pDRAM)); - DPRINTF(("divas hw: pSHARED is 0x%x", c->pSHARED)); - DPRINTF(("divas hw: pCONFIG is 0x%x", c->pCONFIG)); - c->cm_key = cm_getbrdkey("Divas", cfg->card_id);*/ - break; - default: - break; - } - - c->in_use = TRUE; - - return 0; -} - -void UxCardHandleFree(ux_diva_card_t *card) -{ - card->in_use = FALSE; -} - - -#define PLX_IOBASE 0 -#define DIVAS_IOBASE 1 -void *UxCardMemAttach(ux_diva_card_t *card, int id) -{ - if (card->card_type == DIA_CARD_TYPE_DIVA_SERVER) - { - switch (id) - { - case DIVAS_SHARED_MEMORY: - card->mapped = card->pSHARED; - return card->pSHARED; - break; - case DIVAS_RAM_MEMORY: - card->mapped = card->pDRAM; - return card->pDRAM; - break; - case DIVAS_REG_MEMORY: - card->mapped = card->pDEVICES; - return card->pDEVICES; - break; - case DIVAS_CFG_MEMORY: - card->mapped = card->pCONFIG; - return card->pCONFIG; - break; - default: - ASSERT(FALSE); - card->mapped = NULL; - return (void *) 0; - } - } - else if (card->card_type == DIA_CARD_TYPE_DIVA_SERVER_B) - { - switch (id) - { - case PLX_IOBASE: - return (void *) card->reset_base; - break; - case DIVAS_IOBASE: - return (void *) card->io_base; - break; - default: - ASSERT(FALSE); - return 0; - } - } - - else if (card->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q) - { - switch (id) - { - case DIVAS_SHARED_MEMORY: - card->mapped = card->pSHARED; - return card->pSHARED; - break; - case DIVAS_RAM_MEMORY: - card->mapped = card->pDRAM; - return card->pDRAM; - break; - case DIVAS_REG_MEMORY: - card->mapped = (void *) card->io_base; - return (void *) card->io_base; - break; - case DIVAS_CTL_MEMORY: - card->mapped = card->pCONTROL; - return card->pCONTROL; - break; - default: - // ASSERT(FALSE); - DPRINTF(("divas: Trying to attach to mem %d", id)); - card->mapped = NULL; - return (void *) 0; - } - } else - DPRINTF(("divas: Tried to attach to unknown card")); - - /* Unknown card type */ - return NULL; -} - -void UxCardMemDetach(ux_diva_card_t *card, void *address) -{ - return; // Just a place holder. No un-mapping done. -} - -void UxCardLog(int turn_on) -{ - log_on = turn_on; -} - -/* - * Control Register I/O Routines to be performed on Attached I/O ports - */ - -void UxCardPortIoOut(ux_diva_card_t *card, void *AttachedBase, int offset, byte the_byte) -{ - word base = (word) (dword) AttachedBase; - - base += offset; - - outb(the_byte, base); -} - -void UxCardPortIoOutW(ux_diva_card_t *card, void *AttachedBase, int offset, word the_word) -{ - word base = (word) (dword) AttachedBase; - - base += offset; - - outw(the_word, base); -} - -void UxCardPortIoOutD(ux_diva_card_t *card, void *AttachedBase, int offset, dword the_dword) -{ - word base = (word) (dword) AttachedBase; - - base += offset; - - outl(the_dword, base); -} - -byte UxCardPortIoIn(ux_diva_card_t *card, void *AttachedBase, int offset) -{ - word base = (word) (dword) AttachedBase; - - base += offset; - - return inb(base); -} - -word UxCardPortIoInW(ux_diva_card_t *card, void *AttachedBase, int offset) -{ - word base = (word) (dword) AttachedBase; - - base += offset; - - return inw(base); -} - -/* - * Memory mapped card I/O functions - */ - -byte UxCardMemIn(ux_diva_card_t *card, void *address) -{ - byte b; - volatile byte* t = (byte*)address; - - b = *t; - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - DPRINTF(("divas hw: read 0x%02x from 0x%x (memory mapped)", b & 0xff, a)); - } - - return(b); -} - -word UxCardMemInW(ux_diva_card_t *card, void *address) -{ - word w; - volatile word* t = (word*)address; - - w = *t; - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - DPRINTF(("divas hw: read 0x%04x from 0x%x (memory mapped)", w & 0xffff, a)); - } - - return (w); -} - -dword UxCardMemInD(ux_diva_card_t *card, void *address) -{ - dword dw; - volatile dword* t = (dword*)address; - - dw = *t; - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - DPRINTF(("divas hw: read 0x%08x from 0x%x (memory mapped)", dw, a)); - } - - return (dw); -} - -void UxCardMemInBuffer(ux_diva_card_t *card, void *address, void *buffer, int length) -{ - volatile byte *pSource = address; - byte *pDest = buffer; - - while (length--) - { - *pDest++ = *pSource++; - } - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - pDest = buffer; - DPRINTF(("divas hw: read %02x %02x %02x %02x %02x %02x %02x %02x from 0x%x (memory mapped)", - pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff, - pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff, - a)); - } - - return; -} - -void UxCardMemOut(ux_diva_card_t *card, void *address, byte data) -{ - volatile byte* t = (byte*)address; - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - DPRINTF(("divas hw: wrote 0x%02x to 0x%x (memory mapped)", data & 0xff, a)); - } - - *t = data; - - return; -} - -void UxCardMemOutW(ux_diva_card_t *card, void *address, word data) -{ - volatile word* t = (word*)address; - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - DPRINTF(("divas hw: wrote 0x%04x to 0x%x (memory mapped)", data & 0xffff, a)); - } - - *t = data; - return; -} - -void UxCardMemOutD(ux_diva_card_t *card, void *address, dword data) -{ - volatile dword* t = (dword*)address; - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - DPRINTF(("divas hw: wrote 0x%08x to 0x%x (memory mapped)", data, a)); - } - - *t = data; - return; -} - -void UxCardMemOutBuffer(ux_diva_card_t *card, void *address, void *buffer, int length) -{ - byte *pSource = buffer; - byte *pDest = address; - - while (length--) - { - *pDest++ = *pSource++; - } - - if (log_on) - { - byte *a = address; - a -= (int) card->mapped; - pDest = buffer; - DPRINTF(("divas hw: wrote %02x %02x %02x %02x %02x %02x %02x %02x to 0x%x (memory mapped)", - pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff, - pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff, - a)); - } - - return; -} - -/* - * Memory mapped card I/O functions - */ - -byte UxCardIoIn(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address) - -{ - byte the_byte; - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) address, card->io_base + 4); - - the_byte = inb(card->io_base); - - if (log_on) - { - DPRINTF(("divas hw: read 0x%02x from 0x%x (I/O mapped)", - the_byte & 0xff, address)); - } - - return the_byte; -} - -word UxCardIoInW(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address) - -{ - word the_word; - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) address, card->io_base + 4); - the_word = inw(card->io_base); - - if (log_on) - { - DPRINTF(("divas hw: read 0x%04x from 0x%x (I/O mapped)", - the_word & 0xffff, address)); - } - - return the_word; -} - -dword UxCardIoInD(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address) - -{ - dword the_dword; - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) address, card->io_base + 4); - the_dword = inl(card->io_base); - - if (log_on) - { - DPRINTF(("divas hw: read 0x%08x from 0x%x (I/O mapped)", - the_dword, address)); - } - - return the_dword; -} - -void UxCardIoInBuffer(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, void *buffer, int length) - -{ - byte *pSource = address; - byte *pDest = buffer; - - if ((word) (dword) address & 0x1) - { - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) pSource, card->io_base + 4); - *pDest = (byte) inb(card->io_base); - pDest++; - pSource++; - length--; - if (!length) - { - return; - } - } - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) pSource, card->io_base + 4); - insw(card->io_base, (word *)pDest,length%2 ? (length+1)>>1 : length>>1); - - if (log_on) - { - pDest = buffer; - DPRINTF(("divas hw: read %02x %02x %02x %02x %02x %02x %02x %02x from 0x%x (I/O mapped)", - pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff, - pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff, - address)); - } - - return; -} - -/* Output */ - -void UxCardIoOut(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, byte data) -{ - if (log_on) - { - DPRINTF(("divas hw: wrote 0x%02x to 0x%x (I/O mapped)", - data & 0xff, address)); - } - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) address, card->io_base + 4); - outb((byte) data & 0xFF, card->io_base); - - return; -} - -void UxCardIoOutW(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, word data) -{ - if (log_on) - { - DPRINTF(("divas hw: wrote 0x%04x to 0x%x (I/O mapped)", - data & 0xffff, address)); - } - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) address, card->io_base + 4); - outw((word) data & 0xFFFF, card->io_base); - - return; -} - -void UxCardIoOutD(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, dword data) -{ - if (log_on) - { - DPRINTF(("divas hw: wrote 0x%08x to 0x%x (I/O mapped)", data, address)); - } - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) address, card->io_base + 4); - outl((dword) data & 0xFFFFFFFF, card->io_base); - - return; -} - -void UxCardIoOutBuffer(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, void *buffer, int length) - -{ - byte *pSource = buffer; - byte *pDest = address; - - if ((word) (dword) address & 1) - { - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) pDest, card->io_base + 4); - outb(*pSource, card->io_base); - pSource++; - pDest++; - length--; - if (!length) - { - return; - } - } - - outb(0xFF, card->io_base + 0xC); - outw((word) (dword) pDest, card->io_base + 4); - outsw(card->io_base, (word *)pSource, length%2 ? (length+1)>>1 : length>>1); - - if (log_on) - { - pDest = buffer; - DPRINTF(("divas hw: wrote %02x %02x %02x %02x %02x %02x %02x %02x to 0x%x (I/O mapped)", - pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff, - pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff, - address)); - } - - return; -} - -irqreturn_t Divasintr(int arg, void *unused, struct pt_regs *unused_regs) -{ - int i; - card_t *card = NULL; - ux_diva_card_t *ux_ref = NULL; - - for (i = 0; i < DivasCardNext; i++) - { - - if (arg == DivasCards[i].cfg.irq) - { - card = &DivasCards[i]; - ux_ref = card->hw; - - if ((ux_ref) && (card->is_live)) - { - (*ux_ref->user_isr)(ux_ref->user_isr_arg); - } - else - { - DPRINTF(("divas: ISR couldn't locate card")); - } - } - } - - return IRQ_HANDLED; -} - - -int UxIsrInstall(ux_diva_card_t *card, isr_fn_t *isr_fn, void *isr_arg) -{ - int result; - - card->user_isr = isr_fn; - card->user_isr_arg = isr_arg; - - result = request_irq(card->irq, Divasintr, SA_INTERRUPT | SA_SHIRQ, "Divas", (void *) isr_arg); - - return result; -} - -void UxIsrRemove(ux_diva_card_t *card, void *dev_id) -{ - free_irq(card->irq, card->user_isr_arg); -} - -void UxPciConfigWrite(ux_diva_card_t *card, int size, int offset, void *value) -{ - switch (size) { - case sizeof(byte): - pci_write_config_byte(card->pdev, offset, * (byte *) value); - break; - case sizeof(word): - pci_write_config_word(card->pdev, offset, * (word *) value); - break; - case sizeof(dword): - pci_write_config_dword(card->pdev, offset, * (dword *) value); - break; - default: - printk(KERN_WARNING "Divas: Invalid size in UxPciConfigWrite\n"); - } -} - -void UxPciConfigRead(ux_diva_card_t *card, int size, int offset, void *value) -{ - switch (size) { - case sizeof(byte): - pci_read_config_byte(card->pdev, offset, (byte *) value); - break; - case sizeof(word): - pci_read_config_word(card->pdev, offset, (word *) value); - break; - case sizeof(dword): - pci_read_config_dword(card->pdev, offset, (unsigned int *) value); - break; - default: - printk(KERN_WARNING "Divas: Invalid size in UxPciConfigRead\n"); - } -} - -void *UxAlloc(unsigned int size) -{ - void *m; - - m = kmalloc(size, GFP_ATOMIC); - - return m; -} - -void UxFree(void *ptr) -{ - kfree(ptr); -} - -long UxCardLock(ux_diva_card_t *card) -{ - unsigned long flags; - - spin_lock_irqsave(&diva_lock, flags); - - return flags; -} - -void UxCardUnlock(ux_diva_card_t *card, unsigned long ipl) -{ - spin_unlock_irqrestore(&diva_lock, ipl); -} - -dword UxTimeGet(void) -{ - return jiffies; -} - -long UxInterlockedIncrement(ux_diva_card_t *card, long *dst) -{ - register volatile long *p; - register long ret; - int ipl; - - p =dst; - - ipl = UxCardLock(card); - - *p += 1; - ret = *p; - - UxCardUnlock(card,ipl); - - return(ret); - -} - -long UxInterlockedDecrement(ux_diva_card_t *card, long *dst) -{ - register volatile long *p; - register long ret; - int ipl; - - p =dst; - - ipl = UxCardLock(card); - - *p -= 1; - ret = *p; - - UxCardUnlock(card,ipl); - - return(ret); - -} diff --git a/drivers/isdn/eicon/linsys.c b/drivers/isdn/eicon/linsys.c deleted file mode 100644 index afe772fbb5d5..000000000000 --- a/drivers/isdn/eicon/linsys.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.10 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/sched.h> -#undef N_DATA -#include <linux/workqueue.h> - -#include <linux/smp.h> -struct pt_regs; -#include <linux/interrupt.h> -#include <linux/ioport.h> - -#include "sys.h" -#include "divas.h" -#include "adapter.h" -#include "divalog.h" - -#include "uxio.h" - -static struct tasklet_struct DivasTask; - -int Divas4BRIInitPCI(card_t *card, dia_card_t *cfg) -{ - /* Use UxPciConfigWrite routines to initialise PCI config space */ - -/* wPCIcommand = 0x03; - cm_write_devconfig16(CMKey, PCI_COMMAND, &wPCIcommand); - - wPCIcommand = 0x280; - cm_write_devconfig16(CMKey, PCI_STATUS, &wPCIcommand); - - bPCIcommand = 0x30; - cm_write_devconfig16(CMKey, PCI_STATUS, &wPCIcommand); -*/ - return 0; -} - -int DivasPRIInitPCI(card_t *card, dia_card_t *cfg) -{ - /* Use UxPciConfigWrite routines to initialise PCI config space */ - -/* wPCIcommand = 0x03; - cm_write_devconfig16(CMKey, PCI_COMMAND, &wPCIcommand); - - wPCIcommand = 0x280; - cm_write_devconfig16(CMKey, PCI_STATUS, &wPCIcommand); - - bPCIcommand = 0x30; - cm_write_devconfig8(CMKey, PCI_LATENCY, &bPCIcommand);*/ - - return 0; -} - -int DivasBRIInitPCI(card_t *card, dia_card_t *cfg) -{ - /* Need to set these platform dependent values after patching */ - - card->hw->reset_base = card->cfg.reset_base; - card->hw->io_base = card->cfg.io_base; - - request_region(card->hw->reset_base,0x80,"Divas"); - request_region(card->hw->io_base,0x20,"Divas"); - - - /* Same as for PRI */ - return DivasPRIInitPCI(card, cfg); -} - -/* ######################### Stubs of routines that are not done yet ################## */ -/*void DivasLogIdi(card_t *card, ENTITY *e, int request) -{ -} -*/ - -int DivasDpcSchedule(void) -{ - tasklet_schedule(&DivasTask); - - return 0; -} - -int DivasScheduleRequestDpc(void) -{ - tasklet_schedule(&DivasTask); - - return 0; -} - -void DivasInitDpc(void) -{ - tasklet_init(&DivasTask, DivasDoDpc, 0); -} - -void DivasLogAdd(void *buffer, int length) -{ - static - boolean_t overflow = FALSE; - static - boolean_t busy = FALSE; - - /* make sure we're not interrupting ourselves */ - - if (busy) - { - printk(KERN_DEBUG "Divas: Logging interrupting self !\n"); - return; - } - busy = TRUE; - - /* ignore call if daemon isn't running and we've reached limit */ - - if (DivasLogFifoFull()) - { - if (!overflow) - { - printk(KERN_DEBUG "Divas: Trace buffer full\n"); - overflow = TRUE; - } - busy = FALSE; - return; - } - - DivasLogFifoWrite(buffer, length); - - busy = FALSE; - return; -} - -/* #################################################################################### */ diff --git a/drivers/isdn/eicon/log.c b/drivers/isdn/eicon/log.c deleted file mode 100644 index aa27e631a279..000000000000 --- a/drivers/isdn/eicon/log.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Source file for diva log facility - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.5 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "sys.h" -#include "idi.h" -#include "divas.h" -#include "adapter.h" -#include "divalog.h" - -#include "uxio.h" - -/*Counter to monitor number of messages */ -static int m_count; - -#define MAX_BUFFERED_MSGS (1000) - -/* Our Linked List Structure to hold message */ -typedef struct klog_link{ - klog_t klog; - struct klog_link *next; -}KNODE; - -/* First & Last structures in list*/ -KNODE *head; -KNODE *tail; - -/* - * retrieve message from FIFO buffer - * returns NULL if buffer empty - * otherwise returns pointer to entry - */ - -char *DivasLogFifoRead(void) - -{ - KNODE *old_head; - - if(head==NULL) - { - /* Buffer Empty - No Messages */ - return NULL; - } - - m_count--; - /* Keep track of message to be read & increment to next message*/ - old_head = head; - head = head->next; - /*Return ptr to Msg */ - return((char *)old_head); -} - -/* - * write message into FIFO buffer - */ - -void DivasLogFifoWrite(char *entry, int length) - -{ - KNODE *new_klog; - - if(head == NULL) - { - /* No Entries in Log */ - tail=NULL; - m_count=0; - new_klog=UxAlloc(sizeof(KNODE)); - - if(new_klog==NULL) - { - return; - } - - m_count++; - memset(new_klog, 0, sizeof(KNODE)); - - /* Set head & tail to point to the new Msg Struct */ - head=tail=new_klog; - tail->next=NULL; - } - else - { - new_klog=UxAlloc(sizeof(KNODE)); - - if(new_klog==NULL) - { - return; - } - - m_count++; - memset(new_klog, 0, sizeof(KNODE)); - - /* Let last Msg Struct point to new Msg Struct & inc tail */ - tail->next=new_klog; - tail=new_klog; - tail->next=NULL; - } - - if (length > sizeof(klog_t)) - { - length = sizeof(klog_t); - } - - memcpy(&tail->klog, entry, length); - - return; -} - -/* - * DivaslogFifoEmpty:return TRUE if FIFO buffer is empty,otherwise FALSE - */ -int DivasLogFifoEmpty(void) -{ - return (m_count == 0); -} - -/* - *DivasLogFifoFull:return TRUE if FIFO buffer is full,otherwise FALSE - */ -int DivasLogFifoFull(void) -{ - return (m_count == MAX_BUFFERED_MSGS); -} - -/* - * generate an IDI log entry - */ - -void DivasLogIdi(card_t *card, ENTITY *e, int request) - -{ - klog_t klog; - - memset(&klog, 0, sizeof(klog)); - - klog.time_stamp = UxTimeGet(); - - klog.length = sizeof(ENTITY) > sizeof(klog.buffer) ? - sizeof(klog.buffer) : sizeof(ENTITY); - - klog.card = (int) (card - DivasCards); - - klog.type = request ? KLOG_IDI_REQ : KLOG_IDI_CALLBACK; - klog.code = 0; - memcpy(klog.buffer, e, klog.length); - - /* send to the log driver and return */ - - DivasLogAdd(&klog, sizeof(klog)); - - return; -} diff --git a/drivers/isdn/eicon/pc.h b/drivers/isdn/eicon/pc.h deleted file mode 100644 index 1b9f2624893d..000000000000 --- a/drivers/isdn/eicon/pc.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.2 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef PC_H_INCLUDED -#define PC_H_INCLUDED - -/*------------------------------------------------------------------*/ -/* buffer definition */ -/*------------------------------------------------------------------*/ - -typedef struct { - word length; /* length of data/parameter field */ - byte P[270]; /* data/parameter field */ -} PBUFFER; - -/*------------------------------------------------------------------*/ -/* dual port ram structure */ -/*------------------------------------------------------------------*/ - -struct dual -{ - byte Req; /* request register */ - byte ReqId; /* request task/entity identification */ - byte Rc; /* return code register */ - byte RcId; /* return code task/entity identification */ - byte Ind; /* Indication register */ - byte IndId; /* Indication task/entity identification */ - byte IMask; /* Interrupt Mask Flag */ - byte RNR; /* Receiver Not Ready (set by PC) */ - byte XLock; /* XBuffer locked Flag */ - byte Int; /* ISDN-S interrupt */ - byte ReqCh; /* Channel field for layer-3 Requests */ - byte RcCh; /* Channel field for layer-3 Returncodes */ - byte IndCh; /* Channel field for layer-3 Indications */ - byte MInd; /* more data indication field */ - word MLength; /* more data total packet length */ - byte ReadyInt; /* request field for ready interrupt */ - byte SWReg; /* Software register for special purposes */ - byte Reserved[11]; /* reserved space */ - byte InterfaceType; /* interface type 1=16K interface */ - word Signature; /* ISDN-S adapter Signature (GD) */ - PBUFFER XBuffer; /* Transmit Buffer */ - PBUFFER RBuffer; /* Receive Buffer */ -}; - -/*------------------------------------------------------------------*/ -/* SWReg Values (0 means no command) */ -/*------------------------------------------------------------------*/ -#define SWREG_DIE_WITH_LEDON 0x01 -#define SWREG_HALT_CPU 0x02 /* Push CPU into a while(1) loop */ - -/*------------------------------------------------------------------*/ -/* Id Fields Coding */ -/*------------------------------------------------------------------*/ - -#define ID_MASK 0xe0 /* Mask for the ID field */ -#define GL_ERR_ID 0x1f /* ID for error reporting on global requests*/ - -#define DSIG_ID 0x00 /* ID for D-channel signaling */ -#define NL_ID 0x20 /* ID for network-layer access (B or D) */ -#define BLLC_ID 0x60 /* ID for B-channel link level access */ -#define TASK_ID 0x80 /* ID for dynamic user tasks */ -#define TIMER_ID 0xa0 /* ID for timer task */ -#define TEL_ID 0xc0 /* ID for telephone support */ -#define MAN_ID 0xe0 /* ID for management */ - -/*------------------------------------------------------------------*/ -/* ASSIGN and REMOVE requests are the same for all entities */ -/*------------------------------------------------------------------*/ - -#define ASSIGN 0x01 -#define UREMOVE 0xfe /* without returncode */ -#define REMOVE 0xff - -/*------------------------------------------------------------------*/ -/* Timer Interrupt Task Interface */ -/*------------------------------------------------------------------*/ - -#define ASSIGN_TIM 0x01 -#define REMOVE_TIM 0xff - -/*------------------------------------------------------------------*/ -/* dynamic user task interface */ -/*------------------------------------------------------------------*/ - -#define ASSIGN_TSK 0x01 -#define REMOVE_TSK 0xff - -#define LOAD 0xf0 -#define RELOCATE 0xf1 -#define START 0xf2 -#define LOAD2 0xf3 -#define RELOCATE2 0xf4 - -/*------------------------------------------------------------------*/ -/* dynamic user task messages */ -/*------------------------------------------------------------------*/ - -#define TSK_B2 0x0000 -#define TSK_WAKEUP 0x2000 -#define TSK_TIMER 0x4000 -#define TSK_TSK 0x6000 -#define TSK_PC 0xe000 - -/*------------------------------------------------------------------*/ -/* LL management primitives */ -/*------------------------------------------------------------------*/ - -#define ASSIGN_LL 1 /* assign logical link */ -#define REMOVE_LL 0xff /* remove logical link */ - -/*------------------------------------------------------------------*/ -/* LL service primitives */ -/*------------------------------------------------------------------*/ - -#define LL_UDATA 1 /* link unit data request/indication */ -#define LL_ESTABLISH 2 /* link establish request/indication */ -#define LL_RELEASE 3 /* link release request/indication */ -#define LL_DATA 4 /* data request/indication */ -#define LL_LOCAL 5 /* switch to local operation (COM only) */ -#define LL_DATA_PEND 5 /* data pending indication (SDLC SHM only) */ -#define LL_REMOTE 6 /* switch to remote operation (COM only) */ -#define LL_TEST 8 /* link test request */ -#define LL_MDATA 9 /* more data request/indication */ -#define LL_BUDATA 10 /* broadcast unit data request/indication */ -#define LL_XID 12 /* XID command request/indication */ -#define LL_XID_R 13 /* XID response request/indication */ - -/*------------------------------------------------------------------*/ -/* NL service primitives */ -/*------------------------------------------------------------------*/ - -#define N_MDATA 1 /* more data to come REQ/IND */ -#define N_CONNECT 2 /* OSI N-CONNECT REQ/IND */ -#define N_CONNECT_ACK 3 /* OSI N-CONNECT CON/RES */ -#define N_DISC 4 /* OSI N-DISC REQ/IND */ -#define N_DISC_ACK 5 /* OSI N-DISC CON/RES */ -#define N_RESET 6 /* OSI N-RESET REQ/IND */ -#define N_RESET_ACK 7 /* OSI N-RESET CON/RES */ -#define N_DATA 8 /* OSI N-DATA REQ/IND */ -#define N_EDATA 9 /* OSI N-EXPEDITED DATA REQ/IND */ -#define N_UDATA 10 /* OSI D-UNIT-DATA REQ/IND */ -#define N_BDATA 11 /* BROADCAST-DATA REQ/IND */ -#define N_DATA_ACK 12 /* data ack ind for D-bit procedure */ -#define N_EDATA_ACK 13 /* data ack ind for INTERRUPT */ - -#define N_Q_BIT 0x10 /* Q-bit for req/ind */ -#define N_M_BIT 0x20 /* M-bit for req/ind */ -#define N_D_BIT 0x40 /* D-bit for req/ind */ - -/*------------------------------------------------------------------*/ -/* Signaling management primitives */ -/*------------------------------------------------------------------*/ - -#define ASSIGN_SIG 1 /* assign signaling task */ -#define UREMOVE_SIG 0xfe /* remove signaling task without returncode */ -#define REMOVE_SIG 0xff /* remove signaling task */ - -/*------------------------------------------------------------------*/ -/* Signaling service primitives */ -/*------------------------------------------------------------------*/ - -#define CALL_REQ 1 /* call request */ -#define CALL_CON 1 /* call confirmation */ -#define CALL_IND 2 /* incoming call connected */ -#define LISTEN_REQ 2 /* listen request */ -#define HANGUP 3 /* hangup request/indication */ -#define SUSPEND 4 /* call suspend request/confirm */ -#define RESUME 5 /* call resume request/confirm */ -#define SUSPEND_REJ 6 /* suspend rejected indication */ -#define USER_DATA 8 /* user data for user to user signaling */ -#define CONGESTION 9 /* network congestion indication */ -#define INDICATE_REQ 10 /* request to indicate an incoming call */ -#define INDICATE_IND 10 /* indicates that there is an incoming call */ -#define CALL_RES 11 /* accept an incoming call */ -#define CALL_ALERT 12 /* send ALERT for incoming call */ -#define INFO_REQ 13 /* INFO request */ -#define INFO_IND 13 /* INFO indication */ -#define REJECT 14 /* reject an incoming call */ -#define RESOURCES 15 /* reserve B-Channel hardware resources */ -#define TEL_CTRL 16 /* Telephone control request/indication */ -#define STATUS_REQ 17 /* Request D-State (returned in INFO_IND) */ -#define FAC_REG_REQ 18 /* connection idependent fac registration */ -#define FAC_REG_ACK 19 /* fac registration acknowledge */ -#define FAC_REG_REJ 20 /* fac registration reject */ -#define CALL_COMPLETE 21/* send a CALL_PROC for incoming call */ -#define FACILITY_REQ 22 /* send a Facility Message type */ -#define FACILITY_IND 22 /* Facility Message type indication */ -#define SIG_CTRL 29 /* Control for signalling hardware */ -#define DSP_CTRL 30 /* Control for DSPs */ -#define LAW_REQ 31 /* Law config request for (returns info_i) */ - - -/*------------------------------------------------------------------*/ -/* management service primitives */ -/*------------------------------------------------------------------*/ - -#define MAN_READ 2 -#define MAN_WRITE 3 -#define MAN_EXECUTE 4 -#define MAN_EVENT_ON 5 -#define MAN_EVENT_OFF 6 -#define MAN_LOCK 7 -#define MAN_UNLOCK 8 - -#define MAN_INFO_IND 2 -#define MAN_EVENT_IND 3 -#define MAN_TRACE_IND 4 - -#define MAN_ESC 0x80 - -/*------------------------------------------------------------------*/ -/* return code coding */ -/*------------------------------------------------------------------*/ - -#define UNKNOWN_COMMAND 0x01 /* unknown command */ -#define WRONG_COMMAND 0x02 /* wrong command */ -#define WRONG_ID 0x03 /* unknown task/entity id */ -#define WRONG_CH 0x04 /* wrong task/entity id */ -#define UNKNOWN_IE 0x05 /* unknown information el. */ -#define WRONG_IE 0x06 /* wrong information el. */ -#define OUT_OF_RESOURCES 0x07 /* ISDN-S card out of res. */ -#define ADAPTER_DEAD 0x08 /* ISDN card CPU halted */ -#define N_FLOW_CONTROL 0x10 /* Flow-Control, retry */ -#define ASSIGN_RC 0xe0 /* ASSIGN acknowledgement */ -#define ASSIGN_OK 0xef /* ASSIGN OK */ -#define OK_FC 0xfc /* Flow-Control RC */ -#define READY_INT 0xfd /* Ready interrupt */ -#define TIMER_INT 0xfe /* timer interrupt */ -#define OK 0xff /* command accepted */ - -/*------------------------------------------------------------------*/ -/* information elements */ -/*------------------------------------------------------------------*/ - -#define SHIFT 0x90 /* codeset shift */ -#define MORE 0xa0 /* more data */ -#define CL 0xb0 /* congestion level */ - - /* codeset 0 */ - -#define BC 0x04 /* Bearer Capability */ -#define CAU 0x08 /* cause */ -#define CAD 0x0c /* Connected address */ -#define CAI 0x10 /* call identity */ -#define CHI 0x18 /* channel identification */ -#define LLI 0x19 /* logical link id */ -#define CHA 0x1a /* charge advice */ -#define DT 0x29 /* ETSI date/time */ -#define KEY 0x2c /* keypad information element */ -#define FTY 0x1c /* facility information element */ -#define DSP 0x28 /* display */ -#define OAD 0x6c /* origination address */ -#define OSA 0x6d /* origination sub-address */ -#define CPN 0x70 /* called party number */ -#define DSA 0x71 /* destination sub-address */ -#define RDX 0x73 /* redirected number extended */ -#define RDN 0x74 /* redirected number */ -#define LLC 0x7c /* low layer compatibility */ -#define HLC 0x7d /* high layer compatibility */ -#define UUI 0x7e /* user user information */ -#define ESC 0x7f /* escape extension */ - -#define DLC 0x20 /* data link layer configuration */ -#define NLC 0x21 /* network layer configuration */ - - /* codeset 6 */ - -#define SIN 0x01 /* service indicator */ -#define CIF 0x02 /* charging information */ -#define DATE 0x03 /* date */ -#define CPS 0x07 /* called party status */ - -/*------------------------------------------------------------------*/ -/* TEL_CTRL contents */ -/*------------------------------------------------------------------*/ - -#define RING_ON 0x01 -#define RING_OFF 0x02 -#define HANDS_FREE_ON 0x03 -#define HANDS_FREE_OFF 0x04 -#define ON_HOOK 0x80 -#define OFF_HOOK 0x90 - -#endif diff --git a/drivers/isdn/eicon/pc_maint.h b/drivers/isdn/eicon/pc_maint.h deleted file mode 100644 index 660db8ec62ff..000000000000 --- a/drivers/isdn/eicon/pc_maint.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#ifndef PC_MAINT_H -#define PC_MAINT_H - -#if !defined(MIPS_SCOM) -#define BUFFER_SZ 48 -#define MAINT_OFFS 0x380 -#else -#define BUFFER_SZ 128 -#define MAINT_OFFS 0xff00 -#endif - -#define MIPS_BUFFER_SZ 128 -#define MIPS_MAINT_OFFS 0xff00 - -#define DO_LOG 1 -#define MEMR 2 -#define MEMW 3 -#define IOR 4 -#define IOW 5 -#define B1TEST 6 -#define B2TEST 7 -#define BTESTOFF 8 -#define DSIG_STATS 9 -#define B_CH_STATS 10 -#define D_CH_STATS 11 -#define BL1_STATS 12 -#define BL1_STATS_C 13 -#define GET_VERSION 14 -#define OS_STATS 15 -#define XLOG_SET_MASK 16 -#define XLOG_GET_MASK 17 -#define DSP_READ 20 -#define DSP_WRITE 21 - -#define OK 0xff -#define MORE_EVENTS 0xfe -#define NO_EVENT 1 - -struct DSigStruc -{ - byte Id; - byte uX; - byte listen; - byte active; - byte sin[3]; - byte bc[6]; - byte llc[6]; - byte hlc[6]; - byte oad[20]; -}; - -struct BL1Struc { - dword cx_b1; - dword cx_b2; - dword cr_b1; - dword cr_b2; - dword px_b1; - dword px_b2; - dword pr_b1; - dword pr_b2; - word er_b1; - word er_b2; -}; - -struct L2Struc { - dword XTotal; - dword RTotal; - word XError; - word RError; -}; - -struct OSStruc { - word free_n; -}; - -typedef union -{ - struct DSigStruc DSigStats; - struct BL1Struc BL1Stats; - struct L2Struc L2Stats; - struct OSStruc OSStats; - byte b[BUFFER_SZ]; - word w[BUFFER_SZ>>1]; - word l[BUFFER_SZ>>2]; /* word is wrong, do not use! Use 'd' instead. */ - dword d[BUFFER_SZ>>2]; -} BUFFER; - -typedef union -{ - struct DSigStruc DSigStats; - struct BL1Struc BL1Stats; - struct L2Struc L2Stats; - struct OSStruc OSStats; - byte b[MIPS_BUFFER_SZ]; - word w[MIPS_BUFFER_SZ>>1]; - word l[BUFFER_SZ>>2]; /* word is wrong, do not use! Use 'd' instead. */ - dword d[MIPS_BUFFER_SZ>>2]; -} MIPS_BUFFER; - - -#if !defined(MIPS_SCOM) -struct pc_maint -{ - byte req; - byte rc; - byte *mem; /*far*/ - short length; - word port; - byte fill[6]; - BUFFER data; -}; -#else -struct pc_maint -{ - byte req; - byte rc; - byte reserved[2]; /* R3000 alignment ... */ - byte far *mem; - short length; - word port; - byte fill[4]; /* data at offset 16 */ - BUFFER data; -}; -#endif - -struct mi_pc_maint -{ - byte req; - byte rc; - byte reserved[2]; /* R3000 alignment ... */ - byte *mem; /*far*/ - short length; - word port; - byte fill[4]; /* data at offset 16 */ - MIPS_BUFFER data; -}; - -#endif /* PC_MAINT_H */ diff --git a/drivers/isdn/eicon/pr_pc.h b/drivers/isdn/eicon/pr_pc.h deleted file mode 100644 index 3d79cc8c3cb8..000000000000 --- a/drivers/isdn/eicon/pr_pc.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.0 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - - -#if !defined(PR_PC_H) -#define PR_PC_H - -struct pr_ram { - word NextReq; /* pointer to next Req Buffer */ - word NextRc; /* pointer to next Rc Buffer */ - word NextInd; /* pointer to next Ind Buffer */ - byte ReqInput; /* number of Req Buffers sent */ - byte ReqOutput; /* number of Req Buffers returned */ - byte ReqReserved; /* number of Req Buffers reserved */ - byte Int; /* ISDN-P interrupt */ - byte XLock; /* Lock field for arbitration */ - byte RcOutput; /* number of Rc buffers received */ - byte IndOutput; /* number of Ind buffers received */ - byte IMask; /* Interrupt Mask Flag */ - byte Reserved1[2]; /* reserved field, do not use */ - byte ReadyInt; /* request field for ready interrupt */ - byte Reserved2[12]; /* reserved field, do not use */ - byte InterfaceType; /* interface type 1=16K interface */ - word Signature; /* ISDN-P initialized indication */ - byte B[1]; /* buffer space for Req,Ind and Rc */ -}; - -typedef struct { - word next; - byte Req; - byte ReqId; - byte ReqCh; - byte Reserved1; - word Reference; - byte Reserved[8]; - PBUFFER XBuffer; -} REQ; - -typedef struct { - word next; - byte Rc; - byte RcId; - byte RcCh; - byte Reserved1; - word Reference; - byte Reserved2[8]; -} RC; - -typedef struct { - word next; - byte Ind; - byte IndId; - byte IndCh; - byte MInd; - word MLength; - word Reference; - byte RNR; - byte Reserved; - dword Ack; - PBUFFER RBuffer; -} IND; - -#endif diff --git a/drivers/isdn/eicon/pri.c b/drivers/isdn/eicon/pri.c deleted file mode 100644 index e240cdda5847..000000000000 --- a/drivers/isdn/eicon/pri.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Diva Server PRI specific part of initialisation - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.5 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "sys.h" -#include "idi.h" -#include "divas.h" -#include "pc.h" -#include "pr_pc.h" -#include "dsp_defs.h" - -#include "adapter.h" -#include "uxio.h" - -#define DIVAS_LOAD_CMD 0x02 -#define DIVAS_START_CMD 0x03 -#define DIVAS_IRQ_RESET 0xC18 -#define DIVAS_IRQ_RESET_VAL 0xFE - -#define TEST_INT_DIVAS 0x11 -#define TEST_INT_DIVAS_BRI 0x12 - -#define DIVAS_RESET 0x81 -#define DIVAS_LED1 0x04 -#define DIVAS_LED2 0x08 -#define DIVAS_LED3 0x20 -#define DIVAS_LED4 0x40 - -#define DIVAS_RESET_REG 0x20 - -#define DIVAS_SIGNATURE 0x4447 - -/* offset to start of MAINT area (used by xlog) */ - -#define DIVAS_MAINT_OFFSET 0xef00 /* value for PRI card */ - -#define MP_PROTOCOL_ADDR 0xA0011000 -#define MP_DSP_CODE_BASE 0xa03a0000 - -typedef struct { - dword cmd; - dword addr; - dword len; - dword err; - dword live; - dword reserved[(0x1020>>2)-6]; - dword signature; - byte data[1]; -} diva_server_boot_t; - -byte mem_in(ADAPTER *a, void *adr); -word mem_inw(ADAPTER *a, void *adr); -void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length); -void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e); -void mem_out(ADAPTER *a, void *adr, byte data); -void mem_outw(ADAPTER *a, void *adr, word data); -void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length); -void mem_inc(ADAPTER *a, void *adr); - -int DivasPRIInitPCI(card_t *card, dia_card_t *cfg); -static int pri_ISR (card_t* card); - -static int diva_server_reset(card_t *card) -{ - byte *reg; - diva_server_boot_t *boot = NULL; - dword live = 0; - int i = 0; - dword dwWait; - - DPRINTF(("divas: reset Diva Server PRI")); - - reg = UxCardMemAttach(card->hw, DIVAS_REG_MEMORY); - - UxCardMemOut(card->hw, ®[DIVAS_RESET_REG], DIVAS_RESET | - DIVAS_LED1 | DIVAS_LED2 | DIVAS_LED3 | DIVAS_LED4); - - for (dwWait = 0x000fffff; dwWait; dwWait--) - ; - - UxCardMemOut(card->hw, ®[DIVAS_RESET_REG], 0x00); - - for (dwWait = 0x000fffff; dwWait; dwWait--) - ; - - UxCardMemDetach(card->hw, reg); - - boot = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY); - - UxCardMemOutD(card->hw, boot->reserved, 0); - - live = UxCardMemInD(card->hw, &boot->live); - - for (i=0; i<5; i++) - { - if (live != UxCardMemInD(card->hw, &boot->live)) - { - break; - } - UxPause(10); - } - - if (i == 5) - { - UxCardMemDetach(card->hw, boot); - - DPRINTF(("divas: card is reset but CPU not running")); - return -1; - } - - UxCardMemDetach(card->hw, boot); - - DPRINTF(("divas: card reset after %d ms", i * 10)); - - return 0; -} - -static int diva_server_config(card_t *card, dia_config_t *config) -{ - byte *shared; - int i, j; - - DPRINTF(("divas: configure Diva Server PRI")); - - shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - UxCardLog(0); - for (i=0; i<256; i++) - { - UxCardMemOut(card->hw, &shared[i], 0); - } - - UxCardMemOut(card->hw, &shared[ 8], config->tei); - UxCardMemOut(card->hw, &shared[ 9], config->nt2); - UxCardMemOut(card->hw, &shared[10], config->sig_flags); - UxCardMemOut(card->hw, &shared[11], config->watchdog); - UxCardMemOut(card->hw, &shared[12], config->permanent); - UxCardMemOut(card->hw, &shared[13], config->x_interface); - UxCardMemOut(card->hw, &shared[14], config->stable_l2); - UxCardMemOut(card->hw, &shared[15], config->no_order_check); - UxCardMemOut(card->hw, &shared[16], config->handset_type); - UxCardMemOut(card->hw, &shared[17], 0); - UxCardMemOut(card->hw, &shared[18], config->low_channel); - UxCardMemOut(card->hw, &shared[19], config->prot_version); - UxCardMemOut(card->hw, &shared[20], config->crc4); - - for (i=0; i<2; i++) - { - for (j=0; j<32; j++) - { - UxCardMemOut(card->hw, &shared[32+(i*96)+j],config->terminal[i].oad[j]); - } - - for (j=0; j<32; j++) - { - UxCardMemOut(card->hw, &shared[64+(i*96)+j],config->terminal[i].osa[j]); - } - - for (j=0; j<32; j++) - { - UxCardMemOut(card->hw, &shared[96+(i*96)+j],config->terminal[i].spid[j]); - } - } - - UxCardMemDetach(card->hw, shared); - - return 0; -} - -static -void diva_server_reset_int(card_t *card) -{ - byte *cfg; - - cfg = UxCardMemAttach(card->hw, DIVAS_CFG_MEMORY); - - UxCardMemOutW(card->hw, &cfg[DIVAS_IRQ_RESET], DIVAS_IRQ_RESET_VAL); - UxCardMemOutW(card->hw, &cfg[DIVAS_IRQ_RESET + 2], 0); - UxCardMemDetach(card->hw, cfg); - - return; -} - - -static int diva_server_test_int(card_t *card) -{ - int i; - byte *shared; - byte req_int; - - DPRINTF(("divas: test interrupt for Diva Server PRI")); - - shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - UxCardMemIn(card->hw, &shared[0x3FE]); - UxCardMemOut(card->hw, &shared[0x3FE], 0); - UxCardMemIn(card->hw, &shared[0x3FE]); - - UxCardMemDetach(card->hw, shared); - - diva_server_reset_int(card); - - shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY); - - card->test_int_pend = TEST_INT_DIVAS; - - req_int = UxCardMemIn(card->hw, &(((struct pr_ram *)shared)->ReadyInt)); - - req_int++; - - UxCardMemOut(card->hw, &(((struct pr_ram *)shared)->ReadyInt), req_int); - - UxCardMemDetach(card->hw, shared); - - UxCardLog(0); - for (i = 0; i < 50; i++) - { - if (!card->test_int_pend) - { - break; - } - UxPause(10); - } - - - if (card->test_int_pend) - { - - DPRINTF(("active: timeout waiting for card to interrupt")); - return (-1); - - } - - return 0; -} - - -static void print_hdr(unsigned char *code, int offset) -{ - unsigned char hdr[80]; - int i; - - i = 0; - - while ((i < (DIM(hdr) -1)) && - (code[offset + i] != '\0') && - (code[offset + i] != '\r') && - (code[offset + i] != '\n')) - { - hdr[i] = code[offset + i]; - i++; - } - - hdr[i] = '\0'; - - DPRINTF(("divas: loading %s", hdr)); -} - -static int diva_server_load(card_t *card, dia_load_t *load) -{ - diva_server_boot_t *boot; - int i, offset, length; - dword cmd = 0; - - DPRINTF(("divas: loading Diva Server PRI")); - - boot = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY); - - switch(load->code_type) - { - case DIA_CPU_CODE: - DPRINTF(("divas: RISC code")); - print_hdr(load->code, 0x80); - - UxCardMemOutD(card->hw, &boot->addr, MP_PROTOCOL_ADDR); - break; - - case DIA_DSP_CODE: - DPRINTF(("divas: DSP code")); - print_hdr(load->code, 0x0); - - UxCardMemOutD(card->hw, &boot->addr, - (MP_DSP_CODE_BASE + (((sizeof(dword) + - (sizeof(t_dsp_download_desc) * DSP_MAX_DOWNLOAD_COUNT)) - + ~ALIGNMENT_MASK_MAESTRA) & ALIGNMENT_MASK_MAESTRA))); - break; - - case DIA_TABLE_CODE: - DPRINTF(("divas: TABLE code")); - UxCardMemOutD(card->hw, &boot->addr, - (MP_DSP_CODE_BASE + sizeof(dword))); - break; - - case DIA_CONT_CODE: - DPRINTF(("divas: continuation code")); - break; - - case DIA_DLOAD_CNT: - DPRINTF(("divas: COUNT code")); - UxCardMemOutD(card->hw, &boot->addr, MP_DSP_CODE_BASE); - break; - - default: - DPRINTF(("divas: unknown code type")); - UxCardMemDetach(card->hw, boot); - return -1; - } - - UxCardLog(0); - offset = 0; - - do - { - length = (load->length - offset >= 400) ? 400 : load->length - offset; - - for (i=0; i<length; i++) - { - UxCardMemOut(card->hw, &boot->data[i], load->code[offset+i]); - } - - for (i=0; i<length; i++) - { - if (load->code[offset + i] != UxCardMemIn(card->hw, &boot->data[i])) - { - UxCardMemDetach(card->hw, boot); - - DPRINTF(("divas: card code block verify failed")); - return -1; - } - } - - UxCardMemOutD(card->hw, &boot->len, (length + 3) / 4); - UxCardMemOutD(card->hw, &boot->cmd, DIVAS_LOAD_CMD); - - for (i=0; i<50000; i++) - { - cmd = UxCardMemInD(card->hw, &boot->cmd); - if (!cmd) - { - break; - } - /*UxPause(1);*/ - } - - if (cmd) - { - DPRINTF(("divas: timeout waiting for card to ACK load (offset = %d)", offset)); - UxCardMemDetach(card->hw, boot); - return -1; - } - - offset += length; - - } while (offset < load->length); - - UxCardMemDetach(card->hw, boot); - - DPRINTF(("divas: DIVA Server card loaded")); - - return 0; -} - -static int diva_server_start(card_t *card, byte *channels) -{ - diva_server_boot_t *boot; - byte *ram; - int i; - dword signature = 0; - - DPRINTF(("divas: start Diva Server PRI")); - - card->is_live = FALSE; - - boot = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY); - - UxCardMemOutD(card->hw, &boot->addr, MP_PROTOCOL_ADDR); - UxCardMemOutD(card->hw, &boot->cmd, DIVAS_START_CMD); - - UxCardLog(0); - - for (i = 0; i < 300; i++) - { - signature = UxCardMemInD(card->hw, &boot->signature); - if ((signature >> 16) == DIVAS_SIGNATURE) - { - DPRINTF(("divas: started card after %d ms", i * 10)); - break; - } - UxPause(10); - } - - if ((signature >> 16) != DIVAS_SIGNATURE) - { - UxCardMemDetach(card->hw, boot); - DPRINTF(("divas: timeout waiting for card to run protocol code (sig = 0x%x)", signature)); - return -1; - } - - card->is_live = TRUE; - - ram = (byte *) boot; - ram += DIVAS_SHARED_OFFSET; - - *channels = UxCardMemIn(card->hw, &ram[0x3F6]); - card->serial_no = UxCardMemInD(card->hw, &ram[0x3F0]); - - UxCardMemDetach(card->hw, boot); - - if (diva_server_test_int(card)) - { - DPRINTF(("divas: interrupt test failed")); - return -1; - } - - DPRINTF(("divas: DIVA Server card started")); - - return 0; -} - -static -int diva_server_mem_get(card_t *card, mem_block_t *mem_block) - -{ - byte *a; - byte *card_addr; - word length = 0; - int i; - - a = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY); - - card_addr = a; - card_addr += mem_block->addr; - - for (i=0; i < sizeof(mem_block->data); i++) - { - mem_block->data[i] = UxCardMemIn(card->hw, card_addr); - card_addr++; - length++; - } - - UxCardMemDetach(card->hw, a); - - return length; -} - -/* - * Initialise PRI specific entry points - */ - -int DivasPriInit(card_t *card, dia_card_t *cfg) -{ - DPRINTF(("divas: initialise Diva Server PRI")); - - if (DivasPRIInitPCI(card, cfg) == -1) - { - return -1; - } - - card->card_reset = diva_server_reset; - card->card_load = diva_server_load; - card->card_config = diva_server_config; - card->card_start = diva_server_start; - card->reset_int = diva_server_reset_int; - card->card_mem_get = diva_server_mem_get; - - card->xlog_offset = DIVAS_MAINT_OFFSET; - - card->out = DivasOut; - card->test_int = DivasTestInt; - card->dpc = DivasDpc; - card->clear_int = DivasClearInt; - card->card_isr = pri_ISR; - - card->a.ram_out = mem_out; - card->a.ram_outw = mem_outw; - card->a.ram_out_buffer = mem_out_buffer; - card->a.ram_inc = mem_inc; - - card->a.ram_in = mem_in; - card->a.ram_inw = mem_inw; - card->a.ram_in_buffer = mem_in_buffer; - card->a.ram_look_ahead = mem_look_ahead; - - return 0; -} - - -static int pri_ISR (card_t* card) -{ - int served = 0; - byte* cfg = UxCardMemAttach(card->hw, DIVAS_CFG_MEMORY); - volatile unsigned long* isr = (unsigned long*)&cfg[DIVAS_IRQ_RESET]; - register unsigned long val = *isr; - - if (val & 0x80000000) /* our card had caused interrupt ??? */ - { - served = 1; - card->int_pend += 1; - DivasDpcSchedule(); /* ISR DPC */ - - *isr = (unsigned long)~0x03E00000; /* Clear interrupt line */ - } - - UxCardMemDetach(card->hw, cfg); - - return (served != 0); -} - - diff --git a/drivers/isdn/eicon/sys.h b/drivers/isdn/eicon/sys.h deleted file mode 100644 index d789237d5729..000000000000 --- a/drivers/isdn/eicon/sys.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Environment provided by system and miscellaneous definitions - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.2 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#if !defined(SYS_H) -#define SYS_H - -/* abreviations for unsigned types */ -typedef int boolean_t; - -typedef unsigned char byte; - -typedef unsigned long dword; -typedef unsigned short word; - -/* abreviations for volatile types */ - -typedef volatile byte vbyte; -typedef volatile word vword; -typedef volatile dword vdword; - -/* Booleans */ - -#if !defined(TRUE) -#define TRUE (1) -#define FALSE (0) -#endif - -/* NULL pointer */ - -#if !defined(NULL) -#define NULL ((void *) 0) -#endif - -/* Return the dimension of an array */ - -#if !defined(DIM) -#define DIM(array) (sizeof (array)/sizeof ((array)[0])) -#endif - -/* - * Return the number of milliseconds since last boot - */ - -extern dword UxTimeGet(void); - -extern void DivasSprintf(char *buffer, char *format, ...); -extern void DivasPrintf(char *format, ...); - -/* fatal errors, asserts and tracing */ - -void HwFatalErrorFrom(char *file, int line); -void HwFatalError(void); -/* void HwAssert(char *file, int line, char *condition); */ - -#include <linux/kernel.h> -#include <linux/string.h> - -#define _PRINTK printk - -#define _PRINTF DivasPrintf -void _PRINTF(char *format, ...); -#define PRINTF(arg_list) _PRINTF arg_list -#if defined DTRACE -# define DPRINTF(arg_list) _PRINTF arg_list -# define KDPRINTF(arg_list) _PRINTF arg_list ; _PRINTK arg_list ; _PRINTK("\n"); -#else -# define DPRINTF(arg_list) (void)0 -# define KDPRINTF(arg_list) _PRINTK arg_list ; _PRINTK("\n"); -#endif - -#if !defined(ASSERT) -#if defined DEBUG || defined DBG -# define HwFatalError() HwFatalErrorFrom(__FILE__, __LINE__) -# define ASSERT(cond) \ - if (!(cond)) \ - { \ -/* HwAssert(__FILE__, __LINE__, #cond);*/ \ - } -#else -# define ASSERT(cond) ((void)0) -#endif -#endif /* !defined(ASSERT) */ - -#define TRACE (_PRINTF(__FILE__"@%d\n", __LINE__)) - -#endif /* SYS_H */ diff --git a/drivers/isdn/eicon/uxio.h b/drivers/isdn/eicon/uxio.h deleted file mode 100644 index c6c825e10c54..000000000000 --- a/drivers/isdn/eicon/uxio.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Interface to Unix specific code for performing card I/O - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.6 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#if !defined(UXIO_H) -#define UXIO_H - -#include "sys.h" -#include "adapter.h" - - -struct pt_regs; - -/* user callback, returns zero if interrupt was from this card */ -typedef void isr_fn_t(void *); -struct ux_diva_card_s -{ - word in_use; - int io_base; - int reset_base; - int card_type; - byte *mapped; - struct pci_dev *pdev; - int slot; - int irq; - byte *pDRAM; - byte *pDEVICES; - byte *pCONFIG; - byte *pSHARED; - byte *pCONTROL; - word features; - void *user_isr_arg; - isr_fn_t *user_isr; -}; - -/* - * Get a card handle to enable card to be accessed - */ - -int UxCardHandleGet( ux_diva_card_t **card, - dia_card_t *cfg); - -/* - * Free a card handle as no longer needed - */ - -void UxCardHandleFree(ux_diva_card_t *card); - -/* - * Lock and unlock access to a card - */ - -long UxCardLock(ux_diva_card_t *card); -void UxCardUnlock(ux_diva_card_t *card, unsigned long ipl); - -/* - * Set the mapping address for PCI cards - */ - -int UxCardAddrMappingSet(ux_diva_card_t *card, - int id, - void *address, - int size); - -/* - * Attach card to memory to enable it to be accessed - * Returns the mapped address - */ - -void *UxCardMemAttach(ux_diva_card_t *card, int id); - -/* - * map card out of memory after completion of access - */ - -void UxCardMemDetach(ux_diva_card_t *card, void *address); - -/* - * input functions for memory-mapped cards - */ - -byte UxCardMemIn(ux_diva_card_t *card, void *address); - -word UxCardMemInW(ux_diva_card_t *card, void *address); - -dword UxCardMemInD(ux_diva_card_t *card, void *address); - -void UxCardMemInBuffer( ux_diva_card_t *card, - void *address, - void *buffer, - int length); - -/* - * output functions for memory-mapped cards - */ - -void UxCardMemOut(ux_diva_card_t *card, void *address, byte data); - -void UxCardMemOutW(ux_diva_card_t *card, void *address, word data); - -void UxCardMemOutD(ux_diva_card_t *card, void *address, dword data); - -void UxCardMemOutBuffer( ux_diva_card_t *card, - void *address, - void *buffer, - int length); - -/* - * input functions for I/O-mapped cards - */ - -byte UxCardIoIn(ux_diva_card_t *card, void *, void *address); - -word UxCardIoInW(ux_diva_card_t *card, void *, void *address); - -dword UxCardIoInD(ux_diva_card_t *card, void *, void *address); - -void UxCardIoInBuffer( ux_diva_card_t *card, - void *, void *address, - void *buffer, - int length); - -/* - * output functions for I/O-mapped cards - */ - -void UxCardIoOut(ux_diva_card_t *card, void *, void *address, byte data); - -void UxCardIoOutW(ux_diva_card_t *card, void *, void *address, word data); - -void UxCardIoOutD(ux_diva_card_t *card, void *, void *address, dword data); - -void UxCardIoOutBuffer( ux_diva_card_t *card, - void *, void *address, - void *buffer, - int length); - -/* - * Get specified PCI config - */ - -void UxPciConfigRead(ux_diva_card_t *card, - int size, - int offset, - void *value); - -/* - * Set specified PCI config - */ - -void UxPciConfigWrite(ux_diva_card_t *card, - int size, - int offset, - void *value); - -/* allocate memory, returning NULL if none available */ - -void *UxAlloc(unsigned int size); - -void UxFree(void *); - -/* - * Pause for specified number of milli-seconds - */ - -void UxPause(long ms); - -/* - * Install an ISR for the specified card - */ - -int UxIsrInstall(ux_diva_card_t *card, isr_fn_t *isr_fn, void *isr_arg); - -/* - * Remove an ISR for the specified card - */ -void UxIsrRemove(ux_diva_card_t *card, void *); - -/* - * DEBUG function to turn logging ON or OFF - */ - -void UxCardLog(int turn_on); - -long UxInterlockedIncrement(ux_diva_card_t *card, long *dst); -long UxInterlockedDecrement(ux_diva_card_t *card, long *dst); - -#endif /* of UXIO_H */ diff --git a/drivers/isdn/eicon/xlog.c b/drivers/isdn/eicon/xlog.c deleted file mode 100644 index 3312842208e1..000000000000 --- a/drivers/isdn/eicon/xlog.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Unix Eicon active card driver - * XLOG related functions - * - * Copyright (C) Eicon Technology Corporation, 2000. - * - * Eicon File Revision : 1.2 - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include "sys.h" -#include "idi.h" -#include "pc.h" -#include "pc_maint.h" -#include "divalog.h" - -#include "adapter.h" -#include "uxio.h" - -/* - * convert/copy XLOG info into a KLOG entry - */ - -static -void xlog_to_klog(byte *b, int size, int card_num) - -{ - typedef struct - { - word code; - word time_hi; - word time_lo; - word xcode; - byte data[2]; - } card_xlog_t; - - card_xlog_t *x; - - klog_t klog; - - x = (card_xlog_t *) b; - - memset(&klog, 0, sizeof(klog)); - - klog.time_stamp = (dword) x->time_hi; - klog.time_stamp = (klog.time_stamp << 16) | (dword) x->time_lo; - - klog.length = size > sizeof(klog.buffer) ? sizeof(klog.buffer) : size; - - klog.card = card_num; - if (x->code == 1) - { - klog.type = KLOG_XTXT_MSG; - klog.code = 0; - memcpy(klog.buffer, &x->xcode, klog.length); - } - else if (x->code == 2) - { - klog.type = KLOG_XLOG_MSG; - klog.code = x->xcode; - memcpy(klog.buffer, &x->data, klog.length); - } - else - { - char *c; int i; - klog.type = KLOG_TEXT_MSG; - klog.code = 0; - c = "divas: invalid xlog message code from card"; - i = 0; - while (*c) - { - klog.buffer[i] = *c; - c++; - i++; - } - klog.buffer[i] = *c; - } - - /* send to the log driver and return */ - - DivasLogAdd(&klog, sizeof(klog)); - - return; -} - -/* - * send an XLOG request down to specified card - * if response available from previous request then read it - * if not then just send down new request, ready for next time - */ - -void DivasXlogReq(int card_num) - -{ - card_t *card; - ADAPTER *a; - - if ((card_num < 0) || (card_num > DivasCardNext)) - { - DPRINTF(("xlog: invalid card number")); - return; - } - - card = &DivasCards[card_num]; - - if (DivasXlogRetrieve(card)) - { - return; - } - - /* send down request for next time */ - - a = &card->a; - - a->ram_out(a, (word *) (card->xlog_offset + 1), 0); - a->ram_out(a, (word *) (dword) (card->xlog_offset), DO_LOG); - - return; -} - -/* - * retrieve XLOG request from specified card - * returns non-zero if new request sent to card - */ - -int DivasXlogRetrieve(card_t *card) - -{ - ADAPTER *a; - struct mi_pc_maint pcm; - - a = &card->a; - - /* get status of last request */ - - pcm.rc = a->ram_in(a, (word *)(card->xlog_offset + 1)); - - /* if nothing there from previous request, send down a new one */ - - if (pcm.rc == OK) - { - /* read in response */ - - a->ram_in_buffer(a, (word *) (dword) card->xlog_offset, &pcm, sizeof(pcm)); - - xlog_to_klog((byte *) &pcm.data, sizeof(pcm.data), - (int) (card - DivasCards)); - } - - /* if any response received from card, re-send request */ - - if (pcm.rc) - { - a->ram_out(a, (word *) (card->xlog_offset + 1), 0); - a->ram_out(a, (word *) (dword) (card->xlog_offset), DO_LOG); - - return 1; - } - - return 0; -} diff --git a/drivers/isdn/hardware/Kconfig b/drivers/isdn/hardware/Kconfig index b2132c6035a9..2850ff97791f 100644 --- a/drivers/isdn/hardware/Kconfig +++ b/drivers/isdn/hardware/Kconfig @@ -25,8 +25,6 @@ source "drivers/isdn/sc/Kconfig" source "drivers/isdn/act2000/Kconfig" -source "drivers/isdn/eicon/Kconfig" - source "drivers/isdn/tpam/Kconfig" source "drivers/isdn/hysdn/Kconfig" diff --git a/drivers/isdn/hardware/eicon/capifunc.c b/drivers/isdn/hardware/eicon/capifunc.c index e56e81c67e53..865a1ed9fac3 100644 --- a/drivers/isdn/hardware/eicon/capifunc.c +++ b/drivers/isdn/hardware/eicon/capifunc.c @@ -1,4 +1,4 @@ -/* $Id: capifunc.c,v 1.47 2003/09/09 06:52:29 schindler Exp $ +/* $Id: capifunc.c,v 1.48 2004/01/11 19:20:54 armin Exp $ * * ISDN interface module for Eicon active cards DIVA. * CAPI Interface common functions @@ -776,7 +776,7 @@ static void diva_register_appl(struct capi_ctr *ctrl, __u16 appl, } if (application[appl - 1].Id == appl) { - DBG_ERR(("CAPI_REGISTER - appl already registered")) + DBG_LOG(("CAPI_REGISTER - appl already registered")) return; /* appl already registered */ } diff --git a/drivers/isdn/hardware/eicon/divamnt.c b/drivers/isdn/hardware/eicon/divamnt.c index f17438ea0617..abd70d0d0268 100644 --- a/drivers/isdn/hardware/eicon/divamnt.c +++ b/drivers/isdn/hardware/eicon/divamnt.c @@ -1,4 +1,4 @@ -/* $Id: divamnt.c,v 1.28 2003/09/18 06:57:18 schindler Exp $ +/* $Id: divamnt.c,v 1.32 2004/01/15 09:48:13 armin Exp $ * * Driver for Eicon DIVA Server ISDN cards. * Maint module @@ -26,7 +26,7 @@ #include "divasync.h" #include "debug_if.h" -static char *main_revision = "$Revision: 1.28 $"; +static char *main_revision = "$Revision: 1.32 $"; static int major; @@ -53,7 +53,7 @@ static struct timeval start_time; extern int mntfunc_init(int *, void **, unsigned long); extern void mntfunc_finit(void); -extern int maint_read_write(void *buf); +extern int maint_read_write(void *buf, int count); /* * helper functions @@ -363,13 +363,13 @@ static void remove_maint_proc(void) static ssize_t divas_maint_write(struct file *file, const char *buf, size_t count, loff_t * ppos) { - return (maint_read_write((char *) buf)); + return (maint_read_write((char *) buf, (int) count)); } static ssize_t divas_maint_read(struct file *file, char *buf, size_t count, loff_t * ppos) { - return (maint_read_write(buf)); + return (maint_read_write(buf, (int) count)); } static struct file_operations divas_maint_fops = { diff --git a/drivers/isdn/hardware/eicon/mntfunc.c b/drivers/isdn/hardware/eicon/mntfunc.c index 16d2dcb2c86e..00ef979d6c7c 100644 --- a/drivers/isdn/hardware/eicon/mntfunc.c +++ b/drivers/isdn/hardware/eicon/mntfunc.c @@ -1,4 +1,4 @@ -/* $Id: mntfunc.c,v 1.16 2003/09/18 06:57:17 schindler Exp $ +/* $Id: mntfunc.c,v 1.19 2004/01/09 21:22:03 armin Exp $ * * Driver for Eicon DIVA Server ISDN cards. * Maint module @@ -148,12 +148,15 @@ static void DIVA_EXIT_FUNCTION disconnect_didd(void) /* * read/write maint */ -int maint_read_write(void *buf) +int maint_read_write(void *buf, int count) { byte data[128]; dword cmd, id, mask; int ret = 0; + if (count < (3 * sizeof(dword))) + return (-EFAULT); + if (diva_os_copy_from_user(NULL, (void *) &data[0], buf, 3 * sizeof(dword))) { return (-EFAULT); @@ -166,7 +169,7 @@ int maint_read_write(void *buf) switch (cmd) { case DITRACE_CMD_GET_DRIVER_INFO: if ((ret = diva_get_driver_info(id, data, sizeof(data))) > 0) { - if (diva_os_copy_to_user + if ((count < ret) || diva_os_copy_to_user (NULL, buf, (void *) &data[0], ret)) ret = -EFAULT; } else { @@ -176,7 +179,7 @@ int maint_read_write(void *buf) case DITRACE_READ_DRIVER_DBG_MASK: if ((ret = diva_get_driver_dbg_mask(id, (byte *) data)) > 0) { - if (diva_os_copy_to_user + if ((count < ret) || diva_os_copy_to_user (NULL, buf, (void *) &data[0], ret)) ret = -EFAULT; } else { @@ -209,7 +212,7 @@ int maint_read_write(void *buf) ret = size; memcpy(pbuf, pmsg, size); diva_maint_ack_message(1, &old_irql); - if (diva_os_copy_to_user (NULL, buf, + if ((count < size) || diva_os_copy_to_user (NULL, buf, (void *) pbuf, size)) ret = -EFAULT; diva_os_free_tbuffer(0, pbuf); @@ -265,7 +268,7 @@ int maint_read_write(void *buf) pbuf[written++] = 0; pbuf[written++] = 0; - if (diva_os_copy_to_user(NULL, buf, (void *) pbuf, written)) { + if ((count < written) || diva_os_copy_to_user(NULL, buf, (void *) pbuf, written)) { ret = -EFAULT; } else { ret = written; diff --git a/drivers/isdn/hardware/eicon/platform.h b/drivers/isdn/hardware/eicon/platform.h index 0d1266f65359..278bdc9d7980 100644 --- a/drivers/isdn/hardware/eicon/platform.h +++ b/drivers/isdn/hardware/eicon/platform.h @@ -1,4 +1,4 @@ -/* $Id: platform.h,v 1.32 2003/09/18 06:59:59 schindler Exp $ +/* $Id: platform.h,v 1.35 2003/12/05 18:45:05 armin Exp $ * * platform.h * @@ -117,6 +117,8 @@ #define MEM_TYPE_CONFIG 7 #define MEM_TYPE_CONTROL 8 +#define MAX_MEM_TYPE 10 + #define DIVA_OS_MEM_ATTACH_RAM(a) ((a)->ram) #define DIVA_OS_MEM_ATTACH_PORT(a) ((a)->port) #define DIVA_OS_MEM_ATTACH_PROM(a) ((a)->prom) diff --git a/drivers/isdn/hardware/eicon/s_bri.c b/drivers/isdn/hardware/eicon/s_bri.c index 24df86bf4143..7b5495f46700 100644 --- a/drivers/isdn/hardware/eicon/s_bri.c +++ b/drivers/isdn/hardware/eicon/s_bri.c @@ -61,7 +61,7 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) { /* * check for trapped MIPS 3xxx CPU, dump only exception frame */ - if ( READ_WORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 ) + if ( READ_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 ) { dump_trap_frame (IoAdapter, &((byte *)Xlog)[0x90]) ; IoAdapter->trapped = 1 ; diff --git a/drivers/isdn/hardware/eicon/um_idi.c b/drivers/isdn/hardware/eicon/um_idi.c index 6ef0f5a5f64f..354a3e556f06 100644 --- a/drivers/isdn/hardware/eicon/um_idi.c +++ b/drivers/isdn/hardware/eicon/um_idi.c @@ -1,4 +1,4 @@ -/* $Id: um_idi.c,v 1.9 2003/09/09 06:00:47 schindler Exp $ */ +/* $Id: um_idi.c,v 1.12 2004/01/12 18:00:09 armin Exp $ */ #include "platform.h" #include "di_defs.h" @@ -252,7 +252,7 @@ void *divas_um_idi_create_entity(dword adapter_nr, void *file) diva_os_free(0, e); return (0); } - if ((diva_data_q_init(&e->rc, 64, 2))) { + if ((diva_data_q_init(&e->rc, sizeof(diva_um_idi_ind_hdr_t), 2))) { diva_data_q_finit(&e->data); diva_os_free(0, e->os_context); diva_os_free(0, e); diff --git a/drivers/isdn/hardware/eicon/xdi_adapter.h b/drivers/isdn/hardware/eicon/xdi_adapter.h index b52b90580b96..764dfc55017d 100644 --- a/drivers/isdn/hardware/eicon/xdi_adapter.h +++ b/drivers/isdn/hardware/eicon/xdi_adapter.h @@ -1,4 +1,4 @@ -/* $Id: xdi_adapter.h,v 1.5 2003/06/21 17:06:08 schindler Exp $ */ +/* $Id: xdi_adapter.h,v 1.6 2003/12/05 18:45:05 armin Exp $ */ #ifndef __DIVA_OS_XDI_ADAPTER_H__ #define __DIVA_OS_XDI_ADAPTER_H__ @@ -14,7 +14,7 @@ typedef struct _divas_pci_card_resources { dword bar[8]; /* contains context of appropriate BAR Register */ void *addr[8]; /* same bar, but mapped into memory */ dword length[8]; /* bar length */ - int mem_type_id[10]; + int mem_type_id[MAX_MEM_TYPE]; unsigned int qoffset; byte irq; } divas_pci_card_resources_t; diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 120ce6713295..50474f52fcdc 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c @@ -26,11 +26,6 @@ #include <asm/page.h> #include <asm/pgtable.h> -#ifndef TryLockPage -# include "linux/page-flags.h" -# define TryLockPage TestSetPageLocked -#endif - #include <media/video-buf.h> static int debug = 0; diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index e588e3270287..c6d9a5cd2996 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -858,6 +858,7 @@ static struct pci_fixup pci_fixups[] __devinitdata = { { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_isa_dma_hangs }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596, quirk_isa_dma_hangs }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, quirk_isa_dma_hangs }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, quirk_isa_dma_hangs }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_1, quirk_isa_dma_hangs }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_2, quirk_isa_dma_hangs }, diff --git a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c index 9def3233a56f..2d6f684774ec 100644 --- a/drivers/sbus/char/rtc.c +++ b/drivers/sbus/char/rtc.c @@ -89,6 +89,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, switch (cmd) { case RTCGET: + memset(&rtc_tm, 0, sizeof(struct rtc_time)); get_rtc_time(&rtc_tm); if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c index 27d4bf47fdb1..b2ec2aebd23a 100644 --- a/drivers/serial/8250_pnp.c +++ b/drivers/serial/8250_pnp.c @@ -295,6 +295,8 @@ static const struct pnp_device_id pnp_dev_table[] = { { "USR2080", 0 }, /* U.S. Robotics 56K FAX INT */ { "USR3031", 0 }, + /* U.S. Robotics 56K FAX INT */ + { "USR3050", 0 }, /* U.S. Robotics 56K Voice INT PnP */ { "USR3070", 0 }, /* U.S. Robotics 56K Voice EXT PnP */ diff --git a/drivers/video/radeonfb.c b/drivers/video/radeonfb.c index 989f3d457bda..da1a38bfa768 100644 --- a/drivers/video/radeonfb.c +++ b/drivers/video/radeonfb.c @@ -114,6 +114,7 @@ enum radeon_chips { RADEON_Ie, RADEON_If, RADEON_Ig, + RADEON_Yd, RADEON_Ld, RADEON_Le, RADEON_Lf, @@ -207,6 +208,7 @@ static struct pci_device_id radeonfb_pci_table[] = { { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Ie, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Ie}, { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_If, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_If}, { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Ig, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Ig}, + { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Yd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Yd}, { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Ld, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Ld}, { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Le, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Le}, { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Lf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Lf}, diff --git a/fs/afs/callback.c b/fs/afs/callback.c index 76ac0b9dbf48..2fd62f89ae01 100644 --- a/fs/afs/callback.c +++ b/fs/afs/callback.c @@ -24,28 +24,28 @@ /* * allow the fileserver to request callback state (re-)initialisation */ -int SRXAFSCM_InitCallBackState(afs_server_t *server) +int SRXAFSCM_InitCallBackState(struct afs_server *server) { struct list_head callbacks; - _enter("%p",server); + _enter("%p", server); INIT_LIST_HEAD(&callbacks); /* transfer the callback list from the server to a temp holding area */ spin_lock(&server->cb_lock); - list_add(&callbacks,&server->cb_promises); + list_add(&callbacks, &server->cb_promises); list_del_init(&server->cb_promises); - /* munch our way through the list, grabbing the inode, dropping all the locks and regetting - * them in the right order + /* munch our way through the list, grabbing the inode, dropping all the + * locks and regetting them in the right order */ while (!list_empty(&callbacks)) { + struct afs_vnode *vnode; struct inode *inode; - afs_vnode_t *vnode; - vnode = list_entry(callbacks.next,afs_vnode_t,cb_link); + vnode = list_entry(callbacks.next, struct afs_vnode, cb_link); list_del_init(&vnode->cb_link); /* try and grab the inode - may fail */ @@ -56,7 +56,7 @@ int SRXAFSCM_InitCallBackState(afs_server_t *server) spin_unlock(&server->cb_lock); spin_lock(&vnode->lock); - if (vnode->cb_server==server) { + if (vnode->cb_server == server) { vnode->cb_server = NULL; afs_kafstimod_del_timer(&vnode->cb_timeout); spin_lock(&afs_cb_hash_lock); @@ -84,15 +84,14 @@ int SRXAFSCM_InitCallBackState(afs_server_t *server) /* * allow the fileserver to break callback promises */ -int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbacks[]) +int SRXAFSCM_CallBack(struct afs_server *server, size_t count, + struct afs_callback callbacks[]) { - struct list_head *_p; + _enter("%p,%u,", server, count); - _enter("%p,%u,",server,count); - - for (; count>0; callbacks++, count--) { + for (; count > 0; callbacks++, count--) { + struct afs_vnode *vnode = NULL; struct inode *inode = NULL; - afs_vnode_t *vnode = NULL; int valid = 0; _debug("- Fid { vl=%08x n=%u u=%u } CB { v=%u x=%u t=%u }", @@ -107,14 +106,15 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac /* find the inode for this fid */ spin_lock(&afs_cb_hash_lock); - list_for_each(_p,&afs_cb_hash(server,&callbacks->fid)) { - vnode = list_entry(_p,afs_vnode_t,cb_hash_link); - - if (memcmp(&vnode->fid,&callbacks->fid,sizeof(afs_fid_t))!=0) + list_for_each_entry(vnode, + &afs_cb_hash(server, &callbacks->fid), + cb_hash_link) { + if (memcmp(&vnode->fid, &callbacks->fid, + sizeof(struct afs_fid)) != 0) continue; /* right vnode, but is it same server? */ - if (vnode->cb_server!=server) + if (vnode->cb_server != server) break; /* no */ /* try and nail the inode down */ @@ -127,7 +127,7 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac if (inode) { /* we've found the record for this vnode */ spin_lock(&vnode->lock); - if (vnode->cb_server==server) { + if (vnode->cb_server == server) { /* the callback _is_ on the calling server */ vnode->cb_server = NULL; valid = 1; @@ -161,8 +161,8 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac /* * allow the fileserver to see if the cache manager is still alive */ -int SRXAFSCM_Probe(afs_server_t *server) +int SRXAFSCM_Probe(struct afs_server *server) { - _debug("SRXAFSCM_Probe(%p)\n",server); + _debug("SRXAFSCM_Probe(%p)\n", server); return 0; } /* end SRXAFSCM_Probe() */ diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 43e16714a7e8..e7fd3cce44ee 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -29,20 +29,16 @@ LIST_HEAD(afs_proc_cells); static struct list_head afs_cells = LIST_HEAD_INIT(afs_cells); static rwlock_t afs_cells_lock = RW_LOCK_UNLOCKED; static DECLARE_RWSEM(afs_cells_sem); /* add/remove serialisation */ -static afs_cell_t *afs_cell_root; - -static char *rootcell; - -MODULE_PARM(rootcell,"s"); -MODULE_PARM_DESC(rootcell,"root AFS cell name and VL server IP addr list"); +static struct afs_cell *afs_cell_root; #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_cell_cache_match(void *target, const void *entry); +static cachefs_match_val_t afs_cell_cache_match(void *target, + const void *entry); static void afs_cell_cache_update(void *source, void *entry); struct cachefs_index_def afs_cache_cell_index_def = { .name = "cell_ix", - .data_size = sizeof(afs_cell_t), + .data_size = sizeof(struct afs_cache_cell), .keys[0] = { CACHEFS_INDEX_KEYS_ASCIIZ, 64 }, .match = afs_cell_cache_match, .update = afs_cell_cache_update, @@ -55,27 +51,27 @@ struct cachefs_index_def afs_cache_cell_index_def = { * - "name" is the name of the cell * - "vllist" is a colon separated list of IP addresses in "a.b.c.d" format */ -int afs_cell_create(const char *name, char *vllist, afs_cell_t **_cell) +int afs_cell_create(const char *name, char *vllist, struct afs_cell **_cell) { - afs_cell_t *cell; + struct afs_cell *cell; char *next; int ret; - _enter("%s",name); + _enter("%s", name); - if (!name) BUG(); /* TODO: want to look up "this cell" in the cache */ - - down_write(&afs_cells_sem); + BUG_ON(!name); /* TODO: want to look up "this cell" in the cache */ /* allocate and initialise a cell record */ - cell = kmalloc(sizeof(afs_cell_t) + strlen(name) + 1,GFP_KERNEL); + cell = kmalloc(sizeof(struct afs_cell) + strlen(name) + 1, GFP_KERNEL); if (!cell) { _leave(" = -ENOMEM"); return -ENOMEM; } - memset(cell,0,sizeof(afs_cell_t)); - atomic_set(&cell->usage,0); + down_write(&afs_cells_sem); + + memset(cell, 0, sizeof(struct afs_cell)); + atomic_set(&cell->usage, 0); INIT_LIST_HEAD(&cell->link); @@ -96,26 +92,27 @@ int afs_cell_create(const char *name, char *vllist, afs_cell_t **_cell) do { unsigned a, b, c, d; - next = strchr(vllist,':'); - if (next) *next++ = 0; + next = strchr(vllist, ':'); + if (next) + *next++ = 0; - if (sscanf(vllist,"%u.%u.%u.%u",&a,&b,&c,&d)!=4) + if (sscanf(vllist, "%u.%u.%u.%u", &a, &b, &c, &d) != 4) goto badaddr; - if (a>255 || b>255 || c>255 || d>255) + if (a > 255 || b > 255 || c > 255 || d > 255) goto badaddr; cell->vl_addrs[cell->vl_naddrs++].s_addr = - htonl((a<<24)|(b<<16)|(c<<8)|d); + htonl((a << 24) | (b << 16) | (c << 8) | d); if (cell->vl_naddrs >= AFS_CELL_MAX_ADDRS) break; - } while(vllist=next, vllist); + } while(vllist = next, vllist); /* add a proc dir for this cell */ ret = afs_proc_cell_setup(cell); - if (ret<0) + if (ret < 0) goto error; #ifdef AFS_CACHING_SUPPORT @@ -128,24 +125,25 @@ int afs_cell_create(const char *name, char *vllist, afs_cell_t **_cell) /* add to the cell lists */ write_lock(&afs_cells_lock); - list_add_tail(&cell->link,&afs_cells); + list_add_tail(&cell->link, &afs_cells); write_unlock(&afs_cells_lock); down_write(&afs_proc_cells_sem); - list_add_tail(&cell->proc_link,&afs_proc_cells); + list_add_tail(&cell->proc_link, &afs_proc_cells); up_write(&afs_proc_cells_sem); *_cell = cell; up_write(&afs_cells_sem); - _leave(" = 0 (%p)",cell); + _leave(" = 0 (%p)", cell); return 0; badaddr: - printk("kAFS: bad VL server IP address: '%s'\n",vllist); + printk(KERN_ERR "kAFS: bad VL server IP address: '%s'\n", vllist); error: up_write(&afs_cells_sem); - kfree(afs_cell_root); + kfree(cell); + _leave(" = %d", ret); return ret; } /* end afs_cell_create() */ @@ -153,31 +151,54 @@ int afs_cell_create(const char *name, char *vllist, afs_cell_t **_cell) /* * initialise the cell database from module parameters */ -int afs_cell_init(void) +int afs_cell_init(char *rootcell) { + struct afs_cell *old_root, *new_root; char *cp; int ret; _enter(""); if (!rootcell) { - printk("kAFS: no root cell specified\n"); - return -EINVAL; + /* module is loaded with no parameters, or built statically. + * - in the future we might initialize cell DB here. + */ + _leave(" = 0 (but no root)"); + return 0; } - cp = strchr(rootcell,':'); + cp = strchr(rootcell, ':'); if (!cp) { - printk("kAFS: no VL server IP addresses specified\n"); + printk(KERN_ERR "kAFS: no VL server IP addresses specified\n"); + _leave(" = %d (no colon)", -EINVAL); return -EINVAL; } /* allocate a cell record for the root cell */ *cp++ = 0; - ret = afs_cell_create(rootcell,cp,&afs_cell_root); - if (ret==0) - afs_get_cell(afs_cell_root); + ret = afs_cell_create(rootcell, cp, &new_root); + if (ret < 0) { + _leave(" = %d", ret); + return ret; + } - _leave(" = %d",ret); + /* as afs_put_cell() takes locks by itself, we have to do + * a little gymnastics to be race-free. + */ + afs_get_cell(new_root); + + write_lock(&afs_cells_lock); + while (afs_cell_root) { + old_root = afs_cell_root; + afs_cell_root = NULL; + write_unlock(&afs_cells_lock); + afs_put_cell(old_root); + write_lock(&afs_cells_lock); + } + afs_cell_root = new_root; + write_unlock(&afs_cells_lock); + + _leave(" = %d", ret); return ret; } /* end afs_cell_init() */ @@ -188,8 +209,7 @@ int afs_cell_init(void) */ int afs_cell_lookup(const char *name, unsigned namesz, struct afs_cell **_cell) { - struct list_head *_p; - afs_cell_t *cell; + struct afs_cell *cell; int ret; _enter("\"%*.*s\",", namesz, namesz, name ? name : ""); @@ -202,14 +222,14 @@ int afs_cell_lookup(const char *name, unsigned namesz, struct afs_cell **_cell) cell = NULL; read_lock(&afs_cells_lock); - list_for_each(_p,&afs_cells) { - cell = list_entry(_p, struct afs_cell, link); + list_for_each_entry(cell, &afs_cells, link) { if (strncmp(cell->name, name, namesz) == 0) { afs_get_cell(cell); - break; + goto found; } - cell = NULL; } + cell = NULL; + found: read_unlock(&afs_cells_lock); @@ -217,9 +237,24 @@ int afs_cell_lookup(const char *name, unsigned namesz, struct afs_cell **_cell) ret = 0; } else { + read_lock(&afs_cells_lock); + cell = afs_cell_root; - afs_get_cell(cell); - ret = 0; + if (!cell) { + /* this should not happen unless user tries to mount + * when root cell is not set. Return an impossibly + * bizzare errno to alert the user. Things like + * ENOENT might be "more appropriate" but they happen + * for other reasons. + */ + ret = -EDESTADDRREQ; + } + else { + afs_get_cell(cell); + ret = 0; + } + + read_unlock(&afs_cells_lock); } *_cell = cell; @@ -232,9 +267,9 @@ int afs_cell_lookup(const char *name, unsigned namesz, struct afs_cell **_cell) /* * try and get a cell record */ -afs_cell_t *afs_get_cell_maybe(afs_cell_t **_cell) +struct afs_cell *afs_get_cell_maybe(struct afs_cell **_cell) { - afs_cell_t *cell; + struct afs_cell *cell; write_lock(&afs_cells_lock); @@ -253,18 +288,18 @@ afs_cell_t *afs_get_cell_maybe(afs_cell_t **_cell) /* * destroy a cell record */ -void afs_put_cell(afs_cell_t *cell) +void afs_put_cell(struct afs_cell *cell) { if (!cell) return; - _enter("%p{%d,%s}",cell,atomic_read(&cell->usage),cell->name); + _enter("%p{%d,%s}", cell, atomic_read(&cell->usage), cell->name); /* sanity check */ - if (atomic_read(&cell->usage)<=0) - BUG(); + BUG_ON(atomic_read(&cell->usage) <= 0); - /* to prevent a race, the decrement and the dequeue must be effectively atomic */ + /* to prevent a race, the decrement and the dequeue must be effectively + * atomic */ write_lock(&afs_cells_lock); if (likely(!atomic_dec_and_test(&cell->usage))) { @@ -275,10 +310,10 @@ void afs_put_cell(afs_cell_t *cell) write_unlock(&afs_cells_lock); - if (!list_empty(&cell->sv_list)) BUG(); - if (!list_empty(&cell->sv_graveyard)) BUG(); - if (!list_empty(&cell->vl_list)) BUG(); - if (!list_empty(&cell->vl_graveyard)) BUG(); + BUG_ON(!list_empty(&cell->sv_list)); + BUG_ON(!list_empty(&cell->sv_graveyard)); + BUG_ON(!list_empty(&cell->vl_list)); + BUG_ON(!list_empty(&cell->vl_graveyard)); _leave(" [unused]"); } /* end afs_put_cell() */ @@ -287,16 +322,16 @@ void afs_put_cell(afs_cell_t *cell) /* * destroy a cell record */ -static void afs_cell_destroy(afs_cell_t *cell) +static void afs_cell_destroy(struct afs_cell *cell) { - _enter("%p{%d,%s}",cell,atomic_read(&cell->usage),cell->name); + _enter("%p{%d,%s}", cell, atomic_read(&cell->usage), cell->name); - /* to prevent a race, the decrement and the dequeue must be effectively atomic */ + /* to prevent a race, the decrement and the dequeue must be effectively + * atomic */ write_lock(&afs_cells_lock); /* sanity check */ - if (atomic_read(&cell->usage)!=0) - BUG(); + BUG_ON(atomic_read(&cell->usage) != 0); list_del_init(&cell->link); @@ -311,15 +346,15 @@ static void afs_cell_destroy(afs_cell_t *cell) up_write(&afs_proc_cells_sem); #ifdef AFS_CACHING_SUPPORT - cachefs_relinquish_cookie(cell->cache,0); + cachefs_relinquish_cookie(cell->cache, 0); #endif up_write(&afs_cells_sem); - if (!list_empty(&cell->sv_list)) BUG(); - if (!list_empty(&cell->sv_graveyard)) BUG(); - if (!list_empty(&cell->vl_list)) BUG(); - if (!list_empty(&cell->vl_graveyard)) BUG(); + BUG_ON(!list_empty(&cell->sv_list)); + BUG_ON(!list_empty(&cell->sv_graveyard)); + BUG_ON(!list_empty(&cell->vl_list)); + BUG_ON(!list_empty(&cell->vl_graveyard)); /* finish cleaning up the cell */ kfree(cell); @@ -331,42 +366,40 @@ static void afs_cell_destroy(afs_cell_t *cell) /* * lookup the server record corresponding to an Rx RPC peer */ -int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_server) +int afs_server_find_by_peer(const struct rxrpc_peer *peer, + struct afs_server **_server) { - struct list_head *_pc, *_ps; - afs_server_t *server; - afs_cell_t *cell; + struct afs_server *server; + struct afs_cell *cell; - _enter("%p{a=%08x},",peer,ntohl(peer->addr.s_addr)); + _enter("%p{a=%08x},", peer, ntohl(peer->addr.s_addr)); /* search the cell list */ read_lock(&afs_cells_lock); - list_for_each(_pc,&afs_cells) { - cell = list_entry(_pc,afs_cell_t,link); + list_for_each_entry(cell, &afs_cells, link) { _debug("? cell %s",cell->name); write_lock(&cell->sv_lock); /* check the active list */ - list_for_each(_ps,&cell->sv_list) { - server = list_entry(_ps,afs_server_t,link); - - _debug("?? server %08x",ntohl(server->addr.s_addr)); + list_for_each_entry(server, &cell->sv_list, link) { + _debug("?? server %08x", ntohl(server->addr.s_addr)); - if (memcmp(&server->addr,&peer->addr,sizeof(struct in_addr))==0) + if (memcmp(&server->addr, &peer->addr, + sizeof(struct in_addr)) == 0) goto found_server; } /* check the inactive list */ spin_lock(&cell->sv_gylock); - list_for_each(_ps,&cell->sv_graveyard) { - server = list_entry(_ps,afs_server_t,link); - - _debug("?? dead server %08x",ntohl(server->addr.s_addr)); + list_for_each_entry(server, &cell->sv_graveyard, link) { + _debug("?? dead server %08x", + ntohl(server->addr.s_addr)); - if (memcmp(&server->addr,&peer->addr,sizeof(struct in_addr))==0) + if (memcmp(&server->addr, &peer->addr, + sizeof(struct in_addr)) == 0) goto found_dead_server; } spin_unlock(&cell->sv_gylock); @@ -381,7 +414,7 @@ int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_serve /* we found it in the graveyard - resurrect it */ found_dead_server: list_del(&server->link); - list_add_tail(&server->link,&cell->sv_list); + list_add_tail(&server->link, &cell->sv_list); afs_get_server(server); afs_kafstimod_del_timer(&server->timeout); spin_unlock(&cell->sv_gylock); @@ -396,20 +429,20 @@ int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_serve read_unlock(&afs_cells_lock); *_server = server; - _leave(" = 0 (s=%p c=%p)",server,cell); + _leave(" = 0 (s=%p c=%p)", server, cell); return 0; } /* end afs_server_find_by_peer() */ /*****************************************************************************/ /* - * purge in-memory cell database on module unload + * purge in-memory cell database on module unload or afs_init() failure * - the timeout daemon is stopped before calling this */ void afs_cell_purge(void) { - afs_vlocation_t *vlocation; - afs_cell_t *cell; + struct afs_vlocation *vlocation; + struct afs_cell *cell; _enter(""); @@ -422,17 +455,19 @@ void afs_cell_purge(void) write_lock(&afs_cells_lock); if (!list_empty(&afs_cells)) { - cell = list_entry(afs_cells.next,afs_cell_t,link); + cell = list_entry(afs_cells.next, + struct afs_cell, link); list_del_init(&cell->link); } write_unlock(&afs_cells_lock); if (cell) { - _debug("PURGING CELL %s (%d)",cell->name,atomic_read(&cell->usage)); + _debug("PURGING CELL %s (%d)", + cell->name, atomic_read(&cell->usage)); - if (!list_empty(&cell->sv_list)) BUG(); - if (!list_empty(&cell->vl_list)) BUG(); + BUG_ON(!list_empty(&cell->sv_list)); + BUG_ON(!list_empty(&cell->vl_list)); /* purge the cell's VL graveyard list */ _debug(" - clearing VL graveyard"); @@ -441,7 +476,8 @@ void afs_cell_purge(void) while (!list_empty(&cell->vl_graveyard)) { vlocation = list_entry(cell->vl_graveyard.next, - afs_vlocation_t,link); + struct afs_vlocation, + link); list_del_init(&vlocation->link); afs_kafstimod_del_timer(&vlocation->timeout); @@ -449,7 +485,8 @@ void afs_cell_purge(void) spin_unlock(&cell->vl_gylock); afs_vlocation_do_timeout(vlocation); - /* TODO: race if move to use krxtimod instead of kafstimod */ + /* TODO: race if move to use krxtimod instead + * of kafstimod */ spin_lock(&cell->vl_gylock); } @@ -462,9 +499,10 @@ void afs_cell_purge(void) spin_lock(&cell->sv_gylock); while (!list_empty(&cell->sv_graveyard)) { - afs_server_t *server; + struct afs_server *server; - server = list_entry(cell->sv_graveyard.next,afs_server_t,link); + server = list_entry(cell->sv_graveyard.next, + struct afs_server, link); list_del_init(&server->link); afs_kafstimod_del_timer(&server->timeout); @@ -491,7 +529,8 @@ void afs_cell_purge(void) * match a cell record obtained from the cache */ #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_cell_cache_match(void *target, const void *entry) +static cachefs_match_val_t afs_cell_cache_match(void *target, + const void *entry) { const struct afs_cache_cell *ccell = entry; struct afs_cell *cell = target; diff --git a/fs/afs/cell.h b/fs/afs/cell.h index 7784a48bd694..48349108fb00 100644 --- a/fs/afs/cell.h +++ b/fs/afs/cell.h @@ -61,7 +61,7 @@ struct afs_cell char name[0]; /* cell name - must go last */ }; -extern int afs_cell_init(void); +extern int afs_cell_init(char *rootcell); extern int afs_cell_create(const char *name, char *vllist, struct afs_cell **_cell); diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c index 809402a8c725..289489da3ca2 100644 --- a/fs/afs/cmservice.c +++ b/fs/afs/cmservice.c @@ -94,7 +94,7 @@ static struct rxrpc_service AFSCM_service = { .error_func = afscm_error, .aemap_func = afscm_aemap, .ops_begin = &AFSCM_ops[0], - .ops_end = &AFSCM_ops[sizeof(AFSCM_ops)/sizeof(AFSCM_ops[0])], + .ops_end = &AFSCM_ops[sizeof(AFSCM_ops) / sizeof(AFSCM_ops[0])], }; static DECLARE_COMPLETION(kafscmd_alive); @@ -112,13 +112,13 @@ static int kafscmd_die; */ static int kafscmd(void *arg) { - DECLARE_WAITQUEUE(myself,current); + DECLARE_WAITQUEUE(myself, current); struct rxrpc_call *call; _SRXAFSCM_xxxx_t func; int die; - printk("kAFS: Started kafscmd %d\n",current->pid); + printk("kAFS: Started kafscmd %d\n", current->pid); daemonize("kafscmd"); @@ -128,7 +128,7 @@ static int kafscmd(void *arg) do { if (list_empty(&kafscmd_attention_list)) { set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&kafscmd_sleepq,&myself); + add_wait_queue(&kafscmd_sleepq, &myself); for (;;) { set_current_state(TASK_INTERRUPTIBLE); @@ -140,7 +140,7 @@ static int kafscmd(void *arg) schedule(); } - remove_wait_queue(&kafscmd_sleepq,&myself); + remove_wait_queue(&kafscmd_sleepq, &myself); set_current_state(TASK_RUNNING); } @@ -162,7 +162,7 @@ static int kafscmd(void *arg) if (call) { /* act upon it */ - _debug("@@@ Begin Attend Call %p",call); + _debug("@@@ Begin Attend Call %p", call); func = call->app_user; if (func) @@ -170,13 +170,13 @@ static int kafscmd(void *arg) rxrpc_put_call(call); - _debug("@@@ End Attend Call %p",call); + _debug("@@@ End Attend Call %p", call); } } while(!die); /* and that's all */ - complete_and_exit(&kafscmd_dead,0); + complete_and_exit(&kafscmd_dead, 0); } /* end kafscmd() */ @@ -184,12 +184,14 @@ static int kafscmd(void *arg) /* * handle a call coming in to the cache manager * - if I want to keep the call, I must increment its usage count - * - the return value will be negated and passed back in an abort packet if non-zero + * - the return value will be negated and passed back in an abort packet if + * non-zero * - serialised by virtue of there only being one krxiod */ static int afscm_new_call(struct rxrpc_call *call) { - _enter("%p{cid=%u u=%d}",call,ntohl(call->call_id),atomic_read(&call->usage)); + _enter("%p{cid=%u u=%d}", + call, ntohl(call->call_id), atomic_read(&call->usage)); rxrpc_get_call(call); @@ -209,12 +211,13 @@ static int afscm_new_call(struct rxrpc_call *call) */ static void afscm_attention(struct rxrpc_call *call) { - _enter("%p{cid=%u u=%d}",call,ntohl(call->call_id),atomic_read(&call->usage)); + _enter("%p{cid=%u u=%d}", + call, ntohl(call->call_id), atomic_read(&call->usage)); spin_lock(&kafscmd_attention_lock); if (list_empty(&call->app_attn_link)) { - list_add_tail(&call->app_attn_link,&kafscmd_attention_list); + list_add_tail(&call->app_attn_link, &kafscmd_attention_list); rxrpc_get_call(call); } @@ -222,7 +225,7 @@ static void afscm_attention(struct rxrpc_call *call) wake_up(&kafscmd_sleepq); - _leave(" {u=%d}",atomic_read(&call->usage)); + _leave(" {u=%d}", atomic_read(&call->usage)); } /* end afscm_attention() */ /*****************************************************************************/ @@ -243,7 +246,7 @@ static void afscm_error(struct rxrpc_call *call) spin_lock(&kafscmd_attention_lock); if (list_empty(&call->app_attn_link)) { - list_add_tail(&call->app_attn_link,&kafscmd_attention_list); + list_add_tail(&call->app_attn_link, &kafscmd_attention_list); rxrpc_get_call(call); } @@ -301,7 +304,7 @@ int afscm_start(void) wait_for_completion(&kafscmd_alive); ret = rxrpc_add_service(afs_transport, &AFSCM_service); - if (ret<0) + if (ret < 0) goto kill; #ifdef AFS_AUTOMOUNT_SUPPORT @@ -336,14 +339,15 @@ void afscm_stop(void) down_write(&afscm_sem); - if (afscm_usage == 0) BUG(); + BUG_ON(afscm_usage == 0); afscm_usage--; if (afscm_usage == 0) { /* don't want more incoming calls */ rxrpc_del_service(afs_transport, &AFSCM_service); - /* abort any calls I've still got open (the afscm_error() will dequeue them) */ + /* abort any calls I've still got open (the afscm_error() will + * dequeue them) */ spin_lock(&afscm_calls_lock); while (!list_empty(&afscm_calls)) { call = list_entry(afscm_calls.next, @@ -354,7 +358,8 @@ void afscm_stop(void) rxrpc_get_call(call); spin_unlock(&afscm_calls_lock); - rxrpc_call_abort(call,-ESRCH); /* abort, dequeue and put */ + rxrpc_call_abort(call, -ESRCH); /* abort, dequeue and + * put */ _debug("nuking active call %08x.%d", ntohl(call->conn->conn_id), @@ -402,11 +407,11 @@ void afscm_stop(void) */ static void _SRXAFSCM_CallBack(struct rxrpc_call *call) { - afs_server_t *server; + struct afs_server *server; size_t count, qty, tmp; int ret = 0, removed; - _enter("%p{acs=%s}",call,rxrpc_call_states[call->app_call_state]); + _enter("%p{acs=%s}", call, rxrpc_call_states[call->app_call_state]); server = afs_server_get_from_peer(call->conn->peer); @@ -417,38 +422,41 @@ static void _SRXAFSCM_CallBack(struct rxrpc_call *call) case RXRPC_CSTATE_SRVR_GOT_ARGS: ret = -EBADMSG; qty = call->app_ready_qty; - if (qty<8 || qty>50*(6*4)+8) + if (qty < 8 || qty > 50 * (6 * 4) + 8) break; { - afs_callback_t *cb, *pcb; + struct afs_callback *cb, *pcb; int loop; u32 *fp, *bp; - fp = rxrpc_call_alloc_scratch(call,qty); + fp = rxrpc_call_alloc_scratch(call, qty); - /* drag the entire argument block out to the scratch space */ - ret = rxrpc_call_read_data(call,fp,qty,0); - if (ret<0) + /* drag the entire argument block out to the scratch + * space */ + ret = rxrpc_call_read_data(call, fp, qty, 0); + if (ret < 0) break; /* and unmarshall the parameter block */ ret = -EBADMSG; count = ntohl(*fp++); if (count>AFSCBMAX || - (count*(3*4)+8 != qty && count*(6*4)+8 != qty)) + (count * (3 * 4) + 8 != qty && + count * (6 * 4) + 8 != qty)) break; bp = fp + count*3; tmp = ntohl(*bp++); - if (tmp>0 && tmp!=count) + if (tmp > 0 && tmp != count) break; - if (tmp==0) + if (tmp == 0) bp = NULL; - pcb = cb = rxrpc_call_alloc_scratch_s(call,afs_callback_t); + pcb = cb = rxrpc_call_alloc_scratch_s( + call, struct afs_callback); - for (loop=count-1; loop>=0; loop--) { + for (loop = count - 1; loop >= 0; loop--) { pcb->fid.vid = ntohl(*fp++); pcb->fid.vnode = ntohl(*fp++); pcb->fid.unique = ntohl(*fp++); @@ -466,14 +474,15 @@ static void _SRXAFSCM_CallBack(struct rxrpc_call *call) } /* invoke the actual service routine */ - ret = SRXAFSCM_CallBack(server,count,cb); - if (ret<0) + ret = SRXAFSCM_CallBack(server, count, cb); + if (ret < 0) break; } /* send the reply */ - ret = rxrpc_call_write_data(call,0,NULL,RXRPC_LAST_PACKET,GFP_KERNEL,0,&count); - if (ret<0) + ret = rxrpc_call_write_data(call, 0, NULL, RXRPC_LAST_PACKET, + GFP_KERNEL, 0, &count); + if (ret < 0) break; break; @@ -501,12 +510,12 @@ static void _SRXAFSCM_CallBack(struct rxrpc_call *call) break; } - if (ret<0) - rxrpc_call_abort(call,ret); + if (ret < 0) + rxrpc_call_abort(call, ret); afs_put_server(server); - _leave(" = %d",ret); + _leave(" = %d", ret); } /* end _SRXAFSCM_CallBack() */ @@ -516,16 +525,17 @@ static void _SRXAFSCM_CallBack(struct rxrpc_call *call) */ static void _SRXAFSCM_InitCallBackState(struct rxrpc_call *call) { - afs_server_t *server; + struct afs_server *server; size_t count; int ret = 0, removed; - _enter("%p{acs=%s}",call,rxrpc_call_states[call->app_call_state]); + _enter("%p{acs=%s}", call, rxrpc_call_states[call->app_call_state]); server = afs_server_get_from_peer(call->conn->peer); switch (call->app_call_state) { - /* we've received the last packet - drain all the data from the call */ + /* we've received the last packet - drain all the data from the + * call */ case RXRPC_CSTATE_SRVR_GOT_ARGS: /* shouldn't be any args */ ret = -EBADMSG; @@ -535,11 +545,12 @@ static void _SRXAFSCM_InitCallBackState(struct rxrpc_call *call) case RXRPC_CSTATE_SRVR_SND_REPLY: /* invoke the actual service routine */ ret = SRXAFSCM_InitCallBackState(server); - if (ret<0) + if (ret < 0) break; - ret = rxrpc_call_write_data(call,0,NULL,RXRPC_LAST_PACKET,GFP_KERNEL,0,&count); - if (ret<0) + ret = rxrpc_call_write_data(call, 0, NULL, RXRPC_LAST_PACKET, + GFP_KERNEL, 0, &count); + if (ret < 0) break; break; @@ -567,12 +578,12 @@ static void _SRXAFSCM_InitCallBackState(struct rxrpc_call *call) break; } - if (ret<0) - rxrpc_call_abort(call,ret); + if (ret < 0) + rxrpc_call_abort(call, ret); afs_put_server(server); - _leave(" = %d",ret); + _leave(" = %d", ret); } /* end _SRXAFSCM_InitCallBackState() */ @@ -582,16 +593,17 @@ static void _SRXAFSCM_InitCallBackState(struct rxrpc_call *call) */ static void _SRXAFSCM_Probe(struct rxrpc_call *call) { - afs_server_t *server; + struct afs_server *server; size_t count; int ret = 0, removed; - _enter("%p{acs=%s}",call,rxrpc_call_states[call->app_call_state]); + _enter("%p{acs=%s}", call, rxrpc_call_states[call->app_call_state]); server = afs_server_get_from_peer(call->conn->peer); switch (call->app_call_state) { - /* we've received the last packet - drain all the data from the call */ + /* we've received the last packet - drain all the data from the + * call */ case RXRPC_CSTATE_SRVR_GOT_ARGS: /* shouldn't be any args */ ret = -EBADMSG; @@ -601,11 +613,12 @@ static void _SRXAFSCM_Probe(struct rxrpc_call *call) case RXRPC_CSTATE_SRVR_SND_REPLY: /* invoke the actual service routine */ ret = SRXAFSCM_Probe(server); - if (ret<0) + if (ret < 0) break; - ret = rxrpc_call_write_data(call,0,NULL,RXRPC_LAST_PACKET,GFP_KERNEL,0,&count); - if (ret<0) + ret = rxrpc_call_write_data(call, 0, NULL, RXRPC_LAST_PACKET, + GFP_KERNEL, 0, &count); + if (ret < 0) break; break; @@ -633,11 +646,11 @@ static void _SRXAFSCM_Probe(struct rxrpc_call *call) break; } - if (ret<0) - rxrpc_call_abort(call,ret); + if (ret < 0) + rxrpc_call_abort(call, ret); afs_put_server(server); - _leave(" = %d",ret); + _leave(" = %d", ret); } /* end _SRXAFSCM_Probe() */ diff --git a/fs/afs/cmservice.h b/fs/afs/cmservice.h index 89fb14e7615b..af8d4d689cb2 100644 --- a/fs/afs/cmservice.h +++ b/fs/afs/cmservice.h @@ -20,8 +20,10 @@ extern int afscm_start(void); extern void afscm_stop(void); /* cache manager server functions */ -extern int SRXAFSCM_InitCallBackState(afs_server_t *server); -extern int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbacks[]); -extern int SRXAFSCM_Probe(afs_server_t *server); +extern int SRXAFSCM_InitCallBackState(struct afs_server *server); +extern int SRXAFSCM_CallBack(struct afs_server *server, + size_t count, + struct afs_callback callbacks[]); +extern int SRXAFSCM_Probe(struct afs_server *server); #endif /* _LINUX_AFS_CMSERVICE_H */ diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 9d6a7104cc79..d19e7c5d28f2 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -29,8 +29,8 @@ static int afs_dir_open(struct inode *inode, struct file *file); static int afs_dir_readdir(struct file *file, void *dirent, filldir_t filldir); static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd); static int afs_d_delete(struct dentry *dentry); -static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos, - ino_t ino, unsigned dtype); +static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen, + loff_t fpos, ino_t ino, unsigned dtype); struct file_operations afs_dir_file_operations = { .open = afs_dir_open, @@ -61,51 +61,53 @@ static struct dentry_operations afs_fs_dentry_operations = { #define AFS_DIR_DIRENT_SIZE 32 #define AFS_DIRENT_PER_BLOCK 64 -typedef union afs_dirent { +union afs_dirent { struct { - u8 valid; - u8 unused[1]; - u16 hash_next; - u32 vnode; - u32 unique; - u8 name[16]; - u8 overflow[4]; /* if any char of the name (inc NUL) reaches here, consume - * the next dirent too */ + uint8_t valid; + uint8_t unused[1]; + uint16_t hash_next; + uint32_t vnode; + uint32_t unique; + uint8_t name[16]; + uint8_t overflow[4]; /* if any char of the name (inc + * NUL) reaches here, consume + * the next dirent too */ } u; - u8 extended_name[32]; -} afs_dirent_t; + uint8_t extended_name[32]; +}; /* AFS directory page header (one at the beginning of every 2048-byte chunk) */ -typedef struct afs_dir_pagehdr { - u16 npages; - u16 magic; +struct afs_dir_pagehdr { + uint16_t npages; + uint16_t magic; #define AFS_DIR_MAGIC htons(1234) - u8 nentries; - u8 bitmap[8]; - u8 pad[19]; -} afs_dir_pagehdr_t; + uint8_t nentries; + uint8_t bitmap[8]; + uint8_t pad[19]; +}; /* directory block layout */ -typedef union afs_dir_block { +union afs_dir_block { - afs_dir_pagehdr_t pagehdr; + struct afs_dir_pagehdr pagehdr; struct { - afs_dir_pagehdr_t pagehdr; - u8 alloc_ctrs[128]; - u16 hashtable[AFS_DIR_HASHTBL_SIZE]; /* dir hash table */ + struct afs_dir_pagehdr pagehdr; + uint8_t alloc_ctrs[128]; + /* dir hash table */ + uint16_t hashtable[AFS_DIR_HASHTBL_SIZE]; } hdr; - afs_dirent_t dirents[AFS_DIRENT_PER_BLOCK]; -} afs_dir_block_t; + union afs_dirent dirents[AFS_DIRENT_PER_BLOCK]; +}; /* layout on a linux VM page */ -typedef struct afs_dir_page { - afs_dir_block_t blocks[PAGE_SIZE/sizeof(afs_dir_block_t)]; -} afs_dir_page_t; +struct afs_dir_page { + union afs_dir_block blocks[PAGE_SIZE / sizeof(union afs_dir_block)]; +}; struct afs_dir_lookup_cookie { - afs_fid_t fid; + struct afs_fid fid; const char *name; size_t nlen; int found; @@ -117,14 +119,14 @@ struct afs_dir_lookup_cookie { */ static inline void afs_dir_check_page(struct inode *dir, struct page *page) { - afs_dir_page_t *dbuf; + struct afs_dir_page *dbuf; loff_t latter; int tmp, qty; #if 0 /* check the page count */ - qty = desc.size/sizeof(dbuf->blocks[0]); - if (qty==0) + qty = desc.size / sizeof(dbuf->blocks[0]); + if (qty == 0) goto error; if (page->index==0 && qty!=ntohs(dbuf->blocks[0].pagehdr.npages)) { @@ -140,15 +142,15 @@ static inline void afs_dir_check_page(struct inode *dir, struct page *page) qty = PAGE_SIZE; else qty = latter; - qty /= sizeof(afs_dir_block_t); + qty /= sizeof(union afs_dir_block); /* check them */ dbuf = page_address(page); - for (tmp=0; tmp<qty; tmp++) { + for (tmp = 0; tmp < qty; tmp++) { if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) { printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n", - __FUNCTION__,dir->i_ino,tmp, - qty,ntohs(dbuf->blocks[tmp].pagehdr.magic)); + __FUNCTION__, dir->i_ino, tmp, qty, + ntohs(dbuf->blocks[tmp].pagehdr.magic)); goto error; } } @@ -181,17 +183,18 @@ static struct page *afs_dir_get_page(struct inode *dir, unsigned long index) { struct page *page; - _enter("{%lu},%lu",dir->i_ino,index); + _enter("{%lu},%lu", dir->i_ino, index); page = read_cache_page(dir->i_mapping,index, - (filler_t*)dir->i_mapping->a_ops->readpage,NULL); + (filler_t *) dir->i_mapping->a_ops->readpage, + NULL); if (!IS_ERR(page)) { wait_on_page_locked(page); kmap(page); if (!PageUptodate(page)) goto fail; if (!PageChecked(page)) - afs_dir_check_page(dir,page); + afs_dir_check_page(dir, page); if (PageError(page)) goto fail; } @@ -208,10 +211,10 @@ static struct page *afs_dir_get_page(struct inode *dir, unsigned long index) */ static int afs_dir_open(struct inode *inode, struct file *file) { - _enter("{%lu}",inode->i_ino); + _enter("{%lu}", inode->i_ino); - if (sizeof(afs_dir_block_t) != 2048) BUG(); - if (sizeof(afs_dirent_t) != 32) BUG(); + BUG_ON(sizeof(union afs_dir_block) != 2048); + BUG_ON(sizeof(union afs_dirent) != 32); if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED) return -ENOENT; @@ -226,19 +229,19 @@ static int afs_dir_open(struct inode *inode, struct file *file) * deal with one block in an AFS directory */ static int afs_dir_iterate_block(unsigned *fpos, - afs_dir_block_t *block, - unsigned blkoff, - void *cookie, - filldir_t filldir) + union afs_dir_block *block, + unsigned blkoff, + void *cookie, + filldir_t filldir) { - afs_dirent_t *dire; + union afs_dirent *dire; unsigned offset, next, curr; size_t nlen; int tmp, ret; _enter("%u,%x,%p,,",*fpos,blkoff,block); - curr = (*fpos - blkoff) / sizeof(afs_dirent_t); + curr = (*fpos - blkoff) / sizeof(union afs_dirent); /* walk through the block, an entry at a time */ for (offset = AFS_DIRENT_PER_BLOCK - block->pagehdr.nentries; @@ -248,58 +251,70 @@ static int afs_dir_iterate_block(unsigned *fpos, next = offset + 1; /* skip entries marked unused in the bitmap */ - if (!(block->pagehdr.bitmap[offset/8] & (1 << (offset % 8)))) { - _debug("ENT[%Zu.%u]: unused\n",blkoff/sizeof(afs_dir_block_t),offset); - if (offset>=curr) - *fpos = blkoff + next * sizeof(afs_dirent_t); + if (!(block->pagehdr.bitmap[offset / 8] & + (1 << (offset % 8)))) { + _debug("ENT[%Zu.%u]: unused\n", + blkoff / sizeof(union afs_dir_block), offset); + if (offset >= curr) + *fpos = blkoff + + next * sizeof(union afs_dirent); continue; } /* got a valid entry */ dire = &block->dirents[offset]; - nlen = strnlen(dire->u.name,sizeof(*block) - offset*sizeof(afs_dirent_t)); + nlen = strnlen(dire->u.name, + sizeof(*block) - + offset * sizeof(union afs_dirent)); _debug("ENT[%Zu.%u]: %s %Zu \"%s\"\n", - blkoff/sizeof(afs_dir_block_t),offset, - (offset<curr ? "skip" : "fill"), - nlen,dire->u.name); + blkoff / sizeof(union afs_dir_block), offset, + (offset < curr ? "skip" : "fill"), + nlen, dire->u.name); /* work out where the next possible entry is */ - for (tmp=nlen; tmp>15; tmp-=sizeof(afs_dirent_t)) { - if (next>=AFS_DIRENT_PER_BLOCK) { + for (tmp = nlen; tmp > 15; tmp -= sizeof(union afs_dirent)) { + if (next >= AFS_DIRENT_PER_BLOCK) { _debug("ENT[%Zu.%u]:" - " %u travelled beyond end dir block (len %u/%Zu)\n", - blkoff/sizeof(afs_dir_block_t),offset,next,tmp,nlen); + " %u travelled beyond end dir block" + " (len %u/%Zu)\n", + blkoff / sizeof(union afs_dir_block), + offset, next, tmp, nlen); return -EIO; } - if (!(block->pagehdr.bitmap[next/8] & (1 << (next % 8)))) { - _debug("ENT[%Zu.%u]: %u unmarked extension (len %u/%Zu)\n", - blkoff/sizeof(afs_dir_block_t),offset,next,tmp,nlen); + if (!(block->pagehdr.bitmap[next / 8] & + (1 << (next % 8)))) { + _debug("ENT[%Zu.%u]:" + " %u unmarked extension (len %u/%Zu)\n", + blkoff / sizeof(union afs_dir_block), + offset, next, tmp, nlen); return -EIO; } _debug("ENT[%Zu.%u]: ext %u/%Zu\n", - blkoff/sizeof(afs_dir_block_t),next,tmp,nlen); + blkoff / sizeof(union afs_dir_block), + next, tmp, nlen); next++; } /* skip if starts before the current position */ - if (offset<curr) + if (offset < curr) continue; /* found the next entry */ ret = filldir(cookie, dire->u.name, nlen, - blkoff + offset * sizeof(afs_dirent_t), + blkoff + offset * sizeof(union afs_dirent), ntohl(dire->u.vnode), - filldir==afs_dir_lookup_filldir ? dire->u.unique : DT_UNKNOWN); - if (ret<0) { + filldir == afs_dir_lookup_filldir ? + dire->u.unique : DT_UNKNOWN); + if (ret < 0) { _leave(" = 0 [full]"); return 0; } - *fpos = blkoff + next * sizeof(afs_dirent_t); + *fpos = blkoff + next * sizeof(union afs_dirent); } _leave(" = 1 [more]"); @@ -310,15 +325,16 @@ static int afs_dir_iterate_block(unsigned *fpos, /* * read an AFS directory */ -static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie, filldir_t filldir) +static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie, + filldir_t filldir) { - afs_dir_block_t *dblock; - afs_dir_page_t *dbuf; + union afs_dir_block *dblock; + struct afs_dir_page *dbuf; struct page *page; unsigned blkoff, limit; int ret; - _enter("{%lu},%u,,",dir->i_ino,*fpos); + _enter("{%lu},%u,,", dir->i_ino, *fpos); if (AFS_FS_I(dir)->flags & AFS_VNODE_DELETED) { _leave(" = -ESTALE"); @@ -326,35 +342,37 @@ static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie, fill } /* round the file position up to the next entry boundary */ - *fpos += sizeof(afs_dirent_t) - 1; - *fpos &= ~(sizeof(afs_dirent_t) - 1); + *fpos += sizeof(union afs_dirent) - 1; + *fpos &= ~(sizeof(union afs_dirent) - 1); /* walk through the blocks in sequence */ ret = 0; while (*fpos < dir->i_size) { - blkoff = *fpos & ~(sizeof(afs_dir_block_t) - 1); + blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1); /* fetch the appropriate page from the directory */ - page = afs_dir_get_page(dir,blkoff/PAGE_SIZE); + page = afs_dir_get_page(dir, blkoff / PAGE_SIZE); if (IS_ERR(page)) { ret = PTR_ERR(page); break; } - limit = blkoff & ~(PAGE_SIZE-1); + limit = blkoff & ~(PAGE_SIZE - 1); dbuf = page_address(page); /* deal with the individual blocks stashed on this page */ do { - dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) / sizeof(afs_dir_block_t)]; - ret = afs_dir_iterate_block(fpos,dblock,blkoff,cookie,filldir); - if (ret!=1) { + dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) / + sizeof(union afs_dir_block)]; + ret = afs_dir_iterate_block(fpos, dblock, blkoff, + cookie, filldir); + if (ret != 1) { afs_dir_put_page(page); goto out; } - blkoff += sizeof(afs_dir_block_t); + blkoff += sizeof(union afs_dir_block); } while (*fpos < dir->i_size && blkoff < limit); @@ -363,7 +381,7 @@ static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie, fill } out: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_dir_iterate() */ @@ -376,29 +394,31 @@ static int afs_dir_readdir(struct file *file, void *cookie, filldir_t filldir) unsigned fpos; int ret; - _enter("{%Ld,{%lu}}",file->f_pos,file->f_dentry->d_inode->i_ino); + _enter("{%Ld,{%lu}}", file->f_pos, file->f_dentry->d_inode->i_ino); fpos = file->f_pos; - ret = afs_dir_iterate(file->f_dentry->d_inode,&fpos,cookie,filldir); + ret = afs_dir_iterate(file->f_dentry->d_inode, &fpos, cookie, filldir); file->f_pos = fpos; - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_dir_readdir() */ /*****************************************************************************/ /* * search the directory for a name - * - if afs_dir_iterate_block() spots this function, it'll pass the FID uniquifier through dtype + * - if afs_dir_iterate_block() spots this function, it'll pass the FID + * uniquifier through dtype */ -static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos, - ino_t ino, unsigned dtype) +static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen, + loff_t fpos, ino_t ino, unsigned dtype) { struct afs_dir_lookup_cookie *cookie = _cookie; - _enter("{%s,%Zu},%s,%u,,%lu,%u",cookie->name,cookie->nlen,name,nlen,ino,ntohl(dtype)); + _enter("{%s,%Zu},%s,%u,,%lu,%u", + cookie->name, cookie->nlen, name, nlen, ino, ntohl(dtype)); - if (cookie->nlen != nlen || memcmp(cookie->name,name,nlen)!=0) { + if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) { _leave(" = 0 [no]"); return 0; } @@ -420,16 +440,16 @@ static struct dentry *afs_dir_lookup(struct inode *dir, struct dentry *dentry, { struct afs_dir_lookup_cookie cookie; struct afs_super_info *as; + struct afs_vnode *vnode; struct inode *inode; - afs_vnode_t *vnode; unsigned fpos; int ret; - _enter("{%lu},%p{%s}",dir->i_ino,dentry,dentry->d_name.name); + _enter("{%lu},%p{%s}", dir->i_ino, dentry, dentry->d_name.name); /* insanity checks first */ - BUG_ON(sizeof(afs_dir_block_t) != 2048); - BUG_ON(sizeof(afs_dirent_t) != 32); + BUG_ON(sizeof(union afs_dir_block) != 2048); + BUG_ON(sizeof(union afs_dirent) != 32); if (dentry->d_name.len > 255) { _leave(" = -ENAMETOOLONG"); @@ -451,29 +471,29 @@ static struct dentry *afs_dir_lookup(struct inode *dir, struct dentry *dentry, cookie.found = 0; fpos = 0; - ret = afs_dir_iterate(dir,&fpos,&cookie,afs_dir_lookup_filldir); - if (ret<0) { - _leave(" = %d",ret); + ret = afs_dir_iterate(dir, &fpos, &cookie, afs_dir_lookup_filldir); + if (ret < 0) { + _leave(" = %d", ret); return ERR_PTR(ret); } ret = -ENOENT; if (!cookie.found) { - _leave(" = %d",ret); + _leave(" = %d", ret); return ERR_PTR(ret); } /* instantiate the dentry */ - ret = afs_iget(dir->i_sb,&cookie.fid,&inode); - if (ret<0) { - _leave(" = %d",ret); + ret = afs_iget(dir->i_sb, &cookie.fid, &inode); + if (ret < 0) { + _leave(" = %d", ret); return ERR_PTR(ret); } dentry->d_op = &afs_fs_dentry_operations; - dentry->d_fsdata = (void*) (unsigned long) vnode->status.version; + dentry->d_fsdata = (void *) (unsigned long) vnode->status.version; - d_add(dentry,inode); + d_add(dentry, inode); _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }", cookie.fid.vnode, cookie.fid.unique, @@ -486,7 +506,8 @@ static struct dentry *afs_dir_lookup(struct inode *dir, struct dentry *dentry, /*****************************************************************************/ /* * check that a dentry lookup hit has found a valid entry - * - NOTE! the hit can be a negative hit too, so we can't assume we have an inode + * - NOTE! the hit can be a negative hit too, so we can't assume we have an + * inode * (derived from nfs_lookup_revalidate) */ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) @@ -497,7 +518,7 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) unsigned fpos; int ret; - _enter("{sb=%p n=%s},",dentry->d_sb,dentry->d_name.name); + _enter("{sb=%p n=%s},", dentry->d_sb, dentry->d_name.name); /* lock down the parent dentry so we can peer at it */ parent = dget_parent(dentry->d_parent); @@ -505,39 +526,41 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) dir = parent->d_inode; inode = dentry->d_inode; - /* handle a negative inode */ + /* handle a negative dentry */ if (!inode) goto out_bad; /* handle a bad inode */ if (is_bad_inode(inode)) { printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n", - dentry->d_parent->d_name.name,dentry->d_name.name); + dentry->d_parent->d_name.name, dentry->d_name.name); goto out_bad; } - /* force a full look up if the parent directory changed since last the server was consulted - * - otherwise this inode must still exist, even if the inode details themselves have - * changed + /* force a full look up if the parent directory changed since last the + * server was consulted + * - otherwise this inode must still exist, even if the inode details + * themselves have changed */ if (AFS_FS_I(dir)->flags & AFS_VNODE_CHANGED) afs_vnode_fetch_status(AFS_FS_I(dir)); if (AFS_FS_I(dir)->flags & AFS_VNODE_DELETED) { - _debug("%s: parent dir deleted",dentry->d_name.name); + _debug("%s: parent dir deleted", dentry->d_name.name); goto out_bad; } if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED) { - _debug("%s: file already deleted",dentry->d_name.name); + _debug("%s: file already deleted", dentry->d_name.name); goto out_bad; } - if ((unsigned long)dentry->d_fsdata != (unsigned long)AFS_FS_I(dir)->status.version) { + if ((unsigned long) dentry->d_fsdata != + (unsigned long) AFS_FS_I(dir)->status.version) { _debug("%s: parent changed %lu -> %u", dentry->d_name.name, - (unsigned long)dentry->d_fsdata, - (unsigned)AFS_FS_I(dir)->status.version); + (unsigned long) dentry->d_fsdata, + (unsigned) AFS_FS_I(dir)->status.version); /* search the directory for this vnode */ cookie.name = dentry->d_name.name; @@ -546,25 +569,29 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) cookie.found = 0; fpos = 0; - ret = afs_dir_iterate(dir,&fpos,&cookie,afs_dir_lookup_filldir); - if (ret<0) { - _debug("failed to iterate dir %s: %d",parent->d_name.name,ret); + ret = afs_dir_iterate(dir, &fpos, &cookie, + afs_dir_lookup_filldir); + if (ret < 0) { + _debug("failed to iterate dir %s: %d", + parent->d_name.name, ret); goto out_bad; } if (!cookie.found) { - _debug("%s: dirent not found",dentry->d_name.name); + _debug("%s: dirent not found", dentry->d_name.name); goto not_found; } - /* if the vnode ID has changed, then the dirent points to a different file */ - if (cookie.fid.vnode!=AFS_FS_I(inode)->fid.vnode) { - _debug("%s: dirent changed",dentry->d_name.name); + /* if the vnode ID has changed, then the dirent points to a + * different file */ + if (cookie.fid.vnode != AFS_FS_I(inode)->fid.vnode) { + _debug("%s: dirent changed", dentry->d_name.name); goto not_found; } - /* if the vnode ID uniqifier has changed, then the file has been deleted */ - if (cookie.fid.unique!=AFS_FS_I(inode)->fid.unique) { + /* if the vnode ID uniqifier has changed, then the file has + * been deleted */ + if (cookie.fid.unique != AFS_FS_I(inode)->fid.unique) { _debug("%s: file deleted (uq %u -> %u I:%lu)", dentry->d_name.name, cookie.fid.unique, @@ -577,7 +604,8 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) goto out_bad; } - dentry->d_fsdata = (void*) (unsigned long) AFS_FS_I(dir)->status.version; + dentry->d_fsdata = + (void *) (unsigned long) AFS_FS_I(dir)->status.version; } out_valid: @@ -598,7 +626,8 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) shrink_dcache_parent(dentry); - _debug("dropping dentry %s/%s",dentry->d_parent->d_name.name,dentry->d_name.name); + _debug("dropping dentry %s/%s", + dentry->d_parent->d_name.name, dentry->d_name.name); d_drop(dentry); dput(parent); @@ -609,13 +638,14 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) /*****************************************************************************/ /* - * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't sleep) + * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't + * sleep) * - called from dput() when d_count is going to 0. * - return 1 to request dentry be unhashed, 0 otherwise */ static int afs_d_delete(struct dentry *dentry) { - _enter("%s",dentry->d_name.name); + _enter("%s", dentry->d_name.name); if (dentry->d_flags & DCACHE_NFSFS_RENAMED) goto zap; diff --git a/fs/afs/file.c b/fs/afs/file.c index eeb9ff893635..928e3b1d679d 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -31,7 +31,8 @@ static int afs_file_readpage(struct file *file, struct page *page); static int afs_file_invalidatepage(struct page *page, unsigned long offset); static int afs_file_releasepage(struct page *page, int gfp_flags); -static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off); +static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, + loff_t *off); struct inode_operations afs_file_inode_operations = { .getattr = afs_inode_getattr, @@ -60,9 +61,10 @@ struct address_space_operations afs_fs_aops = { /* * AFS file write */ -static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off) +static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, + loff_t *off) { - afs_vnode_t *vnode; + struct afs_vnode *vnode; vnode = AFS_FS_I(file->f_dentry->d_inode); if (vnode->flags & AFS_VNODE_DELETED) @@ -76,10 +78,12 @@ static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, l * deal with notification that a page was read from the cache */ #ifdef AFS_CACHING_SUPPORT -static void afs_file_readpage_read_complete(void *cookie_data, struct page *page, void *data, +static void afs_file_readpage_read_complete(void *cookie_data, + struct page *page, + void *data, int error) { - _enter("%p,%p,%p,%d",cookie_data,page,data,error); + _enter("%p,%p,%p,%d", cookie_data, page, data, error); if (error) SetPageError(page); @@ -95,10 +99,12 @@ static void afs_file_readpage_read_complete(void *cookie_data, struct page *page * deal with notification that a page was written to the cache */ #ifdef AFS_CACHING_SUPPORT -static void afs_file_readpage_write_complete(void *cookie_data, struct page *page, void *data, +static void afs_file_readpage_write_complete(void *cookie_data, + struct page *page, + void *data, int error) { - _enter("%p,%p,%p,%d",cookie_data,page,data,error); + _enter("%p,%p,%p,%d", cookie_data, page, data, error); unlock_page(page); @@ -115,13 +121,13 @@ static int afs_file_readpage(struct file *file, struct page *page) #ifdef AFS_CACHING_SUPPORT struct cachefs_page *pageio; #endif + struct afs_vnode *vnode; struct inode *inode; - afs_vnode_t *vnode; int ret; inode = page->mapping->host; - _enter("{%lu},{%lu}",inode->i_ino,page->index); + _enter("{%lu},{%lu}", inode->i_ino, page->index); vnode = AFS_FS_I(inode); @@ -133,8 +139,8 @@ static int afs_file_readpage(struct file *file, struct page *page) goto error; #ifdef AFS_CACHING_SUPPORT - ret = cachefs_page_get_private(page,&pageio,GFP_NOIO); - if (ret<0) + ret = cachefs_page_get_private(page, &pageio, GFP_NOIO); + if (ret < 0) goto error; /* is it cached? */ @@ -162,23 +168,26 @@ static int afs_file_readpage(struct file *file, struct page *page) default: desc.fid = vnode->fid; desc.offset = page->index << PAGE_CACHE_SHIFT; - desc.size = min((size_t)(inode->i_size - desc.offset),(size_t)PAGE_SIZE); + desc.size = min((size_t) (inode->i_size - desc.offset), + (size_t) PAGE_SIZE); desc.buffer = kmap(page); clear_page(desc.buffer); - /* read the contents of the file from the server into the page */ - ret = afs_vnode_fetch_data(vnode,&desc); + /* read the contents of the file from the server into the + * page */ + ret = afs_vnode_fetch_data(vnode, &desc); kunmap(page); - if (ret<0) { + if (ret < 0) { if (ret==-ENOENT) { - _debug("got NOENT from server - marking file deleted and stale"); + _debug("got NOENT from server" + " - marking file deleted and stale"); vnode->flags |= AFS_VNODE_DELETED; ret = -ESTALE; } #ifdef AFS_CACHING_SUPPORT - cachefs_uncache_page(vnode->cache,page); + cachefs_uncache_page(vnode->cache, page); #endif goto error; } @@ -192,7 +201,7 @@ static int afs_file_readpage(struct file *file, struct page *page) NULL, GFP_KERNEL) != 0 ) { - cachefs_uncache_page(vnode->cache,page); + cachefs_uncache_page(vnode->cache, page); unlock_page(page); } #else @@ -207,7 +216,7 @@ static int afs_file_readpage(struct file *file, struct page *page) SetPageError(page); unlock_page(page); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_file_readpage() */ @@ -217,14 +226,15 @@ static int afs_file_readpage(struct file *file, struct page *page) * get a page cookie for the specified page */ #ifdef AFS_CACHING_SUPPORT -int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie) +int afs_cache_get_page_cookie(struct page *page, + struct cachefs_page **_page_cookie) { int ret; _enter(""); - ret = cachefs_page_get_private(page,_page_cookie,GFP_NOIO); + ret = cachefs_page_get_private(page,_page_cookie, GFP_NOIO); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_cache_get_page_cookie() */ #endif @@ -237,30 +247,32 @@ static int afs_file_invalidatepage(struct page *page, unsigned long offset) { int ret = 1; - _enter("{%lu},%lu",page->index,offset); + _enter("{%lu},%lu", page->index, offset); BUG_ON(!PageLocked(page)); + if (PagePrivate(page)) { #ifdef AFS_CACHING_SUPPORT struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); cachefs_uncache_page(vnode->cache,page); #endif - /* - * We release buffers only if the entire page is being invalidated. - * The get_block cached value has been unconditionally invalidated, - * so real IO is not possible anymore. + /* We release buffers only if the entire page is being + * invalidated. + * The get_block cached value has been unconditionally + * invalidated, so real IO is not possible anymore. */ if (offset == 0) { BUG_ON(!PageLocked(page)); ret = 0; if (!PageWriteback(page)) - ret = page->mapping->a_ops->releasepage(page, 0); + ret = page->mapping->a_ops->releasepage(page, + 0); } } - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_file_invalidatepage() */ @@ -272,12 +284,12 @@ static int afs_file_releasepage(struct page *page, int gfp_flags) { struct cachefs_page *pageio; - _enter("{%lu},%x",page->index,gfp_flags); + _enter("{%lu},%x", page->index, gfp_flags); if (PagePrivate(page)) { #ifdef AFS_CACHING_SUPPORT struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); - cachefs_uncache_page(vnode->cache,page); + cachefs_uncache_page(vnode->cache, page); #endif pageio = (struct cachefs_page *) page->private; diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c index 6a31e03c52bb..911496eb4c6d 100644 --- a/fs/afs/fsclient.c +++ b/fs/afs/fsclient.c @@ -24,7 +24,7 @@ #define FSFETCHSTATUS 132 /* AFS Fetch file status */ #define FSFETCHDATA 130 /* AFS Fetch file data */ -#define FSGIVEUPCALLBACKS 147 /* AFS Discard server callback promises */ +#define FSGIVEUPCALLBACKS 147 /* AFS Discard callback promises */ #define FSGETVOLUMEINFO 148 /* AFS Get root volume information */ #define FSGETROOTVOLUME 151 /* AFS Get root volume name */ #define FSLOOKUP 161 /* AFS lookup file in directory */ @@ -54,10 +54,9 @@ static void afs_rxfs_aemap(struct rxrpc_call *call) * - this operation doesn't seem to work correctly in OpenAFS server 1.2.2 */ #if 0 -int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen) +int afs_rxfs_get_root_volume(struct afs_server *server, + char *buf, size_t *buflen) { - DECLARE_WAITQUEUE(myself,current); - struct rxrpc_connection *conn; struct rxrpc_call *call; struct iovec piov[2]; @@ -65,23 +64,25 @@ int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen) int ret; u32 param[1]; - kenter("%p,%p,%u",server,buf,*buflen); + DECLARE_WAITQUEUE(myself, current); + + kenter("%p,%p,%u",server, buf, *buflen); /* get hold of the fileserver connection */ - ret = afs_server_get_fsconn(server,&conn); - if (ret<0) + ret = afs_server_get_fsconn(server, &conn); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(conn,NULL,NULL,afs_rxfs_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(conn, NULL, NULL, afs_rxfs_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = FSGETROOTVOLUME; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ param[0] = htonl(FSGETROOTVOLUME); @@ -90,14 +91,15 @@ int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen) piov[0].iov_base = param; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ for (;;) { set_current_state(TASK_INTERRUPTIBLE); - if (call->app_call_state!=RXRPC_CSTATE_CLNT_RCV_REPLY || + if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY || signal_pending(current)) break; schedule(); @@ -111,41 +113,41 @@ int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen) switch (call->app_call_state) { case RXRPC_CSTATE_ERROR: ret = call->app_errno; - kdebug("Got Error: %d",ret); + kdebug("Got Error: %d", ret); goto out_unwait; case RXRPC_CSTATE_CLNT_GOT_REPLY: /* read the reply */ - kdebug("Got Reply: qty=%d",call->app_ready_qty); + kdebug("Got Reply: qty=%d", call->app_ready_qty); ret = -EBADMSG; if (call->app_ready_qty <= 4) goto abort; - ret = rxrpc_call_read_data(call,NULL,call->app_ready_qty,0); - if (ret<0) + ret = rxrpc_call_read_data(call, NULL, call->app_ready_qty, 0); + if (ret < 0) goto abort; #if 0 /* unmarshall the reply */ bp = buffer; - for (loop=0; loop<65; loop++) + for (loop = 0; loop < 65; loop++) entry->name[loop] = ntohl(*bp++); entry->name[64] = 0; entry->type = ntohl(*bp++); entry->num_servers = ntohl(*bp++); - for (loop=0; loop<8; loop++) + for (loop = 0; loop < 8; loop++) entry->servers[loop].addr.s_addr = *bp++; - for (loop=0; loop<8; loop++) + for (loop = 0; loop < 8; loop++) entry->servers[loop].partition = ntohl(*bp++); - for (loop=0; loop<8; loop++) + for (loop = 0; loop < 8; loop++) entry->servers[loop].flags = ntohl(*bp++); - for (loop=0; loop<3; loop++) + for (loop = 0; loop < 3; loop++) entry->volume_ids[loop] = ntohl(*bp++); entry->clone_id = ntohl(*bp++); @@ -162,14 +164,14 @@ int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen) abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: - afs_server_release_fsconn(server,conn); + afs_server_release_fsconn(server, conn); out: kleave(""); return ret; @@ -181,12 +183,10 @@ int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen) * get information about a volume */ #if 0 -int afs_rxfs_get_volume_info(afs_server_t *server, +int afs_rxfs_get_volume_info(struct afs_server *server, const char *name, - afs_volume_info_t *vinfo) + struct afs_volume_info *vinfo) { - DECLARE_WAITQUEUE(myself,current); - struct rxrpc_connection *conn; struct rxrpc_call *call; struct iovec piov[3]; @@ -194,27 +194,29 @@ int afs_rxfs_get_volume_info(afs_server_t *server, int ret; u32 param[2], *bp, zero; - _enter("%p,%s,%p",server,name,vinfo); + DECLARE_WAITQUEUE(myself, current); + + _enter("%p,%s,%p", server, name, vinfo); /* get hold of the fileserver connection */ - ret = afs_server_get_fsconn(server,&conn); - if (ret<0) + ret = afs_server_get_fsconn(server, &conn); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(conn,NULL,NULL,afs_rxfs_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(conn, NULL, NULL, afs_rxfs_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = FSGETVOLUMEINFO; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ piov[1].iov_len = strlen(name); - piov[1].iov_base = (char*)name; + piov[1].iov_base = (char *) name; zero = 0; piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3; @@ -227,16 +229,19 @@ int afs_rxfs_get_volume_info(afs_server_t *server, piov[0].iov_base = param; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,3,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ - bp = rxrpc_call_alloc_scratch(call,64); + bp = rxrpc_call_alloc_scratch(call, 64); - ret = rxrpc_call_read_data(call,bp,64,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL); - if (ret<0) { - if (ret==-ECONNABORTED) { + ret = rxrpc_call_read_data(call, bp, 64, + RXRPC_CALL_READ_BLOCK | + RXRPC_CALL_READ_ALL); + if (ret < 0) { + if (ret == -ECONNABORTED) { ret = call->app_errno; goto out_unwait; } @@ -264,7 +269,7 @@ int afs_rxfs_get_volume_info(afs_server_t *server, vinfo->servers[7].addr.s_addr = *bp++; ret = -EBADMSG; - if (vinfo->nservers>8) + if (vinfo->nservers > 8) goto abort; /* success */ @@ -272,17 +277,17 @@ int afs_rxfs_get_volume_info(afs_server_t *server, out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: - afs_server_release_fsconn(server,conn); + afs_server_release_fsconn(server, conn); out: _leave(""); return ret; abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; @@ -293,12 +298,10 @@ int afs_rxfs_get_volume_info(afs_server_t *server, /* * fetch the status information for a file */ -int afs_rxfs_fetch_file_status(afs_server_t *server, - afs_vnode_t *vnode, - afs_volsync_t *volsync) +int afs_rxfs_fetch_file_status(struct afs_server *server, + struct afs_vnode *vnode, + struct afs_volsync *volsync) { - DECLARE_WAITQUEUE(myself,current); - struct afs_server_callslot callslot; struct rxrpc_call *call; struct iovec piov[1]; @@ -306,26 +309,30 @@ int afs_rxfs_fetch_file_status(afs_server_t *server, int ret; u32 *bp; - _enter("%p,{%u,%u,%u}",server,vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique); + DECLARE_WAITQUEUE(myself, current); + + _enter("%p,{%u,%u,%u}", + server, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique); /* get hold of the fileserver connection */ - ret = afs_server_request_callslot(server,&callslot); - if (ret<0) + ret = afs_server_request_callslot(server, &callslot); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(callslot.conn,NULL,NULL,afs_rxfs_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(callslot.conn, NULL, NULL, afs_rxfs_aemap, + &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = FSFETCHSTATUS; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ - bp = rxrpc_call_alloc_scratch(call,16); + bp = rxrpc_call_alloc_scratch(call, 16); bp[0] = htonl(FSFETCHSTATUS); bp[1] = htonl(vnode->fid.vid); bp[2] = htonl(vnode->fid.vnode); @@ -335,16 +342,19 @@ int afs_rxfs_fetch_file_status(afs_server_t *server, piov[0].iov_base = bp; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ - bp = rxrpc_call_alloc_scratch(call,120); + bp = rxrpc_call_alloc_scratch(call, 120); - ret = rxrpc_call_read_data(call,bp,120,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL); - if (ret<0) { - if (ret==-ECONNABORTED) { + ret = rxrpc_call_read_data(call, bp, 120, + RXRPC_CALL_READ_BLOCK | + RXRPC_CALL_READ_ALL); + if (ret < 0) { + if (ret == -ECONNABORTED) { ret = call->app_errno; goto out_unwait; } @@ -370,7 +380,7 @@ int afs_rxfs_fetch_file_status(afs_server_t *server, vnode->status.mtime_server = ntohl(*bp++); bp++; /* group */ bp++; /* sync counter */ - vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; + vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; bp++; /* spare2 */ bp++; /* spare3 */ bp++; /* spare4 */ @@ -393,17 +403,17 @@ int afs_rxfs_fetch_file_status(afs_server_t *server, out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: - afs_server_release_callslot(server,&callslot); + afs_server_release_callslot(server, &callslot); out: _leave(""); return ret; abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; } /* end afs_rxfs_fetch_file_status() */ @@ -412,13 +422,11 @@ int afs_rxfs_fetch_file_status(afs_server_t *server, /* * fetch the contents of a file or directory */ -int afs_rxfs_fetch_file_data(afs_server_t *server, - afs_vnode_t *vnode, +int afs_rxfs_fetch_file_data(struct afs_server *server, + struct afs_vnode *vnode, struct afs_rxfs_fetch_descriptor *desc, - afs_volsync_t *volsync) + struct afs_volsync *volsync) { - DECLARE_WAITQUEUE(myself,current); - struct afs_server_callslot callslot; struct rxrpc_call *call; struct iovec piov[1]; @@ -426,6 +434,8 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, int ret; u32 *bp; + DECLARE_WAITQUEUE(myself, current); + _enter("%p,{fid={%u,%u,%u},sz=%Zu,of=%lu}", server, desc->fid.vid, @@ -435,23 +445,23 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, desc->offset); /* get hold of the fileserver connection */ - ret = afs_server_request_callslot(server,&callslot); - if (ret<0) + ret = afs_server_request_callslot(server, &callslot); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(callslot.conn,NULL,NULL,afs_rxfs_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(callslot.conn, NULL, NULL, afs_rxfs_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = FSFETCHDATA; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ - bp = rxrpc_call_alloc_scratch(call,24); + bp = rxrpc_call_alloc_scratch(call, 24); bp[0] = htonl(FSFETCHDATA); bp[1] = htonl(desc->fid.vid); bp[2] = htonl(desc->fid.vnode); @@ -463,17 +473,18 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, piov[0].iov_base = bp; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the data count to arrive */ - ret = rxrpc_call_read_data(call,bp,4,RXRPC_CALL_READ_BLOCK); - if (ret<0) + ret = rxrpc_call_read_data(call, bp, 4, RXRPC_CALL_READ_BLOCK); + if (ret < 0) goto read_failed; desc->actual = ntohl(bp[0]); - if (desc->actual!=desc->size) { + if (desc->actual != desc->size) { ret = -EBADMSG; goto abort; } @@ -481,16 +492,19 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, /* call the app to read the actual data */ rxrpc_call_reset_scratch(call); - ret = rxrpc_call_read_data(call,desc->buffer,desc->actual,RXRPC_CALL_READ_BLOCK); - if (ret<0) + ret = rxrpc_call_read_data(call, desc->buffer, desc->actual, + RXRPC_CALL_READ_BLOCK); + if (ret < 0) goto read_failed; /* wait for the rest of the reply to completely arrive */ rxrpc_call_reset_scratch(call); - bp = rxrpc_call_alloc_scratch(call,120); + bp = rxrpc_call_alloc_scratch(call, 120); - ret = rxrpc_call_read_data(call,bp,120,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL); - if (ret<0) + ret = rxrpc_call_read_data(call, bp, 120, + RXRPC_CALL_READ_BLOCK | + RXRPC_CALL_READ_ALL); + if (ret < 0) goto read_failed; /* unmarshall the reply */ @@ -512,7 +526,7 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, vnode->status.mtime_server = ntohl(*bp++); bp++; /* group */ bp++; /* sync counter */ - vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; + vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; bp++; /* spare2 */ bp++; /* spare3 */ bp++; /* spare4 */ @@ -538,20 +552,20 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, remove_wait_queue(&call->waitq,&myself); rxrpc_put_call(call); out_put_conn: - afs_server_release_callslot(server,&callslot); + afs_server_release_callslot(server, &callslot); out: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; read_failed: - if (ret==-ECONNABORTED) { + if (ret == -ECONNABORTED) { ret = call->app_errno; goto out_unwait; } abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; @@ -561,10 +575,9 @@ int afs_rxfs_fetch_file_data(afs_server_t *server, /* * ask the AFS fileserver to discard a callback request on a file */ -int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode) +int afs_rxfs_give_up_callback(struct afs_server *server, + struct afs_vnode *vnode) { - DECLARE_WAITQUEUE(myself,current); - struct afs_server_callslot callslot; struct rxrpc_call *call; struct iovec piov[1]; @@ -572,28 +585,31 @@ int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode) int ret; u32 *bp; - _enter("%p,{%u,%u,%u}",server,vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique); + DECLARE_WAITQUEUE(myself, current); + + _enter("%p,{%u,%u,%u}", + server, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique); /* get hold of the fileserver connection */ - ret = afs_server_request_callslot(server,&callslot); - if (ret<0) + ret = afs_server_request_callslot(server, &callslot); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(callslot.conn,NULL,NULL,afs_rxfs_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(callslot.conn, NULL, NULL, afs_rxfs_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = FSGIVEUPCALLBACKS; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ - bp = rxrpc_call_alloc_scratch(call,(1+4+4)*4); + bp = rxrpc_call_alloc_scratch(call, (1 + 4 + 4) * 4); - piov[0].iov_len = (1+4+4)*4; + piov[0].iov_len = (1 + 4 + 4) * 4; piov[0].iov_base = bp; *bp++ = htonl(FSGIVEUPCALLBACKS); @@ -607,14 +623,15 @@ int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode) *bp++ = htonl(vnode->cb_type); /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ for (;;) { set_current_state(TASK_INTERRUPTIBLE); - if (call->app_call_state!=RXRPC_CSTATE_CLNT_RCV_REPLY || + if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY || signal_pending(current)) break; schedule(); @@ -640,17 +657,17 @@ int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode) out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: - afs_server_release_callslot(server,&callslot); + afs_server_release_callslot(server, &callslot); out: _leave(""); return ret; abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; } /* end afs_rxfs_give_up_callback() */ @@ -661,14 +678,12 @@ int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode) * - this operation doesn't seem to work correctly in OpenAFS server 1.2.2 */ #if 0 -int afs_rxfs_lookup(afs_server_t *server, - afs_vnode_t *dir, +int afs_rxfs_lookup(struct afs_server *server, + struct afs_vnode *dir, const char *filename, - afs_vnode_t *vnode, - afs_volsync_t *volsync) + struct afs_vnode *vnode, + struct afs_volsync *volsync) { - DECLARE_WAITQUEUE(myself,current); - struct rxrpc_connection *conn; struct rxrpc_call *call; struct iovec piov[3]; @@ -676,17 +691,20 @@ int afs_rxfs_lookup(afs_server_t *server, int ret; u32 *bp, zero; - kenter("%p,{%u,%u,%u},%s",server,fid->vid,fid->vnode,fid->unique,filename); + DECLARE_WAITQUEUE(myself, current); + + kenter("%p,{%u,%u,%u},%s", + server, fid->vid, fid->vnode, fid->unique, filename); /* get hold of the fileserver connection */ - ret = afs_server_get_fsconn(server,&conn); - if (ret<0) + ret = afs_server_get_fsconn(server, &conn); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(conn,NULL,NULL,afs_rxfs_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(conn, NULL, NULL, afs_rxfs_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = FSLOOKUP; @@ -695,14 +713,14 @@ int afs_rxfs_lookup(afs_server_t *server, add_wait_queue(&call->waitq,&myself); /* marshall the parameters */ - bp = rxrpc_call_alloc_scratch(call,20); + bp = rxrpc_call_alloc_scratch(call, 20); zero = 0; piov[0].iov_len = 20; piov[0].iov_base = bp; piov[1].iov_len = strlen(filename); - piov[1].iov_base = (char*) filename; + piov[1].iov_base = (char *) filename; piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3; piov[2].iov_base = &zero; @@ -713,16 +731,19 @@ int afs_rxfs_lookup(afs_server_t *server, *bp++ = htonl(piov[1].iov_len); /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,3,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ - bp = rxrpc_call_alloc_scratch(call,220); + bp = rxrpc_call_alloc_scratch(call, 220); - ret = rxrpc_call_read_data(call,bp,220,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL); - if (ret<0) { - if (ret==-ECONNABORTED) { + ret = rxrpc_call_read_data(call, bp, 220, + RXRPC_CALL_READ_BLOCK | + RXRPC_CALL_READ_ALL); + if (ret < 0) { + if (ret == -ECONNABORTED) { ret = call->app_errno; goto out_unwait; } @@ -752,30 +773,30 @@ int afs_rxfs_lookup(afs_server_t *server, vnode->status.mtime_server = ntohl(*bp++); bp++; /* group */ bp++; /* sync counter */ - vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; + vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; bp++; /* spare2 */ bp++; /* spare3 */ bp++; /* spare4 */ dir->status.if_version = ntohl(*bp++); - dir->status.type = ntohl(*bp++); + dir->status.type = ntohl(*bp++); dir->status.nlink = ntohl(*bp++); - dir->status.size = ntohl(*bp++); + dir->status.size = ntohl(*bp++); dir->status.version = ntohl(*bp++); dir->status.author = ntohl(*bp++); dir->status.owner = ntohl(*bp++); dir->status.caller_access = ntohl(*bp++); dir->status.anon_access = ntohl(*bp++); - dir->status.mode = ntohl(*bp++); + dir->status.mode = ntohl(*bp++); dir->status.parent.vid = dirfid->vid; - dir->status.parent.vnode = ntohl(*bp++); + dir->status.parent.vnode = ntohl(*bp++); dir->status.parent.unique = ntohl(*bp++); bp++; /* seg size */ - dir->status.mtime_client = ntohl(*bp++); - dir->status.mtime_server = ntohl(*bp++); + dir->status.mtime_client = ntohl(*bp++); + dir->status.mtime_server = ntohl(*bp++); bp++; /* group */ bp++; /* sync counter */ - dir->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; + dir->status.version |= ((unsigned long long) ntohl(*bp++)) << 32; bp++; /* spare2 */ bp++; /* spare3 */ bp++; /* spare4 */ @@ -799,17 +820,17 @@ int afs_rxfs_lookup(afs_server_t *server, out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: - afs_server_release_fsconn(server,conn); + afs_server_release_fsconn(server, conn); out: kleave(""); return ret; abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; } /* end afs_rxfs_lookup() */ diff --git a/fs/afs/fsclient.h b/fs/afs/fsclient.h index 0931a5b1be8f..8ba3e749ee3c 100644 --- a/fs/afs/fsclient.h +++ b/fs/afs/fsclient.h @@ -14,38 +14,39 @@ #include "server.h" -extern int afs_rxfs_get_volume_info(afs_server_t *server, +extern int afs_rxfs_get_volume_info(struct afs_server *server, const char *name, - afs_volume_info_t *vinfo); + struct afs_volume_info *vinfo); -extern int afs_rxfs_fetch_file_status(afs_server_t *server, - afs_vnode_t *vnode, - afs_volsync_t *volsync); +extern int afs_rxfs_fetch_file_status(struct afs_server *server, + struct afs_vnode *vnode, + struct afs_volsync *volsync); struct afs_rxfs_fetch_descriptor { - afs_fid_t fid; /* file ID to fetch */ + struct afs_fid fid; /* file ID to fetch */ size_t size; /* total number of bytes to fetch */ off_t offset; /* offset in file to start from */ void *buffer; /* read buffer */ size_t actual; /* actual size sent back by server */ }; -extern int afs_rxfs_fetch_file_data(afs_server_t *server, - afs_vnode_t *vnode, +extern int afs_rxfs_fetch_file_data(struct afs_server *server, + struct afs_vnode *vnode, struct afs_rxfs_fetch_descriptor *desc, - afs_volsync_t *volsync); + struct afs_volsync *volsync); -extern int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode); +extern int afs_rxfs_give_up_callback(struct afs_server *server, + struct afs_vnode *vnode); /* this doesn't appear to work in OpenAFS server */ -extern int afs_rxfs_lookup(afs_server_t *server, - afs_vnode_t *dir, +extern int afs_rxfs_lookup(struct afs_server *server, + struct afs_vnode *dir, const char *filename, - afs_vnode_t *vnode, - afs_volsync_t *volsync); + struct afs_vnode *vnode, + struct afs_volsync *volsync); /* this is apparently mis-implemented in OpenAFS server */ -extern int afs_rxfs_get_root_volume(afs_server_t *server, +extern int afs_rxfs_get_root_volume(struct afs_server *server, char *buf, size_t *buflen); diff --git a/fs/afs/inode.c b/fs/afs/inode.c index a9c253e67003..bee62f8f901a 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -26,15 +26,15 @@ #include "internal.h" struct afs_iget_data { - afs_fid_t fid; - afs_volume_t *volume; /* volume on which resides */ + struct afs_fid fid; + struct afs_volume *volume; /* volume on which resides */ }; /*****************************************************************************/ /* * map the AFS file status to the inode member variables */ -static int afs_inode_map_status(afs_vnode_t *vnode) +static int afs_inode_map_status(struct afs_vnode *vnode) { struct inode *inode = AFS_VNODE_TO_I(vnode); @@ -97,7 +97,7 @@ static int afs_inode_map_status(afs_vnode_t *vnode) */ int afs_inode_fetch_status(struct inode *inode) { - afs_vnode_t *vnode; + struct afs_vnode *vnode; int ret; vnode = AFS_FS_I(inode); @@ -130,7 +130,7 @@ static int afs_iget5_test(struct inode *inode, void *opaque) static int afs_iget5_set(struct inode *inode, void *opaque) { struct afs_iget_data *data = opaque; - afs_vnode_t *vnode = AFS_FS_I(inode); + struct afs_vnode *vnode = AFS_FS_I(inode); inode->i_ino = data->fid.vnode; inode->i_version = data->fid.unique; @@ -144,7 +144,7 @@ static int afs_iget5_set(struct inode *inode, void *opaque) /* * inode retrieval */ -inline int afs_iget(struct super_block *sb, afs_fid_t *fid, +inline int afs_iget(struct super_block *sb, struct afs_fid *fid, struct inode **_inode) { struct afs_iget_data data = { fid: *fid }; @@ -201,7 +201,11 @@ inline int afs_iget(struct super_block *sb, afs_fid_t *fid, vnode->cb_version, vnode->cb_timeout.timo_jif, vnode->cb_type, +#ifdef AFS_CACHING_SUPPORT vnode->cache +#else + NULL +#endif ); return 0; @@ -222,8 +226,8 @@ inline int afs_iget(struct super_block *sb, afs_fid_t *fid, int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { + struct afs_vnode *vnode; struct inode *inode; - afs_vnode_t *vnode; int ret; inode = dentry->d_inode; @@ -262,7 +266,7 @@ int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, */ void afs_clear_inode(struct inode *inode) { - afs_vnode_t *vnode; + struct afs_vnode *vnode; vnode = AFS_FS_I(inode); diff --git a/fs/afs/internal.h b/fs/afs/internal.h index b5279c59bc2f..11ef8c5568b2 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -46,7 +46,7 @@ static inline void afs_discard_my_signals(void) siginfo_t sinfo; spin_lock_irq(¤t->sighand->siglock); - dequeue_signal(current,¤t->blocked,&sinfo); + dequeue_signal(current,¤t->blocked, &sinfo); spin_unlock_irq(¤t->sighand->siglock); } } @@ -74,17 +74,28 @@ extern struct inode_operations afs_file_inode_operations; extern struct file_operations afs_file_file_operations; #ifdef AFS_CACHING_SUPPORT -extern int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie); +extern int afs_cache_get_page_cookie(struct page *page, + struct cachefs_page **_page_cookie); #endif /* * inode.c */ -extern int afs_iget(struct super_block *sb, afs_fid_t *fid, struct inode **_inode); -extern int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); +extern int afs_iget(struct super_block *sb, struct afs_fid *fid, + struct inode **_inode); +extern int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat); extern void afs_clear_inode(struct inode *inode); /* + * key_afs.c + */ +#ifdef CONFIG_KEYS +extern int afs_key_register(void); +extern void afs_key_unregister(void); +#endif + +/* * main.c */ #ifdef AFS_CACHING_SUPPORT @@ -102,7 +113,7 @@ extern struct afs_timer_ops afs_mntpt_expiry_timer_ops; extern unsigned long afs_mntpt_expiry_timeout; #endif -extern int afs_mntpt_check_symlink(afs_vnode_t *vnode); +extern int afs_mntpt_check_symlink(struct afs_vnode *vnode); /* * super.c @@ -110,13 +121,14 @@ extern int afs_mntpt_check_symlink(afs_vnode_t *vnode); extern int afs_fs_init(void); extern void afs_fs_exit(void); -#define AFS_CB_HASH_COUNT (PAGE_SIZE/sizeof(struct list_head)) +#define AFS_CB_HASH_COUNT (PAGE_SIZE / sizeof(struct list_head)) extern struct list_head afs_cb_hash_tbl[]; extern spinlock_t afs_cb_hash_lock; #define afs_cb_hash(SRV,FID) \ - afs_cb_hash_tbl[((unsigned long)(SRV) + (FID)->vid + (FID)->vnode + (FID)->unique) % \ + afs_cb_hash_tbl[((unsigned long)(SRV) + \ + (FID)->vid + (FID)->vnode + (FID)->unique) % \ AFS_CB_HASH_COUNT] /* @@ -124,7 +136,7 @@ extern spinlock_t afs_cb_hash_lock; */ extern int afs_proc_init(void); extern void afs_proc_cleanup(void); -extern int afs_proc_cell_setup(afs_cell_t *cell); -extern void afs_proc_cell_remove(afs_cell_t *cell); +extern int afs_proc_cell_setup(struct afs_cell *cell); +extern void afs_proc_cell_remove(struct afs_cell *cell); #endif /* AFS_INTERNAL_H */ diff --git a/fs/afs/kafsasyncd.c b/fs/afs/kafsasyncd.c index dc6505578f8d..9c88da3be429 100644 --- a/fs/afs/kafsasyncd.c +++ b/fs/afs/kafsasyncd.c @@ -57,8 +57,8 @@ int afs_kafsasyncd_start(void) { int ret; - ret = kernel_thread(kafsasyncd,NULL,0); - if (ret<0) + ret = kernel_thread(kafsasyncd, NULL, 0); + if (ret < 0) return ret; wait_for_completion(&kafsasyncd_alive); @@ -85,14 +85,14 @@ void afs_kafsasyncd_stop(void) */ static int kafsasyncd(void *arg) { - DECLARE_WAITQUEUE(myself,current); - - struct list_head *_p; + struct afs_async_op *op; int die; + DECLARE_WAITQUEUE(myself, current); + kafsasyncd_task = current; - printk("kAFS: Started kafsasyncd %d\n",current->pid); + printk("kAFS: Started kafsasyncd %d\n", current->pid); daemonize("kafsasyncd"); @@ -101,7 +101,7 @@ static int kafsasyncd(void *arg) /* loop around looking for things to attend to */ do { set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&kafsasyncd_sleepq,&myself); + add_wait_queue(&kafsasyncd_sleepq, &myself); for (;;) { if (!list_empty(&kafsasyncd_async_attnq) || @@ -113,7 +113,7 @@ static int kafsasyncd(void *arg) set_current_state(TASK_INTERRUPTIBLE); } - remove_wait_queue(&kafsasyncd_sleepq,&myself); + remove_wait_queue(&kafsasyncd_sleepq, &myself); set_current_state(TASK_RUNNING); /* discard pending signals */ @@ -121,7 +121,8 @@ static int kafsasyncd(void *arg) die = kafsasyncd_die; - /* deal with the next asynchronous operation requiring attention */ + /* deal with the next asynchronous operation requiring + * attention */ if (!list_empty(&kafsasyncd_async_attnq)) { struct afs_async_op *op; @@ -131,14 +132,17 @@ static int kafsasyncd(void *arg) spin_lock(&kafsasyncd_async_lock); if (!list_empty(&kafsasyncd_async_attnq)) { - op = list_entry(kafsasyncd_async_attnq.next,afs_async_op_t,link); + op = list_entry(kafsasyncd_async_attnq.next, + struct afs_async_op, link); list_del(&op->link); - list_add_tail(&op->link,&kafsasyncd_async_busyq); + list_add_tail(&op->link, + &kafsasyncd_async_busyq); } spin_unlock(&kafsasyncd_async_lock); - _debug("@@@ Operation %p {%p}\n",op,op?op->ops:NULL); + _debug("@@@ Operation %p {%p}\n", + op, op ? op->ops : NULL); if (op) op->ops->attend(op); @@ -148,30 +152,30 @@ static int kafsasyncd(void *arg) } while(!die); - /* need to kill all outstanding asynchronous operations before exiting */ + /* need to kill all outstanding asynchronous operations before + * exiting */ kafsasyncd_task = NULL; spin_lock(&kafsasyncd_async_lock); /* fold the busy and attention queues together */ - list_splice_init(&kafsasyncd_async_busyq,&kafsasyncd_async_attnq); + list_splice_init(&kafsasyncd_async_busyq, + &kafsasyncd_async_attnq); /* dequeue kafsasyncd from all their wait queues */ - list_for_each(_p,&kafsasyncd_async_attnq) { - afs_async_op_t *op = list_entry(_p,afs_async_op_t,link); - + list_for_each_entry(op, &kafsasyncd_async_attnq, link) { op->call->app_attn_func = kafsasyncd_null_call_attn_func; op->call->app_error_func = kafsasyncd_null_call_error_func; - remove_wait_queue(&op->call->waitq,&op->waiter); + remove_wait_queue(&op->call->waitq, &op->waiter); } spin_unlock(&kafsasyncd_async_lock); /* abort all the operations */ while (!list_empty(&kafsasyncd_async_attnq)) { - afs_async_op_t *op = list_entry(_p,afs_async_op_t,link); + op = list_entry(kafsasyncd_async_attnq.next, struct afs_async_op, link); list_del_init(&op->link); - rxrpc_call_abort(op->call,-EIO); + rxrpc_call_abort(op->call, -EIO); rxrpc_put_call(op->call); op->call = NULL; @@ -180,7 +184,7 @@ static int kafsasyncd(void *arg) /* and that's all */ _leave(""); - complete_and_exit(&kafsasyncd_dead,0); + complete_and_exit(&kafsasyncd_dead, 0); } /* end kafsasyncd() */ @@ -189,17 +193,17 @@ static int kafsasyncd(void *arg) * begin an operation * - place operation on busy queue */ -void afs_kafsasyncd_begin_op(afs_async_op_t *op) +void afs_kafsasyncd_begin_op(struct afs_async_op *op) { _enter(""); spin_lock(&kafsasyncd_async_lock); - init_waitqueue_entry(&op->waiter,kafsasyncd_task); - add_wait_queue(&op->call->waitq,&op->waiter); + init_waitqueue_entry(&op->waiter, kafsasyncd_task); + add_wait_queue(&op->call->waitq, &op->waiter); list_del(&op->link); - list_add_tail(&op->link,&kafsasyncd_async_busyq); + list_add_tail(&op->link, &kafsasyncd_async_busyq); spin_unlock(&kafsasyncd_async_lock); @@ -211,14 +215,14 @@ void afs_kafsasyncd_begin_op(afs_async_op_t *op) * request attention for an operation * - move to attention queue */ -void afs_kafsasyncd_attend_op(afs_async_op_t *op) +void afs_kafsasyncd_attend_op(struct afs_async_op *op) { _enter(""); spin_lock(&kafsasyncd_async_lock); list_del(&op->link); - list_add_tail(&op->link,&kafsasyncd_async_attnq); + list_add_tail(&op->link, &kafsasyncd_async_attnq); spin_unlock(&kafsasyncd_async_lock); @@ -232,7 +236,7 @@ void afs_kafsasyncd_attend_op(afs_async_op_t *op) * terminate an operation * - remove from either queue */ -void afs_kafsasyncd_terminate_op(afs_async_op_t *op) +void afs_kafsasyncd_terminate_op(struct afs_async_op *op) { _enter(""); @@ -240,7 +244,7 @@ void afs_kafsasyncd_terminate_op(afs_async_op_t *op) if (!list_empty(&op->link)) { list_del_init(&op->link); - remove_wait_queue(&op->call->waitq,&op->waiter); + remove_wait_queue(&op->call->waitq, &op->waiter); } spin_unlock(&kafsasyncd_async_lock); diff --git a/fs/afs/kafsasyncd.h b/fs/afs/kafsasyncd.h index 6438c17833a1..791803f9a6fb 100644 --- a/fs/afs/kafsasyncd.h +++ b/fs/afs/kafsasyncd.h @@ -14,9 +14,11 @@ #include "types.h" +struct afs_async_op; + struct afs_async_op_ops { - void (*attend)(afs_async_op_t *op); - void (*discard)(afs_async_op_t *op); + void (*attend)(struct afs_async_op *op); + void (*discard)(struct afs_async_op *op); }; /*****************************************************************************/ @@ -26,13 +28,14 @@ struct afs_async_op_ops { struct afs_async_op { struct list_head link; - afs_server_t *server; /* server being contacted */ + struct afs_server *server; /* server being contacted */ struct rxrpc_call *call; /* RxRPC call performing op */ wait_queue_t waiter; /* wait queue for kafsasyncd */ const struct afs_async_op_ops *ops; /* operations */ }; -static inline void afs_async_op_init(afs_async_op_t *op, const struct afs_async_op_ops *ops) +static inline void afs_async_op_init(struct afs_async_op *op, + const struct afs_async_op_ops *ops) { INIT_LIST_HEAD(&op->link); op->call = NULL; @@ -42,8 +45,8 @@ static inline void afs_async_op_init(afs_async_op_t *op, const struct afs_async_ extern int afs_kafsasyncd_start(void); extern void afs_kafsasyncd_stop(void); -extern void afs_kafsasyncd_begin_op(afs_async_op_t *op); -extern void afs_kafsasyncd_attend_op(afs_async_op_t *op); -extern void afs_kafsasyncd_terminate_op(afs_async_op_t *op); +extern void afs_kafsasyncd_begin_op(struct afs_async_op *op); +extern void afs_kafsasyncd_attend_op(struct afs_async_op *op); +extern void afs_kafsasyncd_terminate_op(struct afs_async_op *op); #endif /* _LINUX_AFS_KAFSASYNCD_H */ diff --git a/fs/afs/kafstimod.c b/fs/afs/kafstimod.c index 81b73a8ead4b..d7c8826b52a8 100644 --- a/fs/afs/kafstimod.c +++ b/fs/afs/kafstimod.c @@ -37,8 +37,8 @@ int afs_kafstimod_start(void) { int ret; - ret = kernel_thread(kafstimod,NULL,0); - if (ret<0) + ret = kernel_thread(kafstimod, NULL, 0); + if (ret < 0) return ret; wait_for_completion(&kafstimod_alive); @@ -65,11 +65,11 @@ void afs_kafstimod_stop(void) */ static int kafstimod(void *arg) { - DECLARE_WAITQUEUE(myself,current); + struct afs_timer *timer; - afs_timer_t *timer; + DECLARE_WAITQUEUE(myself, current); - printk("kAFS: Started kafstimod %d\n",current->pid); + printk("kAFS: Started kafstimod %d\n", current->pid); daemonize("kafstimod"); @@ -78,7 +78,7 @@ static int kafstimod(void *arg) /* loop around looking for things to attend to */ loop: set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&kafstimod_sleepq,&myself); + add_wait_queue(&kafstimod_sleepq, &myself); for (;;) { unsigned long jif; @@ -86,9 +86,9 @@ static int kafstimod(void *arg) /* deal with the server being asked to die */ if (kafstimod_die) { - remove_wait_queue(&kafstimod_sleepq,&myself); + remove_wait_queue(&kafstimod_sleepq, &myself); _leave(""); - complete_and_exit(&kafstimod_dead,0); + complete_and_exit(&kafstimod_dead, 0); } /* discard pending signals */ @@ -100,15 +100,16 @@ static int kafstimod(void *arg) timeout = MAX_SCHEDULE_TIMEOUT; } else { - timer = list_entry(kafstimod_list.next,afs_timer_t,link); + timer = list_entry(kafstimod_list.next, + struct afs_timer, link); timeout = timer->timo_jif; jif = jiffies; - if (time_before_eq((unsigned long)timeout,jif)) + if (time_before_eq((unsigned long) timeout, jif)) goto immediate; else { - timeout = (long)timeout - (long)jiffies; + timeout = (long) timeout - (long) jiffies; } } spin_unlock(&kafstimod_lock); @@ -119,13 +120,14 @@ static int kafstimod(void *arg) } /* the thing on the front of the queue needs processing - * - we come here with the lock held and timer pointing to the expired entry + * - we come here with the lock held and timer pointing to the expired + * entry */ immediate: - remove_wait_queue(&kafstimod_sleepq,&myself); + remove_wait_queue(&kafstimod_sleepq, &myself); set_current_state(TASK_RUNNING); - _debug("@@@ Begin Timeout of %p",timer); + _debug("@@@ Begin Timeout of %p", timer); /* dequeue the timer */ list_del_init(&timer->link); @@ -143,27 +145,28 @@ static int kafstimod(void *arg) /* * (re-)queue a timer */ -void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout) +void afs_kafstimod_add_timer(struct afs_timer *timer, unsigned long timeout) { + struct afs_timer *ptimer; struct list_head *_p; - afs_timer_t *ptimer; - _enter("%p,%lu",timer,timeout); + _enter("%p,%lu", timer, timeout); spin_lock(&kafstimod_lock); list_del(&timer->link); - /* the timer was deferred or reset - put it back in the queue at the right place */ + /* the timer was deferred or reset - put it back in the queue at the + * right place */ timer->timo_jif = jiffies + timeout; - list_for_each(_p,&kafstimod_list) { - ptimer = list_entry(_p,afs_timer_t,link); - if (time_before(timer->timo_jif,ptimer->timo_jif)) + list_for_each(_p, &kafstimod_list) { + ptimer = list_entry(_p, struct afs_timer, link); + if (time_before(timer->timo_jif, ptimer->timo_jif)) break; } - list_add_tail(&timer->link,_p); /* insert before stopping point */ + list_add_tail(&timer->link, _p); /* insert before stopping point */ spin_unlock(&kafstimod_lock); @@ -177,11 +180,11 @@ void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout) * dequeue a timer * - returns 0 if the timer was deleted or -ENOENT if it wasn't queued */ -int afs_kafstimod_del_timer(afs_timer_t *timer) +int afs_kafstimod_del_timer(struct afs_timer *timer) { int ret = 0; - _enter("%p",timer); + _enter("%p", timer); spin_lock(&kafstimod_lock); @@ -194,6 +197,6 @@ int afs_kafstimod_del_timer(afs_timer_t *timer) wake_up(&kafstimod_sleepq); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_kafstimod_del_timer() */ diff --git a/fs/afs/kafstimod.h b/fs/afs/kafstimod.h index 342d81d6025b..e312f1a61a7f 100644 --- a/fs/afs/kafstimod.h +++ b/fs/afs/kafstimod.h @@ -14,6 +14,8 @@ #include "types.h" +struct afs_timer; + struct afs_timer_ops { /* called when the front of the timer queue has timed out */ void (*timed_out)(struct afs_timer *timer); @@ -30,7 +32,8 @@ struct afs_timer const struct afs_timer_ops *ops; /* timeout expiry function */ }; -static inline void afs_timer_init(afs_timer_t *timer, const struct afs_timer_ops *ops) +static inline void afs_timer_init(struct afs_timer *timer, + const struct afs_timer_ops *ops) { INIT_LIST_HEAD(&timer->link); timer->ops = ops; @@ -39,7 +42,8 @@ static inline void afs_timer_init(afs_timer_t *timer, const struct afs_timer_ops extern int afs_kafstimod_start(void); extern void afs_kafstimod_stop(void); -extern void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout); -extern int afs_kafstimod_del_timer(afs_timer_t *timer); +extern void afs_kafstimod_add_timer(struct afs_timer *timer, + unsigned long timeout); +extern int afs_kafstimod_del_timer(struct afs_timer *timer); #endif /* _LINUX_AFS_KAFSTIMOD_H */ diff --git a/fs/afs/main.c b/fs/afs/main.c index f31b28c05ab7..c567afd54eb7 100644 --- a/fs/afs/main.c +++ b/fs/afs/main.c @@ -33,13 +33,24 @@ static void afs_exit(void); static int afs_adding_peer(struct rxrpc_peer *peer); static void afs_discarding_peer(struct rxrpc_peer *peer); -module_init(afs_init); +/* XXX late_initcall is kludgy, but the only alternative seems to create + * a transport upon the first mount, which is worse. Or is it? + */ +/* module_init(afs_init); */ +late_initcall(afs_init); /* must be called after net/ to create socket */ + module_exit(afs_exit); MODULE_DESCRIPTION("AFS Client File System"); MODULE_AUTHOR("Red Hat, Inc."); MODULE_LICENSE("GPL"); +static char *rootcell; + +MODULE_PARM(rootcell, "s"); +MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list"); + + static struct rxrpc_peer_ops afs_peer_ops = { .adding = afs_adding_peer, .discarding = afs_discarding_peer, @@ -72,7 +83,7 @@ static int afs_init(void) /* initialise the callback hash table */ spin_lock_init(&afs_cb_hash_lock); - for (loop=AFS_CB_HASH_COUNT-1; loop>=0; loop--) + for (loop = AFS_CB_HASH_COUNT - 1; loop >= 0; loop--) INIT_LIST_HEAD(&afs_cb_hash_tbl[loop]); /* register the /proc stuff */ @@ -82,20 +93,27 @@ static int afs_init(void) #ifdef AFS_CACHING_SUPPORT /* we want to be able to cache */ - ret = cachefs_register_netfs(&afs_cache_netfs,&afs_cache_cell_index_def); + ret = cachefs_register_netfs(&afs_cache_netfs, + &afs_cache_cell_index_def); if (ret < 0) goto error; #endif - /* initialise the cell DB */ - ret = afs_cell_init(); +#ifdef CONFIG_KEYS + ret = afs_key_register(); if (ret < 0) goto error_cache; +#endif + + /* initialise the cell DB */ + ret = afs_cell_init(rootcell); + if (ret < 0) + goto error_keys; /* start the timeout daemon */ ret = afs_kafstimod_start(); if (ret < 0) - goto error_cache; + goto error_keys; /* start the async operation daemon */ ret = afs_kafsasyncd_start(); @@ -103,7 +121,7 @@ static int afs_init(void) goto error_kafstimod; /* create the RxRPC transport */ - ret = rxrpc_create_transport(7001,&afs_transport); + ret = rxrpc_create_transport(7001, &afs_transport); if (ret < 0) goto error_kafsasyncd; @@ -122,14 +140,18 @@ static int afs_init(void) afs_kafsasyncd_stop(); error_kafstimod: afs_kafstimod_stop(); + error_keys: +#ifdef CONFIG_KEYS + afs_key_unregister(); error_cache: +#endif #ifdef AFS_CACHING_SUPPORT cachefs_unregister_netfs(&afs_cache_netfs); error: #endif afs_cell_purge(); afs_proc_cleanup(); - printk(KERN_ERR "kAFS: failed to register: %d\n",ret); + printk(KERN_ERR "kAFS: failed to register: %d\n", ret); return ret; } /* end afs_init() */ @@ -146,6 +168,9 @@ static void __exit afs_exit(void) afs_kafstimod_stop(); afs_kafsasyncd_stop(); afs_cell_purge(); +#ifdef CONFIG_KEYS + afs_key_unregister(); +#endif #ifdef AFS_CACHING_SUPPORT cachefs_unregister_netfs(&afs_cache_netfs); #endif @@ -162,19 +187,20 @@ static void __exit afs_exit(void) */ static int afs_adding_peer(struct rxrpc_peer *peer) { - afs_server_t *server; + struct afs_server *server; int ret; - _debug("kAFS: Adding new peer %08x\n",ntohl(peer->addr.s_addr)); + _debug("kAFS: Adding new peer %08x\n", ntohl(peer->addr.s_addr)); /* determine which server the peer resides in (if any) */ - ret = afs_server_find_by_peer(peer,&server); + ret = afs_server_find_by_peer(peer, &server); if (ret < 0) return ret; /* none that we recognise, so abort */ - _debug("Server %p{u=%d}\n",server,atomic_read(&server->usage)); + _debug("Server %p{u=%d}\n", server, atomic_read(&server->usage)); - _debug("Cell %p{u=%d}\n",server->cell,atomic_read(&server->cell->usage)); + _debug("Cell %p{u=%d}\n", + server->cell, atomic_read(&server->cell->usage)); /* cross-point the structs under a global lock */ spin_lock(&afs_server_peer_lock); @@ -194,14 +220,14 @@ static int afs_adding_peer(struct rxrpc_peer *peer) */ static void afs_discarding_peer(struct rxrpc_peer *peer) { - afs_server_t *server; + struct afs_server *server; _enter("%p",peer); _debug("Discarding peer %08x (rtt=%lu.%lumS)\n", ntohl(peer->addr.s_addr), - (long)(peer->rtt/1000), - (long)(peer->rtt%1000)); + (long) (peer->rtt / 1000), + (long) (peer->rtt % 1000)); /* uncross-point the structs under a global lock */ spin_lock(&afs_server_peer_lock); @@ -209,9 +235,6 @@ static void afs_discarding_peer(struct rxrpc_peer *peer) if (server) { peer->user = NULL; server->peer = NULL; - - //_debug("Server %p{u=%d}\n",server,atomic_read(&server->usage)); - //_debug("Cell %p{u=%d}\n",server->cell,atomic_read(&server->cell->usage)); } spin_unlock(&afs_server_peer_lock); @@ -239,7 +262,7 @@ void __cyg_profile_func_enter (void *this_fn, void *call_site) " movl $0xedededed,%%eax \n" " rep stosl \n" : - : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info)) + : "i"(~(THREAD_SIZE - 1)), "i"(sizeof(struct thread_info)) : "eax", "ecx", "edi", "memory", "cc" ); } @@ -258,7 +281,7 @@ void __cyg_profile_func_exit(void *this_fn, void *call_site) " movl $0xdadadada,%%eax \n" " rep stosl \n" : - : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info)) + : "i"(~(THREAD_SIZE - 1)), "i"(sizeof(struct thread_info)) : "eax", "ecx", "edi", "memory", "cc" ); } diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c index 93082fa5771e..3a36a3ca5e39 100644 --- a/fs/afs/mntpt.c +++ b/fs/afs/mntpt.c @@ -67,18 +67,21 @@ unsigned long afs_mntpt_expiry_timeout = 20; * check a symbolic link to see whether it actually encodes a mountpoint * - sets the AFS_VNODE_MOUNTPOINT flag on the vnode appropriately */ -int afs_mntpt_check_symlink(afs_vnode_t *vnode) +int afs_mntpt_check_symlink(struct afs_vnode *vnode) { struct page *page; + filler_t *filler; size_t size; char *buf; int ret; - _enter("{%u,%u}",vnode->fid.vnode,vnode->fid.unique); + _enter("{%u,%u}", vnode->fid.vnode, vnode->fid.unique); /* read the contents of the symlink into the pagecache */ - page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping,0, - (filler_t*)AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage,NULL); + filler = (filler_t *) AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage; + + page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0, + filler, NULL); if (IS_ERR(page)) { ret = PTR_ERR(page); goto out; @@ -94,11 +97,11 @@ int afs_mntpt_check_symlink(afs_vnode_t *vnode) /* examine the symlink's contents */ size = vnode->status.size; - _debug("symlink to %*.*s",size,(int)size,buf); + _debug("symlink to %*.*s", size, (int) size, buf); - if (size>2 && - (buf[0]=='%' || buf[0]=='#') && - buf[size-1]=='.' + if (size > 2 && + (buf[0] == '%' || buf[0] == '#') && + buf[size - 1] == '.' ) { _debug("symlink is a mountpoint"); spin_lock(&vnode->lock); @@ -112,7 +115,7 @@ int afs_mntpt_check_symlink(afs_vnode_t *vnode) kunmap(page); page_cache_release(page); out: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_mntpt_check_symlink() */ @@ -129,7 +132,8 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir, dir, dentry, dentry->d_parent, - dentry->d_parent ? dentry->d_parent->d_name.name : (const unsigned char*)"", + dentry->d_parent ? + dentry->d_parent->d_name.name : (const unsigned char *) "", dentry->d_name.name); return ERR_PTR(-EREMOTE); @@ -144,7 +148,9 @@ static int afs_mntpt_open(struct inode *inode, struct file *file) kenter("%p,%p{%p{%s},%s}", inode, file, file->f_dentry->d_parent, - file->f_dentry->d_parent ? file->f_dentry->d_parent->d_name.name : (const unsigned char*)"", + file->f_dentry->d_parent ? + file->f_dentry->d_parent->d_name.name : + (const unsigned char *) "", file->f_dentry->d_name.name); return -EREMOTE; @@ -183,10 +189,9 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) goto error; /* read the contents of the AFS special symlink */ - page = read_cache_page(mntpt->d_inode->i_mapping, - 0, - (filler_t*)mntpt->d_inode->i_mapping->a_ops->readpage, - NULL); + filler_t *filler = mntpt->d_inode->i_mapping->a_ops->readpage; + + page = read_cache_page(mntpt->d_inode->i_mapping, 0, filler, NULL); if (IS_ERR(page)) { ret = PTR_ERR(page); goto error; @@ -208,26 +213,26 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) memcpy(options, "cell=", 5); strcpy(options + 5, super->volume->cell->name); if (super->volume->type == AFSVL_RWVOL) - strcat(options,",rwpath"); + strcat(options, ",rwpath"); /* try and do the mount */ kdebug("--- attempting mount %s -o %s ---", devname, options); mnt = do_kern_mount("afs", 0, devname, options); kdebug("--- mount result %p ---", mnt); - free_page((unsigned long)devname); - free_page((unsigned long)options); - kleave(" = %p",mnt); + free_page((unsigned long) devname); + free_page((unsigned long) options); + kleave(" = %p", mnt); return mnt; error: if (page) page_cache_release(page); if (devname) - free_page((unsigned long)devname); + free_page((unsigned long) devname); if (options) - free_page((unsigned long)options); - kleave(" = %d",ret); + free_page((unsigned long) options); + kleave(" = %d", ret); return ERR_PTR(ret); } /* end afs_mntpt_do_automount() */ @@ -252,7 +257,7 @@ static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd) if (IS_ERR(newmnt)) return PTR_ERR(newmnt); - struct_cpy(&newnd,nd); + struct_cpy(&newnd, nd); newnd.dentry = dentry; err = do_add_mount(newmnt, &newnd, 0, &afs_vfsmounts); diff --git a/fs/afs/proc.c b/fs/afs/proc.c index 3670349097d8..465994066fda 100644 --- a/fs/afs/proc.c +++ b/fs/afs/proc.c @@ -27,7 +27,8 @@ static void *afs_proc_cells_start(struct seq_file *p, loff_t *pos); static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos); static void afs_proc_cells_stop(struct seq_file *p, void *v); static int afs_proc_cells_show(struct seq_file *m, void *v); -static ssize_t afs_proc_cells_write(struct file *file, const char *buf, size_t size, loff_t *_pos); +static ssize_t afs_proc_cells_write(struct file *file, const char *buf, + size_t size, loff_t *_pos); static struct seq_operations afs_proc_cells_ops = { .start = afs_proc_cells_start, @@ -44,10 +45,27 @@ static struct file_operations afs_proc_cells_fops = { .release = seq_release, }; +static int afs_proc_rootcell_open(struct inode *inode, struct file *file); +static int afs_proc_rootcell_release(struct inode *inode, struct file *file); +static ssize_t afs_proc_rootcell_read(struct file *file, char *buf, + size_t size, loff_t *_pos); +static ssize_t afs_proc_rootcell_write(struct file *file, const char *buf, + size_t size, loff_t *_pos); + +static struct file_operations afs_proc_rootcell_fops = { + .open = afs_proc_rootcell_open, + .read = afs_proc_rootcell_read, + .write = afs_proc_rootcell_write, + .llseek = no_llseek, + .release = afs_proc_rootcell_release +}; + static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file); -static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file); +static int afs_proc_cell_volumes_release(struct inode *inode, + struct file *file); static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos); -static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, loff_t *pos); +static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, + loff_t *pos); static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v); static int afs_proc_cell_volumes_show(struct seq_file *m, void *v); @@ -65,10 +83,13 @@ static struct file_operations afs_proc_cell_volumes_fops = { .release = afs_proc_cell_volumes_release, }; -static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file); -static int afs_proc_cell_vlservers_release(struct inode *inode, struct file *file); +static int afs_proc_cell_vlservers_open(struct inode *inode, + struct file *file); +static int afs_proc_cell_vlservers_release(struct inode *inode, + struct file *file); static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos); -static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, loff_t *pos); +static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, + loff_t *pos); static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v); static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v); @@ -87,9 +108,11 @@ static struct file_operations afs_proc_cell_vlservers_fops = { }; static int afs_proc_cell_servers_open(struct inode *inode, struct file *file); -static int afs_proc_cell_servers_release(struct inode *inode, struct file *file); +static int afs_proc_cell_servers_release(struct inode *inode, + struct file *file); static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos); -static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, loff_t *pos); +static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, + loff_t *pos); static void afs_proc_cell_servers_stop(struct seq_file *p, void *v); static int afs_proc_cell_servers_show(struct seq_file *m, void *v); @@ -117,26 +140,30 @@ int afs_proc_init(void) _enter(""); - proc_afs = proc_mkdir("fs/afs",NULL); + proc_afs = proc_mkdir("fs/afs", NULL); if (!proc_afs) goto error; proc_afs->owner = THIS_MODULE; - p = create_proc_entry("cells",0,proc_afs); + p = create_proc_entry("cells", 0, proc_afs); if (!p) goto error_proc; p->proc_fops = &afs_proc_cells_fops; p->owner = THIS_MODULE; + p = create_proc_entry("rootcell", 0, proc_afs); + if (!p) + goto error_cells; + p->proc_fops = &afs_proc_rootcell_fops; + p->owner = THIS_MODULE; + _leave(" = 0"); return 0; -#if 0 error_cells: - remove_proc_entry("cells",proc_afs); -#endif + remove_proc_entry("cells", proc_afs); error_proc: - remove_proc_entry("fs/afs",NULL); + remove_proc_entry("fs/afs", NULL); error: _leave(" = -ENOMEM"); return -ENOMEM; @@ -149,9 +176,9 @@ int afs_proc_init(void) */ void afs_proc_cleanup(void) { - remove_proc_entry("cells",proc_afs); + remove_proc_entry("cells", proc_afs); - remove_proc_entry("fs/afs",NULL); + remove_proc_entry("fs/afs", NULL); } /* end afs_proc_cleanup() */ @@ -164,8 +191,8 @@ static int afs_proc_cells_open(struct inode *inode, struct file *file) struct seq_file *m; int ret; - ret = seq_open(file,&afs_proc_cells_ops); - if (ret<0) + ret = seq_open(file, &afs_proc_cells_ops); + if (ret < 0) return ret; m = file->private_data; @@ -176,7 +203,8 @@ static int afs_proc_cells_open(struct inode *inode, struct file *file) /*****************************************************************************/ /* - * set up the iterator to start reading from the cells list and return the first item + * set up the iterator to start reading from the cells list and return the + * first item */ static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos) { @@ -188,15 +216,15 @@ static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos) /* allow for the header line */ if (!pos) - return (void *)1; + return (void *) 1; pos--; /* find the n'th element in the list */ - list_for_each(_p,&afs_proc_cells) + list_for_each(_p, &afs_proc_cells) if (!pos--) break; - return _p!=&afs_proc_cells ? _p : NULL; + return _p != &afs_proc_cells ? _p : NULL; } /* end afs_proc_cells_start() */ /*****************************************************************************/ @@ -210,9 +238,9 @@ static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos) (*pos)++; _p = v; - _p = v==(void*)1 ? afs_proc_cells.next : _p->next; + _p = v == (void *) 1 ? afs_proc_cells.next : _p->next; - return _p!=&afs_proc_cells ? _p : NULL; + return _p != &afs_proc_cells ? _p : NULL; } /* end afs_proc_cells_next() */ /*****************************************************************************/ @@ -231,16 +259,16 @@ static void afs_proc_cells_stop(struct seq_file *p, void *v) */ static int afs_proc_cells_show(struct seq_file *m, void *v) { - afs_cell_t *cell = list_entry(v,afs_cell_t,proc_link); + struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link); /* display header on line 1 */ - if (v == (void *)1) { + if (v == (void *) 1) { seq_puts(m, "USE NAME\n"); return 0; } /* display one cell per line on subsequent lines */ - seq_printf(m,"%3d %s\n",atomic_read(&cell->usage),cell->name); + seq_printf(m, "%3d %s\n", atomic_read(&cell->usage), cell->name); return 0; } /* end afs_proc_cells_show() */ @@ -248,51 +276,61 @@ static int afs_proc_cells_show(struct seq_file *m, void *v) /*****************************************************************************/ /* * handle writes to /proc/fs/afs/cells - * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]* + * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]" */ -static ssize_t afs_proc_cells_write(struct file *file, const char *buf, size_t size, loff_t *_pos) +static ssize_t afs_proc_cells_write(struct file *file, const char *buf, + size_t size, loff_t *_pos) { char *kbuf, *name, *args; int ret; /* start by dragging the command into memory */ - if (size<=1 || size>=PAGE_SIZE) + if (size <= 1 || size >= PAGE_SIZE) return -EINVAL; - kbuf = kmalloc(size+1,GFP_KERNEL); + kbuf = kmalloc(size + 1, GFP_KERNEL); if (!kbuf) return -ENOMEM; ret = -EFAULT; - if (copy_from_user(kbuf,buf,size)!=0) + if (copy_from_user(kbuf, buf, size) != 0) goto done; kbuf[size] = 0; /* trim to first NL */ - name = memchr(kbuf,'\n',size); - if (name) *name = 0; + name = memchr(kbuf, '\n', size); + if (name) + *name = 0; /* split into command, name and argslist */ - name = strchr(kbuf,' '); - if (!name) goto inval; - do { *name++ = 0; } while(*name==' '); - if (!*name) goto inval; + name = strchr(kbuf, ' '); + if (!name) + goto inval; + do { + *name++ = 0; + } while(*name == ' '); + if (!*name) + goto inval; - args = strchr(name,' '); - if (!args) goto inval; - do { *args++ = 0; } while(*args==' '); - if (!*args) goto inval; + args = strchr(name, ' '); + if (!args) + goto inval; + do { + *args++ = 0; + } while(*args == ' '); + if (!*args) + goto inval; /* determine command to perform */ - _debug("cmd=%s name=%s args=%s",kbuf,name,args); + _debug("cmd=%s name=%s args=%s", kbuf, name, args); - if (strcmp(kbuf,"add")==0) { - afs_cell_t *cell; - ret = afs_cell_create(name,args,&cell); - if (ret<0) + if (strcmp(kbuf, "add") == 0) { + struct afs_cell *cell; + ret = afs_cell_create(name, args, &cell); + if (ret < 0) goto done; - printk("kAFS: Added new cell '%s'\n",name); + printk("kAFS: Added new cell '%s'\n", name); } else { goto inval; @@ -302,7 +340,7 @@ static ssize_t afs_proc_cells_write(struct file *file, const char *buf, size_t s done: kfree(kbuf); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; inval: @@ -313,33 +351,97 @@ static ssize_t afs_proc_cells_write(struct file *file, const char *buf, size_t s /*****************************************************************************/ /* + * Stubs for /proc/fs/afs/rootcell + */ +static int afs_proc_rootcell_open(struct inode *inode, struct file *file) +{ + return 0; +} + +static int afs_proc_rootcell_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static ssize_t afs_proc_rootcell_read(struct file *file, char *buf, + size_t size, loff_t *_pos) +{ + return 0; +} + +/*****************************************************************************/ +/* + * handle writes to /proc/fs/afs/rootcell + * - to initialize rootcell: echo "cell.name:192.168.231.14" + */ +static ssize_t afs_proc_rootcell_write(struct file *file, const char *buf, + size_t size, loff_t *_pos) +{ + char *kbuf, *s; + int ret; + + /* start by dragging the command into memory */ + if (size <= 1 || size >= PAGE_SIZE) + return -EINVAL; + + ret = -ENOMEM; + kbuf = kmalloc(size + 1, GFP_KERNEL); + if (!kbuf) + goto nomem; + + ret = -EFAULT; + if (copy_from_user(kbuf, buf, size) != 0) + goto infault; + kbuf[size] = 0; + + /* trim to first NL */ + s = memchr(kbuf, '\n', size); + if (s) + *s = 0; + + /* determine command to perform */ + _debug("rootcell=%s", kbuf); + + ret = afs_cell_init(kbuf); + if (ret >= 0) + ret = size; /* consume everything, always */ + + infault: + kfree(kbuf); + nomem: + _leave(" = %d", ret); + return ret; +} /* end afs_proc_rootcell_write() */ + +/*****************************************************************************/ +/* * initialise /proc/fs/afs/<cell>/ */ -int afs_proc_cell_setup(afs_cell_t *cell) +int afs_proc_cell_setup(struct afs_cell *cell) { struct proc_dir_entry *p; - _enter("%p{%s}",cell,cell->name); + _enter("%p{%s}", cell, cell->name); - cell->proc_dir = proc_mkdir(cell->name,proc_afs); + cell->proc_dir = proc_mkdir(cell->name, proc_afs); if (!cell->proc_dir) return -ENOMEM; - p = create_proc_entry("servers",0,cell->proc_dir); + p = create_proc_entry("servers", 0, cell->proc_dir); if (!p) goto error_proc; p->proc_fops = &afs_proc_cell_servers_fops; p->owner = THIS_MODULE; p->data = cell; - p = create_proc_entry("vlservers",0,cell->proc_dir); + p = create_proc_entry("vlservers", 0, cell->proc_dir); if (!p) goto error_servers; p->proc_fops = &afs_proc_cell_vlservers_fops; p->owner = THIS_MODULE; p->data = cell; - p = create_proc_entry("volumes",0,cell->proc_dir); + p = create_proc_entry("volumes", 0, cell->proc_dir); if (!p) goto error_vlservers; p->proc_fops = &afs_proc_cell_volumes_fops; @@ -350,11 +452,11 @@ int afs_proc_cell_setup(afs_cell_t *cell) return 0; error_vlservers: - remove_proc_entry("vlservers",cell->proc_dir); + remove_proc_entry("vlservers", cell->proc_dir); error_servers: - remove_proc_entry("servers",cell->proc_dir); + remove_proc_entry("servers", cell->proc_dir); error_proc: - remove_proc_entry(cell->name,proc_afs); + remove_proc_entry(cell->name, proc_afs); _leave(" = -ENOMEM"); return -ENOMEM; } /* end afs_proc_cell_setup() */ @@ -363,14 +465,14 @@ int afs_proc_cell_setup(afs_cell_t *cell) /* * remove /proc/fs/afs/<cell>/ */ -void afs_proc_cell_remove(afs_cell_t *cell) +void afs_proc_cell_remove(struct afs_cell *cell) { _enter(""); - remove_proc_entry("volumes",cell->proc_dir); - remove_proc_entry("vlservers",cell->proc_dir); - remove_proc_entry("servers",cell->proc_dir); - remove_proc_entry(cell->name,proc_afs); + remove_proc_entry("volumes", cell->proc_dir); + remove_proc_entry("vlservers", cell->proc_dir); + remove_proc_entry("servers", cell->proc_dir); + remove_proc_entry(cell->name, proc_afs); _leave(""); } /* end afs_proc_cell_remove() */ @@ -381,16 +483,16 @@ void afs_proc_cell_remove(afs_cell_t *cell) */ static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file) { + struct afs_cell *cell; struct seq_file *m; - afs_cell_t *cell; int ret; - cell = afs_get_cell_maybe((afs_cell_t**)&PDE(inode)->data); + cell = afs_get_cell_maybe((struct afs_cell **) &PDE(inode)->data); if (!cell) return -ENOENT; - ret = seq_open(file,&afs_proc_cell_volumes_ops); - if (ret<0) + ret = seq_open(file, &afs_proc_cell_volumes_ops); + if (ret < 0) return ret; m = file->private_data; @@ -405,7 +507,7 @@ static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file) */ static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file) { - afs_cell_t *cell = PDE(inode)->data; + struct afs_cell *cell = PDE(inode)->data; int ret; ret = seq_release(inode,file); @@ -417,49 +519,51 @@ static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file) /*****************************************************************************/ /* - * set up the iterator to start reading from the cells list and return the first item + * set up the iterator to start reading from the cells list and return the + * first item */ static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos) { struct list_head *_p; - afs_cell_t *cell = m->private; + struct afs_cell *cell = m->private; loff_t pos = *_pos; - _enter("cell=%p pos=%Ld",cell,*_pos); + _enter("cell=%p pos=%Ld", cell, *_pos); /* lock the list against modification */ down_read(&cell->vl_sem); /* allow for the header line */ if (!pos) - return (void *)1; + return (void *) 1; pos--; /* find the n'th element in the list */ - list_for_each(_p,&cell->vl_list) + list_for_each(_p, &cell->vl_list) if (!pos--) break; - return _p!=&cell->vl_list ? _p : NULL; + return _p != &cell->vl_list ? _p : NULL; } /* end afs_proc_cell_volumes_start() */ /*****************************************************************************/ /* * move to next cell in cells list */ -static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, loff_t *_pos) +static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, + loff_t *_pos) { struct list_head *_p; - afs_cell_t *cell = p->private; + struct afs_cell *cell = p->private; - _enter("cell=%p pos=%Ld",cell,*_pos); + _enter("cell=%p pos=%Ld", cell, *_pos); (*_pos)++; _p = v; - _p = v==(void*)1 ? cell->vl_list.next : _p->next; + _p = v == (void *) 1 ? cell->vl_list.next : _p->next; - return _p!=&cell->vl_list ? _p : NULL; + return _p != &cell->vl_list ? _p : NULL; } /* end afs_proc_cell_volumes_next() */ /*****************************************************************************/ @@ -468,7 +572,7 @@ static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, loff_t *_po */ static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v) { - afs_cell_t *cell = p->private; + struct afs_cell *cell = p->private; up_read(&cell->vl_sem); @@ -480,16 +584,17 @@ static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v) */ static int afs_proc_cell_volumes_show(struct seq_file *m, void *v) { - afs_vlocation_t *vlocation = list_entry(v,afs_vlocation_t,link); + struct afs_vlocation *vlocation = + list_entry(v, struct afs_vlocation, link); /* display header on line 1 */ - if (v == (void *)1) { + if (v == (void *) 1) { seq_puts(m, "USE VLID[0] VLID[1] VLID[2] NAME\n"); return 0; } /* display one cell per line on subsequent lines */ - seq_printf(m,"%3d %08x %08x %08x %s\n", + seq_printf(m, "%3d %08x %08x %08x %s\n", atomic_read(&vlocation->usage), vlocation->vldb.vid[0], vlocation->vldb.vid[1], @@ -502,15 +607,16 @@ static int afs_proc_cell_volumes_show(struct seq_file *m, void *v) /*****************************************************************************/ /* - * open "/proc/fs/afs/<cell>/vlservers" which provides a list of volume location server + * open "/proc/fs/afs/<cell>/vlservers" which provides a list of volume + * location server */ static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file) { + struct afs_cell *cell; struct seq_file *m; - afs_cell_t *cell; int ret; - cell = afs_get_cell_maybe((afs_cell_t**)&PDE(inode)->data); + cell = afs_get_cell_maybe((struct afs_cell**)&PDE(inode)->data); if (!cell) return -ENOENT; @@ -528,9 +634,10 @@ static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file) /* * close the file and release the ref to the cell */ -static int afs_proc_cell_vlservers_release(struct inode *inode, struct file *file) +static int afs_proc_cell_vlservers_release(struct inode *inode, + struct file *file) { - afs_cell_t *cell = PDE(inode)->data; + struct afs_cell *cell = PDE(inode)->data; int ret; ret = seq_release(inode,file); @@ -542,24 +649,25 @@ static int afs_proc_cell_vlservers_release(struct inode *inode, struct file *fil /*****************************************************************************/ /* - * set up the iterator to start reading from the cells list and return the first item + * set up the iterator to start reading from the cells list and return the + * first item */ static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos) { - afs_cell_t *cell = m->private; + struct afs_cell *cell = m->private; loff_t pos = *_pos; - _enter("cell=%p pos=%Ld",cell,*_pos); + _enter("cell=%p pos=%Ld", cell, *_pos); /* lock the list against modification */ down_read(&cell->vl_sem); /* allow for the header line */ if (!pos) - return (void *)1; + return (void *) 1; pos--; - if (pos>=cell->vl_naddrs) + if (pos >= cell->vl_naddrs) return NULL; return &cell->vl_addrs[pos]; @@ -569,16 +677,17 @@ static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos) /* * move to next cell in cells list */ -static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, loff_t *_pos) +static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, + loff_t *_pos) { - afs_cell_t *cell = p->private; + struct afs_cell *cell = p->private; loff_t pos; - _enter("cell=%p{nad=%u} pos=%Ld",cell,cell->vl_naddrs,*_pos); + _enter("cell=%p{nad=%u} pos=%Ld", cell, cell->vl_naddrs, *_pos); pos = *_pos; (*_pos)++; - if (pos>=cell->vl_naddrs) + if (pos >= cell->vl_naddrs) return NULL; return &cell->vl_addrs[pos]; @@ -590,7 +699,7 @@ static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, loff_t *_ */ static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v) { - afs_cell_t *cell = p->private; + struct afs_cell *cell = p->private; up_read(&cell->vl_sem); @@ -605,33 +714,34 @@ static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v) struct in_addr *addr = v; /* display header on line 1 */ - if (v == (struct in_addr *)1) { - seq_puts(m,"ADDRESS\n"); + if (v == (struct in_addr *) 1) { + seq_puts(m, "ADDRESS\n"); return 0; } /* display one cell per line on subsequent lines */ - seq_printf(m,"%u.%u.%u.%u\n",NIPQUAD(addr->s_addr)); + seq_printf(m, "%u.%u.%u.%u\n", NIPQUAD(addr->s_addr)); return 0; } /* end afs_proc_cell_vlservers_show() */ /*****************************************************************************/ /* - * open "/proc/fs/afs/<cell>/servers" which provides a summary of active servers + * open "/proc/fs/afs/<cell>/servers" which provides a summary of active + * servers */ static int afs_proc_cell_servers_open(struct inode *inode, struct file *file) { + struct afs_cell *cell; struct seq_file *m; - afs_cell_t *cell; int ret; - cell = afs_get_cell_maybe((afs_cell_t**)&PDE(inode)->data); + cell = afs_get_cell_maybe((struct afs_cell **) &PDE(inode)->data); if (!cell) return -ENOENT; - ret = seq_open(file,&afs_proc_cell_servers_ops); - if (ret<0) + ret = seq_open(file, &afs_proc_cell_servers_ops); + if (ret < 0) return ret; m = file->private_data; @@ -644,12 +754,13 @@ static int afs_proc_cell_servers_open(struct inode *inode, struct file *file) /* * close the file and release the ref to the cell */ -static int afs_proc_cell_servers_release(struct inode *inode, struct file *file) +static int afs_proc_cell_servers_release(struct inode *inode, + struct file *file) { - afs_cell_t *cell = PDE(inode)->data; + struct afs_cell *cell = PDE(inode)->data; int ret; - ret = seq_release(inode,file); + ret = seq_release(inode, file); afs_put_cell(cell); @@ -658,49 +769,51 @@ static int afs_proc_cell_servers_release(struct inode *inode, struct file *file) /*****************************************************************************/ /* - * set up the iterator to start reading from the cells list and return the first item + * set up the iterator to start reading from the cells list and return the + * first item */ static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos) { struct list_head *_p; - afs_cell_t *cell = m->private; + struct afs_cell *cell = m->private; loff_t pos = *_pos; - _enter("cell=%p pos=%Ld",cell,*_pos); + _enter("cell=%p pos=%Ld", cell, *_pos); /* lock the list against modification */ read_lock(&cell->sv_lock); /* allow for the header line */ if (!pos) - return (void *)1; + return (void *) 1; pos--; /* find the n'th element in the list */ - list_for_each(_p,&cell->sv_list) + list_for_each(_p, &cell->sv_list) if (!pos--) break; - return _p!=&cell->sv_list ? _p : NULL; + return _p != &cell->sv_list ? _p : NULL; } /* end afs_proc_cell_servers_start() */ /*****************************************************************************/ /* * move to next cell in cells list */ -static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, loff_t *_pos) +static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, + loff_t *_pos) { struct list_head *_p; - afs_cell_t *cell = p->private; + struct afs_cell *cell = p->private; - _enter("cell=%p pos=%Ld",cell,*_pos); + _enter("cell=%p pos=%Ld", cell, *_pos); (*_pos)++; _p = v; - _p = v==(void*)1 ? cell->sv_list.next : _p->next; + _p = v == (void *) 1 ? cell->sv_list.next : _p->next; - return _p!=&cell->sv_list ? _p : NULL; + return _p != &cell->sv_list ? _p : NULL; } /* end afs_proc_cell_servers_next() */ /*****************************************************************************/ @@ -709,7 +822,7 @@ static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, loff_t *_po */ static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) { - afs_cell_t *cell = p->private; + struct afs_cell *cell = p->private; read_unlock(&cell->sv_lock); @@ -721,18 +834,18 @@ static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) */ static int afs_proc_cell_servers_show(struct seq_file *m, void *v) { - afs_server_t *server = list_entry(v,afs_server_t,link); + struct afs_server *server = list_entry(v, struct afs_server, link); char ipaddr[20]; /* display header on line 1 */ - if (v == (void *)1) { + if (v == (void *) 1) { seq_puts(m, "USE ADDR STATE\n"); return 0; } /* display one cell per line on subsequent lines */ - sprintf(ipaddr,"%u.%u.%u.%u",NIPQUAD(server->addr)); - seq_printf(m,"%3d %-15.15s %5d\n", + sprintf(ipaddr, "%u.%u.%u.%u", NIPQUAD(server->addr)); + seq_printf(m, "%3d %-15.15s %5d\n", atomic_read(&server->usage), ipaddr, server->fs_state diff --git a/fs/afs/server.c b/fs/afs/server.c index 0d9d404b1d6f..fbfc28e3eded 100644 --- a/fs/afs/server.c +++ b/fs/afs/server.c @@ -26,11 +26,13 @@ spinlock_t afs_server_peer_lock = SPIN_LOCK_UNLOCKED; #define FS_SERVICE_ID 1 /* AFS Volume Location Service ID */ #define VL_SERVICE_ID 52 /* AFS Volume Location Service ID */ -static void __afs_server_timeout(afs_timer_t *timer) +static void __afs_server_timeout(struct afs_timer *timer) { - afs_server_t *server = list_entry(timer,afs_server_t,timeout); + struct afs_server *server = + list_entry(timer, struct afs_server, timeout); - _debug("SERVER TIMEOUT [%p{u=%d}]",server,atomic_read(&server->usage)); + _debug("SERVER TIMEOUT [%p{u=%d}]", + server, atomic_read(&server->usage)); afs_server_do_timeout(server); } @@ -44,23 +46,23 @@ static const struct afs_timer_ops afs_server_timer_ops = { * lookup a server record in a cell * - TODO: search the cell's server list */ -int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t **_server) +int afs_server_lookup(struct afs_cell *cell, const struct in_addr *addr, + struct afs_server **_server) { - struct list_head *_p; - afs_server_t *server, *active, *zombie; + struct afs_server *server, *active, *zombie; int loop; - _enter("%p,%08x,",cell,ntohl(addr->s_addr)); + _enter("%p,%08x,", cell, ntohl(addr->s_addr)); /* allocate and initialise a server record */ - server = kmalloc(sizeof(afs_server_t),GFP_KERNEL); + server = kmalloc(sizeof(struct afs_server), GFP_KERNEL); if (!server) { _leave(" = -ENOMEM"); return -ENOMEM; } - memset(server,0,sizeof(afs_server_t)); - atomic_set(&server->usage,1); + memset(server, 0, sizeof(struct afs_server)); + atomic_set(&server->usage, 1); INIT_LIST_HEAD(&server->link); init_rwsem(&server->sem); @@ -69,43 +71,39 @@ int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t INIT_LIST_HEAD(&server->cb_promises); spin_lock_init(&server->cb_lock); - for (loop=0; loop<AFS_SERVER_CONN_LIST_SIZE; loop++) + for (loop = 0; loop < AFS_SERVER_CONN_LIST_SIZE; loop++) server->fs_conn_cnt[loop] = 4; - memcpy(&server->addr,addr,sizeof(struct in_addr)); + memcpy(&server->addr, addr, sizeof(struct in_addr)); server->addr.s_addr = addr->s_addr; - afs_timer_init(&server->timeout,&afs_server_timer_ops); + afs_timer_init(&server->timeout, &afs_server_timer_ops); /* add to the cell */ write_lock(&cell->sv_lock); /* check the active list */ - list_for_each(_p,&cell->sv_list) { - active = list_entry(_p,afs_server_t,link); - - if (active->addr.s_addr==addr->s_addr) + list_for_each_entry(active, &cell->sv_list, link) { + if (active->addr.s_addr == addr->s_addr) goto use_active_server; } /* check the inactive list */ spin_lock(&cell->sv_gylock); - list_for_each(_p,&cell->sv_graveyard) { - zombie = list_entry(_p,afs_server_t,link); - - if (zombie->addr.s_addr==addr->s_addr) + list_for_each_entry(zombie, &cell->sv_graveyard, link) { + if (zombie->addr.s_addr == addr->s_addr) goto resurrect_server; } spin_unlock(&cell->sv_gylock); afs_get_cell(cell); server->cell = cell; - list_add_tail(&server->link,&cell->sv_list); + list_add_tail(&server->link, &cell->sv_list); write_unlock(&cell->sv_lock); *_server = server; - _leave(" = 0 (%p)",server); + _leave(" = 0 (%p)", server); return 0; /* found a matching active server */ @@ -117,15 +115,16 @@ int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t kfree(server); *_server = active; - _leave(" = 0 (%p)",active); + _leave(" = 0 (%p)", active); return 0; - /* found a matching server in the graveyard, so resurrect it and dispose of the new rec */ + /* found a matching server in the graveyard, so resurrect it and + * dispose of the new record */ resurrect_server: _debug("resurrecting server"); list_del(&zombie->link); - list_add_tail(&zombie->link,&cell->sv_list); + list_add_tail(&zombie->link, &cell->sv_list); afs_get_server(zombie); afs_kafstimod_del_timer(&zombie->timeout); spin_unlock(&cell->sv_gylock); @@ -134,7 +133,7 @@ int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t kfree(server); *_server = zombie; - _leave(" = 0 (%p)",zombie); + _leave(" = 0 (%p)", zombie); return 0; } /* end afs_server_lookup() */ @@ -144,22 +143,22 @@ int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t * destroy a server record * - removes from the cell list */ -void afs_put_server(afs_server_t *server) +void afs_put_server(struct afs_server *server) { - afs_cell_t *cell; + struct afs_cell *cell; if (!server) return; - _enter("%p",server); + _enter("%p", server); cell = server->cell; /* sanity check */ - if (atomic_read(&server->usage)<=0) - BUG(); + BUG_ON(atomic_read(&server->usage) <= 0); - /* to prevent a race, the decrement and the dequeue must be effectively atomic */ + /* to prevent a race, the decrement and the dequeue must be effectively + * atomic */ write_lock(&cell->sv_lock); if (likely(!atomic_dec_and_test(&server->usage))) { @@ -170,10 +169,10 @@ void afs_put_server(afs_server_t *server) spin_lock(&cell->sv_gylock); list_del(&server->link); - list_add_tail(&server->link,&cell->sv_graveyard); + list_add_tail(&server->link, &cell->sv_graveyard); /* time out in 10 secs */ - afs_kafstimod_add_timer(&server->timeout,10*HZ); + afs_kafstimod_add_timer(&server->timeout, 10 * HZ); spin_unlock(&cell->sv_gylock); write_unlock(&cell->sv_lock); @@ -186,21 +185,21 @@ void afs_put_server(afs_server_t *server) * timeout server record * - removes from the cell's graveyard if the usage count is zero */ -void afs_server_do_timeout(afs_server_t *server) +void afs_server_do_timeout(struct afs_server *server) { struct rxrpc_peer *peer; - afs_cell_t *cell; + struct afs_cell *cell; int loop; - _enter("%p",server); + _enter("%p", server); cell = server->cell; - if (atomic_read(&server->usage)<0) BUG(); + BUG_ON(atomic_read(&server->usage) < 0); /* remove from graveyard if still dead */ spin_lock(&cell->vl_gylock); - if (atomic_read(&server->usage)==0) + if (atomic_read(&server->usage) == 0) list_del_init(&server->link); else server = NULL; @@ -224,7 +223,7 @@ void afs_server_do_timeout(afs_server_t *server) spin_unlock(&afs_server_peer_lock); /* finish cleaning up the server */ - for (loop=AFS_SERVER_CONN_LIST_SIZE-1; loop>=0; loop--) + for (loop = AFS_SERVER_CONN_LIST_SIZE - 1; loop >= 0; loop--) if (server->fs_conn[loop]) rxrpc_put_connection(server->fs_conn[loop]); @@ -240,7 +239,8 @@ void afs_server_do_timeout(afs_server_t *server) /* * get a callslot on a connection to the fileserver on the specified server */ -int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot *callslot) +int afs_server_request_callslot(struct afs_server *server, + struct afs_server_callslot *callslot) { struct afs_server_callslot *pcallslot; struct rxrpc_connection *conn; @@ -262,10 +262,10 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot /* resurrect the server if it's death timeout has expired */ if (server->fs_state) { - if (time_before(jiffies,server->fs_dead_jif)) { + if (time_before(jiffies, server->fs_dead_jif)) { ret = server->fs_state; spin_unlock(&server->fs_lock); - _leave(" = %d [still dead]",ret); + _leave(" = %d [still dead]", ret); return ret; } @@ -273,8 +273,8 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot } /* try and find a connection that has spare callslots */ - for (nconn=0; nconn<AFS_SERVER_CONN_LIST_SIZE; nconn++) { - if (server->fs_conn_cnt[nconn]>0) { + for (nconn = 0; nconn < AFS_SERVER_CONN_LIST_SIZE; nconn++) { + if (server->fs_conn_cnt[nconn] > 0) { server->fs_conn_cnt[nconn]--; spin_unlock(&server->fs_lock); callslot->nconn = nconn; @@ -282,9 +282,10 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot } } - /* none were available - wait interruptibly for one to become available */ + /* none were available - wait interruptibly for one to become + * available */ set_current_state(TASK_INTERRUPTIBLE); - list_add_tail(&callslot->link,&server->fs_callq); + list_add_tail(&callslot->link, &server->fs_callq); spin_unlock(&server->fs_lock); while (!callslot->ready && !signal_pending(current)) { @@ -303,22 +304,24 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot nconn = callslot->nconn; - /* if interrupted, we must release any slot we also got before returning an error */ + /* if interrupted, we must release any slot we also got before + * returning an error */ if (signal_pending(current)) { ret = -EINTR; goto error_release; } - /* if we were woken up with an error, then pass that error back to the called */ - if (nconn<0) { - _leave(" = %d",callslot->errno); + /* if we were woken up with an error, then pass that error back to the + * called */ + if (nconn < 0) { + _leave(" = %d", callslot->errno); return callslot->errno; } /* were we given a connection directly? */ if (callslot->conn) { /* yes - use it */ - _leave(" = 0 (nc=%d)",nconn); + _leave(" = 0 (nc=%d)", nconn); return 0; } @@ -347,7 +350,7 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot NULL, &server->fs_conn[nconn]); - if (ret<0) + if (ret < 0) goto error_release_upw; callslot->conn = server->fs_conn[0]; @@ -364,10 +367,11 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot up_write(&server->sem); error_release: - /* either release the callslot or pass it along to another deserving task */ + /* either release the callslot or pass it along to another deserving + * task */ spin_lock(&server->fs_lock); - if (nconn<0) { + if (nconn < 0) { /* no callslot allocated */ } else if (list_empty(&server->fs_callq)) { @@ -377,13 +381,15 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot } else { /* someone's waiting - dequeue them and wake them up */ - pcallslot = list_entry(server->fs_callq.next,struct afs_server_callslot,link); + pcallslot = list_entry(server->fs_callq.next, + struct afs_server_callslot, link); list_del_init(&pcallslot->link); pcallslot->errno = server->fs_state; if (!pcallslot->errno) { /* pass them out callslot details */ - callslot->conn = xchg(&pcallslot->conn,callslot->conn); + callslot->conn = xchg(&pcallslot->conn, + callslot->conn); pcallslot->nconn = nconn; callslot->nconn = nconn = -1; } @@ -392,10 +398,10 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot spin_unlock(&server->fs_lock); } - if (callslot->conn) rxrpc_put_connection(callslot->conn); + rxrpc_put_connection(callslot->conn); callslot->conn = NULL; - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_server_request_callslot() */ @@ -405,7 +411,8 @@ int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot * release a callslot back to the server * - transfers the RxRPC connection to the next pending callslot if possible */ -void afs_server_release_callslot(afs_server_t *server, struct afs_server_callslot *callslot) +void afs_server_release_callslot(struct afs_server *server, + struct afs_server_callslot *callslot) { struct afs_server_callslot *pcallslot; @@ -414,7 +421,7 @@ void afs_server_release_callslot(afs_server_t *server, struct afs_server_callslo server->fs_conn_cnt[callslot->nconn], callslot->nconn); - if (callslot->nconn<0) BUG(); + BUG_ON(callslot->nconn < 0); spin_lock(&server->fs_lock); @@ -425,13 +432,14 @@ void afs_server_release_callslot(afs_server_t *server, struct afs_server_callslo } else { /* someone's waiting - dequeue them and wake them up */ - pcallslot = list_entry(server->fs_callq.next,struct afs_server_callslot,link); + pcallslot = list_entry(server->fs_callq.next, + struct afs_server_callslot, link); list_del_init(&pcallslot->link); pcallslot->errno = server->fs_state; if (!pcallslot->errno) { /* pass them out callslot details */ - callslot->conn = xchg(&pcallslot->conn,callslot->conn); + callslot->conn = xchg(&pcallslot->conn, callslot->conn); pcallslot->nconn = callslot->nconn; callslot->nconn = -1; } @@ -441,21 +449,23 @@ void afs_server_release_callslot(afs_server_t *server, struct afs_server_callslo spin_unlock(&server->fs_lock); } - if (callslot->conn) rxrpc_put_connection(callslot->conn); + rxrpc_put_connection(callslot->conn); _leave(""); } /* end afs_server_release_callslot() */ /*****************************************************************************/ /* - * get a handle to a connection to the vlserver (volume location) on the specified server + * get a handle to a connection to the vlserver (volume location) on the + * specified server */ -int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn) +int afs_server_get_vlconn(struct afs_server *server, + struct rxrpc_connection **_conn) { struct rxrpc_connection *conn; int ret; - _enter("%p,",server); + _enter("%p,", server); ret = 0; conn = NULL; @@ -479,7 +489,7 @@ int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn) NULL, &server->vlserver); } - if (ret==0) { + if (ret == 0) { rxrpc_get_connection(server->vlserver); conn = server->vlserver; } @@ -487,6 +497,6 @@ int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn) } *_conn = conn; - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_server_get_vlconn() */ diff --git a/fs/afs/server.h b/fs/afs/server.h index feddacf2c954..c3d24115578f 100644 --- a/fs/afs/server.h +++ b/fs/afs/server.h @@ -26,10 +26,10 @@ extern spinlock_t afs_server_peer_lock; struct afs_server { atomic_t usage; - afs_cell_t *cell; /* cell in which server resides */ + struct afs_cell *cell; /* cell in which server resides */ struct list_head link; /* link in cell's server list */ struct rw_semaphore sem; /* access lock */ - afs_timer_t timeout; /* graveyard timeout */ + struct afs_timer timeout; /* graveyard timeout */ struct in_addr addr; /* server address */ struct rxrpc_peer *peer; /* peer record for this server */ struct rxrpc_connection *vlserver; /* connection to the volume location service */ @@ -50,20 +50,25 @@ struct afs_server spinlock_t cb_lock; /* access lock */ }; -extern int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t **_server); +extern int afs_server_lookup(struct afs_cell *cell, + const struct in_addr *addr, + struct afs_server **_server); #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0) -extern void afs_put_server(afs_server_t *server); -extern void afs_server_do_timeout(afs_server_t *server); +extern void afs_put_server(struct afs_server *server); +extern void afs_server_do_timeout(struct afs_server *server); -extern int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_server); +extern int afs_server_find_by_peer(const struct rxrpc_peer *peer, + struct afs_server **_server); -extern int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn); +extern int afs_server_get_vlconn(struct afs_server *server, + struct rxrpc_connection **_conn); -static inline afs_server_t *afs_server_get_from_peer(struct rxrpc_peer *peer) +static inline +struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer) { - afs_server_t *server; + struct afs_server *server; spin_lock(&afs_server_peer_lock); server = peer->user; @@ -88,10 +93,10 @@ struct afs_server_callslot int errno; /* error number if nconn==-1 */ }; -extern int afs_server_request_callslot(afs_server_t *server, +extern int afs_server_request_callslot(struct afs_server *server, struct afs_server_callslot *callslot); -extern void afs_server_release_callslot(afs_server_t *server, +extern void afs_server_release_callslot(struct afs_server *server, struct afs_server_callslot *callslot); #endif /* _LINUX_AFS_SERVER_H */ diff --git a/fs/afs/super.c b/fs/afs/super.c index ac65a1fb6009..0b4e216b53b0 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c @@ -35,14 +35,6 @@ struct afs_mount_params { struct afs_volume *volume; }; -static inline char *strdup(const char *s) -{ - char *ns = kmalloc(strlen(s) + 1, GFP_KERNEL); - if (ns) - strcpy(ns, s); - return ns; -} - static void afs_i_init_once(void *foo, kmem_cache_t *cachep, unsigned long flags); @@ -94,7 +86,7 @@ int __init afs_fs_init(void) ret = -ENOMEM; afs_inode_cachep = kmem_cache_create("afs_inode_cache", - sizeof(afs_vnode_t), + sizeof(struct afs_vnode), 0, SLAB_HWCACHE_ALIGN, afs_i_init_once, @@ -164,8 +156,8 @@ static int want_no_value(char *const *_value, const char *option) /*****************************************************************************/ /* * parse the mount options - * - this function has been shamelessly adapted from the ext3 fs which shamelessly adapted it from - * the msdos fs + * - this function has been shamelessly adapted from the ext3 fs which + * shamelessly adapted it from the msdos fs */ static int afs_super_parse_options(struct afs_mount_params *params, char *options, @@ -243,9 +235,9 @@ static int afs_fill_super(struct super_block *sb, void *data, int silent) { struct afs_mount_params *params = data; struct afs_super_info *as = NULL; + struct afs_fid fid; struct dentry *root = NULL; struct inode *inode = NULL; - afs_fid_t fid; int ret; kenter(""); @@ -395,7 +387,7 @@ static void afs_put_super(struct super_block *sb) static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep, unsigned long flags) { - afs_vnode_t *vnode = (afs_vnode_t *) _vnode; + struct afs_vnode *vnode = (struct afs_vnode *) _vnode; if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) { @@ -417,9 +409,9 @@ static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep, */ static struct inode *afs_alloc_inode(struct super_block *sb) { - afs_vnode_t *vnode; + struct afs_vnode *vnode; - vnode = (afs_vnode_t *) + vnode = (struct afs_vnode *) kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL); if (!vnode) return NULL; diff --git a/fs/afs/types.h b/fs/afs/types.h index 2606f01e217a..27596b35dcc6 100644 --- a/fs/afs/types.h +++ b/fs/afs/types.h @@ -20,21 +20,6 @@ typedef unsigned afs_volid_t; typedef unsigned afs_vnodeid_t; typedef unsigned long long afs_dataversion_t; -typedef struct afs_async_op afs_async_op_t; -typedef struct afs_callback afs_callback_t; -typedef struct afs_cell afs_cell_t; -typedef struct afs_fid afs_fid_t; -typedef struct afs_file_status afs_file_status_t; -typedef struct afs_server afs_server_t; -typedef struct afs_timer afs_timer_t; -typedef struct afs_vlocation afs_vlocation_t; -typedef struct afs_vnode afs_vnode_t; -typedef struct afs_volsync afs_volsync_t; -typedef struct afs_volume afs_volume_t; -typedef struct afs_volume_info afs_volume_info_t; - -typedef struct afsvl_dbentry afsvl_dbentry_t; - typedef enum { AFSVL_RWVOL, /* read/write volume */ AFSVL_ROVOL, /* read-only volume */ @@ -52,6 +37,9 @@ typedef enum { #ifdef __KERNEL__ +struct afs_cell; +struct afs_vnode; + /*****************************************************************************/ /* * AFS file identifier @@ -76,8 +64,8 @@ typedef enum { struct afs_callback { - afs_server_t *server; /* server that made the promise */ - afs_fid_t fid; /* file identifier */ + struct afs_server *server; /* server that made the promise */ + struct afs_fid fid; /* file identifier */ unsigned version; /* callback version */ unsigned expiry; /* time at which expires */ afs_callback_type_t type; /* type of callback */ @@ -120,7 +108,7 @@ struct afs_file_status unsigned caller_access; /* access rights for authenticated caller */ unsigned anon_access; /* access rights for unauthenticated caller */ umode_t mode; /* UNIX mode */ - afs_fid_t parent; /* parent file ID */ + struct afs_fid parent; /* parent file ID */ time_t mtime_client; /* last time client changed data */ time_t mtime_server; /* last time server changed data */ }; diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c index fb3426786429..1a76f15cbf1d 100644 --- a/fs/afs/vlclient.c +++ b/fs/afs/vlclient.c @@ -39,7 +39,8 @@ static void afs_rxvl_aemap(struct rxrpc_call *call) { int err; - _enter("{%u,%u,%d}",call->app_err_state,call->app_abort_code,call->app_errno); + _enter("{%u,%u,%d}", + call->app_err_state, call->app_abort_code, call->app_errno); switch (call->app_err_state) { case RXRPC_ESTATE_LOCAL_ABORT: @@ -92,10 +93,8 @@ static void afs_rxvl_aemap(struct rxrpc_call *call) /* * probe a volume location server to see if it is still alive */ -int afs_rxvl_probe(afs_server_t *server, int alloc_flags) +int afs_rxvl_probe(struct afs_server *server, int alloc_flags) { - DECLARE_WAITQUEUE(myself,current); - struct rxrpc_connection *conn; struct rxrpc_call *call; struct iovec piov[1]; @@ -103,21 +102,23 @@ int afs_rxvl_probe(afs_server_t *server, int alloc_flags) int ret; u32 param[1]; + DECLARE_WAITQUEUE(myself, current); + /* get hold of the vlserver connection */ - ret = afs_server_get_vlconn(server,&conn); - if (ret<0) + ret = afs_server_get_vlconn(server, &conn); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(conn,NULL,NULL,afs_rxvl_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = VLPROBE; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ param[0] = htonl(VLPROBE); @@ -125,14 +126,15 @@ int afs_rxvl_probe(afs_server_t *server, int alloc_flags) piov[0].iov_base = param; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,alloc_flags,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, + alloc_flags, 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ for (;;) { set_current_state(TASK_INTERRUPTIBLE); - if (call->app_call_state!=RXRPC_CSTATE_CLNT_RCV_REPLY || + if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY || signal_pending(current)) break; schedule(); @@ -158,12 +160,12 @@ int afs_rxvl_probe(afs_server_t *server, int alloc_flags) abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: rxrpc_put_connection(conn); @@ -176,10 +178,12 @@ int afs_rxvl_probe(afs_server_t *server, int alloc_flags) /* * look up a volume location database entry by name */ -int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsigned volnamesz, +int afs_rxvl_get_entry_by_name(struct afs_server *server, + const char *volname, + unsigned volnamesz, struct afs_cache_vlocation *entry) { - DECLARE_WAITQUEUE(myself,current); + DECLARE_WAITQUEUE(myself, current); struct rxrpc_connection *conn; struct rxrpc_call *call; @@ -195,7 +199,7 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign /* get hold of the vlserver connection */ ret = afs_server_get_vlconn(server, &conn); - if (ret<0) + if (ret < 0) goto out; /* create a call through that connection */ @@ -211,7 +215,7 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign /* marshall the parameters */ piov[1].iov_len = volnamesz; - piov[1].iov_base = (char*) volname; + piov[1].iov_base = (char *) volname; zero = 0; piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3; @@ -224,14 +228,17 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign piov[0].iov_base = param; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS, 0, &sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ bp = rxrpc_call_alloc_scratch(call, 384); - ret = rxrpc_call_read_data(call, bp, 384, RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL); + ret = rxrpc_call_read_data(call, bp, 384, + RXRPC_CALL_READ_BLOCK | + RXRPC_CALL_READ_ALL); if (ret < 0) { if (ret == -ECONNABORTED) { ret = call->app_errno; @@ -241,23 +248,26 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign } /* unmarshall the reply */ - for (loop=0; loop<64; loop++) + for (loop = 0; loop < 64; loop++) entry->name[loop] = ntohl(*bp++); bp++; /* final NUL */ bp++; /* type */ entry->nservers = ntohl(*bp++); - for (loop=0; loop<8; loop++) + for (loop = 0; loop < 8; loop++) entry->servers[loop].s_addr = *bp++; bp += 8; /* partition IDs */ - for (loop=0; loop<8; loop++) { + for (loop = 0; loop < 8; loop++) { tmp = ntohl(*bp++); - if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW; - if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO; - if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK; + if (tmp & AFS_VLSF_RWVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_RW; + if (tmp & AFS_VLSF_ROVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_RO; + if (tmp & AFS_VLSF_BACKVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_BAK; } entry->vid[0] = ntohl(*bp++); @@ -267,9 +277,12 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign bp++; /* clone ID */ tmp = ntohl(*bp++); /* flags */ - if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFS_VOL_VTM_RW; - if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFS_VOL_VTM_RO; - if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK; + if (tmp & AFS_VLF_RWEXISTS) + entry->vidmask |= AFS_VOL_VTM_RW; + if (tmp & AFS_VLF_ROEXISTS) + entry->vidmask |= AFS_VOL_VTM_RO; + if (tmp & AFS_VLF_BACKEXISTS) + entry->vidmask |= AFS_VOL_VTM_BAK; ret = -ENOMEDIUM; if (!entry->vidmask) @@ -291,7 +304,7 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; } /* end afs_rxvl_get_entry_by_name() */ @@ -300,12 +313,12 @@ int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsign /* * look up a volume location database entry by ID */ -int afs_rxvl_get_entry_by_id(afs_server_t *server, +int afs_rxvl_get_entry_by_id(struct afs_server *server, afs_volid_t volid, afs_voltype_t voltype, struct afs_cache_vlocation *entry) { - DECLARE_WAITQUEUE(myself,current); + DECLARE_WAITQUEUE(myself, current); struct rxrpc_connection *conn; struct rxrpc_call *call; @@ -315,25 +328,25 @@ int afs_rxvl_get_entry_by_id(afs_server_t *server, int ret, loop; u32 *bp, param[3]; - _enter(",%x,%d,",volid,voltype); + _enter(",%x,%d,", volid, voltype); - memset(entry,0,sizeof(*entry)); + memset(entry, 0, sizeof(*entry)); /* get hold of the vlserver connection */ - ret = afs_server_get_vlconn(server,&conn); - if (ret<0) + ret = afs_server_get_vlconn(server, &conn); + if (ret < 0) goto out; /* create a call through that connection */ - ret = rxrpc_create_call(conn,NULL,NULL,afs_rxvl_aemap,&call); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); + ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); goto out_put_conn; } call->app_opcode = VLGETENTRYBYID; /* we want to get event notifications from the call */ - add_wait_queue(&call->waitq,&myself); + add_wait_queue(&call->waitq, &myself); /* marshall the parameters */ param[0] = htonl(VLGETENTRYBYID); @@ -344,16 +357,19 @@ int afs_rxvl_get_entry_by_id(afs_server_t *server, piov[0].iov_base = param; /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) goto abort; /* wait for the reply to completely arrive */ - bp = rxrpc_call_alloc_scratch(call,384); + bp = rxrpc_call_alloc_scratch(call, 384); - ret = rxrpc_call_read_data(call,bp,384,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL); - if (ret<0) { - if (ret==-ECONNABORTED) { + ret = rxrpc_call_read_data(call, bp, 384, + RXRPC_CALL_READ_BLOCK | + RXRPC_CALL_READ_ALL); + if (ret < 0) { + if (ret == -ECONNABORTED) { ret = call->app_errno; goto out_unwait; } @@ -361,23 +377,26 @@ int afs_rxvl_get_entry_by_id(afs_server_t *server, } /* unmarshall the reply */ - for (loop=0; loop<64; loop++) + for (loop = 0; loop < 64; loop++) entry->name[loop] = ntohl(*bp++); bp++; /* final NUL */ bp++; /* type */ entry->nservers = ntohl(*bp++); - for (loop=0; loop<8; loop++) + for (loop = 0; loop < 8; loop++) entry->servers[loop].s_addr = *bp++; bp += 8; /* partition IDs */ - for (loop=0; loop<8; loop++) { + for (loop = 0; loop < 8; loop++) { tmp = ntohl(*bp++); - if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW; - if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO; - if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK; + if (tmp & AFS_VLSF_RWVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_RW; + if (tmp & AFS_VLSF_ROVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_RO; + if (tmp & AFS_VLSF_BACKVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_BAK; } entry->vid[0] = ntohl(*bp++); @@ -387,9 +406,12 @@ int afs_rxvl_get_entry_by_id(afs_server_t *server, bp++; /* clone ID */ tmp = ntohl(*bp++); /* flags */ - if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFS_VOL_VTM_RW; - if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFS_VOL_VTM_RO; - if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK; + if (tmp & AFS_VLF_RWEXISTS) + entry->vidmask |= AFS_VOL_VTM_RW; + if (tmp & AFS_VLF_ROEXISTS) + entry->vidmask |= AFS_VOL_VTM_RO; + if (tmp & AFS_VLF_BACKEXISTS) + entry->vidmask |= AFS_VOL_VTM_BAK; ret = -ENOMEDIUM; if (!entry->vidmask) @@ -412,17 +434,17 @@ int afs_rxvl_get_entry_by_id(afs_server_t *server, out_unwait: set_current_state(TASK_RUNNING); - remove_wait_queue(&call->waitq,&myself); + remove_wait_queue(&call->waitq, &myself); rxrpc_put_call(call); out_put_conn: rxrpc_put_connection(conn); out: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; abort: set_current_state(TASK_UNINTERRUPTIBLE); - rxrpc_call_abort(call,ret); + rxrpc_call_abort(call, ret); schedule(); goto out_unwait; } /* end afs_rxvl_get_entry_by_id() */ @@ -431,7 +453,7 @@ int afs_rxvl_get_entry_by_id(afs_server_t *server, /* * look up a volume location database entry by ID asynchronously */ -int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, +int afs_rxvl_get_entry_by_id_async(struct afs_async_op *op, afs_volid_t volid, afs_voltype_t voltype) { @@ -442,12 +464,12 @@ int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, int ret; u32 param[3]; - _enter(",%x,%d,",volid,voltype); + _enter(",%x,%d,", volid, voltype); /* get hold of the vlserver connection */ - ret = afs_server_get_vlconn(op->server,&conn); - if (ret<0) { - _leave(" = %d",ret); + ret = afs_server_get_vlconn(op->server, &conn); + if (ret < 0) { + _leave(" = %d", ret); return ret; } @@ -459,9 +481,9 @@ int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, &op->call); rxrpc_put_connection(conn); - if (ret<0) { - printk("kAFS: Unable to create call: %d\n",ret); - _leave(" = %d",ret); + if (ret < 0) { + printk("kAFS: Unable to create call: %d\n", ret); + _leave(" = %d", ret); return ret; } @@ -483,18 +505,19 @@ int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, piov[0].iov_base = param; /* allocate result read buffer in scratch space */ - call->app_scr_ptr = rxrpc_call_alloc_scratch(op->call,384); + call->app_scr_ptr = rxrpc_call_alloc_scratch(op->call, 384); /* send the parameters to the server */ - ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent); - if (ret<0) { - rxrpc_call_abort(call,ret); /* handle from kafsasyncd */ + ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS, + 0, &sent); + if (ret < 0) { + rxrpc_call_abort(call, ret); /* handle from kafsasyncd */ ret = 0; goto out; } /* wait for the reply to completely arrive */ - ret = rxrpc_call_read_data(call,call->app_scr_ptr,384,0); + ret = rxrpc_call_read_data(call, call->app_scr_ptr, 384, 0); switch (ret) { case 0: case -EAGAIN: @@ -503,14 +526,14 @@ int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, break; /* all handled by kafsasyncd */ default: - rxrpc_call_abort(call,ret); /* force kafsasyncd to handle it */ + rxrpc_call_abort(call, ret); /* make kafsasyncd handle it */ ret = 0; break; } out: rxrpc_put_call(call); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_rxvl_get_entry_by_id_async() */ @@ -519,40 +542,43 @@ int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, /* * attend to the asynchronous get VLDB entry by ID */ -int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, +int afs_rxvl_get_entry_by_id_async2(struct afs_async_op *op, struct afs_cache_vlocation *entry) { unsigned *bp, tmp; int loop, ret; - _enter("{op=%p cst=%u}",op,op->call->app_call_state); + _enter("{op=%p cst=%u}", op, op->call->app_call_state); - memset(entry,0,sizeof(*entry)); + memset(entry, 0, sizeof(*entry)); - if (op->call->app_call_state==RXRPC_CSTATE_COMPLETE) { + if (op->call->app_call_state == RXRPC_CSTATE_COMPLETE) { /* operation finished */ afs_kafsasyncd_terminate_op(op); bp = op->call->app_scr_ptr; /* unmarshall the reply */ - for (loop=0; loop<64; loop++) + for (loop = 0; loop < 64; loop++) entry->name[loop] = ntohl(*bp++); bp++; /* final NUL */ bp++; /* type */ entry->nservers = ntohl(*bp++); - for (loop=0; loop<8; loop++) + for (loop = 0; loop < 8; loop++) entry->servers[loop].s_addr = *bp++; bp += 8; /* partition IDs */ - for (loop=0; loop<8; loop++) { + for (loop = 0; loop < 8; loop++) { tmp = ntohl(*bp++); - if (tmp & AFS_VLSF_RWVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW; - if (tmp & AFS_VLSF_ROVOL ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO; - if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK; + if (tmp & AFS_VLSF_RWVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_RW; + if (tmp & AFS_VLSF_ROVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_RO; + if (tmp & AFS_VLSF_BACKVOL) + entry->srvtmask[loop] |= AFS_VOL_VTM_BAK; } entry->vid[0] = ntohl(*bp++); @@ -562,13 +588,16 @@ int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, bp++; /* clone ID */ tmp = ntohl(*bp++); /* flags */ - if (tmp & AFS_VLF_RWEXISTS ) entry->vidmask |= AFS_VOL_VTM_RW; - if (tmp & AFS_VLF_ROEXISTS ) entry->vidmask |= AFS_VOL_VTM_RO; - if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK; + if (tmp & AFS_VLF_RWEXISTS) + entry->vidmask |= AFS_VOL_VTM_RW; + if (tmp & AFS_VLF_ROEXISTS) + entry->vidmask |= AFS_VOL_VTM_RO; + if (tmp & AFS_VLF_BACKEXISTS) + entry->vidmask |= AFS_VOL_VTM_BAK; ret = -ENOMEDIUM; if (!entry->vidmask) { - rxrpc_call_abort(op->call,ret); + rxrpc_call_abort(op->call, ret); goto done; } @@ -589,7 +618,7 @@ int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, goto done; } - if (op->call->app_call_state==RXRPC_CSTATE_ERROR) { + if (op->call->app_call_state == RXRPC_CSTATE_ERROR) { /* operation error */ ret = op->call->app_errno; goto done; @@ -601,7 +630,7 @@ int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, done: rxrpc_put_call(op->call); op->call = NULL; - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_rxvl_get_entry_by_id_async2() */ @@ -612,9 +641,9 @@ int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, */ static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call) { - afs_async_op_t *op = call->app_user; + struct afs_async_op *op = call->app_user; - _enter("{op=%p cst=%u}",op,call->app_call_state); + _enter("{op=%p cst=%u}", op, call->app_call_state); switch (call->app_call_state) { case RXRPC_CSTATE_COMPLETE: @@ -624,7 +653,7 @@ static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call) if (call->app_async_read) break; case RXRPC_CSTATE_CLNT_GOT_REPLY: - if (call->app_read_count==0) + if (call->app_read_count == 0) break; printk("kAFS: Reply bigger than expected" " {cst=%u asyn=%d mark=%Zu rdy=%Zu pr=%u%s}", @@ -635,7 +664,7 @@ static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call) call->pkt_rcv_count, call->app_last_rcv ? " last" : ""); - rxrpc_call_abort(call,-EBADMSG); + rxrpc_call_abort(call, -EBADMSG); break; default: BUG(); @@ -652,9 +681,9 @@ static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call) */ static void afs_rxvl_get_entry_by_id_error(struct rxrpc_call *call) { - afs_async_op_t *op = call->app_user; + struct afs_async_op *op = call->app_user; - _enter("{op=%p cst=%u}",op,call->app_call_state); + _enter("{op=%p cst=%u}", op, call->app_call_state); afs_kafsasyncd_attend_op(op); diff --git a/fs/afs/vlclient.h b/fs/afs/vlclient.h index 29f0784287cd..65b0b6e52085 100644 --- a/fs/afs/vlclient.h +++ b/fs/afs/vlclient.h @@ -72,25 +72,25 @@ struct afs_vldbentry { }; /* probe a volume location server to see if it is still alive */ -extern int afs_rxvl_probe(afs_server_t *server, int alloc_flags); +extern int afs_rxvl_probe(struct afs_server *server, int alloc_flags); /* look up a volume location database entry by name */ -extern int afs_rxvl_get_entry_by_name(afs_server_t *server, +extern int afs_rxvl_get_entry_by_name(struct afs_server *server, const char *volname, unsigned volnamesz, struct afs_cache_vlocation *entry); /* look up a volume location database entry by ID */ -extern int afs_rxvl_get_entry_by_id(afs_server_t *server, +extern int afs_rxvl_get_entry_by_id(struct afs_server *server, afs_volid_t volid, afs_voltype_t voltype, struct afs_cache_vlocation *entry); -extern int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op, +extern int afs_rxvl_get_entry_by_id_async(struct afs_async_op *op, afs_volid_t volid, afs_voltype_t voltype); -extern int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op, +extern int afs_rxvl_get_entry_by_id_async2(struct afs_async_op *op, struct afs_cache_vlocation *entry); #endif /* _LINUX_AFS_VLCLIENT_H */ diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c index 3042dea7517a..9cff6b687070 100644 --- a/fs/afs/vlocation.c +++ b/fs/afs/vlocation.c @@ -26,15 +26,17 @@ #define AFS_VLDB_TIMEOUT HZ*1000 -static void afs_vlocation_update_timer(afs_timer_t *timer); -static void afs_vlocation_update_attend(afs_async_op_t *op); -static void afs_vlocation_update_discard(afs_async_op_t *op); +static void afs_vlocation_update_timer(struct afs_timer *timer); +static void afs_vlocation_update_attend(struct afs_async_op *op); +static void afs_vlocation_update_discard(struct afs_async_op *op); -static void __afs_vlocation_timeout(afs_timer_t *timer) +static void __afs_vlocation_timeout(struct afs_timer *timer) { - afs_vlocation_t *vlocation = list_entry(timer,afs_vlocation_t,timeout); + struct afs_vlocation *vlocation = + list_entry(timer, struct afs_vlocation, timeout); - _debug("VL TIMEOUT [%s{u=%d}]",vlocation->vldb.name,atomic_read(&vlocation->usage)); + _debug("VL TIMEOUT [%s{u=%d}]", + vlocation->vldb.name, atomic_read(&vlocation->usage)); afs_vlocation_do_timeout(vlocation); } @@ -53,11 +55,12 @@ static const struct afs_async_op_ops afs_vlocation_update_op_ops = { }; static LIST_HEAD(afs_vlocation_update_pendq); /* queue of VLs awaiting update */ -static afs_vlocation_t *afs_vlocation_update; /* VL currently being updated */ +static struct afs_vlocation *afs_vlocation_update; /* VL currently being updated */ static spinlock_t afs_vlocation_update_lock = SPIN_LOCK_UNLOCKED; /* lock guarding update queue */ #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_vlocation_cache_match(void *target, const void *entry); +static cachefs_match_val_t afs_vlocation_cache_match(void *target, + const void *entry); static void afs_vlocation_cache_update(void *source, void *entry); struct cachefs_index_def afs_vlocation_cache_index_def = { @@ -71,29 +74,31 @@ struct cachefs_index_def afs_vlocation_cache_index_def = { /*****************************************************************************/ /* - * iterate through the VL servers in a cell until one of them admits knowing about the volume in - * question + * iterate through the VL servers in a cell until one of them admits knowing + * about the volume in question * - caller must have cell->vl_sem write-locked */ -static int afs_vlocation_access_vl_by_name(afs_vlocation_t *vlocation, +static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vlocation, const char *name, unsigned namesz, struct afs_cache_vlocation *vldb) { - afs_server_t *server = NULL; - afs_cell_t *cell = vlocation->cell; + struct afs_server *server = NULL; + struct afs_cell *cell = vlocation->cell; int count, ret; _enter("%s,%*.*s,%u", cell->name, namesz, namesz, name, namesz); ret = -ENOMEDIUM; - for (count=cell->vl_naddrs; count>0; count--) { + for (count = cell->vl_naddrs; count > 0; count--) { _debug("CellServ[%hu]: %08x", cell->vl_curr_svix, cell->vl_addrs[cell->vl_curr_svix].s_addr); /* try and create a server */ - ret = afs_server_lookup(cell, &cell->vl_addrs[cell->vl_curr_svix], &server); + ret = afs_server_lookup(cell, + &cell->vl_addrs[cell->vl_curr_svix], + &server); switch (ret) { case 0: break; @@ -141,36 +146,38 @@ static int afs_vlocation_access_vl_by_name(afs_vlocation_t *vlocation, } out: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vlocation_access_vl_by_name() */ /*****************************************************************************/ /* - * iterate through the VL servers in a cell until one of them admits knowing about the volume in - * question + * iterate through the VL servers in a cell until one of them admits knowing + * about the volume in question * - caller must have cell->vl_sem write-locked */ -static int afs_vlocation_access_vl_by_id(afs_vlocation_t *vlocation, +static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vlocation, afs_volid_t volid, afs_voltype_t voltype, struct afs_cache_vlocation *vldb) { - afs_server_t *server = NULL; - afs_cell_t *cell = vlocation->cell; + struct afs_server *server = NULL; + struct afs_cell *cell = vlocation->cell; int count, ret; _enter("%s,%x,%d,", cell->name, volid, voltype); ret = -ENOMEDIUM; - for (count=cell->vl_naddrs; count>0; count--) { + for (count = cell->vl_naddrs; count > 0; count--) { _debug("CellServ[%hu]: %08x", cell->vl_curr_svix, cell->vl_addrs[cell->vl_curr_svix].s_addr); /* try and create a server */ - ret = afs_server_lookup(cell, &cell->vl_addrs[cell->vl_curr_svix], &server); + ret = afs_server_lookup(cell, + &cell->vl_addrs[cell->vl_curr_svix], + &server); switch (ret) { case 0: break; @@ -218,7 +225,7 @@ static int afs_vlocation_access_vl_by_id(afs_vlocation_t *vlocation, } out: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vlocation_access_vl_by_id() */ @@ -227,17 +234,18 @@ static int afs_vlocation_access_vl_by_id(afs_vlocation_t *vlocation, /* * lookup volume location * - caller must have cell->vol_sem write-locked - * - iterate through the VL servers in a cell until one of them admits knowing about the volume in - * question + * - iterate through the VL servers in a cell until one of them admits knowing + * about the volume in question * - lookup in the local cache if not able to find on the VL server * - insert/update in the local cache if did get a VL response */ -int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, - afs_vlocation_t **_vlocation) +int afs_vlocation_lookup(struct afs_cell *cell, + const char *name, + unsigned namesz, + struct afs_vlocation **_vlocation) { struct afs_cache_vlocation vldb; - struct list_head *_p; - afs_vlocation_t *vlocation; + struct afs_vlocation *vlocation; afs_voltype_t voltype; afs_volid_t vid; int active = 0, ret; @@ -250,8 +258,7 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, } /* search the cell's active list first */ - list_for_each(_p, &cell->vl_list) { - vlocation = list_entry(_p, afs_vlocation_t, link); + list_for_each_entry(vlocation, &cell->vl_list, link) { if (namesz < sizeof(vlocation->vldb.name) && vlocation->vldb.name[namesz] != '\0') continue; @@ -262,8 +269,7 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, /* search the cell's graveyard list second */ spin_lock(&cell->vl_gylock); - list_for_each(_p, &cell->vl_graveyard) { - vlocation = list_entry(_p, afs_vlocation_t, link); + list_for_each_entry(vlocation, &cell->vl_graveyard, link) { if (namesz < sizeof(vlocation->vldb.name) && vlocation->vldb.name[namesz] != '\0') continue; @@ -274,11 +280,11 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, spin_unlock(&cell->vl_gylock); /* not in the cell's in-memory lists - create a new record */ - vlocation = kmalloc(sizeof(afs_vlocation_t), GFP_KERNEL); + vlocation = kmalloc(sizeof(struct afs_vlocation), GFP_KERNEL); if (!vlocation) return -ENOMEM; - memset(vlocation, 0, sizeof(afs_vlocation_t)); + memset(vlocation, 0, sizeof(struct afs_vlocation)); atomic_set(&vlocation->usage, 1); INIT_LIST_HEAD(&vlocation->link); rwlock_init(&vlocation->lock); @@ -294,7 +300,8 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, list_add_tail(&vlocation->link, &cell->vl_list); #ifdef AFS_CACHING_SUPPORT - /* we want to store it in the cache, plus it might already be encached */ + /* we want to store it in the cache, plus it might already be + * encached */ cachefs_acquire_cookie(cell->cache, &afs_volume_cache_index_def, vlocation, @@ -306,7 +313,7 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, /* try to look up an unknown volume in the cell VL databases by name */ ret = afs_vlocation_access_vl_by_name(vlocation, name, namesz, &vldb); - if (ret<0) { + if (ret < 0) { printk("kAFS: failed to locate '%*.*s' in cell '%s'\n", namesz, namesz, name, cell->name); goto error; @@ -342,13 +349,18 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, _debug("Locally Cached: %s %02x { %08x(%x) %08x(%x) %08x(%x) }", vlocation->vldb.name, vlocation->vldb.vidmask, - ntohl(vlocation->vldb.servers[0].s_addr), vlocation->vldb.srvtmask[0], - ntohl(vlocation->vldb.servers[1].s_addr), vlocation->vldb.srvtmask[1], - ntohl(vlocation->vldb.servers[2].s_addr), vlocation->vldb.srvtmask[2] + ntohl(vlocation->vldb.servers[0].s_addr), + vlocation->vldb.srvtmask[0], + ntohl(vlocation->vldb.servers[1].s_addr), + vlocation->vldb.srvtmask[1], + ntohl(vlocation->vldb.servers[2].s_addr), + vlocation->vldb.srvtmask[2] ); _debug("Vids: %08x %08x %08x", - vlocation->vldb.vid[0], vlocation->vldb.vid[1], vlocation->vldb.vid[2]); + vlocation->vldb.vid[0], + vlocation->vldb.vid[1], + vlocation->vldb.vid[2]); if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) { vid = vlocation->vldb.vid[0]; @@ -400,21 +412,20 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, _debug("Vids: %08x %08x %08x", vldb.vid[0], vldb.vid[1], vldb.vid[2]); - if ((namesz < sizeof(vlocation->vldb.name) && vlocation->vldb.name[namesz] != '\0') || + if ((namesz < sizeof(vlocation->vldb.name) && + vlocation->vldb.name[namesz] != '\0') || memcmp(vldb.name, name, namesz) != 0) printk("kAFS: name of volume '%*.*s' changed to '%s' on server\n", namesz, namesz, name, vldb.name); memcpy(&vlocation->vldb, &vldb, sizeof(vlocation->vldb)); -#if 0 - /* add volume entry to local cache */ - ret = afsc_update_vlocation(vlocation); - if (ret<0) - goto error; -#endif + afs_kafstimod_add_timer(&vlocation->upd_timer, 10 * HZ); - afs_kafstimod_add_timer(&vlocation->upd_timer, 10*HZ); +#ifdef AFS_CACHING_SUPPORT + /* update volume entry in local cache */ + cachefs_update_cookie(vlocation->cache); +#endif *_vlocation = vlocation; _leave(" = 0 (%p)",vlocation); @@ -435,7 +446,7 @@ int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz, } } - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vlocation_lookup() */ @@ -451,13 +462,12 @@ void __afs_put_vlocation(struct afs_vlocation *vlocation) if (!vlocation) return; - _enter("%s",vlocation->vldb.name); + _enter("%s", vlocation->vldb.name); cell = vlocation->cell; /* sanity check */ - if (atomic_read(&vlocation->usage)<=0) - BUG(); + BUG_ON(atomic_read(&vlocation->usage) <= 0); spin_lock(&cell->vl_gylock); if (likely(!atomic_dec_and_test(&vlocation->usage))) { @@ -470,12 +480,13 @@ void __afs_put_vlocation(struct afs_vlocation *vlocation) list_del(&vlocation->link); list_add_tail(&vlocation->link,&cell->vl_graveyard); - /* remove from pending timeout queue (refcounted if actually being updated) */ + /* remove from pending timeout queue (refcounted if actually being + * updated) */ list_del_init(&vlocation->upd_op.link); /* time out in 10 secs */ afs_kafstimod_del_timer(&vlocation->upd_timer); - afs_kafstimod_add_timer(&vlocation->timeout,10*HZ); + afs_kafstimod_add_timer(&vlocation->timeout, 10 * HZ); spin_unlock(&cell->vl_gylock); @@ -486,7 +497,7 @@ void __afs_put_vlocation(struct afs_vlocation *vlocation) /* * finish using a volume location record */ -void afs_put_vlocation(afs_vlocation_t *vlocation) +void afs_put_vlocation(struct afs_vlocation *vlocation) { if (vlocation) { struct afs_cell *cell = vlocation->cell; @@ -502,19 +513,19 @@ void afs_put_vlocation(afs_vlocation_t *vlocation) * timeout vlocation record * - removes from the cell's graveyard if the usage count is zero */ -void afs_vlocation_do_timeout(afs_vlocation_t *vlocation) +void afs_vlocation_do_timeout(struct afs_vlocation *vlocation) { - afs_cell_t *cell; + struct afs_cell *cell; - _enter("%s",vlocation->vldb.name); + _enter("%s", vlocation->vldb.name); cell = vlocation->cell; - if (atomic_read(&vlocation->usage)<0) BUG(); + BUG_ON(atomic_read(&vlocation->usage) < 0); /* remove from graveyard if still dead */ spin_lock(&cell->vl_gylock); - if (atomic_read(&vlocation->usage)==0) + if (atomic_read(&vlocation->usage) == 0) list_del_init(&vlocation->link); else vlocation = NULL; @@ -527,7 +538,7 @@ void afs_vlocation_do_timeout(afs_vlocation_t *vlocation) /* we can now destroy it properly */ #ifdef AFS_CACHING_SUPPORT - cachefs_relinquish_cookie(vlocation->cache,0); + cachefs_relinquish_cookie(vlocation->cache, 0); #endif afs_put_cell(cell); @@ -540,14 +551,16 @@ void afs_vlocation_do_timeout(afs_vlocation_t *vlocation) /* * send an update operation to the currently selected server */ -static int afs_vlocation_update_begin(afs_vlocation_t *vlocation) +static int afs_vlocation_update_begin(struct afs_vlocation *vlocation) { afs_voltype_t voltype; afs_volid_t vid; int ret; _enter("%s{ufs=%u ucs=%u}", - vlocation->vldb.name,vlocation->upd_first_svix,vlocation->upd_curr_svix); + vlocation->vldb.name, + vlocation->upd_first_svix, + vlocation->upd_curr_svix); /* try to look up a cached volume in the cell VL databases by ID */ if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) { @@ -569,27 +582,29 @@ static int afs_vlocation_update_begin(afs_vlocation_t *vlocation) } /* contact the chosen server */ - ret = afs_server_lookup(vlocation->cell, - &vlocation->cell->vl_addrs[vlocation->upd_curr_svix], - &vlocation->upd_op.server); + ret = afs_server_lookup( + vlocation->cell, + &vlocation->cell->vl_addrs[vlocation->upd_curr_svix], + &vlocation->upd_op.server); + switch (ret) { case 0: break; case -ENOMEM: case -ENONET: default: - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* initiate the update operation */ - ret = afs_rxvl_get_entry_by_id_async(&vlocation->upd_op,vid,voltype); - if (ret<0) { - _leave(" = %d",ret); + ret = afs_rxvl_get_entry_by_id_async(&vlocation->upd_op, vid, voltype); + if (ret < 0) { + _leave(" = %d", ret); return ret; } - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vlocation_update_begin() */ @@ -598,14 +613,15 @@ static int afs_vlocation_update_begin(afs_vlocation_t *vlocation) * abandon updating a VL record * - does not restart the update timer */ -static void afs_vlocation_update_abandon(afs_vlocation_t *vlocation, +static void afs_vlocation_update_abandon(struct afs_vlocation *vlocation, afs_vlocation_upd_t state, int ret) { - _enter("%s,%u",vlocation->vldb.name,state); + _enter("%s,%u", vlocation->vldb.name, state); - if (ret<0) - printk("kAFS: Abandoning VL update '%s': %d\n",vlocation->vldb.name,ret); + if (ret < 0) + printk("kAFS: Abandoning VL update '%s': %d\n", + vlocation->vldb.name, ret); /* discard the server record */ afs_put_server(vlocation->upd_op.server); @@ -627,12 +643,13 @@ static void afs_vlocation_update_abandon(afs_vlocation_t *vlocation, * handle periodic update timeouts and busy retry timeouts * - called from kafstimod */ -static void afs_vlocation_update_timer(afs_timer_t *timer) +static void afs_vlocation_update_timer(struct afs_timer *timer) { - afs_vlocation_t *vlocation = list_entry(timer,afs_vlocation_t,upd_timer); + struct afs_vlocation *vlocation = + list_entry(timer, struct afs_vlocation, upd_timer); int ret; - _enter("%s",vlocation->vldb.name); + _enter("%s", vlocation->vldb.name); /* only update if not in the graveyard (defend against putting too) */ spin_lock(&vlocation->cell->vl_gylock); @@ -642,11 +659,12 @@ static void afs_vlocation_update_timer(afs_timer_t *timer) spin_lock(&afs_vlocation_update_lock); - /* if we were woken up due to EBUSY sleep then restart immediately if possible or else jump - * to front of pending queue */ - if (vlocation->upd_state==AFS_VLUPD_BUSYSLEEP) { + /* if we were woken up due to EBUSY sleep then restart immediately if + * possible or else jump to front of pending queue */ + if (vlocation->upd_state == AFS_VLUPD_BUSYSLEEP) { if (afs_vlocation_update) { - list_add(&vlocation->upd_op.link,&afs_vlocation_update_pendq); + list_add(&vlocation->upd_op.link, + &afs_vlocation_update_pendq); } else { afs_get_vlocation(vlocation); @@ -659,7 +677,8 @@ static void afs_vlocation_update_timer(afs_timer_t *timer) /* put on pending queue if there's already another update in progress */ if (afs_vlocation_update) { vlocation->upd_state = AFS_VLUPD_PENDING; - list_add_tail(&vlocation->upd_op.link,&afs_vlocation_update_pendq); + list_add_tail(&vlocation->upd_op.link, + &afs_vlocation_update_pendq); goto out_unlock2; } @@ -672,16 +691,17 @@ static void afs_vlocation_update_timer(afs_timer_t *timer) spin_unlock(&vlocation->cell->vl_gylock); /* okay... we can start the update */ - _debug("BEGIN VL UPDATE [%s]",vlocation->vldb.name); + _debug("BEGIN VL UPDATE [%s]", vlocation->vldb.name); vlocation->upd_first_svix = vlocation->cell->vl_curr_svix; vlocation->upd_curr_svix = vlocation->upd_first_svix; vlocation->upd_rej_cnt = 0; vlocation->upd_busy_cnt = 0; ret = afs_vlocation_update_begin(vlocation); - if (ret<0) { - afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,ret); - afs_kafstimod_add_timer(&vlocation->upd_timer,AFS_VLDB_TIMEOUT); + if (ret < 0) { + afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, ret); + afs_kafstimod_add_timer(&vlocation->upd_timer, + AFS_VLDB_TIMEOUT); afs_put_vlocation(vlocation); } @@ -702,56 +722,60 @@ static void afs_vlocation_update_timer(afs_timer_t *timer) * attend to an update operation upon which an event happened * - called in kafsasyncd context */ -static void afs_vlocation_update_attend(afs_async_op_t *op) +static void afs_vlocation_update_attend(struct afs_async_op *op) { struct afs_cache_vlocation vldb; - afs_vlocation_t *vlocation = list_entry(op,afs_vlocation_t,upd_op); + struct afs_vlocation *vlocation = + list_entry(op, struct afs_vlocation, upd_op); unsigned tmp; int ret; - _enter("%s",vlocation->vldb.name); + _enter("%s", vlocation->vldb.name); - ret = afs_rxvl_get_entry_by_id_async2(op,&vldb); + ret = afs_rxvl_get_entry_by_id_async2(op, &vldb); switch (ret) { case -EAGAIN: _leave(" [unfinished]"); return; case 0: - _debug("END VL UPDATE: %d\n",ret); + _debug("END VL UPDATE: %d\n", ret); vlocation->valid = 1; _debug("Done VL Lookup: %02x { %08x(%x) %08x(%x) %08x(%x) }", vldb.vidmask, - ntohl(vldb.servers[0].s_addr),vldb.srvtmask[0], - ntohl(vldb.servers[1].s_addr),vldb.srvtmask[1], - ntohl(vldb.servers[2].s_addr),vldb.srvtmask[2] + ntohl(vldb.servers[0].s_addr), vldb.srvtmask[0], + ntohl(vldb.servers[1].s_addr), vldb.srvtmask[1], + ntohl(vldb.servers[2].s_addr), vldb.srvtmask[2] ); - _debug("Vids: %08x %08x %08x",vldb.vid[0],vldb.vid[1],vldb.vid[2]); + _debug("Vids: %08x %08x %08x", + vldb.vid[0], vldb.vid[1], vldb.vid[2]); - afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,0); + afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, 0); down_write(&vlocation->cell->vl_sem); /* actually update the cache */ - if (strncmp(vldb.name,vlocation->vldb.name,sizeof(vlocation->vldb.name))!=0) - printk("kAFS: name of volume '%s' changed to '%s' on server\n", - vlocation->vldb.name,vldb.name); + if (strncmp(vldb.name, vlocation->vldb.name, + sizeof(vlocation->vldb.name)) != 0) + printk("kAFS: name of volume '%s'" + " changed to '%s' on server\n", + vlocation->vldb.name, vldb.name); - memcpy(&vlocation->vldb,&vldb,sizeof(vlocation->vldb)); + memcpy(&vlocation->vldb, &vldb, sizeof(vlocation->vldb)); #if 0 - /* add volume entry to local cache */ - ret = afsc_update_vlocation(vlocation); + /* TODO update volume entry in local cache */ #endif up_write(&vlocation->cell->vl_sem); - if (ret<0) - printk("kAFS: failed to update local cache: %d\n",ret); + if (ret < 0) + printk("kAFS: failed to update local cache: %d\n", ret); - afs_kafstimod_add_timer(&vlocation->upd_timer,AFS_VLDB_TIMEOUT); + afs_kafstimod_add_timer(&vlocation->upd_timer, + AFS_VLDB_TIMEOUT); afs_put_vlocation(vlocation); _leave(" [found]"); return; @@ -763,11 +787,12 @@ static void afs_vlocation_update_attend(afs_async_op_t *op) /* the server is locked - retry in a very short while */ case -EBUSY: vlocation->upd_busy_cnt++; - if (vlocation->upd_busy_cnt>3) + if (vlocation->upd_busy_cnt > 3) goto try_next; /* too many retries */ - afs_vlocation_update_abandon(vlocation,AFS_VLUPD_BUSYSLEEP,0); - afs_kafstimod_add_timer(&vlocation->upd_timer,HZ/2); + afs_vlocation_update_abandon(vlocation, + AFS_VLUPD_BUSYSLEEP, 0); + afs_kafstimod_add_timer(&vlocation->upd_timer, HZ / 2); afs_put_vlocation(vlocation); _leave(" [busy]"); return; @@ -781,7 +806,8 @@ static void afs_vlocation_update_attend(afs_async_op_t *op) */ if (vlocation->upd_curr_svix == vlocation->cell->vl_curr_svix) vlocation->cell->vl_curr_svix = - vlocation->cell->vl_curr_svix % vlocation->cell->vl_naddrs; + vlocation->cell->vl_curr_svix % + vlocation->cell->vl_naddrs; case -EBADRQC: case -EINVAL: @@ -802,26 +828,30 @@ static void afs_vlocation_update_attend(afs_async_op_t *op) vlocation->upd_op.server = NULL; tmp = vlocation->cell->vl_naddrs; - if (tmp==0) + if (tmp == 0) goto abandon; vlocation->upd_curr_svix++; - if (vlocation->upd_curr_svix >= tmp) vlocation->upd_curr_svix = 0; - if (vlocation->upd_first_svix >= tmp) vlocation->upd_first_svix = tmp - 1; + if (vlocation->upd_curr_svix >= tmp) + vlocation->upd_curr_svix = 0; + if (vlocation->upd_first_svix >= tmp) + vlocation->upd_first_svix = tmp - 1; /* move to the next server */ - if (vlocation->upd_curr_svix!=vlocation->upd_first_svix) { + if (vlocation->upd_curr_svix != vlocation->upd_first_svix) { afs_vlocation_update_begin(vlocation); _leave(" [next]"); return; } /* run out of servers to try - was the volume rejected? */ - if (vlocation->upd_rej_cnt>0) { - printk("kAFS: Active volume no longer valid '%s'\n",vlocation->vldb.name); + if (vlocation->upd_rej_cnt > 0) { + printk("kAFS: Active volume no longer valid '%s'\n", + vlocation->vldb.name); vlocation->valid = 0; - afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,0); - afs_kafstimod_add_timer(&vlocation->upd_timer,AFS_VLDB_TIMEOUT); + afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, 0); + afs_kafstimod_add_timer(&vlocation->upd_timer, + AFS_VLDB_TIMEOUT); afs_put_vlocation(vlocation); _leave(" [invalidated]"); return; @@ -829,8 +859,8 @@ static void afs_vlocation_update_attend(afs_async_op_t *op) /* abandon the update */ abandon: - afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,ret); - afs_kafstimod_add_timer(&vlocation->upd_timer,HZ*10); + afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, ret); + afs_kafstimod_add_timer(&vlocation->upd_timer, HZ * 10); afs_put_vlocation(vlocation); _leave(" [abandoned]"); @@ -842,11 +872,12 @@ static void afs_vlocation_update_attend(afs_async_op_t *op) * - called in kafsasyncd context when it's dying due to rmmod * - the call has already been aborted and put()'d */ -static void afs_vlocation_update_discard(afs_async_op_t *op) +static void afs_vlocation_update_discard(struct afs_async_op *op) { - afs_vlocation_t *vlocation = list_entry(op,afs_vlocation_t,upd_op); + struct afs_vlocation *vlocation = + list_entry(op, struct afs_vlocation, upd_op); - _enter("%s",vlocation->vldb.name); + _enter("%s", vlocation->vldb.name); afs_put_server(op->server); op->server = NULL; @@ -870,11 +901,11 @@ static cachefs_match_val_t afs_vlocation_cache_match(void *target, _enter("{%s},{%s}", vlocation->vldb.name, vldb->name); - if (strncmp(vlocation->vldb.name, - vldb->name, - sizeof(vldb->name)) == 0) { + if (strncmp(vlocation->vldb.name, vldb->name, sizeof(vldb->name)) == 0 + ) { if (!vlocation->valid || - vlocation->vldb.rtime == vldb->rtime) { + vlocation->vldb.rtime == vldb->rtime + ) { struct_cpy(&vlocation->vldb, vldb); vlocation->valid = 1; _leave(" = SUCCESS [c->m]"); diff --git a/fs/afs/vnode.c b/fs/afs/vnode.c index b982317733e1..e3e9611cba51 100644 --- a/fs/afs/vnode.c +++ b/fs/afs/vnode.c @@ -30,7 +30,8 @@ struct afs_timer_ops afs_vnode_cb_timed_out_ops = { }; #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry); +static cachefs_match_val_t afs_vnode_cache_match(void *target, + const void *entry); static void afs_vnode_cache_update(void *source, void *entry); struct cachefs_index_def afs_vnode_cache_index_def = { @@ -49,17 +50,17 @@ struct cachefs_index_def afs_vnode_cache_index_def = { */ static void afs_vnode_cb_timed_out(struct afs_timer *timer) { - afs_server_t *oldserver; - afs_vnode_t *vnode; + struct afs_server *oldserver; + struct afs_vnode *vnode; - vnode = list_entry(timer,afs_vnode_t,cb_timeout); + vnode = list_entry(timer, struct afs_vnode, cb_timeout); - _enter("%p",vnode); + _enter("%p", vnode); /* set the changed flag in the vnode and release the server */ spin_lock(&vnode->lock); - oldserver = xchg(&vnode->cb_server,NULL); + oldserver = xchg(&vnode->cb_server, NULL); if (oldserver) { vnode->flags |= AFS_VNODE_CHANGED; @@ -85,28 +86,33 @@ static void afs_vnode_cb_timed_out(struct afs_timer *timer) * - starts callback expiry timer * - adds to server's callback list */ -void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, int ret) +void afs_vnode_finalise_status_update(struct afs_vnode *vnode, + struct afs_server *server, + int ret) { - afs_server_t *oldserver = NULL; + struct afs_server *oldserver = NULL; - _enter("%p,%p,%d",vnode,server,ret); + _enter("%p,%p,%d", vnode, server, ret); spin_lock(&vnode->lock); vnode->flags &= ~AFS_VNODE_CHANGED; - if (ret==0) { + if (ret == 0) { /* adjust the callback timeout appropriately */ - afs_kafstimod_add_timer(&vnode->cb_timeout,vnode->cb_expiry*HZ); + afs_kafstimod_add_timer(&vnode->cb_timeout, + vnode->cb_expiry * HZ); spin_lock(&afs_cb_hash_lock); list_del(&vnode->cb_hash_link); - list_add_tail(&vnode->cb_hash_link,&afs_cb_hash(server,&vnode->fid)); + list_add_tail(&vnode->cb_hash_link, + &afs_cb_hash(server, &vnode->fid)); spin_unlock(&afs_cb_hash_lock); - /* swap ref to old callback server with that for new callback server */ - oldserver = xchg(&vnode->cb_server,server); - if (oldserver!=server) { + /* swap ref to old callback server with that for new callback + * server */ + oldserver = xchg(&vnode->cb_server, server); + if (oldserver != server) { if (oldserver) { spin_lock(&oldserver->cb_lock); list_del_init(&vnode->cb_link); @@ -115,7 +121,7 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, afs_get_server(server); spin_lock(&server->cb_lock); - list_add_tail(&vnode->cb_link,&server->cb_promises); + list_add_tail(&vnode->cb_link, &server->cb_promises); spin_unlock(&server->cb_lock); } else { @@ -123,9 +129,9 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, oldserver = NULL; } } - else if (ret==-ENOENT) { + else if (ret == -ENOENT) { /* the file was deleted - clear the callback timeout */ - oldserver = xchg(&vnode->cb_server,NULL); + oldserver = xchg(&vnode->cb_server, NULL); afs_kafstimod_del_timer(&vnode->cb_timeout); _debug("got NOENT from server - marking file deleted"); @@ -152,15 +158,16 @@ void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, * - there are any outstanding ops that will fetch the status * - TODO implement local caching */ -int afs_vnode_fetch_status(afs_vnode_t *vnode) +int afs_vnode_fetch_status(struct afs_vnode *vnode) { - afs_server_t *server; + struct afs_server *server; int ret; - DECLARE_WAITQUEUE(myself,current); + DECLARE_WAITQUEUE(myself, current); - _enter("%s,{%u,%u,%u}",vnode->volume->vlocation->vldb.name, - vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique); + _enter("%s,{%u,%u,%u}", + vnode->volume->vlocation->vldb.name, + vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique); if (!(vnode->flags & AFS_VNODE_CHANGED) && vnode->cb_server) { _leave(" [unchanged]"); @@ -180,19 +187,23 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) return 0; } - if (vnode->update_cnt>0) { + if (vnode->update_cnt > 0) { /* someone else started a fetch */ set_current_state(TASK_UNINTERRUPTIBLE); - add_wait_queue(&vnode->update_waitq,&myself); + add_wait_queue(&vnode->update_waitq, &myself); /* wait for the status to be updated */ for (;;) { - if (!(vnode->flags & AFS_VNODE_CHANGED)) break; - if (vnode->flags & AFS_VNODE_DELETED) break; - - /* it got updated and invalidated all before we saw it */ - if (vnode->update_cnt==0) { - remove_wait_queue(&vnode->update_waitq,&myself); + if (!(vnode->flags & AFS_VNODE_CHANGED)) + break; + if (vnode->flags & AFS_VNODE_DELETED) + break; + + /* it got updated and invalidated all before we saw + * it */ + if (vnode->update_cnt == 0) { + remove_wait_queue(&vnode->update_waitq, + &myself); set_current_state(TASK_RUNNING); goto get_anyway; } @@ -205,7 +216,7 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) spin_lock(&vnode->lock); } - remove_wait_queue(&vnode->update_waitq,&myself); + remove_wait_queue(&vnode->update_waitq, &myself); spin_unlock(&vnode->lock); set_current_state(TASK_RUNNING); @@ -218,23 +229,24 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) spin_unlock(&vnode->lock); - /* merge AFS status fetches and clear outstanding callback on this vnode */ + /* merge AFS status fetches and clear outstanding callback on this + * vnode */ do { /* pick a server to query */ - ret = afs_volume_pick_fileserver(vnode->volume,&server); + ret = afs_volume_pick_fileserver(vnode->volume, &server); if (ret<0) return ret; - _debug("USING SERVER: %08x\n",ntohl(server->addr.s_addr)); + _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr)); - ret = afs_rxfs_fetch_file_status(server,vnode,NULL); + ret = afs_rxfs_fetch_file_status(server, vnode, NULL); - } while (!afs_volume_release_fileserver(vnode->volume,server,ret)); + } while (!afs_volume_release_fileserver(vnode->volume, server, ret)); /* adjust the flags */ - afs_vnode_finalise_status_update(vnode,server,ret); + afs_vnode_finalise_status_update(vnode, server, ret); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vnode_fetch_status() */ @@ -243,9 +255,10 @@ int afs_vnode_fetch_status(afs_vnode_t *vnode) * fetch file data from the volume * - TODO implement caching and server failover */ -int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *desc) +int afs_vnode_fetch_data(struct afs_vnode *vnode, + struct afs_rxfs_fetch_descriptor *desc) { - afs_server_t *server; + struct afs_server *server; int ret; _enter("%s,{%u,%u,%u}", @@ -259,23 +272,24 @@ int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *d vnode->update_cnt++; spin_unlock(&vnode->lock); - /* merge in AFS status fetches and clear outstanding callback on this vnode */ + /* merge in AFS status fetches and clear outstanding callback on this + * vnode */ do { /* pick a server to query */ - ret = afs_volume_pick_fileserver(vnode->volume,&server); - if (ret<0) + ret = afs_volume_pick_fileserver(vnode->volume, &server); + if (ret < 0) return ret; - _debug("USING SERVER: %08x\n",ntohl(server->addr.s_addr)); + _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr)); - ret = afs_rxfs_fetch_file_data(server,vnode,desc,NULL); + ret = afs_rxfs_fetch_file_data(server, vnode, desc, NULL); - } while (!afs_volume_release_fileserver(vnode->volume,server,ret)); + } while (!afs_volume_release_fileserver(vnode->volume, server, ret)); /* adjust the flags */ - afs_vnode_finalise_status_update(vnode,server,ret); + afs_vnode_finalise_status_update(vnode, server, ret); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vnode_fetch_data() */ @@ -285,9 +299,9 @@ int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *d * break any outstanding callback on a vnode * - only relevent to server that issued it */ -int afs_vnode_give_up_callback(afs_vnode_t *vnode) +int afs_vnode_give_up_callback(struct afs_vnode *vnode) { - afs_server_t *server; + struct afs_server *server; int ret; _enter("%s,{%u,%u,%u}", @@ -305,7 +319,7 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode) afs_kafstimod_del_timer(&vnode->cb_timeout); - server = xchg(&vnode->cb_server,NULL); + server = xchg(&vnode->cb_server, NULL); if (server) { vnode->flags |= AFS_VNODE_CHANGED; @@ -318,11 +332,11 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode) ret = 0; if (server) { - ret = afs_rxfs_give_up_callback(server,vnode); + ret = afs_rxfs_give_up_callback(server, vnode); afs_put_server(server); } - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_vnode_give_up_callback() */ @@ -331,7 +345,8 @@ int afs_vnode_give_up_callback(afs_vnode_t *vnode) * match a vnode record stored in the cache */ #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry) +static cachefs_match_val_t afs_vnode_cache_match(void *target, + const void *entry) { const struct afs_cache_vnode *cvnode = entry; struct afs_vnode *vnode = target; diff --git a/fs/afs/vnode.h b/fs/afs/vnode.h index b35663e0647c..b86a97102e8b 100644 --- a/fs/afs/vnode.h +++ b/fs/afs/vnode.h @@ -70,21 +70,22 @@ struct afs_vnode afs_callback_type_t cb_type; /* type of callback */ }; -static inline afs_vnode_t *AFS_FS_I(struct inode *inode) +static inline struct afs_vnode *AFS_FS_I(struct inode *inode) { - return container_of(inode,afs_vnode_t,vfs_inode); + return container_of(inode,struct afs_vnode,vfs_inode); } -static inline struct inode *AFS_VNODE_TO_I(afs_vnode_t *vnode) +static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) { return &vnode->vfs_inode; } -extern int afs_vnode_fetch_status(afs_vnode_t *vnode); +extern int afs_vnode_fetch_status(struct afs_vnode *vnode); -extern int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *desc); +extern int afs_vnode_fetch_data(struct afs_vnode *vnode, + struct afs_rxfs_fetch_descriptor *desc); -extern int afs_vnode_give_up_callback(afs_vnode_t *vnode); +extern int afs_vnode_give_up_callback(struct afs_vnode *vnode); extern struct afs_timer_ops afs_vnode_cb_timed_out_ops; diff --git a/fs/afs/volume.c b/fs/afs/volume.c index 9f9823ebfa7c..4ebdb2d50b76 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -27,7 +27,8 @@ const char *afs_voltypes[] = { "R/W", "R/O", "BAK" }; #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_volume_cache_match(void *target, const void *entry); +static cachefs_match_val_t afs_volume_cache_match(void *target, + const void *entry); static void afs_volume_cache_update(void *source, void *entry); struct cachefs_index_def afs_volume_cache_index_def = { @@ -45,7 +46,8 @@ struct cachefs_index_def afs_volume_cache_index_def = { * lookup a volume by name * - this can be one of the following: * "%[cell:]volume[.]" R/W volume - * "#[cell:]volume[.]" R/O or R/W volume (rwparent=0), or R/W (rwparent=1) volume + * "#[cell:]volume[.]" R/O or R/W volume (rwparent=0), + * or R/W (rwparent=1) volume * "%[cell:]volume.readonly" R/O volume * "#[cell:]volume.readonly" R/O volume * "%[cell:]volume.backup" Backup volume @@ -53,14 +55,17 @@ struct cachefs_index_def afs_volume_cache_index_def = { * * The cell name is optional, and defaults to the current cell. * - * See "The Rules of Mount Point Traversal" in Chapter 5 of the AFS SysAdmin Guide + * See "The Rules of Mount Point Traversal" in Chapter 5 of the AFS SysAdmin + * Guide * - Rule 1: Explicit type suffix forces access of that type or nothing * (no suffix, then use Rule 2 & 3) - * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W if not available - * - Rule 3: If parent volume is R/W, then only mount R/W volume unless explicitly told otherwise + * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W + * if not available + * - Rule 3: If parent volume is R/W, then only mount R/W volume unless + * explicitly told otherwise */ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, - afs_volume_t **_volume) + struct afs_volume **_volume) { struct afs_vlocation *vlocation = NULL; struct afs_volume *volume = NULL; @@ -108,6 +113,7 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, if (volname) { cellname = name; cellnamesz = volname - name; + volname++; } else { volname = name; @@ -127,7 +133,8 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, if (cellname || !cell) { ret = afs_cell_lookup(cellname, cellnamesz, &cell); if (ret<0) { - printk("kAFS: unable to lookup cell '%s'\n", cellname ?: ""); + printk("kAFS: unable to lookup cell '%s'\n", + cellname ?: ""); goto error; } } @@ -146,7 +153,7 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, goto error; srvtmask = 0; - for (loop=0; loop<vlocation->vldb.nservers; loop++) + for (loop = 0; loop < vlocation->vldb.nservers; loop++) srvtmask |= vlocation->vldb.srvtmask[loop]; if (force) { @@ -177,11 +184,11 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, _debug("creating new volume record"); ret = -ENOMEM; - volume = kmalloc(sizeof(afs_volume_t), GFP_KERNEL); + volume = kmalloc(sizeof(struct afs_volume), GFP_KERNEL); if (!volume) goto error_up; - memset(volume, 0, sizeof(afs_volume_t)); + memset(volume, 0, sizeof(struct afs_volume)); atomic_set(&volume->usage, 1); volume->type = type; volume->type_force = force; @@ -191,12 +198,13 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, init_rwsem(&volume->server_sem); /* look up all the applicable server records */ - for (loop=0; loop<8; loop++) { + for (loop = 0; loop < 8; loop++) { if (vlocation->vldb.srvtmask[loop] & (1 << volume->type)) { - ret = afs_server_lookup(volume->cell, - &vlocation->vldb.servers[loop], - &volume->servers[volume->nservers]); - if (ret<0) + ret = afs_server_lookup( + volume->cell, + &vlocation->vldb.servers[loop], + &volume->servers[volume->nservers]); + if (ret < 0) goto error_discard; volume->nservers++; @@ -217,7 +225,8 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, vlocation->vols[type] = volume; success: - _debug("kAFS selected %s volume %08x", afs_voltypes[volume->type], volume->vid); + _debug("kAFS selected %s volume %08x", + afs_voltypes[volume->type], volume->vid); *_volume = volume; ret = 0; @@ -234,7 +243,7 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, error_discard: up_write(&cell->vl_sem); - for (loop=volume->nservers-1; loop>=0; loop--) + for (loop = volume->nservers - 1; loop >= 0; loop--) afs_put_server(volume->servers[loop]); kfree(volume); @@ -245,23 +254,23 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath, /* * destroy a volume record */ -void afs_put_volume(afs_volume_t *volume) +void afs_put_volume(struct afs_volume *volume) { - afs_vlocation_t *vlocation; + struct afs_vlocation *vlocation; int loop; if (!volume) return; - _enter("%p",volume); + _enter("%p", volume); vlocation = volume->vlocation; /* sanity check */ - if (atomic_read(&volume->usage)<=0) - BUG(); + BUG_ON(atomic_read(&volume->usage) <= 0); - /* to prevent a race, the decrement and the dequeue must be effectively atomic */ + /* to prevent a race, the decrement and the dequeue must be effectively + * atomic */ down_write(&vlocation->cell->vl_sem); if (likely(!atomic_dec_and_test(&volume->usage))) { @@ -276,11 +285,11 @@ void afs_put_volume(afs_volume_t *volume) /* finish cleaning up the volume */ #ifdef AFS_CACHING_SUPPORT - cachefs_relinquish_cookie(volume->cache,0); + cachefs_relinquish_cookie(volume->cache, 0); #endif afs_put_vlocation(vlocation); - for (loop=volume->nservers-1; loop>=0; loop--) + for (loop = volume->nservers - 1; loop >= 0; loop--) afs_put_server(volume->servers[loop]); kfree(volume); @@ -293,26 +302,28 @@ void afs_put_volume(afs_volume_t *volume) * pick a server to use to try accessing this volume * - returns with an elevated usage count on the server chosen */ -int afs_volume_pick_fileserver(afs_volume_t *volume, afs_server_t **_server) +int afs_volume_pick_fileserver(struct afs_volume *volume, + struct afs_server **_server) { - afs_server_t *server; + struct afs_server *server; int ret, state, loop; - _enter("%s",volume->vlocation->vldb.name); + _enter("%s", volume->vlocation->vldb.name); down_read(&volume->server_sem); /* handle the no-server case */ - if (volume->nservers==0) { + if (volume->nservers == 0) { ret = volume->rjservers ? -ENOMEDIUM : -ESTALE; up_read(&volume->server_sem); - _leave(" = %d [no servers]",ret); + _leave(" = %d [no servers]", ret); return ret; } - /* basically, just search the list for the first live server and use that */ + /* basically, just search the list for the first live server and use + * that */ ret = 0; - for (loop=0; loop<volume->nservers; loop++) { + for (loop = 0; loop < volume->nservers; loop++) { server = volume->servers[loop]; state = server->fs_state; @@ -322,30 +333,34 @@ int afs_volume_pick_fileserver(afs_volume_t *volume, afs_server_t **_server) afs_get_server(server); up_read(&volume->server_sem); *_server = server; - _leave(" = 0 (picked %08x)",ntohl(server->addr.s_addr)); + _leave(" = 0 (picked %08x)", + ntohl(server->addr.s_addr)); return 0; case -ENETUNREACH: - if (ret==0) + if (ret == 0) ret = state; break; case -EHOSTUNREACH: - if (ret==0 || ret==-ENETUNREACH) + if (ret == 0 || + ret == -ENETUNREACH) ret = state; break; case -ECONNREFUSED: - if (ret==0 || ret==-ENETUNREACH || ret==-EHOSTUNREACH) + if (ret == 0 || + ret == -ENETUNREACH || + ret == -EHOSTUNREACH) ret = state; break; default: case -EREMOTEIO: - if (ret==0 || - ret==-ENETUNREACH || - ret==-EHOSTUNREACH || - ret==-ECONNREFUSED) + if (ret == 0 || + ret == -ENETUNREACH || + ret == -EHOSTUNREACH || + ret == -ECONNREFUSED) ret = state; break; } @@ -355,7 +370,7 @@ int afs_volume_pick_fileserver(afs_volume_t *volume, afs_server_t **_server) * - TODO: handle the no active servers case better */ up_read(&volume->server_sem); - _leave(" = %d",ret); + _leave(" = %d", ret); return ret; } /* end afs_volume_pick_fileserver() */ @@ -366,11 +381,15 @@ int afs_volume_pick_fileserver(afs_volume_t *volume, afs_server_t **_server) * - records result of using a particular server to access a volume * - return 0 to try again, 1 if okay or to issue error */ -int afs_volume_release_fileserver(afs_volume_t *volume, afs_server_t *server, int result) +int afs_volume_release_fileserver(struct afs_volume *volume, + struct afs_server *server, + int result) { unsigned loop; - _enter("%s,%08x,%d",volume->vlocation->vldb.name,ntohl(server->addr.s_addr),result); + _enter("%s,%08x,%d", + volume->vlocation->vldb.name, ntohl(server->addr.s_addr), + result); switch (result) { /* success */ @@ -383,9 +402,10 @@ int afs_volume_release_fileserver(afs_volume_t *volume, afs_server_t *server, in server->fs_act_jif = jiffies; down_write(&volume->server_sem); - /* first, find where the server is in the active list (if it is) */ - for (loop=0; loop<volume->nservers; loop++) - if (volume->servers[loop]==server) + /* first, find where the server is in the active list (if it + * is) */ + for (loop = 0; loop < volume->nservers; loop++) + if (volume->servers[loop] == server) goto present; /* no longer there - may have been discarded by another op */ @@ -394,20 +414,22 @@ int afs_volume_release_fileserver(afs_volume_t *volume, afs_server_t *server, in present: volume->nservers--; memmove(&volume->servers[loop], - &volume->servers[loop+1], - sizeof(volume->servers[loop]) * (volume->nservers - loop) - ); + &volume->servers[loop + 1], + sizeof(volume->servers[loop]) * + (volume->nservers - loop)); volume->servers[volume->nservers] = NULL; afs_put_server(server); volume->rjservers++; - if (volume->nservers>0) + if (volume->nservers > 0) /* another server might acknowledge its existence */ goto try_next_server_upw; - /* handle the case where all the fileservers have rejected the volume + /* handle the case where all the fileservers have rejected the + * volume * - TODO: try asking the fileservers for volume information - * - TODO: contact the VL server again to see if the volume is no longer registered + * - TODO: contact the VL server again to see if the volume is + * no longer registered */ up_write(&volume->server_sem); afs_put_server(server); @@ -427,7 +449,7 @@ int afs_volume_release_fileserver(afs_volume_t *volume, afs_server_t *server, in if (!server->fs_state) { server->fs_dead_jif = jiffies + HZ * 10; server->fs_state = result; - printk("kAFS: SERVER DEAD state=%d\n",result); + printk("kAFS: SERVER DEAD state=%d\n", result); } spin_unlock(&server->fs_lock); goto try_next_server; @@ -460,7 +482,8 @@ int afs_volume_release_fileserver(afs_volume_t *volume, afs_server_t *server, in * match a volume hash record stored in the cache */ #ifdef AFS_CACHING_SUPPORT -static cachefs_match_val_t afs_volume_cache_match(void *target, const void *entry) +static cachefs_match_val_t afs_volume_cache_match(void *target, + const void *entry) { const struct afs_cache_vhash *vhash = entry; struct afs_volume *volume = target; diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 16884fc26255..c535efa29101 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -349,6 +349,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, elf_type |= MAP_FIXED; map_addr = elf_map(interpreter, load_addr + vaddr, eppnt, elf_prot, elf_type); + error = map_addr; if (BAD_ADDR(map_addr)) goto out_close; @@ -290,7 +290,9 @@ int bio_get_nr_vecs(struct block_device *bdev) * * Attempt to add a page to the bio_vec maplist. This can fail for a * number of reasons, such as the bio being full or target block - * device limitations. + * device limitations. The target block device must allow bio's + * smaller than PAGE_SIZE, so it is always possible to add a single + * page to an empty bio. */ int bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) @@ -592,7 +594,7 @@ static void bio_dirty_fn(void *data); static DECLARE_WORK(bio_dirty_work, bio_dirty_fn, NULL); static spinlock_t bio_dirty_lock = SPIN_LOCK_UNLOCKED; -static struct bio *bio_dirty_list = NULL; +static struct bio *bio_dirty_list; /* * This runs in process context diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index a34b3801336e..f5a6b336f708 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -527,7 +527,8 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) int i; #ifdef EXT2FS_DEBUG unsigned long bitmap_count, x; - + struct ext2_super_block *es; + lock_super (sb); es = EXT2_SB(sb)->s_es; desc_count = 0; @@ -550,7 +551,8 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) brelse(bitmap_bh); } printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n", - le32_to_cpu(es->s_free_blocks_count), desc_count, bitmap_count); + (long)le32_to_cpu(es->s_free_blocks_count), + desc_count, bitmap_count); unlock_super (sb); return bitmap_count; #else diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 768fabc89ccd..df5eb0b299dd 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c @@ -507,7 +507,7 @@ repeat_in_this_group: group = 0; continue; } - if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group), + if (ext2_set_bit_atomic(sb_bgl_lock(sbi, group), ino, bitmap_bh->b_data)) { /* we lost this inode */ if (++ino >= EXT2_INODES_PER_GROUP(sb)) { @@ -543,23 +543,23 @@ got: goto fail; } - percpu_counter_mod(&EXT2_SB(sb)->s_freeinodes_counter, -1); + percpu_counter_mod(&sbi->s_freeinodes_counter, -1); if (S_ISDIR(mode)) - percpu_counter_inc(&EXT2_SB(sb)->s_dirs_counter); + percpu_counter_inc(&sbi->s_dirs_counter); - spin_lock(sb_bgl_lock(EXT2_SB(sb), group)); + spin_lock(sb_bgl_lock(sbi, group)); gdp->bg_free_inodes_count = cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1); if (S_ISDIR(mode)) { - if (EXT2_SB(sb)->s_debts[group] < 255) - EXT2_SB(sb)->s_debts[group]++; + if (sbi->s_debts[group] < 255) + sbi->s_debts[group]++; gdp->bg_used_dirs_count = cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1); } else { - if (EXT2_SB(sb)->s_debts[group]) - EXT2_SB(sb)->s_debts[group]--; + if (sbi->s_debts[group]) + sbi->s_debts[group]--; } - spin_unlock(sb_bgl_lock(EXT2_SB(sb), group)); + spin_unlock(sb_bgl_lock(sbi, group)); sb->s_dirt = 1; mark_buffer_dirty(bh2); @@ -599,7 +599,9 @@ got: ei->i_dir_start_lookup = 0; ei->i_state = EXT2_STATE_NEW; ext2_set_inode_flags(inode); - inode->i_generation = EXT2_SB(sb)->s_next_generation++; + spin_lock(&sbi->s_next_gen_lock); + inode->i_generation = sbi->s_next_generation++; + spin_unlock(&sbi->s_next_gen_lock); insert_inode_hash(inode); if (DQUOT_ALLOC_INODE(inode)) { @@ -636,10 +638,9 @@ unsigned long ext2_count_free_inodes (struct super_block * sb) int i; #ifdef EXT2FS_DEBUG - struct ext2_super_block * es; + struct ext2_super_block *es; unsigned long bitmap_count = 0; struct buffer_head *bitmap_bh = NULL; - int i; lock_super (sb); es = EXT2_SB(sb)->s_es; @@ -656,7 +657,7 @@ unsigned long ext2_count_free_inodes (struct super_block * sb) continue; x = ext2_count_free(bitmap_bh, EXT2_INODES_PER_GROUP(sb) / 8); - printk ("group %d: stored = %d, counted = %lu\n", + printk("group %d: stored = %d, counted = %u\n", i, le16_to_cpu(desc->bg_free_inodes_count), x); bitmap_count += x; } diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 410f95252bdb..576951e2bbdd 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -809,6 +809,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) } sbi->s_gdb_count = db_count; get_random_bytes(&sbi->s_next_generation, sizeof(u32)); + spin_lock_init(&sbi->s_next_gen_lock); /* * set up enough so that it can read an inode */ diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 13f61fc9e85a..c0c206fea391 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -446,8 +446,8 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) return ERR_PTR(-ENOMEM); ei = EXT3_I(inode); - es = EXT3_SB(sb)->s_es; sbi = EXT3_SB(sb); + es = sbi->s_es; if (S_ISDIR(mode)) { if (test_opt (sb, OLDALLOC)) group = find_group_dir(sb, dir); @@ -591,7 +591,9 @@ got: if (IS_DIRSYNC(inode)) handle->h_sync = 1; insert_inode_hash(inode); - inode->i_generation = EXT3_SB(sb)->s_next_generation++; + spin_lock(&sbi->s_next_gen_lock); + inode->i_generation = sbi->s_next_generation++; + spin_unlock(&sbi->s_next_gen_lock); ei->i_state = EXT3_STATE_NEW; diff --git a/fs/ext3/super.c b/fs/ext3/super.c index e2b4a68ccd1a..ea5cfb9ce3c7 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -31,6 +31,7 @@ #include <linux/smp_lock.h> #include <linux/buffer_head.h> #include <linux/vfs.h> +#include <linux/random.h> #include <asm/uaccess.h> #include "xattr.h" #include "acl.h" @@ -1287,6 +1288,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) goto failed_mount2; } sbi->s_gdb_count = db_count; + get_random_bytes(&sbi->s_next_generation, sizeof(u32)); + spin_lock_init(&sbi->s_next_gen_lock); /* * set up enough so that it can read an inode */ diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index ba957c1fb3dc..73ef79d97fd0 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c @@ -85,7 +85,7 @@ static int start_this_handle(journal_t *journal, handle_t *handle) int needed; int nblocks = handle->h_buffer_credits; transaction_t *new_transaction = NULL; - int ret; + int ret = 0; if (nblocks > journal->j_max_transaction_buffers) { printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n", @@ -231,7 +231,7 @@ repeat_locked: out: if (new_transaction) kfree(new_transaction); - return 0; + return ret; } /* Allocate a new handle. This should probably be in a slab... */ diff --git a/fs/libfs.c b/fs/libfs.c index 68002d64552e..475871c787f3 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -155,6 +155,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) } spin_unlock(&dcache_lock); } + update_atime(dentry->d_inode); return 0; } diff --git a/fs/proc/base.c b/fs/proc/base.c index f16a555f7933..363af5b73d24 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1669,14 +1669,26 @@ out: * tasklist lock while doing this, and we must release it before * we actually do the filldir itself, so we use a temp buffer.. */ -static int get_tgid_list(int index, unsigned int *tgids) +static int get_tgid_list(int index, unsigned long version, unsigned int *tgids) { struct task_struct *p; int nr_tgids = 0; index--; read_lock(&tasklist_lock); - for_each_process(p) { + p = NULL; + if (version) { + p = find_task_by_pid(version); + if (!thread_group_leader(p)) + p = NULL; + } + + if (p) + index = 0; + else + p = next_task(&init_task); + + for ( ; p != &init_task; p = next_task(p)) { int tgid = p->pid; if (!pid_alive(p)) continue; @@ -1739,7 +1751,10 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir) nr++; } - nr_tgids = get_tgid_list(nr, tgid_array); + /* + * f_version caches the last tgid which was returned from readdir + */ + nr_tgids = get_tgid_list(nr, filp->f_version, tgid_array); for (i = 0; i < nr_tgids; i++) { int tgid = tgid_array[i]; @@ -1748,8 +1763,10 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir) do buf[--j] = '0' + (tgid % 10); while (tgid/=10); - if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino, DT_DIR) < 0) + if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino, DT_DIR) < 0) { + filp->f_version = tgid; break; + } filp->f_pos++; } return 0; diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 739ca9f198e9..1a7440ae3902 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -76,22 +76,6 @@ int task_statm(struct mm_struct *mm, int *shared, int *text, return size; } -#ifdef AT_SYSINFO_EHDR - -static struct vm_area_struct gate_vmarea = { - /* Do _not_ mark this area as readable, cuz not the entire range may be readable - (e.g., due to execute-only pages or holes) and the tools that read - /proc/PID/maps should read the interesting bits from the gate-DSO file - instead. */ - .vm_start = FIXADDR_USER_START, - .vm_end = FIXADDR_USER_END -}; - -# define gate_map() &gate_vmarea -#else -# define gate_map() NULL -#endif - static int show_map(struct seq_file *m, void *v) { struct vm_area_struct *map = v; @@ -146,15 +130,16 @@ static void *m_start(struct seq_file *m, loff_t *pos) up_read(&mm->mmap_sem); mmput(mm); if (l == -1) - map = gate_map(); + map = get_gate_vma(task); } return map; } static void m_stop(struct seq_file *m, void *v) { + struct task_struct *task = m->private; struct vm_area_struct *map = v; - if (map && map != gate_map()) { + if (map && map != get_gate_vma(task)) { struct mm_struct *mm = map->vm_mm; up_read(&mm->mmap_sem); mmput(mm); @@ -163,13 +148,14 @@ static void m_stop(struct seq_file *m, void *v) static void *m_next(struct seq_file *m, void *v, loff_t *pos) { + struct task_struct *task = m->private; struct vm_area_struct *map = v; (*pos)++; if (map->vm_next) return map->vm_next; m_stop(m, v); - if (map != gate_map()) - return gate_map(); + if (map != get_gate_vma(task)) + return get_gate_vma(task); return NULL; } diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index 572b30f3f417..5d326d6445a5 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c @@ -8,6 +8,7 @@ #include <linux/smp_lock.h> #include <asm/uaccess.h> #include <linux/pagemap.h> +#include <linux/writeback.h> /* ** We pack the tails of files on file close, not at the time they are written. @@ -1176,6 +1177,7 @@ ssize_t reiserfs_file_write( struct file *file, /* the file we are going to writ buf += write_bytes; *ppos = pos += write_bytes; count -= write_bytes; + balance_dirty_pages_ratelimited(inode->i_mapping); } if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) diff --git a/include/asm-alpha/processor.h b/include/asm-alpha/processor.h index fe03e7309686..3c750a362c44 100644 --- a/include/asm-alpha/processor.h +++ b/include/asm-alpha/processor.h @@ -78,6 +78,11 @@ unsigned long get_wchan(struct task_struct *p); #define ARCH_HAS_PREFETCHW #define ARCH_HAS_SPINLOCK_PREFETCH +#ifndef CONFIG_SMP +/* Nothing to prefetch. */ +#define spin_lock_prefetch(lock) do { } while (0) +#endif + #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) extern inline void prefetch(const void *ptr) { @@ -89,10 +94,13 @@ extern inline void prefetchw(const void *ptr) __builtin_prefetch(ptr, 1, 3); } +#ifdef CONFIG_SMP extern inline void spin_lock_prefetch(const void *ptr) { __builtin_prefetch(ptr, 1, 3); } +#endif + #else extern inline void prefetch(const void *ptr) { @@ -104,10 +112,13 @@ extern inline void prefetchw(const void *ptr) __asm__ ("ldq $31,%0" : : "m"(*(char *)ptr)); } +#ifdef CONFIG_SMP extern inline void spin_lock_prefetch(const void *ptr) { __asm__ ("ldq $31,%0" : : "m"(*(char *)ptr)); } +#endif + #endif /* GCC 3.1 */ #endif /* __ASM_ALPHA_PROCESSOR_H */ diff --git a/include/asm-alpha/topology.h b/include/asm-alpha/topology.h index 742b68802fd0..dbdb0d4f90e1 100644 --- a/include/asm-alpha/topology.h +++ b/include/asm-alpha/topology.h @@ -16,8 +16,7 @@ static inline int cpu_to_node(int cpu) node = alpha_mv.cpuid_to_nid(cpu); #ifdef DEBUG_NUMA - if (node < 0) - BUG(); + BUG_ON(node < 0); #endif return node; diff --git a/include/asm-arm/arch-ebsa285/io.h b/include/asm-arm/arch-ebsa285/io.h index aac50402bc1b..8511b2ce534f 100644 --- a/include/asm-arm/arch-ebsa285/io.h +++ b/include/asm-arm/arch-ebsa285/io.h @@ -27,15 +27,13 @@ static inline unsigned long ___mem_pci(unsigned long a) { - if (a <= 0xc0000000 || a >= 0xe0000000) - BUG(); + BUG_ON(a <= 0xc0000000 || a >= 0xe0000000); return a; } static inline unsigned long ___mem_isa(unsigned long a) { - if (a >= 16*1048576) - BUG(); + BUG_ON(a >= 16*1048576); return PCIMEM_BASE + a; } #define __mem_pci(a) ___mem_pci((unsigned long)(a)) diff --git a/include/asm-arm/arch-nexuspci/io.h b/include/asm-arm/arch-nexuspci/io.h index 8afa61e6acba..181bdb5988df 100644 --- a/include/asm-arm/arch-nexuspci/io.h +++ b/include/asm-arm/arch-nexuspci/io.h @@ -28,8 +28,7 @@ static inline unsigned long ___mem_pci(unsigned long a) static inline unsigned long ___mem_isa(unsigned long a) { - if (a >= 16*1048576) - BUG(); + BUG_ON(a >= 16*1048576); return PCIMEM_BASE + a; } #define __mem_pci(a) ___mem_pci((unsigned long)(a)) diff --git a/include/asm-i386/genapic.h b/include/asm-i386/genapic.h index 76465ccbbdf8..7a165f27c880 100644 --- a/include/asm-i386/genapic.h +++ b/include/asm-i386/genapic.h @@ -45,6 +45,7 @@ struct genapic { void (*setup_portio_remap)(void); int (*check_phys_apicid_present)(int boot_cpu_physical_apicid); void (*enable_apic_mode)(void); + u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb); /* mpparse */ void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *, @@ -105,6 +106,7 @@ struct genapic { APICFUNC(send_IPI_allbutself), \ APICFUNC(send_IPI_all), \ APICFUNC(enable_apic_mode), \ + APICFUNC(phys_pkg_id), \ } extern struct genapic *genapic; diff --git a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h index ffc472ff5418..9382e160c46d 100644 --- a/include/asm-i386/hpet.h +++ b/include/asm-i386/hpet.h @@ -54,14 +54,10 @@ #define HPET_T2_CMP 0x148 #define HPET_T2_ROUTE 0x150 -#define HPET_ID_VENDOR 0xffff0000 #define HPET_ID_LEGSUP 0x00008000 #define HPET_ID_NUMBER 0x00001f00 #define HPET_ID_REV 0x000000ff -#define HPET_ID_VENDOR_SHIFT 16 -#define HPET_ID_VENDOR_8086 0x8086 - #define HPET_CFG_ENABLE 0x001 #define HPET_CFG_LEGACY 0x002 diff --git a/include/asm-i386/mach-bigsmp/mach_apic.h b/include/asm-i386/mach-bigsmp/mach_apic.h index 0e9855144660..12980e389c65 100644 --- a/include/asm-i386/mach-bigsmp/mach_apic.h +++ b/include/asm-i386/mach-bigsmp/mach_apic.h @@ -173,4 +173,9 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask) return apicid; } +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return cpuid_apic >> index_msb; +} + #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-i386/mach-default/mach_apic.h b/include/asm-i386/mach-default/mach_apic.h index 1d427aadfa41..5111b015f710 100644 --- a/include/asm-i386/mach-default/mach_apic.h +++ b/include/asm-i386/mach-default/mach_apic.h @@ -127,4 +127,9 @@ static inline void enable_apic_mode(void) { } +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return cpuid_apic >> index_msb; +} + #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-i386/mach-es7000/mach_apic.h b/include/asm-i386/mach-es7000/mach_apic.h index e15b73c7e113..72e87d081af6 100644 --- a/include/asm-i386/mach-es7000/mach_apic.h +++ b/include/asm-i386/mach-es7000/mach_apic.h @@ -192,4 +192,9 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask) return apicid; } +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return cpuid_apic >> index_msb; +} + #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-i386/mach-generic/mach_apic.h b/include/asm-i386/mach-generic/mach_apic.h index 21f0e75f1b25..ed349c793beb 100644 --- a/include/asm-i386/mach-generic/mach_apic.h +++ b/include/asm-i386/mach-generic/mach_apic.h @@ -27,5 +27,6 @@ #define check_apicid_used (genapic->check_apicid_used) #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) #define enable_apic_mode (genapic->enable_apic_mode) +#define phys_pkg_id (genapic->phys_pkg_id) #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-i386/mach-numaq/mach_apic.h b/include/asm-i386/mach-numaq/mach_apic.h index 814ee9aa2521..743bb69aa275 100644 --- a/include/asm-i386/mach-numaq/mach_apic.h +++ b/include/asm-i386/mach-numaq/mach_apic.h @@ -141,4 +141,10 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask) return (int) 0xF; } +/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return cpuid_apic >> index_msb; +} + #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-i386/mach-summit/mach_apic.h b/include/asm-i386/mach-summit/mach_apic.h index a10b4591737e..accca8fcc970 100644 --- a/include/asm-i386/mach-summit/mach_apic.h +++ b/include/asm-i386/mach-summit/mach_apic.h @@ -173,4 +173,15 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask) return apicid; } +/* cpuid returns the value latched in the HW at reset, not the APIC ID + * register's value. For any box whose BIOS changes APIC IDs, like + * clustered APIC systems, we must use hard_smp_processor_id. + * + * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID. + */ +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return hard_smp_processor_id() >> index_msb; +} + #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-i386/mach-visws/mach_apic.h b/include/asm-i386/mach-visws/mach_apic.h index 9a0208496458..3ec402a3a96a 100644 --- a/include/asm-i386/mach-visws/mach_apic.h +++ b/include/asm-i386/mach-visws/mach_apic.h @@ -88,4 +88,10 @@ static inline unsigned int cpu_mask_to_apicid(cpumask_const_t cpumask) { return cpus_coerce_const(cpumask); } + +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return cpuid_apic >> index_msb; +} + #endif /* __ASM_MACH_APIC_H */ diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h index 7b6254324cc9..d72e991e4a2b 100644 --- a/include/asm-mips/dma-mapping.h +++ b/include/asm-mips/dma-mapping.h @@ -124,8 +124,7 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, for (i = 0; i < nhwentries; i++, sg++) { unsigned long addr; - if (!sg->page) - BUG(); + BUG_ON(!sg->page); addr = (unsigned long) page_address(sg->page); if (addr) @@ -139,8 +138,7 @@ dma_sync_single(struct device *dev, dma_addr_t dma_handle, size_t size, { unsigned long addr; - if (direction == DMA_NONE) - BUG(); + BUG_ON(direction == DMA_NONE); addr = baddr_to_bus(hwdev->bus, dma_handle) + PAGE_OFFSET; dma_cache_wback_inv(addr, size); @@ -153,8 +151,7 @@ dma_sync_single_range(struct device *dev, dma_addr_t dma_handle, { unsigned long addr; - if (direction == DMA_NONE) - BUG(); + BUG_ON(direction == DMA_NONE); addr = baddr_to_bus(hwdev->bus, dma_handle) + PAGE_OFFSET; dma_cache_wback_inv(addr, size); @@ -168,8 +165,7 @@ dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems, int i; #endif - if (direction == DMA_NONE) - BUG(); + BUG_ON(direction == DMA_NONE); /* Make sure that gcc doesn't leave the empty loop body. */ #ifdef CONFIG_NONCOHERENT_IO diff --git a/include/asm-mips/pci.h b/include/asm-mips/pci.h index 56e01db6f45d..cd96c958408f 100644 --- a/include/asm-mips/pci.h +++ b/include/asm-mips/pci.h @@ -113,8 +113,7 @@ static inline void pci_dac_dma_sync_single(struct pci_dev *pdev, { unsigned long addr; - if (direction == PCI_DMA_NONE) - BUG(); + BUG_ON(direction == PCI_DMA_NONE); addr = baddr_to_bus(pdev->bus, dma_addr) + PAGE_OFFSET; dma_cache_wback_inv(addr, len); diff --git a/include/asm-parisc/mmu_context.h b/include/asm-parisc/mmu_context.h index 6327156282f2..9c05836239a2 100644 --- a/include/asm-parisc/mmu_context.h +++ b/include/asm-parisc/mmu_context.h @@ -19,8 +19,7 @@ extern void free_sid(unsigned long); static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm) { - if (atomic_read(&mm->mm_users) != 1) - BUG(); + BUG_ON(atomic_read(&mm->mm_users) != 1); mm->context = alloc_sid(); return 0; @@ -64,7 +63,7 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) * already, so we should be OK. */ - if (next == &init_mm) BUG(); /* Should never happen */ + BUG_ON(next == &init_mm); /* Should never happen */ if (next->context == 0) next->context = alloc_sid(); diff --git a/include/asm-parisc/tlbflush.h b/include/asm-parisc/tlbflush.h index a5b731f654cb..86ba2c7ec6f3 100644 --- a/include/asm-parisc/tlbflush.h +++ b/include/asm-parisc/tlbflush.h @@ -27,7 +27,7 @@ extern void flush_tlb_all(void); static inline void flush_tlb_mm(struct mm_struct *mm) { - if (mm == &init_mm) BUG(); /* Should never happen */ + BUG_ON(mm == &init_mm); /* Should never happen */ #ifdef CONFIG_SMP flush_tlb_all(); diff --git a/include/asm-ppc/highmem.h b/include/asm-ppc/highmem.h index c13b4e495519..ca057b43a2ee 100644 --- a/include/asm-ppc/highmem.h +++ b/include/asm-ppc/highmem.h @@ -63,8 +63,7 @@ static inline void *kmap(struct page *page) static inline void kunmap(struct page *page) { - if (in_interrupt()) - BUG(); + BUG_ON(in_interrupt()); if (page < highmem_start_page) return; kunmap_high(page); @@ -89,8 +88,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type) idx = type + KM_TYPE_NR*smp_processor_id(); vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE; #if HIGHMEM_DEBUG - if (!pte_none(*(kmap_pte+idx))) - BUG(); + BUG_ON(!pte_none(*(kmap_pte+idx))); #endif set_pte(kmap_pte+idx, mk_pte(page, kmap_prot)); flush_tlb_page(0, vaddr); @@ -110,8 +108,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type) return; } - if (vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE) - BUG(); + BUG_ON(vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE); /* * force other mappings to Oops if they'll try to access diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h index 763765257bfc..5dad69a5ee61 100644 --- a/include/asm-ppc/pci.h +++ b/include/asm-ppc/pci.h @@ -105,8 +105,7 @@ static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction) { - if (direction == PCI_DMA_NONE) - BUG(); + BUG_ON(direction == PCI_DMA_NONE); /* nothing to do */ } @@ -134,8 +133,7 @@ static inline dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page, static inline void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, size_t size, int direction) { - if (direction == PCI_DMA_NONE) - BUG(); + BUG_ON(direction == PCI_DMA_NONE); /* Nothing to do */ } @@ -159,8 +157,7 @@ static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, { int i; - if (direction == PCI_DMA_NONE) - BUG(); + BUG_ON(direction == PCI_DMA_NONE); /* * temporary 2.4 hack diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h index 5c3515a500a9..305ca8cd8235 100644 --- a/include/asm-ppc64/pci.h +++ b/include/asm-ppc64/pci.h @@ -65,8 +65,7 @@ static inline void pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t dma_handle, size_t size, int direction) { - if (direction == PCI_DMA_NONE) - BUG(); + BUG_ON(direction == PCI_DMA_NONE); /* nothing to do */ } @@ -74,8 +73,7 @@ static inline void pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction) { - if (direction == PCI_DMA_NONE) - BUG(); + BUG_ON(direction == PCI_DMA_NONE); /* nothing to do */ } diff --git a/include/asm-ppc64/topology.h b/include/asm-ppc64/topology.h index 9be503f666f9..a41ca6cba882 100644 --- a/include/asm-ppc64/topology.h +++ b/include/asm-ppc64/topology.h @@ -13,8 +13,7 @@ static inline int cpu_to_node(int cpu) node = numa_cpu_lookup_table[cpu]; #ifdef DEBUG_NUMA - if (node == -1) - BUG(); + BUG_ON(node == -1); #endif return node; diff --git a/include/asm-s390/idals.h b/include/asm-s390/idals.h index 64c783f9b7f2..890bc145f9dd 100644 --- a/include/asm-s390/idals.h +++ b/include/asm-s390/idals.h @@ -223,8 +223,7 @@ idal_buffer_to_user(struct idal_buffer *ib, void *to, size_t count) size_t left; int i; - if (count > ib->size) - BUG(); + BUG_ON(count > ib->size); for (i = 0; count > IDA_BLOCK_SIZE; i++) { left = copy_to_user(to, ib->data[i], IDA_BLOCK_SIZE); if (left) @@ -244,8 +243,7 @@ idal_buffer_from_user(struct idal_buffer *ib, const void *from, size_t count) size_t left; int i; - if (count > ib->size) - BUG(); + BUG_ON(count > ib->size); for (i = 0; count > IDA_BLOCK_SIZE; i++) { left = copy_from_user(ib->data[i], from, IDA_BLOCK_SIZE); if (left) diff --git a/include/asm-sh/spinlock.h b/include/asm-sh/spinlock.h index c0adea380ac7..9930f93b1f14 100644 --- a/include/asm-sh/spinlock.h +++ b/include/asm-sh/spinlock.h @@ -48,8 +48,7 @@ static inline void _raw_spin_lock(spinlock_t *lock) static inline void _raw_spin_unlock(spinlock_t *lock) { #ifdef CONFIG_DEBUG_SPINLOCK - if (!spin_is_locked(lock)) - BUG(); + BUG_ON(!spin_is_locked(lock)); #endif lock->lock = 0; diff --git a/include/asm-sparc64/floppy.h b/include/asm-sparc64/floppy.h index 8beed5df56b3..1bc43aaa49eb 100644 --- a/include/asm-sparc64/floppy.h +++ b/include/asm-sparc64/floppy.h @@ -320,10 +320,9 @@ static void sun_pci_fd_lde_broken_outb(unsigned char val, unsigned long port) static void sun_pci_fd_enable_dma(void) { - if ((NULL == sun_pci_dma_pending.buf) || + BUG_ON((NULL == sun_pci_dma_pending.buf) || (0 == sun_pci_dma_pending.len) || - (0 == sun_pci_dma_pending.direction)) - BUG(); + (0 == sun_pci_dma_pending.direction)); sun_pci_dma_current.buf = sun_pci_dma_pending.buf; sun_pci_dma_current.len = sun_pci_dma_pending.len; diff --git a/include/asm-sparc64/tlbflush.h b/include/asm-sparc64/tlbflush.h index 982829f3dc16..8c70fdd037b6 100644 --- a/include/asm-sparc64/tlbflush.h +++ b/include/asm-sparc64/tlbflush.h @@ -90,10 +90,9 @@ static __inline__ void flush_tlb_pgtables(struct mm_struct *mm, unsigned long st { /* Note the signed type. */ long s = start, e = end, vpte_base; - if (s > e) /* Nobody should call us with start below VM hole and end above. See if it is really true. */ - BUG(); + BUG_ON(s > e); #if 0 /* Currently free_pgtables guarantees this. */ s &= PMD_MASK; diff --git a/include/asm-x86_64/pgalloc.h b/include/asm-x86_64/pgalloc.h index e15895c99a4e..bebcaab3375c 100644 --- a/include/asm-x86_64/pgalloc.h +++ b/include/asm-x86_64/pgalloc.h @@ -24,8 +24,7 @@ extern __inline__ pmd_t *get_pmd(void) extern __inline__ void pmd_free(pmd_t *pmd) { - if ((unsigned long)pmd & (PAGE_SIZE-1)) - BUG(); + BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); free_page((unsigned long)pmd); } @@ -41,8 +40,7 @@ static inline pgd_t *pgd_alloc (struct mm_struct *mm) static inline void pgd_free (pgd_t *pgd) { - if ((unsigned long)pgd & (PAGE_SIZE-1)) - BUG(); + BUG_ON((unsigned long)pgd & (PAGE_SIZE-1)); free_page((unsigned long)pgd); } @@ -64,8 +62,7 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long add extern __inline__ void pte_free_kernel(pte_t *pte) { - if ((unsigned long)pte & (PAGE_SIZE-1)) - BUG(); + BUG_ON((unsigned long)pte & (PAGE_SIZE-1)); free_page((unsigned long)pte); } diff --git a/include/asm-x86_64/spinlock.h b/include/asm-x86_64/spinlock.h index ae3615feecdb..c341097c7106 100644 --- a/include/asm-x86_64/spinlock.h +++ b/include/asm-x86_64/spinlock.h @@ -70,10 +70,8 @@ typedef struct { static inline void _raw_spin_unlock(spinlock_t *lock) { #ifdef CONFIG_DEBUG_SPINLOCK - if (lock->magic != SPINLOCK_MAGIC) - BUG(); - if (!spin_is_locked(lock)) - BUG(); + BUG_ON(lock->magic != SPINLOCK_MAGIC); + BUG_ON(!spin_is_locked(lock)); #endif __asm__ __volatile__( spin_unlock_string @@ -91,10 +89,8 @@ static inline void _raw_spin_unlock(spinlock_t *lock) { char oldval = 1; #ifdef CONFIG_DEBUG_SPINLOCK - if (lock->magic != SPINLOCK_MAGIC) - BUG(); - if (!spin_is_locked(lock)) - BUG(); + BUG_ON(lock->magic != SPINLOCK_MAGIC); + BUG_ON(!spin_is_locked(lock)); #endif __asm__ __volatile__( spin_unlock_string @@ -174,8 +170,7 @@ typedef struct { static inline void _raw_read_lock(rwlock_t *rw) { #ifdef CONFIG_DEBUG_SPINLOCK - if (rw->magic != RWLOCK_MAGIC) - BUG(); + BUG_ON(rw->magic != RWLOCK_MAGIC); #endif __build_read_lock(rw, "__read_lock_failed"); } @@ -183,8 +178,7 @@ static inline void _raw_read_lock(rwlock_t *rw) static inline void _raw_write_lock(rwlock_t *rw) { #ifdef CONFIG_DEBUG_SPINLOCK - if (rw->magic != RWLOCK_MAGIC) - BUG(); + BUG_ON(rw->magic != RWLOCK_MAGIC); #endif __build_write_lock(rw, "__write_lock_failed"); } diff --git a/include/linux/bio.h b/include/linux/bio.h index 4f090059372e..d3b4e9ed4052 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -266,8 +266,7 @@ extern inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) local_irq_save(*flags); addr = (unsigned long) kmap_atomic(bvec->bv_page, KM_BIO_SRC_IRQ); - if (addr & ~PAGE_MASK) - BUG(); + BUG_ON(addr & ~PAGE_MASK); return (char *) addr + bvec->bv_offset; } diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 74b89ea0aae5..b84caaebed87 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -10,57 +10,11 @@ #include <linux/bitops.h> #include <linux/string.h> -static inline int bitmap_empty(const unsigned long *bitmap, int bits) -{ - int k, lim = bits/BITS_PER_LONG; - for (k = 0; k < lim; ++k) - if (bitmap[k]) - return 0; - - if (bits % BITS_PER_LONG) - if (bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1)) - return 0; - - return 1; -} - -static inline int bitmap_full(const unsigned long *bitmap, int bits) -{ - int k, lim = bits/BITS_PER_LONG; - for (k = 0; k < lim; ++k) - if (~bitmap[k]) - return 0; - - if (bits % BITS_PER_LONG) - if (~bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1)) - return 0; - - return 1; -} - -static inline int bitmap_equal(const unsigned long *bitmap1, - unsigned long *bitmap2, int bits) -{ - int k, lim = bits/BITS_PER_LONG;; - for (k = 0; k < lim; ++k) - if (bitmap1[k] != bitmap2[k]) - return 0; - - if (bits % BITS_PER_LONG) - if ((bitmap1[k] ^ bitmap2[k]) & - ((1UL << (bits % BITS_PER_LONG)) - 1)) - return 0; - - return 1; -} - -static inline void bitmap_complement(unsigned long *bitmap, int bits) -{ - int k; - - for (k = 0; k < BITS_TO_LONGS(bits); ++k) - bitmap[k] = ~bitmap[k]; -} +int bitmap_empty(const unsigned long *bitmap, int bits); +int bitmap_full(const unsigned long *bitmap, int bits); +int bitmap_equal(const unsigned long *bitmap1, + unsigned long *bitmap2, int bits); +void bitmap_complement(unsigned long *bitmap, int bits); static inline void bitmap_clear(unsigned long *bitmap, int bits) { @@ -78,81 +32,15 @@ static inline void bitmap_copy(unsigned long *dst, memcpy(dst, src, BITS_TO_LONGS(bits)*sizeof(unsigned long)); } -static inline void bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int shift, int bits) -{ - int k; - DECLARE_BITMAP(__shr_tmp, bits); - - bitmap_clear(__shr_tmp, bits); - for (k = 0; k < bits - shift; ++k) - if (test_bit(k + shift, src)) - set_bit(k, __shr_tmp); - bitmap_copy(dst, __shr_tmp, bits); -} - -static inline void bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int shift, int bits) -{ - int k; - DECLARE_BITMAP(__shl_tmp, bits); - - bitmap_clear(__shl_tmp, bits); - for (k = bits; k >= shift; --k) - if (test_bit(k - shift, src)) - set_bit(k, __shl_tmp); - bitmap_copy(dst, __shl_tmp, bits); -} - -static inline void bitmap_and(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits) -{ - int k; - int nr = BITS_TO_LONGS(bits); - - for (k = 0; k < nr; k++) - dst[k] = bitmap1[k] & bitmap2[k]; -} - -static inline void bitmap_or(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits) -{ - int k; - int nr = BITS_TO_LONGS(bits); - - for (k = 0; k < nr; k++) - dst[k] = bitmap1[k] | bitmap2[k]; -} - -#if BITS_PER_LONG == 32 -static inline int bitmap_weight(const unsigned long *bitmap, int bits) -{ - int k, w = 0, lim = bits/BITS_PER_LONG; - - for (k = 0; k < lim; k++) - w += hweight32(bitmap[k]); - - if (bits % BITS_PER_LONG) - w += hweight32(bitmap[k] & - ((1UL << (bits % BITS_PER_LONG)) - 1)); - - return w; -} -#else -static inline int bitmap_weight(const unsigned long *bitmap, int bits) -{ - int k, w = 0, lim = bits/BITS_PER_LONG; - - for (k = 0; k < lim; k++) - w += hweight64(bitmap[k]); - - if (bits % BITS_PER_LONG) - w += hweight64(bitmap[k] & - ((1UL << (bits % BITS_PER_LONG)) - 1)); - - return w; -} -#endif +void bitmap_shift_right(unsigned long *dst, + const unsigned long *src, int shift, int bits); +void bitmap_shift_left(unsigned long *dst, + const unsigned long *src, int shift, int bits); +void bitmap_and(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void bitmap_or(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int bitmap_weight(const unsigned long *bitmap, int bits); #endif /* __ASSEMBLY__ */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a1c5cd076331..80b4c47842b8 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -483,9 +483,9 @@ static inline void blk_queue_bounce(request_queue_t *q, struct bio **bio) } #endif /* CONFIG_MMU */ -#define rq_for_each_bio(bio, rq) \ +#define rq_for_each_bio(_bio, rq) \ if ((rq->bio)) \ - for (bio = (rq)->bio; bio; bio = bio->bi_next) + for (_bio = (rq)->bio; _bio; _bio = bio->bi_next) struct sec_size { unsigned block_size; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 5f4b675a7bb4..110584f07883 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -125,8 +125,7 @@ BUFFER_FNS(Write_EIO,write_io_error) /* If we *know* page->private refers to buffer_heads */ #define page_buffers(page) \ ({ \ - if (!PagePrivate(page)) \ - BUG(); \ + BUG_ON(!PagePrivate(page)); \ ((struct buffer_head *)(page)->private); \ }) #define page_has_buffers(page) PagePrivate(page) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 6bd0570d3a1c..6b2ea8fecf06 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -270,8 +270,7 @@ extern char * d_path(struct dentry *, struct vfsmount *, char *, int); static inline struct dentry *dget(struct dentry *dentry) { if (dentry) { - if (!atomic_read(&dentry->d_count)) - BUG(); + BUG_ON(!atomic_read(&dentry->d_count)); atomic_inc(&dentry->d_count); } return dentry; diff --git a/include/linux/efi.h b/include/linux/efi.h index 86e9d2ebb5eb..a1764b1fb106 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -297,14 +297,22 @@ extern u64 efi_mem_attributes (unsigned long phys_addr); extern void efi_initialize_iomem_resources(struct resource *code_resource, struct resource *data_resource); extern efi_status_t phys_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc); -extern unsigned long inline __init efi_get_time(void); -extern int inline __init efi_set_rtc_mmss(unsigned long nowtime); +extern inline unsigned long __init efi_get_time(void); +extern inline int __init efi_set_rtc_mmss(unsigned long nowtime); extern struct efi_memory_map memmap; +/* + * We play games with efi_enabled so that the compiler will, if possible, remove + * EFI-related code altogether. + */ #ifdef CONFIG_EFI -extern int efi_enabled; +# ifdef CONFIG_X86 + extern int efi_enabled; +# else +# define efi_enabled 1 +# endif #else -#define efi_enabled 0 +# define efi_enabled 0 #endif /* diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h index 13178c16c7ea..4eda0ed76a48 100644 --- a/include/linux/ext2_fs_sb.h +++ b/include/linux/ext2_fs_sb.h @@ -45,6 +45,7 @@ struct ext2_sb_info { int s_desc_per_block_bits; int s_inode_size; int s_first_ino; + spinlock_t s_next_gen_lock; u32 s_next_generation; unsigned long s_dir_count; u8 *s_debts; diff --git a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h index e9b4012cc776..590fd69ec045 100644 --- a/include/linux/ext3_fs_sb.h +++ b/include/linux/ext3_fs_sb.h @@ -49,6 +49,7 @@ struct ext3_sb_info { int s_desc_per_block_bits; int s_inode_size; int s_first_ino; + spinlock_t s_next_gen_lock; u32 s_next_generation; u32 s_hash_seed[4]; int s_def_hash_version; diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h index 50caf6875ba4..a3555b48cccb 100644 --- a/include/linux/ext3_jbd.h +++ b/include/linux/ext3_jbd.h @@ -221,13 +221,24 @@ static inline int ext3_should_journal_data(struct inode *inode) static inline int ext3_should_order_data(struct inode *inode) { - return (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA); + if (!S_ISREG(inode->i_mode)) + return 0; + if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) + return 0; + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) + return 1; + return 0; } static inline int ext3_should_writeback_data(struct inode *inode) { - return !ext3_should_journal_data(inode) && - !ext3_should_order_data(inode); + if (!S_ISREG(inode->i_mode)) + return 0; + if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) + return 0; + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) + return 1; + return 0; } #endif /* _LINUX_EXT3_JBD_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index fd3c87c86d6f..7d9154665d9b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -353,6 +353,13 @@ struct block_device { int bd_invalidated; struct gendisk * bd_disk; struct list_head bd_list; + /* + * Private data. You must have bd_claim'ed the block_device + * to use this. NOTE: bd_claim allows an owner to claim + * the same device multiple times, the owner must take special + * care to not mess up bd_private for that case. + */ + unsigned long bd_private; }; /* diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 2c9139a94f8f..232d8fdb557c 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -56,8 +56,7 @@ static inline void memclear_highpage_flush(struct page *page, unsigned int offse { void *kaddr; - if (offset + size > PAGE_SIZE) - BUG(); + BUG_ON(offset + size > PAGE_SIZE); kaddr = kmap_atomic(page, KM_USER0); memset((char *)kaddr + offset, 0, size); diff --git a/include/linux/mm.h b/include/linux/mm.h index 881091514f01..3ecd3d633c5f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -223,7 +223,6 @@ struct page { atomic_dec_and_test(&(p)->count); \ }) -#define page_count(p) atomic_read(&(p)->count) #define set_page_count(p,v) atomic_set(&(p)->count, v) #define __put_page(p) atomic_dec(&(p)->count) @@ -231,6 +230,13 @@ extern void FASTCALL(__page_cache_release(struct page *)); #ifdef CONFIG_HUGETLB_PAGE +static inline int page_count(struct page *p) +{ + if (PageCompound(p)) + p = (struct page *)p->lru.next; + return atomic_read(&(p)->count); +} + static inline void get_page(struct page *page) { if (PageCompound(page)) @@ -257,6 +263,8 @@ static inline void put_page(struct page *page) #else /* CONFIG_HUGETLB_PAGE */ +#define page_count(p) atomic_read(&(p)->count) + static inline void get_page(struct page *page) { atomic_inc(&page->count); @@ -322,23 +330,33 @@ static inline void put_page(struct page *page) /* * The zone field is never updated after free_area_init_core() * sets it, so none of the operations on it need to be atomic. - * We'll have up to log2(MAX_NUMNODES * MAX_NR_ZONES) zones - * total, so we use NODES_SHIFT here to get enough bits. + * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total, + * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits. */ -#define ZONE_SHIFT (BITS_PER_LONG - NODES_SHIFT - MAX_NR_ZONES_SHIFT) +#define NODEZONE_SHIFT (BITS_PER_LONG - MAX_NODES_SHIFT - MAX_ZONES_SHIFT) +#define NODEZONE(node, zone) ((node << ZONES_SHIFT) | zone) + +static inline unsigned long page_zonenum(struct page *page) +{ + return (page->flags >> NODEZONE_SHIFT) & (~(~0UL << ZONES_SHIFT)); +} +static inline unsigned long page_nodenum(struct page *page) +{ + return (page->flags >> (NODEZONE_SHIFT + ZONES_SHIFT)); +} struct zone; extern struct zone *zone_table[]; static inline struct zone *page_zone(struct page *page) { - return zone_table[page->flags >> ZONE_SHIFT]; + return zone_table[page->flags >> NODEZONE_SHIFT]; } -static inline void set_page_zone(struct page *page, unsigned long zone_num) +static inline void set_page_zone(struct page *page, unsigned long nodezone_num) { - page->flags &= ~(~0UL << ZONE_SHIFT); - page->flags |= zone_num << ZONE_SHIFT; + page->flags &= ~(~0UL << NODEZONE_SHIFT); + page->flags |= nodezone_num << NODEZONE_SHIFT; } #ifndef CONFIG_DISCONTIGMEM @@ -624,5 +642,33 @@ kernel_map_pages(struct page *page, int numpages, int enable) } #endif +#ifndef CONFIG_ARCH_GATE_AREA +#ifdef AT_SYSINFO_EHDR +static inline int in_gate_area(struct task_struct *task, unsigned long addr) +{ + if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END)) + return 1; + else + return 0; +} + +extern struct vm_area_struct gate_vma; +static inline struct vm_area_struct *get_gate_vma(struct task_struct *tsk) +{ + return &gate_vma; +} +#else +static inline int in_gate_area(struct task_struct *task, unsigned long addr) +{ + return 0; +} + +static inline struct vm_area_struct *get_gate_vma(struct task_struct *tsk) +{ + return NULL; +} +#endif +#endif + #endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */ diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index a089e01dad03..66cbaa36d878 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -160,12 +160,19 @@ struct zone { #define ZONE_NORMAL 1 #define ZONE_HIGHMEM 2 -#define MAX_NR_ZONES 3 /* Sync this with MAX_NR_ZONES_SHIFT */ -#define MAX_NR_ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ +#define MAX_NR_ZONES 3 /* Sync this with ZONES_SHIFT */ +#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ #define GFP_ZONEMASK 0x03 /* + * The "priority" of VM scanning is how much of the queues we will scan in one + * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the + * queues ("queue_length >> 12") during an aging round. + */ +#define DEF_PRIORITY 12 + +/* * One allocation request operates on a zonelist. A zonelist * is a list of zones, the first one is the 'goal' of the * allocation, the other zones are fallback zones, in decreasing @@ -303,7 +310,7 @@ int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *, extern struct pglist_data contig_page_data; #define NODE_DATA(nid) (&contig_page_data) #define NODE_MEM_MAP(nid) mem_map -#define MAX_NODES_SHIFT 0 +#define MAX_NODES_SHIFT 1 #else /* CONFIG_DISCONTIGMEM */ @@ -311,7 +318,7 @@ extern struct pglist_data contig_page_data; #if BITS_PER_LONG == 32 /* - * with 32 bit flags field, page->zone is currently 8 bits. + * with 32 bit page->flags field, we reserve 8 bits for node/zone info. * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. */ #define MAX_NODES_SHIFT 6 @@ -328,6 +335,13 @@ extern struct pglist_data contig_page_data; #error NODES_SHIFT > MAX_NODES_SHIFT #endif +/* There are currently 3 zones: DMA, Normal & Highmem, thus we need 2 bits */ +#define MAX_ZONES_SHIFT 2 + +#if ZONES_SHIFT > MAX_ZONES_SHIFT +#error ZONES_SHIFT > MAX_ZONES_SHIFT +#endif + extern DECLARE_BITMAP(node_online_map, MAX_NUMNODES); extern DECLARE_BITMAP(memblk_online_map, MAX_NR_MEMBLKS); diff --git a/include/linux/module.h b/include/linux/module.h index 13ff244afdbf..c0418e47a296 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -60,6 +60,7 @@ search_extable(const struct exception_table_entry *first, #define __module_cat(a,b) ___module_cat(a,b) #define __MODULE_INFO(tag, name, info) \ static const char __module_cat(name,__LINE__)[] \ + __attribute_used__ \ __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info #define MODULE_GENERIC_TABLE(gtype,name) \ @@ -142,6 +143,7 @@ void *__symbol_get_gpl(const char *symbol); #define __CRC_SYMBOL(sym, sec) \ extern void *__crc_##sym __attribute__((weak)); \ static const unsigned long __kcrctab_##sym \ + __attribute_used__ \ __attribute__((section("__kcrctab" sec), unused)) \ = (unsigned long) &__crc_##sym; #else @@ -155,6 +157,7 @@ void *__symbol_get_gpl(const char *symbol); __attribute__((section("__ksymtab_strings"))) \ = MODULE_SYMBOL_PREFIX #sym; \ static const struct kernel_symbol __ksymtab_##sym \ + __attribute_used__ \ __attribute__((section("__ksymtab" sec), unused)) \ = { (unsigned long)&sym, __kstrtab_##sym } diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 0a5becbed774..cbca00722b5c 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -52,6 +52,7 @@ struct kparam_array #define __module_param_call(prefix, name, set, get, arg, perm) \ static char __param_str_##name[] __initdata = prefix #name; \ static struct kernel_param const __param_##name \ + __attribute_used__ \ __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ = { __param_str_##name, perm, set, get, arg } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 666d89f875f5..cfdeaaad2b7e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -831,7 +831,7 @@ static inline void netif_rx_complete(struct net_device *dev) unsigned long flags; local_irq_save(flags); - if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG(); + BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state)); list_del(&dev->poll_list); smp_mb__before_clear_bit(); clear_bit(__LINK_STATE_RX_SCHED, &dev->state); @@ -857,7 +857,7 @@ static inline void netif_poll_enable(struct net_device *dev) */ static inline void __netif_rx_complete(struct net_device *dev) { - if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG(); + BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state)); list_del(&dev->poll_list); smp_mb__before_clear_bit(); clear_bit(__LINK_STATE_RX_SCHED, &dev->state); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 93edc5a5ad98..5ae592b26d63 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -255,8 +255,7 @@ nfs_file_cred(struct file *file) if (file) cred = (struct rpc_cred *)file->private_data; #ifdef RPC_DEBUG - if (cred && cred->cr_magic != RPCAUTH_CRED_MAGIC) - BUG(); + BUG_ON(cred && cred->cr_magic != RPCAUTH_CRED_MAGIC); #endif return cred; } diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 86d2bbccd9ea..4dba6ec06e3a 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -291,6 +291,7 @@ #define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967 /* Radeon RV280 (9200) */ #define PCI_DEVICE_ID_ATI_RADEON_Y_ 0x5960 +#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964 /* Radeon R300 (9500) */ #define PCI_DEVICE_ID_ATI_RADEON_AD 0x4144 /* Radeon R300 (9700) */ diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index ad88acfd7b70..155c9a2af016 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -44,8 +44,7 @@ extern struct quotactl_ops vfs_quotactl_ops; static __inline__ void DQUOT_INIT(struct inode *inode) { - if (!inode->i_sb) - BUG(); + BUG_ON(!inode->i_sb); if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) inode->i_sb->dq_op->initialize(inode, -1); } @@ -53,8 +52,7 @@ static __inline__ void DQUOT_INIT(struct inode *inode) static __inline__ void DQUOT_DROP(struct inode *inode) { if (IS_QUOTAINIT(inode)) { - if (!inode->i_sb) - BUG(); + BUG_ON(!inode->i_sb); inode->i_sb->dq_op->drop(inode); /* Ops must be set when there's any quota... */ } } diff --git a/include/linux/sched.h b/include/linux/sched.h index dba09fa98441..f5f84aedbaec 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -50,7 +50,7 @@ struct exec_domain; #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */ -#define CLONE_DETACHED 0x00400000 /* Not used - CLONE_THREAD implies detached uniquely */ +#define CLONE_DETACHED 0x00400000 /* Unused, ignored */ #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ #define CLONE_STOPPED 0x02000000 /* Start in stopped state */ diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h index 80fbd56eb3e4..9a20995c531a 100644 --- a/include/linux/smp_lock.h +++ b/include/linux/smp_lock.h @@ -49,8 +49,7 @@ static inline void lock_kernel(void) static inline void unlock_kernel(void) { - if (unlikely(current->lock_depth < 0)) - BUG(); + BUG_ON(current->lock_depth < 0); if (likely(--current->lock_depth < 0)) put_kernel_lock(); } diff --git a/include/net/sock.h b/include/net/sock.h index 16e129f90426..115ace226a2a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -473,8 +473,8 @@ static __inline__ void sk_set_owner(struct sock *sk, struct module *owner) * change the ownership of this struct sock, with one not needed * transient sk_set_owner call. */ - if (unlikely(sk->sk_owner != NULL)) - BUG(); + BUG_ON(sk->sk_owner != NULL); + sk->sk_owner = owner; __module_get(owner); } diff --git a/include/net/tcp.h b/include/net/tcp.h index aeea9b268f80..4ef3b80fe541 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1457,7 +1457,7 @@ static __inline__ int tcp_prequeue(struct sock *sk, struct sk_buff *skb) if (tp->ucopy.memory > sk->sk_rcvbuf) { struct sk_buff *skb1; - if (sock_owned_by_user(sk)) BUG(); + BUG_ON(sock_owned_by_user(sk)); while ((skb1 = __skb_dequeue(&tp->ucopy.prequeue)) != NULL) { sk->sk_backlog_rcv(sk, skb1); diff --git a/include/rxrpc/call.h b/include/rxrpc/call.h index 6ac1df7012e9..9f0ce416a13e 100644 --- a/include/rxrpc/call.h +++ b/include/rxrpc/call.h @@ -187,8 +187,7 @@ extern int rxrpc_incoming_call(struct rxrpc_connection *conn, static inline void rxrpc_get_call(struct rxrpc_call *call) { - if (atomic_read(&call->usage)<=0) - BUG(); + BUG_ON(atomic_read(&call->usage)<=0); atomic_inc(&call->usage); /*printk("rxrpc_get_call(%p{u=%d})\n",(C),atomic_read(&(C)->usage));*/ } diff --git a/include/rxrpc/connection.h b/include/rxrpc/connection.h index 14de354724f9..f22e71097952 100644 --- a/include/rxrpc/connection.h +++ b/include/rxrpc/connection.h @@ -67,8 +67,7 @@ extern int rxrpc_connection_lookup(struct rxrpc_peer *peer, static inline void rxrpc_get_connection(struct rxrpc_connection *conn) { - if (atomic_read(&conn->usage)<0) - BUG(); + BUG_ON(atomic_read(&conn->usage)<0); atomic_inc(&conn->usage); //printk("rxrpc_get_conn(%p{u=%d})\n",conn,atomic_read(&conn->usage)); } diff --git a/include/rxrpc/message.h b/include/rxrpc/message.h index 9be208ab079e..d5755c6db3a8 100644 --- a/include/rxrpc/message.h +++ b/include/rxrpc/message.h @@ -53,8 +53,7 @@ struct rxrpc_message extern void __rxrpc_put_message(struct rxrpc_message *msg); static inline void rxrpc_put_message(struct rxrpc_message *msg) { - if (atomic_read(&msg->usage)<=0) - BUG(); + BUG_ON(atomic_read(&msg->usage)<=0); if (atomic_dec_and_test(&msg->usage)) __rxrpc_put_message(msg); } diff --git a/include/rxrpc/peer.h b/include/rxrpc/peer.h index 07e3a51b60b6..da4832fccd6a 100644 --- a/include/rxrpc/peer.h +++ b/include/rxrpc/peer.h @@ -72,8 +72,7 @@ extern int rxrpc_peer_lookup(struct rxrpc_transport *trans, static inline void rxrpc_get_peer(struct rxrpc_peer *peer) { - if (atomic_read(&peer->usage)<0) - BUG(); + BUG_ON(atomic_read(&peer->usage)<0); atomic_inc(&peer->usage); //printk("rxrpc_get_peer(%p{u=%d})\n",peer,atomic_read(&peer->usage)); } diff --git a/include/rxrpc/transport.h b/include/rxrpc/transport.h index 92fb49c7d4b9..6aa88691186c 100644 --- a/include/rxrpc/transport.h +++ b/include/rxrpc/transport.h @@ -85,8 +85,7 @@ extern int rxrpc_create_transport(unsigned short port, static inline void rxrpc_get_transport(struct rxrpc_transport *trans) { - if (atomic_read(&trans->usage) <= 0) - BUG(); + BUG_ON(atomic_read(&trans->usage) <= 0); atomic_inc(&trans->usage); //printk("rxrpc_get_transport(%p{u=%d})\n", // trans, atomic_read(&trans->usage)); diff --git a/init/main.c b/init/main.c index 41d1a2931b02..4c26b3769e80 100644 --- a/init/main.c +++ b/init/main.c @@ -105,7 +105,7 @@ int system_running; extern void time_init(void); /* Default late time init is NULL. archs can override this later. */ -void (*late_time_init)(void) = NULL; +void (*late_time_init)(void); extern void softirq_init(void); static char *execute_command; diff --git a/kernel/cpu.c b/kernel/cpu.c index 939fc284029d..0652d1871f2f 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -14,7 +14,7 @@ /* This protects CPUs going up and down... */ DECLARE_MUTEX(cpucontrol); -static struct notifier_block *cpu_chain = NULL; +static struct notifier_block *cpu_chain; /* Need to know about CPUs going up/down? */ int register_cpu_notifier(struct notifier_block *nb) diff --git a/kernel/dma.c b/kernel/dma.c index 7ad7fbf83a83..af1d982a0c57 100644 --- a/kernel/dma.c +++ b/kernel/dma.c @@ -136,20 +136,7 @@ static int proc_dma_show(struct seq_file *m, void *v) static int proc_dma_open(struct inode *inode, struct file *file) { - char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); - struct seq_file *m; - int res; - - if (!buf) - return -ENOMEM; - res = single_open(file, proc_dma_show, NULL); - if (!res) { - m = file->private_data; - m->buf = buf; - m->size = PAGE_SIZE; - } else - kfree(buf); - return res; + return single_open(file, proc_dma_show, NULL); } static struct file_operations proc_dma_operations = { diff --git a/kernel/fork.c b/kernel/fork.c index ea2eeb1ed644..b703d95dadc7 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -859,22 +859,6 @@ struct task_struct *copy_process(unsigned long clone_flags, if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM)) return ERR_PTR(-EINVAL); - /* - * CLONE_DETACHED must match CLONE_THREAD: it's a historical - * thing. - */ - if (!(clone_flags & CLONE_DETACHED) != !(clone_flags & CLONE_THREAD)) { - /* Warn about the old no longer supported case so that we see it */ - if (clone_flags & CLONE_THREAD) { - static int count; - if (count < 5) { - count++; - printk(KERN_WARNING "%s trying to use CLONE_THREAD without CLONE_DETACH\n", current->comm); - } - } - return ERR_PTR(-EINVAL); - } - retval = security_task_create(clone_flags); if (retval) goto fork_out; diff --git a/kernel/module.c b/kernel/module.c index 65f82a3278dd..f3113ff19818 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -687,8 +687,8 @@ sys_delete_module(const char __user *name_user, unsigned int flags) goto out; } - /* Already dying? */ - if (mod->state == MODULE_STATE_GOING) { + /* Doing init or already dying? */ + if (mod->state != MODULE_STATE_LIVE) { /* FIXME: if (force), slam module count and wake up waiter --RR */ DEBUGP("%s already dying\n", mod->name); diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 431002eebb0a..784c59eb3933 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c @@ -574,7 +574,7 @@ static struct k_itimer * lock_timer(timer_t timer_id, unsigned long *flags) * it is the same as a requeue pending timer WRT to what we should * report. */ -void inline +static void do_timer_gettime(struct k_itimer *timr, struct itimerspec *cur_setting) { unsigned long expires; diff --git a/kernel/sched.c b/kernel/sched.c index 87c77974e10a..d233ad6a44fe 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -540,6 +540,43 @@ inline int task_curr(task_t *p) } #ifdef CONFIG_SMP +typedef struct { + struct list_head list; + task_t *task; + struct completion done; +} migration_req_t; + +/* + * The task's runqueue lock must be held, and the new mask must be valid. + * Returns true if you have to wait for migration thread. + */ +static int __set_cpus_allowed(task_t *p, cpumask_t new_mask, + migration_req_t *req) +{ + runqueue_t *rq = task_rq(p); + + p->cpus_allowed = new_mask; + /* + * Can the task run on the task's current CPU? If not then + * migrate the thread off to a proper CPU. + */ + if (cpu_isset(task_cpu(p), new_mask)) + return 0; + + /* + * If the task is not on a runqueue (and not running), then + * it is sufficient to simply update the task's cpu field. + */ + if (!p->array && !task_running(rq, p)) { + set_task_cpu(p, any_online_cpu(p->cpus_allowed)); + return 0; + } + + init_completion(&req->done); + req->task = p; + list_add(&req->list, &rq->migration_queue); + return 1; +} /* * wait_task_inactive - wait for a thread to unschedule. @@ -971,16 +1008,34 @@ static inline void double_rq_unlock(runqueue_t *rq1, runqueue_t *rq2) */ static void sched_migrate_task(task_t *p, int dest_cpu) { - cpumask_t old_mask; + runqueue_t *rq; + migration_req_t req; + unsigned long flags; + cpumask_t old_mask, new_mask = cpumask_of_cpu(dest_cpu); + rq = task_rq_lock(p, &flags); old_mask = p->cpus_allowed; - if (!cpu_isset(dest_cpu, old_mask)) - return; - /* force the process onto the specified CPU */ - set_cpus_allowed(p, cpumask_of_cpu(dest_cpu)); + if (!cpu_isset(dest_cpu, old_mask) || !cpu_online(dest_cpu)) + goto out; - /* restore the cpus allowed mask */ - set_cpus_allowed(p, old_mask); + /* force the process onto the specified CPU */ + if (__set_cpus_allowed(p, new_mask, &req)) { + /* Need to wait for migration thread. */ + task_rq_unlock(rq, &flags); + wake_up_process(rq->migration_thread); + wait_for_completion(&req.done); + + /* If we raced with sys_sched_setaffinity, don't + * restore mask. */ + rq = task_rq_lock(p, &flags); + if (likely(cpus_equal(p->cpus_allowed, new_mask))) { + /* Restore old mask: won't need migration + * thread, since current cpu is allowed. */ + BUG_ON(__set_cpus_allowed(p, old_mask, NULL)); + } + } +out: + task_rq_unlock(rq, &flags); } /* @@ -2129,7 +2184,7 @@ static int setscheduler(pid_t pid, int policy, struct sched_param __user *param) * our priority decreased, or if we are not currently running on * this runqueue and our priority is higher than the current's */ - if (rq->curr == p) { + if (task_running(rq, p)) { if (p->prio > oldprio) resched_task(rq->curr); } else if (p->prio < rq->curr->prio) @@ -2628,12 +2683,6 @@ void __init init_idle(task_t *idle, int cpu) * 7) we wake up and the migration is done. */ -typedef struct { - struct list_head list; - task_t *task; - struct completion done; -} migration_req_t; - /* * Change a given task's CPU affinity. Migrate the thread to a * proper CPU and schedule it away if the CPU it's executing on @@ -2646,40 +2695,26 @@ typedef struct { int set_cpus_allowed(task_t *p, cpumask_t new_mask) { unsigned long flags; + int ret = 0; migration_req_t req; runqueue_t *rq; - if (any_online_cpu(new_mask) == NR_CPUS) - return -EINVAL; - rq = task_rq_lock(p, &flags); - p->cpus_allowed = new_mask; - /* - * Can the task run on the task's current CPU? If not then - * migrate the thread off to a proper CPU. - */ - if (cpu_isset(task_cpu(p), new_mask)) { - task_rq_unlock(rq, &flags); - return 0; + if (any_online_cpu(new_mask) == NR_CPUS) { + ret = -EINVAL; + goto out; } - /* - * If the task is not on a runqueue (and not running), then - * it is sufficient to simply update the task's cpu field. - */ - if (!p->array && !task_running(rq, p)) { - set_task_cpu(p, any_online_cpu(p->cpus_allowed)); + + if (__set_cpus_allowed(p, new_mask, &req)) { + /* Need help from migration thread: drop lock and wait. */ task_rq_unlock(rq, &flags); + wake_up_process(rq->migration_thread); + wait_for_completion(&req.done); return 0; } - init_completion(&req.done); - req.task = p; - list_add(&req.list, &rq->migration_queue); +out: task_rq_unlock(rq, &flags); - - wake_up_process(rq->migration_thread); - - wait_for_completion(&req.done); - return 0; + return ret; } EXPORT_SYMBOL_GPL(set_cpus_allowed); diff --git a/kernel/sys.c b/kernel/sys.c index 9aa8ad493460..2e40d516fd75 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -249,8 +249,11 @@ cond_syscall(compat_sys_futex) cond_syscall(sys_epoll_create) cond_syscall(sys_epoll_ctl) cond_syscall(sys_epoll_wait) + +/* arch-specific weak syscall entries */ cond_syscall(sys_pciconfig_read) cond_syscall(sys_pciconfig_write) +cond_syscall(sys_pciconfig_iobase) static int set_one_prio(struct task_struct *p, int niceval, int error) { diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 4b109a7d390b..fed20b9813e5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -14,13 +14,10 @@ * Theodore Ts'o <tytso@mit.edu> */ -#define __KERNEL_SYSCALLS__ - #include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/init.h> -#include <linux/unistd.h> #include <linux/signal.h> #include <linux/completion.h> #include <linux/workqueue.h> @@ -171,7 +168,6 @@ static int worker_thread(void *__startup) struct k_sigaction sa; daemonize("%s/%d", startup->name, cpu); - allow_signal(SIGCHLD); current->flags |= PF_IOTHREAD; cwq->thread = current; @@ -180,7 +176,7 @@ static int worker_thread(void *__startup) complete(&startup->done); - /* Install a handler so SIGCLD is delivered */ + /* SIG_IGN makes children autoreap: see do_notify_parent(). */ sa.sa.sa_handler = SIG_IGN; sa.sa.sa_flags = 0; siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD)); @@ -200,14 +196,6 @@ static int worker_thread(void *__startup) if (!list_empty(&cwq->worklist)) run_workqueue(cwq); - - if (signal_pending(current)) { - while (waitpid(-1, NULL, __WALL|WNOHANG) > 0) - /* SIGCHLD - auto-reaping */ ; - - /* zap all other signals */ - flush_signals(current); - } } remove_wait_queue(&cwq->more_work, &wait); complete(&cwq->exit); diff --git a/lib/Makefile b/lib/Makefile index c588784b3bef..15f8ca078332 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -5,7 +5,8 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \ bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ - kobject.o idr.o div64.o parser.o int_sqrt.o mask.o + kobject.o idr.o div64.o parser.o int_sqrt.o mask.o \ + bitmap.o lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o diff --git a/lib/bitmap.c b/lib/bitmap.c new file mode 100644 index 000000000000..6462e071167b --- /dev/null +++ b/lib/bitmap.c @@ -0,0 +1,141 @@ +#include <linux/bitmap.h> +#include <linux/module.h> + +int bitmap_empty(const unsigned long *bitmap, int bits) +{ + int k, lim = bits/BITS_PER_LONG; + for (k = 0; k < lim; ++k) + if (bitmap[k]) + return 0; + + if (bits % BITS_PER_LONG) + if (bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1)) + return 0; + + return 1; +} +EXPORT_SYMBOL(bitmap_empty); + +int bitmap_full(const unsigned long *bitmap, int bits) +{ + int k, lim = bits/BITS_PER_LONG; + for (k = 0; k < lim; ++k) + if (~bitmap[k]) + return 0; + + if (bits % BITS_PER_LONG) + if (~bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1)) + return 0; + + return 1; +} +EXPORT_SYMBOL(bitmap_full); + +int bitmap_equal(const unsigned long *bitmap1, + unsigned long *bitmap2, int bits) +{ + int k, lim = bits/BITS_PER_LONG;; + for (k = 0; k < lim; ++k) + if (bitmap1[k] != bitmap2[k]) + return 0; + + if (bits % BITS_PER_LONG) + if ((bitmap1[k] ^ bitmap2[k]) & + ((1UL << (bits % BITS_PER_LONG)) - 1)) + return 0; + + return 1; +} +EXPORT_SYMBOL(bitmap_equal); + +void bitmap_complement(unsigned long *bitmap, int bits) +{ + int k; + int nr = BITS_TO_LONGS(bits); + + for (k = 0; k < nr; ++k) + bitmap[k] = ~bitmap[k]; +} +EXPORT_SYMBOL(bitmap_complement); + +void bitmap_shift_right(unsigned long *dst, + const unsigned long *src, int shift, int bits) +{ + int k; + DECLARE_BITMAP(__shr_tmp, bits); + + bitmap_clear(__shr_tmp, bits); + for (k = 0; k < bits - shift; ++k) + if (test_bit(k + shift, src)) + set_bit(k, __shr_tmp); + bitmap_copy(dst, __shr_tmp, bits); +} +EXPORT_SYMBOL(bitmap_shift_right); + +void bitmap_shift_left(unsigned long *dst, + const unsigned long *src, int shift, int bits) +{ + int k; + DECLARE_BITMAP(__shl_tmp, bits); + + bitmap_clear(__shl_tmp, bits); + for (k = bits; k >= shift; --k) + if (test_bit(k - shift, src)) + set_bit(k, __shl_tmp); + bitmap_copy(dst, __shl_tmp, bits); +} +EXPORT_SYMBOL(bitmap_shift_left); + +void bitmap_and(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits) +{ + int k; + int nr = BITS_TO_LONGS(bits); + + for (k = 0; k < nr; k++) + dst[k] = bitmap1[k] & bitmap2[k]; +} +EXPORT_SYMBOL(bitmap_and); + +void bitmap_or(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits) +{ + int k; + int nr = BITS_TO_LONGS(bits); + + for (k = 0; k < nr; k++) + dst[k] = bitmap1[k] | bitmap2[k]; +} +EXPORT_SYMBOL(bitmap_or); + +#if BITS_PER_LONG == 32 +int bitmap_weight(const unsigned long *bitmap, int bits) +{ + int k, w = 0, lim = bits/BITS_PER_LONG; + + for (k = 0; k < lim; k++) + w += hweight32(bitmap[k]); + + if (bits % BITS_PER_LONG) + w += hweight32(bitmap[k] & + ((1UL << (bits % BITS_PER_LONG)) - 1)); + + return w; +} +#else +int bitmap_weight(const unsigned long *bitmap, int bits) +{ + int k, w = 0, lim = bits/BITS_PER_LONG; + + for (k = 0; k < lim; k++) + w += hweight64(bitmap[k]); + + if (bits % BITS_PER_LONG) + w += hweight64(bitmap[k] & + ((1UL << (bits % BITS_PER_LONG)) - 1)); + + return w; +} +#endif +EXPORT_SYMBOL(bitmap_weight); + diff --git a/mm/filemap.c b/mm/filemap.c index b4d34de279a8..e07154c4c979 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -587,22 +587,13 @@ void do_generic_mapping_read(struct address_space *mapping, read_actor_t actor) { struct inode *inode = mapping->host; - unsigned long index, offset, last; + unsigned long index, offset; struct page *cached_page; int error; cached_page = NULL; index = *ppos >> PAGE_CACHE_SHIFT; offset = *ppos & ~PAGE_CACHE_MASK; - last = (*ppos + desc->count) >> PAGE_CACHE_SHIFT; - - /* - * Let the readahead logic know upfront about all - * the pages we'll need to satisfy this request - */ - for (; index < last; index++) - page_cache_readahead(mapping, ra, filp, index); - index = *ppos >> PAGE_CACHE_SHIFT; for (;;) { struct page *page; @@ -621,6 +612,7 @@ void do_generic_mapping_read(struct address_space *mapping, } cond_resched(); + page_cache_readahead(mapping, ra, filp, index); nr = nr - offset; find_page: diff --git a/mm/memory.c b/mm/memory.c index 7d8a8ed53143..d0c834a8ce97 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -45,6 +45,7 @@ #include <linux/pagemap.h> #include <linux/rmap-locking.h> #include <linux/module.h> +#include <linux/init.h> #include <asm/pgalloc.h> #include <asm/rmap.h> @@ -704,25 +705,13 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, struct vm_area_struct * vma; vma = find_extend_vma(mm, start); - -#ifdef FIXADDR_USER_START - if (!vma && - start >= FIXADDR_USER_START && start < FIXADDR_USER_END) { - static struct vm_area_struct fixmap_vma = { - /* Catch users - if there are any valid - ones, we can make this be "&init_mm" or - something. */ - .vm_mm = NULL, - .vm_start = FIXADDR_USER_START, - .vm_end = FIXADDR_USER_END, - .vm_page_prot = PAGE_READONLY, - .vm_flags = VM_READ | VM_EXEC, - }; + if (!vma && in_gate_area(tsk, start)) { unsigned long pg = start & PAGE_MASK; + struct vm_area_struct *gate_vma = get_gate_vma(tsk); pgd_t *pgd; pmd_t *pmd; pte_t *pte; - if (write) /* user fixmap pages are read-only */ + if (write) /* user gate pages are read-only */ return i ? : -EFAULT; pgd = pgd_offset_k(pg); if (!pgd) @@ -738,13 +727,12 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, get_page(pages[i]); } if (vmas) - vmas[i] = &fixmap_vma; + vmas[i] = gate_vma; i++; start += PAGE_SIZE; len--; continue; } -#endif if (!vma || (pages && (vma->vm_flags & VM_IO)) || !(flags & vma->vm_flags)) @@ -1433,10 +1421,8 @@ retry: */ if (write_access && !(vma->vm_flags & VM_SHARED)) { struct page * page = alloc_page(GFP_HIGHUSER); - if (!page) { - page_cache_release(new_page); + if (!page) goto oom; - } copy_user_highpage(page, new_page, address); page_cache_release(new_page); lru_cache_add_active(page); @@ -1493,6 +1479,7 @@ retry: spin_unlock(&mm->page_table_lock); goto out; oom: + page_cache_release(new_page); ret = VM_FAULT_OOM; out: pte_chain_free(pte_chain); @@ -1700,3 +1687,18 @@ struct page * vmalloc_to_page(void * vmalloc_addr) } EXPORT_SYMBOL(vmalloc_to_page); + +#if !defined(CONFIG_ARCH_GATE_AREA) && defined(AT_SYSINFO_EHDR) +struct vm_area_struct gate_vma; + +static int __init gate_vma_init(void) +{ + gate_vma.vm_mm = NULL; + gate_vma.vm_start = FIXADDR_USER_START; + gate_vma.vm_end = FIXADDR_USER_END; + gate_vma.vm_page_prot = PAGE_READONLY; + gate_vma.vm_flags = 0; + return 0; +} +__initcall(gate_vma_init); +#endif diff --git a/mm/nommu.c b/mm/nommu.c index 2d38a9f89fc0..c940756b49e5 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -25,12 +25,12 @@ #include <asm/tlbflush.h> void *high_memory; -struct page *mem_map = NULL; +struct page *mem_map; unsigned long max_mapnr; unsigned long num_physpages; unsigned long askedalloc, realalloc; atomic_t vm_committed_space = ATOMIC_INIT(0); -int sysctl_overcommit_memory = 0; /* default is heuristic overcommit */ +int sysctl_overcommit_memory; /* default is heuristic overcommit */ int sysctl_overcommit_ratio = 50; /* default is 50% */ /* diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 052b2201eb6d..1ad6717ade97 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -233,6 +233,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) } put_cpu_var(ratelimits); } +EXPORT_SYMBOL(balance_dirty_pages_ratelimited); /* * writeback at least _min_pages, and keep writing until the amount of dirty diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c3de7ee44d6e..b2a185f246d4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -50,7 +50,7 @@ EXPORT_SYMBOL(nr_swap_pages); * Used by page_zone() to look up the address of the struct zone whose * id is encoded in the upper bits of page->flags */ -struct zone *zone_table[MAX_NR_ZONES*MAX_NUMNODES]; +struct zone *zone_table[1 << (ZONES_SHIFT + NODES_SHIFT)]; EXPORT_SYMBOL(zone_table); static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" }; @@ -1212,7 +1212,7 @@ void __init memmap_init_zone(struct page *start, unsigned long size, int nid, struct page *page; for (page = start; page < (start + size); page++) { - set_page_zone(page, nid * MAX_NR_ZONES + zone); + set_page_zone(page, NODEZONE(nid, zone)); set_page_count(page, 0); SetPageReserved(page); INIT_LIST_HEAD(&page->list); @@ -1253,7 +1253,7 @@ static void __init free_area_init_core(struct pglist_data *pgdat, unsigned long size, realsize; unsigned long batch; - zone_table[nid * MAX_NR_ZONES + j] = zone; + zone_table[NODEZONE(nid, j)] = zone; realsize = size = zones_size[j]; if (zholes_size) realsize -= zholes_size[j]; @@ -1266,6 +1266,8 @@ static void __init free_area_init_core(struct pglist_data *pgdat, zone->zone_pgdat = pgdat; zone->free_pages = 0; + zone->temp_priority = zone->prev_priority = DEF_PRIORITY; + /* * The per-cpu-pages pools are set to around 1000th of the * size of the zone. But no more than 1/4 of a meg - there's diff --git a/mm/readahead.c b/mm/readahead.c index 46a6ff8e1f65..042376caeec6 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -449,12 +449,8 @@ do_io: * accessed in the current window, there * is a high probability that around 'n' pages * shall be used in the next current window. - * - * To minimize lazy-readahead triggered - * in the next current window, read in - * an extra page. */ - ra->next_size = preoffset - ra->start + 2; + ra->next_size = preoffset - ra->start + 1; } ra->start = offset; ra->size = ra->next_size; @@ -474,13 +470,9 @@ do_io: /* * This read request is within the current window. It is time * to submit I/O for the ahead window while the application is - * about to step into the ahead window. - * Heuristic: Defer reading the ahead window till we hit - * the last page in the current window. (lazy readahead) - * If we read in earlier we run the risk of wasting - * the ahead window. + * crunching through the current window. */ - if (ra->ahead_start == 0 && offset == (ra->start + ra->size -1)) { + if (ra->ahead_start == 0) { ra->ahead_start = ra->start + ra->size; ra->ahead_size = ra->next_size; actual = do_page_cache_readahead(mapping, filp, diff --git a/mm/vmscan.c b/mm/vmscan.c index bb27edc29afd..dcb7dc0f176d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -38,13 +38,6 @@ #include <linux/swapops.h> /* - * The "priority" of VM scanning is how much of the queues we will scan in one - * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the - * queues ("queue_length >> 12") during an aging round. - */ -#define DEF_PRIORITY 12 - -/* * From 0 .. 100. Higher means more swappy. */ int vm_swappiness = 60; diff --git a/net/rxrpc/call.c b/net/rxrpc/call.c index 0b8193629153..f95617a59708 100644 --- a/net/rxrpc/call.c +++ b/net/rxrpc/call.c @@ -699,7 +699,7 @@ static int rxrpc_call_generate_ACK(struct rxrpc_call *call, timo = rxrpc_call_dfr_ack_timeout + jiffies; - _debug("START ACKR TIMER for cj=%lu", timo-call->cjif); + _debug("START ACKR TIMER for cj=%lu", timo - call->cjif); spin_lock(&call->lock); mod_timer(&call->ackr_dfr_timo, timo); @@ -722,7 +722,8 @@ static int rxrpc_call_generate_ACK(struct rxrpc_call *call, /* fill out the appropriate form */ ack.bufferSpace = htons(RXRPC_CALL_ACK_WINDOW_SIZE); - ack.maxSkew = htons(min(call->ackr_high_seq - seq,65535U)); + ack.maxSkew = htons(min(call->ackr_high_seq - seq, + 65535U)); ack.firstPacket = htonl(call->ackr_win_bot); ack.previousPacket = call->ackr_prev_seq; ack.serial = hdr->serial; @@ -825,7 +826,7 @@ void rxrpc_call_do_stuff(struct rxrpc_call *call) _leave(""); -} /* end rxrpc_call_do_timeout() */ +} /* end rxrpc_call_do_stuff() */ /*****************************************************************************/ /* @@ -1061,7 +1062,7 @@ static void rxrpc_call_receive_data_packet(struct rxrpc_call *call, _debug("Call add packet %d to unreadyq", msg->seq); /* insert in seq order */ - list_for_each(_p,&call->app_unreadyq) { + list_for_each(_p, &call->app_unreadyq) { pmsg = list_entry(_p, struct rxrpc_message, link); if (pmsg->seq > msg->seq) break; @@ -2095,7 +2096,8 @@ int rxrpc_call_flush(struct rxrpc_call *call) if (msg->hdr.flags & RXRPC_LAST_PACKET) { msg->hdr.flags &= ~RXRPC_MORE_PACKETS; - msg->hdr.flags |= RXRPC_REQUEST_ACK; + if (call->app_call_state != RXRPC_CSTATE_CLNT_SND_ARGS) + msg->hdr.flags |= RXRPC_REQUEST_ACK; } else { msg->hdr.flags |= RXRPC_MORE_PACKETS; diff --git a/net/rxrpc/krxiod.c b/net/rxrpc/krxiod.c index 051ae4b397d6..f34323701713 100644 --- a/net/rxrpc/krxiod.c +++ b/net/rxrpc/krxiod.c @@ -44,12 +44,6 @@ static int rxrpc_krxiod(void *arg) daemonize("krxiod"); - /* only certain signals are of interest */ - spin_lock_irq(¤t->sighand->siglock); - siginitsetinv(¤t->blocked, 0); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); - /* loop around waiting for work to do */ do { /* wait for work or to be told to exit */ @@ -116,7 +110,7 @@ static int rxrpc_krxiod(void *arg) if (!list_empty(&rxrpc_krxiod_callq)) { call = list_entry(rxrpc_krxiod_callq.next, - struct rxrpc_call, + struct rxrpc_call, rcv_krxiodq_lk); list_del_init(&call->rcv_krxiodq_lk); atomic_dec(&rxrpc_krxiod_qcount); @@ -125,7 +119,7 @@ static int rxrpc_krxiod(void *arg) * away */ if (atomic_read(&call->usage) > 0) { _debug("@@@ KRXIOD" - " Begin Attend Call %p",call); + " Begin Attend Call %p", call); rxrpc_get_call(call); } else { diff --git a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c index 81c0b73ab6f5..c9ee29eb2032 100644 --- a/net/rxrpc/krxsecd.c +++ b/net/rxrpc/krxsecd.c @@ -57,12 +57,6 @@ static int rxrpc_krxsecd(void *arg) daemonize("krxsecd"); - /* only certain signals are of interest */ - spin_lock_irq(¤t->sighand->siglock); - siginitsetinv(¤t->blocked, 0); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); - /* loop around waiting for work to do */ do { /* wait for work or to be told to exit */ diff --git a/net/rxrpc/krxtimod.c b/net/rxrpc/krxtimod.c index 68ea67bf9623..31771577c5bb 100644 --- a/net/rxrpc/krxtimod.c +++ b/net/rxrpc/krxtimod.c @@ -74,12 +74,6 @@ static int krxtimod(void *arg) complete(&krxtimod_alive); - /* only certain signals are of interest */ - spin_lock_irq(¤t->sighand->siglock); - siginitsetinv(¤t->blocked, 0); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); - /* loop around looking for things to attend to */ loop: set_current_state(TASK_INTERRUPTIBLE); diff --git a/net/rxrpc/transport.c b/net/rxrpc/transport.c index 33b22b36d824..70002b501f87 100644 --- a/net/rxrpc/transport.c +++ b/net/rxrpc/transport.c @@ -130,7 +130,19 @@ int rxrpc_create_transport(unsigned short port, return 0; error: - rxrpc_put_transport(trans); + /* finish cleaning up the transport (not really needed here, but...) */ + if (trans->socket) + trans->socket->ops->shutdown(trans->socket, 2); + + /* close the socket */ + if (trans->socket) { + trans->socket->sk->sk_user_data = NULL; + sock_release(trans->socket); + trans->socket = NULL; + } + + kfree(trans); + _leave(" = %d", ret); return ret; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index ca8b1ce356a6..1a8e7c414445 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -800,7 +800,6 @@ int main(int ac, char **av) fprintf(stderr, "\n\n" "Your kernel configuration changes were NOT saved." "\n\n"); - return 1; } return 0; diff --git a/scripts/modpost.c b/scripts/modpost.c index 0b6d7dfffab6..7e6a4bb035a7 100644 --- a/scripts/modpost.c +++ b/scripts/modpost.c @@ -446,6 +446,7 @@ add_versions(struct buffer *b, struct module *mod) buf_printf(b, "\n"); buf_printf(b, "static const struct modversion_info ____versions[]\n"); + buf_printf(b, "__attribute_used__\n"); buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n"); for (s = mod->unres; s; s = s->next) { diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c index 43d6d948e1ac..73aa19031815 100644 --- a/sound/oss/dmabuf.c +++ b/sound/oss/dmabuf.c @@ -587,7 +587,6 @@ int DMAbuf_getrdbuffer(int dev, char **buf, int *len, int dontblock) spin_unlock_irqrestore(&dmap->lock,flags); timeout = interruptible_sleep_on_timeout(&adev->in_sleeper, timeout); - spin_lock_irqsave(&dmap->lock,flags); if (!timeout) { /* FIXME: include device name */ err = -EIO; @@ -595,6 +594,7 @@ int DMAbuf_getrdbuffer(int dev, char **buf, int *len, int dontblock) dma_reset_input(dev); } else err = -EINTR; + spin_lock_irqsave(&dmap->lock,flags); } spin_unlock_irqrestore(&dmap->lock,flags); |
