Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial
authorLinus Torvalds <torvalds@g5.osdl.org>
Fri, 30 Jun 2006 22:39:30 +0000 (15:39 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 30 Jun 2006 22:39:30 +0000 (15:39 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial:
  Remove obsolete #include <linux/config.h>
  remove obsolete swsusp_encrypt
  arch/arm26/Kconfig typos
  Documentation/IPMI typos
  Kconfig: Typos in net/sched/Kconfig
  v9fs: do not include linux/version.h
  Documentation/DocBook/mtdnand.tmpl: typo fixes
  typo fixes: specfic -> specific
  typo fixes in Documentation/networking/pktgen.txt
  typo fixes: occuring -> occurring
  typo fixes: infomation -> information
  typo fixes: disadvantadge -> disadvantage
  typo fixes: aquire -> acquire
  typo fixes: mecanism -> mechanism
  typo fixes: bandwith -> bandwidth
  fix a typo in the RTC_CLASS help text
  smb is no longer maintained

Manually merged trivial conflict in arch/um/kernel/vmlinux.lds.S

233 files changed:
Documentation/pcmcia/crc32hash.c [new file with mode: 0644]
Documentation/pcmcia/devicetable.txt
Documentation/sysctl/vm.txt
Documentation/video4linux/CARDLIST.cx88
MAINTAINERS
arch/arm/mm/mm-armv.c
arch/i386/Kconfig
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
arch/i386/kernel/msr.c
arch/i386/mach-voyager/voyager_smp.c
arch/i386/mm/pgtable.c
arch/ia64/Kconfig
arch/s390/appldata/appldata_base.c
arch/s390/appldata/appldata_mem.c
arch/sparc/kernel/sys_sunos.c
arch/sparc64/kernel/sys_sunos32.c
arch/um/Makefile-x86_64
arch/um/drivers/stderr_console.c
arch/um/kernel/skas/mmu.c
arch/um/kernel/time.c [deleted file]
arch/um/kernel/time_kern.c
arch/um/kernel/vmlinux.lds.S
arch/um/os-Linux/mem.c
arch/um/sys-i386/sys_call_table.S
arch/um/sys-x86_64/syscall_table.c
block/ll_rw_blk.c
drivers/acorn/block/Kconfig
drivers/acpi/Kconfig
drivers/acpi/Makefile
drivers/acpi/ac.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/asus_acpi.c
drivers/acpi/battery.c
drivers/acpi/bus.c
drivers/acpi/button.c
drivers/acpi/container.c
drivers/acpi/debug.c
drivers/acpi/dispatcher/dsinit.c
drivers/acpi/dispatcher/dsmethod.c
drivers/acpi/dispatcher/dswexec.c
drivers/acpi/dispatcher/dswload.c
drivers/acpi/dock.c [new file with mode: 0644]
drivers/acpi/ec.c
drivers/acpi/event.c
drivers/acpi/events/evgpe.c
drivers/acpi/events/evxface.c
drivers/acpi/executer/exconfig.c
drivers/acpi/executer/excreate.c
drivers/acpi/executer/exdump.c
drivers/acpi/executer/exfldio.c
drivers/acpi/executer/exmutex.c
drivers/acpi/executer/exsystem.c
drivers/acpi/fan.c
drivers/acpi/hardware/hwregs.c
drivers/acpi/hotkey.c
drivers/acpi/motherboard.c
drivers/acpi/namespace/nsaccess.c
drivers/acpi/osl.c
drivers/acpi/parser/psparse.c
drivers/acpi/pci_bind.c
drivers/acpi/pci_irq.c
drivers/acpi/pci_link.c
drivers/acpi/pci_root.c
drivers/acpi/power.c
drivers/acpi/processor_core.c
drivers/acpi/processor_idle.c
drivers/acpi/processor_perflib.c
drivers/acpi/processor_thermal.c
drivers/acpi/processor_throttling.c
drivers/acpi/scan.c
drivers/acpi/system.c
drivers/acpi/thermal.c
drivers/acpi/utilities/utdelete.c
drivers/acpi/utilities/utglobal.c
drivers/acpi/utilities/utmisc.c
drivers/acpi/utilities/utmutex.c
drivers/acpi/utils.c
drivers/acpi/video.c
drivers/base/node.c
drivers/cdrom/cm206.c
drivers/char/istallion.c
drivers/char/pc8736x_gpio.c
drivers/char/pcmcia/cm4000_cs.c
drivers/char/scx200_gpio.c
drivers/edac/amd76x_edac.c
drivers/edac/e752x_edac.c
drivers/edac/e7xxx_edac.c
drivers/edac/edac_mc.c
drivers/edac/edac_mc.h
drivers/edac/i82860_edac.c
drivers/edac/i82875p_edac.c
drivers/edac/r82600_edac.c
drivers/i2c/busses/i2c-i801.c
drivers/ide/legacy/ide-cs.c
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/media/dvb/dvb-core/dvb_frontend.c
drivers/media/dvb/frontends/cx22700.c
drivers/media/dvb/frontends/cx24123.c
drivers/media/dvb/ttpci/budget-av.c
drivers/media/video/bt8xx/bttv-cards.c
drivers/media/video/cx88/cx88-blackbird.c
drivers/media/video/cx88/cx88-cards.c
drivers/media/video/cx88/cx88-dvb.c
drivers/media/video/cx88/cx88-video.c
drivers/media/video/cx88/cx88.h
drivers/media/video/em28xx/em28xx-video.c
drivers/media/video/msp3400-driver.h
drivers/media/video/pvrusb2/Makefile
drivers/media/video/pvrusb2/pvrusb2-audio.c
drivers/media/video/pvrusb2/pvrusb2-context.c
drivers/media/video/pvrusb2/pvrusb2-ctrl.c
drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
drivers/media/video/pvrusb2/pvrusb2-debugifc.c
drivers/media/video/pvrusb2/pvrusb2-demod.c [deleted file]
drivers/media/video/pvrusb2/pvrusb2-demod.h [deleted file]
drivers/media/video/pvrusb2/pvrusb2-eeprom.c
drivers/media/video/pvrusb2/pvrusb2-encoder.c
drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-hdw.h
drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
drivers/media/video/pvrusb2/pvrusb2-io.c
drivers/media/video/pvrusb2/pvrusb2-io.h
drivers/media/video/pvrusb2/pvrusb2-ioread.c
drivers/media/video/pvrusb2/pvrusb2-ioread.h
drivers/media/video/pvrusb2/pvrusb2-main.c
drivers/media/video/pvrusb2/pvrusb2-std.c
drivers/media/video/pvrusb2/pvrusb2-sysfs.c
drivers/media/video/pvrusb2/pvrusb2-tuner.c
drivers/media/video/pvrusb2/pvrusb2-v4l2.c
drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
drivers/media/video/pvrusb2/pvrusb2-wm8775.c
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/tda9887.c
drivers/media/video/tuner-core.c
drivers/media/video/tuner-simple.c
drivers/media/video/tuner-types.c
drivers/media/video/tveeprom.c
drivers/media/video/videocodec.h
drivers/net/pcmcia/com20020_cs.c
drivers/net/wireless/hostap/hostap_cs.c
drivers/parisc/led.c
drivers/pci/hotplug/Makefile
drivers/pci/hotplug/acpiphp.h
drivers/pci/hotplug/acpiphp_core.c
drivers/pci/hotplug/acpiphp_dock.c [deleted file]
drivers/pci/hotplug/acpiphp_glue.c
drivers/pcmcia/at91_cf.c
drivers/pcmcia/au1000_db1x00.c
drivers/pcmcia/cs.c
drivers/pcmcia/pcmcia_resource.c
drivers/pcmcia/ti113x.h
drivers/pcmcia/yenta_socket.c
drivers/serial/serial_cs.c
drivers/usb/core/devio.c
drivers/usb/core/inode.c
drivers/usb/core/usb.h
drivers/video/imacfb.c
fs/buffer.c
fs/fs-writeback.c
fs/inode.c
fs/ioprio.c
fs/ncpfs/mmap.c
fs/nfs/pagelist.c
fs/nfs/write.c
fs/nfsd/export.c
fs/nfsd/nfs4state.c
fs/nfsd/nfsfh.c
fs/nfsd/vfs.c
fs/proc/proc_misc.c
include/acpi/acconfig.h
include/acpi/acdispat.h
include/acpi/acglobal.h
include/acpi/acinterp.h
include/acpi/aclocal.h
include/acpi/acmacros.h
include/acpi/acobject.h
include/acpi/acpi_bus.h
include/acpi/acpi_drivers.h
include/acpi/acpiosxf.h
include/acpi/actypes.h
include/acpi/platform/aclinux.h
include/acpi/processor.h
include/asm-s390/pgtable.h
include/asm-um/io.h
include/linux/cpufreq.h
include/linux/kobject.h
include/linux/mm.h
include/linux/mmzone.h
include/linux/page-flags.h
include/linux/pagemap.h
include/linux/pci_ids.h
include/linux/rcupdate.h
include/linux/rtc.h
include/linux/sched.h
include/linux/security.h
include/linux/smp.h
include/linux/sunrpc/svc.h
include/linux/swap.h
include/linux/vmstat.h [new file with mode: 0644]
include/media/tuner-types.h
init/Kconfig
init/main.c
kernel/sched.c
kernel/signal.c
kernel/sysctl.c
lib/kobject_uevent.c
mm/Makefile
mm/filemap.c
mm/highmem.c
mm/memory.c
mm/mempolicy.c
mm/mmap.c
mm/nommu.c
mm/page-writeback.c
mm/page_alloc.c
mm/page_io.c
mm/rmap.c
mm/shmem.c
mm/slab.c
mm/swap.c
mm/swap_state.c
mm/vmscan.c
mm/vmstat.c [new file with mode: 0644]
net/sunrpc/auth_gss/gss_mech_switch.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/svc.c
security/dummy.c
security/selinux/hooks.c

diff --git a/Documentation/pcmcia/crc32hash.c b/Documentation/pcmcia/crc32hash.c
new file mode 100644 (file)
index 0000000..cbc36d2
--- /dev/null
@@ -0,0 +1,32 @@
+/* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
+/* Usage example:
+$ ./crc32hash "Dual Speed"
+*/
+
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+unsigned int crc32(unsigned char const *p, unsigned int len)
+{
+       int i;
+       unsigned int crc = 0;
+       while (len--) {
+               crc ^= *p++;
+               for (i = 0; i < 8; i++)
+                       crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
+       }
+       return crc;
+}
+
+int main(int argc, char **argv) {
+       unsigned int result;
+       if (argc != 2) {
+               printf("no string passed as argument\n");
+               return -1;
+       }
+       result = crc32(argv[1], strlen(argv[1]));
+       printf("0x%x\n", result);
+       return 0;
+}
index 3351c03..199afd1 100644 (file)
@@ -27,37 +27,7 @@ pcmcia:m0149cC1ABf06pfn00fn00pa725B842DpbF1EFEE84pc0877B627pd00000000
 The hex value after "pa" is the hash of product ID string 1, after "pb" for
 string 2 and so on.
 
-Alternatively, you can use this small tool to determine the crc32 hash.
-simply pass the string you want to evaluate as argument to this program,
-e.g.
+Alternatively, you can use crc32hash (see Documentation/pcmcia/crc32hash.c)
+to determine the crc32 hash.  Simply pass the string you want to evaluate
+as argument to this program, e.g.:
 $ ./crc32hash "Dual Speed"
-
--------------------------------------------------------------------------
-/* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-unsigned int crc32(unsigned char const *p, unsigned int len)
-{
-       int i;
-       unsigned int crc = 0;
-       while (len--) {
-               crc ^= *p++;
-               for (i = 0; i < 8; i++)
-                       crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
-       }
-       return crc;
-}
-
-int main(int argc, char **argv) {
-       unsigned int result;
-       if (argc != 2) {
-               printf("no string passed as argument\n");
-               return -1;
-       }
-       result = crc32(argv[1], strlen(argv[1]));
-       printf("0x%x\n", result);
-       return 0;
-}
index 2dc246a..86754eb 100644 (file)
@@ -28,7 +28,6 @@ Currently, these files are in /proc/sys/vm:
 - block_dump
 - drop-caches
 - zone_reclaim_mode
-- zone_reclaim_interval
 - panic_on_oom
 
 ==============================================================
@@ -167,18 +166,6 @@ use of files and builds up large slab caches. However, the slab
 shrink operation is global, may take a long time and free slabs
 in all nodes of the system.
 
-================================================================
-
-zone_reclaim_interval:
-
-The time allowed for off node allocations after zone reclaim
-has failed to reclaim enough pages to allow a local allocation.
-
-Time is set in seconds and set by default to 30 seconds.
-
-Reduce the interval if undesired off node allocations occur. However, too
-frequent scans will have a negative impact onoff node allocation performance.
-
 =============================================================
 
 panic_on_oom
index 6cb63dd..00d9a1f 100644 (file)
@@ -50,3 +50,4 @@
  49 -> PixelView PlayTV P7000                              [1554:4813]
  50 -> NPG Tech Real TV FM Top 10                          [14f1:0842]
  51 -> WinFast DTV2000 H                                   [107d:665e]
+ 52 -> Geniatech DVB-S                                     [14f1:0084]
index 6ddb9a8..42be131 100644 (file)
@@ -925,23 +925,21 @@ S:        Maintained
 
 EDAC-CORE
 P:     Doug Thompson
-M:     norsk5@xmission.com, dthompson@linuxnetworx.com
-P:     Dave Peterson
-M:     dsp@llnl.gov, dave_peterson@pobox.com
+M:     norsk5@xmission.com
 L:     bluesmoke-devel@lists.sourceforge.net
 W:     bluesmoke.sourceforge.net
-S:     Maintained
+S:     Supported
 
 EDAC-E752X
-P:     Dave Peterson
-M:     dsp@llnl.gov, dave_peterson@pobox.com
+P:     Mark Gross
+M:     mark.gross@intel.com
 L:     bluesmoke-devel@lists.sourceforge.net
 W:     bluesmoke.sourceforge.net
 S:     Maintained
 
 EDAC-E7XXX
-P:     Dave Peterson
-M:     dsp@llnl.gov, dave_peterson@pobox.com
+P:     Doug Thompson
+M:     norsk5@xmission.com
 L:     bluesmoke-devel@lists.sourceforge.net
 W:     bluesmoke.sourceforge.net
 S:     Maintained
index 487d7ad..b0242c6 100644 (file)
@@ -226,7 +226,7 @@ void free_pgd_slow(pgd_t *pgd)
 
        pte = pmd_page(*pmd);
        pmd_clear(pmd);
-       dec_page_state(nr_page_table_pages);
+       dec_zone_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
        pte_lock_deinit(pte);
        pte_free(pte);
        pmd_free(pmd);
index 1718429..27d8ddd 100644 (file)
@@ -176,7 +176,7 @@ endchoice
 config ACPI_SRAT
        bool
        default y
-       depends on NUMA && (X86_SUMMIT || X86_GENERICARCH)
+       depends on ACPI && NUMA && (X86_SUMMIT || X86_GENERICARCH)
        select ACPI_NUMA
 
 config HAVE_ARCH_PARSE_SRAT
index b9358e5..567b39b 100644 (file)
@@ -417,8 +417,14 @@ acpi_cpufreq_cpu_init (
                goto err_free;
 
        perf = data->acpi_data;
-       policy->cpus = perf->shared_cpu_map;
        policy->shared_type = perf->shared_type;
+       /*
+        * Will let policy->cpus know about dependency only when software 
+        * coordination is required.
+        */
+       if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
+           policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
+               policy->cpus = perf->shared_cpu_map;
 
        if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
                acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
index d91815e..b77f135 100644 (file)
@@ -398,8 +398,14 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
                dprintk(PFX "obtaining ACPI data failed\n");
                return -EIO;
        }
-       policy->cpus = p->shared_cpu_map;
        policy->shared_type = p->shared_type;
+       /*
+        * Will let policy->cpus know about dependency only when software 
+        * coordination is required.
+        */
+       if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
+           policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
+               policy->cpus = p->shared_cpu_map;
 
        /* verify the acpi_data */
        if (p->state_count <= 1) {
index 4eae03d..d535cdb 100644 (file)
@@ -250,7 +250,9 @@ static int msr_class_device_create(int i)
        return err;
 }
 
-static int msr_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+#ifdef CONFIG_HOTPLUG_CPU
+static int msr_class_cpu_callback(struct notifier_block *nfb,
+                               unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
 
@@ -269,6 +271,7 @@ static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
 {
        .notifier_call = msr_class_cpu_callback,
 };
+#endif
 
 static int __init msr_init(void)
 {
@@ -291,7 +294,7 @@ static int __init msr_init(void)
                if (err != 0)
                        goto out_class;
        }
-       register_cpu_notifier(&msr_class_cpu_notifier);
+       register_hotcpu_notifier(&msr_class_cpu_notifier);
 
        err = 0;
        goto out;
@@ -314,7 +317,7 @@ static void __exit msr_exit(void)
                class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
        class_destroy(msr_class);
        unregister_chrdev(MSR_MAJOR, "cpu/msr");
-       unregister_cpu_notifier(&msr_class_cpu_notifier);
+       unregister_hotcpu_notifier(&msr_class_cpu_notifier);
 }
 
 module_init(msr_init);
index 8a1b882..6c86575 100644 (file)
@@ -1937,3 +1937,9 @@ smp_cpus_done(unsigned int max_cpus)
 {
        zap_low_mappings();
 }
+
+void __init
+smp_setup_processor_id(void)
+{
+       current_thread_info()->cpu = hard_smp_processor_id();
+}
index a5152f1..bd98768 100644 (file)
@@ -29,7 +29,6 @@ void show_mem(void)
        struct page *page;
        pg_data_t *pgdat;
        unsigned long i;
-       struct page_state ps;
        unsigned long flags;
 
        printk(KERN_INFO "Mem-info:\n");
@@ -57,12 +56,13 @@ void show_mem(void)
        printk(KERN_INFO "%d pages shared\n", shared);
        printk(KERN_INFO "%d pages swap cached\n", cached);
 
-       get_page_state(&ps);
-       printk(KERN_INFO "%lu pages dirty\n", ps.nr_dirty);
-       printk(KERN_INFO "%lu pages writeback\n", ps.nr_writeback);
-       printk(KERN_INFO "%lu pages mapped\n", ps.nr_mapped);
-       printk(KERN_INFO "%lu pages slab\n", ps.nr_slab);
-       printk(KERN_INFO "%lu pages pagetables\n", ps.nr_page_table_pages);
+       printk(KERN_INFO "%lu pages dirty\n", global_page_state(NR_FILE_DIRTY));
+       printk(KERN_INFO "%lu pages writeback\n",
+                                       global_page_state(NR_WRITEBACK));
+       printk(KERN_INFO "%lu pages mapped\n", global_page_state(NR_FILE_MAPPED));
+       printk(KERN_INFO "%lu pages slab\n", global_page_state(NR_SLAB));
+       printk(KERN_INFO "%lu pages pagetables\n",
+                                       global_page_state(NR_PAGETABLE));
 }
 
 /*
index b487e22..47de9ee 100644 (file)
@@ -70,6 +70,11 @@ config DMA_IS_DMA32
        bool
        default y
 
+config DMA_IS_NORMAL
+       bool
+       depends on IA64_SGI_SN2
+       default y
+
 choice
        prompt "System type"
        default IA64_GENERIC
index 8937318..d0f82c9 100644 (file)
@@ -765,7 +765,6 @@ unsigned long nr_iowait(void)
 #endif /* MODULE */
 EXPORT_SYMBOL_GPL(si_swapinfo);
 EXPORT_SYMBOL_GPL(nr_threads);
-EXPORT_SYMBOL_GPL(get_full_page_state);
 EXPORT_SYMBOL_GPL(nr_running);
 EXPORT_SYMBOL_GPL(nr_iowait);
 //EXPORT_SYMBOL_GPL(nr_context_switches);
index 7165c8f..ab3b076 100644 (file)
@@ -106,21 +106,21 @@ static void appldata_get_mem_data(void *data)
         * serialized through the appldata_ops_lock and can use static
         */
        static struct sysinfo val;
-       static struct page_state ps;
+       unsigned long ev[NR_VM_EVENT_ITEMS];
        struct appldata_mem_data *mem_data;
 
        mem_data = data;
        mem_data->sync_count_1++;
 
-       get_full_page_state(&ps);
-       mem_data->pgpgin     = ps.pgpgin >> 1;
-       mem_data->pgpgout    = ps.pgpgout >> 1;
-       mem_data->pswpin     = ps.pswpin;
-       mem_data->pswpout    = ps.pswpout;
-       mem_data->pgalloc    = ps.pgalloc_high + ps.pgalloc_normal +
-                              ps.pgalloc_dma;
-       mem_data->pgfault    = ps.pgfault;
-       mem_data->pgmajfault = ps.pgmajfault;
+       all_vm_events(ev);
+       mem_data->pgpgin     = ev[PGPGIN] >> 1;
+       mem_data->pgpgout    = ev[PGPGOUT] >> 1;
+       mem_data->pswpin     = ev[PSWPIN];
+       mem_data->pswpout    = ev[PSWPOUT];
+       mem_data->pgalloc    = ev[PGALLOC_HIGH] + ev[PGALLOC_NORMAL] +
+                              ev[PGALLOC_DMA];
+       mem_data->pgfault    = ev[PGFAULT];
+       mem_data->pgmajfault = ev[PGMAJFAULT];
 
        si_meminfo(&val);
        mem_data->sharedram = val.sharedram;
@@ -129,7 +129,8 @@ static void appldata_get_mem_data(void *data)
        mem_data->totalhigh = P2K(val.totalhigh);
        mem_data->freehigh  = P2K(val.freehigh);
        mem_data->bufferram = P2K(val.bufferram);
-       mem_data->cached    = P2K(atomic_read(&nr_pagecache) - val.bufferram);
+       mem_data->cached    = P2K(global_page_state(NR_FILE_PAGES)
+                               - val.bufferram);
 
        si_swapinfo(&val);
        mem_data->totalswap = P2K(val.totalswap);
index 288de27..aa0fb2e 100644 (file)
@@ -196,7 +196,7 @@ asmlinkage int sunos_brk(unsigned long brk)
         * simple, it hopefully works in most obvious cases.. Easy to
         * fool it, but this should catch most mistakes.
         */
-       freepages = get_page_cache_size();
+       freepages = global_page_state(NR_FILE_PAGES);
        freepages >>= 1;
        freepages += nr_free_pages();
        freepages += nr_swap_pages;
index ae5b32f..87ebdf8 100644 (file)
@@ -155,7 +155,7 @@ asmlinkage int sunos_brk(u32 baddr)
         * simple, it hopefully works in most obvious cases.. Easy to
         * fool it, but this should catch most mistakes.
         */
-       freepages = get_page_cache_size();
+       freepages = global_page_state(NR_FILE_PAGES);
        freepages >>= 1;
        freepages += nr_free_pages();
        freepages += nr_swap_pages;
index dfd88b6..dffd118 100644 (file)
@@ -6,9 +6,11 @@ START := 0x60000000
 
 #We #undef __x86_64__ for kernelspace, not for userspace where
 #it's needed for headers to work!
-CFLAGS += -U__$(SUBARCH)__ -fno-builtin
-USER_CFLAGS += -fno-builtin
+CFLAGS += -U__$(SUBARCH)__ -fno-builtin -m64
+USER_CFLAGS += -fno-builtin -m64
 CHECKFLAGS  += -m64
+AFLAGS += -m64
+LDFLAGS += -m elf_x86_64
 
 ELF_ARCH := i386:x86-64
 ELF_FORMAT := elf64-x86-64
@@ -16,3 +18,4 @@ ELF_FORMAT := elf64-x86-64
 # Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
 
 LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
+LINK-y += -m64
index 429ae8e..6d2cf32 100644 (file)
@@ -8,10 +8,7 @@
 
 /*
  * Don't register by default -- as this registeres very early in the
- * boot process it becomes the default console.  And as this isn't a
- * real tty driver init isn't able to open /dev/console then.
- *
- * In most cases this isn't what you want ...
+ * boot process it becomes the default console.
  */
 static int use_stderr_console = 0;
 
@@ -43,3 +40,20 @@ static int stderr_setup(char *str)
        return 1;
 }
 __setup("stderr=", stderr_setup);
+
+/* The previous behavior of not unregistering led to /dev/console being
+ * impossible to open.  My FC5 filesystem started having init die, and the
+ * system panicing because of this.  Unregistering causes the real
+ * console to become the default console, and /dev/console can then be
+ * opened.  Making this an initcall makes this happen late enough that
+ * there is no added value in dumping everything to stderr, and the
+ * normal console is good enough to show you all available output.
+ */
+static int __init unregister_stderr(void)
+{
+       unregister_console(&stderr_console);
+
+       return 0;
+}
+
+__initcall(unregister_stderr);
index c5c9885..624ca23 100644 (file)
@@ -152,7 +152,7 @@ void destroy_context_skas(struct mm_struct *mm)
                free_page(mmu->id.stack);
                pte_lock_deinit(virt_to_page(mmu->last_page_table));
                pte_free_kernel((pte_t *) mmu->last_page_table);
-                dec_page_state(nr_page_table_pages);
+               dec_zone_page_state(virt_to_page(mmu->last_page_table), NR_PAGETABLE);
 #ifdef CONFIG_3_LEVEL_PGTABLES
                pmd_free((pmd_t *) mmu->last_pmd);
 #endif
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
deleted file mode 100644 (file)
index 8fa2ae7..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/time.h>
-#include <signal.h>
-#include <errno.h>
-#include "user_util.h"
-#include "kern_util.h"
-#include "user.h"
-#include "process.h"
-#include "time_user.h"
-#include "kern_constants.h"
-#include "os.h"
-
-/* XXX This really needs to be declared and initialized in a kernel file since
- * it's in <linux/time.h>
- */
-extern struct timespec wall_to_monotonic;
-
-extern struct timeval xtime;
-
-struct timeval local_offset = { 0, 0 };
-
-void timer(void)
-{
-       gettimeofday(&xtime, NULL);
-       timeradd(&xtime, &local_offset, &xtime);
-}
-
-static void set_interval(int timer_type)
-{
-       int usec = 1000000/hz();
-       struct itimerval interval = ((struct itimerval) { { 0, usec },
-                                                         { 0, usec } });
-
-       if(setitimer(timer_type, &interval, NULL) == -1)
-               panic("setitimer failed - errno = %d\n", errno);
-}
-
-void enable_timer(void)
-{
-       set_interval(ITIMER_VIRTUAL);
-}
-
-void prepare_timer(void * ptr)
-{
-       int usec = 1000000/hz();
-       *(struct itimerval *)ptr = ((struct itimerval) { { 0, usec },
-                                                        { 0, usec }});
-}
-
-void disable_timer(void)
-{
-       struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
-       if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
-          (setitimer(ITIMER_REAL, &disable, NULL) < 0))
-               printk("disnable_timer - setitimer failed, errno = %d\n",
-                      errno);
-       /* If there are signals already queued, after unblocking ignore them */
-       set_handler(SIGALRM, SIG_IGN, 0, -1);
-       set_handler(SIGVTALRM, SIG_IGN, 0, -1);
-}
-
-void switch_timers(int to_real)
-{
-       struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
-       struct itimerval enable = ((struct itimerval) { { 0, 1000000/hz() },
-                                                       { 0, 1000000/hz() }});
-       int old, new;
-
-       if(to_real){
-               old = ITIMER_VIRTUAL;
-               new = ITIMER_REAL;
-       }
-       else {
-               old = ITIMER_REAL;
-               new = ITIMER_VIRTUAL;
-       }
-
-       if((setitimer(old, &disable, NULL) < 0) ||
-          (setitimer(new, &enable, NULL)))
-               printk("switch_timers - setitimer failed, errno = %d\n",
-                      errno);
-}
-
-void uml_idle_timer(void)
-{
-       if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
-               panic("Couldn't unset SIGVTALRM handler");
-       
-       set_handler(SIGALRM, (__sighandler_t) alarm_handler, 
-                   SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
-       set_interval(ITIMER_REAL);
-}
-
-extern void ktime_get_ts(struct timespec *ts);
-#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
-
-void time_init(void)
-{
-       struct timespec now;
-
-       if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
-               panic("Couldn't set SIGVTALRM handler");
-       set_interval(ITIMER_VIRTUAL);
-
-       do_posix_clock_monotonic_gettime(&now);
-       wall_to_monotonic.tv_sec = -now.tv_sec;
-       wall_to_monotonic.tv_nsec = -now.tv_nsec;
-}
-
-/* Defined in linux/ktimer.h, which can't be included here */
-#define clock_was_set()                do { } while (0)
-
-void do_gettimeofday(struct timeval *tv)
-{
-       unsigned long flags;
-
-       flags = time_lock();
-       gettimeofday(tv, NULL);
-       timeradd(tv, &local_offset, tv);
-       time_unlock(flags);
-       clock_was_set();
-}
-
-int do_settimeofday(struct timespec *tv)
-{
-       struct timeval now;
-       unsigned long flags;
-       struct timeval tv_in;
-
-       if ((unsigned long) tv->tv_nsec >= UM_NSEC_PER_SEC)
-               return -EINVAL;
-
-       tv_in.tv_sec = tv->tv_sec;
-       tv_in.tv_usec = tv->tv_nsec / 1000;
-
-       flags = time_lock();
-       gettimeofday(&now, NULL);
-       timersub(&tv_in, &now, &local_offset);
-       time_unlock(flags);
-
-       return(0);
-}
-
-void idle_sleep(int secs)
-{
-       struct timespec ts;
-
-       ts.tv_sec = secs;
-       ts.tv_nsec = 0;
-       nanosleep(&ts, NULL);
-}
-
-/* XXX This partly duplicates init_irq_signals */
-
-void user_time_init(void)
-{
-       set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
-                   SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH,
-                   SIGALRM, SIGUSR2, -1);
-       set_handler(SIGALRM, (__sighandler_t) alarm_handler,
-                   SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH,
-                   SIGVTALRM, SIGUSR2, -1);
-       set_interval(ITIMER_VIRTUAL);
-}
index 87cdbc5..820fa36 100644 (file)
@@ -96,11 +96,15 @@ void time_init_kern(void)
 
 void do_boot_timer_handler(struct sigcontext * sc)
 {
+       unsigned long flags;
        struct pt_regs regs;
 
        CHOOSE_MODE((void) (UPT_SC(&regs.regs) = sc),
                    (void) (regs.regs.skas.is_user = 0));
+
+       write_seqlock_irqsave(&xtime_lock, flags);
        do_timer(&regs);
+       write_sequnlock_irqrestore(&xtime_lock, flags);
 }
 
 static DEFINE_SPINLOCK(timer_spinlock);
@@ -125,25 +129,17 @@ irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
        unsigned long long nsecs;
        unsigned long flags;
 
+       write_seqlock_irqsave(&xtime_lock, flags);
+
        do_timer(regs);
 
-       write_seqlock_irqsave(&xtime_lock, flags);
        nsecs = get_time() + local_offset;
        xtime.tv_sec = nsecs / NSEC_PER_SEC;
        xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC;
-       write_sequnlock_irqrestore(&xtime_lock, flags);
-
-       return(IRQ_HANDLED);
-}
 
-long um_time(int __user *tloc)
-{
-       long ret = get_time() / NSEC_PER_SEC;
-
-       if((tloc != NULL) && put_user(ret, tloc))
-               return -EFAULT;
+       write_sequnlock_irqrestore(&xtime_lock, flags);
 
-       return ret;
+       return IRQ_HANDLED;
 }
 
 void do_gettimeofday(struct timeval *tv)
@@ -174,18 +170,6 @@ static inline void set_time(unsigned long long nsecs)
        clock_was_set();
 }
 
-long um_stime(int __user *tptr)
-{
-       int value;
-
-       if (get_user(value, tptr))
-                return -EFAULT;
-
-       set_time((unsigned long long) value * NSEC_PER_SEC);
-
-       return 0;
-}
-
 int do_settimeofday(struct timespec *tv)
 {
        set_time((unsigned long long) tv->tv_sec * NSEC_PER_SEC + tv->tv_nsec);
index f8aeb44..72acdce 100644 (file)
@@ -1,3 +1,5 @@
+/* in case the preprocessor is a 32bit one */
+#undef i386
 #ifdef CONFIG_LD_SCRIPT_STATIC
 #include "uml.lds.S"
 #else
index c6432e7..560c806 100644 (file)
@@ -55,7 +55,7 @@ static void __init find_tempdir(void)
  */
 static int next(int fd, char *buf, int size, char c)
 {
-       int n;
+       int n, len;
        char *ptr;
 
        while((ptr = strchr(buf, c)) == NULL){
@@ -69,7 +69,17 @@ static int next(int fd, char *buf, int size, char c)
        }
 
        ptr++;
-       memmove(buf, ptr, strlen(ptr) + 1);
+       len = strlen(ptr);
+       memmove(buf, ptr, len + 1);
+
+       /* Refill the buffer so that if there's a partial string that we care
+        * about, it will be completed, and we can recognize it.
+        */
+       n = read(fd, &buf[len], size - len - 1);
+       if(n < 0)
+               return -errno;
+
+       buf[len + n] = '\0';
        return 1;
 }
 
@@ -200,8 +210,11 @@ int create_tmp_file(unsigned long long len)
                exit(1);
        }
 
-        if (lseek64(fd, len, SEEK_SET) < 0) {
-               perror("os_seek_file");
+       /* Seek to len - 1 because writing a character there will
+        * increase the file size by one byte, to the desired length.
+        */
+       if (lseek64(fd, len - 1, SEEK_SET) < 0) {
+               perror("os_seek_file");
                exit(1);
        }
 
index 1ff6147..2497554 100644 (file)
@@ -7,8 +7,6 @@
 #define sys_vm86old sys_ni_syscall
 #define sys_vm86 sys_ni_syscall
 
-#define sys_stime um_stime
-#define sys_time um_time
 #define old_mmap old_mmap_i386
 
 #include "../../i386/kernel/syscall_table.S"
index 67ba024..9e9ad72 100644 (file)
 /*#define sys_set_thread_area sys_ni_syscall
 #define sys_get_thread_area sys_ni_syscall*/
 
-/* For __NR_time. The x86-64 name hopefully will change from sys_time64 to
- * sys_time (since the current situation is bogus). I've sent a patch to cleanup
- * this. Remove below the obsoleted line. */
-#define sys_time64 um_time
-#define sys_time um_time
-
 /* On UML we call it this way ("old" means it's not mmap2) */
 #define sys_mmap old_mmap
 /* On x86-64 sys_uname is actually sys_newuname plus a compatibility trick.
index 46c1c33..5813d63 100644 (file)
@@ -3116,9 +3116,9 @@ void submit_bio(int rw, struct bio *bio)
        BIO_BUG_ON(!bio->bi_io_vec);
        bio->bi_rw |= rw;
        if (rw & WRITE)
-               mod_page_state(pgpgout, count);
+               count_vm_events(PGPGOUT, count);
        else
-               mod_page_state(pgpgin, count);
+               count_vm_events(PGPGIN, count);
 
        if (unlikely(block_dump)) {
                char b[BDEVNAME_SIZE];
index 073add3..a0ff25e 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 menu "Acorn-specific block devices"
-       depends on ARCH_ACORN
+       depends on ARCH_ARC || ARCH_A5K
 
 config BLK_DEV_FD1772
        tristate "Old Archimedes floppy (1772) support"
index 610d2cc..bc2652d 100644 (file)
@@ -133,6 +133,13 @@ config ACPI_FAN
          This driver adds support for ACPI fan devices, allowing user-mode 
          applications to perform basic fan control (on, off, status).
 
+config ACPI_DOCK
+       tristate "Dock"
+       depends on !ACPI_IBM_DOCK
+       default y
+       help
+         This driver adds support for ACPI controlled docking stations
+
 config ACPI_PROCESSOR
        tristate "Processor"
        default y
index 5984b4f..f0a68ec 100644 (file)
@@ -42,6 +42,7 @@ obj-$(CONFIG_ACPI_BATTERY)    += battery.o
 obj-$(CONFIG_ACPI_BUTTON)      += button.o
 obj-$(CONFIG_ACPI_EC)          += ec.o
 obj-$(CONFIG_ACPI_FAN)         += fan.o
+obj-$(CONFIG_ACPI_DOCK)                += dock.o
 obj-$(CONFIG_ACPI_VIDEO)       += video.o 
 obj-$(CONFIG_ACPI_HOTKEY)      += hotkey.o
 obj-y                          += pci_root.o pci_link.o pci_irq.o pci_bind.o
index 7839b83..36ca365 100644 (file)
@@ -84,20 +84,18 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_get_state");
 
        if (!ac)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error reading AC Adapter state\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
                ac->state = ACPI_AC_STATUS_UNKNOWN;
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -110,14 +108,13 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_ac *ac = (struct acpi_ac *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
 
        if (!ac)
-               return_VALUE(0);
+               return 0;
 
        if (acpi_ac_get_state(ac)) {
                seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
-               return_VALUE(0);
+               return 0;
        }
 
        seq_puts(seq, "state:                   ");
@@ -133,7 +130,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
                break;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_ac_open_fs(struct inode *inode, struct file *file)
@@ -145,13 +142,12 @@ static int acpi_ac_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_ac_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
 
@@ -159,21 +155,18 @@ static int acpi_ac_add_fs(struct acpi_device *device)
        entry = create_proc_entry(ACPI_AC_FILE_STATE,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_AC_FILE_STATE));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_ac_fops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_ac_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device));
@@ -182,7 +175,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -194,13 +187,12 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_ac *ac = (struct acpi_ac *)data;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_notify");
 
        if (!ac)
-               return_VOID;
+               return;
 
        if (acpi_bus_get_device(ac->handle, &device))
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_AC_NOTIFY_STATUS:
@@ -213,7 +205,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static int acpi_ac_add(struct acpi_device *device)
@@ -222,14 +214,13 @@ static int acpi_ac_add(struct acpi_device *device)
        acpi_status status = AE_OK;
        struct acpi_ac *ac = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL);
        if (!ac)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(ac, 0, sizeof(struct acpi_ac));
 
        ac->handle = device->handle;
@@ -249,8 +240,6 @@ static int acpi_ac_add(struct acpi_device *device)
                                             ACPI_DEVICE_NOTIFY, acpi_ac_notify,
                                             ac);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error installing notify handler\n"));
                result = -ENODEV;
                goto end;
        }
@@ -265,7 +254,7 @@ static int acpi_ac_add(struct acpi_device *device)
                kfree(ac);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_ac_remove(struct acpi_device *device, int type)
@@ -273,55 +262,49 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
        acpi_status status = AE_OK;
        struct acpi_ac *ac = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ac = (struct acpi_ac *)acpi_driver_data(device);
 
        status = acpi_remove_notify_handler(ac->handle,
                                            ACPI_DEVICE_NOTIFY, acpi_ac_notify);
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
 
        acpi_ac_remove_fs(device);
 
        kfree(ac);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int __init acpi_ac_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ac_init");
 
        acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
        if (!acpi_ac_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_ac_dir->owner = THIS_MODULE;
 
        result = acpi_bus_register_driver(&acpi_ac_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_ac_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_ac_exit");
 
        acpi_bus_unregister_driver(&acpi_ac_driver);
 
        remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_ac_init);
index 1012284..cd57372 100644 (file)
@@ -128,7 +128,6 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
        acpi_status status;
        struct acpi_memory_info *info, *n;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_get_device_resources");
 
        status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
                                     acpi_memory_get_resource, mem_device);
@@ -150,23 +149,21 @@ acpi_memory_get_device(acpi_handle handle,
        struct acpi_device *device = NULL;
        struct acpi_device *pdevice = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_get_device");
 
        if (!acpi_bus_get_device(handle, &device) && device)
                goto end;
 
        status = acpi_get_parent(handle, &phandle);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n"));
-               return_VALUE(-EINVAL);
+               ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
+               return -EINVAL;
        }
 
        /* Get the parent device */
        status = acpi_bus_get_device(phandle, &pdevice);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error in acpi_bus_get_device\n"));
-               return_VALUE(-EINVAL);
+               ACPI_EXCEPTION((AE_INFO, status, "Cannot get acpi bus device"));
+               return -EINVAL;
        }
 
        /*
@@ -175,30 +172,29 @@ acpi_memory_get_device(acpi_handle handle,
         */
        status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n"));
-               return_VALUE(-EINVAL);
+               ACPI_EXCEPTION((AE_INFO, status, "Cannot add acpi bus"));
+               return -EINVAL;
        }
 
       end:
        *mem_device = acpi_driver_data(device);
        if (!(*mem_device)) {
                printk(KERN_ERR "\n driver data not found");
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
 {
        unsigned long current_status;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_check_device");
 
        /* Get device present/absent information from the _STA */
        if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
                                               NULL, &current_status)))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        /*
         * Check for device status. Device should be
         * present/enabled/functioning.
@@ -206,9 +202,9 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
        if (!((current_status & ACPI_MEMORY_STA_PRESENT)
              && (current_status & ACPI_MEMORY_STA_ENABLED)
              && (current_status & ACPI_MEMORY_STA_FUNCTIONAL)))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
@@ -217,13 +213,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
        struct acpi_memory_info *info;
        int node;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_enable_device");
 
        /* Get the range from the _CRS */
        result = acpi_memory_get_device_resources(mem_device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "\nget_device_resources failed\n"));
+               printk(KERN_ERR PREFIX "get_device_resources failed\n");
                mem_device->state = MEMORY_INVALID_STATE;
                return result;
        }
@@ -254,7 +248,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
                num_enabled++;
        }
        if (!num_enabled) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n"));
+               printk(KERN_ERR PREFIX "add_memory failed\n");
                mem_device->state = MEMORY_INVALID_STATE;
                return -EINVAL;
        }
@@ -269,7 +263,6 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
        union acpi_object arg;
        unsigned long current_status;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_powerdown_device");
 
        /* Issue the _EJ0 command */
        arg_list.count = 1;
@@ -280,21 +273,21 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
                                      "_EJ0", &arg_list, NULL);
        /* Return on _EJ0 failure */
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "_EJ0 failed"));
+               return -ENODEV;
        }
 
        /* Evalute _STA to check if the device is disabled */
        status = acpi_evaluate_integer(mem_device->handle, "_STA",
                                       NULL, &current_status);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /* Check for device status.  Device should be disabled */
        if (current_status & ACPI_MEMORY_STA_ENABLED)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
@@ -302,7 +295,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
        int result;
        struct acpi_memory_info *info, *n;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
 
        /*
         * Ask the VM to offline this memory range.
@@ -320,8 +312,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
        /* Power-off and eject the device */
        result = acpi_memory_powerdown_device(mem_device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Device Power Down failed.\n"));
                /* Set the status of the device to invalid */
                mem_device->state = MEMORY_INVALID_STATE;
                return result;
@@ -336,7 +326,6 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_memory_device *mem_device;
        struct acpi_device *device;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_device_notify");
 
        switch (event) {
        case ACPI_NOTIFY_BUS_CHECK:
@@ -348,15 +337,14 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "\nReceived DEVICE CHECK notification for device\n"));
                if (acpi_memory_get_device(handle, &mem_device)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Error in finding driver data\n"));
-                       return_VOID;
+                       printk(KERN_ERR PREFIX "Cannot find driver data\n");
+                       return;
                }
 
                if (!acpi_memory_check_device(mem_device)) {
                        if (acpi_memory_enable_device(mem_device))
-                               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                 "Error in acpi_memory_enable_device\n"));
+                               printk(KERN_ERR PREFIX
+                                           "Cannot enable memory device\n");
                }
                break;
        case ACPI_NOTIFY_EJECT_REQUEST:
@@ -364,14 +352,12 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
                                  "\nReceived EJECT REQUEST notification for device\n"));
 
                if (acpi_bus_get_device(handle, &device)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Device doesn't exist\n"));
+                       printk(KERN_ERR PREFIX "Device doesn't exist\n");
                        break;
                }
                mem_device = acpi_driver_data(device);
                if (!mem_device) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Driver Data is NULL\n"));
+                       printk(KERN_ERR PREFIX "Driver Data is NULL\n");
                        break;
                }
 
@@ -382,8 +368,8 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
                 *      with generic sysfs driver
                 */
                if (acpi_memory_disable_device(mem_device))
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Error in acpi_memory_disable_device\n"));
+                       printk(KERN_ERR PREFIX
+                                   "Disable memory device\n");
                /*
                 * TBD: Invoke acpi_bus_remove to cleanup data structures
                 */
@@ -394,7 +380,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static int acpi_memory_device_add(struct acpi_device *device)
@@ -402,14 +388,13 @@ static int acpi_memory_device_add(struct acpi_device *device)
        int result;
        struct acpi_memory_device *mem_device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_device_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
        if (!mem_device)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(mem_device, 0, sizeof(struct acpi_memory_device));
 
        INIT_LIST_HEAD(&mem_device->res_list);
@@ -422,7 +407,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
        result = acpi_memory_get_device_resources(mem_device);
        if (result) {
                kfree(mem_device);
-               return_VALUE(result);
+               return result;
        }
 
        /* Set the device state */
@@ -430,22 +415,21 @@ static int acpi_memory_device_add(struct acpi_device *device)
 
        printk(KERN_INFO "%s \n", acpi_device_name(device));
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_memory_device_remove(struct acpi_device *device, int type)
 {
        struct acpi_memory_device *mem_device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_device_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
        kfree(mem_device);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_memory_device_start (struct acpi_device *device)
@@ -453,8 +437,6 @@ static int acpi_memory_device_start (struct acpi_device *device)
        struct acpi_memory_device *mem_device;
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_device_start");
-
        mem_device = acpi_driver_data(device);
 
        if (!acpi_memory_check_device(mem_device)) {
@@ -464,7 +446,7 @@ static int acpi_memory_device_start (struct acpi_device *device)
                        ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                "Error in acpi_memory_enable_device\n"));
        }
-       return_VALUE(result);
+       return result;
 }
 
 /*
@@ -477,16 +459,15 @@ static acpi_status is_memory_device(acpi_handle handle)
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_device_info *info;
 
-       ACPI_FUNCTION_TRACE("is_memory_device");
 
        status = acpi_get_object_info(handle, &buffer);
        if (ACPI_FAILURE(status))
-               return_ACPI_STATUS(AE_ERROR);
+               return status;
 
        info = buffer.pointer;
        if (!(info->valid & ACPI_VALID_HID)) {
                acpi_os_free(buffer.pointer);
-               return_ACPI_STATUS(AE_ERROR);
+               return AE_ERROR;
        }
 
        hardware_id = info->hardware_id.value;
@@ -495,7 +476,7 @@ static acpi_status is_memory_device(acpi_handle handle)
                status = AE_ERROR;
 
        acpi_os_free(buffer.pointer);
-       return_ACPI_STATUS(status);
+       return status;
 }
 
 static acpi_status
@@ -504,21 +485,17 @@ acpi_memory_register_notify_handler(acpi_handle handle,
 {
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_register_notify_handler");
 
        status = is_memory_device(handle);
-       if (ACPI_FAILURE(status))
-               return_ACPI_STATUS(AE_OK);      /* continue */
+       if (ACPI_FAILURE(status)){
+               ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
+               return AE_OK;   /* continue */
+       }
 
        status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
                                             acpi_memory_device_notify, NULL);
-       if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error installing notify handler\n"));
-               return_ACPI_STATUS(AE_OK);      /* continue */
-       }
-
-       return_ACPI_STATUS(status);
+       /* continue */
+       return AE_OK;
 }
 
 static acpi_status
@@ -527,22 +504,18 @@ acpi_memory_deregister_notify_handler(acpi_handle handle,
 {
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler");
 
        status = is_memory_device(handle);
-       if (ACPI_FAILURE(status))
-               return_ACPI_STATUS(AE_OK);      /* continue */
+       if (ACPI_FAILURE(status)){
+               ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
+               return AE_OK;   /* continue */
+       }
 
        status = acpi_remove_notify_handler(handle,
                                            ACPI_SYSTEM_NOTIFY,
                                            acpi_memory_device_notify);
-       if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
-               return_ACPI_STATUS(AE_OK);      /* continue */
-       }
 
-       return_ACPI_STATUS(status);
+       return AE_OK;   /* continue */
 }
 
 static int __init acpi_memory_device_init(void)
@@ -550,12 +523,11 @@ static int __init acpi_memory_device_init(void)
        int result;
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_device_init");
 
        result = acpi_bus_register_driver(&acpi_memory_device_driver);
 
        if (result < 0)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
                                     ACPI_UINT32_MAX,
@@ -563,19 +535,18 @@ static int __init acpi_memory_device_init(void)
                                     NULL, NULL);
 
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
                acpi_bus_unregister_driver(&acpi_memory_device_driver);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_memory_device_exit(void)
 {
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("acpi_memory_device_exit");
 
        /*
         * Adding this to un-install notification handlers for all the device
@@ -587,11 +558,11 @@ static void __exit acpi_memory_device_exit(void)
                                     NULL, NULL);
 
        if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
 
        acpi_bus_unregister_driver(&acpi_memory_device_driver);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_memory_device_init);
index 839f423..055cfd5 100644 (file)
@@ -1232,7 +1232,7 @@ static int __init asus_acpi_init(void)
        result = acpi_bus_register_driver(&asus_hotk_driver);
        if (result < 0) {
                remove_proc_entry(PROC_ASUS, acpi_root_dir);
-               return -ENODEV;
+               return result;
        }
 
        /*
index 702e857..00b0728 100644 (file)
@@ -132,17 +132,16 @@ acpi_battery_get_info(struct acpi_battery *battery,
        struct acpi_buffer data = { 0, NULL };
        union acpi_object *package = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_get_info");
 
        if (!battery || !bif)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Evalute _BIF */
 
        status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
+               return -ENODEV;
        }
 
        package = (union acpi_object *)buffer.pointer;
@@ -151,7 +150,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
 
        status = acpi_extract_package(package, &format, &data);
        if (status != AE_BUFFER_OVERFLOW) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
                result = -ENODEV;
                goto end;
        }
@@ -165,7 +164,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
 
        status = acpi_extract_package(package, &format, &data);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
                kfree(data.pointer);
                result = -ENODEV;
                goto end;
@@ -177,7 +176,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
        if (!result)
                (*bif) = (struct acpi_battery_info *)data.pointer;
 
-       return_VALUE(result);
+       return result;
 }
 
 static int
@@ -193,17 +192,16 @@ acpi_battery_get_status(struct acpi_battery *battery,
        struct acpi_buffer data = { 0, NULL };
        union acpi_object *package = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_get_status");
 
        if (!battery || !bst)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Evalute _BST */
 
        status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
+               return -ENODEV;
        }
 
        package = (union acpi_object *)buffer.pointer;
@@ -212,7 +210,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
 
        status = acpi_extract_package(package, &format, &data);
        if (status != AE_BUFFER_OVERFLOW) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
                result = -ENODEV;
                goto end;
        }
@@ -226,7 +224,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
 
        status = acpi_extract_package(package, &format, &data);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
                kfree(data.pointer);
                result = -ENODEV;
                goto end;
@@ -238,7 +236,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
        if (!result)
                (*bst) = (struct acpi_battery_status *)data.pointer;
 
-       return_VALUE(result);
+       return result;
 }
 
 static int
@@ -248,25 +246,24 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list arg_list = { 1, &arg0 };
 
-       ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
 
        if (!battery)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!battery->flags.alarm)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        arg0.integer.value = alarm;
 
        status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm));
 
        battery->alarm = alarm;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_battery_check(struct acpi_battery *battery)
@@ -277,18 +274,17 @@ static int acpi_battery_check(struct acpi_battery *battery)
        struct acpi_device *device = NULL;
        struct acpi_battery_info *bif = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_check");
 
        if (!battery)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        result = acpi_bus_get_device(battery->handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        result = acpi_bus_get_status(device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        /* Insertion? */
 
@@ -300,7 +296,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
 
                result = acpi_battery_get_info(battery, &bif);
                if (result)
-                       return_VALUE(result);
+                       return result;
 
                battery->flags.power_unit = bif->power_unit;
                battery->trips.warning = bif->design_capacity_warning;
@@ -324,7 +320,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
 
        battery->flags.present = device->status.battery_present;
 
-       return_VALUE(result);
+       return result;
 }
 
 /* --------------------------------------------------------------------------
@@ -339,7 +335,6 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
        struct acpi_battery_info *bif = NULL;
        char *units = "?";
 
-       ACPI_FUNCTION_TRACE("acpi_battery_read_info");
 
        if (!battery)
                goto end;
@@ -409,7 +404,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
       end:
        kfree(bif);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
@@ -424,7 +419,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
        struct acpi_battery_status *bst = NULL;
        char *units = "?";
 
-       ACPI_FUNCTION_TRACE("acpi_battery_read_state");
 
        if (!battery)
                goto end;
@@ -458,8 +452,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
        if ((bst->state & 0x01) && (bst->state & 0x02)) {
                seq_printf(seq,
                           "charging state:          charging/discharging\n");
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Battery Charging and Discharging?\n"));
        } else if (bst->state & 0x01)
                seq_printf(seq, "charging state:          discharging\n");
        else if (bst->state & 0x02)
@@ -489,7 +481,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
       end:
        kfree(bst);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
@@ -502,7 +494,6 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
        struct acpi_battery *battery = (struct acpi_battery *)seq->private;
        char *units = "?";
 
-       ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
 
        if (!battery)
                goto end;
@@ -527,7 +518,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
                seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static ssize_t
@@ -540,25 +531,24 @@ acpi_battery_write_alarm(struct file *file,
        struct seq_file *m = (struct seq_file *)file->private_data;
        struct acpi_battery *battery = (struct acpi_battery *)m->private;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
 
        if (!battery || (count > sizeof(alarm_string) - 1))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!battery->flags.present)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (copy_from_user(alarm_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        alarm_string[count] = '\0';
 
        result = acpi_battery_set_alarm(battery,
                                        simple_strtoul(alarm_string, NULL, 0));
        if (result)
-               return_VALUE(result);
+               return result;
 
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
@@ -595,13 +585,12 @@ static int acpi_battery_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_battery_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
 
@@ -609,9 +598,7 @@ static int acpi_battery_add_fs(struct acpi_device *device)
        entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_BATTERY_FILE_INFO));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_battery_info_ops;
                entry->data = acpi_driver_data(device);
@@ -622,9 +609,7 @@ static int acpi_battery_add_fs(struct acpi_device *device)
        entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_BATTERY_FILE_STATUS));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_battery_state_ops;
                entry->data = acpi_driver_data(device);
@@ -636,21 +621,18 @@ static int acpi_battery_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_BATTERY_FILE_ALARM));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_battery_alarm_ops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_battery_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_BATTERY_FILE_ALARM,
@@ -664,7 +646,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -676,13 +658,12 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_battery *battery = (struct acpi_battery *)data;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_notify");
 
        if (!battery)
-               return_VOID;
+               return;
 
        if (acpi_bus_get_device(handle, &device))
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_BATTERY_NOTIFY_STATUS:
@@ -696,7 +677,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static int acpi_battery_add(struct acpi_device *device)
@@ -705,14 +686,13 @@ static int acpi_battery_add(struct acpi_device *device)
        acpi_status status = 0;
        struct acpi_battery *battery = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL);
        if (!battery)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(battery, 0, sizeof(struct acpi_battery));
 
        battery->handle = device->handle;
@@ -732,8 +712,6 @@ static int acpi_battery_add(struct acpi_device *device)
                                             ACPI_DEVICE_NOTIFY,
                                             acpi_battery_notify, battery);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error installing notify handler\n"));
                result = -ENODEV;
                goto end;
        }
@@ -748,7 +726,7 @@ static int acpi_battery_add(struct acpi_device *device)
                kfree(battery);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_battery_remove(struct acpi_device *device, int type)
@@ -756,56 +734,50 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
        acpi_status status = 0;
        struct acpi_battery *battery = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        battery = (struct acpi_battery *)acpi_driver_data(device);
 
        status = acpi_remove_notify_handler(battery->handle,
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_battery_notify);
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
 
        acpi_battery_remove_fs(device);
 
        kfree(battery);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int __init acpi_battery_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_battery_init");
 
        acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
        if (!acpi_battery_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_battery_dir->owner = THIS_MODULE;
 
        result = acpi_bus_register_driver(&acpi_battery_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_battery_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_battery_exit");
 
        acpi_bus_unregister_driver(&acpi_battery_driver);
 
        remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_battery_init);
index dd3983c..dec044c 100644 (file)
@@ -60,21 +60,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_device");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* TBD: Support fixed-feature devices */
 
        status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
        if (ACPI_FAILURE(status) || !*device) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n",
-                                 handle));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle));
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_get_device);
@@ -84,10 +82,9 @@ int acpi_bus_get_status(struct acpi_device *device)
        acpi_status status = AE_OK;
        unsigned long sta = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_status");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /*
         * Evaluate _STA if present.
@@ -96,7 +93,7 @@ int acpi_bus_get_status(struct acpi_device *device)
                status =
                    acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                STRUCT_TO_INT(device->status) = (int)sta;
        }
 
@@ -120,7 +117,7 @@ int acpi_bus_get_status(struct acpi_device *device)
                          device->pnp.bus_id,
                          (u32) STRUCT_TO_INT(device->status)));
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_get_status);
@@ -136,11 +133,10 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
        struct acpi_device *device = NULL;
        unsigned long psc = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_power");
 
        result = acpi_bus_get_device(handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        *state = ACPI_STATE_UNKNOWN;
 
@@ -159,12 +155,12 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
                        status = acpi_evaluate_integer(device->handle, "_PSC",
                                                       NULL, &psc);
                        if (ACPI_FAILURE(status))
-                               return_VALUE(-ENODEV);
+                               return -ENODEV;
                        device->power.state = (int)psc;
                } else if (device->power.flags.power_resources) {
                        result = acpi_power_get_inferred_state(device);
                        if (result)
-                               return_VALUE(result);
+                               return result;
                }
 
                *state = device->power.state;
@@ -173,7 +169,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
                          device->pnp.bus_id, device->power.state));
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_get_power);
@@ -185,21 +181,20 @@ int acpi_bus_set_power(acpi_handle handle, int state)
        struct acpi_device *device = NULL;
        char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
 
-       ACPI_FUNCTION_TRACE("acpi_bus_set_power");
 
        result = acpi_bus_get_device(handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Make sure this is a valid target state */
 
        if (!device->flags.power_manageable) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Device is not power manageable\n"));
-               return_VALUE(-ENODEV);
+               printk(KERN_DEBUG "Device `[%s]is not power manageable",
+                               device->kobj.name);
+               return -ENODEV;
        }
        /*
         * Get device's current power state if it's unknown
@@ -211,18 +206,18 @@ int acpi_bus_set_power(acpi_handle handle, int state)
                if (state == device->power.state) {
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
                                          state));
-                       return_VALUE(0);
+                       return 0;
                }
        }
        if (!device->power.states[state].flags.valid) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n",
-                                 state));
-               return_VALUE(-ENODEV);
+               printk(KERN_WARNING PREFIX "Device does not support D%d\n", state);
+               return -ENODEV;
        }
        if (device->parent && (state < device->parent->power.state)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Cannot set device to a higher-powered state than parent\n"));
-               return_VALUE(-ENODEV);
+               printk(KERN_WARNING PREFIX
+                             "Cannot set device to a higher-powered"
+                             " state than parent\n");
+               return -ENODEV;
        }
 
        /*
@@ -264,15 +259,15 @@ int acpi_bus_set_power(acpi_handle handle, int state)
 
       end:
        if (result)
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Error transitioning device [%s] to D%d\n",
-                                 device->pnp.bus_id, state));
+               printk(KERN_WARNING PREFIX
+                             "Transitioning device [%s] to D%d\n",
+                             device->pnp.bus_id, state);
        else
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "Device [%s] transitioned to D%d\n",
                                  device->pnp.bus_id, state));
 
-       return_VALUE(result);
+       return result;
 }
 
 EXPORT_SYMBOL(acpi_bus_set_power);
@@ -293,18 +288,17 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
        struct acpi_bus_event *event = NULL;
        unsigned long flags = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* drop event on the floor if no one's listening */
        if (!event_is_open)
-               return_VALUE(0);
+               return 0;
 
        event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
        if (!event)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
 
        strcpy(event->device_class, device->pnp.device_class);
        strcpy(event->bus_id, device->pnp.bus_id);
@@ -317,7 +311,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
 
        wake_up_interruptible(&acpi_bus_event_queue);
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_generate_event);
@@ -329,10 +323,9 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
 
        DECLARE_WAITQUEUE(wait, current);
 
-       ACPI_FUNCTION_TRACE("acpi_bus_receive_event");
 
        if (!event)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (list_empty(&acpi_bus_event_list)) {
 
@@ -346,7 +339,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
                set_current_state(TASK_RUNNING);
 
                if (signal_pending(current))
-                       return_VALUE(-ERESTARTSYS);
+                       return -ERESTARTSYS;
        }
 
        spin_lock_irqsave(&acpi_bus_event_lock, flags);
@@ -357,13 +350,13 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
        spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
 
        if (!entry)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        memcpy(event, entry, sizeof(struct acpi_bus_event));
 
        kfree(entry);
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_receive_event);
@@ -378,10 +371,9 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
        acpi_status status = 0;
        struct acpi_device_status old_status;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_check_device");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (status_changed)
                *status_changed = 0;
@@ -398,15 +390,15 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
                        if (status_changed)
                                *status_changed = 1;
                }
-               return_VALUE(0);
+               return 0;
        }
 
        status = acpi_bus_get_status(device);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
-               return_VALUE(0);
+               return 0;
 
        if (status_changed)
                *status_changed = 1;
@@ -422,7 +414,7 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
                /* TBD: Handle device removal */
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_bus_check_scope(struct acpi_device *device)
@@ -430,25 +422,24 @@ static int acpi_bus_check_scope(struct acpi_device *device)
        int result = 0;
        int status_changed = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Status Change? */
        result = acpi_bus_check_device(device, &status_changed);
        if (result)
-               return_VALUE(result);
+               return result;
 
        if (!status_changed)
-               return_VALUE(0);
+               return 0;
 
        /*
         * TBD: Enumerate child devices within this device's scope and
         *       run acpi_bus_check_device()'s on them.
         */
 
-       return_VALUE(0);
+       return 0;
 }
 
 /**
@@ -461,10 +452,9 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_notify");
 
        if (acpi_bus_get_device(handle, &device))
-               return_VOID;
+               return;
 
        switch (type) {
 
@@ -539,7 +529,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 /* --------------------------------------------------------------------------
@@ -553,7 +543,6 @@ static int __init acpi_bus_init_irq(void)
        struct acpi_object_list arg_list = { 1, &arg };
        char *message = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
 
        /* 
         * Let the system know what interrupt model we are using by
@@ -572,7 +561,7 @@ static int __init acpi_bus_init_irq(void)
                break;
        default:
                printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
@@ -581,11 +570,11 @@ static int __init acpi_bus_init_irq(void)
 
        status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
        if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 void __init acpi_early_init(void)
@@ -593,10 +582,9 @@ void __init acpi_early_init(void)
        acpi_status status = AE_OK;
        struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt };
 
-       ACPI_FUNCTION_TRACE("acpi_early_init");
 
        if (acpi_disabled)
-               return_VOID;
+               return;
 
        printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
 
@@ -656,11 +644,11 @@ void __init acpi_early_init(void)
                goto error0;
        }
 
-       return_VOID;
+       return;
 
       error0:
        disable_acpi();
-       return_VOID;
+       return;
 }
 
 static int __init acpi_bus_init(void)
@@ -669,7 +657,6 @@ static int __init acpi_bus_init(void)
        acpi_status status = AE_OK;
        extern acpi_status acpi_os_initialize1(void);
 
-       ACPI_FUNCTION_TRACE("acpi_bus_init");
 
        status = acpi_os_initialize1();
 
@@ -731,12 +718,12 @@ static int __init acpi_bus_init(void)
         */
        acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
 
-       return_VALUE(0);
+       return 0;
 
        /* Mimic structured exception handling */
       error1:
        acpi_terminate();
-       return_VALUE(-ENODEV);
+       return -ENODEV;
 }
 
 decl_subsys(acpi, NULL, NULL);
@@ -745,11 +732,10 @@ static int __init acpi_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_init");
 
        if (acpi_disabled) {
                printk(KERN_INFO PREFIX "Interpreter disabled.\n");
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        firmware_register(&acpi_subsys);
@@ -770,7 +756,7 @@ static int __init acpi_init(void)
        } else
                disable_acpi();
 
-       return_VALUE(result);
+       return result;
 }
 
 subsys_initcall(acpi_init);
index 4b6d9f0..0259463 100644 (file)
@@ -112,15 +112,14 @@ static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_button *button = (struct acpi_button *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
 
        if (!button || !button->device)
-               return_VALUE(0);
+               return 0;
 
        seq_printf(seq, "type:                    %s\n",
                   acpi_device_name(button->device));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
@@ -134,10 +133,9 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
        acpi_status status;
        unsigned long state;
 
-       ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
 
        if (!button || !button->device)
-               return_VALUE(0);
+               return 0;
 
        status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
        if (ACPI_FAILURE(status)) {
@@ -147,7 +145,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
                           (state ? "open" : "closed"));
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
@@ -164,10 +162,9 @@ static int acpi_button_add_fs(struct acpi_device *device)
        struct proc_dir_entry *entry = NULL;
        struct acpi_button *button = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_button_add_fs");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        button = acpi_driver_data(device);
 
@@ -195,21 +192,19 @@ static int acpi_button_add_fs(struct acpi_device *device)
        }
 
        if (!entry)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        entry->owner = THIS_MODULE;
 
        acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
        if (!acpi_device_dir(device))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_device_dir(device)->owner = THIS_MODULE;
 
        /* 'info' [R] */
        entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_BUTTON_FILE_INFO));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_button_info_fops;
                entry->data = acpi_driver_data(device);
@@ -221,9 +216,7 @@ static int acpi_button_add_fs(struct acpi_device *device)
                entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
                                          S_IRUGO, acpi_device_dir(device));
                if (!entry)
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Unable to create '%s' fs entry\n",
-                                         ACPI_BUTTON_FILE_INFO));
+                       return -ENODEV;
                else {
                        entry->proc_fops = &acpi_button_state_fops;
                        entry->data = acpi_driver_data(device);
@@ -231,14 +224,13 @@ static int acpi_button_add_fs(struct acpi_device *device)
                }
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_button_remove_fs(struct acpi_device *device)
 {
        struct acpi_button *button = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
 
        button = acpi_driver_data(device);
        if (acpi_device_dir(device)) {
@@ -253,7 +245,7 @@ static int acpi_button_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -264,10 +256,9 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
 {
        struct acpi_button *button = (struct acpi_button *)data;
 
-       ACPI_FUNCTION_TRACE("acpi_button_notify");
 
        if (!button || !button->device)
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_BUTTON_NOTIFY_STATUS:
@@ -280,21 +271,20 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static acpi_status acpi_button_notify_fixed(void *data)
 {
        struct acpi_button *button = (struct acpi_button *)data;
 
-       ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
 
        if (!button)
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 static int acpi_button_add(struct acpi_device *device)
@@ -303,14 +293,13 @@ static int acpi_button_add(struct acpi_device *device)
        acpi_status status = AE_OK;
        struct acpi_button *button = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_button_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL);
        if (!button)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(button, 0, sizeof(struct acpi_button));
 
        button->device = device;
@@ -349,8 +338,8 @@ static int acpi_button_add(struct acpi_device *device)
                sprintf(acpi_device_class(device), "%s/%s",
                        ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
        } else {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
-                                 acpi_device_hid(device)));
+               printk(KERN_ERR PREFIX "Unsupported hid [%s]\n",
+                           acpi_device_hid(device));
                result = -ENODEV;
                goto end;
        }
@@ -381,8 +370,6 @@ static int acpi_button_add(struct acpi_device *device)
        }
 
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error installing notify handler\n"));
                result = -ENODEV;
                goto end;
        }
@@ -406,7 +393,7 @@ static int acpi_button_add(struct acpi_device *device)
                kfree(button);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_button_remove(struct acpi_device *device, int type)
@@ -414,10 +401,9 @@ static int acpi_button_remove(struct acpi_device *device, int type)
        acpi_status status = 0;
        struct acpi_button *button = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_button_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        button = acpi_driver_data(device);
 
@@ -440,39 +426,33 @@ static int acpi_button_remove(struct acpi_device *device, int type)
                break;
        }
 
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
-
        acpi_button_remove_fs(device);
 
        kfree(button);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int __init acpi_button_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_button_init");
 
        acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
        if (!acpi_button_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_button_dir->owner = THIS_MODULE;
        result = acpi_bus_register_driver(&acpi_button_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_button_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_button_exit");
 
        acpi_bus_unregister_driver(&acpi_button_driver);
 
@@ -484,7 +464,7 @@ static void __exit acpi_button_exit(void)
                remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
        remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_button_init);
index b69a8ca..7f7e41d 100644 (file)
@@ -73,17 +73,16 @@ static int is_device_present(acpi_handle handle)
        acpi_status status;
        unsigned long sta;
 
-       ACPI_FUNCTION_TRACE("is_device_present");
 
        status = acpi_get_handle(handle, "_STA", &temp);
        if (ACPI_FAILURE(status))
-               return_VALUE(1);        /* _STA not found, assmue device present */
+               return 1;       /* _STA not found, assmue device present */
 
        status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
        if (ACPI_FAILURE(status))
-               return_VALUE(0);        /* Firmware error */
+               return 0;       /* Firmware error */
 
-       return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
+       return ((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
 }
 
 /*******************************************************************/
@@ -91,16 +90,15 @@ static int acpi_container_add(struct acpi_device *device)
 {
        struct acpi_container *container;
 
-       ACPI_FUNCTION_TRACE("acpi_container_add");
 
        if (!device) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "device is NULL\n"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "device is NULL\n");
+               return -EINVAL;
        }
 
        container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
        if (!container)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
 
        memset(container, 0, sizeof(struct acpi_container));
        container->handle = device->handle;
@@ -111,7 +109,7 @@ static int acpi_container_add(struct acpi_device *device)
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
                          acpi_device_name(device), acpi_device_bid(device)));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_container_remove(struct acpi_device *device, int type)
@@ -130,23 +128,22 @@ static int container_device_add(struct acpi_device **device, acpi_handle handle)
        struct acpi_device *pdev;
        int result;
 
-       ACPI_FUNCTION_TRACE("container_device_add");
 
        if (acpi_get_parent(handle, &phandle)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (acpi_bus_get_device(phandle, &pdev)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        result = acpi_bus_start(*device);
 
-       return_VALUE(result);
+       return result;
 }
 
 static void container_notify_cb(acpi_handle handle, u32 type, void *context)
@@ -156,7 +153,6 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
        int present;
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("container_notify_cb");
 
        present = is_device_present(handle);
 
@@ -192,7 +188,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
        default:
                break;
        }
-       return_VOID;
+       return;
 }
 
 static acpi_status
@@ -205,11 +201,10 @@ container_walk_namespace_cb(acpi_handle handle,
        acpi_status status;
        int *action = context;
 
-       ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
 
        status = acpi_get_object_info(handle, &buffer);
        if (ACPI_FAILURE(status) || !buffer.pointer) {
-               return_ACPI_STATUS(AE_OK);
+               return AE_OK;
        }
 
        info = buffer.pointer;
@@ -243,7 +238,7 @@ container_walk_namespace_cb(acpi_handle handle,
       end:
        acpi_os_free(buffer.pointer);
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 static int __init acpi_container_init(void)
@@ -269,7 +264,6 @@ static void __exit acpi_container_exit(void)
 {
        int action = UNINSTALL_NOTIFY_HANDLER;
 
-       ACPI_FUNCTION_TRACE("acpi_container_exit");
 
        acpi_walk_namespace(ACPI_TYPE_DEVICE,
                            ACPI_ROOT_OBJECT,
@@ -278,7 +272,7 @@ static void __exit acpi_container_exit(void)
 
        acpi_bus_unregister_driver(&acpi_container_driver);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_container_init);
index 263322b..35c6af8 100644 (file)
@@ -155,13 +155,12 @@ acpi_system_write_debug(struct file *file,
 {
        char debug_string[12] = { '\0' };
 
-       ACPI_FUNCTION_TRACE("acpi_system_write_debug");
 
        if (count > sizeof(debug_string) - 1)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(debug_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        debug_string[count] = '\0';
 
@@ -173,10 +172,10 @@ acpi_system_write_debug(struct file *file,
                acpi_dbg_level = simple_strtoul(debug_string, NULL, 0);
                break;
        default:
-               return_VALUE(-EINVAL);
+               return -EINVAL;
        }
 
-       return_VALUE(count);
+       return count;
 }
 
 static int __init acpi_debug_init(void)
@@ -185,10 +184,9 @@ static int __init acpi_debug_init(void)
        int error = 0;
        char *name;
 
-       ACPI_FUNCTION_TRACE("acpi_debug_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
        /* 'debug_layer' [R/W] */
        name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
@@ -213,15 +211,12 @@ static int __init acpi_debug_init(void)
                goto Error;
 
       Done:
-       return_VALUE(error);
+       return error;
 
       Error:
-       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                         "Unable to create '%s' proc fs entry\n", name));
-
        remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
        remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
-       error = -EFAULT;
+       error = -ENODEV;
        goto Done;
 }
 
index bbdf990..daf51b5 100644 (file)
@@ -125,37 +125,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
                if (info->table_desc->pointer->revision == 1) {
                        node->flags |= ANOBJ_DATA_WIDTH_32;
                }
-#ifdef ACPI_INIT_PARSE_METHODS
-               /*
-                * Note 11/2005: Removed this code to parse all methods during table
-                * load because it causes problems if there are any errors during the
-                * parse. Also, it seems like overkill and we probably don't want to
-                * abort a table load because of an issue with a single method.
-                */
-
-               /*
-                * Print a dot for each method unless we are going to print
-                * the entire pathname
-                */
-               if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
-                       ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
-               }
 
-               /*
-                * Always parse methods to detect errors, we will delete
-                * the parse tree below
-                */
-               status = acpi_ds_parse_method(obj_handle);
-               if (ACPI_FAILURE(status)) {
-                       ACPI_ERROR((AE_INFO,
-                                   "Method %p [%4.4s] - parse failure, %s",
-                                   obj_handle,
-                                   acpi_ut_get_node_name(obj_handle),
-                                   acpi_format_exception(status)));
-
-                       /* This parse failed, but we will continue parsing more methods */
-               }
-#endif
                info->method_count++;
                break;
 
index bc9aca4..a39a33f 100644 (file)
 #define _COMPONENT          ACPI_DISPATCHER
 ACPI_MODULE_NAME("dsmethod")
 
+/* Local prototypes */
+static acpi_status
+acpi_ds_create_method_mutex(union acpi_operand_object *method_desc);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ds_method_error
@@ -67,6 +71,7 @@ ACPI_MODULE_NAME("dsmethod")
  *              Note: Allows the exception handler to change the status code
  *
  ******************************************************************************/
+
 acpi_status
 acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
 {
@@ -113,11 +118,51 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_ds_create_method_mutex
+ *
+ * PARAMETERS:  obj_desc            - The method object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create a mutex object for a serialized control method
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
+{
+       union acpi_operand_object *mutex_desc;
+       acpi_status status;
+
+       ACPI_FUNCTION_NAME(ds_create_method_mutex);
+
+       /* Create the new mutex object */
+
+       mutex_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
+       if (!mutex_desc) {
+               return_ACPI_STATUS(AE_NO_MEMORY);
+       }
+
+       /* Create the actual OS Mutex */
+
+       status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);
+       if (ACPI_FAILURE(status)) {
+               return_ACPI_STATUS(status);
+       }
+
+       mutex_desc->mutex.sync_level = method_desc->method.sync_level;
+       method_desc->method.mutex = mutex_desc;
+       return_ACPI_STATUS(AE_OK);
+}
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_ds_begin_method_execution
  *
  * PARAMETERS:  method_node         - Node of the method
  *              obj_desc            - The method object
- *              calling_method_node - Caller of this method (if non-null)
+ *              walk_state          - current state, NULL if not yet executing
+ *                                    a method.
  *
  * RETURN:      Status
  *
@@ -128,9 +173,9 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
  ******************************************************************************/
 
 acpi_status
-acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
-                              union acpi_operand_object * obj_desc,
-                              struct acpi_namespace_node * calling_method_node)
+acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
+                              union acpi_operand_object *obj_desc,
+                              struct acpi_walk_state *walk_state)
 {
        acpi_status status = AE_OK;
 
@@ -149,35 +194,80 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
        }
 
        /*
-        * If there is a concurrency limit on this method, we need to
-        * obtain a unit from the method semaphore.
+        * If this method is serialized, we need to acquire the method mutex.
         */
-       if (obj_desc->method.semaphore) {
+       if (obj_desc->method.method_flags & AML_METHOD_SERIALIZED) {
                /*
-                * Allow recursive method calls, up to the reentrancy/concurrency
-                * limit imposed by the SERIALIZED rule and the sync_level method
-                * parameter.
-                *
-                * The point of this code is to avoid permanently blocking a
-                * thread that is making recursive method calls.
+                * Create a mutex for the method if it is defined to be Serialized
+                * and a mutex has not already been created. We defer the mutex creation
+                * until a method is actually executed, to minimize the object count
                 */
-               if (method_node == calling_method_node) {
-                       if (obj_desc->method.thread_count >=
-                           obj_desc->method.concurrency) {
-                               return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
+               if (!obj_desc->method.mutex) {
+                       status = acpi_ds_create_method_mutex(obj_desc);
+                       if (ACPI_FAILURE(status)) {
+                               return_ACPI_STATUS(status);
                        }
                }
 
                /*
-                * Get a unit from the method semaphore. This releases the
-                * interpreter if we block (then reacquires it)
+                * The current_sync_level (per-thread) must be less than or equal to
+                * the sync level of the method. This mechanism provides some
+                * deadlock prevention
+                *
+                * Top-level method invocation has no walk state at this point
                 */
-               status =
-                   acpi_ex_system_wait_semaphore(obj_desc->method.semaphore,
-                                                 ACPI_WAIT_FOREVER);
-               if (ACPI_FAILURE(status)) {
-                       return_ACPI_STATUS(status);
+               if (walk_state &&
+                   (walk_state->thread->current_sync_level >
+                    obj_desc->method.mutex->mutex.sync_level)) {
+                       ACPI_ERROR((AE_INFO,
+                                   "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)",
+                                   acpi_ut_get_node_name(method_node),
+                                   walk_state->thread->current_sync_level));
+
+                       return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
                }
+
+               /*
+                * Obtain the method mutex if necessary. Do not acquire mutex for a
+                * recursive call.
+                */
+               if (!walk_state ||
+                   !obj_desc->method.mutex->mutex.owner_thread ||
+                   (walk_state->thread !=
+                    obj_desc->method.mutex->mutex.owner_thread)) {
+                       /*
+                        * Acquire the method mutex. This releases the interpreter if we
+                        * block (and reacquires it before it returns)
+                        */
+                       status =
+                           acpi_ex_system_wait_mutex(obj_desc->method.mutex->
+                                                     mutex.os_mutex,
+                                                     ACPI_WAIT_FOREVER);
+                       if (ACPI_FAILURE(status)) {
+                               return_ACPI_STATUS(status);
+                       }
+
+                       /* Update the mutex and walk info and save the original sync_level */
+
+                       if (walk_state) {
+                               obj_desc->method.mutex->mutex.
+                                   original_sync_level =
+                                   walk_state->thread->current_sync_level;
+
+                               obj_desc->method.mutex->mutex.owner_thread =
+                                   walk_state->thread;
+                               walk_state->thread->current_sync_level =
+                                   obj_desc->method.sync_level;
+                       } else {
+                               obj_desc->method.mutex->mutex.
+                                   original_sync_level =
+                                   obj_desc->method.mutex->mutex.sync_level;
+                       }
+               }
+
+               /* Always increase acquisition depth */
+
+               obj_desc->method.mutex->mutex.acquisition_depth++;
        }
 
        /*
@@ -200,10 +290,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
        return_ACPI_STATUS(status);
 
       cleanup:
-       /* On error, must signal the method semaphore if present */
+       /* On error, must release the method mutex (if present) */
 
-       if (obj_desc->method.semaphore) {
-               (void)acpi_os_signal_semaphore(obj_desc->method.semaphore, 1);
+       if (obj_desc->method.mutex) {
+               acpi_os_release_mutex(obj_desc->method.mutex->mutex.os_mutex);
        }
        return_ACPI_STATUS(status);
 }
@@ -253,10 +343,10 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
                return_ACPI_STATUS(AE_NULL_OBJECT);
        }
 
-       /* Init for new method, possibly wait on concurrency semaphore */
+       /* Init for new method, possibly wait on method mutex */
 
        status = acpi_ds_begin_method_execution(method_node, obj_desc,
-                                               this_walk_state->method_node);
+                                               this_walk_state);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
@@ -478,6 +568,8 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
  *              created, delete all locals and arguments, and delete the parse
  *              tree if requested.
  *
+ * MUTEX:       Interpreter is locked
+ *
  ******************************************************************************/
 
 void
@@ -503,26 +595,21 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
        }
 
        /*
-        * Lock the parser while we terminate this method.
-        * If this is the last thread executing the method,
-        * we have additional cleanup to perform
+        * If method is serialized, release the mutex and restore the
+        * current sync level for this thread
         */
-       status = acpi_ut_acquire_mutex(ACPI_MTX_CONTROL_METHOD);
-       if (ACPI_FAILURE(status)) {
-               return_VOID;
-       }
+       if (method_desc->method.mutex) {
 
-       /* Signal completion of the execution of this method if necessary */
+               /* Acquisition Depth handles recursive calls */
 
-       if (method_desc->method.semaphore) {
-               status =
-                   acpi_os_signal_semaphore(method_desc->method.semaphore, 1);
-               if (ACPI_FAILURE(status)) {
-
-                       /* Ignore error and continue */
+               method_desc->method.mutex->mutex.acquisition_depth--;
+               if (!method_desc->method.mutex->mutex.acquisition_depth) {
+                       walk_state->thread->current_sync_level =
+                           method_desc->method.mutex->mutex.
+                           original_sync_level;
 
-                       ACPI_EXCEPTION((AE_INFO, status,
-                                       "Could not signal method semaphore"));
+                       acpi_os_release_mutex(method_desc->method.mutex->mutex.
+                                             os_mutex);
                }
        }
 
@@ -537,7 +624,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
 
                status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
                if (ACPI_FAILURE(status)) {
-                       goto exit;
+                       return_VOID;
                }
 
                /*
@@ -580,18 +667,16 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
                /*
                 * Support to dynamically change a method from not_serialized to
                 * Serialized if it appears that the method is incorrectly written and
-                * does not support multiple thread execution.  The best example of this
-                * is if such a method creates namespace objects and blocks.  A second
+                * does not support multiple thread execution. The best example of this
+                * is if such a method creates namespace objects and blocks. A second
                 * thread will fail with an AE_ALREADY_EXISTS exception
                 *
                 * This code is here because we must wait until the last thread exits
                 * before creating the synchronization semaphore.
                 */
-               if ((method_desc->method.concurrency == 1) &&
-                   (!method_desc->method.semaphore)) {
-                       status = acpi_os_create_semaphore(1, 1,
-                                                         &method_desc->method.
-                                                         semaphore);
+               if ((method_desc->method.method_flags & AML_METHOD_SERIALIZED)
+                   && (!method_desc->method.mutex)) {
+                       status = acpi_ds_create_method_mutex(method_desc);
                }
 
                /* No more threads, we can free the owner_id */
@@ -599,144 +684,5 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
                acpi_ut_release_owner_id(&method_desc->method.owner_id);
        }
 
-      exit:
-       (void)acpi_ut_release_mutex(ACPI_MTX_CONTROL_METHOD);
        return_VOID;
 }
-
-#ifdef ACPI_INIT_PARSE_METHODS
-       /*
-        * Note 11/2005: Removed this code to parse all methods during table
-        * load because it causes problems if there are any errors during the
-        * parse. Also, it seems like overkill and we probably don't want to
-        * abort a table load because of an issue with a single method.
-        */
-
-/*******************************************************************************
- *
- * FUNCTION:    acpi_ds_parse_method
- *
- * PARAMETERS:  Node        - Method node
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Parse the AML that is associated with the method.
- *
- * MUTEX:       Assumes parser is locked
- *
- ******************************************************************************/
-
-acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
-{
-       acpi_status status;
-       union acpi_operand_object *obj_desc;
-       union acpi_parse_object *op;
-       struct acpi_walk_state *walk_state;
-
-       ACPI_FUNCTION_TRACE_PTR(ds_parse_method, node);
-
-       /* Parameter Validation */
-
-       if (!node) {
-               return_ACPI_STATUS(AE_NULL_ENTRY);
-       }
-
-       ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
-                         "**** Parsing [%4.4s] **** NamedObj=%p\n",
-                         acpi_ut_get_node_name(node), node));
-
-       /* Extract the method object from the method Node */
-
-       obj_desc = acpi_ns_get_attached_object(node);
-       if (!obj_desc) {
-               return_ACPI_STATUS(AE_NULL_OBJECT);
-       }
-
-       /* Create a mutex for the method if there is a concurrency limit */
-
-       if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
-           (!obj_desc->method.semaphore)) {
-               status = acpi_os_create_semaphore(obj_desc->method.concurrency,
-                                                 obj_desc->method.concurrency,
-                                                 &obj_desc->method.semaphore);
-               if (ACPI_FAILURE(status)) {
-                       return_ACPI_STATUS(status);
-               }
-       }
-
-       /*
-        * Allocate a new parser op to be the root of the parsed
-        * method tree
-        */
-       op = acpi_ps_alloc_op(AML_METHOD_OP);
-       if (!op) {
-               return_ACPI_STATUS(AE_NO_MEMORY);
-       }
-
-       /* Init new op with the method name and pointer back to the Node */
-
-       acpi_ps_set_name(op, node->name.integer);
-       op->common.node = node;
-
-       /*
-        * Get a new owner_id for objects created by this method. Namespace
-        * objects (such as Operation Regions) can be created during the
-        * first pass parse.
-        */
-       status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
-       if (ACPI_FAILURE(status)) {
-               goto cleanup;
-       }
-
-       /* Create and initialize a new walk state */
-
-       walk_state =
-           acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
-                                     NULL);
-       if (!walk_state) {
-               status = AE_NO_MEMORY;
-               goto cleanup2;
-       }
-
-       status = acpi_ds_init_aml_walk(walk_state, op, node,
-                                      obj_desc->method.aml_start,
-                                      obj_desc->method.aml_length, NULL, 1);
-       if (ACPI_FAILURE(status)) {
-               acpi_ds_delete_walk_state(walk_state);
-               goto cleanup2;
-       }
-
-       /*
-        * Parse the method, first pass
-        *
-        * The first pass load is where newly declared named objects are added into
-        * the namespace.  Actual evaluation of the named objects (what would be
-        * called a "second pass") happens during the actual execution of the
-        * method so that operands to the named objects can take on dynamic
-        * run-time values.
-        */
-       status = acpi_ps_parse_aml(walk_state);
-       if (ACPI_FAILURE(status)) {
-               goto cleanup2;
-       }
-
-       ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
-                         "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n",
-                         acpi_ut_get_node_name(node), node, op));
-
-       /*
-        * Delete the parse tree. We simply re-parse the method for every
-        * execution since there isn't much overhead (compared to keeping lots
-        * of parse trees around)
-        */
-       acpi_ns_delete_namespace_subtree(node);
-       acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
-
-      cleanup2:
-       acpi_ut_release_owner_id(&obj_desc->method.owner_id);
-
-      cleanup:
-       acpi_ps_delete_parse_tree(op);
-       return_ACPI_STATUS(status);
-}
-#endif
index 3acbd91..b1ded62 100644 (file)
@@ -472,7 +472,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                            acpi_ds_result_push(walk_state->result_obj,
                                                walk_state);
                }
-
                break;
 
        default:
@@ -510,6 +509,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
                                ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
                                                  "Method Reference in a Package, Op=%p\n",
                                                  op));
+
                                op->common.node =
                                    (struct acpi_namespace_node *)op->asl.value.
                                    arg->asl.node->object;
@@ -670,7 +670,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
 
                                status = acpi_ds_result_stack_pop(walk_state);
                        }
-
                        break;
 
                case AML_TYPE_UNDEFINED:
@@ -708,7 +707,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
         * Check if we just completed the evaluation of a
         * conditional predicate
         */
-
        if ((ACPI_SUCCESS(status)) &&
            (walk_state->control_state) &&
            (walk_state->control_state->common.state ==
index 3507439..e3ca7f6 100644 (file)
@@ -175,7 +175,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                if (status == AE_NOT_FOUND) {
                        /*
                         * Table disassembly:
-                        * Target of Scope() not found.  Generate an External for it, and
+                        * Target of Scope() not found. Generate an External for it, and
                         * insert the name into the namespace.
                         */
                        acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0);
@@ -210,16 +210,15 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                case ACPI_TYPE_BUFFER:
 
                        /*
-                        * These types we will allow, but we will change the type.  This
+                        * These types we will allow, but we will change the type. This
                         * enables some existing code of the form:
                         *
                         *  Name (DEB, 0)
                         *  Scope (DEB) { ... }
                         *
-                        * Note: silently change the type here.  On the second pass, we will report
+                        * Note: silently change the type here. On the second pass, we will report
                         * a warning
                         */
-
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
                                          path,
@@ -242,7 +241,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                break;
 
        default:
-
                /*
                 * For all other named opcodes, we will enter the name into
                 * the namespace.
@@ -259,7 +257,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                 *       buffer_field, or Package), the name of the object is already
                 *       in the namespace.
                 */
-
                if (walk_state->deferred_node) {
 
                        /* This name is already in the namespace, get the node */
@@ -293,8 +290,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                }
 
                /*
-                * Enter the named type into the internal namespace.  We enter the name
-                * as we go downward in the parse tree.  Any necessary subobjects that
+                * Enter the named type into the internal namespace. We enter the name
+                * as we go downward in the parse tree. Any necessary subobjects that
                 * involve arguments to the opcode must be created as we go back up the
                 * parse tree later.
                 */
@@ -327,12 +324,12 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                                                            (status);
                                                }
                                        }
+
                                        status = AE_OK;
                                }
                        }
 
                        if (ACPI_FAILURE(status)) {
-
                                ACPI_ERROR_NAMESPACE(path, status);
                                return_ACPI_STATUS(status);
                        }
@@ -434,9 +431,13 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
                        status =
                            acpi_ex_create_region(op->named.data,
                                                  op->named.length,
-                                                 (acpi_adr_space_type)
-                                                 ((op->common.value.arg)->
-                                                  common.value.integer),
+                                                 (acpi_adr_space_type) ((op->
+                                                                         common.
+                                                                         value.
+                                                                         arg)->
+                                                                        common.
+                                                                        value.
+                                                                        integer),
                                                  walk_state);
                        if (ACPI_FAILURE(status)) {
                                return_ACPI_STATUS(status);
@@ -474,7 +475,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
                         * method_op pkg_length name_string method_flags term_list
                         *
                         * Note: We must create the method node/object pair as soon as we
-                        * see the method declaration.  This allows later pass1 parsing
+                        * see the method declaration. This allows later pass1 parsing
                         * of invocations of the method (need to know the number of
                         * arguments.)
                         */
@@ -499,6 +500,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
                                                                  length,
                                                                  walk_state);
                                }
+
                                walk_state->operands[0] = NULL;
                                walk_state->num_operands = 0;
 
@@ -570,7 +572,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
 #ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
                        if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
                            (walk_state->op_info->class == AML_CLASS_CONTROL)) {
-
                                ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
                                                  "Begin/EXEC: %s (fl %8.8X)\n",
                                                  walk_state->op_info->name,
@@ -602,7 +603,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                } else {
                        /* Get name from the op */
 
-                       buffer_ptr = (char *)&op->named.name;
+                       buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
                }
        } else {
                /* Get the namestring from the raw AML */
@@ -629,7 +630,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                break;
 
        case AML_INT_NAMEPATH_OP:
-
                /*
                 * The name_path is an object reference to an existing object.
                 * Don't enter the name into the namespace, but look it up
@@ -642,7 +642,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                break;
 
        case AML_SCOPE_OP:
-
                /*
                 * The Path is an object reference to an existing object.
                 * Don't enter the name into the namespace, but look it up
@@ -664,6 +663,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
 #endif
                        return_ACPI_STATUS(status);
                }
+
                /*
                 * We must check to make sure that the target is
                 * one of the opcodes that actually opens a scope
@@ -683,13 +683,12 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                case ACPI_TYPE_BUFFER:
 
                        /*
-                        * These types we will allow, but we will change the type.  This
+                        * These types we will allow, but we will change the type. This
                         * enables some existing code of the form:
                         *
                         *  Name (DEB, 0)
                         *  Scope (DEB) { ... }
                         */
-
                        ACPI_WARNING((AE_INFO,
                                      "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
                                      buffer_ptr,
@@ -729,14 +728,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                                if (ACPI_FAILURE(status)) {
                                        return_ACPI_STATUS(status);
                                }
-
                        }
+
                        return_ACPI_STATUS(AE_OK);
                }
 
                /*
-                * Enter the named type into the internal namespace.  We enter the name
-                * as we go downward in the parse tree.  Any necessary subobjects that
+                * Enter the named type into the internal namespace. We enter the name
+                * as we go downward in the parse tree. Any necessary subobjects that
                 * involve arguments to the opcode must be created as we go back up the
                 * parse tree later.
                 *
@@ -787,7 +786,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
         * can get it again quickly when this scope is closed
         */
        op->common.node = node;
-
        return_ACPI_STATUS(status);
 }
 
@@ -922,7 +920,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
 #ifndef ACPI_NO_METHOD_EXECUTION
 
        case AML_TYPE_CREATE_FIELD:
-
                /*
                 * Create the field object, but the field buffer and index must
                 * be evaluated later during the execution phase
@@ -931,7 +928,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
                break;
 
        case AML_TYPE_NAMED_FIELD:
-
                /*
                 * If we are executing a method, initialize the field
                 */
@@ -1051,6 +1047,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
                         * argument is the space_id. (We must save the address of the
                         * AML of the address and length operands)
                         */
+
                        /*
                         * If we have a valid region, initialize it
                         * Namespace is NOT locked at this point.
@@ -1080,7 +1077,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
                         * method_op pkg_length name_string method_flags term_list
                         *
                         * Note: We must create the method node/object pair as soon as we
-                        * see the method declaration.  This allows later pass1 parsing
+                        * see the method declaration. This allows later pass1 parsing
                         * of invocations of the method (need to know the number of
                         * arguments.)
                         */
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
new file mode 100644 (file)
index 0000000..510a945
--- /dev/null
@@ -0,0 +1,739 @@
+/*
+ *  dock.c - ACPI dock station driver
+ *
+ *  Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/notifier.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+#define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver"
+
+ACPI_MODULE_NAME("dock")
+MODULE_AUTHOR("Kristen Carlson Accardi");
+MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+static struct atomic_notifier_head dock_notifier_list;
+
+struct dock_station {
+       acpi_handle handle;
+       unsigned long last_dock_time;
+       u32 flags;
+       spinlock_t dd_lock;
+       spinlock_t hp_lock;
+       struct list_head dependent_devices;
+       struct list_head hotplug_devices;
+};
+
+struct dock_dependent_device {
+       struct list_head list;
+       struct list_head hotplug_list;
+       acpi_handle handle;
+       acpi_notify_handler handler;
+       void *context;
+};
+
+#define DOCK_DOCKING   0x00000001
+#define DOCK_EVENT     KOBJ_DOCK
+#define UNDOCK_EVENT   KOBJ_UNDOCK
+
+static struct dock_station *dock_station;
+
+/*****************************************************************************
+ *                         Dock Dependent device functions                   *
+ *****************************************************************************/
+/**
+ *  alloc_dock_dependent_device - allocate and init a dependent device
+ *  @handle: the acpi_handle of the dependent device
+ *
+ *  Allocate memory for a dependent device structure for a device referenced
+ *  by the acpi handle
+ */
+static struct dock_dependent_device *
+alloc_dock_dependent_device(acpi_handle handle)
+{
+       struct dock_dependent_device *dd;
+
+       dd = kzalloc(sizeof(*dd), GFP_KERNEL);
+       if (dd) {
+               dd->handle = handle;
+               INIT_LIST_HEAD(&dd->list);
+               INIT_LIST_HEAD(&dd->hotplug_list);
+       }
+       return dd;
+}
+
+/**
+ * add_dock_dependent_device - associate a device with the dock station
+ * @ds: The dock station
+ * @dd: The dependent device
+ *
+ * Add the dependent device to the dock's dependent device list.
+ */
+static void
+add_dock_dependent_device(struct dock_station *ds,
+                         struct dock_dependent_device *dd)
+{
+       spin_lock(&ds->dd_lock);
+       list_add_tail(&dd->list, &ds->dependent_devices);
+       spin_unlock(&ds->dd_lock);
+}
+
+/**
+ * dock_add_hotplug_device - associate a hotplug handler with the dock station
+ * @ds: The dock station
+ * @dd: The dependent device struct
+ *
+ * Add the dependent device to the dock's hotplug device list
+ */
+static void
+dock_add_hotplug_device(struct dock_station *ds,
+                       struct dock_dependent_device *dd)
+{
+       spin_lock(&ds->hp_lock);
+       list_add_tail(&dd->hotplug_list, &ds->hotplug_devices);
+       spin_unlock(&ds->hp_lock);
+}
+
+/**
+ * dock_del_hotplug_device - remove a hotplug handler from the dock station
+ * @ds: The dock station
+ * @dd: the dependent device struct
+ *
+ * Delete the dependent device from the dock's hotplug device list
+ */
+static void
+dock_del_hotplug_device(struct dock_station *ds,
+                       struct dock_dependent_device *dd)
+{
+       spin_lock(&ds->hp_lock);
+       list_del(&dd->hotplug_list);
+       spin_unlock(&ds->hp_lock);
+}
+
+/**
+ * find_dock_dependent_device - get a device dependent on this dock
+ * @ds: the dock station
+ * @handle: the acpi_handle of the device we want
+ *
+ * iterate over the dependent device list for this dock.  If the
+ * dependent device matches the handle, return.
+ */
+static struct dock_dependent_device *
+find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
+{
+       struct dock_dependent_device *dd;
+
+       spin_lock(&ds->dd_lock);
+       list_for_each_entry(dd, &ds->dependent_devices, list) {
+               if (handle == dd->handle) {
+                       spin_unlock(&ds->dd_lock);
+                       return dd;
+               }
+       }
+       spin_unlock(&ds->dd_lock);
+       return NULL;
+}
+
+/*****************************************************************************
+ *                         Dock functions                                    *
+ *****************************************************************************/
+/**
+ * is_dock - see if a device is a dock station
+ * @handle: acpi handle of the device
+ *
+ * If an acpi object has a _DCK method, then it is by definition a dock
+ * station, so return true.
+ */
+static int is_dock(acpi_handle handle)
+{
+       acpi_status status;
+       acpi_handle tmp;
+
+       status = acpi_get_handle(handle, "_DCK", &tmp);
+       if (ACPI_FAILURE(status))
+               return 0;
+       return 1;
+}
+
+/**
+ * is_dock_device - see if a device is on a dock station
+ * @handle: acpi handle of the device
+ *
+ * If this device is either the dock station itself,
+ * or is a device dependent on the dock station, then it
+ * is a dock device
+ */
+int is_dock_device(acpi_handle handle)
+{
+       if (!dock_station)
+               return 0;
+
+       if (is_dock(handle) || find_dock_dependent_device(dock_station, handle))
+               return 1;
+
+       return 0;
+}
+
+EXPORT_SYMBOL_GPL(is_dock_device);
+
+/**
+ * dock_present - see if the dock station is present.
+ * @ds: the dock station
+ *
+ * execute the _STA method.  note that present does not
+ * imply that we are docked.
+ */
+static int dock_present(struct dock_station *ds)
+{
+       unsigned long sta;
+       acpi_status status;
+
+       if (ds) {
+               status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
+               if (ACPI_SUCCESS(status) && sta)
+                       return 1;
+       }
+       return 0;
+}
+
+
+
+/**
+ * dock_create_acpi_device - add new devices to acpi
+ * @handle - handle of the device to add
+ *
+ *  This function will create a new acpi_device for the given
+ *  handle if one does not exist already.  This should cause
+ *  acpi to scan for drivers for the given devices, and call
+ *  matching driver's add routine.
+ *
+ *  Returns a pointer to the acpi_device corresponding to the handle.
+ */
+static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
+{
+       struct acpi_device *device = NULL;
+       struct acpi_device *parent_device;
+       acpi_handle parent;
+       int ret;
+
+       if (acpi_bus_get_device(handle, &device)) {
+               /*
+                * no device created for this object,
+                * so we should create one.
+                */
+               acpi_get_parent(handle, &parent);
+               if (acpi_bus_get_device(parent, &parent_device))
+                       parent_device = NULL;
+
+               ret = acpi_bus_add(&device, parent_device, handle,
+                       ACPI_BUS_TYPE_DEVICE);
+               if (ret) {
+                       pr_debug("error adding bus, %x\n",
+                               -ret);
+                       return NULL;
+               }
+       }
+       return device;
+}
+
+/**
+ * dock_remove_acpi_device - remove the acpi_device struct from acpi
+ * @handle - the handle of the device to remove
+ *
+ *  Tell acpi to remove the acpi_device.  This should cause any loaded
+ *  driver to have it's remove routine called.
+ */
+static void dock_remove_acpi_device(acpi_handle handle)
+{
+       struct acpi_device *device;
+       int ret;
+
+       if (!acpi_bus_get_device(handle, &device)) {
+               ret = acpi_bus_trim(device, 1);
+               if (ret)
+                       pr_debug("error removing bus, %x\n", -ret);
+       }
+}
+
+
+/**
+ * hotplug_dock_devices - insert or remove devices on the dock station
+ * @ds: the dock station
+ * @event: either bus check or eject request
+ *
+ * Some devices on the dock station need to have drivers called
+ * to perform hotplug operations after a dock event has occurred.
+ * Traverse the list of dock devices that have registered a
+ * hotplug handler, and call the handler.
+ */
+static void hotplug_dock_devices(struct dock_station *ds, u32 event)
+{
+       struct dock_dependent_device *dd;
+
+       spin_lock(&ds->hp_lock);
+
+       /*
+        * First call driver specific hotplug functions
+        */
+       list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) {
+               if (dd->handler)
+                       dd->handler(dd->handle, event, dd->context);
+       }
+
+       /*
+        * Now make sure that an acpi_device is created for each
+        * dependent device, or removed if this is an eject request.
+        * This will cause acpi_drivers to be stopped/started if they
+        * exist
+        */
+       list_for_each_entry(dd, &ds->dependent_devices, list) {
+               if (event == ACPI_NOTIFY_EJECT_REQUEST)
+                       dock_remove_acpi_device(dd->handle);
+               else
+                       dock_create_acpi_device(dd->handle);
+       }
+       spin_unlock(&ds->hp_lock);
+}
+
+static void dock_event(struct dock_station *ds, u32 event, int num)
+{
+       struct acpi_device *device;
+
+       device = dock_create_acpi_device(ds->handle);
+       if (device)
+               kobject_uevent(&device->kobj, num);
+}
+
+/**
+ * eject_dock - respond to a dock eject request
+ * @ds: the dock station
+ *
+ * This is called after _DCK is called, to execute the dock station's
+ * _EJ0 method.
+ */
+static void eject_dock(struct dock_station *ds)
+{
+       struct acpi_object_list arg_list;
+       union acpi_object arg;
+       acpi_status status;
+       acpi_handle tmp;
+
+       /* all dock devices should have _EJ0, but check anyway */
+       status = acpi_get_handle(ds->handle, "_EJ0", &tmp);
+       if (ACPI_FAILURE(status)) {
+               pr_debug("No _EJ0 support for dock device\n");
+               return;
+       }
+
+       arg_list.count = 1;
+       arg_list.pointer = &arg;
+       arg.type = ACPI_TYPE_INTEGER;
+       arg.integer.value = 1;
+
+       if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
+                                             &arg_list, NULL)))
+               pr_debug("Failed to evaluate _EJ0!\n");
+}
+
+/**
+ * handle_dock - handle a dock event
+ * @ds: the dock station
+ * @dock: to dock, or undock - that is the question
+ *
+ * Execute the _DCK method in response to an acpi event
+ */
+static void handle_dock(struct dock_station *ds, int dock)
+{
+       acpi_status status;
+       struct acpi_object_list arg_list;
+       union acpi_object arg;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       union acpi_object *obj;
+
+       acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer);
+       obj = name_buffer.pointer;
+
+       printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking");
+
+       /* _DCK method has one argument */
+       arg_list.count = 1;
+       arg_list.pointer = &arg;
+       arg.type = ACPI_TYPE_INTEGER;
+       arg.integer.value = dock;
+       status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
+       if (ACPI_FAILURE(status))
+               pr_debug("%s: failed to execute _DCK\n", obj->string.pointer);
+       kfree(buffer.pointer);
+       kfree(name_buffer.pointer);
+}
+
+static inline void dock(struct dock_station *ds)
+{
+       handle_dock(ds, 1);
+}
+
+static inline void undock(struct dock_station *ds)
+{
+       handle_dock(ds, 0);
+}
+
+static inline void begin_dock(struct dock_station *ds)
+{
+       ds->flags |= DOCK_DOCKING;
+}
+
+static inline void complete_dock(struct dock_station *ds)
+{
+       ds->flags &= ~(DOCK_DOCKING);
+       ds->last_dock_time = jiffies;
+}
+
+/**
+ * dock_in_progress - see if we are in the middle of handling a dock event
+ * @ds: the dock station
+ *
+ * Sometimes while docking, false dock events can be sent to the driver
+ * because good connections aren't made or some other reason.  Ignore these
+ * if we are in the middle of doing something.
+ */
+static int dock_in_progress(struct dock_station *ds)
+{
+       if ((ds->flags & DOCK_DOCKING) ||
+           time_before(jiffies, (ds->last_dock_time + HZ)))
+               return 1;
+       return 0;
+}
+
+/**
+ * register_dock_notifier - add yourself to the dock notifier list
+ * @nb: the callers notifier block
+ *
+ * If a driver wishes to be notified about dock events, they can
+ * use this function to put a notifier block on the dock notifier list.
+ * this notifier call chain will be called after a dock event, but
+ * before hotplugging any new devices.
+ */
+int register_dock_notifier(struct notifier_block *nb)
+{
+       return atomic_notifier_chain_register(&dock_notifier_list, nb);
+}
+
+EXPORT_SYMBOL_GPL(register_dock_notifier);
+
+/**
+ * unregister_dock_notifier - remove yourself from the dock notifier list
+ * @nb: the callers notifier block
+ */
+void unregister_dock_notifier(struct notifier_block *nb)
+{
+       atomic_notifier_chain_unregister(&dock_notifier_list, nb);
+}
+
+EXPORT_SYMBOL_GPL(unregister_dock_notifier);
+
+/**
+ * register_hotplug_dock_device - register a hotplug function
+ * @handle: the handle of the device
+ * @handler: the acpi_notifier_handler to call after docking
+ * @context: device specific data
+ *
+ * If a driver would like to perform a hotplug operation after a dock
+ * event, they can register an acpi_notifiy_handler to be called by
+ * the dock driver after _DCK is executed.
+ */
+int
+register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler,
+                            void *context)
+{
+       struct dock_dependent_device *dd;
+
+       if (!dock_station)
+               return -ENODEV;
+
+       /*
+        * make sure this handle is for a device dependent on the dock,
+        * this would include the dock station itself
+        */
+       dd = find_dock_dependent_device(dock_station, handle);
+       if (dd) {
+               dd->handler = handler;
+               dd->context = context;
+               dock_add_hotplug_device(dock_station, dd);
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
+EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
+
+/**
+ * unregister_hotplug_dock_device - remove yourself from the hotplug list
+ * @handle: the acpi handle of the device
+ */
+void unregister_hotplug_dock_device(acpi_handle handle)
+{
+       struct dock_dependent_device *dd;
+
+       if (!dock_station)
+               return;
+
+       dd = find_dock_dependent_device(dock_station, handle);
+       if (dd)
+               dock_del_hotplug_device(dock_station, dd);
+}
+
+EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
+
+/**
+ * dock_notify - act upon an acpi dock notification
+ * @handle: the dock station handle
+ * @event: the acpi event
+ * @data: our driver data struct
+ *
+ * If we are notified to dock, then check to see if the dock is
+ * present and then dock.  Notify all drivers of the dock event,
+ * and then hotplug and devices that may need hotplugging.  For undock
+ * check to make sure the dock device is still present, then undock
+ * and hotremove all the devices that may need removing.
+ */
+static void dock_notify(acpi_handle handle, u32 event, void *data)
+{
+       struct dock_station *ds = (struct dock_station *)data;
+
+       switch (event) {
+       case ACPI_NOTIFY_BUS_CHECK:
+               if (!dock_in_progress(ds) && dock_present(ds)) {
+                       begin_dock(ds);
+                       dock(ds);
+                       if (!dock_present(ds)) {
+                               printk(KERN_ERR PREFIX "Unable to dock!\n");
+                               break;
+                       }
+                       atomic_notifier_call_chain(&dock_notifier_list,
+                                                  event, NULL);
+                       hotplug_dock_devices(ds, event);
+                       complete_dock(ds);
+                       dock_event(ds, event, DOCK_EVENT);
+               }
+               break;
+       case ACPI_NOTIFY_DEVICE_CHECK:
+       /*
+         * According to acpi spec 3.0a, if a DEVICE_CHECK notification
+         * is sent and _DCK is present, it is assumed to mean an
+         * undock request.  This notify routine will only be called
+         * for objects defining _DCK, so we will fall through to eject
+         * request here.  However, we will pass an eject request through
+        * to the driver who wish to hotplug.
+         */
+       case ACPI_NOTIFY_EJECT_REQUEST:
+               if (!dock_in_progress(ds) && dock_present(ds)) {
+                       /*
+                        * here we need to generate the undock
+                        * event prior to actually doing the undock
+                        * so that the device struct still exists.
+                        */
+                       dock_event(ds, event, UNDOCK_EVENT);
+                       hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST);
+                       undock(ds);
+                       eject_dock(ds);
+                       if (dock_present(ds))
+                               printk(KERN_ERR PREFIX "Unable to undock!\n");
+               }
+               break;
+       default:
+               printk(KERN_ERR PREFIX "Unknown dock event %d\n", event);
+       }
+}
+
+/**
+ * find_dock_devices - find devices on the dock station
+ * @handle: the handle of the device we are examining
+ * @lvl: unused
+ * @context: the dock station private data
+ * @rv: unused
+ *
+ * This function is called by acpi_walk_namespace.  It will
+ * check to see if an object has an _EJD method.  If it does, then it
+ * will see if it is dependent on the dock station.
+ */
+static acpi_status
+find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+       acpi_status status;
+       acpi_handle tmp;
+       struct dock_station *ds = (struct dock_station *)context;
+       struct dock_dependent_device *dd;
+
+       status = acpi_bus_get_ejd(handle, &tmp);
+       if (ACPI_FAILURE(status))
+               return AE_OK;
+
+       if (tmp == ds->handle) {
+               dd = alloc_dock_dependent_device(handle);
+               if (dd)
+                       add_dock_dependent_device(ds, dd);
+       }
+
+       return AE_OK;
+}
+
+/**
+ * dock_add - add a new dock station
+ * @handle: the dock station handle
+ *
+ * allocated and initialize a new dock station device.  Find all devices
+ * that are on the dock station, and register for dock event notifications.
+ */
+static int dock_add(acpi_handle handle)
+{
+       int ret;
+       acpi_status status;
+       struct dock_dependent_device *dd;
+
+       /* allocate & initialize the dock_station private data */
+       dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
+       if (!dock_station)
+               return -ENOMEM;
+       dock_station->handle = handle;
+       dock_station->last_dock_time = jiffies - HZ;
+       INIT_LIST_HEAD(&dock_station->dependent_devices);
+       INIT_LIST_HEAD(&dock_station->hotplug_devices);
+       spin_lock_init(&dock_station->dd_lock);
+       spin_lock_init(&dock_station->hp_lock);
+
+       /* Find dependent devices */
+       acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+                           ACPI_UINT32_MAX, find_dock_devices, dock_station,
+                           NULL);
+
+       /* add the dock station as a device dependent on itself */
+       dd = alloc_dock_dependent_device(handle);
+       if (!dd) {
+               kfree(dock_station);
+               return -ENOMEM;
+       }
+       add_dock_dependent_device(dock_station, dd);
+
+       /* register for dock events */
+       status = acpi_install_notify_handler(dock_station->handle,
+                                            ACPI_SYSTEM_NOTIFY,
+                                            dock_notify, dock_station);
+
+       if (ACPI_FAILURE(status)) {
+               printk(KERN_ERR PREFIX "Error installing notify handler\n");
+               ret = -ENODEV;
+               goto dock_add_err;
+       }
+
+       printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME);
+
+       return 0;
+
+dock_add_err:
+       kfree(dock_station);
+       kfree(dd);
+       return ret;
+}
+
+/**
+ * dock_remove - free up resources related to the dock station
+ */
+static int dock_remove(void)
+{
+       struct dock_dependent_device *dd, *tmp;
+       acpi_status status;
+
+       if (!dock_station)
+               return 0;
+
+       /* remove dependent devices */
+       list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices,
+                                list)
+           kfree(dd);
+
+       /* remove dock notify handler */
+       status = acpi_remove_notify_handler(dock_station->handle,
+                                           ACPI_SYSTEM_NOTIFY,
+                                           dock_notify);
+       if (ACPI_FAILURE(status))
+               printk(KERN_ERR "Error removing notify handler\n");
+
+       /* free dock station memory */
+       kfree(dock_station);
+       return 0;
+}
+
+/**
+ * find_dock - look for a dock station
+ * @handle: acpi handle of a device
+ * @lvl: unused
+ * @context: counter of dock stations found
+ * @rv: unused
+ *
+ * This is called by acpi_walk_namespace to look for dock stations.
+ */
+static acpi_status
+find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+       int *count = (int *)context;
+       acpi_status status = AE_OK;
+
+       if (is_dock(handle)) {
+               if (dock_add(handle) >= 0) {
+                       (*count)++;
+                       status = AE_CTRL_TERMINATE;
+               }
+       }
+       return status;
+}
+
+static int __init dock_init(void)
+{
+       int num = 0;
+
+       dock_station = NULL;
+
+       /* look for a dock station */
+       acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+                           ACPI_UINT32_MAX, find_dock, &num, NULL);
+
+       if (!num)
+               return -ENODEV;
+
+       return 0;
+}
+
+static void __exit dock_exit(void)
+{
+       dock_remove();
+}
+
+postcore_initcall(dock_init);
+module_exit(dock_exit);
index 18b3ea9..8c5d7df 100644 (file)
@@ -207,16 +207,15 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_wait");
 
        ec->intr.expect_event = event;
        smp_mb();
 
        switch (event) {
        case ACPI_EC_EVENT_IBE:
-               if (~acpi_ec_read_status(ec) & event) {
+               if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) {
                        ec->intr.expect_event = 0;
-                       return_VALUE(0);
+                       return 0;
                }
                break;
        default:
@@ -238,16 +237,16 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
        switch (event) {
        case ACPI_EC_EVENT_OBF:
                if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
-                       return_VALUE(0);
+                       return 0;
                break;
 
        case ACPI_EC_EVENT_IBE:
                if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
-                       return_VALUE(0);
+                       return 0;
                break;
        }
 
-       return_VALUE(-ETIME);
+       return -ETIME;
 }
 
 #ifdef ACPI_FUTURE_USAGE
@@ -260,7 +259,6 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec)
        u32 tmp = 0;
        int status = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
 
        status = acpi_ec_read_status(ec);
        if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
@@ -272,22 +270,21 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec)
                status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
                acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
                if (tmp != 0x90) {      /* Burst ACK byte */
-                       return_VALUE(-EINVAL);
+                       return -EINVAL;
                }
        }
 
        atomic_set(&ec->intr.leaving_burst, 0);
-       return_VALUE(0);
+       return 0;
       end:
-       printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n");
-       return_VALUE(-1);
+       ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode");
+       return -1;
 }
 
 int acpi_ec_leave_burst_mode(union acpi_ec *ec)
 {
        int status = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
 
        status = acpi_ec_read_status(ec);
        if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
@@ -298,10 +295,10 @@ int acpi_ec_leave_burst_mode(union acpi_ec *ec)
                acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
        } 
        atomic_set(&ec->intr.leaving_burst, 1);
-       return_VALUE(0);
+       return 0;
 end:
-       printk(KERN_WARNING PREFIX "leave burst_mode:error\n");
-       return_VALUE(-1);
+       ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode");
+       return -1;
 }
 #endif /* ACPI_FUTURE_USAGE */
 
@@ -325,17 +322,16 @@ static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
        int result = 0;
        u32 glk = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_read");
 
        if (!ec || !data)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        *data = 0;
 
        if (ec->common.global_lock) {
                status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        if (down_interruptible(&ec->poll.sem)) {
@@ -365,7 +361,7 @@ end_nosem:
        if (ec->common.global_lock)
                acpi_release_global_lock(glk);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
@@ -374,15 +370,14 @@ static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
        acpi_status status = AE_OK;
        u32 glk = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_write");
 
        if (!ec)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (ec->common.global_lock) {
                status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        if (down_interruptible(&ec->poll.sem)) {
@@ -415,7 +410,7 @@ end_nosem:
        if (ec->common.global_lock)
                acpi_release_global_lock(glk);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
@@ -423,17 +418,16 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
        int status = 0;
        u32 glk;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_read");
 
        if (!ec || !data)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        *data = 0;
 
        if (ec->common.global_lock) {
                status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        WARN_ON(in_interrupt());
@@ -467,7 +461,7 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
        if (ec->common.global_lock)
                acpi_release_global_lock(glk);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
@@ -475,15 +469,14 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
        int status = 0;
        u32 glk;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_write");
 
        if (!ec)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (ec->common.global_lock) {
                status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        WARN_ON(in_interrupt());
@@ -516,7 +509,7 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
        if (ec->common.global_lock)
                acpi_release_global_lock(glk);
 
-       return_VALUE(status);
+       return status;
 }
 
 /*
@@ -574,17 +567,16 @@ static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
        acpi_status status = AE_OK;
        u32 glk = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_query");
 
        if (!ec || !data)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        *data = 0;
 
        if (ec->common.global_lock) {
                status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        /*
@@ -613,23 +605,22 @@ end_nosem:
        if (ec->common.global_lock)
                acpi_release_global_lock(glk);
 
-       return_VALUE(result);
+       return result;
 }
 static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
 {
        int status = 0;
        u32 glk;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_query");
 
        if (!ec || !data)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
        *data = 0;
 
        if (ec->common.global_lock) {
                status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
                if (ACPI_FAILURE(status))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        down(&ec->intr.sem);
@@ -662,7 +653,7 @@ static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
        if (ec->common.global_lock)
                acpi_release_global_lock(glk);
 
-       return_VALUE(status);
+       return status;
 }
 
 /* --------------------------------------------------------------------------
@@ -691,13 +682,12 @@ static void acpi_ec_gpe_poll_query(void *ec_cxt)
                '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
        };
 
-       ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
 
        if (!ec_cxt)
                goto end;
 
        if (down_interruptible (&ec->poll.sem)) {
-               return_VOID;
+               return;
        }
        acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
        up(&ec->poll.sem);
@@ -734,7 +724,6 @@ static void acpi_ec_gpe_intr_query(void *ec_cxt)
                '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
        };
 
-       ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
 
        if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
                result = acpi_ec_query(ec, &value);
@@ -793,12 +782,15 @@ static u32 acpi_ec_gpe_intr_handler(void *data)
        case ACPI_EC_EVENT_OBF:
                if (!(value & ACPI_EC_FLAG_OBF))
                        break;
+               ec->intr.expect_event = 0;
+               wake_up(&ec->intr.wait);
+               break;
        case ACPI_EC_EVENT_IBE:
                if ((value & ACPI_EC_FLAG_IBF))
                        break;
                ec->intr.expect_event = 0;
                wake_up(&ec->intr.wait);
-               return ACPI_INTERRUPT_HANDLED;
+               break;
        default:
                break;
        }
@@ -846,15 +838,14 @@ acpi_ec_space_handler(u32 function,
        acpi_integer f_v = 0;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
 
        if ((address > 0xFF) || !value || !handler_context)
-               return_VALUE(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        if (bit_width != 8 && acpi_strict) {
                printk(KERN_WARNING PREFIX
                       "acpi_ec_space_handler: bit_width should be 8\n");
-               return_VALUE(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
        }
 
        ec = (union acpi_ec *)handler_context;
@@ -893,16 +884,16 @@ acpi_ec_space_handler(u32 function,
       out:
        switch (result) {
        case -EINVAL:
-               return_VALUE(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
                break;
        case -ENODEV:
-               return_VALUE(AE_NOT_FOUND);
+               return AE_NOT_FOUND;
                break;
        case -ETIME:
-               return_VALUE(AE_TIME);
+               return AE_TIME;
                break;
        default:
-               return_VALUE(AE_OK);
+               return AE_OK;
        }
 }
 
@@ -916,7 +907,6 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
 {
        union acpi_ec *ec = (union acpi_ec *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_read_info");
 
        if (!ec)
                goto end;
@@ -931,7 +921,7 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
        acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
@@ -951,33 +941,29 @@ static int acpi_ec_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_ec_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_EC_FILE_INFO));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_ec_info_ops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_ec_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
@@ -985,7 +971,7 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -998,14 +984,13 @@ static int acpi_ec_poll_add(struct acpi_device *device)
        acpi_status status = AE_OK;
        union acpi_ec *ec = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
        if (!ec)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(ec, 0, sizeof(union acpi_ec));
 
        ec->common.handle = device->handle;
@@ -1038,8 +1023,7 @@ static int acpi_ec_poll_add(struct acpi_device *device)
            acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
                                  &ec->common.gpe_bit);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error obtaining GPE bit assignment\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit"));
                result = -ENODEV;
                goto end;
        }
@@ -1059,7 +1043,7 @@ static int acpi_ec_poll_add(struct acpi_device *device)
        if (result)
                kfree(ec);
 
-       return_VALUE(result);
+       return result;
 }
 static int acpi_ec_intr_add(struct acpi_device *device)
 {
@@ -1067,14 +1051,13 @@ static int acpi_ec_intr_add(struct acpi_device *device)
        acpi_status status = AE_OK;
        union acpi_ec *ec = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
        if (!ec)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(ec, 0, sizeof(union acpi_ec));
 
        ec->common.handle = device->handle;
@@ -1110,8 +1093,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
            acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
                                  &ec->common.gpe_bit);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error obtaining GPE bit assignment\n"));
+               printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n");
                result = -ENODEV;
                goto end;
        }
@@ -1131,17 +1113,16 @@ static int acpi_ec_intr_add(struct acpi_device *device)
        if (result)
                kfree(ec);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_ec_remove(struct acpi_device *device, int type)
 {
        union acpi_ec *ec = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_remove");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ec = acpi_driver_data(device);
 
@@ -1149,7 +1130,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
 
        kfree(ec);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static acpi_status
@@ -1188,15 +1169,14 @@ static int acpi_ec_start(struct acpi_device *device)
        acpi_status status = AE_OK;
        union acpi_ec *ec = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_start");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ec = acpi_driver_data(device);
 
        if (!ec)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /*
         * Get I/O port addresses. Convert to GAS format.
@@ -1205,9 +1185,8 @@ static int acpi_ec_start(struct acpi_device *device)
                                     acpi_ec_io_ports, ec);
        if (ACPI_FAILURE(status)
            || ec->common.command_addr.register_bit_width == 0) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error getting I/O port addresses"));
-               return_VALUE(-ENODEV);
+               printk(KERN_ERR PREFIX "Error getting I/O port addresses\n");
+               return -ENODEV;
        }
 
        ec->common.status_addr = ec->common.command_addr;
@@ -1224,7 +1203,7 @@ static int acpi_ec_start(struct acpi_device *device)
                                          ACPI_GPE_EDGE_TRIGGERED,
                                          &acpi_ec_gpe_handler, ec);
        if (ACPI_FAILURE(status)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
        acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
        acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
@@ -1236,10 +1215,10 @@ static int acpi_ec_start(struct acpi_device *device)
        if (ACPI_FAILURE(status)) {
                acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
                                        &acpi_ec_gpe_handler);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(AE_OK);
+       return AE_OK;
 }
 
 static int acpi_ec_stop(struct acpi_device *device, int type)
@@ -1247,10 +1226,9 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
        acpi_status status = AE_OK;
        union acpi_ec *ec = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_stop");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        ec = acpi_driver_data(device);
 
@@ -1258,15 +1236,15 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
                                                   ACPI_ADR_SPACE_EC,
                                                   &acpi_ec_space_handler);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        status =
            acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
                                    &acpi_ec_gpe_handler);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static acpi_status __init
@@ -1536,23 +1514,22 @@ static int __init acpi_ec_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_ec_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
        acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
        if (!acpi_ec_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /* Now register the driver for the EC */
        result = acpi_bus_register_driver(&acpi_ec_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 subsys_initcall(acpi_ec_init);
@@ -1561,13 +1538,12 @@ subsys_initcall(acpi_ec_init);
 #if 0
 static void __exit acpi_ec_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_ec_exit");
 
        acpi_bus_unregister_driver(&acpi_ec_driver);
 
        remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 #endif                         /* 0 */
 
index 2dbb1b0..a901b23 100644 (file)
@@ -48,18 +48,17 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
        static int chars_remaining = 0;
        static char *ptr;
 
-       ACPI_FUNCTION_TRACE("acpi_system_read_event");
 
        if (!chars_remaining) {
                memset(&event, 0, sizeof(struct acpi_bus_event));
 
                if ((file->f_flags & O_NONBLOCK)
                    && (list_empty(&acpi_bus_event_list)))
-                       return_VALUE(-EAGAIN);
+                       return -EAGAIN;
 
                result = acpi_bus_receive_event(&event);
                if (result)
-                       return_VALUE(result);
+                       return result;
 
                chars_remaining = sprintf(str, "%s %s %08x %08x\n",
                                          event.device_class ? event.
@@ -75,13 +74,13 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
        }
 
        if (copy_to_user(buffer, ptr, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        *ppos += count;
        chars_remaining -= count;
        ptr += count;
 
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_system_close_event(struct inode *inode, struct file *file)
@@ -112,22 +111,18 @@ static int __init acpi_event_init(void)
        struct proc_dir_entry *entry;
        int error = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_event_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
        /* 'event' [R] */
        entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
        if (entry)
                entry->proc_fops = &acpi_system_event_ops;
        else {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' proc fs entry\n",
-                                 "event"));
-               error = -EFAULT;
+               error = -ENODEV;
        }
-       return_VALUE(error);
+       return error;
 }
 
 subsys_initcall(acpi_event_init);
index f01d339..c76c058 100644 (file)
@@ -382,7 +382,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
        u32 status_reg;
        u32 enable_reg;
        acpi_cpu_flags flags;
-       acpi_cpu_flags hw_flags;
        acpi_native_uint i;
        acpi_native_uint j;
 
@@ -394,8 +393,11 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
                return (int_status);
        }
 
-       /* We need to hold the GPE lock now, hardware lock in the loop */
-
+       /*
+        * We need to obtain the GPE lock for both the data structs and registers
+        * Note: Not necessary to obtain the hardware lock, since the GPE registers
+        * are owned by the gpe_lock.
+        */
        flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
 
        /* Examine all GPE blocks attached to this interrupt level */
@@ -413,8 +415,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
 
                        gpe_register_info = &gpe_block->register_info[i];
 
-                       hw_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
-
                        /* Read the Status Register */
 
                        status =
@@ -423,8 +423,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
                                                   &gpe_register_info->
                                                   status_address);
                        if (ACPI_FAILURE(status)) {
-                               acpi_os_release_lock(acpi_gbl_hardware_lock,
-                                                    hw_flags);
                                goto unlock_and_exit;
                        }
 
@@ -435,8 +433,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
                                                   &enable_reg,
                                                   &gpe_register_info->
                                                   enable_address);
-                       acpi_os_release_lock(acpi_gbl_hardware_lock, hw_flags);
-
                        if (ACPI_FAILURE(status)) {
                                goto unlock_and_exit;
                        }
index 76c34a6..4f948df 100644 (file)
@@ -414,12 +414,13 @@ acpi_remove_notify_handler(acpi_handle device,
 
        if ((!device) ||
            (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               status = AE_BAD_PARAMETER;
+               goto exit;
        }
 
        status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
        if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
+               goto exit;
        }
 
        /* Convert and validate the device handle */
@@ -427,7 +428,7 @@ acpi_remove_notify_handler(acpi_handle device,
        node = acpi_ns_map_handle_to_node(device);
        if (!node) {
                status = AE_BAD_PARAMETER;
-               goto unlock_and_exit;
+               goto unlock;
        }
 
        /* Root Object */
@@ -441,7 +442,7 @@ acpi_remove_notify_handler(acpi_handle device,
                    ((handler_type & ACPI_DEVICE_NOTIFY) &&
                     !acpi_gbl_device_notify.handler)) {
                        status = AE_NOT_EXIST;
-                       goto unlock_and_exit;
+                       goto unlock;
                }
 
                /* Make sure all deferred tasks are completed */
@@ -450,7 +451,7 @@ acpi_remove_notify_handler(acpi_handle device,
                acpi_os_wait_events_complete(NULL);
                status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
                if (ACPI_FAILURE(status)) {
-                       return_ACPI_STATUS(status);
+                       goto exit;
                }
 
                if (handler_type & ACPI_SYSTEM_NOTIFY) {
@@ -473,7 +474,7 @@ acpi_remove_notify_handler(acpi_handle device,
 
                if (!acpi_ev_is_notify_object(node)) {
                        status = AE_TYPE;
-                       goto unlock_and_exit;
+                       goto unlock;
                }
 
                /* Check for an existing internal object */
@@ -481,7 +482,7 @@ acpi_remove_notify_handler(acpi_handle device,
                obj_desc = acpi_ns_get_attached_object(node);
                if (!obj_desc) {
                        status = AE_NOT_EXIST;
-                       goto unlock_and_exit;
+                       goto unlock;
                }
 
                /* Object exists - make sure there's an existing handler */
@@ -491,7 +492,7 @@ acpi_remove_notify_handler(acpi_handle device,
                        if ((!notify_obj) ||
                            (notify_obj->notify.handler != handler)) {
                                status = AE_BAD_PARAMETER;
-                               goto unlock_and_exit;
+                               goto unlock;
                        }
                        /* Make sure all deferred tasks are completed */
 
@@ -499,7 +500,7 @@ acpi_remove_notify_handler(acpi_handle device,
                        acpi_os_wait_events_complete(NULL);
                        status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
                        if (ACPI_FAILURE(status)) {
-                               return_ACPI_STATUS(status);
+                               goto exit;
                        }
 
                        /* Remove the handler */
@@ -512,7 +513,7 @@ acpi_remove_notify_handler(acpi_handle device,
                        if ((!notify_obj) ||
                            (notify_obj->notify.handler != handler)) {
                                status = AE_BAD_PARAMETER;
-                               goto unlock_and_exit;
+                               goto unlock;
                        }
                        /* Make sure all deferred tasks are completed */
 
@@ -520,7 +521,7 @@ acpi_remove_notify_handler(acpi_handle device,
                        acpi_os_wait_events_complete(NULL);
                        status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
                        if (ACPI_FAILURE(status)) {
-                               return_ACPI_STATUS(status);
+                               goto exit;
                        }
 
                        /* Remove the handler */
@@ -529,8 +530,11 @@ acpi_remove_notify_handler(acpi_handle device,
                }
        }
 
-      unlock_and_exit:
+unlock:
        (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+exit:
+       if (ACPI_FAILURE(status))
+               ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler"));
        return_ACPI_STATUS(status);
 }
 
@@ -568,12 +572,13 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
        /* Parameter validation */
 
        if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               status = AE_BAD_PARAMETER;
+               goto exit;
        }
 
        status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
        if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
+               goto exit;
        }
 
        /* Ensure that we have a valid GPE number */
@@ -581,7 +586,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
        gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
        if (!gpe_event_info) {
                status = AE_BAD_PARAMETER;
-               goto unlock_and_exit;
+               goto unlock;
        }
 
        /* Make sure that there isn't a handler there already */
@@ -589,7 +594,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
        if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
            ACPI_GPE_DISPATCH_HANDLER) {
                status = AE_ALREADY_EXISTS;
-               goto unlock_and_exit;
+               goto unlock;
        }
 
        /* Allocate and init handler object */
@@ -597,7 +602,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
        handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info));
        if (!handler) {
                status = AE_NO_MEMORY;
-               goto unlock_and_exit;
+               goto unlock;
        }
 
        handler->address = address;
@@ -608,7 +613,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
 
        status = acpi_ev_disable_gpe(gpe_event_info);
        if (ACPI_FAILURE(status)) {
-               goto unlock_and_exit;
+               goto unlock;
        }
 
        /* Install the handler */
@@ -623,8 +628,12 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
 
        acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
 
-      unlock_and_exit:
+unlock:
        (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
+exit:
+       if (ACPI_FAILURE(status))
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Installing notify handler failed"));
        return_ACPI_STATUS(status);
 }
 
index 8233524..83fed07 100644 (file)
@@ -266,6 +266,10 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
                }
        }
 
+       ACPI_INFO((AE_INFO,
+                  "Dynamic OEM Table Load - [%4.4s] OemId [%6.6s] OemTableId [%8.8s]",
+                  table->signature, table->oem_id, table->oem_table_id));
+
        *return_desc = ddb_handle;
        return_ACPI_STATUS(status);
 }
@@ -446,6 +450,10 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
                return_ACPI_STATUS(status);
        }
 
+       ACPI_INFO((AE_INFO,
+                  "Dynamic SSDT Load - OemId [%6.6s] OemTableId [%8.8s]",
+                  table_ptr->oem_id, table_ptr->oem_table_id));
+
       cleanup:
        if (ACPI_FAILURE(status)) {
                ACPI_FREE(table_ptr);
index 106dc72..34eec82 100644 (file)
@@ -177,7 +177,7 @@ acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
         * that the event is created in an unsignalled state
         */
        status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
-                                         &obj_desc->event.semaphore);
+                                         &obj_desc->event.os_semaphore);
        if (ACPI_FAILURE(status)) {
                goto cleanup;
        }
@@ -226,12 +226,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
                goto cleanup;
        }
 
-       /*
-        * Create the actual OS semaphore.
-        * One unit max to make it a mutex, with one initial unit to allow
-        * the mutex to be acquired.
-        */
-       status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);
+       /* Create the actual OS Mutex */
+
+       status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex);
        if (ACPI_FAILURE(status)) {
                goto cleanup;
        }
@@ -565,7 +562,7 @@ acpi_ex_create_method(u8 * aml_start,
        obj_desc->method.aml_length = aml_length;
 
        /*
-        * Disassemble the method flags.  Split off the Arg Count
+        * Disassemble the method flags. Split off the Arg Count
         * for efficiency
         */
        method_flags = (u8) operand[1]->integer.value;
@@ -576,21 +573,19 @@ acpi_ex_create_method(u8 * aml_start,
            (u8) (method_flags & AML_METHOD_ARG_COUNT);
 
        /*
-        * Get the concurrency count.  If required, a semaphore will be
+        * Get the sync_level. If method is serialized, a mutex will be
         * created for this method when it is parsed.
         */
        if (acpi_gbl_all_methods_serialized) {
-               obj_desc->method.concurrency = 1;
+               obj_desc->method.sync_level = 0;
                obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
        } else if (method_flags & AML_METHOD_SERIALIZED) {
                /*
-                * ACPI 1.0: Concurrency = 1
-                * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1)
+                * ACPI 1.0: sync_level = 0
+                * ACPI 2.0: sync_level = sync_level in method declaration
                 */
-               obj_desc->method.concurrency = (u8)
-                   (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
-       } else {
-               obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;
+               obj_desc->method.sync_level = (u8)
+                   ((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4);
        }
 
        /* Attach the new object to the method Node */
index 7b9718e..2450943 100644 (file)
@@ -118,14 +118,14 @@ static struct acpi_exdump_info acpi_ex_dump_device[4] = {
 
 static struct acpi_exdump_info acpi_ex_dump_event[2] = {
        {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
-       {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"}
+       {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"}
 };
 
 static struct acpi_exdump_info acpi_ex_dump_method[8] = {
        {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
        {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"},
-       {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"},
-       {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"},
+       {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
+       {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"},
        {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
        {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
        {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
@@ -138,7 +138,7 @@ static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
        {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
        {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
         "Acquire Depth"},
-       {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"}
+       {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
 };
 
 static struct acpi_exdump_info acpi_ex_dump_region[7] = {
index 051053f..40f0bee 100644 (file)
@@ -727,11 +727,23 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
                        return_ACPI_STATUS(status);
                }
 
-               /* Merge with previous datum if necessary */
-
-               merged_datum |= raw_datum <<
-                   (obj_desc->common_field.access_bit_width -
-                    obj_desc->common_field.start_field_bit_offset);
+               /*
+                * Merge with previous datum if necessary.
+                *
+                * Note: Before the shift, check if the shift value will be larger than
+                * the integer size. If so, there is no need to perform the operation.
+                * This avoids the differences in behavior between different compilers
+                * concerning shift values larger than the target data width.
+                */
+               if ((obj_desc->common_field.access_bit_width -
+                    obj_desc->common_field.start_field_bit_offset) <
+                   ACPI_INTEGER_BIT_SIZE) {
+                       merged_datum |=
+                           raw_datum << (obj_desc->common_field.
+                                         access_bit_width -
+                                         obj_desc->common_field.
+                                         start_field_bit_offset);
+               }
 
                if (i == datum_count) {
                        break;
@@ -808,13 +820,23 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
                return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
        }
 
-       /* Compute the number of datums (access width data items) */
+       /*
+        * Create the bitmasks used for bit insertion.
+        * Note: This if/else is used to bypass compiler differences with the
+        * shift operator
+        */
+       if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
+               width_mask = ACPI_INTEGER_MAX;
+       } else {
+               width_mask =
+                   ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
+                                        access_bit_width);
+       }
 
-       width_mask =
-           ACPI_MASK_BITS_ABOVE(obj_desc->common_field.access_bit_width);
-       mask =
-           width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field.
-                                             start_field_bit_offset);
+       mask = width_mask &
+           ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
+
+       /* Compute the number of datums (access width data items) */
 
        datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
                                       obj_desc->common_field.access_bit_width);
@@ -848,12 +870,29 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
                        return_ACPI_STATUS(status);
                }
 
-               /* Start new output datum by merging with previous input datum */
-
                field_offset += obj_desc->common_field.access_byte_width;
-               merged_datum = raw_datum >>
-                   (obj_desc->common_field.access_bit_width -
-                    obj_desc->common_field.start_field_bit_offset);
+
+               /*
+                * Start new output datum by merging with previous input datum
+                * if necessary.
+                *
+                * Note: Before the shift, check if the shift value will be larger than
+                * the integer size. If so, there is no need to perform the operation.
+                * This avoids the differences in behavior between different compilers
+                * concerning shift values larger than the target data width.
+                */
+               if ((obj_desc->common_field.access_bit_width -
+                    obj_desc->common_field.start_field_bit_offset) <
+                   ACPI_INTEGER_BIT_SIZE) {
+                       merged_datum =
+                           raw_datum >> (obj_desc->common_field.
+                                         access_bit_width -
+                                         obj_desc->common_field.
+                                         start_field_bit_offset);
+               } else {
+                       merged_datum = 0;
+               }
+
                mask = width_mask;
 
                if (i == datum_count) {
index 93098d6..d8ac287 100644 (file)
@@ -161,12 +161,13 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
 
        /*
         * Current Sync must be less than or equal to the sync level of the
-        * mutex.  This mechanism provides some deadlock prevention
+        * mutex. This mechanism provides some deadlock prevention
         */
        if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
                ACPI_ERROR((AE_INFO,
-                           "Cannot acquire Mutex [%4.4s], incorrect SyncLevel",
-                           acpi_ut_get_node_name(obj_desc->mutex.node)));
+                           "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)",
+                           acpi_ut_get_node_name(obj_desc->mutex.node),
+                           walk_state->thread->current_sync_level));
                return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
        }
 
@@ -178,8 +179,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
 
                if ((obj_desc->mutex.owner_thread->thread_id ==
                     walk_state->thread->thread_id) ||
-                   (obj_desc->mutex.semaphore ==
-                    acpi_gbl_global_lock_semaphore)) {
+                   (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK)) {
                        /*
                         * The mutex is already owned by this thread,
                         * just increment the acquisition depth
@@ -264,7 +264,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
         */
        if ((obj_desc->mutex.owner_thread->thread_id !=
             walk_state->thread->thread_id)
-           && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
+           && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) {
                ACPI_ERROR((AE_INFO,
                            "Thread %X cannot release Mutex [%4.4s] acquired by thread %X",
                            walk_state->thread->thread_id,
index 52beee3..6b5d1e6 100644 (file)
@@ -63,14 +63,14 @@ ACPI_MODULE_NAME("exsystem")
  *              interpreter is released.
  *
  ******************************************************************************/
-acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
+acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
 {
        acpi_status status;
        acpi_status status2;
 
        ACPI_FUNCTION_TRACE(ex_system_wait_semaphore);
 
-       status = acpi_os_wait_semaphore(semaphore, 1, 0);
+       status = acpi_os_wait_semaphore(semaphore, 1, ACPI_DO_NOT_WAIT);
        if (ACPI_SUCCESS(status)) {
                return_ACPI_STATUS(status);
        }
@@ -103,6 +103,59 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_ex_system_wait_mutex
+ *
+ * PARAMETERS:  Mutex           - Mutex to wait on
+ *              Timeout         - Max time to wait
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Implements a semaphore wait with a check to see if the
+ *              semaphore is available immediately.  If it is not, the
+ *              interpreter is released.
+ *
+ ******************************************************************************/
+
+acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)
+{
+       acpi_status status;
+       acpi_status status2;
+
+       ACPI_FUNCTION_TRACE(ex_system_wait_mutex);
+
+       status = acpi_os_acquire_mutex(mutex, ACPI_DO_NOT_WAIT);
+       if (ACPI_SUCCESS(status)) {
+               return_ACPI_STATUS(status);
+       }
+
+       if (status == AE_TIME) {
+
+               /* We must wait, so unlock the interpreter */
+
+               acpi_ex_exit_interpreter();
+
+               status = acpi_os_acquire_mutex(mutex, timeout);
+
+               ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+                                 "*** Thread awake after blocking, %s\n",
+                                 acpi_format_exception(status)));
+
+               /* Reacquire the interpreter */
+
+               status2 = acpi_ex_enter_interpreter();
+               if (ACPI_FAILURE(status2)) {
+
+                       /* Report fatal error, could not acquire interpreter */
+
+                       return_ACPI_STATUS(status2);
+               }
+       }
+
+       return_ACPI_STATUS(status);
+}
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_ex_system_do_stall
  *
  * PARAMETERS:  how_long        - The amount of time to stall,
@@ -176,7 +229,7 @@ acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
  *
  * FUNCTION:    acpi_ex_system_acquire_mutex
  *
- * PARAMETERS:  time_desc       - The 'time to delay' object descriptor
+ * PARAMETERS:  time_desc       - Maximum time to wait for the mutex
  *              obj_desc        - The object descriptor for this op
  *
  * RETURN:      Status
@@ -201,14 +254,14 @@ acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc,
 
        /* Support for the _GL_ Mutex object -- go get the global lock */
 
-       if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
+       if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {
                status =
                    acpi_ev_acquire_global_lock((u16) time_desc->integer.value);
                return_ACPI_STATUS(status);
        }
 
-       status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore,
-                                              (u16) time_desc->integer.value);
+       status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,
+                                          (u16) time_desc->integer.value);
        return_ACPI_STATUS(status);
 }
 
@@ -239,13 +292,13 @@ acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc)
 
        /* Support for the _GL_ Mutex object -- release the global lock */
 
-       if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
+       if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {
                status = acpi_ev_release_global_lock();
                return_ACPI_STATUS(status);
        }
 
-       status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1);
-       return_ACPI_STATUS(status);
+       acpi_os_release_mutex(obj_desc->mutex.os_mutex);
+       return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
@@ -268,7 +321,8 @@ acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc)
        ACPI_FUNCTION_TRACE(ex_system_signal_event);
 
        if (obj_desc) {
-               status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1);
+               status =
+                   acpi_os_signal_semaphore(obj_desc->event.os_semaphore, 1);
        }
 
        return_ACPI_STATUS(status);
@@ -299,7 +353,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
 
        if (obj_desc) {
                status =
-                   acpi_ex_system_wait_semaphore(obj_desc->event.semaphore,
+                   acpi_ex_system_wait_semaphore(obj_desc->event.os_semaphore,
                                                  (u16) time_desc->integer.
                                                  value);
        }
@@ -322,7 +376,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
 acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
 {
        acpi_status status = AE_OK;
-       void *temp_semaphore;
+       acpi_semaphore temp_semaphore;
 
        ACPI_FUNCTION_ENTRY();
 
@@ -333,8 +387,8 @@ acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
        status =
            acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
        if (ACPI_SUCCESS(status)) {
-               (void)acpi_os_delete_semaphore(obj_desc->event.semaphore);
-               obj_desc->event.semaphore = temp_semaphore;
+               (void)acpi_os_delete_semaphore(obj_desc->event.os_semaphore);
+               obj_desc->event.os_semaphore = temp_semaphore;
        }
 
        return (status);
index 1cd2578..38acc69 100644 (file)
@@ -78,7 +78,6 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
        struct acpi_fan *fan = seq->private;
        int state = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_fan_read_state");
 
        if (fan) {
                if (acpi_bus_get_power(fan->handle, &state))
@@ -87,7 +86,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
                        seq_printf(seq, "status:                  %s\n",
                                   !state ? "on" : "off");
        }
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
@@ -104,22 +103,21 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
        struct acpi_fan *fan = (struct acpi_fan *)m->private;
        char state_string[12] = { '\0' };
 
-       ACPI_FUNCTION_TRACE("acpi_fan_write_state");
 
        if (!fan || (count > sizeof(state_string) - 1))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(state_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        state_string[count] = '\0';
 
        result = acpi_bus_set_power(fan->handle,
                                    simple_strtoul(state_string, NULL, 0));
        if (result)
-               return_VALUE(result);
+               return result;
 
-       return_VALUE(count);
+       return count;
 }
 
 static struct file_operations acpi_fan_state_ops = {
@@ -135,16 +133,15 @@ static int acpi_fan_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_fan_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
 
@@ -153,21 +150,18 @@ static int acpi_fan_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_FAN_FILE_STATE));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_fan_state_ops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_fan_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
@@ -175,7 +169,7 @@ static int acpi_fan_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -188,14 +182,13 @@ static int acpi_fan_add(struct acpi_device *device)
        struct acpi_fan *fan = NULL;
        int state = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_fan_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL);
        if (!fan)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(fan, 0, sizeof(struct acpi_fan));
 
        fan->handle = device->handle;
@@ -205,8 +198,7 @@ static int acpi_fan_add(struct acpi_device *device)
 
        result = acpi_bus_get_power(fan->handle, &state);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error reading power state\n"));
+               printk(KERN_ERR PREFIX "Reading power state\n");
                goto end;
        }
 
@@ -226,17 +218,16 @@ static int acpi_fan_add(struct acpi_device *device)
        if (result)
                kfree(fan);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_fan_remove(struct acpi_device *device, int type)
 {
        struct acpi_fan *fan = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_fan_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        fan = (struct acpi_fan *)acpi_driver_data(device);
 
@@ -244,7 +235,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
 
        kfree(fan);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_fan_suspend(struct acpi_device *device, int state)
@@ -283,31 +274,29 @@ static int __init acpi_fan_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_fan_init");
 
        acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
        if (!acpi_fan_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_fan_dir->owner = THIS_MODULE;
 
        result = acpi_bus_register_driver(&acpi_fan_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_fan_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_fan_exit");
 
        acpi_bus_unregister_driver(&acpi_fan_driver);
 
        remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_fan_init);
index ae142de..3143f36 100644 (file)
@@ -172,9 +172,9 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
        }
 
        /*
-        * The package must have at least two elements.  NOTE (March 2005): This
+        * The package must have at least two elements. NOTE (March 2005): This
         * goes against the current ACPI spec which defines this object as a
-        * package with one encoded DWORD element.  However, existing practice
+        * package with one encoded DWORD element. However, existing practice
         * by BIOS vendors seems to be to have 2 or more elements, at least
         * one per sleep type (A/B).
         */
@@ -255,7 +255,7 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
  *              return_value    - Value that was read from the register
  *              Flags           - Lock the hardware or not
  *
- * RETURN:      Status and the value read from specified Register.  Value
+ * RETURN:      Status and the value read from specified Register. Value
  *              returned is normalized to bit0 (is shifted all the way right)
  *
  * DESCRIPTION: ACPI bit_register read function.
@@ -361,8 +361,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
        case ACPI_REGISTER_PM1_STATUS:
 
                /*
-                * Status Registers are different from the rest.  Clear by
-                * writing 1, and writing 0 has no effect.  So, the only relevant
+                * Status Registers are different from the rest. Clear by
+                * writing 1, and writing 0 has no effect. So, the only relevant
                 * information is the single bit we're interested in, all others should
                 * be written as 0 so they will be left unchanged.
                 */
@@ -467,14 +467,13 @@ ACPI_EXPORT_SYMBOL(acpi_set_register)
  *
  * FUNCTION:    acpi_hw_register_read
  *
- * PARAMETERS:  use_lock            - Mutex hw access
- *              register_id         - register_iD + Offset
+ * PARAMETERS:  use_lock            - Lock hardware? True/False
+ *              register_id         - ACPI Register ID
  *              return_value        - Where the register value is returned
  *
  * RETURN:      Status and the value read.
  *
- * DESCRIPTION: Acpi register read function.  Registers are read at the
- *              given offset.
+ * DESCRIPTION: Read from the specified ACPI register
  *
  ******************************************************************************/
 acpi_status
@@ -580,14 +579,26 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
  *
  * FUNCTION:    acpi_hw_register_write
  *
- * PARAMETERS:  use_lock            - Mutex hw access
- *              register_id         - register_iD + Offset
+ * PARAMETERS:  use_lock            - Lock hardware? True/False
+ *              register_id         - ACPI Register ID
  *              Value               - The value to write
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Acpi register Write function.  Registers are written at the
- *              given offset.
+ * DESCRIPTION: Write to the specified ACPI register
+ *
+ * NOTE: In accordance with the ACPI specification, this function automatically
+ * preserves the value of the following bits, meaning that these bits cannot be
+ * changed via this interface:
+ *
+ * PM1_CONTROL[0] = SCI_EN
+ * PM1_CONTROL[9]
+ * PM1_STATUS[11]
+ *
+ * ACPI References:
+ * 1) Hardware Ignored Bits: When software writes to a register with ignored
+ *      bit fields, it preserves the ignored bit fields
+ * 2) SCI_EN: OSPM always preserves this bit position
  *
  ******************************************************************************/
 
@@ -595,6 +606,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
 {
        acpi_status status;
        acpi_cpu_flags lock_flags = 0;
+       u32 read_value;
 
        ACPI_FUNCTION_TRACE(hw_register_write);
 
@@ -605,6 +617,22 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
        switch (register_id) {
        case ACPI_REGISTER_PM1_STATUS:  /* 16-bit access */
 
+               /* Perform a read first to preserve certain bits (per ACPI spec) */
+
+               status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
+                                              ACPI_REGISTER_PM1_STATUS,
+                                              &read_value);
+               if (ACPI_FAILURE(status)) {
+                       goto unlock_and_exit;
+               }
+
+               /* Insert the bits to be preserved */
+
+               ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
+                                read_value);
+
+               /* Now we can write the data */
+
                status =
                    acpi_hw_low_level_write(16, value,
                                            &acpi_gbl_FADT->xpm1a_evt_blk);
@@ -635,6 +663,25 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
 
        case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
 
+               /*
+                * Perform a read first to preserve certain bits (per ACPI spec)
+                *
+                * Note: This includes SCI_EN, we never want to change this bit
+                */
+               status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
+                                              ACPI_REGISTER_PM1_CONTROL,
+                                              &read_value);
+               if (ACPI_FAILURE(status)) {
+                       goto unlock_and_exit;
+               }
+
+               /* Insert the bits to be preserved */
+
+               ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
+                                read_value);
+
+               /* Now we can write the data */
+
                status =
                    acpi_hw_low_level_write(16, value,
                                            &acpi_gbl_FADT->xpm1a_cnt_blk);
@@ -726,7 +773,7 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
                return (AE_OK);
        }
 
-       /* Get a local copy of the address.  Handles possible alignment issues */
+       /* Get a local copy of the address. Handles possible alignment issues */
 
        ACPI_MOVE_64_TO_64(&address, &reg->address);
        if (!address) {
@@ -798,7 +845,7 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
                return (AE_OK);
        }
 
-       /* Get a local copy of the address.  Handles possible alignment issues */
+       /* Get a local copy of the address. Handles possible alignment issues */
 
        ACPI_MOVE_64_TO_64(&address, &reg->address);
        if (!address) {
index c25b2b9..fd81a0f 100644 (file)
@@ -231,11 +231,10 @@ struct list_head hotkey_entries;  /* head of the list of hotkey_list */
 
 static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
 {
-       ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
 
        seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int hotkey_info_open_fs(struct inode *inode, struct file *file)
@@ -266,7 +265,6 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
            (struct acpi_polling_hotkey *)seq->private;
        char *buf;
 
-       ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
 
        if (poll_hotkey->poll_result) {
                buf = format_result(poll_hotkey->poll_result);
@@ -274,7 +272,7 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
                        seq_printf(seq, "%s", buf);
                kfree(buf);
        }
-       return_VALUE(0);
+       return 0;
 }
 
 static int hotkey_polling_open_fs(struct inode *inode, struct file *file)
@@ -293,7 +291,6 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
        struct list_head *entries;
        int val = -1;
 
-       ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
 
        list_for_each(entries, list->entries) {
                union acpi_hotkey *key =
@@ -305,7 +302,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
                }
        }
 
-       return_VALUE(val);
+       return val;
 }
 
 static void
@@ -314,15 +311,14 @@ acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
        struct acpi_device *device = NULL;
        u32 internal_event;
 
-       ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler");
 
        if (acpi_bus_get_device(handle, &device))
-               return_VOID;
+               return;
 
        internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
        acpi_bus_generate_event(device, internal_event, 0);
 
-       return_VOID;
+       return;
 }
 
 /* Need to invent automatically hotkey add method */
@@ -346,7 +342,6 @@ static int create_polling_proc(union acpi_hotkey *device)
        char proc_name[80];
        mode_t mode;
 
-       ACPI_FUNCTION_TRACE("create_polling_proc");
        mode = S_IFREG | S_IRUGO | S_IWUGO;
 
        sprintf(proc_name, "%d", device->link.hotkey_standard_num);
@@ -356,10 +351,7 @@ static int create_polling_proc(union acpi_hotkey *device)
        proc = create_proc_entry(proc_name, mode, hotkey_proc_dir);
 
        if (!proc) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Hotkey: Unable to create %s entry\n",
-                                 device->poll_hotkey.poll_method));
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        } else {
                proc->proc_fops = &hotkey_polling_fops;
                proc->owner = THIS_MODULE;
@@ -368,7 +360,7 @@ static int create_polling_proc(union acpi_hotkey *device)
                proc->gid = 0;
                device->poll_hotkey.proc = proc;
        }
-       return_VALUE(0);
+       return 0;
 }
 
 static int hotkey_add(union acpi_hotkey *device)
@@ -376,7 +368,6 @@ static int hotkey_add(union acpi_hotkey *device)
        int status = 0;
        struct acpi_device *dev = NULL;
 
-       ACPI_FUNCTION_TRACE("hotkey_add");
 
        if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
                acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
@@ -391,14 +382,13 @@ static int hotkey_add(union acpi_hotkey *device)
 
        list_add_tail(&device->link.entries, global_hotkey_list.entries);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int hotkey_remove(union acpi_hotkey *device)
 {
        struct list_head *entries, *next;
 
-       ACPI_FUNCTION_TRACE("hotkey_remove");
 
        list_for_each_safe(entries, next, global_hotkey_list.entries) {
                union acpi_hotkey *key =
@@ -412,14 +402,13 @@ static int hotkey_remove(union acpi_hotkey *device)
                }
        }
        kfree(device);
-       return_VALUE(0);
+       return 0;
 }
 
 static int hotkey_update(union acpi_hotkey *key)
 {
        struct list_head *entries;
 
-       ACPI_FUNCTION_TRACE("hotkey_update");
 
        list_for_each(entries, global_hotkey_list.entries) {
                union acpi_hotkey *tmp =
@@ -461,19 +450,18 @@ static int hotkey_update(union acpi_hotkey *key)
                                 */
                                kfree(key);
                        }
-                       return_VALUE(0);
+                       return 0;
                        break;
                }
        }
 
-       return_VALUE(-ENODEV);
+       return -ENODEV;
 }
 
 static void free_hotkey_device(union acpi_hotkey *key)
 {
        struct acpi_device *dev;
 
-       ACPI_FUNCTION_TRACE("free_hotkey_device");
 
        if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
                acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
@@ -493,7 +481,7 @@ static void free_hotkey_device(union acpi_hotkey *key)
                free_poll_hotkey_buffer(key);
        }
        kfree(key);
-       return_VOID;
+       return;
 }
 
 static void free_hotkey_buffer(union acpi_hotkey *key)
@@ -514,7 +502,6 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
        acpi_handle tmp_handle;
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("init_hotkey_device");
 
        if (std_num < 0 || IS_POLL(std_num) || !key)
                goto do_fail;
@@ -541,9 +528,9 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
                                 method, &tmp_handle);
        if (ACPI_FAILURE(status))
                goto do_fail;
-       return_VALUE(AE_OK);
+       return AE_OK;
       do_fail:
-       return_VALUE(-ENODEV);
+       return -ENODEV;
 }
 
 static int
@@ -555,7 +542,6 @@ init_poll_hotkey_device(union acpi_hotkey *key,
        acpi_status status = AE_OK;
        acpi_handle tmp_handle;
 
-       ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
 
        if (std_num < 0 || IS_EVENT(std_num) || !key)
                goto do_fail;
@@ -590,22 +576,20 @@ init_poll_hotkey_device(union acpi_hotkey *key,
            (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
        if (!key->poll_hotkey.poll_result)
                goto do_fail;
-       return_VALUE(AE_OK);
+       return AE_OK;
       do_fail:
-       return_VALUE(-ENODEV);
+       return -ENODEV;
 }
 
 static int hotkey_open_config(struct inode *inode, struct file *file)
 {
-       ACPI_FUNCTION_TRACE("hotkey_open_config");
-       return_VALUE(single_open
+       return (single_open
                     (file, hotkey_config_seq_show, PDE(inode)->data));
 }
 
 static int hotkey_poll_open_config(struct inode *inode, struct file *file)
 {
-       ACPI_FUNCTION_TRACE("hotkey_poll_open_config");
-       return_VALUE(single_open
+       return (single_open
                     (file, hotkey_poll_config_seq_show, PDE(inode)->data));
 }
 
@@ -618,7 +602,6 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
        struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
        struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
 
-       ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
 
        list_for_each(entries, hotkey_list->entries) {
                union acpi_hotkey *key =
@@ -636,7 +619,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
                }
        }
        seq_puts(seq, "\n");
-       return_VALUE(0);
+       return 0;
 }
 
 static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
@@ -648,7 +631,6 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
        struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
        struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
 
-       ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
 
        list_for_each(entries, hotkey_list->entries) {
                union acpi_hotkey *key =
@@ -666,7 +648,7 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
                }
        }
        seq_puts(seq, "\n");
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -678,7 +660,6 @@ get_parms(char *config_record,
          char **method, int *internal_event_num, int *external_event_num)
 {
        char *tmp, *tmp1, count;
-       ACPI_FUNCTION_TRACE(("get_parms"));
 
        sscanf(config_record, "%d", cmd);
 
@@ -744,9 +725,9 @@ get_parms(char *config_record,
            0)
                goto do_fail;
 
-       return_VALUE(6);
+       return 6;
       do_fail:
-       return_VALUE(-1);
+       return -1;
 }
 
 /*  count is length for one input record */
@@ -763,16 +744,15 @@ static ssize_t hotkey_write_config(struct file *file,
        int ret = 0;
        union acpi_hotkey *key = NULL;
 
-       ACPI_FUNCTION_TRACE(("hotkey_write_config"));
 
        config_record = (char *)kmalloc(count + 1, GFP_KERNEL);
        if (!config_record)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
 
        if (copy_from_user(config_record, buffer, count)) {
                kfree(config_record);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "Invalid data\n");
+               return -EINVAL;
        }
        config_record[count] = 0;
 
@@ -792,9 +772,8 @@ static ssize_t hotkey_write_config(struct file *file,
                kfree(bus_method);
                kfree(action_handle);
                kfree(method);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid data format ret=%d\n", ret));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret);
+               return -EINVAL;
        }
 
        key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
@@ -806,7 +785,7 @@ static ssize_t hotkey_write_config(struct file *file,
                tmp = get_hotkey_by_event(&global_hotkey_list,
                                          internal_event_num);
                if (!tmp)
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key"));
+                       printk(KERN_ERR PREFIX "Invalid key\n");
                else
                        memcpy(key, tmp, sizeof(union acpi_hotkey));
                goto cont_cmd;
@@ -828,8 +807,8 @@ static ssize_t hotkey_write_config(struct file *file,
                else
                        free_poll_hotkey_buffer(key);
                kfree(key);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "Invalid hotkey\n");
+               return -EINVAL;
        }
 
       cont_cmd:
@@ -855,15 +834,15 @@ static ssize_t hotkey_write_config(struct file *file,
                goto fail_out;
                break;
        }
-       return_VALUE(count);
+       return count;
       fail_out:
        if (IS_EVENT(internal_event_num))
                free_hotkey_buffer(key);
        else
                free_poll_hotkey_buffer(key);
        kfree(key);
-       ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n"));
-       return_VALUE(-EINVAL);
+       printk(KERN_ERR PREFIX "invalid key\n");
+       return -EINVAL;
 }
 
 /*
@@ -880,7 +859,6 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
        union acpi_object in_obj;       /* the only param we use */
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("write_acpi_int");
        params.count = 1;
        params.pointer = &in_obj;
        in_obj.type = ACPI_TYPE_INTEGER;
@@ -888,7 +866,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
 
        status = acpi_evaluate_object(handle, (char *)method, &params, output);
 
-       return_VALUE(status == AE_OK);
+       return (status == AE_OK);
 }
 
 static int read_acpi_int(acpi_handle handle, const char *method,
@@ -898,7 +876,6 @@ static int read_acpi_int(acpi_handle handle, const char *method,
        union acpi_object out_obj;
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("read_acpi_int");
        output.length = sizeof(out_obj);
        output.pointer = &out_obj;
 
@@ -907,8 +884,8 @@ static int read_acpi_int(acpi_handle handle, const char *method,
                val->integer.value = out_obj.integer.value;
                val->type = out_obj.type;
        } else
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer"));
-       return_VALUE((status == AE_OK)
+               printk(KERN_ERR PREFIX "null val pointer\n");
+       return ((status == AE_OK)
                     && (out_obj.type == ACPI_TYPE_INTEGER));
 }
 
@@ -945,24 +922,23 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
        int event, method_type, type, value;
        union acpi_hotkey *key;
 
-       ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
 
        arg = (char *)kmalloc(count + 1, GFP_KERNEL);
        if (!arg)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        arg[count] = 0;
 
        if (copy_from_user(arg, buffer, count)) {
                kfree(arg);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "Invalid argument 2\n");
+               return -EINVAL;
        }
 
        if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) !=
            4) {
                kfree(arg);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "Invalid argument 3\n");
+               return -EINVAL;
        }
        kfree(arg);
        if (type == ACPI_TYPE_INTEGER) {
@@ -987,12 +963,12 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
 
                }
        } else {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported"));
-               return_VALUE(-EINVAL);
+               printk(KERN_WARNING "Not supported\n");
+               return -EINVAL;
        }
-       return_VALUE(count);
+       return count;
       do_fail:
-       return_VALUE(-EINVAL);
+       return -EINVAL;
 
 }
 
@@ -1001,7 +977,6 @@ static int __init hotkey_init(void)
        int result;
        mode_t mode = S_IFREG | S_IRUGO | S_IWUGO;
 
-       ACPI_FUNCTION_TRACE("hotkey_init");
 
        if (acpi_disabled)
                return -ENODEV;
@@ -1013,9 +988,6 @@ static int __init hotkey_init(void)
 
        hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir);
        if (!hotkey_proc_dir) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Hotkey: Unable to create %s entry\n",
-                                 HOTKEY_PROC));
                return (-ENODEV);
        }
        hotkey_proc_dir->owner = THIS_MODULE;
@@ -1023,9 +995,6 @@ static int __init hotkey_init(void)
        hotkey_config =
            create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir);
        if (!hotkey_config) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Hotkey: Unable to create %s entry\n",
-                                 HOTKEY_EV_CONFIG));
                goto do_fail1;
        } else {
                hotkey_config->proc_fops = &hotkey_config_fops;
@@ -1038,10 +1007,6 @@ static int __init hotkey_init(void)
        hotkey_poll_config =
            create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir);
        if (!hotkey_poll_config) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Hotkey: Unable to create %s entry\n",
-                                 HOTKEY_EV_CONFIG));
-
                goto do_fail2;
        } else {
                hotkey_poll_config->proc_fops = &hotkey_poll_config_fops;
@@ -1053,9 +1018,6 @@ static int __init hotkey_init(void)
 
        hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir);
        if (!hotkey_action) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Hotkey: Unable to create %s entry\n",
-                                 HOTKEY_ACTION));
                goto do_fail3;
        } else {
                hotkey_action->proc_fops = &hotkey_action_fops;
@@ -1066,9 +1028,6 @@ static int __init hotkey_init(void)
 
        hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir);
        if (!hotkey_info) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Hotkey: Unable to create %s entry\n",
-                                 HOTKEY_INFO));
                goto do_fail4;
        } else {
                hotkey_info->proc_fops = &hotkey_info_fops;
@@ -1104,7 +1063,6 @@ static void __exit hotkey_exit(void)
 {
        struct list_head *entries, *next;
 
-       ACPI_FUNCTION_TRACE("hotkey_exit");
 
        list_for_each_safe(entries, next, global_hotkey_list.entries) {
                union acpi_hotkey *key =
index d51d68f..ec6b7f9 100644 (file)
@@ -52,13 +52,12 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
 {
        struct resource *requested_res = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
 
        if (res->type == ACPI_RESOURCE_TYPE_IO) {
                struct acpi_resource_io *io_res = &res->data.io;
 
                if (io_res->minimum != io_res->maximum)
-                       return_VALUE(AE_OK);
+                       return AE_OK;
                if (IS_RESERVED_ADDR
                    (io_res->minimum, io_res->address_length)) {
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -92,7 +91,7 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
 
        if (requested_res)
                requested_res->flags &= ~IORESOURCE_BUSY;
-       return_VALUE(AE_OK);
+       return AE_OK;
 }
 
 static int acpi_motherboard_add(struct acpi_device *device)
index 48fadad..c1c6c23 100644 (file)
@@ -196,33 +196,30 @@ acpi_status acpi_ns_root_initialize(void)
                                    (u8) (ACPI_TO_INTEGER(val) - 1);
 
                                if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
-                                       /*
-                                        * Create a counting semaphore for the
-                                        * global lock
-                                        */
+
+                                       /* Create a counting semaphore for the global lock */
+
                                        status =
                                            acpi_os_create_semaphore
                                            (ACPI_NO_UNIT_LIMIT, 1,
-                                            &obj_desc->mutex.semaphore);
+                                            &acpi_gbl_global_lock_semaphore);
                                        if (ACPI_FAILURE(status)) {
                                                acpi_ut_remove_reference
                                                    (obj_desc);
                                                goto unlock_and_exit;
                                        }
 
-                                       /*
-                                        * We just created the mutex for the
-                                        * global lock, save it
-                                        */
-                                       acpi_gbl_global_lock_semaphore =
-                                           obj_desc->mutex.semaphore;
+                                       /* Mark this mutex as very special */
+
+                                       obj_desc->mutex.os_mutex =
+                                           ACPI_GLOBAL_LOCK;
                                } else {
                                        /* Create a mutex */
 
-                                       status = acpi_os_create_semaphore(1, 1,
-                                                                         &obj_desc->
-                                                                         mutex.
-                                                                         semaphore);
+                                       status =
+                                           acpi_os_create_mutex(&obj_desc->
+                                                                mutex.
+                                                                os_mutex);
                                        if (ACPI_FAILURE(status)) {
                                                acpi_ut_remove_reference
                                                    (obj_desc);
index 41da26a..5dd2ed1 100644 (file)
@@ -136,6 +136,7 @@ void acpi_os_vprintf(const char *fmt, va_list args)
 #endif
 }
 
+
 extern int acpi_in_resume;
 void *acpi_os_allocate(acpi_size size)
 {
@@ -585,19 +586,18 @@ static void acpi_os_execute_deferred(void *context)
 {
        struct acpi_os_dpc *dpc = NULL;
 
-       ACPI_FUNCTION_TRACE("os_execute_deferred");
 
        dpc = (struct acpi_os_dpc *)context;
        if (!dpc) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-               return_VOID;
+               printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
+               return;
        }
 
        dpc->function(dpc->context);
 
        kfree(dpc);
 
-       return_VOID;
+       return;
 }
 
 static int acpi_os_execute_thread(void *context)
@@ -687,35 +687,19 @@ EXPORT_SYMBOL(acpi_os_wait_events_complete);
 /*
  * Allocate the memory for a spinlock and initialize it.
  */
-acpi_status acpi_os_create_lock(acpi_handle * out_handle)
+acpi_status acpi_os_create_lock(acpi_spinlock * handle)
 {
-       spinlock_t *lock_ptr;
-
-       ACPI_FUNCTION_TRACE("os_create_lock");
-
-       lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
-
-       spin_lock_init(lock_ptr);
-
-       ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
+       spin_lock_init(*handle);
 
-       *out_handle = lock_ptr;
-
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 /*
  * Deallocate the memory for a spinlock.
  */
-void acpi_os_delete_lock(acpi_handle handle)
+void acpi_os_delete_lock(acpi_spinlock handle)
 {
-       ACPI_FUNCTION_TRACE("os_create_lock");
-
-       ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
-
-       acpi_os_free(handle);
-
-       return_VOID;
+       return;
 }
 
 acpi_status
@@ -723,11 +707,10 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
 {
        struct semaphore *sem = NULL;
 
-       ACPI_FUNCTION_TRACE("os_create_semaphore");
 
        sem = acpi_os_allocate(sizeof(struct semaphore));
        if (!sem)
-               return_ACPI_STATUS(AE_NO_MEMORY);
+               return AE_NO_MEMORY;
        memset(sem, 0, sizeof(struct semaphore));
 
        sema_init(sem, initial_units);
@@ -737,7 +720,7 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
        ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
                          *handle, initial_units));
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 EXPORT_SYMBOL(acpi_os_create_semaphore);
@@ -753,17 +736,16 @@ acpi_status acpi_os_delete_semaphore(acpi_handle handle)
 {
        struct semaphore *sem = (struct semaphore *)handle;
 
-       ACPI_FUNCTION_TRACE("os_delete_semaphore");
 
        if (!sem)
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
 
        acpi_os_free(sem);
        sem = NULL;
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 EXPORT_SYMBOL(acpi_os_delete_semaphore);
@@ -783,13 +765,12 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
        struct semaphore *sem = (struct semaphore *)handle;
        int ret = 0;
 
-       ACPI_FUNCTION_TRACE("os_wait_semaphore");
 
        if (!sem || (units < 1))
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        if (units > 1)
-               return_ACPI_STATUS(AE_SUPPORT);
+               return AE_SUPPORT;
 
        ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
                          handle, units, timeout));
@@ -838,17 +819,17 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
        }
 
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Failed to acquire semaphore[%p|%d|%d], %s\n",
+               ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
+                                 "Failed to acquire semaphore[%p|%d|%d], %s",
                                  handle, units, timeout,
                                  acpi_format_exception(status)));
        } else {
                ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
-                                 "Acquired semaphore[%p|%d|%d]\n", handle,
+                                 "Acquired semaphore[%p|%d|%d]", handle,
                                  units, timeout));
        }
 
-       return_ACPI_STATUS(status);
+       return status;
 }
 
 EXPORT_SYMBOL(acpi_os_wait_semaphore);
@@ -860,20 +841,19 @@ acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
 {
        struct semaphore *sem = (struct semaphore *)handle;
 
-       ACPI_FUNCTION_TRACE("os_signal_semaphore");
 
        if (!sem || (units < 1))
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        if (units > 1)
-               return_ACPI_STATUS(AE_SUPPORT);
+               return AE_SUPPORT;
 
        ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
                          units));
 
        up(sem);
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 EXPORT_SYMBOL(acpi_os_signal_semaphore);
@@ -1042,10 +1022,10 @@ EXPORT_SYMBOL(max_cstate);
  * handle is a pointer to the spinlock_t.
  */
 
-acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
+acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
 {
        acpi_cpu_flags flags;
-       spin_lock_irqsave((spinlock_t *) handle, flags);
+       spin_lock_irqsave(lockp, flags);
        return flags;
 }
 
@@ -1053,9 +1033,9 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
  * Release a spinlock. See above.
  */
 
-void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags)
+void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
 {
-       spin_unlock_irqrestore((spinlock_t *) handle, flags);
+       spin_unlock_irqrestore(lockp, flags);
 }
 
 #ifndef ACPI_USE_LOCAL_CACHE
index 7ee2f2e..a02aa62 100644 (file)
@@ -469,6 +469,16 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
        }
 
        walk_state->thread = thread;
+
+       /*
+        * If executing a method, the starting sync_level is this method's
+        * sync_level
+        */
+       if (walk_state->method_desc) {
+               walk_state->thread->current_sync_level =
+                   walk_state->method_desc->method.sync_level;
+       }
+
        acpi_ds_push_walk_state(walk_state, thread);
 
        /*
@@ -505,6 +515,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
                        status =
                            acpi_ds_call_control_method(thread, walk_state,
                                                        NULL);
+                       if (ACPI_FAILURE(status)) {
+                               status =
+                                   acpi_ds_method_error(status, walk_state);
+                       }
 
                        /*
                         * If the transfer to the new method method call worked, a new walk
@@ -525,7 +539,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
                        /* Check for possible multi-thread reentrancy problem */
 
                        if ((status == AE_ALREADY_EXISTS) &&
-                           (!walk_state->method_desc->method.semaphore)) {
+                           (!walk_state->method_desc->method.mutex)) {
                                /*
                                 * Method tried to create an object twice. The probable cause is
                                 * that the method cannot handle reentrancy.
@@ -537,7 +551,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
                                 */
                                walk_state->method_desc->method.method_flags |=
                                    AML_METHOD_SERIALIZED;
-                               walk_state->method_desc->method.concurrency = 1;
+                               walk_state->method_desc->method.sync_level = 0;
                        }
                }
 
index 2a718df..1e2ae6e 100644 (file)
@@ -47,11 +47,10 @@ struct acpi_pci_data {
 static void acpi_pci_data_handler(acpi_handle handle, u32 function,
                                  void *context)
 {
-       ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
 
        /* TBD: Anything we need to do here? */
 
-       return_VOID;
+       return;
 }
 
 /**
@@ -68,25 +67,24 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
        struct acpi_device *device = NULL;
        struct acpi_pci_data *data = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_get_pci_id");
 
        if (!id)
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        result = acpi_bus_get_device(handle, &device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid ACPI Bus context for device %s\n",
-                                 acpi_device_bid(device)));
-               return_ACPI_STATUS(AE_NOT_EXIST);
+               printk(KERN_ERR PREFIX
+                           "Invalid ACPI Bus context for device %s\n",
+                           acpi_device_bid(device));
+               return AE_NOT_EXIST;
        }
 
        status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data);
        if (ACPI_FAILURE(status) || !data) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid ACPI-PCI context for device %s\n",
-                                 acpi_device_bid(device)));
-               return_ACPI_STATUS(status);
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Invalid ACPI-PCI context for device %s",
+                               acpi_device_bid(device)));
+               return status;
        }
 
        *id = data->id;
@@ -103,7 +101,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
                          acpi_device_bid(device), id->segment, id->bus,
                          id->device, id->function));
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 EXPORT_SYMBOL(acpi_get_pci_id);
@@ -120,14 +118,13 @@ int acpi_pci_bind(struct acpi_device *device)
        struct pci_dev *dev;
        struct pci_bus *bus;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_bind");
 
        if (!device || !device->parent)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(pathname, 0, ACPI_PATHNAME_MAX);
        buffer.length = ACPI_PATHNAME_MAX;
        buffer.pointer = pathname;
@@ -135,7 +132,7 @@ int acpi_pci_bind(struct acpi_device *device)
        data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
        if (!data) {
                kfree(pathname);
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        }
        memset(data, 0, sizeof(struct acpi_pci_data));
 
@@ -151,9 +148,9 @@ int acpi_pci_bind(struct acpi_device *device)
        status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
                               (void **)&pdata);
        if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid ACPI-PCI context for parent device %s\n",
-                                 acpi_device_bid(device->parent)));
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Invalid ACPI-PCI context for parent device %s",
+                               acpi_device_bid(device->parent)));
                result = -ENODEV;
                goto end;
        }
@@ -206,10 +203,10 @@ int acpi_pci_bind(struct acpi_device *device)
                goto end;
        }
        if (!data->dev->bus) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
-                                 data->id.segment, data->id.bus,
-                                 data->id.device, data->id.function));
+               printk(KERN_ERR PREFIX
+                           "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
+                           data->id.segment, data->id.bus,
+                           data->id.device, data->id.function);
                result = -ENODEV;
                goto end;
        }
@@ -237,9 +234,9 @@ int acpi_pci_bind(struct acpi_device *device)
         */
        status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to attach ACPI-PCI context to device %s\n",
-                                 acpi_device_bid(device)));
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Unable to attach ACPI-PCI context to device %s",
+                               acpi_device_bid(device)));
                result = -ENODEV;
                goto end;
        }
@@ -269,7 +266,7 @@ int acpi_pci_bind(struct acpi_device *device)
        if (result)
                kfree(data);
 
-       return_VALUE(result);
+       return result;
 }
 
 int acpi_pci_unbind(struct acpi_device *device)
@@ -280,14 +277,13 @@ int acpi_pci_unbind(struct acpi_device *device)
        char *pathname = NULL;
        struct acpi_buffer buffer = { 0, NULL };
 
-       ACPI_FUNCTION_TRACE("acpi_pci_unbind");
 
        if (!device || !device->parent)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(pathname, 0, ACPI_PATHNAME_MAX);
 
        buffer.length = ACPI_PATHNAME_MAX;
@@ -301,18 +297,18 @@ int acpi_pci_unbind(struct acpi_device *device)
            acpi_get_data(device->handle, acpi_pci_data_handler,
                          (void **)&data);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to get data from device %s\n",
-                                 acpi_device_bid(device)));
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Unable to get data from device %s",
+                               acpi_device_bid(device)));
                result = -ENODEV;
                goto end;
        }
 
        status = acpi_detach_data(device->handle, acpi_pci_data_handler);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to detach data from device %s\n",
-                                 acpi_device_bid(device)));
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Unable to detach data from device %s",
+                               acpi_device_bid(device)));
                result = -ENODEV;
                goto end;
        }
@@ -322,7 +318,7 @@ int acpi_pci_unbind(struct acpi_device *device)
        kfree(data);
 
       end:
-       return_VALUE(result);
+       return result;
 }
 
 int
@@ -335,11 +331,10 @@ acpi_pci_bind_root(struct acpi_device *device,
        char *pathname = NULL;
        struct acpi_buffer buffer = { 0, NULL };
 
-       ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
 
        pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(pathname, 0, ACPI_PATHNAME_MAX);
 
        buffer.length = ACPI_PATHNAME_MAX;
@@ -347,13 +342,13 @@ acpi_pci_bind_root(struct acpi_device *device,
 
        if (!device || !id || !bus) {
                kfree(pathname);
-               return_VALUE(-EINVAL);
+               return -EINVAL;
        }
 
        data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
        if (!data) {
                kfree(pathname);
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        }
        memset(data, 0, sizeof(struct acpi_pci_data));
 
@@ -369,9 +364,9 @@ acpi_pci_bind_root(struct acpi_device *device,
 
        status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to attach ACPI-PCI context to device %s\n",
-                                 pathname));
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Unable to attach ACPI-PCI context to device %s",
+                               pathname));
                result = -ENODEV;
                goto end;
        }
@@ -381,5 +376,5 @@ acpi_pci_bind_root(struct acpi_device *device,
        if (result != 0)
                kfree(data);
 
-       return_VALUE(result);
+       return result;
 }
index ed3f226..feda034 100644 (file)
@@ -54,10 +54,9 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
        struct list_head *node = NULL;
        struct acpi_prt_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry");
 
        if (!acpi_prt.count)
-               return_PTR(NULL);
+               return NULL;
 
        /*
         * Parse through all PRT entries looking for a match on the specified
@@ -72,12 +71,12 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
                    && (device == entry->id.device)
                    && (pin == entry->pin)) {
                        spin_unlock(&acpi_prt_lock);
-                       return_PTR(entry);
+                       return entry;
                }
        }
 
        spin_unlock(&acpi_prt_lock);
-       return_PTR(NULL);
+       return NULL;
 }
 
 static int
@@ -86,14 +85,13 @@ acpi_pci_irq_add_entry(acpi_handle handle,
 {
        struct acpi_prt_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry");
 
        if (!prt)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
        if (!entry)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(entry, 0, sizeof(struct acpi_prt_entry));
 
        entry->id.segment = segment;
@@ -140,7 +138,7 @@ acpi_pci_irq_add_entry(acpi_handle handle,
        acpi_prt.count++;
        spin_unlock(&acpi_prt_lock);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void
@@ -162,11 +160,10 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
        struct acpi_pci_routing_table *entry = NULL;
        static int first_time = 1;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt");
 
        pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
        if (!pathname)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(pathname, 0, ACPI_PATHNAME_MAX);
 
        if (first_time) {
@@ -196,24 +193,24 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
        kfree(pathname);
        status = acpi_get_irq_routing_table(handle, &buffer);
        if (status != AE_BUFFER_OVERFLOW) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n",
-                                 acpi_format_exception(status)));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
+                               acpi_format_exception(status)));
+               return -ENODEV;
        }
 
        prt = kmalloc(buffer.length, GFP_KERNEL);
        if (!prt) {
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        }
        memset(prt, 0, buffer.length);
        buffer.pointer = prt;
 
        status = acpi_get_irq_routing_table(handle, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n",
-                                 acpi_format_exception(status)));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
+                               acpi_format_exception(status)));
                kfree(buffer.pointer);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        entry = prt;
@@ -226,7 +223,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
 
        kfree(prt);
 
-       return_VALUE(0);
+       return 0;
 }
 
 void acpi_pci_irq_del_prt(int segment, int bus)
@@ -261,16 +258,15 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
 {
        int irq;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
 
        if (entry->link.handle) {
                irq = acpi_pci_link_allocate_irq(entry->link.handle,
                                                 entry->link.index, triggering,
                                                 polarity, link);
                if (irq < 0) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                         "Invalid IRQ link routing entry\n"));
-                       return_VALUE(-1);
+                       printk(KERN_WARNING PREFIX
+                                     "Invalid IRQ link routing entry\n");
+                       return -1;
                }
        } else {
                irq = entry->link.index;
@@ -279,7 +275,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
-       return_VALUE(irq);
+       return irq;
 }
 
 static int
@@ -288,13 +284,12 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry,
 {
        int irq;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
        if (entry->link.handle) {
                irq = acpi_pci_link_free_irq(entry->link.handle);
        } else {
                irq = entry->link.index;
        }
-       return_VALUE(irq);
+       return irq;
 }
 
 /*
@@ -314,7 +309,6 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
        int bus_nr = bus->number;
        int ret;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "Searching for PRT entry for %02x:%02x:%02x[%c]\n",
@@ -323,11 +317,11 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
        entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
        if (!entry) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
-               return_VALUE(-1);
+               return -1;
        }
 
        ret = func(entry, triggering, polarity, link);
-       return_VALUE(ret);
+       return ret;
 }
 
 /*
@@ -345,10 +339,9 @@ acpi_pci_irq_derive(struct pci_dev *dev,
        int irq = -1;
        u8 bridge_pin = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_derive");
 
        if (!dev)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* 
         * Attempt to derive an IRQ for this device from a parent bridge's
@@ -365,7 +358,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
                                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                                  "No interrupt pin configured for device %s\n",
                                                  pci_name(bridge)));
-                               return_VALUE(-1);
+                               return -1;
                        }
                        /* Pin is from 0 to 3 */
                        bridge_pin--;
@@ -378,16 +371,15 @@ acpi_pci_irq_derive(struct pci_dev *dev,
        }
 
        if (irq < 0) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Unable to derive IRQ for device %s\n",
-                                 pci_name(dev)));
-               return_VALUE(-1);
+               printk(KERN_WARNING PREFIX "Unable to derive IRQ for device %s\n",
+                             pci_name(dev));
+               return -1;
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n",
                          irq, pci_name(dev), pci_name(bridge)));
 
-       return_VALUE(irq);
+       return irq;
 }
 
 /*
@@ -405,24 +397,22 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
        char *link = NULL;
        int rc;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
 
        if (!dev)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        pin = dev->pin;
        if (!pin) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "No interrupt pin configured for device %s\n",
                                  pci_name(dev)));
-               return_VALUE(0);
+               return 0;
        }
        pin--;
 
        if (!dev->bus) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid (NULL) 'bus' field\n"));
-               return_VALUE(-ENODEV);
+               printk(KERN_ERR PREFIX "Invalid (NULL) 'bus' field\n");
+               return -ENODEV;
        }
 
        /* 
@@ -454,10 +444,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
                        printk(" - using IRQ %d\n", dev->irq);
                        acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
                                          ACPI_ACTIVE_LOW);
-                       return_VALUE(0);
+                       return 0;
                } else {
                        printk("\n");
-                       return_VALUE(0);
+                       return 0;
                }
        }
 
@@ -465,7 +455,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
        if (rc < 0) {
                printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
                       "to register GSI\n", pci_name(dev), ('A' + pin));
-               return_VALUE(rc);
+               return rc;
        }
        dev->irq = rc;
 
@@ -479,7 +469,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
               (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
               (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_pci_irq_enable);
@@ -496,14 +486,13 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
        int triggering = ACPI_LEVEL_SENSITIVE;
        int polarity = ACPI_ACTIVE_LOW;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
 
        if (!dev || !dev->bus)
-               return_VOID;
+               return;
 
        pin = dev->pin;
        if (!pin)
-               return_VOID;
+               return;
        pin--;
 
        /*
@@ -521,7 +510,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
                                          &triggering, &polarity, NULL,
                                          acpi_pci_free_irq);
        if (gsi < 0)
-               return_VOID;
+               return;
 
        /*
         * TBD: It might be worth clearing dev->irq by magic constant
@@ -533,5 +522,5 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
 
        acpi_unregister_gsi(gsi);
 
-       return_VOID;
+       return;
 }
index 228bdb6..1badce2 100644 (file)
@@ -107,26 +107,23 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
        struct acpi_pci_link *link = (struct acpi_pci_link *)context;
        u32 i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
 
        switch (resource->type) {
        case ACPI_RESOURCE_TYPE_START_DEPENDENT:
-               return_ACPI_STATUS(AE_OK);
+               return AE_OK;
        case ACPI_RESOURCE_TYPE_IRQ:
                {
                        struct acpi_resource_irq *p = &resource->data.irq;
                        if (!p || !p->interrupt_count) {
-                               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                 "Blank IRQ resource\n"));
-                               return_ACPI_STATUS(AE_OK);
+                               printk(KERN_WARNING PREFIX "Blank IRQ resource\n");
+                               return AE_OK;
                        }
                        for (i = 0;
                             (i < p->interrupt_count
                              && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
                                if (!p->interrupts[i]) {
-                                       ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                         "Invalid IRQ %d\n",
-                                                         p->interrupts[i]));
+                                       printk(KERN_WARNING PREFIX "Invalid IRQ %d\n",
+                                                     p->interrupts[i]);
                                        continue;
                                }
                                link->irq.possible[i] = p->interrupts[i];
@@ -142,17 +139,16 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
                        struct acpi_resource_extended_irq *p =
                            &resource->data.extended_irq;
                        if (!p || !p->interrupt_count) {
-                               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                 "Blank EXT IRQ resource\n"));
-                               return_ACPI_STATUS(AE_OK);
+                               printk(KERN_WARNING PREFIX
+                                             "Blank EXT IRQ resource\n");
+                               return AE_OK;
                        }
                        for (i = 0;
                             (i < p->interrupt_count
                              && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
                                if (!p->interrupts[i]) {
-                                       ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                         "Invalid IRQ %d\n",
-                                                         p->interrupts[i]));
+                                       printk(KERN_WARNING PREFIX "Invalid IRQ %d\n",
+                                                     p->interrupts[i]);
                                        continue;
                                }
                                link->irq.possible[i] = p->interrupts[i];
@@ -164,35 +160,33 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
                        break;
                }
        default:
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Resource is not an IRQ entry\n"));
-               return_ACPI_STATUS(AE_OK);
+               printk(KERN_ERR PREFIX "Resource is not an IRQ entry\n");
+               return AE_OK;
        }
 
-       return_ACPI_STATUS(AE_CTRL_TERMINATE);
+       return AE_CTRL_TERMINATE;
 }
 
 static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
 {
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
 
        if (!link)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
                                     acpi_pci_link_check_possible, link);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS"));
+               return -ENODEV;
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "Found %d possible IRQs\n",
                          link->irq.possible_count));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static acpi_status
@@ -200,7 +194,6 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
 {
        int *irq = (int *)context;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
 
        switch (resource->type) {
        case ACPI_RESOURCE_TYPE_IRQ:
@@ -213,7 +206,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
                                 */
                                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                                  "Blank IRQ resource\n"));
-                               return_ACPI_STATUS(AE_OK);
+                               return AE_OK;
                        }
                        *irq = p->interrupts[0];
                        break;
@@ -227,20 +220,20 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
                                 * extended IRQ descriptors must
                                 * return at least 1 IRQ
                                 */
-                               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                 "Blank EXT IRQ resource\n"));
-                               return_ACPI_STATUS(AE_OK);
+                               printk(KERN_WARNING PREFIX
+                                             "Blank EXT IRQ resource\n");
+                               return AE_OK;
                        }
                        *irq = p->interrupts[0];
                        break;
                }
                break;
        default:
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type));
+               printk(KERN_ERR PREFIX "Resource %d isn't an IRQ\n", resource->type);
        case ACPI_RESOURCE_TYPE_END_TAG:
-               return_ACPI_STATUS(AE_OK);
+               return AE_OK;
        }
-       return_ACPI_STATUS(AE_CTRL_TERMINATE);
+       return AE_CTRL_TERMINATE;
 }
 
 /*
@@ -256,10 +249,9 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
        acpi_status status = AE_OK;
        int irq = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
 
        if (!link || !link->handle)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        link->irq.active = 0;
 
@@ -268,14 +260,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
                /* Query _STA, set link->device->status */
                result = acpi_bus_get_status(link->device);
                if (result) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Unable to read status\n"));
+                       printk(KERN_ERR PREFIX "Unable to read status\n");
                        goto end;
                }
 
                if (!link->device->status.enabled) {
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
-                       return_VALUE(0);
+                       return 0;
                }
        }
 
@@ -286,13 +277,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
        status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
                                     acpi_pci_link_check_current, &irq);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS"));
                result = -ENODEV;
                goto end;
        }
 
        if (acpi_strict && !irq) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n"));
+               printk(KERN_ERR PREFIX "_CRS returned 0\n");
                result = -ENODEV;
        }
 
@@ -301,7 +292,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
 
       end:
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
@@ -314,14 +305,13 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
        } *resource;
        struct acpi_buffer buffer = { 0, NULL };
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_set");
 
        if (!link || !irq)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
        if (!resource)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
 
        memset(resource, 0, sizeof(*resource) + 1);
        buffer.length = sizeof(*resource) + 1;
@@ -362,7 +352,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
                /* ignore resource_source, it's optional */
                break;
        default:
-               printk("ACPI BUG: resource_type %d\n", link->irq.resource_type);
+               printk(KERN_ERR PREFIX "Invalid Resource_type %d\n", link->irq.resource_type);
                result = -EINVAL;
                goto end;
 
@@ -374,7 +364,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
 
        /* check for total failure */
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SRS"));
                result = -ENODEV;
                goto end;
        }
@@ -382,14 +372,14 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
        /* Query _STA, set device->status */
        result = acpi_bus_get_status(link->device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
+               printk(KERN_ERR PREFIX "Unable to read status\n");
                goto end;
        }
        if (!link->device->status.enabled) {
                printk(KERN_WARNING PREFIX
-                      "%s [%s] disabled and referenced, BIOS bug.\n",
-                      acpi_device_name(link->device),
-                      acpi_device_bid(link->device));
+                             "%s [%s] disabled and referenced, BIOS bug\n",
+                             acpi_device_name(link->device),
+                             acpi_device_bid(link->device));
        }
 
        /* Query _CRS, set link->irq.active */
@@ -408,9 +398,9 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
                 * assume _SRS worked and override _CRS value.
                 */
                printk(KERN_WARNING PREFIX
-                      "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
-                      acpi_device_name(link->device),
-                      acpi_device_bid(link->device), link->irq.active, irq);
+                             "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
+                             acpi_device_name(link->device),
+                             acpi_device_bid(link->device), link->irq.active, irq);
                link->irq.active = irq;
        }
 
@@ -418,7 +408,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
 
       end:
        kfree(resource);
-       return_VALUE(result);
+       return result;
 }
 
 /* --------------------------------------------------------------------------
@@ -492,7 +482,6 @@ int __init acpi_irq_penalty_init(void)
        struct acpi_pci_link *link = NULL;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
 
        /*
         * Update penalties to facilitate IRQ balancing.
@@ -501,8 +490,7 @@ int __init acpi_irq_penalty_init(void)
 
                link = list_entry(node, struct acpi_pci_link, node);
                if (!link) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Invalid link context\n"));
+                       printk(KERN_ERR PREFIX "Invalid link context\n");
                        continue;
                }
 
@@ -530,7 +518,7 @@ int __init acpi_irq_penalty_init(void)
        /* Add a penalty for the SCI */
        acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_irq_balance;   /* 0: static, 1: balance */
@@ -540,13 +528,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
        int irq;
        int i;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
 
        if (link->irq.initialized) {
                if (link->refcnt == 0)
                        /* This means the link is disabled but initialized */
                        acpi_pci_link_set(link, link->irq.active);
-               return_VALUE(0);
+               return 0;
        }
 
        /*
@@ -562,7 +549,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
        if (i == link->irq.possible_count) {
                if (acpi_strict)
                        printk(KERN_WARNING PREFIX "_CRS %d not found"
-                              " in _PRS\n", link->irq.active);
+                                     " in _PRS\n", link->irq.active);
                link->irq.active = 0;
        }
 
@@ -589,12 +576,11 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
 
        /* Attempt to enable the link device at this IRQ. */
        if (acpi_pci_link_set(link, irq)) {
-               printk(PREFIX
-                      "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
-                      "Try pci=noacpi or acpi=off\n",
-                      acpi_device_name(link->device),
-                      acpi_device_bid(link->device));
-               return_VALUE(-ENODEV);
+               printk(KERN_ERR PREFIX "Unable to set IRQ for %s [%s]. "
+                           "Try pci=noacpi or acpi=off\n",
+                           acpi_device_name(link->device),
+                           acpi_device_bid(link->device));
+               return -ENODEV;
        } else {
                acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
                printk(PREFIX "%s [%s] enabled at IRQ %d\n",
@@ -604,7 +590,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
 
        link->irq.initialized = 1;
 
-       return_VALUE(0);
+       return 0;
 }
 
 /*
@@ -622,36 +608,35 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
        struct acpi_device *device = NULL;
        struct acpi_pci_link *link = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
 
        result = acpi_bus_get_device(handle, &device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Invalid link device\n");
+               return -1;
        }
 
        link = (struct acpi_pci_link *)acpi_driver_data(device);
        if (!link) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Invalid link context\n");
+               return -1;
        }
 
        /* TBD: Support multiple index (IRQ) entries per Link Device */
        if (index) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Invalid index %d\n", index);
+               return -1;
        }
 
        mutex_lock(&acpi_link_lock);
        if (acpi_pci_link_allocate(link)) {
                mutex_unlock(&acpi_link_lock);
-               return_VALUE(-1);
+               return -1;
        }
 
        if (!link->irq.active) {
                mutex_unlock(&acpi_link_lock);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Link active IRQ is 0!\n");
+               return -1;
        }
        link->refcnt++;
        mutex_unlock(&acpi_link_lock);
@@ -665,7 +650,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "Link %s is referenced\n",
                          acpi_device_bid(link->device)));
-       return_VALUE(link->irq.active);
+       return (link->irq.active);
 }
 
 /*
@@ -678,25 +663,24 @@ int acpi_pci_link_free_irq(acpi_handle handle)
        struct acpi_pci_link *link = NULL;
        acpi_status result;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
 
        result = acpi_bus_get_device(handle, &device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Invalid link device\n");
+               return -1;
        }
 
        link = (struct acpi_pci_link *)acpi_driver_data(device);
        if (!link) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Invalid link context\n");
+               return -1;
        }
 
        mutex_lock(&acpi_link_lock);
        if (!link->irq.initialized) {
                mutex_unlock(&acpi_link_lock);
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n"));
-               return_VALUE(-1);
+               printk(KERN_ERR PREFIX "Link isn't initialized\n");
+               return -1;
        }
 #ifdef FUTURE_USE
        /*
@@ -718,7 +702,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
                acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
        }
        mutex_unlock(&acpi_link_lock);
-       return_VALUE(link->irq.active);
+       return (link->irq.active);
 }
 
 /* --------------------------------------------------------------------------
@@ -732,14 +716,13 @@ static int acpi_pci_link_add(struct acpi_device *device)
        int i = 0;
        int found = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
        if (!link)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(link, 0, sizeof(struct acpi_pci_link));
 
        link->device = device;
@@ -788,17 +771,16 @@ static int acpi_pci_link_add(struct acpi_device *device)
        if (result)
                kfree(link);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_pci_link_resume(struct acpi_pci_link *link)
 {
-       ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
 
        if (link->refcnt && link->irq.active && link->irq.initialized)
-               return_VALUE(acpi_pci_link_set(link, link->irq.active));
+               return (acpi_pci_link_set(link, link->irq.active));
        else
-               return_VALUE(0);
+               return 0;
 }
 
 /*
@@ -811,7 +793,6 @@ static int irqrouter_resume(struct sys_device *dev)
        struct list_head *node = NULL;
        struct acpi_pci_link *link = NULL;
 
-       ACPI_FUNCTION_TRACE("irqrouter_resume");
 
        /* Make sure SCI is enabled again (Apple firmware bug?) */
        acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK);
@@ -820,24 +801,22 @@ static int irqrouter_resume(struct sys_device *dev)
        list_for_each(node, &acpi_link.entries) {
                link = list_entry(node, struct acpi_pci_link, node);
                if (!link) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Invalid link context\n"));
+                       printk(KERN_ERR PREFIX "Invalid link context\n");
                        continue;
                }
                acpi_pci_link_resume(link);
        }
        acpi_in_resume = 0;
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_pci_link_remove(struct acpi_device *device, int type)
 {
        struct acpi_pci_link *link = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        link = (struct acpi_pci_link *)acpi_driver_data(device);
 
@@ -847,7 +826,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type)
 
        kfree(link);
 
-       return_VALUE(0);
+       return 0;
 }
 
 /*
@@ -953,34 +932,32 @@ static int __init irqrouter_init_sysfs(void)
 {
        int error;
 
-       ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
 
        if (acpi_disabled || acpi_noirq)
-               return_VALUE(0);
+               return 0;
 
        error = sysdev_class_register(&irqrouter_sysdev_class);
        if (!error)
                error = sysdev_register(&device_irqrouter);
 
-       return_VALUE(error);
+       return error;
 }
 
 device_initcall(irqrouter_init_sysfs);
 
 static int __init acpi_pci_link_init(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_pci_link_init");
 
        if (acpi_noirq)
-               return_VALUE(0);
+               return 0;
 
        acpi_link.count = 0;
        INIT_LIST_HEAD(&acpi_link.entries);
 
        if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
-       return_VALUE(0);
+       return 0;
 }
 
 subsys_initcall(acpi_pci_link_init);
index 4c313ea..8f10442 100644 (file)
@@ -160,14 +160,13 @@ static int acpi_pci_root_add(struct acpi_device *device)
        unsigned long value = 0;
        acpi_handle handle = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_root_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
        if (!root)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(root, 0, sizeof(struct acpi_pci_root));
        INIT_LIST_HEAD(&root->node);
 
@@ -198,7 +197,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
                root->id.segment = 0;
                break;
        default:
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SEG\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG"));
                result = -ENODEV;
                goto end;
        }
@@ -219,7 +218,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
                root->id.bus = 0;
                break;
        default:
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BBN\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN"));
                result = -ENODEV;
                goto end;
        }
@@ -231,8 +230,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
                        int bus = 0;
                        acpi_status status;
 
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n"));
+                       printk(KERN_ERR PREFIX
+                                   "Wrong _BBN value, reboot"
+                                   " and use option 'pci=noacpi'\n");
 
                        status = try_get_root_bridge_busnr(root->handle, &bus);
                        if (ACPI_FAILURE(status))
@@ -273,9 +273,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
         */
        root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus);
        if (!root->bus) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Bus %04x:%02x not present in PCI namespace\n",
-                                 root->id.segment, root->id.bus));
+               printk(KERN_ERR PREFIX
+                           "Bus %04x:%02x not present in PCI namespace\n",
+                           root->id.segment, root->id.bus);
                result = -ENODEV;
                goto end;
        }
@@ -306,46 +306,43 @@ static int acpi_pci_root_add(struct acpi_device *device)
                kfree(root);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_pci_root_start(struct acpi_device *device)
 {
        struct acpi_pci_root *root;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_root_start");
 
        list_for_each_entry(root, &acpi_pci_roots, node) {
                if (root->handle == device->handle) {
                        pci_bus_add_devices(root->bus);
-                       return_VALUE(0);
+                       return 0;
                }
        }
-       return_VALUE(-ENODEV);
+       return -ENODEV;
 }
 
 static int acpi_pci_root_remove(struct acpi_device *device, int type)
 {
        struct acpi_pci_root *root = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_pci_root_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        root = (struct acpi_pci_root *)acpi_driver_data(device);
 
        kfree(root);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int __init acpi_pci_root_init(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_pci_root_init");
 
        if (acpi_pci_disabled)
-               return_VALUE(0);
+               return 0;
 
        /* DEBUG:
           acpi_dbg_layer = ACPI_PCI_COMPONENT;
@@ -353,9 +350,9 @@ static int __init acpi_pci_root_init(void)
         */
 
        if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
-       return_VALUE(0);
+       return 0;
 }
 
 subsys_initcall(acpi_pci_root_init);
index 62a5595..224f729 100644 (file)
@@ -98,23 +98,21 @@ acpi_power_get_context(acpi_handle handle,
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_power_get_context");
 
        if (!resource)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        result = acpi_bus_get_device(handle, &device);
        if (result) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n",
-                                 handle));
-               return_VALUE(result);
+               printk(KERN_WARNING PREFIX "Getting context [%p]\n", handle);
+               return result;
        }
 
        *resource = (struct acpi_power_resource *)acpi_driver_data(device);
        if (!resource)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_power_get_state(struct acpi_power_resource *resource)
@@ -122,14 +120,13 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
        acpi_status status = AE_OK;
        unsigned long sta = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_power_get_state");
 
        if (!resource)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (sta & 0x01)
                resource->state = ACPI_POWER_RESOURCE_STATE_ON;
@@ -139,7 +136,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
                          resource->name, resource->state ? "on" : "off"));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
@@ -148,20 +145,19 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
        struct acpi_power_resource *resource = NULL;
        u32 i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_power_get_list_state");
 
        if (!list || !state)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* The state of the list is 'on' IFF all resources are 'on'. */
 
        for (i = 0; i < list->count; i++) {
                result = acpi_power_get_context(list->handles[i], &resource);
                if (result)
-                       return_VALUE(result);
+                       return result;
                result = acpi_power_get_state(resource);
                if (result)
-                       return_VALUE(result);
+                       return result;
 
                *state = resource->state;
 
@@ -172,7 +168,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n",
                          *state ? "on" : "off"));
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_power_on(acpi_handle handle)
@@ -182,11 +178,10 @@ static int acpi_power_on(acpi_handle handle)
        struct acpi_device *device = NULL;
        struct acpi_power_resource *resource = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_power_on");
 
        result = acpi_power_get_context(handle, &resource);
        if (result)
-               return_VALUE(result);
+               return result;
 
        resource->references++;
 
@@ -194,29 +189,29 @@ static int acpi_power_on(acpi_handle handle)
            || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n",
                                  resource->name));
-               return_VALUE(0);
+               return 0;
        }
 
        status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        result = acpi_power_get_state(resource);
        if (result)
-               return_VALUE(result);
+               return result;
        if (resource->state != ACPI_POWER_RESOURCE_STATE_ON)
-               return_VALUE(-ENOEXEC);
+               return -ENOEXEC;
 
        /* Update the power resource's _device_ power state */
        result = acpi_bus_get_device(resource->handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
        device->power.state = ACPI_STATE_D0;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
                          resource->name));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_power_off_device(acpi_handle handle)
@@ -226,11 +221,10 @@ static int acpi_power_off_device(acpi_handle handle)
        struct acpi_device *device = NULL;
        struct acpi_power_resource *resource = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_power_off_device");
 
        result = acpi_power_get_context(handle, &resource);
        if (result)
-               return_VALUE(result);
+               return result;
 
        if (resource->references)
                resource->references--;
@@ -239,35 +233,35 @@ static int acpi_power_off_device(acpi_handle handle)
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "Resource [%s] is still in use, dereferencing\n",
                                  device->pnp.bus_id));
-               return_VALUE(0);
+               return 0;
        }
 
        if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
                                  device->pnp.bus_id));
-               return_VALUE(0);
+               return 0;
        }
 
        status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        result = acpi_power_get_state(resource);
        if (result)
-               return_VALUE(result);
+               return result;
        if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF)
-               return_VALUE(-ENOEXEC);
+               return -ENOEXEC;
 
        /* Update the power resource's _device_ power state */
        result = acpi_bus_get_device(resource->handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
        device->power.state = ACPI_STATE_D3;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
                          resource->name));
 
-       return_VALUE(0);
+       return 0;
 }
 
 /*
@@ -283,31 +277,29 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev)
        int i;
        int ret = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power");
        if (!dev || !dev->wakeup.flags.valid)
-               return_VALUE(-1);
+               return -1;
 
        arg.integer.value = 1;
        /* Open power resource */
        for (i = 0; i < dev->wakeup.resources.count; i++) {
                ret = acpi_power_on(dev->wakeup.resources.handles[i]);
                if (ret) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Error transition power state\n"));
+                       printk(KERN_ERR PREFIX "Transition power state\n");
                        dev->wakeup.flags.valid = 0;
-                       return_VALUE(-1);
+                       return -1;
                }
        }
 
        /* Execute PSW */
        status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
        if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n"));
+               printk(KERN_ERR PREFIX "Evaluate _PSW\n");
                dev->wakeup.flags.valid = 0;
                ret = -1;
        }
 
-       return_VALUE(ret);
+       return ret;
 }
 
 /*
@@ -323,32 +315,30 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
        int i;
        int ret = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power");
 
        if (!dev || !dev->wakeup.flags.valid)
-               return_VALUE(-1);
+               return -1;
 
        arg.integer.value = 0;
        /* Execute PSW */
        status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
        if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n"));
+               printk(KERN_ERR PREFIX "Evaluate _PSW\n");
                dev->wakeup.flags.valid = 0;
-               return_VALUE(-1);
+               return -1;
        }
 
        /* Close power resource */
        for (i = 0; i < dev->wakeup.resources.count; i++) {
                ret = acpi_power_off_device(dev->wakeup.resources.handles[i]);
                if (ret) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Error transition power state\n"));
+                       printk(KERN_ERR PREFIX "Transition power state\n");
                        dev->wakeup.flags.valid = 0;
-                       return_VALUE(-1);
+                       return -1;
                }
        }
 
-       return_VALUE(ret);
+       return ret;
 }
 
 /* --------------------------------------------------------------------------
@@ -362,10 +352,9 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
        int list_state = 0;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        device->power.state = ACPI_STATE_UNKNOWN;
 
@@ -380,17 +369,17 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
 
                result = acpi_power_get_list_state(list, &list_state);
                if (result)
-                       return_VALUE(result);
+                       return result;
 
                if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
                        device->power.state = i;
-                       return_VALUE(0);
+                       return 0;
                }
        }
 
        device->power.state = ACPI_STATE_D3;
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_power_transition(struct acpi_device *device, int state)
@@ -400,14 +389,13 @@ int acpi_power_transition(struct acpi_device *device, int state)
        struct acpi_handle_list *tl = NULL;     /* Target Resources */
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_power_transition");
 
        if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if ((device->power.state < ACPI_STATE_D0)
            || (device->power.state > ACPI_STATE_D3))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        cl = &device->power.states[device->power.state].resources;
        tl = &device->power.states[state].resources;
@@ -444,11 +432,10 @@ int acpi_power_transition(struct acpi_device *device, int state)
        device->power.state = state;
       end:
        if (result)
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Error transitioning device [%s] to D%d\n",
-                                 device->pnp.bus_id, state));
+               printk(KERN_WARNING PREFIX "Transitioning device [%s] to D%d\n",
+                             device->pnp.bus_id, state);
 
-       return_VALUE(result);
+       return result;
 }
 
 /* --------------------------------------------------------------------------
@@ -461,7 +448,6 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_power_resource *resource = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_power_seq_show");
 
        resource = (struct acpi_power_resource *)seq->private;
 
@@ -488,7 +474,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
                   resource->order, resource->references);
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_power_open_fs(struct inode *inode, struct file *file)
@@ -500,36 +486,32 @@ static int acpi_power_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_power_add_fs");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_power_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
 
        /* 'status' [R] */
        entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_POWER_FILE_STATUS));
+               return -EIO;
        else {
                entry->proc_fops = &acpi_power_fops;
                entry->data = acpi_driver_data(device);
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_power_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_POWER_FILE_STATUS,
@@ -538,7 +520,7 @@ static int acpi_power_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -553,14 +535,13 @@ static int acpi_power_add(struct acpi_device *device)
        union acpi_object acpi_object;
        struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
 
-       ACPI_FUNCTION_TRACE("acpi_power_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
        if (!resource)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(resource, 0, sizeof(struct acpi_power_resource));
 
        resource->handle = device->handle;
@@ -605,17 +586,16 @@ static int acpi_power_add(struct acpi_device *device)
        if (result)
                kfree(resource);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_power_remove(struct acpi_device *device, int type)
 {
        struct acpi_power_resource *resource = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_power_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        resource = (struct acpi_power_resource *)acpi_driver_data(device);
 
@@ -623,31 +603,30 @@ static int acpi_power_remove(struct acpi_device *device, int type)
 
        kfree(resource);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int __init acpi_power_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_power_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
        INIT_LIST_HEAD(&acpi_power_resource_list);
 
        acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
        if (!acpi_power_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        result = acpi_bus_register_driver(&acpi_power_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 subsys_initcall(acpi_power_init);
index decaebb..5267432 100644 (file)
@@ -122,10 +122,9 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
        u8 value1 = 0;
        u8 value2 = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4");
 
        if (!dev)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /*
         * Note that 'dev' references the PIIX4 ACPI Controller.
@@ -218,7 +217,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "Type-F DMA livelock erratum (C3 disabled)\n"));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_errata(struct acpi_processor *pr)
@@ -226,10 +225,9 @@ static int acpi_processor_errata(struct acpi_processor *pr)
        int result = 0;
        struct pci_dev *dev = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_errata");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /*
         * PIIX4
@@ -242,7 +240,7 @@ static int acpi_processor_errata(struct acpi_processor *pr)
                pci_dev_put(dev);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 /* --------------------------------------------------------------------------
@@ -258,10 +256,9 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr)
        struct acpi_object_list *pdc_in = pr->pdc;
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
 
        if (!pdc_in)
-               return_VALUE(status);
+               return status;
 
        status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
 
@@ -269,7 +266,7 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr)
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                    "Could not evaluate _PDC, using legacy perf. control...\n"));
 
-       return_VALUE(status);
+       return status;
 }
 
 /* --------------------------------------------------------------------------
@@ -282,7 +279,6 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_processor *pr = (struct acpi_processor *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
 
        if (!pr)
                goto end;
@@ -301,7 +297,7 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
                   pr->flags.limit ? "yes" : "no");
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
@@ -314,13 +310,12 @@ static int acpi_processor_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_processor_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
        }
        acpi_device_dir(device)->owner = THIS_MODULE;
 
@@ -328,9 +323,7 @@ static int acpi_processor_add_fs(struct acpi_device *device)
        entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_PROCESSOR_FILE_INFO));
+               return -EIO;
        else {
                entry->proc_fops = &acpi_processor_info_fops;
                entry->data = acpi_driver_data(device);
@@ -342,9 +335,7 @@ static int acpi_processor_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_PROCESSOR_FILE_THROTTLING));
+               return -EIO;
        else {
                entry->proc_fops = &acpi_processor_throttling_fops;
                entry->data = acpi_driver_data(device);
@@ -356,21 +347,18 @@ static int acpi_processor_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_PROCESSOR_FILE_LIMIT));
+               return -EIO;
        else {
                entry->proc_fops = &acpi_processor_limit_fops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
@@ -383,7 +371,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* Use the acpiid in MADT to map cpus in case of SMP */
@@ -430,10 +418,9 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
        int cpu_index;
        static int cpu0_initialized;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_info");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (num_online_cpus() > 1)
                errata.smp = TRUE;
@@ -459,9 +446,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
         */
        status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error evaluating processor object\n"));
-               return_VALUE(-ENODEV);
+               printk(KERN_ERR PREFIX "Evaluating processor object\n");
+               return -ENODEV;
        }
 
        /*
@@ -490,10 +476,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
        if (cpu_index == -1) {
                if (ACPI_FAILURE
                    (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Error getting cpuindex for acpiid 0x%x\n",
-                                         pr->acpi_id));
-                       return_VALUE(-ENODEV);
+                       printk(KERN_ERR PREFIX
+                                   "Getting cpuindex for acpiid 0x%x\n",
+                                   pr->acpi_id);
+                       return -ENODEV;
                }
        }
 
@@ -503,8 +489,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
        if (!object.processor.pblk_address)
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
        else if (object.processor.pblk_length != 6)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n",
-                                 object.processor.pblk_length));
+               printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
+                           object.processor.pblk_length);
        else {
                pr->throttling.address = object.processor.pblk_address;
                pr->throttling.duty_offset = acpi_fadt.duty_offset;
@@ -528,7 +514,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
        acpi_processor_get_throttling_info(pr);
        acpi_processor_get_limit_info(pr);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void *processor_device_array[NR_CPUS];
@@ -539,14 +525,13 @@ static int acpi_processor_start(struct acpi_device *device)
        acpi_status status = AE_OK;
        struct acpi_processor *pr;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_start");
 
        pr = acpi_driver_data(device);
 
        result = acpi_processor_get_info(pr);
        if (result) {
                /* Processor is physically not present */
-               return_VALUE(0);
+               return 0;
        }
 
        BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
@@ -560,7 +545,7 @@ static int acpi_processor_start(struct acpi_device *device)
            processor_device_array[pr->id] != (void *)device) {
                printk(KERN_WARNING "BIOS reported wrong ACPI id"
                        "for the processor\n");
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
        processor_device_array[pr->id] = (void *)device;
 
@@ -572,10 +557,6 @@ static int acpi_processor_start(struct acpi_device *device)
 
        status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
                                             acpi_processor_notify, pr);
-       if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error installing device notify handler\n"));
-       }
 
        /* _PDC call should be done before doing anything else (if reqd.). */
        arch_acpi_processor_init_pdc(pr);
@@ -592,7 +573,7 @@ static int acpi_processor_start(struct acpi_device *device)
 
       end:
 
-       return_VALUE(result);
+       return result;
 }
 
 static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
@@ -600,13 +581,12 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_processor *pr = (struct acpi_processor *)data;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_notify");
 
        if (!pr)
-               return_VOID;
+               return;
 
        if (acpi_bus_get_device(pr->handle, &device))
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
@@ -624,21 +604,20 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static int acpi_processor_add(struct acpi_device *device)
 {
        struct acpi_processor *pr = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL);
        if (!pr)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(pr, 0, sizeof(struct acpi_processor));
 
        pr->handle = device->handle;
@@ -646,7 +625,7 @@ static int acpi_processor_add(struct acpi_device *device)
        strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
        acpi_driver_data(device) = pr;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_remove(struct acpi_device *device, int type)
@@ -654,31 +633,26 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
        acpi_status status = AE_OK;
        struct acpi_processor *pr = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        pr = (struct acpi_processor *)acpi_driver_data(device);
 
        if (pr->id >= NR_CPUS) {
                kfree(pr);
-               return_VALUE(0);
+               return 0;
        }
 
        if (type == ACPI_BUS_REMOVAL_EJECT) {
                if (acpi_processor_handle_eject(pr))
-                       return_VALUE(-EINVAL);
+                       return -EINVAL;
        }
 
        acpi_processor_power_exit(pr, device);
 
        status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
                                            acpi_processor_notify);
-       if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
-       }
 
        acpi_processor_remove_fs(device);
 
@@ -686,7 +660,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
 
        kfree(pr);
 
-       return_VALUE(0);
+       return 0;
 }
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
@@ -701,15 +675,13 @@ static int is_processor_present(acpi_handle handle)
        acpi_status status;
        unsigned long sta = 0;
 
-       ACPI_FUNCTION_TRACE("is_processor_present");
 
        status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
        if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Processor Device is not present\n"));
-               return_VALUE(0);
+               ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present"));
+               return 0;
        }
-       return_VALUE(1);
+       return 1;
 }
 
 static
@@ -719,30 +691,29 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
        struct acpi_device *pdev;
        struct acpi_processor *pr;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_device_add");
 
        if (acpi_get_parent(handle, &phandle)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (acpi_bus_get_device(phandle, &pdev)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        acpi_bus_start(*device);
 
        pr = acpi_driver_data(*device);
        if (!pr)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
                kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
        }
-       return_VALUE(0);
+       return 0;
 }
 
 static void
@@ -752,7 +723,6 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_device *device = NULL;
        int result;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify");
 
        switch (event) {
        case ACPI_NOTIFY_BUS_CHECK:
@@ -767,15 +737,14 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
                if (acpi_bus_get_device(handle, &device)) {
                        result = acpi_processor_device_add(handle, &device);
                        if (result)
-                               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                 "Unable to add the device\n"));
+                               printk(KERN_ERR PREFIX
+                                           "Unable to add the device\n");
                        break;
                }
 
                pr = acpi_driver_data(device);
                if (!pr) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Driver data is NULL\n"));
+                       printk(KERN_ERR PREFIX "Driver data is NULL\n");
                        break;
                }
 
@@ -788,9 +757,8 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
                if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
                        kobject_uevent(&device->kobj, KOBJ_ONLINE);
                } else {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Device [%s] failed to start\n",
-                                         acpi_device_bid(device)));
+                       printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
+                                   acpi_device_bid(device));
                }
                break;
        case ACPI_NOTIFY_EJECT_REQUEST:
@@ -798,15 +766,15 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
                                  "received ACPI_NOTIFY_EJECT_REQUEST\n"));
 
                if (acpi_bus_get_device(handle, &device)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Device don't exist, dropping EJECT\n"));
+                       printk(KERN_ERR PREFIX
+                                   "Device don't exist, dropping EJECT\n");
                        break;
                }
                pr = acpi_driver_data(device);
                if (!pr) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Driver data is NULL, dropping EJECT\n"));
-                       return_VOID;
+                       printk(KERN_ERR PREFIX
+                                   "Driver data is NULL, dropping EJECT\n");
+                       return;
                }
 
                if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
@@ -818,7 +786,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static acpi_status
@@ -857,21 +825,20 @@ processor_walk_namespace_cb(acpi_handle handle,
 
 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init");
 
        if (!is_processor_present(handle)) {
-               return_VALUE(AE_ERROR);
+               return AE_ERROR;
        }
 
        if (acpi_map_lsapic(handle, p_cpu))
-               return_VALUE(AE_ERROR);
+               return AE_ERROR;
 
        if (arch_register_cpu(*p_cpu)) {
                acpi_unmap_lsapic(*p_cpu);
-               return_VALUE(AE_ERROR);
+               return AE_ERROR;
        }
 
-       return_VALUE(AE_OK);
+       return AE_OK;
 }
 
 static int acpi_processor_handle_eject(struct acpi_processor *pr)
@@ -928,20 +895,19 @@ static int __init acpi_processor_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_init");
 
        memset(&processors, 0, sizeof(processors));
        memset(&errata, 0, sizeof(errata));
 
        acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
        if (!acpi_processor_dir)
-               return_VALUE(0);
+               return 0;
        acpi_processor_dir->owner = THIS_MODULE;
 
        result = acpi_bus_register_driver(&acpi_processor_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
-               return_VALUE(0);
+               return 0;
        }
 
        acpi_processor_install_hotplug_notify();
@@ -950,12 +916,11 @@ static int __init acpi_processor_init(void)
 
        acpi_processor_ppc_init();
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_processor_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_exit");
 
        acpi_processor_ppc_exit();
 
@@ -967,7 +932,7 @@ static void __exit acpi_processor_exit(void)
 
        remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_processor_init);
index 8a74bf3..e439eb7 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
- *  Copyright (C) 2004       Dominik Brodowski <linux@brodo.de>
+ *  Copyright (C) 2004, 2005 Dominik Brodowski <linux@brodo.de>
  *  Copyright (C) 2004  Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
  *                     - Added processor hotplug support
  *  Copyright (C) 2005  Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
@@ -99,6 +99,9 @@ static int set_max_cstate(struct dmi_system_id *id)
 static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
        { set_max_cstate, "IBM ThinkPad R40e", {
          DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
+         DMI_MATCH(DMI_BIOS_VERSION,"1SET70WW")}, (void *)1},
+       { set_max_cstate, "IBM ThinkPad R40e", {
+         DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
          DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1},
        { set_max_cstate, "IBM ThinkPad R40e", {
          DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
@@ -261,21 +264,15 @@ static void acpi_processor_idle(void)
                u32 bm_status = 0;
                unsigned long diff = jiffies - pr->power.bm_check_timestamp;
 
-               if (diff > 32)
-                       diff = 32;
+               if (diff > 31)
+                       diff = 31;
 
-               while (diff) {
-                       /* if we didn't get called, assume there was busmaster activity */
-                       diff--;
-                       if (diff)
-                               pr->power.bm_activity |= 0x1;
-                       pr->power.bm_activity <<= 1;
-               }
+               pr->power.bm_activity <<= diff;
 
                acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS,
                                  &bm_status, ACPI_MTX_DO_NOT_LOCK);
                if (bm_status) {
-                       pr->power.bm_activity++;
+                       pr->power.bm_activity |= 0x1;
                        acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS,
                                          1, ACPI_MTX_DO_NOT_LOCK);
                }
@@ -287,16 +284,16 @@ static void acpi_processor_idle(void)
                else if (errata.piix4.bmisx) {
                        if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01)
                            || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
-                               pr->power.bm_activity++;
+                               pr->power.bm_activity |= 0x1;
                }
 
                pr->power.bm_check_timestamp = jiffies;
 
                /*
-                * Apply bus mastering demotion policy.  Automatically demote
+                * If bus mastering is or was active this jiffy, demote
                 * to avoid a faulty transition.  Note that the processor
                 * won't enter a low-power state during this call (to this
-                * funciton) but should upon the next.
+                * function) but should upon the next.
                 *
                 * TBD: A better policy might be to fallback to the demotion
                 *      state (use it for this quantum only) istead of
@@ -304,7 +301,8 @@ static void acpi_processor_idle(void)
                 *      qualification.  This may, however, introduce DMA
                 *      issues (e.g. floppy DMA transfer overrun/underrun).
                 */
-               if (pr->power.bm_activity & cx->demotion.threshold.bm) {
+               if ((pr->power.bm_activity & 0x1) &&
+                   cx->demotion.threshold.bm) {
                        local_irq_enable();
                        next_state = cx->demotion.state;
                        goto end;
@@ -322,8 +320,6 @@ static void acpi_processor_idle(void)
                cx = &pr->power.states[ACPI_STATE_C1];
 #endif
 
-       cx->usage++;
-
        /*
         * Sleep:
         * ------
@@ -365,7 +361,9 @@ static void acpi_processor_idle(void)
                t1 = inl(acpi_fadt.xpm_tmr_blk.address);
                /* Invoke C2 */
                inb(cx->address);
-               /* Dummy op - must do something useless after P_LVL2 read */
+               /* Dummy wait op - must do something useless after P_LVL2 read
+                  because chipsets cannot guarantee that STPCLK# signal
+                  gets asserted in time to freeze execution properly. */
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
                /* Get end time (ticks) */
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
@@ -403,7 +401,7 @@ static void acpi_processor_idle(void)
                t1 = inl(acpi_fadt.xpm_tmr_blk.address);
                /* Invoke C3 */
                inb(cx->address);
-               /* Dummy op - must do something useless after P_LVL3 read */
+               /* Dummy wait op (see above) */
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
                /* Get end time (ticks) */
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
@@ -430,6 +428,9 @@ static void acpi_processor_idle(void)
                local_irq_enable();
                return;
        }
+       cx->usage++;
+       if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0))
+               cx->time += sleep_ticks;
 
        next_state = pr->power.state;
 
@@ -517,10 +518,9 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
        struct acpi_processor_cx *higher = NULL;
        struct acpi_processor_cx *cx;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /*
         * This function sets the default Cx state policy (OS idle handler).
@@ -544,7 +544,7 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
        }
 
        if (!state_is_set)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /* demotion */
        for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
@@ -583,18 +583,17 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
                higher = cx;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!pr->pblk)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /* if info is obtained from pblk/fadt, type equals state */
        pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
@@ -606,7 +605,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
         * an SMP system. 
         */
        if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 #endif
 
        /* determine C2 and C3 address from pblk */
@@ -622,12 +621,11 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
                          pr->power.states[ACPI_STATE_C2].address,
                          pr->power.states[ACPI_STATE_C3].address));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
 
        /* Zero initialize all the C-states info. */
        memset(pr->power.states, 0, sizeof(pr->power.states));
@@ -640,7 +638,7 @@ static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
        pr->power.states[ACPI_STATE_C0].valid = 1;
        pr->power.states[ACPI_STATE_C1].valid = 1;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
@@ -652,10 +650,9 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *cst;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
 
        if (nocst)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        current_count = 1;
 
@@ -667,15 +664,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
        status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n"));
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        cst = (union acpi_object *)buffer.pointer;
 
        /* There must be at least 2 elements */
        if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "not enough elements in _CST\n"));
+               printk(KERN_ERR PREFIX "not enough elements in _CST\n");
                status = -EFAULT;
                goto end;
        }
@@ -684,8 +680,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
 
        /* Validate number of power states. */
        if (count < 1 || count != cst->package.count - 1) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "count given by _CST is not valid\n"));
+               printk(KERN_ERR PREFIX "count given by _CST is not valid\n");
                status = -EFAULT;
                goto end;
        }
@@ -775,15 +770,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
       end:
        acpi_os_free(buffer.pointer);
 
-       return_VALUE(status);
+       return status;
 }
 
 static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2");
 
        if (!cx->address)
-               return_VOID;
+               return;
 
        /*
         * C2 latency must be less than or equal to 100
@@ -792,7 +786,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
        else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "latency too large [%d]\n", cx->latency));
-               return_VOID;
+               return;
        }
 
        /*
@@ -802,7 +796,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
        cx->valid = 1;
        cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
 
-       return_VOID;
+       return;
 }
 
 static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
@@ -810,10 +804,9 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
 {
        static int bm_check_flag;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3");
 
        if (!cx->address)
-               return_VOID;
+               return;
 
        /*
         * C3 latency must be less than or equal to 1000
@@ -822,7 +815,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
        else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "latency too large [%d]\n", cx->latency));
-               return_VOID;
+               return;
        }
 
        /*
@@ -835,7 +828,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
        else if (errata.piix4.fdma) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "C3 not supported on PIIX4 with Type-F DMA\n"));
-               return_VOID;
+               return;
        }
 
        /* All the logic here assumes flags.bm_check is same across all CPUs */
@@ -852,7 +845,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
                if (!pr->flags.bm_control) {
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "C3 support requires bus mastering control\n"));
-                       return_VOID;
+                       return;
                }
        } else {
                /*
@@ -863,7 +856,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "Cache invalidation should work properly"
                                          " for C3 to be enabled on SMP systems\n"));
-                       return_VOID;
+                       return;
                }
                acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
                                  0, ACPI_MTX_DO_NOT_LOCK);
@@ -878,7 +871,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
        cx->valid = 1;
        cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
 
-       return_VOID;
+       return;
 }
 
 static int acpi_processor_power_verify(struct acpi_processor *pr)
@@ -937,7 +930,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
        unsigned int i;
        int result;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_power_info");
 
        /* NOTE: the idle thread may not be running while calling
         * this function */
@@ -960,7 +952,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
         */
        result = acpi_processor_set_power_policy(pr);
        if (result)
-               return_VALUE(result);
+               return result;
 
        /*
         * if one state of type C2 or C3 is available, mark this
@@ -974,24 +966,23 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
                }
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (nocst) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (!pr->flags.power_setup_done)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /* Fall back to the default idle loop */
        pm_idle = pm_idle_save;
@@ -1002,7 +993,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
        if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
                pm_idle = acpi_processor_idle;
 
-       return_VALUE(result);
+       return result;
 }
 
 /* proc interface */
@@ -1012,7 +1003,6 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
        struct acpi_processor *pr = (struct acpi_processor *)seq->private;
        unsigned int i;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show");
 
        if (!pr)
                goto end;
@@ -1064,13 +1054,14 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
                else
                        seq_puts(seq, "demotion[--] ");
 
-               seq_printf(seq, "latency[%03d] usage[%08d]\n",
+               seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
                           pr->power.states[i].latency,
-                          pr->power.states[i].usage);
+                          pr->power.states[i].usage,
+                          pr->power.states[i].time);
        }
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
@@ -1094,7 +1085,6 @@ int acpi_processor_power_init(struct acpi_processor *pr,
        struct proc_dir_entry *entry = NULL;
        unsigned int i;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_power_init");
 
        if (!first_run) {
                dmi_check_system(processor_power_dmi_table);
@@ -1106,14 +1096,14 @@ int acpi_processor_power_init(struct acpi_processor *pr,
        }
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (acpi_fadt.cst_cnt && !nocst) {
                status =
                    acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
                if (ACPI_FAILURE(status)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Notifying BIOS of _CST ability failed\n"));
+                       ACPI_EXCEPTION((AE_INFO, status,
+                                       "Notifying BIOS of _CST ability failed"));
                }
        }
 
@@ -1142,9 +1132,7 @@ int acpi_processor_power_init(struct acpi_processor *pr,
        entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_PROCESSOR_FILE_POWER));
+               return -EIO;
        else {
                entry->proc_fops = &acpi_processor_power_fops;
                entry->data = acpi_driver_data(device);
@@ -1153,13 +1141,12 @@ int acpi_processor_power_init(struct acpi_processor *pr,
 
        pr->flags.power_setup_done = 1;
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_processor_power_exit(struct acpi_processor *pr,
                              struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_power_exit");
 
        pr->flags.power_setup_done = 0;
 
@@ -1179,5 +1166,5 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
                cpu_idle_wait();
        }
 
-       return_VALUE(0);
+       return 0;
 }
index 41aaaba..14a00e5 100644 (file)
@@ -108,10 +108,9 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
        acpi_status status = 0;
        unsigned long ppc = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /*
         * _PPC indicates the maximum state currently supported by the platform
@@ -123,13 +122,13 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
                acpi_processor_ppc_status |= PPC_IN_USE;
 
        if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
+               return -ENODEV;
        }
 
        pr->performance_platform_limit = (int)ppc;
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
@@ -168,18 +167,17 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
        union acpi_object *pct = NULL;
        union acpi_object obj = { 0 };
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
 
        status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
+               return -ENODEV;
        }
 
        pct = (union acpi_object *)buffer.pointer;
        if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
            || (pct->package.count != 2)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n"));
+               printk(KERN_ERR PREFIX "Invalid _PCT data\n");
                result = -EFAULT;
                goto end;
        }
@@ -193,8 +191,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
        if ((obj.type != ACPI_TYPE_BUFFER)
            || (obj.buffer.length < sizeof(struct acpi_pct_register))
            || (obj.buffer.pointer == NULL)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid _PCT data (control_register)\n"));
+               printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
                result = -EFAULT;
                goto end;
        }
@@ -210,8 +207,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
        if ((obj.type != ACPI_TYPE_BUFFER)
            || (obj.buffer.length < sizeof(struct acpi_pct_register))
            || (obj.buffer.pointer == NULL)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Invalid _PCT data (status_register)\n"));
+               printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
                result = -EFAULT;
                goto end;
        }
@@ -222,7 +218,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
       end:
        acpi_os_free(buffer.pointer);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_processor_get_performance_states(struct acpi_processor *pr)
@@ -235,17 +231,16 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
        union acpi_object *pss = NULL;
        int i;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
 
        status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
+               return -ENODEV;
        }
 
        pss = (union acpi_object *)buffer.pointer;
        if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n"));
+               printk(KERN_ERR PREFIX "Invalid _PSS data\n");
                result = -EFAULT;
                goto end;
        }
@@ -274,8 +269,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
                status = acpi_extract_package(&(pss->package.elements[i]),
                                              &format, &state);
                if (ACPI_FAILURE(status)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Invalid _PSS data\n"));
+                       ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
                        result = -EFAULT;
                        kfree(pr->performance->states);
                        goto end;
@@ -291,8 +285,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
                                  (u32) px->control, (u32) px->status));
 
                if (!px->core_frequency) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Invalid _PSS data: freq is zero\n"));
+                       printk(KERN_ERR PREFIX
+                                   "Invalid _PSS data: freq is zero\n");
                        result = -EFAULT;
                        kfree(pr->performance->states);
                        goto end;
@@ -302,7 +296,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
       end:
        acpi_os_free(buffer.pointer);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_processor_get_performance_info(struct acpi_processor *pr)
@@ -311,31 +305,30 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
        acpi_status status = AE_OK;
        acpi_handle handle = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
 
        if (!pr || !pr->performance || !pr->handle)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_get_handle(pr->handle, "_PCT", &handle);
        if (ACPI_FAILURE(status)) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "ACPI-based processor performance control unavailable\n"));
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        result = acpi_processor_get_performance_control(pr);
        if (result)
-               return_VALUE(result);
+               return result;
 
        result = acpi_processor_get_performance_states(pr);
        if (result)
-               return_VALUE(result);
+               return result;
 
        result = acpi_processor_get_platform_limit(pr);
        if (result)
-               return_VALUE(result);
+               return result;
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_processor_notify_smm(struct module *calling_module)
@@ -343,13 +336,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
        acpi_status status;
        static int is_done = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
 
        if (!(acpi_processor_ppc_status & PPC_REGISTERED))
-               return_VALUE(-EBUSY);
+               return -EBUSY;
 
        if (!try_module_get(calling_module))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* is_done is set to negative if an error occured,
         * and to postitive if _no_ error occured, but SMM
@@ -358,10 +350,10 @@ int acpi_processor_notify_smm(struct module *calling_module)
         */
        if (is_done > 0) {
                module_put(calling_module);
-               return_VALUE(0);
+               return 0;
        } else if (is_done < 0) {
                module_put(calling_module);
-               return_VALUE(is_done);
+               return is_done;
        }
 
        is_done = -EIO;
@@ -370,7 +362,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
        if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n"));
                module_put(calling_module);
-               return_VALUE(0);
+               return 0;
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -387,12 +379,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
        status = acpi_os_write_port(acpi_fadt.smi_cmd,
                                    (u32) acpi_fadt.pstate_cnt, 8);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Failed to write pstate_cnt [0x%x] to "
-                                 "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt,
-                                 acpi_fadt.smi_cmd));
+               ACPI_EXCEPTION((AE_INFO, status,
+                               "Failed to write pstate_cnt [0x%x] to "
+                               "smi_cmd [0x%x]", acpi_fadt.pstate_cnt,
+                               acpi_fadt.smi_cmd));
                module_put(calling_module);
-               return_VALUE(status);
+               return status;
        }
 
        /* Success. If there's no _PPC, we need to fear nothing, so
@@ -402,7 +394,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
        if (!(acpi_processor_ppc_status & PPC_IN_USE))
                module_put(calling_module);
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_processor_notify_smm);
@@ -423,7 +415,6 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
        struct acpi_processor *pr = (struct acpi_processor *)seq->private;
        int i;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
 
        if (!pr)
                goto end;
@@ -447,7 +438,7 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
                           (u32) pr->performance->states[i].transition_latency);
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
@@ -469,23 +460,22 @@ acpi_processor_write_performance(struct file *file,
        unsigned int new_state = 0;
        struct cpufreq_policy policy;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
 
        if (!pr || (count > sizeof(state_string) - 1))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        perf = pr->performance;
        if (!perf)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(state_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        state_string[count] = '\0';
        new_state = simple_strtoul(state_string, NULL, 0);
 
        if (new_state >= perf->state_count)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        cpufreq_get_policy(&policy, pr->id);
 
@@ -495,9 +485,9 @@ acpi_processor_write_performance(struct file *file,
 
        result = cpufreq_set_policy(&policy);
        if (result)
-               return_VALUE(result);
+               return result;
 
-       return_VALUE(count);
+       return count;
 }
 
 static void acpi_cpufreq_add_file(struct acpi_processor *pr)
@@ -505,42 +495,36 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
        struct proc_dir_entry *entry = NULL;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
 
        if (acpi_bus_get_device(pr->handle, &device))
-               return_VOID;
+               return;
 
        /* add file 'performance' [R/W] */
        entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
-       if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_PROCESSOR_FILE_PERFORMANCE));
-       else {
+       if (entry){
                acpi_processor_perf_fops.write = acpi_processor_write_performance;
                entry->proc_fops = &acpi_processor_perf_fops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
-       return_VOID;
+       return;
 }
 
 static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
 {
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
 
        if (acpi_bus_get_device(pr->handle, &device))
-               return_VOID;
+               return;
 
        /* remove file 'performance' */
        remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
                          acpi_device_dir(device));
 
-       return_VOID;
+       return;
 }
 
 #else
@@ -698,12 +682,12 @@ int acpi_processor_preregister_performance(
                /* Validate the Domain info */
                count_target = pdomain->num_processors;
                count = 1;
-               if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL ||
-                   pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) {
+               if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
                        pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
-               } else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) {
+               else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
+                       pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW;
+               else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
                        pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
-               }
 
                for_each_possible_cpu(j) {
                        if (i == j)
@@ -784,22 +768,21 @@ acpi_processor_register_performance(struct acpi_processor_performance
 {
        struct acpi_processor *pr;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_register_performance");
 
        if (!(acpi_processor_ppc_status & PPC_REGISTERED))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        mutex_lock(&performance_mutex);
 
        pr = processors[cpu];
        if (!pr) {
                mutex_unlock(&performance_mutex);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (pr->performance) {
                mutex_unlock(&performance_mutex);
-               return_VALUE(-EBUSY);
+               return -EBUSY;
        }
 
        WARN_ON(!performance);
@@ -809,13 +792,13 @@ acpi_processor_register_performance(struct acpi_processor_performance
        if (acpi_processor_get_performance_info(pr)) {
                pr->performance = NULL;
                mutex_unlock(&performance_mutex);
-               return_VALUE(-EIO);
+               return -EIO;
        }
 
        acpi_cpufreq_add_file(pr);
 
        mutex_unlock(&performance_mutex);
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_processor_register_performance);
@@ -826,14 +809,13 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
 {
        struct acpi_processor *pr;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
 
        mutex_lock(&performance_mutex);
 
        pr = processors[cpu];
        if (!pr) {
                mutex_unlock(&performance_mutex);
-               return_VOID;
+               return;
        }
 
        if (pr->performance)
@@ -844,7 +826,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
 
        mutex_unlock(&performance_mutex);
 
-       return_VOID;
+       return;
 }
 
 EXPORT_SYMBOL(acpi_processor_unregister_performance);
index f99ad05..ef5e0f6 100644 (file)
@@ -54,13 +54,12 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
        u16 px = 0;
        u16 tx = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_apply_limit");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!pr->flags.limit)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (pr->flags.throttling) {
                if (pr->limit.user.tx > tx)
@@ -82,9 +81,9 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
 
       end:
        if (result)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n"));
+               printk(KERN_ERR PREFIX "Unable to set limit\n");
 
-       return_VALUE(result);
+       return result;
 }
 
 #ifdef CONFIG_CPU_FREQ
@@ -200,19 +199,18 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
        struct acpi_device *device = NULL;
        int tx = 0, max_tx_px = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
 
        if ((type < ACPI_PROCESSOR_LIMIT_NONE)
            || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        result = acpi_bus_get_device(handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        pr = (struct acpi_processor *)acpi_driver_data(device);
        if (!pr)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /* Thermal limits are always relative to the current Px/Tx state. */
        if (pr->flags.throttling)
@@ -289,30 +287,28 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
 
                result = acpi_processor_apply_limit(pr);
                if (result)
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Unable to set thermal limit\n"));
+                       printk(KERN_ERR PREFIX "Unable to set thermal limit\n");
 
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
                                  pr->limit.thermal.px, pr->limit.thermal.tx));
        } else
                result = 0;
        if (max_tx_px)
-               return_VALUE(1);
+               return 1;
        else
-               return_VALUE(result);
+               return result;
 }
 
 int acpi_processor_get_limit_info(struct acpi_processor *pr)
 {
-       ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (pr->flags.throttling)
                pr->flags.limit = 1;
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* /proc interface */
@@ -321,7 +317,6 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_processor *pr = (struct acpi_processor *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
 
        if (!pr)
                goto end;
@@ -339,7 +334,7 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
                   pr->limit.thermal.px, pr->limit.thermal.tx);
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
@@ -359,36 +354,33 @@ static ssize_t acpi_processor_write_limit(struct file * file,
        int px = 0;
        int tx = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_write_limit");
 
        if (!pr || (count > sizeof(limit_string) - 1)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
-               return_VALUE(-EINVAL);
+               return -EINVAL;
        }
 
        if (copy_from_user(limit_string, buffer, count)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
-               return_VALUE(-EFAULT);
+               return -EFAULT;
        }
 
        limit_string[count] = '\0';
 
        if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "Invalid data format\n");
+               return -EINVAL;
        }
 
        if (pr->flags.throttling) {
                if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid tx\n"));
-                       return_VALUE(-EINVAL);
+                       printk(KERN_ERR PREFIX "Invalid tx\n");
+                       return -EINVAL;
                }
                pr->limit.user.tx = tx;
        }
 
        result = acpi_processor_apply_limit(pr);
 
-       return_VALUE(count);
+       return count;
 }
 
 struct file_operations acpi_processor_limit_fops = {
index b966549..d044ec5 100644 (file)
@@ -55,13 +55,12 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
        u32 duty_mask = 0;
        u32 duty_value = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!pr->flags.throttling)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        pr->throttling.state = 0;
 
@@ -93,7 +92,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
                          "Throttling state is T%d (%d%% throttling applied)\n",
                          state, pr->throttling.states[state].performance));
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
@@ -102,19 +101,18 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
        u32 duty_mask = 0;
        u32 duty_value = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if ((state < 0) || (state > (pr->throttling.state_count - 1)))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!pr->flags.throttling)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (state == pr->throttling.state)
-               return_VALUE(0);
+               return 0;
 
        /*
         * Calculate the duty_value and duty_mask.
@@ -165,7 +163,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
                          (pr->throttling.states[state].performance ? pr->
                           throttling.states[state].performance / 10 : 0)));
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_processor_get_throttling_info(struct acpi_processor *pr)
@@ -174,7 +172,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
        int step = 0;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -183,21 +180,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
                          pr->throttling.duty_width));
 
        if (!pr)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* TBD: Support ACPI 2.0 objects */
 
        if (!pr->throttling.address) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
-               return_VALUE(0);
+               return 0;
        } else if (!pr->throttling.duty_width) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
-               return_VALUE(0);
+               return 0;
        }
        /* TBD: Support duty_cycle values that span bit 4. */
        else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n"));
-               return_VALUE(0);
+               printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
+               return 0;
        }
 
        /*
@@ -208,7 +205,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
        if (errata.piix4.throttle) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "Throttling not supported on PIIX4 A- or B-step\n"));
-               return_VALUE(0);
+               return 0;
        }
 
        pr->throttling.state_count = 1 << acpi_fadt.duty_width;
@@ -254,7 +251,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
        if (result)
                pr->flags.throttling = 0;
 
-       return_VALUE(result);
+       return result;
 }
 
 /* proc interface */
@@ -266,7 +263,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
        int i = 0;
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
 
        if (!pr)
                goto end;
@@ -296,7 +292,7 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
                            throttling.states[i].performance / 10 : 0));
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_processor_throttling_open_fs(struct inode *inode,
@@ -315,13 +311,12 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
        struct acpi_processor *pr = (struct acpi_processor *)m->private;
        char state_string[12] = { '\0' };
 
-       ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
 
        if (!pr || (count > sizeof(state_string) - 1))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(state_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        state_string[count] = '\0';
 
@@ -329,9 +324,9 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
                                               simple_strtoul(state_string,
                                                              NULL, 0));
        if (result)
-               return_VALUE(result);
+               return result;
 
-       return_VALUE(count);
+       return count;
 }
 
 struct file_operations acpi_processor_throttling_fops = {
index f8316a0..861ac37 100644 (file)
@@ -162,11 +162,10 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
 
 void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
 {
-       ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
 
        /* TBD */
 
-       return_VOID;
+       return;
 }
 
 static int acpi_bus_get_power_flags(struct acpi_device *device)
@@ -175,7 +174,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
        acpi_handle handle = NULL;
        u32 i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
 
        /*
         * Power Management Flags
@@ -228,7 +226,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
 
        device->power.state = ACPI_STATE_UNKNOWN;
 
-       return_VALUE(0);
+       return 0;
 }
 
 int acpi_match_ids(struct acpi_device *device, char *ids)
@@ -306,20 +304,18 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *package = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
 
        /* _PRW */
        status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW"));
                goto end;
        }
 
        package = (union acpi_object *)buffer.pointer;
        status = acpi_bus_extract_wakeup_device_power_package(device, package);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error extracting _PRW package\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package"));
                goto end;
        }
 
@@ -333,7 +329,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
       end:
        if (ACPI_FAILURE(status))
                device->flags.wake_capable = 0;
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -489,19 +485,18 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
 
        if (!device || !driver)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!driver->ops.add)
-               return_VALUE(-ENOSYS);
+               return -ENOSYS;
 
        result = driver->ops.add(device);
        if (result) {
                device->driver = NULL;
                acpi_driver_data(device) = NULL;
-               return_VALUE(result);
+               return result;
        }
 
        device->driver = driver;
@@ -513,7 +508,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "Driver successfully bound to device\n"));
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_start_single_object(struct acpi_device *device)
@@ -521,10 +516,9 @@ static int acpi_start_single_object(struct acpi_device *device)
        int result = 0;
        struct acpi_driver *driver;
 
-       ACPI_FUNCTION_TRACE("acpi_start_single_object");
 
        if (!(driver = device->driver))
-               return_VALUE(0);
+               return 0;
 
        if (driver->ops.start) {
                result = driver->ops.start(device);
@@ -532,14 +526,13 @@ static int acpi_start_single_object(struct acpi_device *device)
                        driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static void acpi_driver_attach(struct acpi_driver *drv)
 {
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_driver_attach");
 
        spin_lock(&acpi_device_lock);
        list_for_each_safe(node, next, &acpi_device_list) {
@@ -568,7 +561,6 @@ static void acpi_driver_detach(struct acpi_driver *drv)
 {
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_driver_detach");
 
        spin_lock(&acpi_device_lock);
        list_for_each_safe(node, next, &acpi_device_list) {
@@ -598,17 +590,16 @@ static void acpi_driver_detach(struct acpi_driver *drv)
  */
 int acpi_bus_register_driver(struct acpi_driver *driver)
 {
-       ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
 
        if (acpi_disabled)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        spin_lock(&acpi_device_lock);
        list_add_tail(&driver->node, &acpi_bus_drivers);
        spin_unlock(&acpi_device_lock);
        acpi_driver_attach(driver);
 
-       return_VALUE(0);
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_bus_register_driver);
@@ -646,7 +637,6 @@ static int acpi_bus_find_driver(struct acpi_device *device)
        int result = 0;
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
 
        spin_lock(&acpi_device_lock);
        list_for_each_safe(node, next, &acpi_bus_drivers) {
@@ -666,19 +656,41 @@ static int acpi_bus_find_driver(struct acpi_device *device)
        spin_unlock(&acpi_device_lock);
 
       Done:
-       return_VALUE(result);
+       return result;
 }
 
 /* --------------------------------------------------------------------------
                                  Device Enumeration
    -------------------------------------------------------------------------- */
 
+acpi_status
+acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
+{
+       acpi_status status;
+       acpi_handle tmp;
+       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+       union acpi_object *obj;
+
+       status = acpi_get_handle(handle, "_EJD", &tmp);
+       if (ACPI_FAILURE(status))
+               return status;
+
+       status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer);
+       if (ACPI_SUCCESS(status)) {
+               obj = buffer.pointer;
+               status = acpi_get_handle(NULL, obj->string.pointer, ejd);
+               kfree(buffer.pointer);
+       }
+       return status;
+}
+EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
+
+
 static int acpi_bus_get_flags(struct acpi_device *device)
 {
        acpi_status status = AE_OK;
        acpi_handle temp = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
 
        /* Presence of _STA indicates 'dynamic_status' */
        status = acpi_get_handle(device->handle, "_STA", &temp);
@@ -724,7 +736,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
 
        /* TBD: Peformance management */
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void acpi_device_get_busid(struct acpi_device *device,
@@ -918,10 +930,9 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
        int result = 0;
        struct acpi_driver *driver;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_remove");
 
        if (!dev)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        driver = dev->driver;
 
@@ -930,12 +941,12 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
                if (driver->ops.stop) {
                        result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
                        if (result)
-                               return_VALUE(result);
+                               return result;
                }
 
                result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
                if (result) {
-                       return_VALUE(result);
+                       return result;
                }
 
                atomic_dec(&dev->driver->references);
@@ -944,7 +955,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
        }
 
        if (!rmdevice)
-               return_VALUE(0);
+               return 0;
 
        if (dev->flags.bus_address) {
                if ((dev->parent) && (dev->parent->ops.unbind))
@@ -953,7 +964,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
 
        acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -963,15 +974,14 @@ acpi_add_single_object(struct acpi_device **child,
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_add_single_object");
 
        if (!child)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
        if (!device) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
-               return_VALUE(-ENOMEM);
+               printk(KERN_ERR PREFIX "Memory allocation error\n");
+               return -ENOMEM;
        }
        memset(device, 0, sizeof(struct acpi_device));
 
@@ -1096,7 +1106,7 @@ acpi_add_single_object(struct acpi_device **child,
                kfree(device);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
@@ -1109,10 +1119,9 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
        acpi_object_type type = 0;
        u32 level = 1;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_scan");
 
        if (!start)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        parent = start;
        phandle = start->handle;
@@ -1209,7 +1218,7 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
                }
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 int
@@ -1219,7 +1228,6 @@ acpi_bus_add(struct acpi_device **child,
        int result;
        struct acpi_bus_ops ops;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_add");
 
        result = acpi_add_single_object(child, parent, handle, type);
        if (!result) {
@@ -1227,7 +1235,7 @@ acpi_bus_add(struct acpi_device **child,
                ops.acpi_op_add = 1;
                result = acpi_bus_scan(*child, &ops);
        }
-       return_VALUE(result);
+       return result;
 }
 
 EXPORT_SYMBOL(acpi_bus_add);
@@ -1237,10 +1245,9 @@ int acpi_bus_start(struct acpi_device *device)
        int result;
        struct acpi_bus_ops ops;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_start");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        result = acpi_start_single_object(device);
        if (!result) {
@@ -1248,7 +1255,7 @@ int acpi_bus_start(struct acpi_device *device)
                ops.acpi_op_start = 1;
                result = acpi_bus_scan(device, &ops);
        }
-       return_VALUE(result);
+       return result;
 }
 
 EXPORT_SYMBOL(acpi_bus_start);
@@ -1314,10 +1321,9 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
 
        if (!root)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        /*
         * Enumerate all fixed-feature devices.
@@ -1338,7 +1344,7 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
                        result = acpi_start_single_object(device);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 
@@ -1427,7 +1433,7 @@ static int acpi_device_resume(struct device * dev)
 }
 
 
-struct bus_type acpi_bus_type = {
+static struct bus_type acpi_bus_type = {
        .name           = "acpi",
        .suspend        = acpi_device_suspend,
        .resume         = acpi_device_resume,
@@ -1440,10 +1446,9 @@ static int __init acpi_scan_init(void)
        int result;
        struct acpi_bus_ops ops;
 
-       ACPI_FUNCTION_TRACE("acpi_scan_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
        kset_register(&acpi_namespace_kset);
 
@@ -1488,7 +1493,7 @@ static int __init acpi_scan_init(void)
                acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
 
       Done:
-       return_VALUE(result);
+       return result;
 }
 
 subsys_initcall(acpi_scan_init);
index a934ac4..c90bd2f 100644 (file)
@@ -47,10 +47,9 @@ extern struct fadt_descriptor acpi_fadt;
 
 static int acpi_system_read_info(struct seq_file *seq, void *offset)
 {
-       ACPI_FUNCTION_TRACE("acpi_system_read_info");
 
        seq_printf(seq, "version:                 %x\n", ACPI_CA_VERSION);
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
@@ -80,17 +79,16 @@ acpi_system_read_dsdt(struct file *file,
        struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
        ssize_t res;
 
-       ACPI_FUNCTION_TRACE("acpi_system_read_dsdt");
 
        status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        res = simple_read_from_buffer(buffer, count, ppos,
                                      dsdt.pointer, dsdt.length);
        acpi_os_free(dsdt.pointer);
 
-       return_VALUE(res);
+       return res;
 }
 
 static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
@@ -108,17 +106,16 @@ acpi_system_read_fadt(struct file *file,
        struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL };
        ssize_t res;
 
-       ACPI_FUNCTION_TRACE("acpi_system_read_fadt");
 
        status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &fadt);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        res = simple_read_from_buffer(buffer, count, ppos,
                                      fadt.pointer, fadt.length);
        acpi_os_free(fadt.pointer);
 
-       return_VALUE(res);
+       return res;
 }
 
 static int __init acpi_system_init(void)
@@ -127,10 +124,9 @@ static int __init acpi_system_init(void)
        int error = 0;
        char *name;
 
-       ACPI_FUNCTION_TRACE("acpi_system_init");
 
        if (acpi_disabled)
-               return_VALUE(0);
+               return 0;
 
        /* 'info' [R] */
        name = ACPI_SYSTEM_FILE_INFO;
@@ -158,12 +154,9 @@ static int __init acpi_system_init(void)
                goto Error;
 
       Done:
-       return_VALUE(error);
+       return error;
 
       Error:
-       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                         "Unable to create '%s' proc fs entry\n", name));
-
        remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
        remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
        remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
index e7fe3a1..c855f44 100644 (file)
@@ -222,51 +222,48 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        tz->last_temperature = tz->temperature;
 
        status =
            acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
                          tz->temperature));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status =
            acpi_evaluate_integer(tz->handle, "_TZP", NULL,
                                  &tz->polling_frequency);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
                          tz->polling_frequency));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
 {
-       ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        tz->polling_frequency = seconds * 10;   /* Convert value to deci-seconds */
 
@@ -274,7 +271,7 @@ static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
                          "Polling frequency set to %lu seconds\n",
                          tz->polling_frequency));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
@@ -284,29 +281,28 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
        struct acpi_object_list arg_list = { 1, &arg0 };
        acpi_handle handle = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_get_handle(tz->handle, "_SCP", &handle);
        if (ACPI_FAILURE(status)) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        arg0.integer.value = mode;
 
        status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        tz->cooling_mode = mode;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n",
                          mode ? "passive" : "active"));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
@@ -314,10 +310,9 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
        acpi_status status = AE_OK;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Critical Shutdown (required) */
 
@@ -325,8 +320,8 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
                                       &tz->trips.critical.temperature);
        if (ACPI_FAILURE(status)) {
                tz->trips.critical.flags.valid = 0;
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
-               return_VALUE(-ENODEV);
+               ACPI_EXCEPTION((AE_INFO, status, "No critical threshold"));
+               return -ENODEV;
        } else {
                tz->trips.critical.flags.valid = 1;
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -384,8 +379,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
                        tz->trips.passive.flags.valid = 0;
 
                if (!tz->trips.passive.flags.valid)
-                       ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                         "Invalid passive threshold\n"));
+                       printk(KERN_WARNING PREFIX "Invalid passive threshold\n");
                else
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "Found passive threshold [%lu]\n",
@@ -414,29 +408,27 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
                                          "Found active threshold [%d]:[%lu]\n",
                                          i, tz->trips.active[i].temperature));
                } else
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Invalid active threshold [%d]\n",
-                                         i));
+                       ACPI_EXCEPTION((AE_INFO, status,
+                                       "Invalid active threshold [%d]", i));
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_get_devices(struct acpi_thermal *tz)
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_get_devices");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status =
            acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_call_usermode(char *path)
@@ -444,10 +436,9 @@ static int acpi_thermal_call_usermode(char *path)
        char *argv[2] = { NULL, NULL };
        char *envp[3] = { NULL, NULL, NULL };
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode");
 
        if (!path)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        argv[0] = path;
 
@@ -457,7 +448,7 @@ static int acpi_thermal_call_usermode(char *path)
 
        call_usermodehelper(argv[0], argv, envp, 0);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_critical(struct acpi_thermal *tz)
@@ -465,20 +456,19 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_critical");
 
        if (!tz || !tz->trips.critical.flags.valid)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (tz->temperature >= tz->trips.critical.temperature) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n"));
+               printk(KERN_WARNING PREFIX "Critical trip point\n");
                tz->trips.critical.flags.enabled = 1;
        } else if (tz->trips.critical.flags.enabled)
                tz->trips.critical.flags.enabled = 0;
 
        result = acpi_bus_get_device(tz->handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        printk(KERN_EMERG
               "Critical temperature reached (%ld C), shutting down.\n",
@@ -488,7 +478,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
 
        acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_hot(struct acpi_thermal *tz)
@@ -496,27 +486,26 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
        int result = 0;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_hot");
 
        if (!tz || !tz->trips.hot.flags.valid)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (tz->temperature >= tz->trips.hot.temperature) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n"));
+               printk(KERN_WARNING PREFIX "Hot trip point\n");
                tz->trips.hot.flags.enabled = 1;
        } else if (tz->trips.hot.flags.enabled)
                tz->trips.hot.flags.enabled = 0;
 
        result = acpi_bus_get_device(tz->handle, &device);
        if (result)
-               return_VALUE(result);
+               return result;
 
        acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT,
                                tz->trips.hot.flags.enabled);
 
        /* TBD: Call user-mode "sleep(S4)" function */
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void acpi_thermal_passive(struct acpi_thermal *tz)
@@ -526,7 +515,6 @@ static void acpi_thermal_passive(struct acpi_thermal *tz)
        int trend = 0;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_passive");
 
        if (!tz || !tz->trips.passive.flags.valid)
                return;
@@ -615,7 +603,6 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
        int j = 0;
        unsigned long maxtemp = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_active");
 
        if (!tz)
                return;
@@ -642,10 +629,10 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
                                                       handles[j],
                                                       ACPI_STATE_D0);
                                if (result) {
-                                       ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                         "Unable to turn cooling device [%p] 'on'\n",
-                                                         active->devices.
-                                                         handles[j]));
+                                       printk(KERN_WARNING PREFIX
+                                                     "Unable to turn cooling device [%p] 'on'\n",
+                                                     active->devices.
+                                                     handles[j]);
                                        continue;
                                }
                                active->flags.enabled = 1;
@@ -667,9 +654,9 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
                        result = acpi_bus_set_power(active->devices.handles[j],
                                                    ACPI_STATE_D3);
                        if (result) {
-                               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                 "Unable to turn cooling device [%p] 'off'\n",
-                                                 active->devices.handles[j]));
+                               printk(KERN_WARNING PREFIX
+                                             "Unable to turn cooling device [%p] 'off'\n",
+                                             active->devices.handles[j]);
                                continue;
                        }
                        active->flags.enabled = 0;
@@ -697,18 +684,17 @@ static void acpi_thermal_check(void *data)
        int i = 0;
        struct acpi_thermal_state state;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_check");
 
        if (!tz) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
-               return_VOID;
+               printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
+               return;
        }
 
        state = tz->state;
 
        result = acpi_thermal_get_temperature(tz);
        if (result)
-               return_VOID;
+               return;
 
        memset(&tz->state, 0, sizeof(tz->state));
 
@@ -797,7 +783,7 @@ static void acpi_thermal_check(void *data)
                }
        }
 
-       return_VOID;
+       return;
 }
 
 /* --------------------------------------------------------------------------
@@ -810,7 +796,6 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show");
 
        if (!tz)
                goto end;
@@ -833,7 +818,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
        }
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
@@ -846,7 +831,6 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
        int result = 0;
        struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show");
 
        if (!tz)
                goto end;
@@ -859,7 +843,7 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
                   KELVIN_TO_CELSIUS(tz->temperature));
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
@@ -873,7 +857,6 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
        int i = 0;
        int j = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show");
 
        if (!tz)
                goto end;
@@ -913,7 +896,7 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
        }
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
@@ -934,28 +917,25 @@ acpi_thermal_write_trip_points(struct file *file,
        int *active;
        int i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
 
        limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
        if (!limit_string)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
 
        memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
 
        active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
        if (!active) {
                kfree(limit_string);
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        }
 
        if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
                count = -EINVAL;
                goto end;
        }
 
        if (copy_from_user(limit_string, buffer, count)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
                count = -EFAULT;
                goto end;
        }
@@ -968,7 +948,6 @@ acpi_thermal_write_trip_points(struct file *file,
                     &active[5], &active[6], &active[7], &active[8],
                     &active[9]);
        if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
                count = -EINVAL;
                goto end;
        }
@@ -985,14 +964,13 @@ acpi_thermal_write_trip_points(struct file *file,
       end:
        kfree(active);
        kfree(limit_string);
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show");
 
        if (!tz)
                goto end;
@@ -1008,7 +986,7 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
                           tz->cooling_mode ? "passive" : "active");
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
@@ -1027,16 +1005,15 @@ acpi_thermal_write_cooling_mode(struct file *file,
        int result = 0;
        char mode_string[12] = { '\0' };
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode");
 
        if (!tz || (count > sizeof(mode_string) - 1))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (!tz->flags.cooling_mode)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (copy_from_user(mode_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        mode_string[count] = '\0';
 
@@ -1044,18 +1021,17 @@ acpi_thermal_write_cooling_mode(struct file *file,
                                               simple_strtoul(mode_string, NULL,
                                                              0));
        if (result)
-               return_VALUE(result);
+               return result;
 
        acpi_thermal_check(tz);
 
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show");
 
        if (!tz)
                goto end;
@@ -1069,7 +1045,7 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
                   (tz->polling_frequency / 10));
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
@@ -1089,13 +1065,12 @@ acpi_thermal_write_polling(struct file *file,
        char polling_string[12] = { '\0' };
        int seconds = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_write_polling");
 
        if (!tz || (count > sizeof(polling_string) - 1))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(polling_string, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        polling_string[count] = '\0';
 
@@ -1103,24 +1078,23 @@ acpi_thermal_write_polling(struct file *file,
 
        result = acpi_thermal_set_polling(tz, seconds);
        if (result)
-               return_VALUE(result);
+               return result;
 
        acpi_thermal_check(tz);
 
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_thermal_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_thermal_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
 
@@ -1128,9 +1102,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
        entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_THERMAL_FILE_STATE));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_thermal_state_fops;
                entry->data = acpi_driver_data(device);
@@ -1141,9 +1113,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
        entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_THERMAL_FILE_TEMPERATURE));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_thermal_temp_fops;
                entry->data = acpi_driver_data(device);
@@ -1155,9 +1125,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_THERMAL_FILE_TRIP_POINTS));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_thermal_trip_fops;
                entry->data = acpi_driver_data(device);
@@ -1169,9 +1137,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_THERMAL_FILE_COOLING_MODE));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_thermal_cooling_fops;
                entry->data = acpi_driver_data(device);
@@ -1183,21 +1149,18 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
                                  S_IFREG | S_IRUGO | S_IWUSR,
                                  acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_THERMAL_FILE_POLLING_FREQ));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_thermal_polling_fops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_remove_fs(struct acpi_device *device)
 {
-       ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
 
        if (acpi_device_dir(device)) {
                remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
@@ -1214,7 +1177,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -1226,13 +1189,12 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_thermal *tz = (struct acpi_thermal *)data;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_notify");
 
        if (!tz)
-               return_VOID;
+               return;
 
        if (acpi_bus_get_device(tz->handle, &device))
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_THERMAL_NOTIFY_TEMPERATURE:
@@ -1254,27 +1216,26 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static int acpi_thermal_get_info(struct acpi_thermal *tz)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_get_info");
 
        if (!tz)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Get temperature [_TMP] (required) */
        result = acpi_thermal_get_temperature(tz);
        if (result)
-               return_VALUE(result);
+               return result;
 
        /* Get trip points [_CRT, _PSV, etc.] (required) */
        result = acpi_thermal_get_trip_points(tz);
        if (result)
-               return_VALUE(result);
+               return result;
 
        /* Set the cooling mode [_SCP] to active cooling (default) */
        result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
@@ -1314,7 +1275,7 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
        if (!result)
                tz->flags.devices = 1;
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_add(struct acpi_device *device)
@@ -1323,14 +1284,13 @@ static int acpi_thermal_add(struct acpi_device *device)
        acpi_status status = AE_OK;
        struct acpi_thermal *tz = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
        if (!tz)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(tz, 0, sizeof(struct acpi_thermal));
 
        tz->handle = device->handle;
@@ -1355,8 +1315,6 @@ static int acpi_thermal_add(struct acpi_device *device)
                                             ACPI_DEVICE_NOTIFY,
                                             acpi_thermal_notify, tz);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error installing notify handler\n"));
                result = -ENODEV;
                goto end;
        }
@@ -1371,7 +1329,7 @@ static int acpi_thermal_add(struct acpi_device *device)
                kfree(tz);
        }
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_thermal_remove(struct acpi_device *device, int type)
@@ -1379,10 +1337,9 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
        acpi_status status = AE_OK;
        struct acpi_thermal *tz = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        tz = (struct acpi_thermal *)acpi_driver_data(device);
 
@@ -1398,9 +1355,6 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
        status = acpi_remove_notify_handler(tz->handle,
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_thermal_notify);
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
 
        /* Terminate policy */
        if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
@@ -1416,7 +1370,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
        acpi_thermal_remove_fs(device);
 
        kfree(tz);
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_thermal_resume(struct acpi_device *device, int state)
@@ -1424,7 +1378,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state)
        struct acpi_thermal *tz = NULL;
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        tz = (struct acpi_thermal *)acpi_driver_data(device);
 
@@ -1437,31 +1391,29 @@ static int __init acpi_thermal_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_thermal_init");
 
        acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
        if (!acpi_thermal_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_thermal_dir->owner = THIS_MODULE;
 
        result = acpi_bus_register_driver(&acpi_thermal_driver);
        if (result < 0) {
                remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_thermal_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_thermal_exit");
 
        acpi_bus_unregister_driver(&acpi_thermal_driver);
 
        remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_thermal_init);
index 67b9f32..38ebe1c 100644 (file)
@@ -155,21 +155,30 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
        case ACPI_TYPE_MUTEX:
 
                ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
-                                 "***** Mutex %p, Semaphore %p\n",
-                                 object, object->mutex.semaphore));
+                                 "***** Mutex %p, OS Mutex %p\n",
+                                 object, object->mutex.os_mutex));
 
-               acpi_ex_unlink_mutex(object);
-               (void)acpi_os_delete_semaphore(object->mutex.semaphore);
+               if (object->mutex.os_mutex != ACPI_GLOBAL_LOCK) {
+                       acpi_ex_unlink_mutex(object);
+                       acpi_os_delete_mutex(object->mutex.os_mutex);
+               } else {
+                       /* Global Lock "mutex" is actually a counting semaphore */
+
+                       (void)
+                           acpi_os_delete_semaphore
+                           (acpi_gbl_global_lock_semaphore);
+                       acpi_gbl_global_lock_semaphore = NULL;
+               }
                break;
 
        case ACPI_TYPE_EVENT:
 
                ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
-                                 "***** Event %p, Semaphore %p\n",
-                                 object, object->event.semaphore));
+                                 "***** Event %p, OS Semaphore %p\n",
+                                 object, object->event.os_semaphore));
 
-               (void)acpi_os_delete_semaphore(object->event.semaphore);
-               object->event.semaphore = NULL;
+               (void)acpi_os_delete_semaphore(object->event.os_semaphore);
+               object->event.os_semaphore = NULL;
                break;
 
        case ACPI_TYPE_METHOD:
@@ -177,12 +186,13 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
                ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
                                  "***** Method %p\n", object));
 
-               /* Delete the method semaphore if it exists */
+               /* Delete the method mutex if it exists */
 
-               if (object->method.semaphore) {
-                       (void)acpi_os_delete_semaphore(object->method.
-                                                      semaphore);
-                       object->method.semaphore = NULL;
+               if (object->method.mutex) {
+                       acpi_os_delete_mutex(object->method.mutex->mutex.
+                                            os_mutex);
+                       acpi_ut_delete_object_desc(object->method.mutex);
+                       object->method.mutex = NULL;
                }
                break;
 
index e5999c6..014030a 100644 (file)
@@ -794,6 +794,7 @@ void acpi_ut_init_globals(void)
 
        /* Global Lock support */
 
+       acpi_gbl_global_lock_semaphore = NULL;
        acpi_gbl_global_lock_acquired = FALSE;
        acpi_gbl_global_lock_thread_count = 0;
        acpi_gbl_global_lock_handle = 0;
index 5c75d35..3326831 100644 (file)
@@ -41,6 +41,8 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
+
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
 
@@ -962,6 +964,7 @@ acpi_ut_exception(char *module_name,
        acpi_os_vprintf(format, args);
        acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
 }
+EXPORT_SYMBOL(acpi_ut_exception);
 
 void ACPI_INTERNAL_VAR_XFACE
 acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
index 25eb343..dfc8f30 100644 (file)
@@ -82,12 +82,9 @@ acpi_status acpi_ut_mutex_initialize(void)
 
        /* Create the spinlocks for use at interrupt level */
 
-       status = acpi_os_create_lock(&acpi_gbl_gpe_lock);
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
-       }
+       spin_lock_init(acpi_gbl_gpe_lock);
+       spin_lock_init(acpi_gbl_hardware_lock);
 
-       status = acpi_os_create_lock(&acpi_gbl_hardware_lock);
        return_ACPI_STATUS(status);
 }
 
@@ -146,9 +143,8 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
        }
 
        if (!acpi_gbl_mutex_info[mutex_id].mutex) {
-               status = acpi_os_create_semaphore(1, 1,
-                                                 &acpi_gbl_mutex_info
-                                                 [mutex_id].mutex);
+               status =
+                   acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
                acpi_gbl_mutex_info[mutex_id].thread_id =
                    ACPI_MUTEX_NOT_ACQUIRED;
                acpi_gbl_mutex_info[mutex_id].use_count = 0;
@@ -171,7 +167,6 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
 
 static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
 {
-       acpi_status status;
 
        ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
 
@@ -179,12 +174,12 @@ static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
-       status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex);
+       acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
 
        acpi_gbl_mutex_info[mutex_id].mutex = NULL;
        acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
 
-       return_ACPI_STATUS(status);
+       return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
@@ -251,8 +246,8 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
                          "Thread %X attempting to acquire Mutex [%s]\n",
                          this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
 
-       status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex,
-                                       1, ACPI_WAIT_FOREVER);
+       status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
+                                      ACPI_WAIT_FOREVER);
        if (ACPI_SUCCESS(status)) {
                ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
                                  "Thread %X acquired Mutex [%s]\n",
@@ -284,7 +279,6 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
 
 acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
 {
-       acpi_status status;
        acpi_thread_id this_thread_id;
 
        ACPI_FUNCTION_NAME(ut_release_mutex);
@@ -340,19 +334,6 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
 
        acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
 
-       status =
-           acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
-
-       if (ACPI_FAILURE(status)) {
-               ACPI_EXCEPTION((AE_INFO, status,
-                               "Thread %X could not release Mutex [%X]",
-                               this_thread_id, mutex_id));
-       } else {
-               ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
-                                 "Thread %X released Mutex [%s]\n",
-                                 this_thread_id,
-                                 acpi_ut_get_mutex_name(mutex_id)));
-       }
-
-       return (status);
+       acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
+       return (AE_OK);
 }
index 6b51685..1930e1a 100644 (file)
@@ -58,31 +58,29 @@ acpi_extract_package(union acpi_object *package,
        u8 *head = NULL;
        u8 *tail = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_extract_package");
 
        if (!package || (package->type != ACPI_TYPE_PACKAGE)
            || (package->package.count < 1)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Invalid 'package' argument\n"));
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               printk(KERN_WARNING PREFIX "Invalid package argument\n");
+               return AE_BAD_PARAMETER;
        }
 
        if (!format || !format->pointer || (format->length < 1)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n"));
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               printk(KERN_WARNING PREFIX "Invalid format argument\n");
+               return AE_BAD_PARAMETER;
        }
 
        if (!buffer) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n"));
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               printk(KERN_WARNING PREFIX "Invalid buffer argument\n");
+               return AE_BAD_PARAMETER;
        }
 
        format_count = (format->length / sizeof(char)) - 1;
        if (format_count > package->package.count) {
-               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                 "Format specifies more objects [%d] than exist in package [%d].",
-                                 format_count, package->package.count));
-               return_ACPI_STATUS(AE_BAD_DATA);
+               printk(KERN_WARNING PREFIX "Format specifies more objects [%d]"
+                             " than exist in package [%d].\n",
+                             format_count, package->package.count);
+               return AE_BAD_DATA;
        }
 
        format_string = (char *)format->pointer;
@@ -95,7 +93,7 @@ acpi_extract_package(union acpi_object *package,
                union acpi_object *element = &(package->package.elements[i]);
 
                if (!element) {
-                       return_ACPI_STATUS(AE_BAD_DATA);
+                       return AE_BAD_DATA;
                }
 
                switch (element->type) {
@@ -113,10 +111,11 @@ acpi_extract_package(union acpi_object *package,
                                tail_offset += sizeof(char *);
                                break;
                        default:
-                               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                 "Invalid package element [%d]: got number, expecing [%c].\n",
-                                                 i, format_string[i]));
-                               return_ACPI_STATUS(AE_BAD_DATA);
+                               printk(KERN_WARNING PREFIX "Invalid package element"
+                                             " [%d]: got number, expecing"
+                                             " [%c]\n",
+                                             i, format_string[i]);
+                               return AE_BAD_DATA;
                                break;
                        }
                        break;
@@ -138,10 +137,11 @@ acpi_extract_package(union acpi_object *package,
                                tail_offset += sizeof(u8 *);
                                break;
                        default:
-                               ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-                                                 "Invalid package element [%d] got string/buffer, expecing [%c].\n",
-                                                 i, format_string[i]));
-                               return_ACPI_STATUS(AE_BAD_DATA);
+                               printk(KERN_WARNING PREFIX "Invalid package element"
+                                             " [%d] got string/buffer,"
+                                             " expecing [%c]\n",
+                                             i, format_string[i]);
+                               return AE_BAD_DATA;
                                break;
                        }
                        break;
@@ -152,7 +152,7 @@ acpi_extract_package(union acpi_object *package,
                                          "Found unsupported element at index=%d\n",
                                          i));
                        /* TBD: handle nested packages... */
-                       return_ACPI_STATUS(AE_SUPPORT);
+                       return AE_SUPPORT;
                        break;
                }
        }
@@ -162,9 +162,9 @@ acpi_extract_package(union acpi_object *package,
         */
        if (buffer->length < size_required) {
                buffer->length = size_required;
-               return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
+               return AE_BUFFER_OVERFLOW;
        } else if (buffer->length != size_required || !buffer->pointer) {
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
        }
 
        head = buffer->pointer;
@@ -179,7 +179,7 @@ acpi_extract_package(union acpi_object *package,
                union acpi_object *element = &(package->package.elements[i]);
 
                if (!element) {
-                       return_ACPI_STATUS(AE_BAD_DATA);
+                       return AE_BAD_DATA;
                }
 
                switch (element->type) {
@@ -244,7 +244,7 @@ acpi_extract_package(union acpi_object *package,
                }
        }
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 EXPORT_SYMBOL(acpi_extract_package);
@@ -258,14 +258,13 @@ acpi_evaluate_integer(acpi_handle handle,
        union acpi_object *element;
        struct acpi_buffer buffer = { 0, NULL };
 
-       ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
 
        if (!data)
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
        if (!element)
-               return_ACPI_STATUS(AE_NO_MEMORY);
+               return AE_NO_MEMORY;
 
        memset(element, 0, sizeof(union acpi_object));
        buffer.length = sizeof(union acpi_object);
@@ -274,13 +273,13 @@ acpi_evaluate_integer(acpi_handle handle,
        if (ACPI_FAILURE(status)) {
                acpi_util_eval_error(handle, pathname, status);
                kfree(element);
-               return_ACPI_STATUS(status);
+               return status;
        }
 
        if (element->type != ACPI_TYPE_INTEGER) {
                acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
                kfree(element);
-               return_ACPI_STATUS(AE_BAD_DATA);
+               return AE_BAD_DATA;
        }
 
        *data = element->integer.value;
@@ -288,7 +287,7 @@ acpi_evaluate_integer(acpi_handle handle,
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 EXPORT_SYMBOL(acpi_evaluate_integer);
@@ -303,15 +302,14 @@ acpi_evaluate_string(acpi_handle handle,
        acpi_object *element = NULL;
        acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 
-       ACPI_FUNCTION_TRACE("acpi_evaluate_string");
 
        if (!data)
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
 
        status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
        if (ACPI_FAILURE(status)) {
                acpi_util_eval_error(handle, pathname, status);
-               return_ACPI_STATUS(status);
+               return status;
        }
 
        element = (acpi_object *) buffer.pointer;
@@ -320,13 +318,13 @@ acpi_evaluate_string(acpi_handle handle,
            || (element->type != ACPI_TYPE_BUFFER)
            || !element->string.length) {
                acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
-               return_ACPI_STATUS(AE_BAD_DATA);
+               return AE_BAD_DATA;
        }
 
        *data = kmalloc(element->string.length + 1, GFP_KERNEL);
        if (!data) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
-               return_VALUE(-ENOMEM);
+               printk(KERN_ERR PREFIX "Memory allocation\n");
+               return -ENOMEM;
        }
        memset(*data, 0, element->string.length + 1);
 
@@ -336,7 +334,7 @@ acpi_evaluate_string(acpi_handle handle,
 
        acpi_os_free(buffer.pointer);
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 #endif
 
@@ -352,10 +350,9 @@ acpi_evaluate_reference(acpi_handle handle,
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        u32 i = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
 
        if (!list) {
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
+               return AE_BAD_PARAMETER;
        }
 
        /* Evaluate object. */
@@ -367,32 +364,29 @@ acpi_evaluate_reference(acpi_handle handle,
        package = (union acpi_object *)buffer.pointer;
 
        if ((buffer.length == 0) || !package) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "No return object (len %X ptr %p)\n",
-                                 (unsigned)buffer.length, package));
+               printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n",
+                           (unsigned)buffer.length, package);
                status = AE_BAD_DATA;
                acpi_util_eval_error(handle, pathname, status);
                goto end;
        }
        if (package->type != ACPI_TYPE_PACKAGE) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Expecting a [Package], found type %X\n",
-                                 package->type));
+               printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n",
+                           package->type);
                status = AE_BAD_DATA;
                acpi_util_eval_error(handle, pathname, status);
                goto end;
        }
        if (!package->package.count) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "[Package] has zero elements (%p)\n",
-                                 package));
+               printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n",
+                           package);
                status = AE_BAD_DATA;
                acpi_util_eval_error(handle, pathname, status);
                goto end;
        }
 
        if (package->package.count > ACPI_MAX_HANDLES) {
-               return_ACPI_STATUS(AE_NO_MEMORY);
+               return AE_NO_MEMORY;
        }
        list->count = package->package.count;
 
@@ -404,9 +398,9 @@ acpi_evaluate_reference(acpi_handle handle,
 
                if (element->type != ACPI_TYPE_ANY) {
                        status = AE_BAD_DATA;
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Expecting a [Reference] package element, found type %X\n",
-                                         element->type));
+                       printk(KERN_ERR PREFIX
+                                   "Expecting a [Reference] package element, found type %X\n",
+                                   element->type);
                        acpi_util_eval_error(handle, pathname, status);
                        break;
                }
@@ -426,7 +420,7 @@ acpi_evaluate_reference(acpi_handle handle,
 
        acpi_os_free(buffer.pointer);
 
-       return_ACPI_STATUS(status);
+       return status;
 }
 
 EXPORT_SYMBOL(acpi_evaluate_reference);
index e7e9a69..9feb633 100644 (file)
@@ -272,10 +272,9 @@ static int
 acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
 {
        int status;
-       ACPI_FUNCTION_TRACE("acpi_video_device_query");
        status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -284,11 +283,10 @@ acpi_video_device_get_state(struct acpi_video_device *device,
 {
        int status;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
 
        status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -299,12 +297,11 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state)
        struct acpi_object_list args = { 1, &arg0 };
        unsigned long ret;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
 
        arg0.integer.value = state;
        status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -315,28 +312,27 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *obj;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
 
        *levels = NULL;
 
        status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
        if (!ACPI_SUCCESS(status))
-               return_VALUE(status);
+               return status;
        obj = (union acpi_object *)buffer.pointer;
        if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
+               printk(KERN_ERR PREFIX "Invalid _BCL data\n");
                status = -EFAULT;
                goto err;
        }
 
        *levels = obj;
 
-       return_VALUE(0);
+       return 0;
 
       err:
        kfree(buffer.pointer);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -346,13 +342,12 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list args = { 1, &arg0 };
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
 
        arg0.integer.value = level;
        status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
 
        printk(KERN_DEBUG "set_level status: %x\n", status);
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -360,11 +355,10 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
                                        unsigned long *level)
 {
        int status;
-       ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
 
        status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -377,34 +371,33 @@ acpi_video_device_EDID(struct acpi_video_device *device,
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list args = { 1, &arg0 };
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
 
        *edid = NULL;
 
        if (!device)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        if (length == 128)
                arg0.integer.value = 1;
        else if (length == 256)
                arg0.integer.value = 2;
        else
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
        if (ACPI_FAILURE(status))
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        obj = (union acpi_object *)buffer.pointer;
 
        if (obj && obj->type == ACPI_TYPE_BUFFER)
                *edid = obj;
        else {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n"));
+               printk(KERN_ERR PREFIX "Invalid _DDC data\n");
                status = -EFAULT;
                kfree(obj);
        }
 
-       return_VALUE(status);
+       return status;
 }
 
 /* bus */
@@ -417,7 +410,6 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list args = { 1, &arg0 };
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
 
        arg0.integer.value = option;
 
@@ -425,7 +417,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
        if (ACPI_SUCCESS(status))
                status = tmp ? (-EINVAL) : (AE_OK);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -433,11 +425,10 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
 {
        int status;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
 
        status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -445,12 +436,11 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
                            unsigned long *options)
 {
        int status;
-       ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
 
        status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
        *options &= 3;
 
-       return_VALUE(status);
+       return status;
 }
 
 /*
@@ -481,7 +471,6 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list args = { 1, &arg0 };
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
 
        if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
                status = -1;
@@ -492,7 +481,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
        acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
 
       Failed:
-       return_VALUE(status);
+       return status;
 }
 
 /*
@@ -514,7 +503,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
        union acpi_object *obj = NULL;
        struct acpi_video_device_brightness *br = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
 
        memset(&device->cap, 0, 4);
 
@@ -560,8 +548,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                                o = (union acpi_object *)&obj->package.
                                    elements[i];
                                if (o->type != ACPI_TYPE_INTEGER) {
-                                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                                         "Invalid data\n"));
+                                       printk(KERN_ERR PREFIX "Invalid data\n");
                                        continue;
                                }
                                br->levels[count] = (u32) o->integer.value;
@@ -583,7 +570,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 
        kfree(obj);
 
-       return_VOID;
+       return;
 }
 
 /*
@@ -630,10 +617,9 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
 {
        acpi_status status = -ENOENT;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_check");
 
        if (!video)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Since there is no HID, CID and so on for VGA driver, we have
         * to check well known required nodes.
@@ -657,7 +643,7 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
                status = 0;
        }
 
-       return_VALUE(status);
+       return status;
 }
 
 /* --------------------------------------------------------------------------
@@ -673,7 +659,6 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
        struct acpi_video_device *dev =
            (struct acpi_video_device *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
 
        if (!dev)
                goto end;
@@ -692,7 +677,7 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
        seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -709,7 +694,6 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
            (struct acpi_video_device *)seq->private;
        unsigned long state;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
 
        if (!dev)
                goto end;
@@ -729,7 +713,7 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
                seq_printf(seq, "<not supported>\n");
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -750,13 +734,12 @@ acpi_video_device_write_state(struct file *file,
        char str[12] = { 0 };
        u32 state = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
 
        if (!dev || count + 1 > sizeof str)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        str[count] = 0;
        state = simple_strtoul(str, NULL, 0);
@@ -765,9 +748,9 @@ acpi_video_device_write_state(struct file *file,
        status = acpi_video_device_set_state(dev, state);
 
        if (status)
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
-       return_VALUE(count);
+       return count;
 }
 
 static int
@@ -777,11 +760,10 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
            (struct acpi_video_device *)seq->private;
        int i;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
 
        if (!dev || !dev->brightness) {
                seq_printf(seq, "<not supported>\n");
-               return_VALUE(0);
+               return 0;
        }
 
        seq_printf(seq, "levels: ");
@@ -789,7 +771,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
                seq_printf(seq, " %d", dev->brightness->levels[i]);
        seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -810,19 +792,18 @@ acpi_video_device_write_brightness(struct file *file,
        unsigned int level = 0;
        int i;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
 
        if (!dev || !dev->brightness || count + 1 > sizeof str)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        str[count] = 0;
        level = simple_strtoul(str, NULL, 0);
 
        if (level > 100)
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        /* validate though the list of available levels */
        for (i = 0; i < dev->brightness->count; i++)
@@ -833,7 +814,7 @@ acpi_video_device_write_brightness(struct file *file,
                        break;
                }
 
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
@@ -844,7 +825,6 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
        int i;
        union acpi_object *edid = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
 
        if (!dev)
                goto out;
@@ -869,7 +849,7 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
        else
                kfree(edid);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -884,28 +864,26 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
        struct proc_dir_entry *entry = NULL;
        struct acpi_video_device *vid_dev;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
 
        if (!device)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
        if (!vid_dev)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     vid_dev->video->dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
 
        /* 'info' [R] */
        entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'info' fs entry\n"));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_video_device_info_fops;
                entry->data = acpi_driver_data(device);
@@ -917,8 +895,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
            create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
                              acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'state' fs entry\n"));
+               return -ENODEV;
        else {
                acpi_video_device_state_fops.write = acpi_video_device_write_state;
                entry->proc_fops = &acpi_video_device_state_fops;
@@ -931,8 +908,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
            create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
                              acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'brightness' fs entry\n"));
+               return -ENODEV;
        else {
                acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
                entry->proc_fops = &acpi_video_device_brightness_fops;
@@ -943,25 +919,23 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
        /* 'EDID' [R] */
        entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'brightness' fs entry\n"));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_video_device_EDID_fops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_device_remove_fs(struct acpi_device *device)
 {
        struct acpi_video_device *vid_dev;
-       ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
 
        vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
        if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
 
        if (acpi_device_dir(device)) {
                remove_proc_entry("info", acpi_device_dir(device));
@@ -972,7 +946,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* video bus */
@@ -980,7 +954,6 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
 
        if (!video)
                goto end;
@@ -993,7 +966,7 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
                   video->flags.post ? "yes" : "no");
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
@@ -1006,7 +979,6 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
 
        if (!video)
                goto end;
@@ -1015,7 +987,7 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
        seq_printf(seq, "<TODO>\n");
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
@@ -1029,7 +1001,6 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
        unsigned long options;
        int status;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
 
        if (!video)
                goto end;
@@ -1052,7 +1023,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
        } else
                seq_printf(seq, "<not supported>\n");
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -1068,7 +1039,6 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
        int status;
        unsigned long id;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
 
        if (!video)
                goto end;
@@ -1081,18 +1051,17 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
        seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
 
       end:
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
 {
        struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
 
        seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
@@ -1117,22 +1086,21 @@ acpi_video_bus_write_POST(struct file *file,
        char str[12] = { 0 };
        unsigned long opt, options;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
 
        if (!video || count + 1 > sizeof str)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status = acpi_video_bus_POST_options(video, &options);
        if (!ACPI_SUCCESS(status))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        str[count] = 0;
        opt = strtoul(str, NULL, 0);
        if (opt > 3)
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        /* just in case an OEM 'forget' the motherboard... */
        options |= 1;
@@ -1140,11 +1108,11 @@ acpi_video_bus_write_POST(struct file *file,
        if (options & (1ul << opt)) {
                status = acpi_video_bus_set_POST(video, opt);
                if (!ACPI_SUCCESS(status))
-                       return_VALUE(-EFAULT);
+                       return -EFAULT;
 
        }
 
-       return_VALUE(count);
+       return count;
 }
 
 static ssize_t
@@ -1158,25 +1126,24 @@ acpi_video_bus_write_DOS(struct file *file,
        char str[12] = { 0 };
        unsigned long opt;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
 
        if (!video || count + 1 > sizeof str)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        str[count] = 0;
        opt = strtoul(str, NULL, 0);
        if (opt > 7)
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
        status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
 
        if (!ACPI_SUCCESS(status))
-               return_VALUE(-EFAULT);
+               return -EFAULT;
 
-       return_VALUE(count);
+       return count;
 }
 
 static int acpi_video_bus_add_fs(struct acpi_device *device)
@@ -1184,7 +1151,6 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
        struct proc_dir_entry *entry = NULL;
        struct acpi_video_bus *video;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
 
        video = (struct acpi_video_bus *)acpi_driver_data(device);
 
@@ -1192,7 +1158,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
                                                     acpi_video_dir);
                if (!acpi_device_dir(device))
-                       return_VALUE(-ENODEV);
+                       return -ENODEV;
                video->dir = acpi_device_dir(device);
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
@@ -1200,8 +1166,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
        /* 'info' [R] */
        entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'info' fs entry\n"));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_video_bus_info_fops;
                entry->data = acpi_driver_data(device);
@@ -1211,8 +1176,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
        /* 'ROM' [R] */
        entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'ROM' fs entry\n"));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_video_bus_ROM_fops;
                entry->data = acpi_driver_data(device);
@@ -1223,8 +1187,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
        entry =
            create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'POST_info' fs entry\n"));
+               return -ENODEV;
        else {
                entry->proc_fops = &acpi_video_bus_POST_info_fops;
                entry->data = acpi_driver_data(device);
@@ -1236,8 +1199,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
            create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
                              acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'POST' fs entry\n"));
+               return -ENODEV;
        else {
                acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
                entry->proc_fops = &acpi_video_bus_POST_fops;
@@ -1250,8 +1212,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
            create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
                              acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create 'DOS' fs entry\n"));
+               return -ENODEV;
        else {
                acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
                entry->proc_fops = &acpi_video_bus_DOS_fops;
@@ -1259,14 +1220,13 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
                entry->owner = THIS_MODULE;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_bus_remove_fs(struct acpi_device *device)
 {
        struct acpi_video_bus *video;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
 
        video = (struct acpi_video_bus *)acpi_driver_data(device);
 
@@ -1280,7 +1240,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device)
                acpi_device_dir(device) = NULL;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* --------------------------------------------------------------------------
@@ -1297,10 +1257,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
        int status;
        struct acpi_video_device *data;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
 
        if (!device || !video)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        status =
            acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
@@ -1308,7 +1267,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
 
                data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
                if (!data)
-                       return_VALUE(-ENOMEM);
+                       return -ENOMEM;
 
                memset(data, 0, sizeof(struct acpi_video_device));
 
@@ -1359,10 +1318,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
 
                acpi_video_device_add_fs(device);
 
-               return_VALUE(0);
+               return 0;
        }
 
-       return_VALUE(-ENOENT);
+       return -ENOENT;
 }
 
 /*
@@ -1405,7 +1364,6 @@ acpi_video_device_bind(struct acpi_video_bus *video,
                       struct acpi_video_device *device)
 {
        int i;
-       ACPI_FUNCTION_TRACE("acpi_video_device_bind");
 
 #define IDS_VAL(i) video->attached_array[i].value.int_val
 #define IDS_BIND(i) video->attached_array[i].bind_info
@@ -1442,17 +1400,16 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
        union acpi_object *dod = NULL;
        union acpi_object *obj;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
 
        status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
        if (!ACPI_SUCCESS(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n"));
-               return_VALUE(status);
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
+               return status;
        }
 
        dod = (union acpi_object *)buffer.pointer;
        if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
+               ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
                status = -EFAULT;
                goto out;
        }
@@ -1476,8 +1433,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
                obj = (union acpi_object *)&dod->package.elements[i];
 
                if (obj->type != ACPI_TYPE_INTEGER) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Invalid _DOD data\n"));
+                       printk(KERN_ERR PREFIX "Invalid _DOD data\n");
                        active_device_list[i].value.int_val =
                            ACPI_VIDEO_HEAD_INVALID;
                }
@@ -1495,7 +1451,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
        video->attached_count = count;
       out:
        acpi_os_free(buffer.pointer);
-       return_VALUE(status);
+       return status;
 }
 
 /*
@@ -1520,7 +1476,6 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
        unsigned long state;
        int status = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_video_switch_output");
 
        list_for_each_safe(node, next, &video->video_device_list) {
                dev = container_of(node, struct acpi_video_device, entry);
@@ -1551,7 +1506,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
                break;
        }
 
-       return_VALUE(status);
+       return status;
 }
 
 static int
@@ -1578,7 +1533,6 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
        int status = 0;
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_video_get_devices");
 
        acpi_video_device_enumerate(video);
 
@@ -1591,13 +1545,12 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
 
                status = acpi_video_bus_get_one_device(dev, video);
                if (ACPI_FAILURE(status)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Cant attach device\n"));
+                       ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
                        continue;
                }
 
        }
-       return_VALUE(status);
+       return status;
 }
 
 static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
@@ -1605,10 +1558,9 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
        acpi_status status;
        struct acpi_video_bus *video;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
 
        if (!device || !device->video)
-               return_VALUE(-ENOENT);
+               return -ENOENT;
 
        video = device->video;
 
@@ -1620,11 +1572,8 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
        status = acpi_remove_notify_handler(device->handle,
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_video_device_notify);
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
@@ -1632,7 +1581,6 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
        int status;
        struct list_head *node, *next;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
 
        list_for_each_safe(node, next, &video->video_device_list) {
                struct acpi_video_device *data =
@@ -1651,7 +1599,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
                kfree(data);
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 /* acpi_video interface */
@@ -1671,14 +1619,13 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_video_bus *video = (struct acpi_video_bus *)data;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
        printk("video bus notify\n");
 
        if (!video)
-               return_VOID;
+               return;
 
        if (acpi_bus_get_device(handle, &device))
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_VIDEO_NOTIFY_SWITCH:  /* User request that a switch occur,
@@ -1707,7 +1654,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       return_VOID;
+       return;
 }
 
 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
@@ -1716,14 +1663,13 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
            (struct acpi_video_device *)data;
        struct acpi_device *device = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_video_device_notify");
 
        printk("video device notify\n");
        if (!video_device)
-               return_VOID;
+               return;
 
        if (acpi_bus_get_device(handle, &device))
-               return_VOID;
+               return;
 
        switch (event) {
        case ACPI_VIDEO_NOTIFY_SWITCH:  /* change in status (cycle output device) */
@@ -1743,7 +1689,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
                                  "Unsupported event [0x%x]\n", event));
                break;
        }
-       return_VOID;
+       return;
 }
 
 static int acpi_video_bus_add(struct acpi_device *device)
@@ -1752,14 +1698,13 @@ static int acpi_video_bus_add(struct acpi_device *device)
        acpi_status status = 0;
        struct acpi_video_bus *video = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_add");
 
        if (!device)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
        if (!video)
-               return_VALUE(-ENOMEM);
+               return -ENOMEM;
        memset(video, 0, sizeof(struct acpi_video_bus));
 
        video->handle = device->handle;
@@ -1806,7 +1751,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
        if (result)
                kfree(video);
 
-       return_VALUE(result);
+       return result;
 }
 
 static int acpi_video_bus_remove(struct acpi_device *device, int type)
@@ -1814,10 +1759,9 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
        acpi_status status = 0;
        struct acpi_video_bus *video = NULL;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
 
        if (!device || !acpi_driver_data(device))
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        video = (struct acpi_video_bus *)acpi_driver_data(device);
 
@@ -1826,9 +1770,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
        status = acpi_remove_notify_handler(video->handle,
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_video_bus_notify);
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Error removing notify handler\n"));
 
        acpi_video_bus_put_devices(video);
        acpi_video_bus_remove_fs(device);
@@ -1836,7 +1777,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
        kfree(video->attached_array);
        kfree(video);
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int
@@ -1846,10 +1787,9 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
        acpi_handle h_dummy2;
        acpi_handle h_dummy3;
 
-       ACPI_FUNCTION_TRACE("acpi_video_bus_match");
 
        if (!device || !driver)
-               return_VALUE(-EINVAL);
+               return -EINVAL;
 
        /* Since there is no HID, CID for ACPI Video drivers, we have
         * to check well known required nodes for each feature we support.
@@ -1858,26 +1798,25 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
        /* Does this device able to support video switching ? */
        if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
            ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
-               return_VALUE(0);
+               return 0;
 
        /* Does this device able to retrieve a video ROM ? */
        if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
-               return_VALUE(0);
+               return 0;
 
        /* Does this device able to configure which video head to be POSTed ? */
        if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
            ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
            ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
-               return_VALUE(0);
+               return 0;
 
-       return_VALUE(-ENODEV);
+       return -ENODEV;
 }
 
 static int __init acpi_video_init(void)
 {
        int result = 0;
 
-       ACPI_FUNCTION_TRACE("acpi_video_init");
 
        /*
           acpi_dbg_level = 0xFFFFFFFF;
@@ -1886,27 +1825,26 @@ static int __init acpi_video_init(void)
 
        acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
        if (!acpi_video_dir)
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        acpi_video_dir->owner = THIS_MODULE;
 
        result = acpi_bus_register_driver(&acpi_video_bus);
        if (result < 0) {
                remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
-       return_VALUE(0);
+       return 0;
 }
 
 static void __exit acpi_video_exit(void)
 {
-       ACPI_FUNCTION_TRACE("acpi_video_exit");
 
        acpi_bus_unregister_driver(&acpi_video_bus);
 
        remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_video_init);
index eae2bdc..d7de175 100644 (file)
@@ -40,24 +40,13 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
        int n;
        int nid = dev->id;
        struct sysinfo i;
-       struct page_state ps;
        unsigned long inactive;
        unsigned long active;
        unsigned long free;
 
        si_meminfo_node(&i, nid);
-       get_page_state_node(&ps, nid);
        __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
 
-       /* Check for negative values in these approximate counters */
-       if ((long)ps.nr_dirty < 0)
-               ps.nr_dirty = 0;
-       if ((long)ps.nr_writeback < 0)
-               ps.nr_writeback = 0;
-       if ((long)ps.nr_mapped < 0)
-               ps.nr_mapped = 0;
-       if ((long)ps.nr_slab < 0)
-               ps.nr_slab = 0;
 
        n = sprintf(buf, "\n"
                       "Node %d MemTotal:     %8lu kB\n"
@@ -71,7 +60,12 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       "Node %d LowFree:      %8lu kB\n"
                       "Node %d Dirty:        %8lu kB\n"
                       "Node %d Writeback:    %8lu kB\n"
+                      "Node %d FilePages:    %8lu kB\n"
                       "Node %d Mapped:       %8lu kB\n"
+                      "Node %d AnonPages:    %8lu kB\n"
+                      "Node %d PageTables:   %8lu kB\n"
+                      "Node %d NFS Unstable: %8lu kB\n"
+                      "Node %d Bounce:       %8lu kB\n"
                       "Node %d Slab:         %8lu kB\n",
                       nid, K(i.totalram),
                       nid, K(i.freeram),
@@ -82,10 +76,15 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       nid, K(i.freehigh),
                       nid, K(i.totalram - i.totalhigh),
                       nid, K(i.freeram - i.freehigh),
-                      nid, K(ps.nr_dirty),
-                      nid, K(ps.nr_writeback),
-                      nid, K(ps.nr_mapped),
-                      nid, K(ps.nr_slab));
+                      nid, K(node_page_state(nid, NR_FILE_DIRTY)),
+                      nid, K(node_page_state(nid, NR_WRITEBACK)),
+                      nid, K(node_page_state(nid, NR_FILE_PAGES)),
+                      nid, K(node_page_state(nid, NR_FILE_MAPPED)),
+                      nid, K(node_page_state(nid, NR_ANON_PAGES)),
+                      nid, K(node_page_state(nid, NR_PAGETABLE)),
+                      nid, K(node_page_state(nid, NR_UNSTABLE_NFS)),
+                      nid, K(node_page_state(nid, NR_BOUNCE)),
+                      nid, K(node_page_state(nid, NR_SLAB)));
        n += hugetlb_report_node_meminfo(nid, buf + n);
        return n;
 }
@@ -95,28 +94,6 @@ static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
 
 static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
 {
-       unsigned long numa_hit, numa_miss, interleave_hit, numa_foreign;
-       unsigned long local_node, other_node;
-       int i, cpu;
-       pg_data_t *pg = NODE_DATA(dev->id);
-       numa_hit = 0;
-       numa_miss = 0;
-       interleave_hit = 0;
-       numa_foreign = 0;
-       local_node = 0;
-       other_node = 0;
-       for (i = 0; i < MAX_NR_ZONES; i++) {
-               struct zone *z = &pg->node_zones[i];
-               for_each_online_cpu(cpu) {
-                       struct per_cpu_pageset *ps = zone_pcp(z,cpu);
-                       numa_hit += ps->numa_hit;
-                       numa_miss += ps->numa_miss;
-                       numa_foreign += ps->numa_foreign;
-                       interleave_hit += ps->interleave_hit;
-                       local_node += ps->local_node;
-                       other_node += ps->other_node;
-               }
-       }
        return sprintf(buf,
                       "numa_hit %lu\n"
                       "numa_miss %lu\n"
@@ -124,12 +101,12 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
                       "interleave_hit %lu\n"
                       "local_node %lu\n"
                       "other_node %lu\n",
-                      numa_hit,
-                      numa_miss,
-                      numa_foreign,
-                      interleave_hit,
-                      local_node,
-                      other_node);
+                      node_page_state(dev->id, NUMA_HIT),
+                      node_page_state(dev->id, NUMA_MISS),
+                      node_page_state(dev->id, NUMA_FOREIGN),
+                      node_page_state(dev->id, NUMA_INTERLEAVE_HIT),
+                      node_page_state(dev->id, NUMA_LOCAL),
+                      node_page_state(dev->id, NUMA_OTHER));
 }
 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
 
index 4ee2886..9b05ddd 100644 (file)
@@ -914,7 +914,7 @@ static void seek(int lba)
        cd->dsb = wait_dsb();
 }
 
-uch bcdbin(unsigned char bcd)
+static uch bcdbin(unsigned char bcd)
 {                              /* stolen from mcd.c! */
        return (bcd >> 4) * 10 + (bcd & 0xf);
 }
@@ -1532,7 +1532,7 @@ static void __init parse_options(void)
        }
 }
 
-static int __cm206_init(void)
+static int __init __cm206_init(void)
 {
        parse_options();
 #if !defined(AUTO_PROBE_MODULE)
@@ -1593,8 +1593,3 @@ __setup("cm206=", cm206_setup);
 #endif                         /* !MODULE */
 MODULE_ALIAS_BLOCKDEV_MAJOR(CM206_CDROM_MAJOR);
 
-/*
- * Local variables:
- * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -m486 -DMODULE -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h  -c -o cm206.o cm206.c"
- * End:
- */
index c86a718..fbce2f0 100644 (file)
@@ -281,7 +281,6 @@ static char *stli_brdnames[] = {
 
 /*****************************************************************************/
 
-#ifdef MODULE
 /*
  *     Define some string labels for arguments passed from the module
  *     load line. These allow for easy board definitions, and easy
@@ -380,8 +379,6 @@ MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]");
 module_param_array(board3, charp, NULL, 0);
 MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]");
 
-#endif
-
 /*
  *     Set up a default memory address table for EISA board probing.
  *     The default addresses are all bellow 1Mbyte, which has to be the
@@ -642,14 +639,8 @@ static unsigned int        stli_baudrates[] = {
  *     Prototype all functions in this driver!
  */
 
-#ifdef MODULE
-static void    stli_argbrds(void);
 static int     stli_parsebrd(stlconf_t *confp, char **argp);
-
-static unsigned long   stli_atol(char *str);
-#endif
-
-int            stli_init(void);
+static int     stli_init(void);
 static int     stli_open(struct tty_struct *tty, struct file *filp);
 static void    stli_close(struct tty_struct *tty, struct file *filp);
 static int     stli_write(struct tty_struct *tty, const unsigned char *buf, int count);
@@ -785,8 +776,6 @@ static int  stli_timeron;
 
 static struct class *istallion_class;
 
-#ifdef MODULE
-
 /*
  *     Loadable module initialization stuff.
  */
@@ -953,8 +942,6 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
        return(1);
 }
 
-#endif
-
 /*****************************************************************************/
 
 static int stli_open(struct tty_struct *tty, struct file *filp)
@@ -4693,7 +4680,7 @@ static struct tty_operations stli_ops = {
 
 /*****************************************************************************/
 
-int __init stli_init(void)
+static int __init stli_init(void)
 {
        int i;
        printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
index 1c706cc..c860de6 100644 (file)
@@ -319,9 +319,10 @@ static int __init pc8736x_gpio_init(void)
        return 0;
 
 undo_platform_dev_add:
-       platform_device_put(pdev);
+       platform_device_del(pdev);
 undo_platform_dev_alloc:
-       kfree(pdev);
+       platform_device_put(pdev);
+
        return rc;
 }
 
index eab5394..31c8a21 100644 (file)
@@ -149,12 +149,7 @@ struct cm4000_dev {
 #define        ZERO_DEV(dev)                                           \
        memset(&dev->atr_csum,0,                                \
                sizeof(struct cm4000_dev) -                     \
-               /*link*/ sizeof(struct pcmcia_device *) -       \
-               /*node*/ sizeof(dev_node_t) -                   \
-               /*atr*/ MAX_ATR*sizeof(char) -                  \
-               /*rbuf*/ 512*sizeof(char) -                     \
-               /*sbuf*/ 512*sizeof(char) -                     \
-               /*queue*/ 4*sizeof(wait_queue_head_t))
+               offsetof(struct cm4000_dev, atr_csum))
 
 static struct pcmcia_device *dev_table[CM4000_MAX_DEV];
 static struct class *cmm_class;
index 5a280a3..45083e5 100644 (file)
@@ -126,9 +126,10 @@ static int __init scx200_gpio_init(void)
 undo_chrdev_region:
        unregister_chrdev_region(dev, num_pins);
 undo_platform_device_add:
-       platform_device_put(pdev);
+       platform_device_del(pdev);
 undo_malloc:
-       kfree(pdev);
+       platform_device_put(pdev);
+
        return rc;
 }
 
@@ -136,7 +137,6 @@ static void __exit scx200_gpio_cleanup(void)
 {
        kfree(scx200_devices);
        unregister_chrdev_region(MKDEV(major, 0), num_pins);
-       platform_device_put(pdev);
        platform_device_unregister(pdev);
        /* kfree(pdev); */
 }
index 35599ed..d75864e 100644 (file)
@@ -19,6 +19,9 @@
 #include <linux/slab.h>
 #include "edac_mc.h"
 
+#define AMD76X_REVISION        " Ver: 2.0.0 "  __DATE__
+
+
 #define amd76x_printk(level, fmt, arg...) \
        edac_printk(level, "amd76x", fmt, ##arg)
 
@@ -101,15 +104,18 @@ static const struct amd76x_dev_info amd76x_devs[] = {
 static void amd76x_get_error_info(struct mem_ctl_info *mci,
                struct amd76x_error_info *info)
 {
-       pci_read_config_dword(mci->pdev, AMD76X_ECC_MODE_STATUS,
+       struct pci_dev *pdev;
+
+       pdev = to_pci_dev(mci->dev);
+       pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS,
                                &info->ecc_mode_status);
 
        if (info->ecc_mode_status & BIT(8))
-               pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS,
+               pci_write_bits32(pdev, AMD76X_ECC_MODE_STATUS,
                                (u32) BIT(8), (u32) BIT(8));
 
        if (info->ecc_mode_status & BIT(9))
-               pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS,
+               pci_write_bits32(pdev, AMD76X_ECC_MODE_STATUS,
                                (u32) BIT(9), (u32) BIT(9));
 }
 
@@ -175,6 +181,38 @@ static void amd76x_check(struct mem_ctl_info *mci)
        amd76x_process_error_info(mci, &info, 1);
 }
 
+static void amd76x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
+               enum edac_type edac_mode)
+{
+       struct csrow_info *csrow;
+       u32 mba, mba_base, mba_mask, dms;
+       int index;
+
+       for (index = 0; index < mci->nr_csrows; index++) {
+               csrow = &mci->csrows[index];
+
+               /* find the DRAM Chip Select Base address and mask */
+               pci_read_config_dword(pdev,
+                                     AMD76X_MEM_BASE_ADDR + (index * 4),
+                                     &mba);
+
+               if (!(mba & BIT(0)))
+                       continue;
+
+               mba_base = mba & 0xff800000UL;
+               mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
+               pci_read_config_dword(pdev, AMD76X_DRAM_MODE_STATUS, &dms);
+               csrow->first_page = mba_base >> PAGE_SHIFT;
+               csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
+               csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
+               csrow->page_mask = mba_mask >> PAGE_SHIFT;
+               csrow->grain = csrow->nr_pages << PAGE_SHIFT;
+               csrow->mtype = MEM_RDDR;
+               csrow->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
+               csrow->edac_mode = edac_mode;
+       }
+}
+
 /**
  *     amd76x_probe1   -       Perform set up for detected device
  *     @pdev; PCI device detected
@@ -186,15 +224,13 @@ static void amd76x_check(struct mem_ctl_info *mci)
  */
 static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
 {
-       int rc = -ENODEV;
-       int index;
-       struct mem_ctl_info *mci = NULL;
-       enum edac_type ems_modes[] = {
+       static const enum edac_type ems_modes[] = {
                EDAC_NONE,
                EDAC_EC,
                EDAC_SECDED,
                EDAC_SECDED
        };
+       struct mem_ctl_info *mci = NULL;
        u32 ems;
        u32 ems_mode;
        struct amd76x_error_info discard;
@@ -205,53 +241,28 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
        mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS);
 
        if (mci == NULL) {
-               rc = -ENOMEM;
-               goto fail;
+               return -ENOMEM;
        }
 
        debugf0("%s(): mci = %p\n", __func__, mci);
-       mci->pdev = pdev;
+       mci->dev = &pdev->dev;
        mci->mtype_cap = MEM_FLAG_RDDR;
        mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
        mci->edac_cap = ems_mode ?
                        (EDAC_FLAG_EC | EDAC_FLAG_SECDED) : EDAC_FLAG_NONE;
        mci->mod_name = EDAC_MOD_STR;
-       mci->mod_ver = "$Revision: 1.4.2.5 $";
+       mci->mod_ver = AMD76X_REVISION;
        mci->ctl_name = amd76x_devs[dev_idx].ctl_name;
        mci->edac_check = amd76x_check;
        mci->ctl_page_to_phys = NULL;
 
-       for (index = 0; index < mci->nr_csrows; index++) {
-               struct csrow_info *csrow = &mci->csrows[index];
-               u32 mba;
-               u32 mba_base;
-               u32 mba_mask;
-               u32 dms;
-
-               /* find the DRAM Chip Select Base address and mask */
-               pci_read_config_dword(mci->pdev,
-                               AMD76X_MEM_BASE_ADDR + (index * 4), &mba);
-
-               if (!(mba & BIT(0)))
-                       continue;
-
-               mba_base = mba & 0xff800000UL;
-               mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
-               pci_read_config_dword(mci->pdev, AMD76X_DRAM_MODE_STATUS,
-                               &dms);
-               csrow->first_page = mba_base >> PAGE_SHIFT;
-               csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
-               csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
-               csrow->page_mask = mba_mask >> PAGE_SHIFT;
-               csrow->grain = csrow->nr_pages << PAGE_SHIFT;
-               csrow->mtype = MEM_RDDR;
-               csrow->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
-               csrow->edac_mode = ems_modes[ems_mode];
-       }
-
+       amd76x_init_csrows(mci, pdev, ems_modes[ems_mode]);
        amd76x_get_error_info(mci, &discard);  /* clear counters */
 
-       if (edac_mc_add_mc(mci)) {
+       /* Here we assume that we will never see multiple instances of this
+        * type of memory controller.  The ID is therefore hardcoded to 0.
+        */
+       if (edac_mc_add_mc(mci,0)) {
                debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
                goto fail;
        }
@@ -261,9 +272,8 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
        return 0;
 
 fail:
-       if (mci != NULL)
-               edac_mc_free(mci);
-       return rc;
+       edac_mc_free(mci);
+       return -ENODEV;
 }
 
 /* returns count (>= 0), or negative on error */
@@ -290,7 +300,7 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
-       if ((mci = edac_mc_del_mc(pdev)) == NULL)
+       if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
        edac_mc_free(mci);
index a52573b..815c3eb 100644 (file)
@@ -24,6 +24,8 @@
 #include <linux/slab.h>
 #include "edac_mc.h"
 
+#define E752X_REVISION " Ver: 2.0.0 " __DATE__
+
 static int force_function_unhide;
 
 #define e752x_printk(level, fmt, arg...) \
@@ -762,22 +764,174 @@ static void e752x_check(struct mem_ctl_info *mci)
        e752x_process_error_info(mci, &info, 1);
 }
 
-static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
+/* Return 1 if dual channel mode is active.  Else return 0. */
+static inline int dual_channel_active(u16 ddrcsr)
+{
+       return (((ddrcsr >> 12) & 3) == 3);
+}
+
+static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
+               u16 ddrcsr)
+{
+       struct csrow_info *csrow;
+       unsigned long last_cumul_size;
+       int index, mem_dev, drc_chan;
+       int drc_drbg;  /* DRB granularity 0=64mb, 1=128mb */
+       int drc_ddim;  /* DRAM Data Integrity Mode 0=none, 2=edac */
+       u8 value;
+       u32 dra, drc, cumul_size;
+
+       pci_read_config_dword(pdev, E752X_DRA, &dra);
+       pci_read_config_dword(pdev, E752X_DRC, &drc);
+       drc_chan = dual_channel_active(ddrcsr);
+       drc_drbg = drc_chan + 1;  /* 128 in dual mode, 64 in single */
+       drc_ddim = (drc >> 20) & 0x3;
+
+       /* The dram row boundary (DRB) reg values are boundary address for
+        * each DRAM row with a granularity of 64 or 128MB (single/dual
+        * channel operation).  DRB regs are cumulative; therefore DRB7 will
+        * contain the total memory contained in all eight rows.
+        */
+       for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
+               /* mem_dev 0=x8, 1=x4 */
+               mem_dev = (dra >> (index * 4 + 2)) & 0x3;
+               csrow = &mci->csrows[index];
+
+               mem_dev = (mem_dev == 2);
+               pci_read_config_byte(pdev, E752X_DRB + index, &value);
+               /* convert a 128 or 64 MiB DRB to a page size. */
+               cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
+               debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
+                       cumul_size);
+               if (cumul_size == last_cumul_size)
+                       continue;       /* not populated */
+
+               csrow->first_page = last_cumul_size;
+               csrow->last_page = cumul_size - 1;
+               csrow->nr_pages = cumul_size - last_cumul_size;
+               last_cumul_size = cumul_size;
+               csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
+               csrow->mtype = MEM_RDDR;        /* only one type supported */
+               csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
+
+               /*
+                * if single channel or x8 devices then SECDED
+                * if dual channel and x4 then S4ECD4ED
+                */
+               if (drc_ddim) {
+                       if (drc_chan && mem_dev) {
+                               csrow->edac_mode = EDAC_S4ECD4ED;
+                               mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
+                       } else {
+                               csrow->edac_mode = EDAC_SECDED;
+                               mci->edac_cap |= EDAC_FLAG_SECDED;
+                       }
+               } else
+                       csrow->edac_mode = EDAC_NONE;
+       }
+}
+
+static void e752x_init_mem_map_table(struct pci_dev *pdev,
+               struct e752x_pvt *pvt)
 {
-       int rc = -ENODEV;
        int index;
+       u8 value, last, row, stat8;
+
+       last = 0;
+       row = 0;
+
+       for (index = 0; index < 8; index += 2) {
+               pci_read_config_byte(pdev, E752X_DRB + index, &value);
+               /* test if there is a dimm in this slot */
+               if (value == last) {
+                       /* no dimm in the slot, so flag it as empty */
+                       pvt->map[index] = 0xff;
+                       pvt->map[index + 1] = 0xff;
+               } else {        /* there is a dimm in the slot */
+                       pvt->map[index] = row;
+                       row++;
+                       last = value;
+                       /* test the next value to see if the dimm is double
+                        * sided
+                        */
+                       pci_read_config_byte(pdev, E752X_DRB + index + 1,
+                                            &value);
+                       pvt->map[index + 1] = (value == last) ?
+                           0xff :      /* the dimm is single sided,
+                                          so flag as empty */
+                           row;        /* this is a double sided dimm
+                                          to save the next row # */
+                       row++;
+                       last = value;
+               }
+       }
+
+       /* set the map type.  1 = normal, 0 = reversed */
+       pci_read_config_byte(pdev, E752X_DRM, &stat8);
+       pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
+}
+
+/* Return 0 on success or 1 on failure. */
+static int e752x_get_devs(struct pci_dev *pdev, int dev_idx,
+               struct e752x_pvt *pvt)
+{
+       struct pci_dev *dev;
+
+       pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
+                                       pvt->dev_info->err_dev,
+                                       pvt->bridge_ck);
+
+       if (pvt->bridge_ck == NULL)
+               pvt->bridge_ck = pci_scan_single_device(pdev->bus,
+                                                       PCI_DEVFN(0, 1));
+
+       if (pvt->bridge_ck == NULL) {
+               e752x_printk(KERN_ERR, "error reporting device not found:"
+                      "vendor %x device 0x%x (broken BIOS?)\n",
+                      PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
+               return 1;
+       }
+
+       dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev,
+                            NULL);
+
+       if (dev == NULL)
+               goto fail;
+
+       pvt->dev_d0f0 = dev;
+       pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
+
+       return 0;
+
+fail:
+       pci_dev_put(pvt->bridge_ck);
+       return 1;
+}
+
+static void e752x_init_error_reporting_regs(struct e752x_pvt *pvt)
+{
+       struct pci_dev *dev;
+
+       dev = pvt->dev_d0f1;
+       /* Turn off error disable & SMI in case the BIOS turned it on */
+       pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00);
+       pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00);
+       pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00);
+       pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00);
+       pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00);
+       pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
+       pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
+       pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
+}
+
+static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
+{
        u16 pci_data;
        u8 stat8;
-       struct mem_ctl_info *mci = NULL;
-       struct e752x_pvt *pvt = NULL;
+       struct mem_ctl_info *mci;
+       struct e752x_pvt *pvt;
        u16 ddrcsr;
-       u32 drc;
        int drc_chan;   /* Number of channels 0=1chan,1=2chan */
-       int drc_drbg;   /* DRB granularity 0=64mb, 1=128mb */
-       int drc_ddim;   /* DRAM Data Integrity Mode 0=none,2=edac */
-       u32 dra;
-       unsigned long last_cumul_size;
-       struct pci_dev *dev = NULL;
        struct e752x_error_info discard;
 
        debugf0("%s(): mci\n", __func__);
@@ -791,25 +945,20 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
        if (!force_function_unhide && !(stat8 & (1 << 5))) {
                printk(KERN_INFO "Contact your BIOS vendor to see if the "
                        "E752x error registers can be safely un-hidden\n");
-               goto fail;
+               return -ENOMEM;
        }
        stat8 |= (1 << 5);
        pci_write_config_byte(pdev, E752X_DEVPRES1, stat8);
 
-       /* need to find out the number of channels */
-       pci_read_config_dword(pdev, E752X_DRC, &drc);
        pci_read_config_word(pdev, E752X_DDRCSR, &ddrcsr);
        /* FIXME: should check >>12 or 0xf, true for all? */
        /* Dual channel = 1, Single channel = 0 */
-       drc_chan = (((ddrcsr >> 12) & 3) == 3);
-       drc_drbg = drc_chan + 1;        /* 128 in dual mode, 64 in single */
-       drc_ddim = (drc >> 20) & 0x3;
+       drc_chan = dual_channel_active(ddrcsr);
 
        mci = edac_mc_alloc(sizeof(*pvt), E752X_NR_CSROWS, drc_chan + 1);
 
        if (mci == NULL) {
-               rc = -ENOMEM;
-               goto fail;
+               return -ENOMEM;
        }
 
        debugf3("%s(): init mci\n", __func__);
@@ -818,159 +967,54 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
            EDAC_FLAG_S4ECD4ED;
        /* FIXME - what if different memory types are in different csrows? */
        mci->mod_name = EDAC_MOD_STR;
-       mci->mod_ver = "$Revision: 1.5.2.11 $";
-       mci->pdev = pdev;
+       mci->mod_ver = E752X_REVISION;
+       mci->dev = &pdev->dev;
 
        debugf3("%s(): init pvt\n", __func__);
        pvt = (struct e752x_pvt *) mci->pvt_info;
        pvt->dev_info = &e752x_devs[dev_idx];
-       pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
-                                       pvt->dev_info->err_dev,
-                                       pvt->bridge_ck);
-
-       if (pvt->bridge_ck == NULL)
-               pvt->bridge_ck = pci_scan_single_device(pdev->bus,
-                                       PCI_DEVFN(0, 1));
+       pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
 
-       if (pvt->bridge_ck == NULL) {
-               e752x_printk(KERN_ERR, "error reporting device not found:"
-                       "vendor %x device 0x%x (broken BIOS?)\n",
-                       PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
-               goto fail;
+       if (e752x_get_devs(pdev, dev_idx, pvt)) {
+               edac_mc_free(mci);
+               return -ENODEV;
        }
 
-       pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
        debugf3("%s(): more mci init\n", __func__);
        mci->ctl_name = pvt->dev_info->ctl_name;
        mci->edac_check = e752x_check;
        mci->ctl_page_to_phys = ctl_page_to_phys;
 
-       /* find out the device types */
-       pci_read_config_dword(pdev, E752X_DRA, &dra);
-
-       /*
-        * The dram row boundary (DRB) reg values are boundary address for
-        * each DRAM row with a granularity of 64 or 128MB (single/dual
-        * channel operation).  DRB regs are cumulative; therefore DRB7 will
-        * contain the total memory contained in all eight rows.
-        */
-       for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
-               u8 value;
-               u32 cumul_size;
-
-               /* mem_dev 0=x8, 1=x4 */
-               int mem_dev = (dra >> (index * 4 + 2)) & 0x3;
-               struct csrow_info *csrow = &mci->csrows[index];
-
-               mem_dev = (mem_dev == 2);
-               pci_read_config_byte(mci->pdev, E752X_DRB + index, &value);
-               /* convert a 128 or 64 MiB DRB to a page size. */
-               cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
-               debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
-                       cumul_size);
-
-               if (cumul_size == last_cumul_size)
-                       continue; /* not populated */
-
-               csrow->first_page = last_cumul_size;
-               csrow->last_page = cumul_size - 1;
-               csrow->nr_pages = cumul_size - last_cumul_size;
-               last_cumul_size = cumul_size;
-               csrow->grain = 1 << 12;  /* 4KiB - resolution of CELOG */
-               csrow->mtype = MEM_RDDR;  /* only one type supported */
-               csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
-
-               /*
-                * if single channel or x8 devices then SECDED
-                * if dual channel and x4 then S4ECD4ED
-                */
-               if (drc_ddim) {
-                       if (drc_chan && mem_dev) {
-                               csrow->edac_mode = EDAC_S4ECD4ED;
-                               mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
-                       } else {
-                               csrow->edac_mode = EDAC_SECDED;
-                               mci->edac_cap |= EDAC_FLAG_SECDED;
-                       }
-               } else
-                       csrow->edac_mode = EDAC_NONE;
-       }
-
-       /* Fill in the memory map table */
-       {
-               u8 value;
-               u8 last = 0;
-               u8 row = 0;
-
-               for (index = 0; index < 8; index += 2) {
-                       pci_read_config_byte(mci->pdev, E752X_DRB + index,
-                                       &value);
-
-                       /* test if there is a dimm in this slot */
-                       if (value == last) {
-                               /* no dimm in the slot, so flag it as empty */
-                               pvt->map[index] = 0xff;
-                               pvt->map[index + 1] = 0xff;
-                       } else { /* there is a dimm in the slot */
-                               pvt->map[index] = row;
-                               row++;
-                               last = value;
-                               /* test the next value to see if the dimm is
-                                  double sided */
-                               pci_read_config_byte(mci->pdev,
-                                               E752X_DRB + index + 1,
-                                               &value);
-                               pvt->map[index + 1] = (value == last) ?
-                                       0xff :  /* the dimm is single sided,
-                                                * so flag as empty
-                                                */
-                                       row;    /* this is a double sided dimm
-                                                * to save the next row #
-                                                */
-                               row++;
-                               last = value;
-                       }
-               }
-       }
+       e752x_init_csrows(mci, pdev, ddrcsr);
+       e752x_init_mem_map_table(pdev, pvt);
 
        /* set the map type.  1 = normal, 0 = reversed */
-       pci_read_config_byte(mci->pdev, E752X_DRM, &stat8);
+       pci_read_config_byte(pdev, E752X_DRM, &stat8);
        pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
 
        mci->edac_cap |= EDAC_FLAG_NONE;
        debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
 
        /* load the top of low memory, remap base, and remap limit vars */
-       pci_read_config_word(mci->pdev, E752X_TOLM, &pci_data);
+       pci_read_config_word(pdev, E752X_TOLM, &pci_data);
        pvt->tolm = ((u32) pci_data) << 4;
-       pci_read_config_word(mci->pdev, E752X_REMAPBASE, &pci_data);
+       pci_read_config_word(pdev, E752X_REMAPBASE, &pci_data);
        pvt->remapbase = ((u32) pci_data) << 14;
-       pci_read_config_word(mci->pdev, E752X_REMAPLIMIT, &pci_data);
+       pci_read_config_word(pdev, E752X_REMAPLIMIT, &pci_data);
        pvt->remaplimit = ((u32) pci_data) << 14;
        e752x_printk(KERN_INFO,
                "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
                pvt->remapbase, pvt->remaplimit);
 
-       if (edac_mc_add_mc(mci)) {
+       /* Here we assume that we will never see multiple instances of this
+        * type of memory controller.  The ID is therefore hardcoded to 0.
+        */
+       if (edac_mc_add_mc(mci,0)) {
                debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
                goto fail;
        }
 
-       dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev,
-                       NULL);
-       pvt->dev_d0f0 = dev;
-       /* find the error reporting device and clear errors */
-       dev = pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
-       /* Turn off error disable & SMI in case the BIOS turned it on */
-       pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00);
-       pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00);
-       pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00);
-       pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00);
-       pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00);
-       pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
-       pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
-       pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
-
+       e752x_init_error_reporting_regs(pvt);
        e752x_get_error_info(mci, &discard); /* clear other MCH errors */
 
        /* get this far and it's successful */
@@ -978,20 +1022,12 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
        return 0;
 
 fail:
-       if (mci) {
-               if (pvt->dev_d0f0)
-                       pci_dev_put(pvt->dev_d0f0);
-
-               if (pvt->dev_d0f1)
-                       pci_dev_put(pvt->dev_d0f1);
-
-               if (pvt->bridge_ck)
-                       pci_dev_put(pvt->bridge_ck);
-
-               edac_mc_free(mci);
-       }
+       pci_dev_put(pvt->dev_d0f0);
+       pci_dev_put(pvt->dev_d0f1);
+       pci_dev_put(pvt->bridge_ck);
+       edac_mc_free(mci);
 
-       return rc;
+       return -ENODEV;
 }
 
 /* returns count (>= 0), or negative on error */
@@ -1014,7 +1050,7 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
-       if ((mci = edac_mc_del_mc(pdev)) == NULL)
+       if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
        pvt = (struct e752x_pvt *) mci->pvt_info;
index ecfca7c..5a5ecd5 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/slab.h>
 #include "edac_mc.h"
 
+#define        E7XXX_REVISION " Ver: 2.0.0 " __DATE__
+
 #define e7xxx_printk(level, fmt, arg...) \
        edac_printk(level, "e7xxx", fmt, ##arg)
 
@@ -332,99 +334,61 @@ static void e7xxx_check(struct mem_ctl_info *mci)
        e7xxx_process_error_info(mci, &info, 1);
 }
 
-static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
+/* Return 1 if dual channel mode is active.  Else return 0. */
+static inline int dual_channel_active(u32 drc, int dev_idx)
 {
-       int rc = -ENODEV;
-       int index;
-       u16 pci_data;
-       struct mem_ctl_info *mci = NULL;
-       struct e7xxx_pvt *pvt = NULL;
-       u32 drc;
-       int drc_chan = 1;       /* Number of channels 0=1chan,1=2chan */
-       int drc_drbg = 1;       /* DRB granularity 0=32mb,1=64mb */
-       int drc_ddim;           /* DRAM Data Integrity Mode 0=none,2=edac */
-       u32 dra;
-       unsigned long last_cumul_size;
-       struct e7xxx_error_info discard;
-
-       debugf0("%s(): mci\n", __func__);
+       return (dev_idx == E7501) ? ((drc >> 22) & 0x1) : 1;
+}
 
-       /* need to find out the number of channels */
-       pci_read_config_dword(pdev, E7XXX_DRC, &drc);
 
+/* Return DRB granularity (0=32mb, 1=64mb). */
+static inline int drb_granularity(u32 drc, int dev_idx)
+{
        /* only e7501 can be single channel */
-       if (dev_idx == E7501) {
-               drc_chan = ((drc >> 22) & 0x1);
-               drc_drbg = (drc >> 18) & 0x3;
-       }
-
-       drc_ddim = (drc >> 20) & 0x3;
-       mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
-
-       if (mci == NULL) {
-               rc = -ENOMEM;
-               goto fail;
-       }
-
-       debugf3("%s(): init mci\n", __func__);
-       mci->mtype_cap = MEM_FLAG_RDDR;
-       mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
-                       EDAC_FLAG_S4ECD4ED;
-       /* FIXME - what if different memory types are in different csrows? */
-       mci->mod_name = EDAC_MOD_STR;
-       mci->mod_ver = "$Revision: 1.5.2.9 $";
-       mci->pdev = pdev;
+       return (dev_idx == E7501) ? ((drc >> 18) & 0x3) : 1;
+}
 
-       debugf3("%s(): init pvt\n", __func__);
-       pvt = (struct e7xxx_pvt *) mci->pvt_info;
-       pvt->dev_info = &e7xxx_devs[dev_idx];
-       pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
-                                       pvt->dev_info->err_dev,
-                                       pvt->bridge_ck);
 
-       if (!pvt->bridge_ck) {
-               e7xxx_printk(KERN_ERR, "error reporting device not found:"
-                       "vendor %x device 0x%x (broken BIOS?)\n",
-                       PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
-               goto fail;
-       }
-
-       debugf3("%s(): more mci init\n", __func__);
-       mci->ctl_name = pvt->dev_info->ctl_name;
-       mci->edac_check = e7xxx_check;
-       mci->ctl_page_to_phys = ctl_page_to_phys;
+static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
+               int dev_idx, u32 drc)
+{
+       unsigned long last_cumul_size;
+       int index;
+       u8 value;
+       u32 dra, cumul_size;
+       int drc_chan, drc_drbg, drc_ddim, mem_dev;
+       struct csrow_info *csrow;
 
-       /* find out the device types */
        pci_read_config_dword(pdev, E7XXX_DRA, &dra);
+       drc_chan = dual_channel_active(drc, dev_idx);
+       drc_drbg = drb_granularity(drc, dev_idx);
+       drc_ddim = (drc >> 20) & 0x3;
+       last_cumul_size = 0;
 
-       /*
-        * The dram row boundary (DRB) reg values are boundary address
+       /* The dram row boundary (DRB) reg values are boundary address
         * for each DRAM row with a granularity of 32 or 64MB (single/dual
         * channel operation).  DRB regs are cumulative; therefore DRB7 will
         * contain the total memory contained in all eight rows.
         */
-       for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
-               u8 value;
-               u32 cumul_size;
+       for (index = 0; index < mci->nr_csrows; index++) {
                /* mem_dev 0=x8, 1=x4 */
-               int mem_dev = (dra >> (index * 4 + 3)) & 0x1;
-               struct csrow_info *csrow = &mci->csrows[index];
+               mem_dev = (dra >> (index * 4 + 3)) & 0x1;
+               csrow = &mci->csrows[index];
 
-               pci_read_config_byte(mci->pdev, E7XXX_DRB + index, &value);
+               pci_read_config_byte(pdev, E7XXX_DRB + index, &value);
                /* convert a 64 or 32 MiB DRB to a page size. */
                cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
                debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
                        cumul_size);
-
                if (cumul_size == last_cumul_size)
-                       continue;  /* not populated */
+                       continue;       /* not populated */
 
                csrow->first_page = last_cumul_size;
                csrow->last_page = cumul_size - 1;
                csrow->nr_pages = cumul_size - last_cumul_size;
                last_cumul_size = cumul_size;
-               csrow->grain = 1 << 12;  /* 4KiB - resolution of CELOG */
-               csrow->mtype = MEM_RDDR;  /* only one type supported */
+               csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
+               csrow->mtype = MEM_RDDR;        /* only one type supported */
                csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
 
                /*
@@ -442,16 +406,61 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
                } else
                        csrow->edac_mode = EDAC_NONE;
        }
+}
 
-       mci->edac_cap |= EDAC_FLAG_NONE;
+static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
+{
+       u16 pci_data;
+       struct mem_ctl_info *mci = NULL;
+       struct e7xxx_pvt *pvt = NULL;
+       u32 drc;
+       int drc_chan;
+       struct e7xxx_error_info discard;
+
+       debugf0("%s(): mci\n", __func__);
+       pci_read_config_dword(pdev, E7XXX_DRC, &drc);
+
+       drc_chan = dual_channel_active(drc, dev_idx);
+       mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
+
+       if (mci == NULL)
+               return -ENOMEM;
+
+       debugf3("%s(): init mci\n", __func__);
+       mci->mtype_cap = MEM_FLAG_RDDR;
+       mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
+                       EDAC_FLAG_S4ECD4ED;
+       /* FIXME - what if different memory types are in different csrows? */
+       mci->mod_name = EDAC_MOD_STR;
+       mci->mod_ver = E7XXX_REVISION;
+       mci->dev = &pdev->dev;
+       debugf3("%s(): init pvt\n", __func__);
+       pvt = (struct e7xxx_pvt *) mci->pvt_info;
+       pvt->dev_info = &e7xxx_devs[dev_idx];
+       pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
+                                       pvt->dev_info->err_dev,
+                                       pvt->bridge_ck);
 
+       if (!pvt->bridge_ck) {
+               e7xxx_printk(KERN_ERR, "error reporting device not found:"
+                       "vendor %x device 0x%x (broken BIOS?)\n",
+                       PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
+               goto fail0;
+       }
+
+       debugf3("%s(): more mci init\n", __func__);
+       mci->ctl_name = pvt->dev_info->ctl_name;
+       mci->edac_check = e7xxx_check;
+       mci->ctl_page_to_phys = ctl_page_to_phys;
+       e7xxx_init_csrows(mci, pdev, dev_idx, drc);
+       mci->edac_cap |= EDAC_FLAG_NONE;
        debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
        /* load the top of low memory, remap base, and remap limit vars */
-       pci_read_config_word(mci->pdev, E7XXX_TOLM, &pci_data);
+       pci_read_config_word(pdev, E7XXX_TOLM, &pci_data);
        pvt->tolm = ((u32) pci_data) << 4;
-       pci_read_config_word(mci->pdev, E7XXX_REMAPBASE, &pci_data);
+       pci_read_config_word(pdev, E7XXX_REMAPBASE, &pci_data);
        pvt->remapbase = ((u32) pci_data) << 14;
-       pci_read_config_word(mci->pdev, E7XXX_REMAPLIMIT, &pci_data);
+       pci_read_config_word(pdev, E7XXX_REMAPLIMIT, &pci_data);
        pvt->remaplimit = ((u32) pci_data) << 14;
        e7xxx_printk(KERN_INFO,
                "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
@@ -460,23 +469,25 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
        /* clear any pending errors, or initial state bits */
        e7xxx_get_error_info(mci, &discard);
 
-       if (edac_mc_add_mc(mci) != 0) {
+       /* Here we assume that we will never see multiple instances of this
+        * type of memory controller.  The ID is therefore hardcoded to 0.
+        */
+       if (edac_mc_add_mc(mci,0)) {
                debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
-               goto fail;
+               goto fail1;
        }
 
        /* get this far and it's successful */
        debugf3("%s(): success\n", __func__);
        return 0;
 
-fail:
-       if (mci != NULL) {
-               if(pvt != NULL && pvt->bridge_ck)
-                       pci_dev_put(pvt->bridge_ck);
-               edac_mc_free(mci);
-       }
+fail1:
+       pci_dev_put(pvt->bridge_ck);
+
+fail0:
+       edac_mc_free(mci);
 
-       return rc;
+       return -ENODEV;
 }
 
 /* returns count (>= 0), or negative on error */
@@ -497,7 +508,7 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
-       if ((mci = edac_mc_del_mc(pdev)) == NULL)
+       if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
        pvt = (struct e7xxx_pvt *) mci->pvt_info;
index 0499782..3a7cfe8 100644 (file)
@@ -53,16 +53,17 @@ static int log_ce = 1;
 static int panic_on_ue;
 static int poll_msec = 1000;
 
-static int check_pci_parity = 0;       /* default YES check PCI parity */
-static int panic_on_pci_parity;                /* default no panic on PCI Parity */
-static atomic_t pci_parity_count = ATOMIC_INIT(0);
-
 /* lock to memory controller's control array */
 static DECLARE_MUTEX(mem_ctls_mutex);
 static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices);
 
 static struct task_struct *edac_thread;
 
+#ifdef CONFIG_PCI
+static int check_pci_parity = 0;       /* default YES check PCI parity */
+static int panic_on_pci_parity;                /* default no panic on PCI Parity */
+static atomic_t pci_parity_count = ATOMIC_INIT(0);
+
 /* Structure of the whitelist and blacklist arrays */
 struct edac_pci_device_list {
        unsigned int  vendor;           /* Vendor ID */
@@ -79,6 +80,12 @@ static int pci_blacklist_count;
 static struct edac_pci_device_list pci_whitelist[MAX_LISTED_PCI_DEVICES];
 static int pci_whitelist_count ;
 
+#ifndef DISABLE_EDAC_SYSFS
+static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */
+static struct completion edac_pci_kobj_complete;
+#endif /* DISABLE_EDAC_SYSFS */
+#endif /* CONFIG_PCI */
+
 /*  START sysfs data and methods */
 
 #ifndef DISABLE_EDAC_SYSFS
@@ -126,18 +133,15 @@ static struct sysdev_class edac_class = {
        set_kset_name("edac"),
 };
 
-/* sysfs objects:
+/* sysfs object:
  *     /sys/devices/system/edac/mc
- *     /sys/devices/system/edac/pci
  */
 static struct kobject edac_memctrl_kobj;
-static struct kobject edac_pci_kobj;
 
 /* We use these to wait for the reference counts on edac_memctrl_kobj and
  * edac_pci_kobj to reach 0.
  */
 static struct completion edac_memctrl_kobj_complete;
-static struct completion edac_pci_kobj_complete;
 
 /*
  * /sys/devices/system/edac/mc;
@@ -323,6 +327,8 @@ static void edac_sysfs_memctrl_teardown(void)
 #endif  /* DISABLE_EDAC_SYSFS */
 }
 
+#ifdef CONFIG_PCI
+
 #ifndef DISABLE_EDAC_SYSFS
 
 /*
@@ -623,6 +629,252 @@ static void edac_sysfs_pci_teardown(void)
 #endif
 }
 
+
+static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
+{
+       int where;
+       u16 status;
+
+       where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
+       pci_read_config_word(dev, where, &status);
+
+       /* If we get back 0xFFFF then we must suspect that the card has been
+        * pulled but the Linux PCI layer has not yet finished cleaning up.
+        * We don't want to report on such devices
+        */
+
+       if (status == 0xFFFF) {
+               u32 sanity;
+
+               pci_read_config_dword(dev, 0, &sanity);
+
+               if (sanity == 0xFFFFFFFF)
+                       return 0;
+       }
+
+       status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
+               PCI_STATUS_PARITY;
+
+       if (status)
+               /* reset only the bits we are interested in */
+               pci_write_config_word(dev, where, status);
+
+       return status;
+}
+
+typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
+
+/* Clear any PCI parity errors logged by this device. */
+static void edac_pci_dev_parity_clear(struct pci_dev *dev)
+{
+       u8 header_type;
+
+       get_pci_parity_status(dev, 0);
+
+       /* read the device TYPE, looking for bridges */
+       pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
+
+       if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
+               get_pci_parity_status(dev, 1);
+}
+
+/*
+ *  PCI Parity polling
+ *
+ */
+static void edac_pci_dev_parity_test(struct pci_dev *dev)
+{
+       u16 status;
+       u8  header_type;
+
+       /* read the STATUS register on this device
+        */
+       status = get_pci_parity_status(dev, 0);
+
+       debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id );
+
+       /* check the status reg for errors */
+       if (status) {
+               if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
+                       edac_printk(KERN_CRIT, EDAC_PCI,
+                               "Signaled System Error on %s\n",
+                               pci_name(dev));
+
+               if (status & (PCI_STATUS_PARITY)) {
+                       edac_printk(KERN_CRIT, EDAC_PCI,
+                               "Master Data Parity Error on %s\n",
+                               pci_name(dev));
+
+                       atomic_inc(&pci_parity_count);
+               }
+
+               if (status & (PCI_STATUS_DETECTED_PARITY)) {
+                       edac_printk(KERN_CRIT, EDAC_PCI,
+                               "Detected Parity Error on %s\n",
+                               pci_name(dev));
+
+                       atomic_inc(&pci_parity_count);
+               }
+       }
+
+       /* read the device TYPE, looking for bridges */
+       pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
+
+       debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id );
+
+       if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
+               /* On bridges, need to examine secondary status register  */
+               status = get_pci_parity_status(dev, 1);
+
+               debugf2("PCI SEC_STATUS= 0x%04x %s\n",
+                               status, dev->dev.bus_id );
+
+               /* check the secondary status reg for errors */
+               if (status) {
+                       if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
+                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
+                                       "Signaled System Error on %s\n",
+                                       pci_name(dev));
+
+                       if (status & (PCI_STATUS_PARITY)) {
+                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
+                                       "Master Data Parity Error on "
+                                       "%s\n", pci_name(dev));
+
+                               atomic_inc(&pci_parity_count);
+                       }
+
+                       if (status & (PCI_STATUS_DETECTED_PARITY)) {
+                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
+                                       "Detected Parity Error on %s\n",
+                                       pci_name(dev));
+
+                               atomic_inc(&pci_parity_count);
+                       }
+               }
+       }
+}
+
+/*
+ * check_dev_on_list: Scan for a PCI device on a white/black list
+ * @list:      an EDAC  &edac_pci_device_list  white/black list pointer
+ * @free_index:        index of next free entry on the list
+ * @pci_dev:   PCI Device pointer
+ *
+ * see if list contains the device.
+ *
+ * Returns:    0 not found
+ *             1 found on list
+ */
+static int check_dev_on_list(struct edac_pci_device_list *list,
+               int free_index, struct pci_dev *dev)
+{
+       int i;
+       int rc = 0;     /* Assume not found */
+       unsigned short vendor=dev->vendor;
+       unsigned short device=dev->device;
+
+       /* Scan the list, looking for a vendor/device match */
+       for (i = 0; i < free_index; i++, list++ ) {
+               if ((list->vendor == vendor ) && (list->device == device )) {
+                       rc = 1;
+                       break;
+               }
+       }
+
+       return rc;
+}
+
+/*
+ * pci_dev parity list iterator
+ *     Scan the PCI device list for one iteration, looking for SERRORs
+ *     Master Parity ERRORS or Parity ERRORs on primary or secondary devices
+ */
+static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
+{
+       struct pci_dev *dev = NULL;
+
+       /* request for kernel access to the next PCI device, if any,
+        * and while we are looking at it have its reference count
+        * bumped until we are done with it
+        */
+       while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+               /* if whitelist exists then it has priority, so only scan
+                * those devices on the whitelist
+                */
+               if (pci_whitelist_count > 0 ) {
+                       if (check_dev_on_list(pci_whitelist,
+                                       pci_whitelist_count, dev))
+                               fn(dev);
+               } else {
+                       /*
+                        * if no whitelist, then check if this devices is
+                        * blacklisted
+                        */
+                       if (!check_dev_on_list(pci_blacklist,
+                                       pci_blacklist_count, dev))
+                               fn(dev);
+               }
+       }
+}
+
+static void do_pci_parity_check(void)
+{
+       unsigned long flags;
+       int before_count;
+
+       debugf3("%s()\n", __func__);
+
+       if (!check_pci_parity)
+               return;
+
+       before_count = atomic_read(&pci_parity_count);
+
+       /* scan all PCI devices looking for a Parity Error on devices and
+        * bridges
+        */
+       local_irq_save(flags);
+       edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
+       local_irq_restore(flags);
+
+       /* Only if operator has selected panic on PCI Error */
+       if (panic_on_pci_parity) {
+               /* If the count is different 'after' from 'before' */
+               if (before_count != atomic_read(&pci_parity_count))
+                       panic("EDAC: PCI Parity Error");
+       }
+}
+
+static inline void clear_pci_parity_errors(void)
+{
+       /* Clear any PCI bus parity errors that devices initially have logged
+        * in their registers.
+        */
+       edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
+}
+
+#else  /* CONFIG_PCI */
+
+static inline void do_pci_parity_check(void)
+{
+       /* no-op */
+}
+
+static inline void clear_pci_parity_errors(void)
+{
+       /* no-op */
+}
+
+static void edac_sysfs_pci_teardown(void)
+{
+}
+
+static int edac_sysfs_pci_setup(void)
+{
+       return 0;
+}
+#endif /* CONFIG_PCI */
+
 #ifndef DISABLE_EDAC_SYSFS
 
 /* EDAC sysfs CSROW data structures and methods */
@@ -1131,7 +1383,7 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
                return err;
 
        /* create a symlink for the device */
-       err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj,
+       err = sysfs_create_link(edac_mci_kobj, &mci->dev->kobj,
                                EDAC_DEVICE_SYMLINK);
 
        if (err)
@@ -1237,7 +1489,7 @@ void edac_mc_dump_mci(struct mem_ctl_info *mci)
        debugf4("\tmci->edac_check = %p\n", mci->edac_check);
        debugf3("\tmci->nr_csrows = %d, csrows = %p\n",
                mci->nr_csrows, mci->csrows);
-       debugf3("\tpdev = %p\n", mci->pdev);
+       debugf3("\tdev = %p\n", mci->dev);
        debugf3("\tmod_name:ctl_name = %s:%s\n",
                mci->mod_name, mci->ctl_name);
        debugf3("\tpvt_info = %p\n\n", mci->pvt_info);
@@ -1362,7 +1614,7 @@ void edac_mc_free(struct mem_ctl_info *mci)
 }
 EXPORT_SYMBOL_GPL(edac_mc_free);
 
-static struct mem_ctl_info *find_mci_by_pdev(struct pci_dev *pdev)
+static struct mem_ctl_info *find_mci_by_dev(struct device *dev)
 {
        struct mem_ctl_info *mci;
        struct list_head *item;
@@ -1372,54 +1624,53 @@ static struct mem_ctl_info *find_mci_by_pdev(struct pci_dev *pdev)
        list_for_each(item, &mc_devices) {
                mci = list_entry(item, struct mem_ctl_info, link);
 
-               if (mci->pdev == pdev)
+               if (mci->dev == dev)
                        return mci;
        }
 
        return NULL;
 }
 
-static int add_mc_to_global_list(struct mem_ctl_info *mci)
+/* Return 0 on success, 1 on failure.
+ * Before calling this function, caller must
+ * assign a unique value to mci->mc_idx.
+ */
+static int add_mc_to_global_list (struct mem_ctl_info *mci)
 {
        struct list_head *item, *insert_before;
        struct mem_ctl_info *p;
-       int i;
 
-       if (list_empty(&mc_devices)) {
-               mci->mc_idx = 0;
-               insert_before = &mc_devices;
-       } else {
-               if (find_mci_by_pdev(mci->pdev)) {
-                       edac_printk(KERN_WARNING, EDAC_MC,
-                               "%s (%s) %s %s already assigned %d\n",
-                               mci->pdev->dev.bus_id,
-                               pci_name(mci->pdev), mci->mod_name,
-                               mci->ctl_name, mci->mc_idx);
-                       return 1;
-               }
+       insert_before = &mc_devices;
 
-               insert_before = NULL;
-               i = 0;
+       if (unlikely((p = find_mci_by_dev(mci->dev)) != NULL))
+               goto fail0;
 
-               list_for_each(item, &mc_devices) {
-                       p = list_entry(item, struct mem_ctl_info, link);
+       list_for_each(item, &mc_devices) {
+               p = list_entry(item, struct mem_ctl_info, link);
 
-                       if (p->mc_idx != i) {
-                               insert_before = item;
-                               break;
-                       }
+               if (p->mc_idx >= mci->mc_idx) {
+                       if (unlikely(p->mc_idx == mci->mc_idx))
+                               goto fail1;
 
-                       i++;
+                       insert_before = item;
+                       break;
                }
-
-               mci->mc_idx = i;
-
-               if (insert_before == NULL)
-                       insert_before = &mc_devices;
        }
 
        list_add_tail_rcu(&mci->link, insert_before);
        return 0;
+
+fail0:
+       edac_printk(KERN_WARNING, EDAC_MC,
+                   "%s (%s) %s %s already assigned %d\n", p->dev->bus_id,
+                   dev_name(p->dev), p->mod_name, p->ctl_name, p->mc_idx);
+       return 1;
+
+fail1:
+       edac_printk(KERN_WARNING, EDAC_MC,
+                   "bug in low-level driver: attempt to assign\n"
+                   "    duplicate mc_idx %d in %s()\n", p->mc_idx, __func__);
+       return 1;
 }
 
 static void complete_mc_list_del(struct rcu_head *head)
@@ -1443,6 +1694,7 @@ static void del_mc_from_global_list(struct mem_ctl_info *mci)
  * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and
  *                 create sysfs entries associated with mci structure
  * @mci: pointer to the mci structure to be added to the list
+ * @mc_idx: A unique numeric identifier to be assigned to the 'mci' structure.
  *
  * Return:
  *     0       Success
@@ -1450,9 +1702,10 @@ static void del_mc_from_global_list(struct mem_ctl_info *mci)
  */
 
 /* FIXME - should a warning be printed if no error detection? correction? */
-int edac_mc_add_mc(struct mem_ctl_info *mci)
+int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx)
 {
        debugf0("%s()\n", __func__);
+       mci->mc_idx = mc_idx;
 #ifdef CONFIG_EDAC_DEBUG
        if (edac_debug_level >= 3)
                edac_mc_dump_mci(mci);
@@ -1485,8 +1738,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
         }
 
        /* Report action taken */
-       edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: PCI %s\n",
-               mci->mod_name, mci->ctl_name, pci_name(mci->pdev));
+       edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: DEV %s\n",
+               mci->mod_name, mci->ctl_name, dev_name(mci->dev));
 
        up(&mem_ctls_mutex);
        return 0;
@@ -1503,18 +1756,18 @@ EXPORT_SYMBOL_GPL(edac_mc_add_mc);
 /**
  * edac_mc_del_mc: Remove sysfs entries for specified mci structure and
  *                 remove mci structure from global list
- * @pdev: Pointer to 'struct pci_dev' representing mci structure to remove.
+ * @pdev: Pointer to 'struct device' representing mci structure to remove.
  *
  * Return pointer to removed mci structure, or NULL if device not found.
  */
-struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev)
+struct mem_ctl_info * edac_mc_del_mc(struct device *dev)
 {
        struct mem_ctl_info *mci;
 
        debugf0("MC: %s()\n", __func__);
        down(&mem_ctls_mutex);
 
-       if ((mci = find_mci_by_pdev(pdev)) == NULL) {
+       if ((mci = find_mci_by_dev(dev)) == NULL) {
                up(&mem_ctls_mutex);
                return NULL;
        }
@@ -1523,8 +1776,8 @@ struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev)
        del_mc_from_global_list(mci);
        up(&mem_ctls_mutex);
        edac_printk(KERN_INFO, EDAC_MC,
-               "Removed device %d for %s %s: PCI %s\n", mci->mc_idx,
-               mci->mod_name, mci->ctl_name, pci_name(mci->pdev));
+               "Removed device %d for %s %s: DEV %s\n", mci->mc_idx,
+               mci->mod_name, mci->ctl_name, dev_name(mci->dev));
        return mci;
 }
 EXPORT_SYMBOL_GPL(edac_mc_del_mc);
@@ -1738,244 +1991,6 @@ void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg)
 }
 EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info);
 
-#ifdef CONFIG_PCI
-
-static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
-{
-       int where;
-       u16 status;
-
-       where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
-       pci_read_config_word(dev, where, &status);
-
-       /* If we get back 0xFFFF then we must suspect that the card has been
-        * pulled but the Linux PCI layer has not yet finished cleaning up.
-        * We don't want to report on such devices
-        */
-
-       if (status == 0xFFFF) {
-               u32 sanity;
-
-               pci_read_config_dword(dev, 0, &sanity);
-
-               if (sanity == 0xFFFFFFFF)
-                       return 0;
-       }
-
-       status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
-               PCI_STATUS_PARITY;
-
-       if (status)
-               /* reset only the bits we are interested in */
-               pci_write_config_word(dev, where, status);
-
-       return status;
-}
-
-typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
-
-/* Clear any PCI parity errors logged by this device. */
-static void edac_pci_dev_parity_clear(struct pci_dev *dev)
-{
-       u8 header_type;
-
-       get_pci_parity_status(dev, 0);
-
-       /* read the device TYPE, looking for bridges */
-       pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
-
-       if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
-               get_pci_parity_status(dev, 1);
-}
-
-/*
- *  PCI Parity polling
- *
- */
-static void edac_pci_dev_parity_test(struct pci_dev *dev)
-{
-       u16 status;
-       u8  header_type;
-
-       /* read the STATUS register on this device
-        */
-       status = get_pci_parity_status(dev, 0);
-
-       debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id );
-
-       /* check the status reg for errors */
-       if (status) {
-               if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
-                       edac_printk(KERN_CRIT, EDAC_PCI,
-                               "Signaled System Error on %s\n",
-                               pci_name(dev));
-
-               if (status & (PCI_STATUS_PARITY)) {
-                       edac_printk(KERN_CRIT, EDAC_PCI,
-                               "Master Data Parity Error on %s\n",
-                               pci_name(dev));
-
-                       atomic_inc(&pci_parity_count);
-               }
-
-               if (status & (PCI_STATUS_DETECTED_PARITY)) {
-                       edac_printk(KERN_CRIT, EDAC_PCI,
-                               "Detected Parity Error on %s\n",
-                               pci_name(dev));
-
-                       atomic_inc(&pci_parity_count);
-               }
-       }
-
-       /* read the device TYPE, looking for bridges */
-       pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
-
-       debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id );
-
-       if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
-               /* On bridges, need to examine secondary status register  */
-               status = get_pci_parity_status(dev, 1);
-
-               debugf2("PCI SEC_STATUS= 0x%04x %s\n",
-                               status, dev->dev.bus_id );
-
-               /* check the secondary status reg for errors */
-               if (status) {
-                       if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
-                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
-                                       "Signaled System Error on %s\n",
-                                       pci_name(dev));
-
-                       if (status & (PCI_STATUS_PARITY)) {
-                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
-                                       "Master Data Parity Error on "
-                                       "%s\n", pci_name(dev));
-
-                               atomic_inc(&pci_parity_count);
-                       }
-
-                       if (status & (PCI_STATUS_DETECTED_PARITY)) {
-                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
-                                       "Detected Parity Error on %s\n",
-                                       pci_name(dev));
-
-                               atomic_inc(&pci_parity_count);
-                       }
-               }
-       }
-}
-
-/*
- * check_dev_on_list: Scan for a PCI device on a white/black list
- * @list:      an EDAC  &edac_pci_device_list  white/black list pointer
- * @free_index:        index of next free entry on the list
- * @pci_dev:   PCI Device pointer
- *
- * see if list contains the device.
- *
- * Returns:    0 not found
- *             1 found on list
- */
-static int check_dev_on_list(struct edac_pci_device_list *list,
-               int free_index, struct pci_dev *dev)
-{
-       int i;
-       int rc = 0;     /* Assume not found */
-       unsigned short vendor=dev->vendor;
-       unsigned short device=dev->device;
-
-       /* Scan the list, looking for a vendor/device match */
-       for (i = 0; i < free_index; i++, list++ ) {
-               if ((list->vendor == vendor ) && (list->device == device )) {
-                       rc = 1;
-                       break;
-               }
-       }
-
-       return rc;
-}
-
-/*
- * pci_dev parity list iterator
- *     Scan the PCI device list for one iteration, looking for SERRORs
- *     Master Parity ERRORS or Parity ERRORs on primary or secondary devices
- */
-static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
-{
-       struct pci_dev *dev = NULL;
-
-       /* request for kernel access to the next PCI device, if any,
-        * and while we are looking at it have its reference count
-        * bumped until we are done with it
-        */
-       while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-               /* if whitelist exists then it has priority, so only scan
-                * those devices on the whitelist
-                */
-               if (pci_whitelist_count > 0 ) {
-                       if (check_dev_on_list(pci_whitelist,
-                                       pci_whitelist_count, dev))
-                               fn(dev);
-               } else {
-                       /*
-                        * if no whitelist, then check if this devices is
-                        * blacklisted
-                        */
-                       if (!check_dev_on_list(pci_blacklist,
-                                       pci_blacklist_count, dev))
-                               fn(dev);
-               }
-       }
-}
-
-static void do_pci_parity_check(void)
-{
-       unsigned long flags;
-       int before_count;
-
-       debugf3("%s()\n", __func__);
-
-       if (!check_pci_parity)
-               return;
-
-       before_count = atomic_read(&pci_parity_count);
-
-       /* scan all PCI devices looking for a Parity Error on devices and
-        * bridges
-        */
-       local_irq_save(flags);
-       edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
-       local_irq_restore(flags);
-
-       /* Only if operator has selected panic on PCI Error */
-       if (panic_on_pci_parity) {
-               /* If the count is different 'after' from 'before' */
-               if (before_count != atomic_read(&pci_parity_count))
-                       panic("EDAC: PCI Parity Error");
-       }
-}
-
-static inline void clear_pci_parity_errors(void)
-{
-       /* Clear any PCI bus parity errors that devices initially have logged
-        * in their registers.
-        */
-       edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
-}
-
-#else  /* CONFIG_PCI */
-
-static inline void do_pci_parity_check(void)
-{
-       /* no-op */
-}
-
-static inline void clear_pci_parity_errors(void)
-{
-       /* no-op */
-}
-
-#endif  /* CONFIG_PCI */
 
 /*
  * Iterate over all MC instances and check for ECC, et al, errors
@@ -2095,10 +2110,12 @@ MODULE_DESCRIPTION("Core library routines for MC reporting");
 
 module_param(panic_on_ue, int, 0644);
 MODULE_PARM_DESC(panic_on_ue, "Panic on uncorrected error: 0=off 1=on");
+#ifdef CONFIG_PCI
 module_param(check_pci_parity, int, 0644);
 MODULE_PARM_DESC(check_pci_parity, "Check for PCI bus parity errors: 0=off 1=on");
 module_param(panic_on_pci_parity, int, 0644);
 MODULE_PARM_DESC(panic_on_pci_parity, "Panic on PCI Bus Parity error: 0=off 1=on");
+#endif
 module_param(log_ue, int, 0644);
 MODULE_PARM_DESC(log_ue, "Log uncorrectable error to console: 0=off 1=on");
 module_param(log_ce, int, 0644);
index ad578eb..1be4947 100644 (file)
@@ -87,6 +87,12 @@ extern int edac_debug_level;
 #define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
        PCI_DEVICE_ID_ ## vend ## _ ## dev
 
+#if defined(CONFIG_X86) && defined(CONFIG_PCI)
+#define dev_name(dev) pci_name(to_pci_dev(dev))
+#else
+#define dev_name(dev) to_platform_device(dev)->name
+#endif
+
 /* memory devices */
 enum dev_type {
        DEV_UNKNOWN = 0,
@@ -326,10 +332,10 @@ struct mem_ctl_info {
        struct csrow_info *csrows;
        /*
         * FIXME - what about controllers on other busses? - IDs must be
-        * unique.  pdev pointer should be sufficiently unique, but
+        * unique.  dev pointer should be sufficiently unique, but
         * BUS:SLOT.FUNC numbers may not be unique.
         */
-       struct pci_dev *pdev;
+       struct device *dev;
        const char *mod_name;
        const char *mod_ver;
        const char *ctl_name;
@@ -352,6 +358,8 @@ struct mem_ctl_info {
        struct completion kobj_complete;
 };
 
+#ifdef CONFIG_PCI
+
 /* write all or some bits in a byte-register*/
 static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
                u8 mask)
@@ -400,14 +408,16 @@ static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
        pci_write_config_dword(pdev, offset, value);
 }
 
+#endif /* CONFIG_PCI */
+
 #ifdef CONFIG_EDAC_DEBUG
 void edac_mc_dump_channel(struct channel_info *chan);
 void edac_mc_dump_mci(struct mem_ctl_info *mci);
 void edac_mc_dump_csrow(struct csrow_info *csrow);
 #endif  /* CONFIG_EDAC_DEBUG */
 
-extern int edac_mc_add_mc(struct mem_ctl_info *mci);
-extern struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev);
+extern int edac_mc_add_mc(struct mem_ctl_info *mci,int mc_idx);
+extern struct mem_ctl_info * edac_mc_del_mc(struct device *dev);
 extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
                                        unsigned long page);
 extern void edac_mc_scrub_block(unsigned long page, unsigned long offset,
index 56ba31f..e30a4a2 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/slab.h>
 #include "edac_mc.h"
 
+#define  I82860_REVISION " Ver: 2.0.0 " __DATE__
+
 #define i82860_printk(level, fmt, arg...) \
        edac_printk(level, "i82860", fmt, ##arg)
 
@@ -62,17 +64,21 @@ static struct pci_dev *mci_pdev = NULL;     /* init dev: in case that AGP code
 static void i82860_get_error_info(struct mem_ctl_info *mci,
                struct i82860_error_info *info)
 {
+       struct pci_dev *pdev;
+
+       pdev = to_pci_dev(mci->dev);
+
        /*
         * This is a mess because there is no atomic way to read all the
         * registers at once and the registers can transition from CE being
         * overwritten by UE.
         */
-       pci_read_config_word(mci->pdev, I82860_ERRSTS, &info->errsts);
-       pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap);
-       pci_read_config_word(mci->pdev, I82860_DERRCTL_STS, &info->derrsyn);
-       pci_read_config_word(mci->pdev, I82860_ERRSTS, &info->errsts2);
+       pci_read_config_word(pdev, I82860_ERRSTS, &info->errsts);
+       pci_read_config_dword(pdev, I82860_EAP, &info->eap);
+       pci_read_config_word(pdev, I82860_DERRCTL_STS, &info->derrsyn);
+       pci_read_config_word(pdev, I82860_ERRSTS, &info->errsts2);
 
-       pci_write_bits16(mci->pdev, I82860_ERRSTS, 0x0003, 0x0003);
+       pci_write_bits16(pdev, I82860_ERRSTS, 0x0003, 0x0003);
 
        /*
         * If the error is the same for both reads then the first set of reads
@@ -83,8 +89,8 @@ static void i82860_get_error_info(struct mem_ctl_info *mci,
                return;
 
        if ((info->errsts ^ info->errsts2) & 0x0003) {
-               pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap);
-               pci_read_config_word(mci->pdev, I82860_DERRCTL_STS,
+               pci_read_config_dword(pdev, I82860_EAP, &info->eap);
+               pci_read_config_word(pdev, I82860_DERRCTL_STS,
                                &info->derrsyn);
        }
 }
@@ -126,15 +132,50 @@ static void i82860_check(struct mem_ctl_info *mci)
        i82860_process_error_info(mci, &info, 1);
 }
 
-static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
+static void i82860_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev)
 {
-       int rc = -ENODEV;
-       int index;
-       struct mem_ctl_info *mci = NULL;
        unsigned long last_cumul_size;
-       struct i82860_error_info discard;
+       u16 mchcfg_ddim;  /* DRAM Data Integrity Mode 0=none, 2=edac */
+       u16 value;
+       u32 cumul_size;
+       struct csrow_info *csrow;
+       int index;
+
+       pci_read_config_word(pdev, I82860_MCHCFG, &mchcfg_ddim);
+       mchcfg_ddim = mchcfg_ddim & 0x180;
+       last_cumul_size = 0;
+
+       /* The group row boundary (GRA) reg values are boundary address
+        * for each DRAM row with a granularity of 16MB.  GRA regs are
+        * cumulative; therefore GRA15 will contain the total memory contained
+        * in all eight rows.
+        */
+       for (index = 0; index < mci->nr_csrows; index++) {
+               csrow = &mci->csrows[index];
+               pci_read_config_word(pdev, I82860_GBA + index * 2, &value);
+               cumul_size = (value & I82860_GBA_MASK) <<
+                   (I82860_GBA_SHIFT - PAGE_SHIFT);
+               debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
+                       cumul_size);
 
-       u16 mchcfg_ddim;        /* DRAM Data Integrity Mode 0=none,2=edac */
+               if (cumul_size == last_cumul_size)
+                       continue;       /* not populated */
+
+               csrow->first_page = last_cumul_size;
+               csrow->last_page = cumul_size - 1;
+               csrow->nr_pages = cumul_size - last_cumul_size;
+               last_cumul_size = cumul_size;
+               csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */
+               csrow->mtype = MEM_RMBS;
+               csrow->dtype = DEV_UNKNOWN;
+               csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE;
+       }
+}
+
+static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
+{
+       struct mem_ctl_info *mci;
+       struct i82860_error_info discard;
 
        /* RDRAM has channels but these don't map onto the abstractions that
           edac uses.
@@ -150,67 +191,35 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
                return -ENOMEM;
 
        debugf3("%s(): init mci\n", __func__);
-       mci->pdev = pdev;
+       mci->dev = &pdev->dev;
        mci->mtype_cap = MEM_FLAG_DDR;
-
        mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
        /* I"m not sure about this but I think that all RDRAM is SECDED */
        mci->edac_cap = EDAC_FLAG_SECDED;
-       /* adjust FLAGS */
-
        mci->mod_name = EDAC_MOD_STR;
-       mci->mod_ver = "$Revision: 1.1.2.6 $";
+       mci->mod_ver = I82860_REVISION;
        mci->ctl_name = i82860_devs[dev_idx].ctl_name;
        mci->edac_check = i82860_check;
        mci->ctl_page_to_phys = NULL;
+       i82860_init_csrows(mci, pdev);
+       i82860_get_error_info(mci, &discard);  /* clear counters */
 
-       pci_read_config_word(mci->pdev, I82860_MCHCFG, &mchcfg_ddim);
-       mchcfg_ddim = mchcfg_ddim & 0x180;
-
-       /*
-        * The group row boundary (GRA) reg values are boundary address
-        * for each DRAM row with a granularity of 16MB.  GRA regs are
-        * cumulative; therefore GRA15 will contain the total memory contained
-        * in all eight rows.
+       /* Here we assume that we will never see multiple instances of this
+        * type of memory controller.  The ID is therefore hardcoded to 0.
         */
-       for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
-               u16 value;
-               u32 cumul_size;
-               struct csrow_info *csrow = &mci->csrows[index];
-
-               pci_read_config_word(mci->pdev, I82860_GBA + index * 2,
-                               &value);
-
-               cumul_size = (value & I82860_GBA_MASK) <<
-                   (I82860_GBA_SHIFT - PAGE_SHIFT);
-               debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
-                       cumul_size);
-
-               if (cumul_size == last_cumul_size)
-                       continue;       /* not populated */
-
-               csrow->first_page = last_cumul_size;
-               csrow->last_page = cumul_size - 1;
-               csrow->nr_pages = cumul_size - last_cumul_size;
-               last_cumul_size = cumul_size;
-               csrow->grain = 1 << 12;  /* I82860_EAP has 4KiB reolution */
-               csrow->mtype = MEM_RMBS;
-               csrow->dtype = DEV_UNKNOWN;
-               csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE;
+       if (edac_mc_add_mc(mci,0)) {
+               debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
+               goto fail;
        }
 
-       i82860_get_error_info(mci, &discard);  /* clear counters */
+       /* get this far and it's successful */
+       debugf3("%s(): success\n", __func__);
 
-       if (edac_mc_add_mc(mci)) {
-               debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
-               edac_mc_free(mci);
-       } else {
-               /* get this far and it's successful */
-               debugf3("%s(): success\n", __func__);
-               rc = 0;
-       }
+       return 0;
 
-       return rc;
+fail:
+       edac_mc_free(mci);
+       return -ENODEV;
 }
 
 /* returns count (>= 0), or negative on error */
@@ -239,7 +248,7 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
-       if ((mci = edac_mc_del_mc(pdev)) == NULL)
+       if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
        edac_mc_free(mci);
index e1d751d..9423ee5 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/slab.h>
 #include "edac_mc.h"
 
+#define I82875P_REVISION       " Ver: 2.0.0 " __DATE__
+
 #define i82875p_printk(level, fmt, arg...) \
        edac_printk(level, "i82875p", fmt, ##arg)
 
@@ -184,18 +186,22 @@ static int i82875p_registered = 1;
 static void i82875p_get_error_info(struct mem_ctl_info *mci,
                struct i82875p_error_info *info)
 {
+       struct pci_dev *pdev;
+
+       pdev = to_pci_dev(mci->dev);
+
        /*
         * This is a mess because there is no atomic way to read all the
         * registers at once and the registers can transition from CE being
         * overwritten by UE.
         */
-       pci_read_config_word(mci->pdev, I82875P_ERRSTS, &info->errsts);
-       pci_read_config_dword(mci->pdev, I82875P_EAP, &info->eap);
-       pci_read_config_byte(mci->pdev, I82875P_DES, &info->des);
-       pci_read_config_byte(mci->pdev, I82875P_DERRSYN, &info->derrsyn);
-       pci_read_config_word(mci->pdev, I82875P_ERRSTS, &info->errsts2);
+       pci_read_config_word(pdev, I82875P_ERRSTS, &info->errsts);
+       pci_read_config_dword(pdev, I82875P_EAP, &info->eap);
+       pci_read_config_byte(pdev, I82875P_DES, &info->des);
+       pci_read_config_byte(pdev, I82875P_DERRSYN, &info->derrsyn);
+       pci_read_config_word(pdev, I82875P_ERRSTS, &info->errsts2);
 
-       pci_write_bits16(mci->pdev, I82875P_ERRSTS, 0x0081, 0x0081);
+       pci_write_bits16(pdev, I82875P_ERRSTS, 0x0081, 0x0081);
 
        /*
         * If the error is the same then we can for both reads then
@@ -207,9 +213,9 @@ static void i82875p_get_error_info(struct mem_ctl_info *mci,
                return;
 
        if ((info->errsts ^ info->errsts2) & 0x0081) {
-               pci_read_config_dword(mci->pdev, I82875P_EAP, &info->eap);
-               pci_read_config_byte(mci->pdev, I82875P_DES, &info->des);
-               pci_read_config_byte(mci->pdev, I82875P_DERRSYN,
+               pci_read_config_dword(pdev, I82875P_EAP, &info->eap);
+               pci_read_config_byte(pdev, I82875P_DES, &info->des);
+               pci_read_config_byte(pdev, I82875P_DERRSYN,
                                &info->derrsyn);
        }
 }
@@ -258,116 +264,109 @@ static void i82875p_check(struct mem_ctl_info *mci)
 extern int pci_proc_attach_device(struct pci_dev *);
 #endif
 
-static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
+/* Return 0 on success or 1 on failure. */
+static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
+               struct pci_dev **ovrfl_pdev, void __iomem **ovrfl_window)
 {
-       int rc = -ENODEV;
-       int index;
-       struct mem_ctl_info *mci = NULL;
-       struct i82875p_pvt *pvt = NULL;
-       unsigned long last_cumul_size;
-       struct pci_dev *ovrfl_pdev;
-       void __iomem *ovrfl_window = NULL;
-       u32 drc;
-       u32 drc_chan;           /* Number of channels 0=1chan,1=2chan */
-       u32 nr_chans;
-       u32 drc_ddim;           /* DRAM Data Integrity Mode 0=none,2=edac */
-       struct i82875p_error_info discard;
+       struct pci_dev *dev;
+       void __iomem *window;
 
-       debugf0("%s()\n", __func__);
-       ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
+       *ovrfl_pdev = NULL;
+       *ovrfl_window = NULL;
+       dev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
 
-       if (!ovrfl_pdev) {
-               /*
-                * Intel tells BIOS developers to hide device 6 which
+       if (dev == NULL) {
+               /* Intel tells BIOS developers to hide device 6 which
                 * configures the overflow device access containing
                 * the DRBs - this is where we expose device 6.
                 * http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm
                 */
                pci_write_bits8(pdev, 0xf4, 0x2, 0x2);
-               ovrfl_pdev =
-                       pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
+               dev = pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
 
-               if (!ovrfl_pdev)
-                       return -ENODEV;
+               if (dev == NULL)
+                       return 1;
        }
 
+       *ovrfl_pdev = dev;
+
 #ifdef CONFIG_PROC_FS
-       if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) {
-               i82875p_printk(KERN_ERR,
-                       "%s(): Failed to attach overflow device\n", __func__);
-               return -ENODEV;
+       if ((dev->procent == NULL) && pci_proc_attach_device(dev)) {
+               i82875p_printk(KERN_ERR, "%s(): Failed to attach overflow "
+                              "device\n", __func__);
+               return 1;
        }
-#endif
-                               /* CONFIG_PROC_FS */
-       if (pci_enable_device(ovrfl_pdev)) {
-               i82875p_printk(KERN_ERR,
-                       "%s(): Failed to enable overflow device\n", __func__);
-               return -ENODEV;
+#endif  /* CONFIG_PROC_FS */
+       if (pci_enable_device(dev)) {
+               i82875p_printk(KERN_ERR, "%s(): Failed to enable overflow "
+                              "device\n", __func__);
+               return 1;
        }
 
-       if (pci_request_regions(ovrfl_pdev, pci_name(ovrfl_pdev))) {
+       if (pci_request_regions(dev, pci_name(dev))) {
 #ifdef CORRECT_BIOS
                goto fail0;
 #endif
        }
 
        /* cache is irrelevant for PCI bus reads/writes */
-       ovrfl_window = ioremap_nocache(pci_resource_start(ovrfl_pdev, 0),
-                               pci_resource_len(ovrfl_pdev, 0));
+       window = ioremap_nocache(pci_resource_start(dev, 0),
+                                pci_resource_len(dev, 0));
 
-       if (!ovrfl_window) {
+       if (window == NULL) {
                i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n",
-                       __func__);
+                              __func__);
                goto fail1;
        }
 
-       /* need to find out the number of channels */
-       drc = readl(ovrfl_window + I82875P_DRC);
-       drc_chan = ((drc >> 21) & 0x1);
-       nr_chans = drc_chan + 1;
+       *ovrfl_window = window;
+       return 0;
 
-       drc_ddim = (drc >> 18) & 0x1;
-       mci = edac_mc_alloc(sizeof(*pvt), I82875P_NR_CSROWS(nr_chans),
-                               nr_chans);
+fail1:
+       pci_release_regions(dev);
 
-       if (!mci) {
-               rc = -ENOMEM;
-               goto fail2;
-       }
+#ifdef CORRECT_BIOS
+fail0:
+       pci_disable_device(dev);
+#endif
+       /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */
+       return 1;
+}
 
-       debugf3("%s(): init mci\n", __func__);
-       mci->pdev = pdev;
-       mci->mtype_cap = MEM_FLAG_DDR;
-       mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
-       mci->edac_cap = EDAC_FLAG_UNKNOWN;
-       /* adjust FLAGS */
 
-       mci->mod_name = EDAC_MOD_STR;
-       mci->mod_ver = "$Revision: 1.5.2.11 $";
-       mci->ctl_name = i82875p_devs[dev_idx].ctl_name;
-       mci->edac_check = i82875p_check;
-       mci->ctl_page_to_phys = NULL;
-       debugf3("%s(): init pvt\n", __func__);
-       pvt = (struct i82875p_pvt *) mci->pvt_info;
-       pvt->ovrfl_pdev = ovrfl_pdev;
-       pvt->ovrfl_window = ovrfl_window;
+/* Return 1 if dual channel mode is active.  Else return 0. */
+static inline int dual_channel_active(u32 drc)
+{
+       return (drc >> 21) & 0x1;
+}
 
-       /*
-        * The dram row boundary (DRB) reg values are boundary address
+
+static void i82875p_init_csrows(struct mem_ctl_info *mci,
+               struct pci_dev *pdev, void __iomem *ovrfl_window, u32 drc)
+{
+       struct csrow_info *csrow;
+       unsigned long last_cumul_size;
+       u8 value;
+       u32 drc_ddim;  /* DRAM Data Integrity Mode 0=none,2=edac */
+       u32 cumul_size;
+       int index;
+
+       drc_ddim = (drc >> 18) & 0x1;
+       last_cumul_size = 0;
+
+       /* The dram row boundary (DRB) reg values are boundary address
         * for each DRAM row with a granularity of 32 or 64MB (single/dual
         * channel operation).  DRB regs are cumulative; therefore DRB7 will
         * contain the total memory contained in all eight rows.
         */
-       for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
-               u8 value;
-               u32 cumul_size;
-               struct csrow_info *csrow = &mci->csrows[index];
+
+       for (index = 0; index < mci->nr_csrows; index++) {
+               csrow = &mci->csrows[index];
 
                value = readb(ovrfl_window + I82875P_DRB + index);
                cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT);
                debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
                        cumul_size);
-
                if (cumul_size == last_cumul_size)
                        continue;       /* not populated */
 
@@ -375,35 +374,75 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
                csrow->last_page = cumul_size - 1;
                csrow->nr_pages = cumul_size - last_cumul_size;
                last_cumul_size = cumul_size;
-               csrow->grain = 1 << 12;  /* I82875P_EAP has 4KiB reolution */
+               csrow->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */
                csrow->mtype = MEM_DDR;
                csrow->dtype = DEV_UNKNOWN;
                csrow->edac_mode = drc_ddim ? EDAC_SECDED : EDAC_NONE;
        }
+}
+
+static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
+{
+       int rc = -ENODEV;
+       struct mem_ctl_info *mci;
+       struct i82875p_pvt *pvt;
+       struct pci_dev *ovrfl_pdev;
+       void __iomem *ovrfl_window;
+       u32 drc;
+       u32 nr_chans;
+       struct i82875p_error_info discard;
+
+       debugf0("%s()\n", __func__);
+       ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
+
+       if (i82875p_setup_overfl_dev(pdev, &ovrfl_pdev, &ovrfl_window))
+               return -ENODEV;
+       drc = readl(ovrfl_window + I82875P_DRC);
+       nr_chans = dual_channel_active(drc) + 1;
+       mci = edac_mc_alloc(sizeof(*pvt), I82875P_NR_CSROWS(nr_chans),
+                               nr_chans);
+
+       if (!mci) {
+               rc = -ENOMEM;
+               goto fail0;
+       }
 
+       debugf3("%s(): init mci\n", __func__);
+       mci->dev = &pdev->dev;
+       mci->mtype_cap = MEM_FLAG_DDR;
+       mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
+       mci->edac_cap = EDAC_FLAG_UNKNOWN;
+       mci->mod_name = EDAC_MOD_STR;
+       mci->mod_ver = I82875P_REVISION;
+       mci->ctl_name = i82875p_devs[dev_idx].ctl_name;
+       mci->edac_check = i82875p_check;
+       mci->ctl_page_to_phys = NULL;
+       debugf3("%s(): init pvt\n", __func__);
+       pvt = (struct i82875p_pvt *) mci->pvt_info;
+       pvt->ovrfl_pdev = ovrfl_pdev;
+       pvt->ovrfl_window = ovrfl_window;
+       i82875p_init_csrows(mci, pdev, ovrfl_window, drc);
        i82875p_get_error_info(mci, &discard);  /* clear counters */
 
-       if (edac_mc_add_mc(mci)) {
+       /* Here we assume that we will never see multiple instances of this
+        * type of memory controller.  The ID is therefore hardcoded to 0.
+        */
+       if (edac_mc_add_mc(mci,0)) {
                debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
-               goto fail3;
+               goto fail1;
        }
 
        /* get this far and it's successful */
        debugf3("%s(): success\n", __func__);
        return 0;
 
-fail3:
+fail1:
        edac_mc_free(mci);
 
-fail2:
+fail0:
        iounmap(ovrfl_window);
-
-fail1:
        pci_release_regions(ovrfl_pdev);
 
-#ifdef CORRECT_BIOS
-fail0:
-#endif
        pci_disable_device(ovrfl_pdev);
        /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */
        return rc;
@@ -436,7 +475,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
-       if ((mci = edac_mc_del_mc(pdev)) == NULL)
+       if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
        pvt = (struct i82875p_pvt *) mci->pvt_info;
index 4275b14..a0e248d 100644 (file)
@@ -22,6 +22,8 @@
 #include <linux/slab.h>
 #include "edac_mc.h"
 
+#define R82600_REVISION        " Ver: 2.0.0 " __DATE__
+
 #define r82600_printk(level, fmt, arg...) \
        edac_printk(level, "r82600", fmt, ##arg)
 
@@ -133,17 +135,20 @@ static unsigned int disable_hardware_scrub = 0;
 static void r82600_get_error_info (struct mem_ctl_info *mci,
                struct r82600_error_info *info)
 {
-       pci_read_config_dword(mci->pdev, R82600_EAP, &info->eapr);
+       struct pci_dev *pdev;
+
+       pdev = to_pci_dev(mci->dev);
+       pci_read_config_dword(pdev, R82600_EAP, &info->eapr);
 
        if (info->eapr & BIT(0))
                /* Clear error to allow next error to be reported [p.62] */
-               pci_write_bits32(mci->pdev, R82600_EAP,
+               pci_write_bits32(pdev, R82600_EAP,
                                ((u32) BIT(0) & (u32) BIT(1)),
                                ((u32) BIT(0) & (u32) BIT(1)));
 
        if (info->eapr & BIT(1))
                /* Clear error to allow next error to be reported [p.62] */
-               pci_write_bits32(mci->pdev, R82600_EAP,
+               pci_write_bits32(pdev, R82600_EAP,
                                ((u32) BIT(0) & (u32) BIT(1)),
                                ((u32) BIT(0) & (u32) BIT(1)));
 }
@@ -199,25 +204,72 @@ static void r82600_check(struct mem_ctl_info *mci)
        r82600_process_error_info(mci, &info, 1);
 }
 
-static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
+static inline int ecc_enabled(u8 dramcr)
+{
+       return dramcr & BIT(5);
+}
+
+static void r82600_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
+               u8 dramcr)
 {
-       int rc = -ENODEV;
+       struct csrow_info *csrow;
        int index;
-       struct mem_ctl_info *mci = NULL;
+       u8 drbar;  /* SDRAM Row Boundry Address Register */
+       u32 row_high_limit, row_high_limit_last;
+       u32 reg_sdram, ecc_on, row_base;
+
+       ecc_on = ecc_enabled(dramcr);
+       reg_sdram = dramcr & BIT(4);
+       row_high_limit_last = 0;
+
+       for (index = 0; index < mci->nr_csrows; index++) {
+               csrow = &mci->csrows[index];
+
+               /* find the DRAM Chip Select Base address and mask */
+               pci_read_config_byte(pdev, R82600_DRBA + index, &drbar);
+
+               debugf1("%s() Row=%d DRBA = %#0x\n", __func__, index, drbar);
+
+               row_high_limit = ((u32) drbar << 24);
+/*             row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */
+
+               debugf1("%s() Row=%d, Boundry Address=%#0x, Last = %#0x\n",
+                       __func__, index, row_high_limit, row_high_limit_last);
+
+               /* Empty row [p.57] */
+               if (row_high_limit == row_high_limit_last)
+                       continue;
+
+               row_base = row_high_limit_last;
+
+               csrow->first_page = row_base >> PAGE_SHIFT;
+               csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
+               csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
+               /* Error address is top 19 bits - so granularity is      *
+                * 14 bits                                               */
+               csrow->grain = 1 << 14;
+               csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR;
+               /* FIXME - check that this is unknowable with this chipset */
+               csrow->dtype = DEV_UNKNOWN;
+
+               /* Mode is global on 82600 */
+               csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE;
+               row_high_limit_last = row_high_limit;
+       }
+}
+
+static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
+{
+       struct mem_ctl_info *mci;
        u8 dramcr;
-       u32 ecc_on;
-       u32 reg_sdram;
        u32 eapr;
        u32 scrub_disabled;
        u32 sdram_refresh_rate;
-       u32 row_high_limit_last = 0;
        struct r82600_error_info discard;
 
        debugf0("%s()\n", __func__);
        pci_read_config_byte(pdev, R82600_DRAMC, &dramcr);
        pci_read_config_dword(pdev, R82600_EAP, &eapr);
-       ecc_on = dramcr & BIT(5);
-       reg_sdram = dramcr & BIT(4);
        scrub_disabled = eapr & BIT(31);
        sdram_refresh_rate = dramcr & (BIT(0) | BIT(1));
        debugf2("%s(): sdram refresh rate = %#0x\n", __func__,
@@ -225,13 +277,11 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
        debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr);
        mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS);
 
-       if (mci == NULL) {
-               rc = -ENOMEM;
-               goto fail;
-       }
+       if (mci == NULL)
+               return -ENOMEM;
 
        debugf0("%s(): mci = %p\n", __func__, mci);
-       mci->pdev = pdev;
+       mci->dev = &pdev->dev;
        mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
        mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
        /* FIXME try to work out if the chip leads have been used for COM2
@@ -244,7 +294,7 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
         * is possible.                                               */
        mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
 
-       if (ecc_on) {
+       if (ecc_enabled(dramcr)) {
                if (scrub_disabled)
                        debugf3("%s(): mci = %p - Scrubbing disabled! EAP: "
                                "%#0x\n", __func__, mci, eapr);
@@ -252,53 +302,17 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
                mci->edac_cap = EDAC_FLAG_NONE;
 
        mci->mod_name = EDAC_MOD_STR;
-       mci->mod_ver = "$Revision: 1.1.2.6 $";
+       mci->mod_ver = R82600_REVISION;
        mci->ctl_name = "R82600";
        mci->edac_check = r82600_check;
        mci->ctl_page_to_phys = NULL;
-
-       for (index = 0; index < mci->nr_csrows; index++) {
-               struct csrow_info *csrow = &mci->csrows[index];
-               u8 drbar;       /* sDram Row Boundry Address Register */
-               u32 row_high_limit;
-               u32 row_base;
-
-               /* find the DRAM Chip Select Base address and mask */
-               pci_read_config_byte(mci->pdev, R82600_DRBA + index, &drbar);
-
-               debugf1("MC%d: %s() Row=%d DRBA = %#0x\n", mci->mc_idx,
-                       __func__, index, drbar);
-
-               row_high_limit = ((u32) drbar << 24);
-/*             row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */
-
-               debugf1("MC%d: %s() Row=%d, Boundry Address=%#0x, Last = "
-                       "%#0x \n", mci->mc_idx, __func__, index,
-                       row_high_limit, row_high_limit_last);
-
-               /* Empty row [p.57] */
-               if (row_high_limit == row_high_limit_last)
-                       continue;
-
-               row_base = row_high_limit_last;
-               csrow->first_page = row_base >> PAGE_SHIFT;
-               csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
-               csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
-               /* Error address is top 19 bits - so granularity is      *
-                * 14 bits                                               */
-               csrow->grain = 1 << 14;
-               csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR;
-               /* FIXME - check that this is unknowable with this chipset */
-               csrow->dtype = DEV_UNKNOWN;
-
-               /* Mode is global on 82600 */
-               csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE;
-               row_high_limit_last = row_high_limit;
-       }
-
+       r82600_init_csrows(mci, pdev, dramcr);
        r82600_get_error_info(mci, &discard);  /* clear counters */
 
-       if (edac_mc_add_mc(mci)) {
+       /* Here we assume that we will never see multiple instances of this
+        * type of memory controller.  The ID is therefore hardcoded to 0.
+        */
+       if (edac_mc_add_mc(mci,0)) {
                debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
                goto fail;
        }
@@ -308,17 +322,15 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
        if (disable_hardware_scrub) {
                debugf3("%s(): Disabling Hardware Scrub (scrub on error)\n",
                        __func__);
-               pci_write_bits32(mci->pdev, R82600_EAP, BIT(31), BIT(31));
+               pci_write_bits32(pdev, R82600_EAP, BIT(31), BIT(31));
        }
 
        debugf3("%s(): success\n", __func__);
        return 0;
 
 fail:
-       if (mci)
-               edac_mc_free(mci);
-
-       return rc;
+       edac_mc_free(mci);
+       return -ENODEV;
 }
 
 /* returns count (>= 0), or negative on error */
@@ -337,7 +349,7 @@ static void __devexit r82600_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
-       if ((mci = edac_mc_del_mc(pdev)) == NULL)
+       if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
        edac_mc_free(mci);
index 8b46ef7..7be1d0a 100644 (file)
@@ -494,8 +494,8 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
        err = pci_request_region(dev, SMBBAR, i801_driver.name);
        if (err) {
                dev_err(&dev->dev, "Failed to request SMBus region "
-                       "0x%lx-0x%lx\n", i801_smba,
-                       pci_resource_end(dev, SMBBAR));
+                       "0x%lx-0x%Lx\n", i801_smba,
+                       (unsigned long long)pci_resource_end(dev, SMBBAR));
                goto exit;
        }
 
index 602797a..b7e459e 100644 (file)
@@ -146,7 +146,16 @@ static void ide_detach(struct pcmcia_device *link)
     kfree(link->priv);
 } /* ide_detach */
 
-static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle)
+static void idecs_mmio_fixup(ide_hwif_t *hwif)
+{
+       default_hwif_mmiops(hwif);
+       hwif->mmio = 2;
+
+       ide_undecoded_slave(hwif);
+}
+
+static int idecs_register(unsigned long io, unsigned long ctl,
+       unsigned long irq, struct pcmcia_device *handle, int is_mmio)
 {
     hw_regs_t hw;
     memset(&hw, 0, sizeof(hw));
@@ -154,7 +163,19 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
     hw.irq = irq;
     hw.chipset = ide_pci;
     hw.dev = &handle->dev;
-    return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);
+
+    if(is_mmio)
+       return ide_register_hw_with_fixup(&hw, NULL, idecs_mmio_fixup);
+    else
+        return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);
+}
+
+void outb_io(unsigned char value, unsigned long port) {
+       outb(value, port);
+}
+
+void outb_mem(unsigned char value, unsigned long port) {
+       writeb(value, (void __iomem *) port);
 }
 
 /*======================================================================
@@ -180,7 +201,8 @@ static int ide_config(struct pcmcia_device *link)
     } *stk = NULL;
     cistpl_cftable_entry_t *cfg;
     int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0;
-    unsigned long io_base, ctl_base;
+    unsigned long io_base, ctl_base, is_mmio, try_slave;
+    void (*my_outb)(unsigned char, unsigned long);
 
     DEBUG(0, "ide_config(0x%p)\n", link);
 
@@ -210,7 +232,7 @@ static int ide_config(struct pcmcia_device *link)
     /* Not sure if this is right... look up the current Vcc */
     CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
 
-    pass = io_base = ctl_base = 0;
+    pass = io_base = ctl_base = is_mmio = try_slave = 0;
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
     tuple.Attributes = 0;
     CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -258,11 +280,45 @@ static int ide_config(struct pcmcia_device *link)
                        goto next_entry;
                io_base = link->io.BasePort1;
                ctl_base = link->io.BasePort1 + 0x0e;
+
+               if (io->win[0].len >= 0x20)
+                       try_slave = 1;
+
            } else goto next_entry;
            /* If we've got this far, we're done */
            break;
        }
 
+       if ((cfg->mem.nwin > 0) || (stk->dflt.mem.nwin > 0)) {
+           win_req_t req;
+           memreq_t map;
+           cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &stk->dflt.mem;
+
+           if (mem->win[0].len < 16)
+               goto next_entry;
+
+           req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
+           req.Attributes |= WIN_ENABLE;
+           req.Base = mem->win[0].host_addr;
+           req.Size = 0;
+
+           req.AccessSpeed = 0;
+           if (pcmcia_request_window(&link, &req, &link->win) != 0)
+               goto next_entry;
+           map.Page = 0; map.CardOffset = mem->win[0].card_addr;
+           if (pcmcia_map_mem_page(link->win, &map) != 0)
+               goto next_entry;
+
+           io_base = (unsigned long) ioremap(req.Base, req.Size);
+           ctl_base = io_base + 0x0e;
+           is_mmio = 1;
+
+           if (mem->win[0].len >= 0x20)
+               try_slave = 1;
+
+           break;
+       }
+
     next_entry:
        if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
            memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
@@ -278,21 +334,26 @@ static int ide_config(struct pcmcia_device *link)
     CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
     CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
 
+    if(is_mmio)
+       my_outb = outb_mem;
+    else
+       my_outb = outb_io;
+
     /* disable drive interrupts during IDE probe */
-    outb(0x02, ctl_base);
+    my_outb(0x02, ctl_base);
 
     /* special setup for KXLC005 card */
     if (is_kme)
-       outb(0x81, ctl_base+1);
+       my_outb(0x81, ctl_base+1);
 
     /* retry registration in case device is still spinning up */
     for (hd = -1, i = 0; i < 10; i++) {
-       hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link);
+       hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link, is_mmio);
        if (hd >= 0) break;
-       if (link->io.NumPorts1 == 0x20) {
-           outb(0x02, ctl_base + 0x10);
+       if (try_slave) {
+           my_outb(0x02, ctl_base + 0x10);
            hd = idecs_register(io_base + 0x10, ctl_base + 0x10,
-                               link->irq.AssignedIRQ, link);
+                               link->irq.AssignedIRQ, link, is_mmio);
            if (hd >= 0) {
                io_base += 0x10;
                ctl_base += 0x10;
index 4c3f2de..b2c033e 100644 (file)
@@ -54,7 +54,6 @@
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/ioctl.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/cdev.h>
 #include <linux/in.h>
 #include <linux/net.h>
index 5e8bb41..59ac35d 100644 (file)
@@ -570,7 +570,8 @@ static int dvb_frontend_thread(void *data)
                                        dvb_frontend_add_event(fe, s);
                                        fepriv->status = s;
                                }
-                       }
+                       } else
+                               dvb_frontend_swzigzag(fe);
                } else
                        dvb_frontend_swzigzag(fe);
        }
@@ -975,6 +976,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
 
        case FE_SET_FRONTEND_TUNE_MODE:
                fepriv->tune_mode_flags = (unsigned long) parg;
+               err = 0;
                break;
        };
 
index 3c7c09a..13ad1bf 100644 (file)
@@ -134,6 +134,7 @@ static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_paramet
                return -EINVAL;
 
        if (p->code_rate_LP < FEC_1_2 || p->code_rate_LP > FEC_7_8)
+               return -EINVAL;
 
        if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5)
                return -EINVAL;
index f2f795c..274a87b 100644 (file)
@@ -670,10 +670,10 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
        switch (voltage) {
        case SEC_VOLTAGE_13:
                dprintk("%s: setting voltage 13V\n", __FUNCTION__);
-               return cx24123_writereg(state, 0x29, val | 0x80);
+               return cx24123_writereg(state, 0x29, val & 0x7f);
        case SEC_VOLTAGE_18:
                dprintk("%s: setting voltage 18V\n", __FUNCTION__);
-               return cx24123_writereg(state, 0x29, val & 0x7f);
+               return cx24123_writereg(state, 0x29, val | 0x80);
        default:
                return -EINVAL;
        };
index 6163cb0..5f111d4 100644 (file)
@@ -1141,6 +1141,15 @@ static void frontend_init(struct budget_av *budget_av)
                break;
 
        case SUBID_DVBC_KNC1:
+               budget_av->reinitialise_demod = 1;
+               fe = tda10021_attach(&philips_cu1216_config,
+                                    &budget_av->budget.i2c_adap,
+                                    read_pwm(budget_av));
+               if (fe) {
+                       fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
+               }
+               break;
+
        case SUBID_DVBC_KNC1_PLUS:
        case SUBID_DVBC_CINERGY1200:
                budget_av->reinitialise_demod = 1;
@@ -1293,11 +1302,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
 
        budget_av->budget.dvb_adapter.priv = budget_av;
        frontend_init(budget_av);
-
-       if (!budget_av->has_saa7113) {
-               ciintf_init(budget_av);
-       }
-
+       ciintf_init(budget_av);
        return 0;
 }
 
index df57633..de14818 100644 (file)
@@ -3547,11 +3547,6 @@ void __devinit bttv_init_card2(struct bttv *btv)
        /* Hybrid DVB card, DOES have a tda9887 */
        if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE)
                tda9887 = 1;
-       if((btv->tuner_type == TUNER_PHILIPS_FM1216ME_MK3) ||
-          (btv->tuner_type == TUNER_PHILIPS_FM1236_MK3) ||
-          (btv->tuner_type == TUNER_PHILIPS_FM1256_IH3) ||
-           tda9887)
-               request_module("tda9887");
        if (btv->tuner_type != UNSET)
                request_module("tuner");
 }
index 4ff8158..349632b 100644 (file)
@@ -686,6 +686,39 @@ static struct videobuf_queue_ops blackbird_qops = {
 
 /* ------------------------------------------------------------------ */
 
+static const u32 *ctrl_classes[] = {
+       cx88_user_ctrls,
+       cx2341x_mpeg_ctrls,
+       NULL
+};
+
+static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl)
+{
+       qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
+       if (qctrl->id == 0)
+               return -EINVAL;
+
+       /* Standard V4L2 controls */
+       if (cx8800_ctrl_query(qctrl) == 0)
+               return 0;
+
+       /* MPEG V4L2 controls */
+       if (cx2341x_ctrl_query(&dev->params, qctrl))
+               qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
+       return 0;
+}
+
+static int blackbird_querymenu(struct cx8802_dev *dev, struct v4l2_querymenu *qmenu)
+{
+       struct v4l2_queryctrl qctrl;
+
+       qctrl.id = qmenu->id;
+       blackbird_queryctrl(dev, &qctrl);
+       return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
+}
+
+/* ------------------------------------------------------------------ */
+
 static int mpeg_do_ioctl(struct inode *inode, struct file *file,
                         unsigned int cmd, void *arg)
 {
@@ -866,6 +899,16 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
                       core->name);
                return 0;
        }
+       case VIDIOC_QUERYMENU:
+               return blackbird_querymenu(dev, arg);
+       case VIDIOC_QUERYCTRL:
+       {
+               struct v4l2_queryctrl *c = arg;
+
+               if (blackbird_queryctrl(dev, c) == 0)
+                       return 0;
+               return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
+       }
 
        default:
                return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
index f9d68f2..14bd486 100644 (file)
@@ -1194,6 +1194,21 @@ struct cx88_board cx88_boards[] = {
                }},
                .dvb            = 1,
        },
+       [CX88_BOARD_GENIATECH_DVBS] = {
+               .name          = "Geniatech DVB-S",
+               .tuner_type    = TUNER_ABSENT,
+               .radio_type    = UNSET,
+               .tuner_addr    = ADDR_UNSET,
+               .radio_addr    = ADDR_UNSET,
+               .input  = {{
+                       .type  = CX88_VMUX_DVB,
+                       .vmux  = 0,
+               },{
+                       .type  = CX88_VMUX_COMPOSITE1,
+                       .vmux  = 1,
+               }},
+               .dvb      = 1,
+       },
 };
 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
 
@@ -1439,6 +1454,10 @@ struct cx88_subid cx88_subids[] = {
                .subvendor = 0x18ac,
                .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */
                .card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
+       },{
+               .subvendor = 0x14f1,
+               .subdevice = 0x0084,
+               .card      = CX88_BOARD_GENIATECH_DVBS,
        },
 };
 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
index dce1fed..afde378 100644 (file)
@@ -496,6 +496,26 @@ static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t
        return 0;
 }
 
+static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+{
+       struct cx8802_dev *dev= fe->dvb->priv;
+       struct cx88_core *core = dev->core;
+
+       if (voltage == SEC_VOLTAGE_OFF) {
+               dprintk(1,"LNB Voltage OFF\n");
+               cx_write(MO_GP0_IO, 0x0000efff);
+       }
+
+       if (core->prev_set_voltage)
+               return core->prev_set_voltage(fe, voltage);
+       return 0;
+}
+
+static struct cx24123_config geniatech_dvbs_config = {
+       .demod_address  = 0x55,
+       .set_ts_params  = cx24123_set_ts_param,
+};
+
 static struct cx24123_config hauppauge_novas_config = {
        .demod_address          = 0x55,
        .set_ts_params          = cx24123_set_ts_param,
@@ -760,6 +780,14 @@ static int dvb_register(struct cx8802_dev *dev)
                        dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
                }
                break;
+       case CX88_BOARD_GENIATECH_DVBS:
+               dev->dvb.frontend = cx24123_attach(&geniatech_dvbs_config,
+                                                  &dev->core->i2c_adap);
+               if (dev->dvb.frontend) {
+                       dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
+                       dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
+               }
+               break;
 #endif
        default:
                printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
index 8d5cf47..c538d99 100644 (file)
@@ -327,6 +327,51 @@ static struct cx88_ctrl cx8800_ctls[] = {
 };
 static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
 
+const u32 cx88_user_ctrls[] = {
+       V4L2_CID_USER_CLASS,
+       V4L2_CID_BRIGHTNESS,
+       V4L2_CID_CONTRAST,
+       V4L2_CID_SATURATION,
+       V4L2_CID_HUE,
+       V4L2_CID_AUDIO_VOLUME,
+       V4L2_CID_AUDIO_BALANCE,
+       V4L2_CID_AUDIO_MUTE,
+       0
+};
+EXPORT_SYMBOL(cx88_user_ctrls);
+
+static const u32 *ctrl_classes[] = {
+       cx88_user_ctrls,
+       NULL
+};
+
+int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl)
+{
+       int i;
+
+       if (qctrl->id < V4L2_CID_BASE ||
+           qctrl->id >= V4L2_CID_LASTP1)
+               return -EINVAL;
+       for (i = 0; i < CX8800_CTLS; i++)
+               if (cx8800_ctls[i].v.id == qctrl->id)
+                       break;
+       if (i == CX8800_CTLS) {
+               *qctrl = no_ctl;
+               return 0;
+       }
+       *qctrl = cx8800_ctls[i].v;
+       return 0;
+}
+EXPORT_SYMBOL(cx8800_ctrl_query);
+
+static int cx88_queryctrl(struct v4l2_queryctrl *qctrl)
+{
+       qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
+       if (qctrl->id == 0)
+               return -EINVAL;
+       return cx8800_ctrl_query(qctrl);
+}
+
 /* ------------------------------------------------------------------- */
 /* resource management                                                 */
 
@@ -1362,20 +1407,8 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
        case VIDIOC_QUERYCTRL:
        {
                struct v4l2_queryctrl *c = arg;
-               int i;
 
-               if (c->id <  V4L2_CID_BASE ||
-                   c->id >= V4L2_CID_LASTP1)
-                       return -EINVAL;
-               for (i = 0; i < CX8800_CTLS; i++)
-                       if (cx8800_ctls[i].v.id == c->id)
-                               break;
-               if (i == CX8800_CTLS) {
-                       *c = no_ctl;
-                       return 0;
-               }
-               *c = cx8800_ctls[i].v;
-               return 0;
+               return cx88_queryctrl(c);
        }
        case VIDIOC_G_CTRL:
                return get_control(core,arg);
@@ -1893,8 +1926,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
        /* load and configure helper modules */
        if (TUNER_ABSENT != core->tuner_type)
                request_module("tuner");
-       if (core->tda9887_conf)
-               request_module("tda9887");
 
        /* register v4l devices */
        dev->video_dev = cx88_vdev_init(core,dev->pci,
index 9a9a0fc..e781095 100644 (file)
@@ -196,6 +196,7 @@ extern struct sram_channel cx88_sram_channels[];
 #define CX88_BOARD_PIXELVIEW_PLAYTV_P7000  49
 #define CX88_BOARD_NPGTECH_REALTV_TOP10FM  50
 #define CX88_BOARD_WINFAST_DTV2000H        51
+#define CX88_BOARD_GENIATECH_DVBS          52
 
 enum cx88_itype {
        CX88_VMUX_COMPOSITE1 = 1,
@@ -590,6 +591,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev);
 extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
                                struct cx88_core *core, unsigned int cmd,
                                void *arg, v4l2_kioctl driver_ioctl);
+extern const u32 cx88_user_ctrls[];
+extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl);
 
 /*
  * Local variables:
index 9286090..2a461dd 100644 (file)
@@ -1574,8 +1574,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
                request_module("tvp5150");
        if (dev->has_tuner)
                request_module("tuner");
-       if (dev->tda9887_conf)
-               request_module("tda9887");
 #endif
        errCode = em28xx_config(dev);
        if (errCode) {
index 4e45104..545e4ac 100644 (file)
@@ -90,8 +90,8 @@ struct msp_state {
        /* thread */
        struct task_struct   *kthread;
        wait_queue_head_t    wq;
-       int                  restart:1;
-       int                  watch_stereo:1;
+       unsigned int         restart:1;
+       unsigned int         watch_stereo:1;
 };
 
 /* msp3400-driver.c */
index fed603a..02e4142 100644 (file)
@@ -8,7 +8,7 @@ obj-pvrusb2-24xxx-$(CONFIG_VIDEO_PVRUSB2_24XXX) := \
 pvrusb2-objs   := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \
                   pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \
                   pvrusb2-encoder.o pvrusb2-video-v4l.o \
-                  pvrusb2-eeprom.o pvrusb2-tuner.o pvrusb2-demod.o \
+                  pvrusb2-eeprom.o pvrusb2-tuner.o \
                   pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \
                   pvrusb2-ctrl.o pvrusb2-std.o \
                   pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \
index 313d2dc..9846c46 100644 (file)
@@ -145,8 +145,8 @@ static int get_audio_status(struct pvr2_msp3400_handler *ctxt)
 
 static void pvr2_msp3400_detach(struct pvr2_msp3400_handler *ctxt)
 {
-       ctxt->client->handler = 0;
-       ctxt->hdw->audio_stat = 0;
+       ctxt->client->handler = NULL;
+       ctxt->hdw->audio_stat = NULL;
        kfree(ctxt);
 }
 
index 40dc598..f129f31 100644 (file)
@@ -77,7 +77,7 @@ struct pvr2_context *pvr2_context_create(
        const struct usb_device_id *devid,
        void (*setup_func)(struct pvr2_context *))
 {
-       struct pvr2_context *mp = 0;
+       struct pvr2_context *mp = NULL;
        mp = kmalloc(sizeof(*mp),GFP_KERNEL);
        if (!mp) goto done;
        memset(mp,0,sizeof(*mp));
@@ -87,7 +87,7 @@ struct pvr2_context *pvr2_context_create(
        mp->hdw = pvr2_hdw_create(intf,devid);
        if (!mp->hdw) {
                pvr2_context_destroy(mp);
-               mp = 0;
+               mp = NULL;
                goto done;
        }
 
@@ -145,7 +145,7 @@ void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp)
 {
        cp->hdw = mp->hdw;
        cp->mc_head = mp;
-       cp->mc_next = 0;
+       cp->mc_next = NULL;
        cp->mc_prev = mp->mc_last;
        if (mp->mc_last) {
                mp->mc_last->mc_next = cp;
@@ -160,8 +160,8 @@ static void pvr2_channel_disclaim_stream(struct pvr2_channel *cp)
 {
        if (!cp->stream) return;
        pvr2_stream_kill(cp->stream->stream);
-       cp->stream->user = 0;
-       cp->stream = 0;
+       cp->stream->user = NULL;
+       cp->stream = NULL;
 }
 
 
@@ -179,7 +179,7 @@ void pvr2_channel_done(struct pvr2_channel *cp)
        } else {
                mp->mc_first = cp->mc_next;
        }
-       cp->hdw = 0;
+       cp->hdw = NULL;
 }
 
 
@@ -212,7 +212,7 @@ struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
 {
        struct pvr2_ioread *cp;
        cp = pvr2_ioread_create();
-       if (!cp) return 0;
+       if (!cp) return NULL;
        pvr2_ioread_setup(cp,sp->stream);
        pvr2_ioread_set_sync_key(cp,stream_sync_key,sizeof(stream_sync_key));
        return cp;
index d5df9fb..fb6198f 100644 (file)
@@ -158,7 +158,7 @@ int pvr2_ctrl_get_mask(struct pvr2_ctrl *cptr)
 /* Retrieve the control's name */
 const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr)
 {
-       if (!cptr) return 0;
+       if (!cptr) return NULL;
        return cptr->info->name;
 }
 
@@ -166,7 +166,7 @@ const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr)
 /* Retrieve the control's desc */
 const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *cptr)
 {
-       if (!cptr) return 0;
+       if (!cptr) return NULL;
        return cptr->info->desc;
 }
 
@@ -488,7 +488,7 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr,
 
        LOCK_TAKE(cptr->hdw->big_lock); do {
                if (cptr->info->type == pvr2_ctl_int) {
-                       ret = parse_token(ptr,len,valptr,0,0);
+                       ret = parse_token(ptr,len,valptr,NULL,0);
                        if ((ret >= 0) &&
                            ((*valptr < cptr->info->def.type_int.min_value) ||
                             (*valptr > cptr->info->def.type_int.max_value))) {
index 27eadaf..c80c26b 100644 (file)
@@ -139,8 +139,8 @@ static const struct pvr2_v4l_cx2584x_ops decoder_ops[] = {
 
 static void decoder_detach(struct pvr2_v4l_cx2584x *ctxt)
 {
-       ctxt->client->handler = 0;
-       ctxt->hdw->decoder_ctrl = 0;
+       ctxt->client->handler = NULL;
+       ctxt->hdw->decoder_ctrl = NULL;
        kfree(ctxt);
 }
 
@@ -221,7 +221,7 @@ static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
 static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
 {
        int ret;
-       ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0);
+       ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,NULL);
        pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
 }
 
index 586900e..f985f00 100644 (file)
@@ -82,7 +82,7 @@ static unsigned int debugifc_isolate_word(const char *buf,unsigned int count,
        unsigned int wlen;
        unsigned int scnt;
 
-       wptr = 0;
+       wptr = NULL;
        wlen = 0;
        scnt = debugifc_count_whitespace(buf,count);
        consume_cnt += scnt; count -= scnt; buf += scnt;
@@ -337,8 +337,8 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
 }
 
 
-int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
-                        unsigned int count)
+static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
+                               unsigned int count)
 {
        const char *wptr;
        unsigned int wlen;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-demod.c b/drivers/media/video/pvrusb2/pvrusb2-demod.c
deleted file mode 100644 (file)
index 9686569..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- *
- *  $Id$
- *
- *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
- *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "pvrusb2.h"
-#include "pvrusb2-util.h"
-#include "pvrusb2-demod.h"
-#include "pvrusb2-hdw-internal.h"
-#include "pvrusb2-debug.h"
-#include <linux/videodev2.h>
-#include <media/tuner.h>
-#include <media/v4l2-common.h>
-
-
-struct pvr2_demod_handler {
-       struct pvr2_hdw *hdw;
-       struct pvr2_i2c_client *client;
-       struct pvr2_i2c_handler i2c_handler;
-       int type_update_fl;
-};
-
-
-static void set_config(struct pvr2_demod_handler *ctxt)
-{
-       struct pvr2_hdw *hdw = ctxt->hdw;
-       int cfg = 0;
-
-       switch (hdw->tuner_type) {
-       case TUNER_PHILIPS_FM1216ME_MK3:
-       case TUNER_PHILIPS_FM1236_MK3:
-               cfg = TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE;
-               break;
-       default:
-               break;
-       }
-       pvr2_trace(PVR2_TRACE_CHIPS,"i2c demod set_config(0x%x)",cfg);
-       pvr2_i2c_client_cmd(ctxt->client,TDA9887_SET_CONFIG,&cfg);
-       ctxt->type_update_fl = 0;
-}
-
-
-static int demod_check(struct pvr2_demod_handler *ctxt)
-{
-       struct pvr2_hdw *hdw = ctxt->hdw;
-       if (hdw->tuner_updated) ctxt->type_update_fl = !0;
-       return ctxt->type_update_fl != 0;
-}
-
-
-static void demod_update(struct pvr2_demod_handler *ctxt)
-{
-       if (ctxt->type_update_fl) set_config(ctxt);
-}
-
-
-static void demod_detach(struct pvr2_demod_handler *ctxt)
-{
-       ctxt->client->handler = 0;
-       kfree(ctxt);
-}
-
-
-static unsigned int demod_describe(struct pvr2_demod_handler *ctxt,char *buf,unsigned int cnt)
-{
-       return scnprintf(buf,cnt,"handler: pvrusb2-demod");
-}
-
-
-const static struct pvr2_i2c_handler_functions tuner_funcs = {
-       .detach = (void (*)(void *))demod_detach,
-       .check = (int (*)(void *))demod_check,
-       .update = (void (*)(void *))demod_update,
-       .describe = (unsigned int (*)(void *,char *,unsigned int))demod_describe,
-};
-
-
-int pvr2_i2c_demod_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
-{
-       struct pvr2_demod_handler *ctxt;
-       if (cp->handler) return 0;
-
-       ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
-       if (!ctxt) return 0;
-       memset(ctxt,0,sizeof(*ctxt));
-
-       ctxt->i2c_handler.func_data = ctxt;
-       ctxt->i2c_handler.func_table = &tuner_funcs;
-       ctxt->type_update_fl = !0;
-       ctxt->client = cp;
-       ctxt->hdw = hdw;
-       cp->handler = &ctxt->i2c_handler;
-       pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x tda9887 V4L2 handler set up",
-                  cp->client->addr);
-       return !0;
-}
-
-
-
-
-/*
-  Stuff for Emacs to see, in order to encourage consistent editing style:
-  *** Local Variables: ***
-  *** mode: c ***
-  *** fill-column: 70 ***
-  *** tab-width: 8 ***
-  *** c-basic-offset: 8 ***
-  *** End: ***
-  */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-demod.h b/drivers/media/video/pvrusb2/pvrusb2-demod.h
deleted file mode 100644 (file)
index 4c4e40f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- *  $Id$
- *
- *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-#ifndef __PVRUSB2_DEMOD_H
-#define __PVRUSB2_DEMOD_H
-
-#include "pvrusb2-i2c-core.h"
-
-int pvr2_i2c_demod_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
-
-#endif /* __PVRUSB2_DEMOD_H */
-
-/*
-  Stuff for Emacs to see, in order to encourage consistent editing style:
-  *** Local Variables: ***
-  *** mode: c ***
-  *** fill-column: 70 ***
-  *** tab-width: 8 ***
-  *** c-basic-offset: 8 ***
-  *** End: ***
-  */
index 94d383f..6cff8e7 100644 (file)
@@ -58,7 +58,7 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
                pvr2_trace(PVR2_TRACE_ERROR_LEGS,
                           "Failed to allocate memory"
                           " required to read eeprom");
-               return 0;
+               return NULL;
        }
 
        trace_eeprom("Value for eeprom addr from controller was 0x%x",
@@ -108,7 +108,7 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
                        pvr2_trace(PVR2_TRACE_ERROR_LEGS,
                                   "eeprom fetch set offs err=%d",ret);
                        kfree(eeprom);
-                       return 0;
+                       return NULL;
                }
        }
        return eeprom;
index 2cc3169..18a7073 100644 (file)
@@ -65,7 +65,7 @@ static int pvr2_encoder_write_words(struct pvr2_hdw *hdw,
                }
                ret = pvr2_send_request(hdw,
                                        hdw->cmd_buffer,1+(chunkCnt*7),
-                                       0,0);
+                                       NULL,0);
                if (ret) return ret;
                data += chunkCnt;
                dlen -= chunkCnt;
@@ -322,7 +322,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
        }
 
        ret = cx2341x_update(hdw,pvr2_encoder_cmd,
-                            (hdw->enc_cur_valid ? &hdw->enc_cur_state : 0),
+                            (hdw->enc_cur_valid ? &hdw->enc_cur_state : NULL),
                             &hdw->enc_ctl_state);
        if (ret) {
                pvr2_trace(PVR2_TRACE_ERROR_LEGS,
index ba2afbf..0d6dc33 100644 (file)
@@ -354,23 +354,6 @@ struct pvr2_hdw {
        unsigned int control_cnt;
 };
 
-int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
-
-unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *);
-
-void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
-                                    unsigned long msk,unsigned long val);
-void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
-                                           unsigned long msk,
-                                           unsigned long val);
-
-void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
-void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
-
-int pvr2_i2c_basic_op(struct pvr2_hdw *,u8 i2c_addr,
-                     u8 *wdata,u16 wlen,
-                     u8 *rdata,u16 rlen);
-
 #endif /* __PVRUSB2_HDW_INTERNAL_H */
 
 /*
index 643c471..9b48abc 100644 (file)
@@ -63,7 +63,6 @@ struct pvr2_string_table {
 static const char *pvr2_client_24xxx[] = {
        "cx25840",
        "tuner",
-       "tda9887",
        "wm8775",
 };
 #endif
@@ -73,7 +72,6 @@ static const char *pvr2_client_29xxx[] = {
        "msp3400",
        "saa7115",
        "tuner",
-       "tda9887",
 };
 
 static struct pvr2_string_table pvr2_client_lists[] = {
@@ -89,8 +87,8 @@ static struct pvr2_string_table pvr2_client_lists[] = {
 #endif
 };
 
-static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0};
-DECLARE_MUTEX(pvr2_unit_sem);
+static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
+static DECLARE_MUTEX(pvr2_unit_sem);
 
 static int ctlchg = 0;
 static int initusbreset = 1;
@@ -263,6 +261,25 @@ static const char *control_values_subsystem[] = {
        [PVR2_SUBSYS_B_ENC_RUN] = "enc_run",
 };
 
+static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
+static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
+static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
+static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw);
+static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
+static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
+static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw);
+static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                           unsigned long msk,
+                                           unsigned long val);
+static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                                  unsigned long msk,
+                                                  unsigned long val);
+static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
+                               unsigned int timeout,int probe_fl,
+                               void *write_data,unsigned int write_len,
+                               void *read_data,unsigned int read_len);
+static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res);
+static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res);
 
 static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
 {
@@ -405,7 +422,7 @@ static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr)
        info = (struct pvr2_ctl_info *)(cptr->info);
        if (qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY) {
                if (info->set_value) {
-                       info->set_value = 0;
+                       info->set_value = NULL;
                }
        } else {
                if (!(info->set_value)) {
@@ -836,14 +853,6 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
 }
 
 
-struct pvr2_hdw *pvr2_hdw_find(int unit_number)
-{
-       if (unit_number < 0) return 0;
-       if (unit_number >= PVR_NUM) return 0;
-       return unit_pointers[unit_number];
-}
-
-
 int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
 {
        return hdw->unit_number;
@@ -917,9 +926,9 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
  * is not suitable for an usb transaction.
  *
  */
-int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
+static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
 {
-       const struct firmware *fw_entry = 0;
+       const struct firmware *fw_entry = NULL;
        void  *fw_ptr;
        unsigned int pipe;
        int ret;
@@ -1015,7 +1024,7 @@ int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
 
 int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
 {
-       const struct firmware *fw_entry = 0;
+       const struct firmware *fw_entry = NULL;
        void  *fw_ptr;
        unsigned int pipe, fw_len, fw_done;
        int actual_length;
@@ -1166,8 +1175,9 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
   reconfigure and start over.
 
 */
-void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
-                                    unsigned long msk,unsigned long val)
+static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                           unsigned long msk,
+                                           unsigned long val)
 {
        unsigned long nmsk;
        unsigned long vmsk;
@@ -1318,18 +1328,6 @@ void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
 }
 
 
-void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk)
-{
-       pvr2_hdw_subsys_bit_chg(hdw,msk,msk);
-}
-
-
-void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk)
-{
-       pvr2_hdw_subsys_bit_chg(hdw,msk,0);
-}
-
-
 unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw)
 {
        return hdw->subsys_enabled_mask;
@@ -1342,9 +1340,9 @@ unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
 }
 
 
-void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
-                                           unsigned long msk,
-                                           unsigned long val)
+static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                                  unsigned long msk,
+                                                  unsigned long val)
 {
        unsigned long val2;
        msk &= PVR2_SUBSYS_ALL;
@@ -1366,7 +1364,7 @@ void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
 }
 
 
-int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
+static int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
 {
        if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0;
        if (enableFl) {
@@ -1400,8 +1398,8 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
 }
 
 
-int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
-                                    enum pvr2_config config)
+static int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
+                                           enum pvr2_config config)
 {
        unsigned long sm = hdw->subsys_enabled_mask;
        if (!hdw->flag_ok) return -EIO;
@@ -1741,7 +1739,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
            sizeof(pvr2_device_names)/sizeof(pvr2_device_names[0])) {
                pvr2_trace(PVR2_TRACE_ERROR_LEGS,
                           "Bogus device type of %u reported",hdw_type);
-               return 0;
+               return NULL;
        }
 
        hdw = kmalloc(sizeof(*hdw),GFP_KERNEL);
@@ -1922,38 +1920,38 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
                if (hdw->mpeg_ctrl_info) kfree(hdw->mpeg_ctrl_info);
                kfree(hdw);
        }
-       return 0;
+       return NULL;
 }
 
 
 /* Remove _all_ associations between this driver and the underlying USB
    layer. */
-void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
+static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
 {
        if (hdw->flag_disconnected) return;
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw);
        if (hdw->ctl_read_urb) {
                usb_kill_urb(hdw->ctl_read_urb);
                usb_free_urb(hdw->ctl_read_urb);
-               hdw->ctl_read_urb = 0;
+               hdw->ctl_read_urb = NULL;
        }
        if (hdw->ctl_write_urb) {
                usb_kill_urb(hdw->ctl_write_urb);
                usb_free_urb(hdw->ctl_write_urb);
-               hdw->ctl_write_urb = 0;
+               hdw->ctl_write_urb = NULL;
        }
        if (hdw->ctl_read_buffer) {
                kfree(hdw->ctl_read_buffer);
-               hdw->ctl_read_buffer = 0;
+               hdw->ctl_read_buffer = NULL;
        }
        if (hdw->ctl_write_buffer) {
                kfree(hdw->ctl_write_buffer);
-               hdw->ctl_write_buffer = 0;
+               hdw->ctl_write_buffer = NULL;
        }
        pvr2_hdw_render_useless_unlocked(hdw);
        hdw->flag_disconnected = !0;
-       hdw->usb_dev = 0;
-       hdw->usb_intf = 0;
+       hdw->usb_dev = NULL;
+       hdw->usb_intf = NULL;
 }
 
 
@@ -1963,11 +1961,11 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw);
        if (hdw->fw_buffer) {
                kfree(hdw->fw_buffer);
-               hdw->fw_buffer = 0;
+               hdw->fw_buffer = NULL;
        }
        if (hdw->vid_stream) {
                pvr2_stream_destroy(hdw->vid_stream);
-               hdw->vid_stream = 0;
+               hdw->vid_stream = NULL;
        }
        if (hdw->audio_stat) {
                hdw->audio_stat->detach(hdw->audio_stat->ctxt);
@@ -1981,7 +1979,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
                if ((hdw->unit_number >= 0) &&
                    (hdw->unit_number < PVR_NUM) &&
                    (unit_pointers[hdw->unit_number] == hdw)) {
-                       unit_pointers[hdw->unit_number] = 0;
+                       unit_pointers[hdw->unit_number] = NULL;
                }
        } while (0); up(&pvr2_unit_sem);
        if (hdw->controls) kfree(hdw->controls);
@@ -2018,7 +2016,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
 
 // Attempt to autoselect an appropriate value for std_enum_cur given
 // whatever is currently in std_mask_cur
-void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
+static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
 {
        unsigned int idx;
        for (idx = 1; idx < hdw->std_enum_cnt; idx++) {
@@ -2033,7 +2031,7 @@ void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
 
 // Calculate correct set of enumerated standards based on currently known
 // set of available standards bits.
-void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
+static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
 {
        struct v4l2_standard *newstd;
        unsigned int std_cnt;
@@ -2043,12 +2041,12 @@ void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
 
        if (hdw->std_defs) {
                kfree(hdw->std_defs);
-               hdw->std_defs = 0;
+               hdw->std_defs = NULL;
        }
        hdw->std_enum_cnt = 0;
        if (hdw->std_enum_names) {
                kfree(hdw->std_enum_names);
-               hdw->std_enum_names = 0;
+               hdw->std_enum_names = NULL;
        }
 
        if (!std_cnt) {
@@ -2099,7 +2097,7 @@ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
                                             unsigned int idx)
 {
-       if (idx >= hdw->control_cnt) return 0;
+       if (idx >= hdw->control_cnt) return NULL;
        return hdw->controls + idx;
 }
 
@@ -2118,7 +2116,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
                i = cptr->info->internal_id;
                if (i && (i == ctl_id)) return cptr;
        }
-       return 0;
+       return NULL;
 }
 
 
@@ -2135,7 +2133,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id
                i = cptr->info->v4l_id;
                if (i && (i == ctl_id)) return cptr;
        }
-       return 0;
+       return NULL;
 }
 
 
@@ -2149,7 +2147,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
        int i;
 
        /* This could be made a lot more efficient, but for now... */
-       cp2 = 0;
+       cp2 = NULL;
        for (idx = 0; idx < hdw->control_cnt; idx++) {
                cptr = hdw->controls + idx;
                i = cptr->info->v4l_id;
@@ -2159,7 +2157,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
                cp2 = cptr;
        }
        return cp2;
-       return 0;
+       return NULL;
 }
 
 
@@ -2182,7 +2180,7 @@ static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
    state(s) back to their previous value before this function was called.
    Thus we can automatically reconfigure affected pieces of the driver as
    controls are changed. */
-int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
+static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
 {
        unsigned long saved_subsys_mask = hdw->subsys_enabled_mask;
        unsigned long stale_subsys_mask = 0;
@@ -2321,14 +2319,6 @@ void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *hdw)
 }
 
 
-void pvr2_hdw_poll_trigger(struct pvr2_hdw *hdw)
-{
-       LOCK_TAKE(hdw->big_lock); do {
-               pvr2_hdw_poll_trigger_unlocked(hdw);
-       } while (0); LOCK_GIVE(hdw->big_lock);
-}
-
-
 /* Return name for this driver instance */
 const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
 {
@@ -2337,7 +2327,7 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
 
 
 /* Return bit mask indicating signal status */
-unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
+static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
 {
        unsigned int msk = 0;
        switch (hdw->input_val) {
@@ -2424,7 +2414,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, int enable_flag)
                        pvr2_trace(PVR2_TRACE_FIRMWARE,
                                   "Cleaning up after CPU firmware fetch");
                        kfree(hdw->fw_buffer);
-                       hdw->fw_buffer = 0;
+                       hdw->fw_buffer = NULL;
                        hdw->fw_size = 0;
                        /* Now release the CPU.  It will disconnect and
                           reconnect later. */
@@ -2519,22 +2509,6 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
 }
 
 
-void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw)
-{
-       if (!hdw->usb_dev) return;
-       usb_settoggle(hdw->usb_dev, PVR2_CTL_WRITE_ENDPOINT & 0xf,
-                     !(PVR2_CTL_WRITE_ENDPOINT & USB_DIR_IN), 0);
-       usb_settoggle(hdw->usb_dev, PVR2_CTL_READ_ENDPOINT & 0xf,
-                     !(PVR2_CTL_READ_ENDPOINT & USB_DIR_IN), 0);
-       usb_clear_halt(hdw->usb_dev,
-                      usb_rcvbulkpipe(hdw->usb_dev,
-                                      PVR2_CTL_READ_ENDPOINT & 0x7f));
-       usb_clear_halt(hdw->usb_dev,
-                      usb_sndbulkpipe(hdw->usb_dev,
-                                      PVR2_CTL_WRITE_ENDPOINT & 0x7f));
-}
-
-
 static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs)
 {
        struct pvr2_hdw *hdw = urb->context;
@@ -2568,10 +2542,10 @@ static void pvr2_ctl_timeout(unsigned long data)
 }
 
 
-int pvr2_send_request_ex(struct pvr2_hdw *hdw,
-                        unsigned int timeout,int probe_fl,
-                        void *write_data,unsigned int write_len,
-                        void *read_data,unsigned int read_len)
+static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
+                               unsigned int timeout,int probe_fl,
+                               void *write_data,unsigned int write_len,
+                               void *read_data,unsigned int read_len)
 {
        unsigned int idx;
        int status = 0;
@@ -2826,7 +2800,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
 }
 
 
-int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
+static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
 {
        int ret = 0;
 
@@ -2850,7 +2824,7 @@ int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
 }
 
 
-int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
+static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
 {
        int ret;
 
@@ -2867,7 +2841,7 @@ int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
 }
 
 
-int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
+static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
 {
        int ret;
 
@@ -2883,13 +2857,13 @@ int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
 }
 
 
-void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
+static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
 {
        if (!hdw->flag_ok) return;
        pvr2_trace(PVR2_TRACE_INIT,"render_useless");
        hdw->flag_ok = 0;
        if (hdw->vid_stream) {
-               pvr2_stream_setup(hdw->vid_stream,0,0,0);
+               pvr2_stream_setup(hdw->vid_stream,NULL,0,0);
        }
        hdw->flag_streaming_enabled = 0;
        hdw->subsys_enabled_mask = 0;
@@ -2908,7 +2882,7 @@ void pvr2_hdw_device_reset(struct pvr2_hdw *hdw)
 {
        int ret;
        pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset...");
-       ret = usb_lock_device_for_reset(hdw->usb_dev,0);
+       ret = usb_lock_device_for_reset(hdw->usb_dev,NULL);
        if (ret == 1) {
                ret = usb_reset_device(hdw->usb_dev);
                usb_unlock_device(hdw->usb_dev);
@@ -2957,7 +2931,7 @@ int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw)
                pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset");
                hdw->flag_ok = !0;
                hdw->cmd_buffer[0] = 0xdd;
-               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
+               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        return status;
 }
@@ -2969,7 +2943,7 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw)
        LOCK_TAKE(hdw->ctl_lock); do {
                pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup");
                hdw->cmd_buffer[0] = 0xde;
-               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
+               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        return status;
 }
@@ -2996,12 +2970,12 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
 }
 
 
-int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
+static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
 {
        int status;
        LOCK_TAKE(hdw->ctl_lock); do {
                hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37);
-               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
+               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        if (!status) {
                hdw->subsys_enabled_mask =
@@ -3094,7 +3068,7 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
 }
 
 
-int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
+static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
 {
        int result;
        LOCK_TAKE(hdw->ctl_lock); do {
index 63f5291..fd931b5 100644 (file)
@@ -91,7 +91,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
 void pvr2_hdw_poll(struct pvr2_hdw *);
 
 /* Trigger a poll to take place later at a convenient time */
-void pvr2_hdw_poll_trigger(struct pvr2_hdw *);
 void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *);
 
 /* Register a callback used to trigger a future poll */
@@ -99,9 +98,6 @@ void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *,
                                 void (*func)(void *),
                                 void *data);
 
-/* Get pointer to structure given unit number */
-struct pvr2_hdw *pvr2_hdw_find(int unit_number);
-
 /* Destroy hardware interaction structure */
 void pvr2_hdw_destroy(struct pvr2_hdw *);
 
@@ -180,12 +176,6 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
 void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
                             unsigned long msk,unsigned long val);
 
-/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,msk) */
-void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk);
-
-/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,0) */
-void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk);
-
 /* Retrieve mask indicating which pieces of hardware are currently enabled
    / configured. */
 unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *);
@@ -225,34 +215,18 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
 /* The following entry points are all lower level things you normally don't
    want to worry about. */
 
-/* Attempt to recover from a USB foul-up (in practice I find that if you
-   have to do this, then it's already too late). */
-void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw);
-
 /* Issue a command and get a response from the device.  LOTS of higher
    level stuff is built on this. */
 int pvr2_send_request(struct pvr2_hdw *,
                      void *write_ptr,unsigned int write_len,
                      void *read_ptr,unsigned int read_len);
 
-/* Issue a command and get a response from the device.  This extended
-   version includes a probe flag (which if set means that device errors
-   should not be logged or treated as fatal) and a timeout in jiffies.
-   This can be used to non-lethally probe the health of endpoint 1. */
-int pvr2_send_request_ex(struct pvr2_hdw *,unsigned int timeout,int probe_fl,
-                        void *write_ptr,unsigned int write_len,
-                        void *read_ptr,unsigned int read_len);
-
 /* Slightly higher level device communication functions. */
 int pvr2_write_register(struct pvr2_hdw *, u16, u32);
-int pvr2_read_register(struct pvr2_hdw *, u16, u32 *);
-int pvr2_write_u16(struct pvr2_hdw *, u16, int);
-int pvr2_write_u8(struct pvr2_hdw *, u8, int);
 
 /* Call if for any reason we can't talk to the hardware anymore - this will
    cause the driver to stop flailing on the device. */
 void pvr2_hdw_render_useless(struct pvr2_hdw *);
-void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *);
 
 /* Set / clear 8051's reset bit */
 void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int);
@@ -271,12 +245,6 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *);
 /* Order decoder to reset */
 int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *);
 
-/* Stop / start video stream transport */
-int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
-
-/* Find I2C address of eeprom */
-int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *);
-
 /* Direct manipulation of GPIO bits */
 int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
 int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
index 1dd4f62..fbe6039 100644 (file)
@@ -25,7 +25,6 @@
 #include "pvrusb2-i2c-cmd-v4l2.h"
 #include "pvrusb2-audio.h"
 #include "pvrusb2-tuner.h"
-#include "pvrusb2-demod.h"
 #include "pvrusb2-video-v4l.h"
 #ifdef CONFIG_VIDEO_PVRUSB2_24XXX
 #include "pvrusb2-cx2584x-v4l.h"
@@ -89,11 +88,6 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
                        return;
                }
        }
-       if (id == I2C_DRIVERID_TDA9887) {
-               if (pvr2_i2c_demod_setup(hdw,cp)) {
-                       return;
-               }
-       }
 }
 
 
index 9f81aff..8a9933d 100644 (file)
@@ -196,7 +196,7 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size = {
 static void do_log(struct pvr2_hdw *hdw)
 {
        pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 do_log()");
-       pvr2_i2c_core_cmd(hdw,VIDIOC_LOG_STATUS,0);
+       pvr2_i2c_core_cmd(hdw,VIDIOC_LOG_STATUS,NULL);
 
 }
 
@@ -217,7 +217,7 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_log = {
 void pvr2_v4l2_cmd_stream(struct pvr2_i2c_client *cp,int fl)
 {
        pvr2_i2c_client_cmd(cp,
-                           (fl ? VIDIOC_STREAMON : VIDIOC_STREAMOFF),0);
+                           (fl ? VIDIOC_STREAMON : VIDIOC_STREAMOFF),NULL);
 }
 
 
index c8d0bde..7fca479 100644 (file)
@@ -37,6 +37,10 @@ static unsigned int i2c_scan = 0;
 module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
 
+static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
+                                            unsigned int detail,
+                                            char *buf,unsigned int maxlen);
+
 static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
                          u8 i2c_addr,      /* I2C address we're talking to */
                          u8 *data,         /* Data to write */
@@ -165,12 +169,12 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
 
 /* This is the common low level entry point for doing I2C operations to the
    hardware. */
-int pvr2_i2c_basic_op(struct pvr2_hdw *hdw,
-                     u8 i2c_addr,
-                     u8 *wdata,
-                     u16 wlen,
-                     u8 *rdata,
-                     u16 rlen)
+static int pvr2_i2c_basic_op(struct pvr2_hdw *hdw,
+                            u8 i2c_addr,
+                            u8 *wdata,
+                            u16 wlen,
+                            u8 *rdata,
+                            u16 rlen)
 {
        if (!rdata) rlen = 0;
        if (!wdata) wlen = 0;
@@ -267,7 +271,7 @@ static int i2c_hack_cx25840(struct pvr2_hdw *hdw,
                           "WARNING: Disabling further access to the device"
                           " to prevent other foul-ups.");
                // This blocks all further communication with the part.
-               hdw->i2c_func[0x44] = 0;
+               hdw->i2c_func[0x44] = NULL;
                pvr2_hdw_render_useless(hdw);
                goto fail;
        }
@@ -294,7 +298,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
                         int num)
 {
        int ret = -ENOTSUPP;
-       pvr2_i2c_func funcp = 0;
+       pvr2_i2c_func funcp = NULL;
        struct pvr2_hdw *hdw = (struct pvr2_hdw *)(i2c_adap->algo_data);
 
        if (!num) {
@@ -319,7 +323,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
                        u16 tcnt,bcnt,offs;
                        if (!msgs[0].len) {
                                /* Length == 0 read.  This is a probe. */
-                               if (funcp(hdw,msgs[0].addr,0,0,0,0)) {
+                               if (funcp(hdw,msgs[0].addr,NULL,0,NULL,0)) {
                                        ret = -EIO;
                                        goto done;
                                }
@@ -336,7 +340,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
                                if (bcnt > sizeof(hdw->cmd_buffer)-1) {
                                        bcnt = sizeof(hdw->cmd_buffer)-1;
                                }
-                               if (funcp(hdw,msgs[0].addr,0,0,
+                               if (funcp(hdw,msgs[0].addr,NULL,0,
                                          msgs[0].buf+offs,bcnt)) {
                                        ret = -EIO;
                                        goto done;
@@ -350,7 +354,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
                        /* Simple write */
                        ret = 1;
                        if (funcp(hdw,msgs[0].addr,
-                                 msgs[0].buf,msgs[0].len,0,0)) {
+                                 msgs[0].buf,msgs[0].len,NULL,0)) {
                                ret = -EIO;
                        }
                        goto done;
@@ -705,9 +709,9 @@ int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw)
        return (hdw->i2c_pend_types & PVR2_I2C_PEND_ALL) != 0;
 }
 
-unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
-                                     unsigned int detail,
-                                     char *buf,unsigned int maxlen)
+static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
+                                            unsigned int detail,
+                                            char *buf,unsigned int maxlen)
 {
        unsigned int ccnt,bcnt;
        int spcfl = 0;
@@ -871,7 +875,7 @@ static void do_i2c_scan(struct pvr2_hdw *hdw)
        msg[0].addr = 0;
        msg[0].flags = I2C_M_RD;
        msg[0].len = 0;
-       msg[0].buf = 0;
+       msg[0].buf = NULL;
        printk("%s: i2c scan beginning\n",hdw->name);
        for (i = 0; i < 128; i++) {
                msg[0].addr = i;
index e8af5b0..6d7e252 100644 (file)
@@ -75,9 +75,6 @@ unsigned int pvr2_i2c_report(struct pvr2_hdw *,char *buf,unsigned int maxlen);
        PVR2_I2C_DETAIL_DEBUG |\
        PVR2_I2C_DETAIL_HANDLER |\
        PVR2_I2C_DETAIL_CTLMASK)
-unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *,
-                                     unsigned int detail_mask,
-                                     char *buf,unsigned int maxlen);
 
 void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *);
 const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx);
index a984c91..681f79c 100644 (file)
@@ -93,7 +93,7 @@ struct pvr2_buffer {
        struct urb *purb;
 };
 
-const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
+static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
 {
        switch (st) {
        case pvr2_buffer_state_none: return "none";
@@ -104,7 +104,8 @@ const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
        return "unknown";
 }
 
-void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
+#ifdef SANITY_CHECK_BUFFERS
+static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
 {
        pvr2_trace(PVR2_TRACE_INFO,
                   "buffer%s%s %p state=%s id=%d status=%d"
@@ -115,10 +116,11 @@ void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
                   (bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"),
                   (bp ? bp->id : 0),
                   (bp ? bp->status : 0),
-                  (bp ? bp->stream : 0),
-                  (bp ? bp->purb : 0),
+                  (bp ? bp->stream : NULL),
+                  (bp ? bp->purb : NULL),
                   (bp ? bp->signature : 0));
 }
+#endif  /*  SANITY_CHECK_BUFFERS  */
 
 static void pvr2_buffer_remove(struct pvr2_buffer *bp)
 {
@@ -284,7 +286,7 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp)
        pvr2_buffer_wipe(bp);
        pvr2_buffer_set_none(bp);
        bp->signature = 0;
-       bp->stream = 0;
+       bp->stream = NULL;
        if (bp->purb) usb_free_urb(bp->purb);
        pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/"
                   " bufferDone     %p",bp);
@@ -339,13 +341,13 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
                        struct pvr2_buffer *bp;
                        bp = sp->buffers[sp->buffer_total_count - 1];
                        /* Paranoia */
-                       sp->buffers[sp->buffer_total_count - 1] = 0;
+                       sp->buffers[sp->buffer_total_count - 1] = NULL;
                        (sp->buffer_total_count)--;
                        pvr2_buffer_done(bp);
                        kfree(bp);
                }
                if (scnt < sp->buffer_slot_count) {
-                       struct pvr2_buffer **nb = 0;
+                       struct pvr2_buffer **nb = NULL;
                        if (scnt) {
                                nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL);
                                if (!nb) return -ENOMEM;
@@ -513,10 +515,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp,
 }
 
 /* Query / set the nominal buffer count */
-int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
-{
-       return sp->buffer_target_count;
-}
 
 int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
 {
@@ -532,21 +530,21 @@ int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
 struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp)
 {
        struct list_head *lp = sp->idle_list.next;
-       if (lp == &sp->idle_list) return 0;
+       if (lp == &sp->idle_list) return NULL;
        return list_entry(lp,struct pvr2_buffer,list_overhead);
 }
 
 struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp)
 {
        struct list_head *lp = sp->ready_list.next;
-       if (lp == &sp->ready_list) return 0;
+       if (lp == &sp->ready_list) return NULL;
        return list_entry(lp,struct pvr2_buffer,list_overhead);
 }
 
 struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id)
 {
-       if (id < 0) return 0;
-       if (id >= sp->buffer_total_count) return 0;
+       if (id < 0) return NULL;
+       if (id >= sp->buffer_total_count) return NULL;
        return sp->buffers[id];
 }
 
@@ -555,17 +553,6 @@ int pvr2_stream_get_ready_count(struct pvr2_stream *sp)
        return sp->r_count;
 }
 
-int pvr2_stream_get_idle_count(struct pvr2_stream *sp)
-{
-       return sp->i_count;
-}
-
-void pvr2_stream_flush(struct pvr2_stream *sp)
-{
-       mutex_lock(&sp->mutex); do {
-               pvr2_stream_internal_flush(sp);
-       } while(0); mutex_unlock(&sp->mutex);
-}
 
 void pvr2_stream_kill(struct pvr2_stream *sp)
 {
@@ -620,20 +607,6 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp)
        return ret;
 }
 
-int pvr2_buffer_idle(struct pvr2_buffer *bp)
-{
-       struct pvr2_stream *sp;
-       if (!bp) return -EINVAL;
-       sp = bp->stream;
-       mutex_lock(&sp->mutex); do {
-               pvr2_buffer_wipe(bp);
-               pvr2_buffer_set_idle(bp);
-               if (sp->buffer_total_count != sp->buffer_target_count) {
-                       pvr2_stream_achieve_buffer_count(sp);
-               }
-       } while(0); mutex_unlock(&sp->mutex);
-       return 0;
-}
 
 int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
 {
@@ -673,10 +646,6 @@ int pvr2_buffer_get_status(struct pvr2_buffer *bp)
        return bp->status;
 }
 
-enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *bp)
-{
-       return bp->state;
-}
 
 int pvr2_buffer_get_id(struct pvr2_buffer *bp)
 {
index 65e1138..96285ad 100644 (file)
@@ -36,8 +36,6 @@ enum pvr2_buffer_state {
 struct pvr2_stream;
 struct pvr2_buffer;
 
-const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
-
 /* Initialize / tear down stream structure */
 struct pvr2_stream *pvr2_stream_create(void);
 void pvr2_stream_destroy(struct pvr2_stream *);
@@ -49,7 +47,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *,
                              void *data);
 
 /* Query / set the nominal buffer count */
-int pvr2_stream_get_buffer_count(struct pvr2_stream *);
 int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
 
 /* Get a pointer to a buffer that is either idle, ready, or is specified
@@ -59,12 +56,8 @@ struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
 struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
 
 /* Find out how many buffers are idle or ready */
-int pvr2_stream_get_idle_count(struct pvr2_stream *);
 int pvr2_stream_get_ready_count(struct pvr2_stream *);
 
-/* Kill all pending operations */
-void pvr2_stream_flush(struct pvr2_stream *);
-
 /* Kill all pending buffers and throw away any ready buffers as well */
 void pvr2_stream_kill(struct pvr2_stream *);
 
@@ -77,18 +70,12 @@ unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
 /* Retrieve completion code for given ready buffer */
 int pvr2_buffer_get_status(struct pvr2_buffer *);
 
-/* Retrieve state of given buffer */
-enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *);
-
 /* Retrieve ID of given buffer */
 int pvr2_buffer_get_id(struct pvr2_buffer *);
 
 /* Start reading into given buffer (kill it if needed) */
 int pvr2_buffer_queue(struct pvr2_buffer *);
 
-/* Move buffer back to idle pool (kill it if needed) */
-int pvr2_buffer_idle(struct pvr2_buffer *);
-
 #endif /* __PVRUSB2_IO_H */
 
 /*
index 49da062..f7a2e22 100644 (file)
@@ -54,7 +54,7 @@ static int pvr2_ioread_init(struct pvr2_ioread *cp)
 {
        unsigned int idx;
 
-       cp->stream = 0;
+       cp->stream = NULL;
        mutex_init(&cp->mutex);
 
        for (idx = 0; idx < BUFFER_COUNT; idx++) {
@@ -77,7 +77,7 @@ static void pvr2_ioread_done(struct pvr2_ioread *cp)
 {
        unsigned int idx;
 
-       pvr2_ioread_setup(cp,0);
+       pvr2_ioread_setup(cp,NULL);
        for (idx = 0; idx < BUFFER_COUNT; idx++) {
                if (!(cp->buffer_storage[idx])) continue;
                kfree(cp->buffer_storage[idx]);
@@ -88,12 +88,12 @@ struct pvr2_ioread *pvr2_ioread_create(void)
 {
        struct pvr2_ioread *cp;
        cp = kmalloc(sizeof(*cp),GFP_KERNEL);
-       if (!cp) return 0;
+       if (!cp) return NULL;
        pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_create id=%p",cp);
        memset(cp,0,sizeof(*cp));
        if (pvr2_ioread_init(cp) < 0) {
                kfree(cp);
-               return 0;
+               return NULL;
        }
        return cp;
 }
@@ -105,7 +105,7 @@ void pvr2_ioread_destroy(struct pvr2_ioread *cp)
        pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp);
        if (cp->sync_key_ptr) {
                kfree(cp->sync_key_ptr);
-               cp->sync_key_ptr = 0;
+               cp->sync_key_ptr = NULL;
        }
        kfree(cp);
 }
@@ -124,7 +124,7 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp,
        if (sync_key_len != cp->sync_key_len) {
                if (cp->sync_key_ptr) {
                        kfree(cp->sync_key_ptr);
-                       cp->sync_key_ptr = 0;
+                       cp->sync_key_ptr = NULL;
                }
                cp->sync_key_len = 0;
                if (sync_key_len) {
@@ -144,8 +144,8 @@ static void pvr2_ioread_stop(struct pvr2_ioread *cp)
        pvr2_trace(PVR2_TRACE_START_STOP,
                   "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp);
        pvr2_stream_kill(cp->stream);
-       cp->c_buf = 0;
-       cp->c_data_ptr = 0;
+       cp->c_buf = NULL;
+       cp->c_data_ptr = NULL;
        cp->c_data_len = 0;
        cp->c_data_offs = 0;
        cp->enabled = 0;
@@ -179,8 +179,8 @@ static int pvr2_ioread_start(struct pvr2_ioread *cp)
                }
        }
        cp->enabled = !0;
-       cp->c_buf = 0;
-       cp->c_data_ptr = 0;
+       cp->c_buf = NULL;
+       cp->c_data_ptr = NULL;
        cp->c_data_len = 0;
        cp->c_data_offs = 0;
        cp->stream_running = 0;
@@ -214,7 +214,7 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
                        pvr2_ioread_stop(cp);
                        pvr2_stream_kill(cp->stream);
                        pvr2_stream_set_buffer_count(cp->stream,0);
-                       cp->stream = 0;
+                       cp->stream = NULL;
                }
                if (sp) {
                        pvr2_trace(PVR2_TRACE_START_STOP,
@@ -251,12 +251,8 @@ int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl)
        return ret;
 }
 
-int pvr2_ioread_get_enabled(struct pvr2_ioread *cp)
-{
-       return cp->enabled != 0;
-}
 
-int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
+static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
 {
        int stat;
 
@@ -274,8 +270,8 @@ int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
                                pvr2_ioread_stop(cp);
                                return 0;
                        }
-                       cp->c_buf = 0;
-                       cp->c_data_ptr = 0;
+                       cp->c_buf = NULL;
+                       cp->c_data_ptr = NULL;
                        cp->c_data_len = 0;
                        cp->c_data_offs = 0;
                }
@@ -307,7 +303,7 @@ int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
        return !0;
 }
 
-void pvr2_ioread_filter(struct pvr2_ioread *cp)
+static void pvr2_ioread_filter(struct pvr2_ioread *cp)
 {
        unsigned int idx;
        if (!cp->enabled) return;
index 6b00259..1d362f8 100644 (file)
@@ -33,7 +33,6 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *,
                              const char *sync_key_ptr,
                              unsigned int sync_key_len);
 int pvr2_ioread_set_enabled(struct pvr2_ioread *,int fl);
-int pvr2_ioread_get_enabled(struct pvr2_ioread *);
 int pvr2_ioread_read(struct pvr2_ioread *,void __user *buf,unsigned int cnt);
 int pvr2_ioread_avail(struct pvr2_ioread *);
 
index b952482..8f1a5af 100644 (file)
@@ -54,7 +54,7 @@ module_param_named(debug,pvrusb2_debug,int,S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug trace mask");
 
 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
-static struct pvr2_sysfs_class *class_ptr = 0;
+static struct pvr2_sysfs_class *class_ptr = NULL;
 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
 
 static void pvr_setup_attach(struct pvr2_context *pvr)
@@ -104,10 +104,10 @@ static void pvr_disconnect(struct usb_interface *intf)
 }
 
 static struct usb_driver pvr_driver = {
-       name:           "pvrusb2",
-       id_table:       pvr2_device_table,
-       probe:          pvr_probe,
-       disconnect:     pvr_disconnect
+       .name =         "pvrusb2",
+       .id_table =     pvr2_device_table,
+       .probe =        pvr_probe,
+       .disconnect =   pvr_disconnect
 };
 
 /*
index 1340636..f95c598 100644 (file)
@@ -121,7 +121,7 @@ static const struct std_name *find_std_name(const struct std_name *arrPtr,
                if (strlen(p->name) != bufSize) continue;
                if (!memcmp(bufPtr,p->name,bufSize)) return p;
        }
-       return 0;
+       return NULL;
 }
 
 
@@ -289,7 +289,7 @@ static struct v4l2_standard *match_std(v4l2_std_id id)
                        return generic_standards + idx;
                }
        }
-       return 0;
+       return NULL;
 }
 
 static int pvr2_std_fill(struct v4l2_standard *std,v4l2_std_id id)
@@ -364,7 +364,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
 
        pvr2_trace(PVR2_TRACE_INIT,"Setting up %u unique standard(s)",
                   std_cnt);
-       if (!std_cnt) return 0; // paranoia
+       if (!std_cnt) return NULL; // paranoia
 
        stddefs = kmalloc(sizeof(struct v4l2_standard) * std_cnt,
                          GFP_KERNEL);
index c6e6523..6af55a8 100644 (file)
@@ -504,7 +504,7 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
        cip->cptr = cptr;
 
        cip->chptr = sfp;
-       cip->item_next = 0;
+       cip->item_next = NULL;
        if (sfp->item_last) {
                sfp->item_last->item_next = cip;
        } else {
@@ -625,7 +625,7 @@ static void pvr2_sysfs_tear_down_debugifc(struct pvr2_sysfs *sfp)
                                 &sfp->debugifc->attr_debuginfo);
        class_device_remove_file(sfp->class_dev,&sfp->debugifc->attr_debugcmd);
        kfree(sfp->debugifc);
-       sfp->debugifc = 0;
+       sfp->debugifc = NULL;
 }
 #endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
 
@@ -678,9 +678,9 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
        class_device_remove_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
        class_device_remove_file(sfp->class_dev,&sfp->attr_unit_number);
        pvr2_sysfs_trace("Destroying class_dev id=%p",sfp->class_dev);
-       sfp->class_dev->class_data = 0;
+       sfp->class_dev->class_data = NULL;
        class_device_unregister(sfp->class_dev);
-       sfp->class_dev = 0;
+       sfp->class_dev = NULL;
 }
 
 
@@ -739,13 +739,13 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
        sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
        sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
        sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
-       sfp->attr_v4l_minor_number.store = 0;
+       sfp->attr_v4l_minor_number.store = NULL;
        class_device_create_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
        sfp->attr_unit_number.attr.owner = THIS_MODULE;
        sfp->attr_unit_number.attr.name = "unit_number";
        sfp->attr_unit_number.attr.mode = S_IRUGO;
        sfp->attr_unit_number.show = unit_number_show;
-       sfp->attr_unit_number.store = 0;
+       sfp->attr_unit_number.store = NULL;
        class_device_create_file(sfp->class_dev,&sfp->attr_unit_number);
 
        pvr2_sysfs_add_controls(sfp);
@@ -806,7 +806,7 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
                pvr2_sysfs_trace(
                        "Registration failed for pvr2_sysfs_class id=%p",clp);
                kfree(clp);
-               clp = 0;
+               clp = NULL;
        }
        return clp;
 }
index f4aba81..af9f246 100644 (file)
@@ -69,7 +69,7 @@ static void tuner_update(struct pvr2_tuner_handler *ctxt)
 
 static void pvr2_tuner_detach(struct pvr2_tuner_handler *ctxt)
 {
-       ctxt->client->handler = 0;
+       ctxt->client->handler = NULL;
        kfree(ctxt);
 }
 
index 9619510..0caf70b 100644 (file)
@@ -81,7 +81,7 @@ static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
 module_param_array(video_nr, int, NULL, 0444);
 MODULE_PARM_DESC(video_nr, "Offset for device's minor");
 
-struct v4l2_capability pvr_capability ={
+static struct v4l2_capability pvr_capability ={
        .driver         = "pvrusb2",
        .card           = "Hauppauge WinTV pvr-usb2",
        .bus_info       = "usb",
@@ -111,7 +111,7 @@ static struct v4l2_tuner pvr_v4l2_tuners[]= {
        }
 };
 
-struct v4l2_fmtdesc pvr_fmtdesc [] = {
+static struct v4l2_fmtdesc pvr_fmtdesc [] = {
        {
                .index          = 0,
                .type           = V4L2_BUF_TYPE_VIDEO_CAPTURE,
@@ -127,7 +127,7 @@ struct v4l2_fmtdesc pvr_fmtdesc [] = {
 #define PVR_FORMAT_PIX  0
 #define PVR_FORMAT_VBI  1
 
-struct v4l2_format pvr_format [] = {
+static struct v4l2_format pvr_format [] = {
        [PVR_FORMAT_PIX] = {
                .type   = V4L2_BUF_TYPE_VIDEO_CAPTURE,
                .fmt    = {
@@ -701,9 +701,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
 
 static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
 {
-       pvr2_trace(PVR2_TRACE_INIT,
-                  "unregistering device video%d [%s]",
-                  dip->vdev->minor,pvr2_config_get_name(dip->config));
+       printk(KERN_INFO "pvrusb2: unregistering device video%d [%s]\n",
+              dip->vdev->minor,pvr2_config_get_name(dip->config));
        if (dip->ctxt_idx >= 0) {
                mutex_lock(&device_lock);
                devices[dip->ctxt_idx] = NULL;
@@ -725,7 +724,7 @@ static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
 }
 
 
-void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
+static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
 {
        struct pvr2_v4l2 *vp;
        vp = container_of(chp,struct pvr2_v4l2,channel);
@@ -735,8 +734,8 @@ void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
 }
 
 
-int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
-                   unsigned int cmd, unsigned long arg)
+static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
+                          unsigned int cmd, unsigned long arg)
 {
 
 /* Temporary hack : use ivtv api until a v4l2 one is available. */
@@ -747,7 +746,7 @@ int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
 }
 
 
-int pvr2_v4l2_release(struct inode *inode, struct file *file)
+static int pvr2_v4l2_release(struct inode *inode, struct file *file)
 {
        struct pvr2_v4l2_fh *fhp = file->private_data;
        struct pvr2_v4l2 *vp = fhp->vhead;
@@ -761,9 +760,9 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
                hdw = fhp->channel.mc_head->hdw;
                pvr2_hdw_set_streaming(hdw,0);
                sp = pvr2_ioread_get_stream(fhp->rhp);
-               if (sp) pvr2_stream_set_callback(sp,0,0);
+               if (sp) pvr2_stream_set_callback(sp,NULL,NULL);
                pvr2_ioread_destroy(fhp->rhp);
-               fhp->rhp = 0;
+               fhp->rhp = NULL;
        }
        v4l2_prio_close(&vp->prio, &fhp->prio);
        file->private_data = NULL;
@@ -779,9 +778,9 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
                } else {
                        vp->vfirst = fhp->vnext;
                }
-               fhp->vnext = 0;
-               fhp->vprev = 0;
-               fhp->vhead = 0;
+               fhp->vnext = NULL;
+               fhp->vprev = NULL;
+               fhp->vhead = NULL;
                pvr2_channel_done(&fhp->channel);
                pvr2_trace(PVR2_TRACE_STRUCT,
                           "Destroying pvr_v4l2_fh id=%p",fhp);
@@ -794,9 +793,9 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
 }
 
 
-int pvr2_v4l2_open(struct inode *inode, struct file *file)
+static int pvr2_v4l2_open(struct inode *inode, struct file *file)
 {
-       struct pvr2_v4l2_dev *dip = 0; /* Our own context pointer */
+       struct pvr2_v4l2_dev *dip = NULL; /* Our own context pointer */
        struct pvr2_v4l2_fh *fhp;
        struct pvr2_v4l2 *vp;
        struct pvr2_hdw *hdw;
@@ -854,7 +853,7 @@ int pvr2_v4l2_open(struct inode *inode, struct file *file)
        pvr2_context_enter(vp->channel.mc_head); do {
                pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp);
                pvr2_channel_init(&fhp->channel,vp->channel.mc_head);
-               fhp->vnext = 0;
+               fhp->vnext = NULL;
                fhp->vprev = vp->vlast;
                if (vp->vlast) {
                        vp->vlast->vnext = fhp;
@@ -897,7 +896,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
 
        fh->rhp = pvr2_channel_create_mpeg_stream(fh->dev_info->stream);
        if (!fh->rhp) {
-               pvr2_channel_claim_stream(&fh->channel,0);
+               pvr2_channel_claim_stream(&fh->channel,NULL);
                return -ENOMEM;
        }
 
@@ -1078,9 +1077,8 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
            (video_register_device(dip->vdev, v4l_type, -1) < 0)) {
                err("Failed to register pvrusb2 v4l video device");
        } else {
-               pvr2_trace(PVR2_TRACE_INIT,
-                          "registered device video%d [%s]",
-                          dip->vdev->minor,pvr2_config_get_name(dip->config));
+               printk(KERN_INFO "pvrusb2: registered device video%d [%s]\n",
+                      dip->vdev->minor,pvr2_config_get_name(dip->config));
        }
 
        if ((dip->vdev->minor < sizeof(devices)/sizeof(devices[0])) &&
index e4ec7f2..05f2cdd 100644 (file)
@@ -126,8 +126,8 @@ static const struct pvr2_v4l_decoder_ops decoder_ops[] = {
 
 static void decoder_detach(struct pvr2_v4l_decoder *ctxt)
 {
-       ctxt->client->handler = 0;
-       ctxt->hdw->decoder_ctrl = 0;
+       ctxt->client->handler = NULL;
+       ctxt->hdw->decoder_ctrl = NULL;
        kfree(ctxt);
 }
 
index fcad346..2413e51 100644 (file)
@@ -89,7 +89,7 @@ static unsigned int wm8775_describe(struct pvr2_v4l_wm8775 *ctxt,
 
 static void wm8775_detach(struct pvr2_v4l_wm8775 *ctxt)
 {
-       ctxt->client->handler = 0;
+       ctxt->client->handler = NULL;
        kfree(ctxt);
 }
 
index 0841556..535172f 100644 (file)
@@ -941,8 +941,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
        /* load i2c helpers */
        if (TUNER_ABSENT != dev->tuner_type)
                request_module("tuner");
-       if (dev->tda9887_conf)
-               request_module("tda9887");
        if (card_is_empress(dev)) {
                request_module("saa6752hs");
                request_module_depend("saa7134-empress",&need_empress);
index 2fadabf..8dab481 100644 (file)
@@ -590,8 +590,8 @@ int tda9887_tuner_init(struct i2c_client *c)
        t->set_tv_freq = tda9887_set_freq;
        t->set_radio_freq = tda9887_set_freq;
        t->standby = tda9887_standby;
-       t->tuner_status=tda9887_tuner_status;
-       t->get_afc=tda9887_get_afc;
+       t->tuner_status = tda9887_tuner_status;
+       t->get_afc = tda9887_get_afc;
 
        return 0;
 }
index 011413c..f7eb402 100644 (file)
@@ -416,7 +416,7 @@ static void tuner_status(struct i2c_client *client)
 
 /* ---------------------------------------------------------------------- */
 
-/* static var Used only in tuner_attach and tuner_probe */
+/* static vars: used only in tuner_attach and tuner_probe */
 static unsigned default_mode_mask;
 
 /* During client attach, set_type is called by adapter's attach_inform callback.
@@ -608,13 +608,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                tuner_dbg("VIDIOCSAUDIO not implemented.\n");
                break;
        case TDA9887_SET_CONFIG:
-       {
-               int *i = arg;
+               if (t->type == TUNER_TDA9887) {
+                       int *i = arg;
 
-               t->tda9887_config = *i;
-               set_freq(client, t->tv_freq);
+                       t->tda9887_config = *i;
+                       set_freq(client, t->tv_freq);
+               }
                break;
-       }
        /* --- v4l ioctls --- */
        /* take care: bttv does userspace copying, we'll get a
           kernel pointer here... */
index 6da6f82..d071c5c 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/i2c.h>
 #include <linux/videodev.h>
 #include <media/tuner.h>
+#include <media/v4l2-common.h>
 
 static int offset = 0;
 module_param(offset, int, 0666);
@@ -128,6 +129,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
        u8 buffer[4];
        int rc, IFPCoff, i, j;
        enum param_type desired_type;
+       struct tuner_params *params;
 
        tun = &tuners[t->type];
 
@@ -169,19 +171,20 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                          IFPCoff,t->type);
                j = 0;
        }
+       params = &tun->params[j];
 
-       for (i = 0; i < tun->params[j].count; i++) {
-               if (freq > tun->params[j].ranges[i].limit)
+       for (i = 0; i < params->count; i++) {
+               if (freq > params->ranges[i].limit)
                        continue;
                break;
        }
-       if (i == tun->params[j].count) {
+       if (i == params->count) {
                tuner_dbg("TV frequency out of range (%d > %d)",
-                               freq, tun->params[j].ranges[i - 1].limit);
-               freq = tun->params[j].ranges[--i].limit;
+                               freq, params->ranges[i - 1].limit);
+               freq = params->ranges[--i].limit;
        }
-       config = tun->params[j].ranges[i].config;
-       cb     = tun->params[j].ranges[i].cb;
+       config = params->ranges[i].config;
+       cb     = params->ranges[i].cb;
        /*  i == 0 -> VHF_LO
         *  i == 1 -> VHF_HI
         *  i == 2 -> UHF     */
@@ -281,7 +284,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                break;
        }
 
-       if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) {
+       if (params->cb_first_if_lower_freq && div < t->last_div) {
                buffer[0] = config;
                buffer[1] = cb;
                buffer[2] = (div>>8) & 0x7f;
@@ -293,6 +296,43 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                buffer[3] = cb;
        }
        t->last_div = div;
+       if (params->has_tda9887) {
+               int config = 0;
+               int is_secam_l = (t->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) &&
+                       !(t->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC));
+
+               if (t->std == V4L2_STD_SECAM_LC) {
+                       if (params->port1_active ^ params->port1_invert_for_secam_lc)
+                               config |= TDA9887_PORT1_ACTIVE;
+                       if (params->port2_active ^ params->port2_invert_for_secam_lc)
+                               config |= TDA9887_PORT2_ACTIVE;
+               }
+               else {
+                       if (params->port1_active)
+                               config |= TDA9887_PORT1_ACTIVE;
+                       if (params->port2_active)
+                               config |= TDA9887_PORT2_ACTIVE;
+               }
+               if (params->intercarrier_mode)
+                       config |= TDA9887_INTERCARRIER;
+               if (is_secam_l) {
+                       if (i == 0 && params->default_top_secam_low)
+                               config |= TDA9887_TOP(params->default_top_secam_low);
+                       else if (i == 1 && params->default_top_secam_mid)
+                               config |= TDA9887_TOP(params->default_top_secam_mid);
+                       else if (params->default_top_secam_high)
+                               config |= TDA9887_TOP(params->default_top_secam_high);
+               }
+               else {
+                       if (i == 0 && params->default_top_low)
+                               config |= TDA9887_TOP(params->default_top_low);
+                       else if (i == 1 && params->default_top_mid)
+                               config |= TDA9887_TOP(params->default_top_mid);
+                       else if (params->default_top_high)
+                               config |= TDA9887_TOP(params->default_top_high);
+               }
+               i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
+       }
        tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
                  buffer[0],buffer[1],buffer[2],buffer[3]);
 
@@ -339,6 +379,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
        u16 div;
        int rc, j;
        enum param_type desired_type = TUNER_PARAM_TYPE_RADIO;
+       struct tuner_params *params;
 
        tun = &tuners[t->type];
 
@@ -352,7 +393,8 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
                j = 0;
 
        div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */
-       buffer[2] = (tun->params[j].ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
+       params = &tun->params[j];
+       buffer[2] = (params->ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
 
        switch (t->type) {
        case TUNER_TENA_9533_DI:
@@ -384,7 +426,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
        }
        buffer[0] = (div>>8) & 0x7f;
        buffer[1] = div      & 0xff;
-       if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) {
+       if (params->cb_first_if_lower_freq && div < t->last_div) {
                buffer[0] = buffer[2];
                buffer[1] = buffer[3];
                buffer[2] = (div>>8) & 0x7f;
@@ -398,6 +440,18 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
               buffer[0],buffer[1],buffer[2],buffer[3]);
        t->last_div = div;
 
+       if (params->has_tda9887) {
+               int config = 0;
+               if (params->port1_active && !params->port1_fm_high_sensitivity)
+                       config |= TDA9887_PORT1_ACTIVE;
+               if (params->port2_active && !params->port2_fm_high_sensitivity)
+                       config |= TDA9887_PORT2_ACTIVE;
+               if (params->intercarrier_mode)
+                       config |= TDA9887_INTERCARRIER;
+/*             if (params->port1_set_for_fm_mono)
+                       config &= ~TDA9887_PORT1_ACTIVE;*/
+               i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
+       }
        if (4 != (rc = i2c_master_send(c,buffer,4)))
                tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
 }
index 9d9226c..a167e17 100644 (file)
@@ -380,6 +380,10 @@ static struct tuner_params tuner_philips_fq1216me_params[] = {
                .type   = TUNER_PARAM_TYPE_PAL,
                .ranges = tuner_lg_pal_ranges,
                .count  = ARRAY_SIZE(tuner_lg_pal_ranges),
+               .has_tda9887 = 1,
+               .port1_active = 1,
+               .port2_active = 1,
+               .port2_invert_for_secam_lc = 1,
        },
 };
 
@@ -542,6 +546,14 @@ static struct tuner_params tuner_fm1216me_mk3_params[] = {
                .ranges = tuner_fm1216me_mk3_pal_ranges,
                .count  = ARRAY_SIZE(tuner_fm1216me_mk3_pal_ranges),
                .cb_first_if_lower_freq = 1,
+               .has_tda9887 = 1,
+               .port1_active = 1,
+               .port2_active = 1,
+               .port2_invert_for_secam_lc = 1,
+               .port1_fm_high_sensitivity = 1,
+               .default_top_mid = -2,
+               .default_top_secam_mid = -2,
+               .default_top_secam_high = -2,
        },
 };
 
@@ -612,6 +624,10 @@ static struct tuner_params tuner_fm1236_mk3_params[] = {
                .ranges = tuner_fm1236_mk3_ntsc_ranges,
                .count  = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges),
                .cb_first_if_lower_freq = 1,
+               .has_tda9887 = 1,
+               .port1_active = 1,
+               .port2_active = 1,
+               .port1_fm_high_sensitivity = 1,
        },
 };
 
@@ -632,6 +648,8 @@ static struct tuner_params tuner_microtune_4049_fm5_params[] = {
                .type   = TUNER_PARAM_TYPE_PAL,
                .ranges = tuner_temic_4009f_5_pal_ranges,
                .count  = ARRAY_SIZE(tuner_temic_4009f_5_pal_ranges),
+               .has_tda9887 = 1,
+               .port1_invert_for_secam_lc = 1,
        },
 };
 
@@ -648,6 +666,8 @@ static struct tuner_params tuner_panasonic_vp27_params[] = {
                .type   = TUNER_PARAM_TYPE_NTSC,
                .ranges = tuner_panasonic_vp27_ntsc_ranges,
                .count  = ARRAY_SIZE(tuner_panasonic_vp27_ntsc_ranges),
+               .has_tda9887 = 1,
+               .intercarrier_mode = 1,
        },
 };
 
@@ -782,6 +802,13 @@ static struct tuner_params tuner_philips_fq1216ame_mk4_params[] = {
                .type   = TUNER_PARAM_TYPE_PAL,
                .ranges = tuner_philips_fq12_6a___mk4_pal_ranges,
                .count  = ARRAY_SIZE(tuner_philips_fq12_6a___mk4_pal_ranges),
+               .has_tda9887 = 1,
+               .port1_active = 1,
+               .port2_invert_for_secam_lc = 1,
+               .default_top_mid = -2,
+               .default_top_secam_low = -2,
+               .default_top_secam_mid = -2,
+               .default_top_secam_high = -2,
        },
 };
 
@@ -870,6 +897,12 @@ static struct tuner_params tuner_philips_fmd1216me_mk3_params[] = {
                .type   = TUNER_PARAM_TYPE_PAL,
                .ranges = tuner_philips_fmd1216me_mk3_pal_ranges,
                .count  = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_pal_ranges),
+               .has_tda9887 = 1,
+               .port1_active = 1,
+               .port2_active = 1,
+               .port2_fm_high_sensitivity = 1,
+               .port2_invert_for_secam_lc = 1,
+               .port1_set_for_fm_mono = 1,
        },
 };
 
@@ -1005,6 +1038,7 @@ static struct tuner_params tuner_samsung_tcpn_2121p30a_params[] = {
                .type   = TUNER_PARAM_TYPE_NTSC,
                .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges,
                .count  = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges),
+               .has_tda9887 = 1,
        },
 };
 
@@ -1037,6 +1071,10 @@ static struct tuner_params tuner_samsung_tcpg_6121p30a_params[] = {
                .type   = TUNER_PARAM_TYPE_PAL,
                .ranges = tuner_samsung_tcpg_6121p30a_pal_ranges,
                .count  = ARRAY_SIZE(tuner_samsung_tcpg_6121p30a_pal_ranges),
+               .has_tda9887 = 1,
+               .port1_active = 1,
+               .port2_active = 1,
+               .port2_invert_for_secam_lc = 1,
        },
 };
 
index 30f8d80..d95529e 100644 (file)
@@ -73,14 +73,14 @@ static struct HAUPPAUGE_TUNER_FMT
 }
 hauppauge_tuner_fmt[] =
 {
-       { V4L2_STD_UNKNOWN," UNKNOWN" },
-       { V4L2_STD_UNKNOWN," FM" },
-       { V4L2_STD_PAL_BG, " PAL(B/G)" },
-       { V4L2_STD_NTSC_M, " NTSC(M)" },
-       { V4L2_STD_PAL_I,  " PAL(I)" },
-       { V4L2_STD_SECAM_L," SECAM(L/L')" },
-       { V4L2_STD_PAL_DK, " PAL(D/D1/K)" },
-       { V4L2_STD_ATSC,   " ATSC/DVB Digital" },
+       { V4L2_STD_UNKNOWN,                   " UNKNOWN" },
+       { V4L2_STD_UNKNOWN,                   " FM" },
+       { V4L2_STD_B|V4L2_STD_GH,             " PAL(B/G)" },
+       { V4L2_STD_MN,                        " NTSC(M)" },
+       { V4L2_STD_PAL_I,                     " PAL(I)" },
+       { V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC, " SECAM(L/L')" },
+       { V4L2_STD_DK,                        " PAL(D/D1/K)" },
+       { V4L2_STD_ATSC,                      " ATSC/DVB Digital" },
 };
 
 /* This is the full list of possible tuners. Many thanks to Hauppauge for
@@ -219,7 +219,7 @@ hauppauge_tuner[] =
        { TUNER_ABSENT,        "Thompson DTT75105"},
        { TUNER_ABSENT,        "Conexant_CX24109"},
        { TUNER_TCL_2002N,     "TCL M2523_5N_E"},
-       { TUNER_ABSENT,        "TCL M2523_3DB_E"},
+       { TUNER_TCL_2002MB,    "TCL M2523_3DB_E"},
        { TUNER_ABSENT,        "Philips 8275A"},
        { TUNER_ABSENT,        "Microtune MT2060"},
        { TUNER_ABSENT,        "Philips FM1236 MK5"},
index 8c23372..97a3bbe 100644 (file)
@@ -222,14 +222,14 @@ M                       zr36055[1] 0001 0000c001 00000000 (zr36050[1])
 /* ========================= */
 
 struct vfe_polarity {
-       int vsync_pol:1;
-       int hsync_pol:1;
-       int field_pol:1;
-       int blank_pol:1;
-       int subimg_pol:1;
-       int poe_pol:1;
-       int pvalid_pol:1;
-       int vclk_pol:1;
+       unsigned int vsync_pol:1;
+       unsigned int hsync_pol:1;
+       unsigned int field_pol:1;
+       unsigned int blank_pol:1;
+       unsigned int subimg_pol:1;
+       unsigned int poe_pol:1;
+       unsigned int pvalid_pol:1;
+       unsigned int vclk_pol:1;
 };
 
 struct vfe_settings {
index 441de82..48434d7 100644 (file)
@@ -387,7 +387,10 @@ static int com20020_resume(struct pcmcia_device *link)
 }
 
 static struct pcmcia_device_id com20020_ids[] = {
-       PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
+       PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.",
+                       "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
+       PCMCIA_DEVICE_PROD_ID12("SoHard AG",
+                       "SH ARC PCMCIA", 0xf8991729, 0x69dff0c7),
        PCMCIA_DEVICE_NULL
 };
 MODULE_DEVICE_TABLE(pcmcia, com20020_ids);
index c309d2e..52e6df5 100644 (file)
@@ -843,7 +843,7 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
        PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
        PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
-       PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),
+/*     PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),    conflict with pcnet_cs */
        PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
        PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
        PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
index 133a616..bf00fa2 100644 (file)
@@ -410,16 +410,17 @@ static __inline__ int led_get_net_activity(void)
 static __inline__ int led_get_diskio_activity(void)
 {      
        static unsigned long last_pgpgin, last_pgpgout;
-       struct page_state pgstat;
+       unsigned long events[NR_VM_EVENT_ITEMS];
        int changed;
 
-       get_full_page_state(&pgstat); /* get no of sectors in & out */
+       all_vm_events(events);
 
        /* Just use a very simple calculation here. Do not care about overflow,
           since we only want to know if there was activity or not. */
-       changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout);
-       last_pgpgin  = pgstat.pgpgin;
-       last_pgpgout = pgstat.pgpgout;
+       changed = (events[PGPGIN] != last_pgpgin) ||
+                 (events[PGPGOUT] != last_pgpgout);
+       last_pgpgin  = events[PGPGIN];
+       last_pgpgout = events[PGPGOUT];
 
        return (changed ? LED_DISK_IO : 0);
 }
index 421cfff..34a1891 100644 (file)
@@ -40,8 +40,7 @@ ibmphp-objs           :=      ibmphp_core.o   \
                                ibmphp_hpc.o
 
 acpiphp-objs           :=      acpiphp_core.o  \
-                               acpiphp_glue.o  \
-                               acpiphp_dock.o
+                               acpiphp_glue.o
 
 rpaphp-objs            :=      rpaphp_core.o   \
                                rpaphp_pci.o    \
index 17a93f8..be104ec 100644 (file)
@@ -130,7 +130,7 @@ struct acpiphp_func {
 
        struct list_head sibling;
        struct pci_dev *pci_dev;
-
+       struct notifier_block nb;
        acpi_handle     handle;
 
        u8              function;       /* pci function# */
@@ -151,24 +151,6 @@ struct acpiphp_attention_info
 };
 
 
-struct dependent_device {
-       struct list_head device_list;
-       struct list_head pci_list;
-       acpi_handle handle;
-       struct acpiphp_func *func;
-};
-
-
-struct acpiphp_dock_station {
-       acpi_handle handle;
-       u32 last_dock_time;
-       u32 flags;
-       struct acpiphp_func *dock_bridge;
-       struct list_head dependent_devices;
-       struct list_head pci_dependent_devices;
-};
-
-
 /* PCI bus bridge HID */
 #define ACPI_PCI_HOST_HID              "PNP0A03"
 
@@ -207,11 +189,6 @@ struct acpiphp_dock_station {
 #define FUNC_HAS_PS2           (0x00000040)
 #define FUNC_HAS_PS3           (0x00000080)
 #define FUNC_HAS_DCK            (0x00000100)
-#define FUNC_IS_DD              (0x00000200)
-
-/* dock station flags */
-#define DOCK_DOCKING            (0x00000001)
-#define DOCK_HAS_BRIDGE         (0x00000002)
 
 /* function prototypes */
 
@@ -226,7 +203,6 @@ extern int acpiphp_glue_init (void);
 extern void acpiphp_glue_exit (void);
 extern int acpiphp_get_num_slots (void);
 typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
-void handle_hotplug_event_func(acpi_handle, u32, void*);
 
 extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
 extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
@@ -236,16 +212,6 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
 extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
 extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
 
-/* acpiphp_dock.c */
-extern int find_dock_station(void);
-extern void remove_dock_station(void);
-extern void add_dependent_device(struct dependent_device *new_dd);
-extern void add_pci_dependent_device(struct dependent_device *new_dd);
-extern struct dependent_device *get_dependent_device(acpi_handle handle);
-extern int is_dependent_device(acpi_handle handle);
-extern int detect_dependent_devices(acpi_handle *bridge_handle);
-extern struct dependent_device *alloc_dependent_device(acpi_handle handle);
-
 /* variables */
 extern int acpiphp_debug;
 
index 4f1b0da..34de569 100644 (file)
@@ -416,27 +416,12 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 
 static int __init acpiphp_init(void)
 {
-       int retval;
-       int docking_station;
-
        info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
 
        acpiphp_debug = debug;
 
-       docking_station = find_dock_station();
-
        /* read all the ACPI info from the system */
-       retval = init_acpi();
-
-       /* if we have found a docking station, we should
-        * go ahead and load even if init_acpi has found
-        * no slots.  This handles the case when the _DCK
-        * method not defined under the actual dock bridge
-        */
-       if (docking_station)
-               return 0;
-       else
-               return retval;
+       return init_acpi();
 }
 
 
@@ -444,8 +429,6 @@ static void __exit acpiphp_exit(void)
 {
        /* deallocate internal data structures etc. */
        acpiphp_glue_exit();
-
-       remove_dock_station();
 }
 
 module_init(acpiphp_init);
diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c
deleted file mode 100644 (file)
index 4f1aaf1..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * ACPI PCI HotPlug dock functions to ACPI CA subsystem
- *
- * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com)
- * Copyright (C) 2006 Intel Corporation
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <kristen.c.accardi@intel.com>
- *
- */
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/smp_lock.h>
-#include <linux/mutex.h>
-
-#include "../pci.h"
-#include "pci_hotplug.h"
-#include "acpiphp.h"
-
-static struct acpiphp_dock_station *ds;
-#define MY_NAME "acpiphp_dock"
-
-
-int is_dependent_device(acpi_handle handle)
-{
-       return (get_dependent_device(handle) ? 1 : 0);
-}
-
-
-static acpi_status
-find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv)
-{
-       int *count = (int *)context;
-
-       if (is_dependent_device(handle)) {
-               (*count)++;
-               return AE_CTRL_TERMINATE;
-       } else {
-               return AE_OK;
-       }
-}
-
-
-
-
-void add_dependent_device(struct dependent_device *new_dd)
-{
-       list_add_tail(&new_dd->device_list, &ds->dependent_devices);
-}
-
-
-void add_pci_dependent_device(struct dependent_device *new_dd)
-{
-       list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices);
-}
-
-
-
-struct dependent_device * get_dependent_device(acpi_handle handle)
-{
-       struct dependent_device *dd;
-
-       if (!ds)
-               return NULL;
-
-       list_for_each_entry(dd, &ds->dependent_devices, device_list) {
-               if (handle == dd->handle)
-                       return dd;
-       }
-       return NULL;
-}
-
-
-
-struct dependent_device *alloc_dependent_device(acpi_handle handle)
-{
-       struct dependent_device *dd;
-
-       dd = kzalloc(sizeof(*dd), GFP_KERNEL);
-       if (dd) {
-               INIT_LIST_HEAD(&dd->pci_list);
-               INIT_LIST_HEAD(&dd->device_list);
-               dd->handle = handle;
-       }
-       return dd;
-}
-
-
-
-static int is_dock(acpi_handle handle)
-{
-       acpi_status status;
-       acpi_handle tmp;
-
-       status = acpi_get_handle(handle, "_DCK", &tmp);
-       if (ACPI_FAILURE(status)) {
-               return 0;
-       }
-       return 1;
-}
-
-
-
-static int dock_present(void)
-{
-       unsigned long sta;
-       acpi_status status;
-
-       if (ds) {
-               status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
-               if (ACPI_SUCCESS(status) && sta)
-                       return 1;
-       }
-       return 0;
-}
-
-
-
-static void eject_dock(void)
-{
-       struct acpi_object_list arg_list;
-       union acpi_object arg;
-
-       arg_list.count = 1;
-       arg_list.pointer = &arg;
-       arg.type = ACPI_TYPE_INTEGER;
-       arg.integer.value = 1;
-
-       if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
-                                       &arg_list, NULL)) || dock_present())
-               warn("%s: failed to eject dock!\n", __FUNCTION__);
-
-       return;
-}
-
-
-
-
-static acpi_status handle_dock(int dock)
-{
-       acpi_status status;
-       struct acpi_object_list arg_list;
-       union acpi_object arg;
-       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
-
-       dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking");
-
-       /* _DCK method has one argument */
-       arg_list.count = 1;
-       arg_list.pointer = &arg;
-       arg.type = ACPI_TYPE_INTEGER;
-       arg.integer.value = dock;
-       status = acpi_evaluate_object(ds->handle, "_DCK",
-                                       &arg_list, &buffer);
-       if (ACPI_FAILURE(status))
-               err("%s: failed to execute _DCK\n", __FUNCTION__);
-       acpi_os_free(buffer.pointer);
-
-       return status;
-}
-
-
-
-static inline void dock(void)
-{
-       handle_dock(1);
-}
-
-
-
-static inline void undock(void)
-{
-       handle_dock(0);
-}
-
-
-
-/*
- * the _DCK method can do funny things... and sometimes not
- * hah-hah funny.
- *
- * TBD - figure out a way to only call fixups for
- * systems that require them.
- */
-static void post_dock_fixups(void)
-{
-       struct pci_bus *bus;
-       u32 buses;
-       struct dependent_device *dd;
-
-       list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) {
-               bus = dd->func->slot->bridge->pci_bus;
-
-               /* fixup bad _DCK function that rewrites
-                * secondary bridge on slot
-                */
-               pci_read_config_dword(bus->self,
-                               PCI_PRIMARY_BUS,
-                               &buses);
-
-               if (((buses >> 8) & 0xff) != bus->secondary) {
-                       buses = (buses & 0xff000000)
-                               | ((unsigned int)(bus->primary)     <<  0)
-                               | ((unsigned int)(bus->secondary)   <<  8)
-                               | ((unsigned int)(bus->subordinate) << 16);
-                       pci_write_config_dword(bus->self,
-                                       PCI_PRIMARY_BUS,
-                                       buses);
-               }
-       }
-}
-
-
-
-static void hotplug_pci(u32 type)
-{
-       struct dependent_device *dd;
-
-       list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list)
-               handle_hotplug_event_func(dd->handle, type, dd->func);
-}
-
-
-
-static inline void begin_dock(void)
-{
-       ds->flags |= DOCK_DOCKING;
-}
-
-
-static inline void complete_dock(void)
-{
-       ds->flags &= ~(DOCK_DOCKING);
-       ds->last_dock_time = jiffies;
-}
-
-
-static int dock_in_progress(void)
-{
-       if (ds->flags & DOCK_DOCKING ||
-               ds->last_dock_time == jiffies) {
-               dbg("dock in progress\n");
-               return 1;
-       }
-       return 0;
-}
-
-
-
-static void
-handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context)
-{
-       dbg("%s: enter\n", __FUNCTION__);
-
-       switch (type) {
-               case ACPI_NOTIFY_BUS_CHECK:
-                       dbg("BUS Check\n");
-                       if (!dock_in_progress() && dock_present()) {
-                               begin_dock();
-                               dock();
-                               if (!dock_present()) {
-                                       err("Unable to dock!\n");
-                                       break;
-                               }
-                               post_dock_fixups();
-                               hotplug_pci(type);
-                               complete_dock();
-                       }
-                       break;
-               case ACPI_NOTIFY_EJECT_REQUEST:
-                       dbg("EJECT request\n");
-                       if (!dock_in_progress() && dock_present()) {
-                               hotplug_pci(type);
-                               undock();
-                               eject_dock();
-                               if (dock_present())
-                                       err("Unable to undock!\n");
-                       }
-                       break;
-       }
-}
-
-
-
-
-static acpi_status
-find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv)
-{
-       acpi_status status;
-       acpi_handle tmp;
-       acpi_handle dck_handle = (acpi_handle) context;
-       char objname[64];
-       struct acpi_buffer buffer = { .length = sizeof(objname),
-                                     .pointer = objname };
-       struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL};
-       union acpi_object *ejd_obj;
-
-       status = acpi_get_handle(handle, "_EJD", &tmp);
-       if (ACPI_FAILURE(status))
-               return AE_OK;
-
-       /* make sure we are dependent on the dock device,
-        * by executing the _EJD method, then getting a handle
-        * to the device referenced by that name.  If that
-        * device handle is the same handle as the dock station
-        * handle, then we are a device dependent on the dock station
-        */
-       acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer);
-       status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer);
-       if (ACPI_FAILURE(status)) {
-               err("Unable to execute _EJD!\n");
-               goto find_ejd_out;
-       }
-       ejd_obj = ejd_buffer.pointer;
-       status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp);
-       if (ACPI_FAILURE(status))
-               goto find_ejd_out;
-
-       if (tmp == dck_handle) {
-               struct dependent_device *dd;
-               dbg("%s: found device dependent on dock\n", __FUNCTION__);
-               dd = alloc_dependent_device(handle);
-               if (!dd) {
-                       err("Can't allocate memory for dependent device!\n");
-                       goto find_ejd_out;
-               }
-               add_dependent_device(dd);
-       }
-
-find_ejd_out:
-       acpi_os_free(ejd_buffer.pointer);
-       return AE_OK;
-}
-
-
-
-int detect_dependent_devices(acpi_handle *bridge_handle)
-{
-       acpi_status status;
-       int count;
-
-       count = 0;
-
-       status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
-                                       (u32)1, find_dependent_device,
-                                       (void *)&count, NULL);
-
-       return count;
-}
-
-
-
-
-
-static acpi_status
-find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
-{
-       int *count = (int *)context;
-
-       if (is_dock(handle)) {
-               dbg("%s: found dock\n", __FUNCTION__);
-               ds = kzalloc(sizeof(*ds), GFP_KERNEL);
-               ds->handle = handle;
-               INIT_LIST_HEAD(&ds->dependent_devices);
-               INIT_LIST_HEAD(&ds->pci_dependent_devices);
-
-               /* look for devices dependent on dock station */
-               acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                       ACPI_UINT32_MAX, find_dock_ejd, handle, NULL);
-
-               acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
-                       handle_hotplug_event_dock, ds);
-               (*count)++;
-       }
-
-       return AE_OK;
-}
-
-
-
-
-int find_dock_station(void)
-{
-       int num = 0;
-
-       ds = NULL;
-
-       /* start from the root object, because some laptops define
-        * _DCK methods outside the scope of PCI (IBM x-series laptop)
-        */
-       acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-                       ACPI_UINT32_MAX, find_dock, &num, NULL);
-
-       return num;
-}
-
-
-
-void remove_dock_station(void)
-{
-       struct dependent_device *dd, *tmp;
-       if (ds) {
-               if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle,
-                       ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock)))
-                       err("failed to remove dock notify handler\n");
-
-               /* free all dependent devices */
-               list_for_each_entry_safe(dd, tmp, &ds->dependent_devices,
-                               device_list)
-                       kfree(dd);
-
-               /* no need to touch the pci_dependent_device list,
-                * cause all memory was freed above
-                */
-               kfree(ds);
-       }
-}
-
-
index d370f99..ef95d12 100644 (file)
@@ -59,6 +59,7 @@ static LIST_HEAD(bridge_list);
 static void handle_hotplug_event_bridge (acpi_handle, u32, void *);
 static void acpiphp_sanitize_bus(struct pci_bus *bus);
 static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
+static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
 
 
 /*
@@ -116,6 +117,59 @@ is_ejectable_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
        }
 }
 
+/* callback routine to check for the existance of a pci dock device */
+static acpi_status
+is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+       int *count = (int *)context;
+
+       if (is_dock_device(handle)) {
+               (*count)++;
+               return AE_CTRL_TERMINATE;
+       } else {
+               return AE_OK;
+       }
+}
+
+
+
+
+/*
+ * the _DCK method can do funny things... and sometimes not
+ * hah-hah funny.
+ *
+ * TBD - figure out a way to only call fixups for
+ * systems that require them.
+ */
+static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
+       void *v)
+{
+       struct acpiphp_func *func = container_of(nb, struct acpiphp_func, nb);
+       struct pci_bus *bus = func->slot->bridge->pci_bus;
+       u32 buses;
+
+       if (!bus->self)
+               return  NOTIFY_OK;
+
+       /* fixup bad _DCK function that rewrites
+        * secondary bridge on slot
+        */
+       pci_read_config_dword(bus->self,
+                       PCI_PRIMARY_BUS,
+                       &buses);
+
+       if (((buses >> 8) & 0xff) != bus->secondary) {
+               buses = (buses & 0xff000000)
+                       | ((unsigned int)(bus->primary)     <<  0)
+                       | ((unsigned int)(bus->secondary)   <<  8)
+                       | ((unsigned int)(bus->subordinate) << 16);
+               pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
+       }
+       return NOTIFY_OK;
+}
+
+
+
 
 /* callback routine to register each ACPI PCI slot object */
 static acpi_status
@@ -124,7 +178,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
        struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context;
        struct acpiphp_slot *slot;
        struct acpiphp_func *newfunc;
-       struct dependent_device *dd;
        acpi_handle tmp;
        acpi_status status = AE_OK;
        unsigned long adr, sun;
@@ -137,7 +190,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
 
        status = acpi_get_handle(handle, "_EJ0", &tmp);
 
-       if (ACPI_FAILURE(status) && !(is_dependent_device(handle)))
+       if (ACPI_FAILURE(status) && !(is_dock_device(handle)))
                return AE_OK;
 
        device = (adr >> 16) & 0xffff;
@@ -162,22 +215,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
        if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp)))
                newfunc->flags |= FUNC_HAS_PS3;
 
-       if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) {
+       if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp)))
                newfunc->flags |= FUNC_HAS_DCK;
-               /* add to devices dependent on dock station,
-                * because this may actually be the dock bridge
-                */
-               dd = alloc_dependent_device(handle);
-                if (!dd)
-                        err("Can't allocate memory for "
-                               "new dependent device!\n");
-               else
-                       add_dependent_device(dd);
-       }
 
        status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
-       if (ACPI_FAILURE(status))
-               sun = -1;
+       if (ACPI_FAILURE(status)) {
+               /*
+                * use the count of the number of slots we've found
+                * for the number of the slot
+                */
+               sun = bridge->nr_slots+1;
+       }
 
        /* search for objects that share the same slot */
        for (slot = bridge->slots; slot; slot = slot->next)
@@ -225,20 +273,23 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
                slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
        }
 
-       /* if this is a device dependent on a dock station,
-        * associate the acpiphp_func to the dependent_device
-        * struct.
-        */
-       if ((dd = get_dependent_device(handle))) {
-               newfunc->flags |= FUNC_IS_DD;
-               /*
-                * we don't want any devices which is dependent
-                * on the dock to have it's _EJ0 method executed.
-                * because we need to run _DCK first.
+       if (is_dock_device(handle)) {
+               /* we don't want to call this device's _EJ0
+                * because we want the dock notify handler
+                * to call it after it calls _DCK
                 */
                newfunc->flags &= ~FUNC_HAS_EJ0;
-               dd->func = newfunc;
-               add_pci_dependent_device(dd);
+               if (register_hotplug_dock_device(handle,
+                       handle_hotplug_event_func, newfunc))
+                       dbg("failed to register dock device\n");
+
+               /* we need to be notified when dock events happen
+                * outside of the hotplug operation, since we may
+                * need to do fixups before we can hotplug.
+                */
+               newfunc->nb.notifier_call = post_dock_fixups;
+               if (register_dock_notifier(&newfunc->nb))
+                       dbg("failed to register a dock notifier");
        }
 
        /* install notify handler */
@@ -277,6 +328,15 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle)
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
                                     is_ejectable_slot, (void *)&count, NULL);
 
+       /*
+        * we also need to add this bridge if there is a dock bridge or
+        * other pci device on a dock station (removable)
+        */
+       if (!count)
+               status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
+                               (u32)1, is_pci_dock_device, (void *)&count,
+                               NULL);
+
        return count;
 }
 
@@ -487,8 +547,7 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
                goto out;
 
        /* check if this bridge has ejectable slots */
-       if ((detect_ejectable_slots(handle) > 0) ||
-               (detect_dependent_devices(handle) > 0)) {
+       if ((detect_ejectable_slots(handle) > 0)) {
                dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
                add_p2p_bridge(handle, dev);
        }
@@ -605,6 +664,10 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
                list_for_each_safe (list, tmp, &slot->funcs) {
                        struct acpiphp_func *func;
                        func = list_entry(list, struct acpiphp_func, sibling);
+                       if (is_dock_device(func->handle)) {
+                               unregister_hotplug_dock_device(func->handle);
+                               unregister_dock_notifier(&func->nb);
+                       }
                        if (!(func->flags & FUNC_HAS_DCK)) {
                                status = acpi_remove_notify_handler(func->handle,
                                                ACPI_SYSTEM_NOTIFY,
@@ -1440,7 +1503,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont
  * handles ACPI event notification on slots
  *
  */
-void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
+static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
 {
        struct acpiphp_func *func;
        char objname[64];
index a4d5094..5256342 100644 (file)
@@ -214,11 +214,10 @@ static struct pccard_operations at91_cf_ops = {
 
 /*--------------------------------------------------------------------------*/
 
-static int __init at91_cf_probe(struct device *dev)
+static int __init at91_cf_probe(struct platform_device *pdev)
 {
        struct at91_cf_socket   *cf;
-       struct at91_cf_data     *board = dev->platform_data;
-       struct platform_device  *pdev = to_platform_device(dev);
+       struct at91_cf_data     *board = pdev->dev.platform_data;
        struct resource         *io;
        unsigned int            csa;
        int                     status;
@@ -236,7 +235,7 @@ static int __init at91_cf_probe(struct device *dev)
 
        cf->board = board;
        cf->pdev = pdev;
-       dev_set_drvdata(dev, cf);
+       platform_set_drvdata(pdev, cf);
 
        /* CF takes over CS4, CS5, CS6 */
        csa = at91_sys_read(AT91_EBI_CSA);
@@ -271,6 +270,7 @@ static int __init at91_cf_probe(struct device *dev)
                        SA_SAMPLE_RANDOM, driver_name, cf);
        if (status < 0)
                goto fail0;
+       device_init_wakeup(&pdev->dev, 1);
 
        /*
         * The card driver will request this irq later as needed.
@@ -301,7 +301,7 @@ static int __init at91_cf_probe(struct device *dev)
                board->det_pin, board->irq_pin);
 
        cf->socket.owner = THIS_MODULE;
-       cf->socket.dev.dev = dev;
+       cf->socket.dev.dev = &pdev->dev;
        cf->socket.ops = &at91_cf_ops;
        cf->socket.resource_ops = &pccard_static_ops;
        cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
@@ -323,21 +323,25 @@ fail1:
                free_irq(board->irq_pin, cf);
 fail0a:
        free_irq(board->det_pin, cf);
+       device_init_wakeup(&pdev->dev, 0);
 fail0:
        at91_sys_write(AT91_EBI_CSA, csa);
        kfree(cf);
        return status;
 }
 
-static int __exit at91_cf_remove(struct device *dev)
+static int __exit at91_cf_remove(struct platform_device *pdev)
 {
-       struct at91_cf_socket   *cf = dev_get_drvdata(dev);
+       struct at91_cf_socket   *cf = platform_get_drvdata(pdev);
+       struct at91_cf_data     *board = cf->board;
        struct resource         *io = cf->socket.io[0].res;
        unsigned int            csa;
 
        pcmcia_unregister_socket(&cf->socket);
-       free_irq(cf->board->irq_pin, cf);
-       free_irq(cf->board->det_pin, cf);
+       if (board->irq_pin)
+               free_irq(board->irq_pin, cf);
+       free_irq(board->det_pin, cf);
+       device_init_wakeup(&pdev->dev, 0);
        iounmap((void __iomem *) cf->socket.io_offset);
        release_mem_region(io->start, io->end + 1 - io->start);
 
@@ -348,26 +352,65 @@ static int __exit at91_cf_remove(struct device *dev)
        return 0;
 }
 
-static struct device_driver at91_cf_driver = {
-       .name           = (char *) driver_name,
-       .bus            = &platform_bus_type,
+#ifdef CONFIG_PM
+
+static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
+{
+       struct at91_cf_socket   *cf = platform_get_drvdata(pdev);
+       struct at91_cf_data     *board = cf->board;
+
+       pcmcia_socket_dev_suspend(&pdev->dev, mesg);
+       if (device_may_wakeup(&pdev->dev))
+               enable_irq_wake(board->det_pin);
+       else {
+               disable_irq_wake(board->det_pin);
+               disable_irq(board->det_pin);
+       }
+       if (board->irq_pin)
+               disable_irq(board->irq_pin);
+       return 0;
+}
+
+static int at91_cf_resume(struct platform_device *pdev)
+{
+       struct at91_cf_socket   *cf = platform_get_drvdata(pdev);
+       struct at91_cf_data     *board = cf->board;
+
+       if (board->irq_pin)
+               enable_irq(board->irq_pin);
+       if (!device_may_wakeup(&pdev->dev))
+               enable_irq(board->det_pin);
+       pcmcia_socket_dev_resume(&pdev->dev);
+       return 0;
+}
+
+#else
+#define        at91_cf_suspend         NULL
+#define        at91_cf_resume          NULL
+#endif
+
+static struct platform_driver at91_cf_driver = {
+       .driver = {
+               .name           = (char *) driver_name,
+               .owner          = THIS_MODULE,
+       },
        .probe          = at91_cf_probe,
        .remove         = __exit_p(at91_cf_remove),
-       .suspend        = pcmcia_socket_dev_suspend,
-       .resume         = pcmcia_socket_dev_resume,
+       .suspend        = at91_cf_suspend,
+       .resume         = at91_cf_resume,
 };
 
 /*--------------------------------------------------------------------------*/
 
 static int __init at91_cf_init(void)
 {
-       return driver_register(&at91_cf_driver);
+       return platform_driver_register(&at91_cf_driver);
 }
 module_init(at91_cf_init);
 
 static void __exit at91_cf_exit(void)
 {
-       driver_unregister(&at91_cf_driver);
+       platform_driver_unregister(&at91_cf_driver);
 }
 module_exit(at91_cf_exit);
 
index 24cfee1..74e0515 100644 (file)
@@ -295,7 +295,7 @@ struct pcmcia_low_level db1x00_pcmcia_ops = {
        .socket_suspend         = db1x00_socket_suspend
 };
 
-int __init au1x_board_init(struct device *dev)
+int au1x_board_init(struct device *dev)
 {
        int ret = -ENODEV;
        bcsr->pcmcia = 0; /* turn off power, if it's not already off */
index 3162998..f9cd831 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/pm.h>
 #include <linux/pci.h>
 #include <linux/device.h>
+#include <linux/kthread.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 
@@ -176,6 +177,7 @@ static int pccardd(void *__skt);
  */
 int pcmcia_register_socket(struct pcmcia_socket *socket)
 {
+       struct task_struct *tsk;
        int ret;
 
        if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops)
@@ -239,15 +241,18 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
        mutex_init(&socket->skt_mutex);
        spin_lock_init(&socket->thread_lock);
 
-       ret = kernel_thread(pccardd, socket, CLONE_KERNEL);
-       if (ret < 0)
+       tsk = kthread_run(pccardd, socket, "pccardd");
+       if (IS_ERR(tsk)) {
+               ret = PTR_ERR(tsk);
                goto err;
+       }
 
        wait_for_completion(&socket->thread_done);
-       if(!socket->thread) {
+       if (!socket->thread) {
                printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket);
                return -EIO;
        }
+
        pcmcia_parse_events(socket, SS_DETECT);
 
        return 0;
@@ -272,10 +277,8 @@ void pcmcia_unregister_socket(struct pcmcia_socket *socket)
        cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
 
        if (socket->thread) {
-               init_completion(&socket->thread_done);
-               socket->thread = NULL;
                wake_up(&socket->thread_wait);
-               wait_for_completion(&socket->thread_done);
+               kthread_stop(socket->thread);
        }
        release_cis_mem(socket);
 
@@ -630,8 +633,6 @@ static int pccardd(void *__skt)
        DECLARE_WAITQUEUE(wait, current);
        int ret;
 
-       daemonize("pccardd");
-
        skt->thread = current;
        skt->socket = dead_socket;
        skt->ops->init(skt);
@@ -643,7 +644,8 @@ static int pccardd(void *__skt)
                printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
                        skt);
                skt->thread = NULL;
-               complete_and_exit(&skt->thread_done, 0);
+               complete(&skt->thread_done);
+               return 0;
        }
 
        add_wait_queue(&skt->thread_wait, &wait);
@@ -674,7 +676,7 @@ static int pccardd(void *__skt)
                        continue;
                }
 
-               if (!skt->thread)
+               if (kthread_should_stop())
                        break;
 
                schedule();
@@ -688,7 +690,7 @@ static int pccardd(void *__skt)
        /* remove from the device core */
        class_device_unregister(&skt->dev);
 
-       complete_and_exit(&skt->thread_done, 0);
+       return 0;
 }
 
 /*
@@ -697,11 +699,12 @@ static int pccardd(void *__skt)
  */
 void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
 {
+       unsigned long flags;
        cs_dbg(s, 4, "parse_events: events %08x\n", events);
        if (s->thread) {
-               spin_lock(&s->thread_lock);
+               spin_lock_irqsave(&s->thread_lock, flags);
                s->thread_events |= events;
-               spin_unlock(&s->thread_lock);
+               spin_unlock_irqrestore(&s->thread_lock, flags);
 
                wake_up(&s->thread_wait);
        }
index 3131bb0..3281e51 100644 (file)
@@ -788,6 +788,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
        struct pcmcia_socket *s = p_dev->socket;
        config_t *c;
        int ret = CS_IN_USE, irq = 0;
+       int type;
 
        if (!(s->state & SOCKET_PRESENT))
                return CS_NO_CARD;
@@ -797,6 +798,13 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
        if (c->state & CONFIG_IRQ_REQ)
                return CS_IN_USE;
 
+       /* Decide what type of interrupt we are registering */
+       type = 0;
+       if (s->functions > 1)           /* All of this ought to be handled higher up */
+               type = SA_SHIRQ;
+       if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)
+               type = SA_SHIRQ;
+
 #ifdef CONFIG_PCMCIA_PROBE
        if (s->irq.AssignedIRQ != 0) {
                /* If the interrupt is already assigned, it must be the same */
@@ -822,9 +830,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
                         * marked as used by the kernel resource management core */
                        ret = request_irq(irq,
                                          (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Handler : test_action,
-                                         ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
-                                          (s->functions > 1) ||
-                                          (irq == s->pci_irq)) ? SA_SHIRQ : 0,
+                                         type,
                                          p_dev->devname,
                                          (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data);
                        if (!ret) {
@@ -839,18 +845,21 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
        if (ret && !s->irq.AssignedIRQ) {
                if (!s->pci_irq)
                        return ret;
+               type = SA_SHIRQ;
                irq = s->pci_irq;
        }
 
-       if (ret && req->Attributes & IRQ_HANDLE_PRESENT) {
-               if (request_irq(irq, req->Handler,
-                               ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
-                                (s->functions > 1) ||
-                                (irq == s->pci_irq)) ? SA_SHIRQ : 0,
-                               p_dev->devname, req->Instance))
+       if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) {
+               if (request_irq(irq, req->Handler, type,  p_dev->devname, req->Instance))
                        return CS_IN_USE;
        }
 
+       /* Make sure the fact the request type was overridden is passed back */
+       if (type == SA_SHIRQ && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) {
+               req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
+               printk(KERN_WARNING "pcmcia: request for exclusive IRQ could not be fulfilled.\n");
+               printk(KERN_WARNING "pcmcia: the driver needs updating to supported shared IRQ lines.\n");
+       }
        c->irq.Attributes = req->Attributes;
        s->irq.AssignedIRQ = req->AssignedIRQ = irq;
        s->irq.Config++;
index 7a3d1b8..62e9ebf 100644 (file)
@@ -647,6 +647,7 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
                 */
                break;
 
+       case PCI_DEVICE_ID_TI_XX12:
        case PCI_DEVICE_ID_TI_X515:
        case PCI_DEVICE_ID_TI_X420:
        case PCI_DEVICE_ID_TI_X620:
index 4145eb8..47e5760 100644 (file)
@@ -287,7 +287,10 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
        struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
        u16 bridge;
 
-       yenta_set_power(socket, state);
+       /* if powering down: do it immediately */
+       if (state->Vcc == 0)
+               yenta_set_power(socket, state);
+
        socket->io_irq = state->io_irq;
        bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR);
        if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
@@ -339,6 +342,10 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
        /* Socket event mask: get card insert/remove events.. */
        cb_writel(socket, CB_SOCKET_EVENT, -1);
        cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
+
+       /* if powering up: do it as the last step when the socket is configured */
+       if (state->Vcc != 0)
+               yenta_set_power(socket, state);
        return 0;
 }
 
@@ -998,6 +1005,77 @@ static void yenta_config_init(struct yenta_socket *socket)
        config_writew(socket, CB_BRIDGE_CONTROL, bridge);
 }
 
+/**
+ * yenta_fixup_parent_bridge - Fix subordinate bus# of the parent bridge
+ * @cardbus_bridge: The PCI bus which the CardBus bridge bridges to
+ *
+ * Checks if devices on the bus which the CardBus bridge bridges to would be
+ * invisible during PCI scans because of a misconfigured subordinate number
+ * of the parent brige - some BIOSes seem to be too lazy to set it right.
+ * Does the fixup carefully by checking how far it can go without conflicts.
+ * See http://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information.
+ */
+static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
+{
+       struct list_head *tmp;
+       unsigned char upper_limit;
+       /*
+        * We only check and fix the parent bridge: All systems which need
+        * this fixup that have been reviewed are laptops and the only bridge
+        * which needed fixing was the parent bridge of the CardBus bridge:
+        */
+       struct pci_bus *bridge_to_fix = cardbus_bridge->parent;
+
+       /* Check bus numbers are already set up correctly: */
+       if (bridge_to_fix->subordinate >= cardbus_bridge->subordinate)
+               return; /* The subordinate number is ok, nothing to do */
+
+       if (!bridge_to_fix->parent)
+               return; /* Root bridges are ok */
+
+       /* stay within the limits of the bus range of the parent: */
+       upper_limit = bridge_to_fix->parent->subordinate;
+
+       /* check the bus ranges of all silbling bridges to prevent overlap */
+       list_for_each(tmp, &bridge_to_fix->parent->children) {
+               struct pci_bus * silbling = pci_bus_b(tmp);
+               /*
+                * If the silbling has a higher secondary bus number
+                * and it's secondary is equal or smaller than our
+                * current upper limit, set the new upper limit to
+                * the bus number below the silbling's range:
+                */
+               if (silbling->secondary > bridge_to_fix->subordinate
+                   && silbling->secondary <= upper_limit)
+                       upper_limit = silbling->secondary - 1;
+       }
+
+       /* Show that the wanted subordinate number is not possible: */
+       if (cardbus_bridge->subordinate > upper_limit)
+               printk(KERN_WARNING "Yenta: Upper limit for fixing this "
+                       "bridge's parent bridge: #%02x\n", upper_limit);
+
+       /* If we have room to increase the bridge's subordinate number, */
+       if (bridge_to_fix->subordinate < upper_limit) {
+
+               /* use the highest number of the hidden bus, within limits */
+               unsigned char subordinate_to_assign =
+                       min(cardbus_bridge->subordinate, upper_limit);
+
+               printk(KERN_INFO "Yenta: Raising subordinate bus# of parent "
+                       "bus (#%02x) from #%02x to #%02x\n",
+                       bridge_to_fix->number,
+                       bridge_to_fix->subordinate, subordinate_to_assign);
+
+               /* Save the new subordinate in the bus struct of the bridge */
+               bridge_to_fix->subordinate = subordinate_to_assign;
+
+               /* and update the PCI config space with the new subordinate */
+               pci_write_config_byte(bridge_to_fix->self,
+                       PCI_SUBORDINATE_BUS, bridge_to_fix->subordinate);
+       }
+}
+
 /*
  * Initialize a cardbus controller. Make sure we have a usable
  * interrupt, and that we can map the cardbus area. Fill in the
@@ -1113,6 +1191,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
        yenta_get_socket_capabilities(socket, isa_interrupts);
        printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
 
+       yenta_fixup_parent_bridge(dev->subordinate);
+
        /* Register it with the pcmcia layer.. */
        ret = pcmcia_register_socket(&socket->socket);
        if (ret == 0) {
@@ -1232,6 +1312,7 @@ static struct pci_device_id yenta_table [] = {
 
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX),
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX),
+       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12, TI12XX),
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX),
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX),
        CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX),
index 2c70773..cbf260b 100644 (file)
@@ -786,6 +786,7 @@ static struct pcmcia_device_id serial_ids[] = {
        PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"),
        PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
        PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"),
+       PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"),
        /* too generic */
        /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */
        /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */
index bcbeaf7..f7bdd94 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/usbdevice_fs.h>
 #include <linux/cdev.h>
 #include <linux/notifier.h>
+#include <linux/security.h>
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 #include <linux/moduleparam.h>
@@ -68,6 +69,7 @@ struct async {
        void __user *userbuffer;
        void __user *userurb;
        struct urb *urb;
+       u32 secid;
 };
 
 static int usbfs_snoop = 0;
@@ -312,7 +314,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
                sinfo.si_code = SI_ASYNCIO;
                sinfo.si_addr = as->userurb;
                kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, 
-                                     as->euid);
+                                     as->euid, as->secid);
        }
        snoop(&urb->dev->dev, "urb complete\n");
        snoop_urb(urb, as->userurb);
@@ -572,6 +574,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
        ps->disc_euid = current->euid;
        ps->disccontext = NULL;
        ps->ifclaimed = 0;
+       security_task_getsecid(current, &ps->secid);
        wmb();
        list_add_tail(&ps->list, &dev->filelist);
        file->private_data = ps;
@@ -1053,6 +1056,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
        as->pid = current->pid;
        as->uid = current->uid;
        as->euid = current->euid;
+       security_task_getsecid(current, &as->secid);
        if (!(uurb->endpoint & USB_DIR_IN)) {
                if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) {
                        free_async(as);
index 02a6312..e47e3a8 100644 (file)
@@ -699,7 +699,7 @@ static void usbfs_remove_device(struct usb_device *dev)
                        sinfo.si_errno = EPIPE;
                        sinfo.si_code = SI_ASYNCIO;
                        sinfo.si_addr = ds->disccontext;
-                       kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid);
+                       kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid);
                }
        }
 }
index 7a650c7..49f6923 100644 (file)
@@ -80,6 +80,7 @@ struct dev_state {
        uid_t disc_uid, disc_euid;
        void __user *disccontext;
        unsigned long ifclaimed;
+       u32 secid;
 };
 
 /* internal notify stuff */
index 7b1c168..cdbae17 100644 (file)
@@ -207,10 +207,6 @@ static int __init imacfb_probe(struct platform_device *dev)
                size_remap = size_total;
        imacfb_fix.smem_len = size_remap;
 
-#ifndef __i386__
-       screen_info.imacpm_seg = 0;
-#endif
-
        if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) {
                printk(KERN_WARNING
                       "imacfb: cannot reserve video memory at 0x%lx\n",
index bf22bb5..3660dcb 100644 (file)
@@ -851,7 +851,7 @@ int __set_page_dirty_buffers(struct page *page)
                write_lock_irq(&mapping->tree_lock);
                if (page->mapping) {    /* Race with truncate? */
                        if (mapping_cap_account_dirty(mapping))
-                               inc_page_state(nr_dirty);
+                               __inc_zone_page_state(page, NR_FILE_DIRTY);
                        radix_tree_tag_set(&mapping->page_tree,
                                                page_index(page),
                                                PAGECACHE_TAG_DIRTY);
index 031b27a..892643d 100644 (file)
@@ -464,8 +464,8 @@ void sync_inodes_sb(struct super_block *sb, int wait)
                .range_start    = 0,
                .range_end      = LLONG_MAX,
        };
-       unsigned long nr_dirty = read_page_state(nr_dirty);
-       unsigned long nr_unstable = read_page_state(nr_unstable);
+       unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
+       unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);
 
        wbc.nr_to_write = nr_dirty + nr_unstable +
                        (inodes_stat.nr_inodes - inodes_stat.nr_unused) +
index e53796a..0bf9f04 100644 (file)
@@ -451,15 +451,14 @@ static void prune_icache(int nr_to_scan)
                nr_pruned++;
        }
        inodes_stat.nr_unused -= nr_pruned;
+       if (current_is_kswapd())
+               __count_vm_events(KSWAPD_INODESTEAL, reap);
+       else
+               __count_vm_events(PGINODESTEAL, reap);
        spin_unlock(&inode_lock);
 
        dispose_list(&freeable);
        mutex_unlock(&iprune_mutex);
-
-       if (current_is_kswapd())
-               mod_page_state(kswapd_inodesteal, reap);
-       else
-               mod_page_state(pginodesteal, reap);
 }
 
 /*
index 7fa76ed..93aa571 100644 (file)
@@ -125,11 +125,24 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
        return ret;
 }
 
+static int get_task_ioprio(struct task_struct *p)
+{
+       int ret;
+
+       ret = security_task_getioprio(p);
+       if (ret)
+               goto out;
+       ret = p->ioprio;
+out:
+       return ret;
+}
+
 asmlinkage long sys_ioprio_get(int which, int who)
 {
        struct task_struct *g, *p;
        struct user_struct *user;
        int ret = -ESRCH;
+       int tmpio;
 
        read_lock_irq(&tasklist_lock);
        switch (which) {
@@ -139,16 +152,19 @@ asmlinkage long sys_ioprio_get(int which, int who)
                        else
                                p = find_task_by_pid(who);
                        if (p)
-                               ret = p->ioprio;
+                               ret = get_task_ioprio(p);
                        break;
                case IOPRIO_WHO_PGRP:
                        if (!who)
                                who = process_group(current);
                        do_each_task_pid(who, PIDTYPE_PGID, p) {
+                               tmpio = get_task_ioprio(p);
+                               if (tmpio < 0)
+                                       continue;
                                if (ret == -ESRCH)
-                                       ret = p->ioprio;
+                                       ret = tmpio;
                                else
-                                       ret = ioprio_best(ret, p->ioprio);
+                                       ret = ioprio_best(ret, tmpio);
                        } while_each_task_pid(who, PIDTYPE_PGID, p);
                        break;
                case IOPRIO_WHO_USER:
@@ -163,10 +179,13 @@ asmlinkage long sys_ioprio_get(int which, int who)
                        do_each_thread(g, p) {
                                if (p->uid != user->uid)
                                        continue;
+                               tmpio = get_task_ioprio(p);
+                               if (tmpio < 0)
+                                       continue;
                                if (ret == -ESRCH)
-                                       ret = p->ioprio;
+                                       ret = tmpio;
                                else
-                                       ret = ioprio_best(ret, p->ioprio);
+                                       ret = ioprio_best(ret, tmpio);
                        } while_each_thread(g, p);
 
                        if (who)
index 52d60c3..e7d5a30 100644 (file)
@@ -93,7 +93,7 @@ static struct page* ncp_file_mmap_nopage(struct vm_area_struct *area,
         */
        if (type)
                *type = VM_FAULT_MAJOR;
-       inc_page_state(pgmajfault);
+       count_vm_event(PGMAJFAULT);
        return page;
 }
 
index d3ff7ab..36e902a 100644 (file)
@@ -314,6 +314,7 @@ nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst,
                                                req->wb_index, NFS_PAGE_TAG_DIRTY);
                                nfs_list_remove_request(req);
                                nfs_list_add_request(req, dst);
+                               dec_zone_page_state(req->wb_page, NR_FILE_DIRTY);
                                res++;
                        }
                }
index 1aadc13..bca5734 100644 (file)
@@ -496,7 +496,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
        nfs_list_add_request(req, &nfsi->dirty);
        nfsi->ndirty++;
        spin_unlock(&nfsi->req_lock);
-       inc_page_state(nr_dirty);
+       inc_zone_page_state(req->wb_page, NR_FILE_DIRTY);
        mark_inode_dirty(inode);
 }
 
@@ -524,7 +524,7 @@ nfs_mark_request_commit(struct nfs_page *req)
        nfs_list_add_request(req, &nfsi->commit);
        nfsi->ncommit++;
        spin_unlock(&nfsi->req_lock);
-       inc_page_state(nr_unstable);
+       inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
        mark_inode_dirty(inode);
 }
 #endif
@@ -608,7 +608,6 @@ nfs_scan_dirty(struct inode *inode, struct list_head *dst, unsigned long idx_sta
        if (nfsi->ndirty != 0) {
                res = nfs_scan_lock_dirty(nfsi, dst, idx_start, npages);
                nfsi->ndirty -= res;
-               sub_page_state(nr_dirty,res);
                if ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty))
                        printk(KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n");
        }
@@ -1393,7 +1392,6 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
 {
        struct nfs_write_data   *data = calldata;
        struct nfs_page         *req;
-       int res = 0;
 
         dprintk("NFS: %4d nfs_commit_done (status %d)\n",
                                 task->tk_pid, task->tk_status);
@@ -1405,6 +1403,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
        while (!list_empty(&data->pages)) {
                req = nfs_list_entry(data->pages.next);
                nfs_list_remove_request(req);
+               dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
 
                dprintk("NFS: commit (%s/%Ld %d@%Ld)",
                        req->wb_context->dentry->d_inode->i_sb->s_id,
@@ -1431,9 +1430,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
                nfs_mark_request_dirty(req);
        next:
                nfs_clear_page_writeback(req);
-               res++;
        }
-       sub_page_state(nr_unstable,res);
 }
 
 static const struct rpc_call_ops nfs_commit_ops = {
index 3eec300..01bc68c 100644 (file)
@@ -126,7 +126,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
        if (*ep)
                goto out;
        dprintk("found fsidtype %d\n", fsidtype);
-       if (fsidtype > 2)
+       if (key_len(fsidtype)==0) /* invalid type */
                goto out;
        if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
                goto out;
index 7c7d016..9daa0b9 100644 (file)
@@ -1237,8 +1237,15 @@ find_file(struct inode *ino)
        return NULL;
 }
 
-#define TEST_ACCESS(x) ((x > 0 || x < 4)?1:0)
-#define TEST_DENY(x) ((x >= 0 || x < 5)?1:0)
+static int access_valid(u32 x)
+{
+       return (x > 0 && x < 4);
+}
+
+static int deny_valid(u32 x)
+{
+       return (x >= 0 && x < 5);
+}
 
 static void
 set_access(unsigned int *access, unsigned long bmap) {
@@ -1745,7 +1752,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
        int status;
 
        status = nfserr_inval;
-       if (!TEST_ACCESS(open->op_share_access) || !TEST_DENY(open->op_share_deny))
+       if (!access_valid(open->op_share_access)
+                       || !deny_valid(open->op_share_deny))
                goto out;
        /*
         * Lookup file; if found, lookup stateid and check open request,
@@ -1782,10 +1790,10 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
        } else {
                /* Stateid was not found, this is a new OPEN */
                int flags = 0;
+               if (open->op_share_access & NFS4_SHARE_ACCESS_READ)
+                       flags |= MAY_READ;
                if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
-                       flags = MAY_WRITE;
-               else
-                       flags = MAY_READ;
+                       flags |= MAY_WRITE;
                status = nfs4_new_open(rqstp, &stp, dp, current_fh, flags);
                if (status)
                        goto out;
@@ -2070,16 +2078,12 @@ nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int fl
        if (!stateid->si_fileid) { /* delegation stateid */
                if(!(dp = find_delegation_stateid(ino, stateid))) {
                        dprintk("NFSD: delegation stateid not found\n");
-                       if (nfs4_in_grace())
-                               status = nfserr_grace;
                        goto out;
                }
                stidp = &dp->dl_stateid;
        } else { /* open or lock stateid */
                if (!(stp = find_stateid(stateid, flags))) {
                        dprintk("NFSD: open or lock stateid not found\n");
-                       if (nfs4_in_grace())
-                               status = nfserr_grace;
                        goto out;
                }
                if ((flags & CHECK_FH) && nfs4_check_fh(current_fh, stp))
@@ -2252,8 +2256,9 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
                        (int)current_fh->fh_dentry->d_name.len,
                        current_fh->fh_dentry->d_name.name);
 
-       if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0)))
-               goto out;
+       status = fh_verify(rqstp, current_fh, S_IFREG, 0);
+       if (status)
+               return status;
 
        nfs4_lock_state();
 
@@ -2320,7 +2325,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n
                        (int)current_fh->fh_dentry->d_name.len,
                        current_fh->fh_dentry->d_name.name);
 
-       if (!TEST_ACCESS(od->od_share_access) || !TEST_DENY(od->od_share_deny))
+       if (!access_valid(od->od_share_access)
+                       || !deny_valid(od->od_share_deny))
                return nfserr_inval;
 
        nfs4_lock_state();
index 3f2ec2e..ecc439d 100644 (file)
@@ -187,13 +187,6 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
                        goto out;
                }
 
-               /* Set user creds for this exportpoint */
-               error = nfsd_setuser(rqstp, exp);
-               if (error) {
-                       error = nfserrno(error);
-                       goto out;
-               }
-
                /*
                 * Look up the dentry using the NFS file handle.
                 */
@@ -251,6 +244,14 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
        }
        cache_get(&exp->h);
 
+       /* Set user creds for this exportpoint; necessary even in the "just
+        * checking" case because this may be a filehandle that was created by
+        * fh_compose, and that is about to be used in another nfsv4 compound
+        * operation */
+       error = nfserrno(nfsd_setuser(rqstp, exp));
+       if (error)
+               goto out;
+
        error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type);
        if (error)
                goto out;
@@ -312,8 +313,8 @@ int
 fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, struct svc_fh *ref_fh)
 {
        /* ref_fh is a reference file handle.
-        * if it is non-null, then we should compose a filehandle which is
-        * of the same version, where possible.
+        * if it is non-null and for the same filesystem, then we should compose
+        * a filehandle which is of the same version, where possible.
         * Currently, that means that if ref_fh->fh_handle.fh_version == 0xca
         * Then create a 32byte filehandle using nfs_fhbase_old
         *
@@ -332,7 +333,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st
                parent->d_name.name, dentry->d_name.name,
                (inode ? inode->i_ino : 0));
 
-       if (ref_fh) {
+       if (ref_fh && ref_fh->fh_export == exp) {
                ref_fh_version = ref_fh->fh_handle.fh_version;
                if (ref_fh_version == 0xca)
                        ref_fh_fsid_type = 0;
@@ -461,7 +462,7 @@ fh_update(struct svc_fh *fhp)
        } else {
                int size;
                if (fhp->fh_handle.fh_fileid_type != 0)
-                       goto out_uptodate;
+                       goto out;
                datap = fhp->fh_handle.fh_auth+
                        fhp->fh_handle.fh_size/4 -1;
                size = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
@@ -481,10 +482,6 @@ out_negative:
        printk(KERN_ERR "fh_update: %s/%s still negative!\n",
                dentry->d_parent->d_name.name, dentry->d_name.name);
        goto out;
-out_uptodate:
-       printk(KERN_ERR "fh_update: %s/%s already up-to-date!\n",
-               dentry->d_parent->d_name.name, dentry->d_name.name);
-       goto out;
 }
 
 /*
index da3ec74..c9e3b5a 100644 (file)
@@ -672,7 +672,10 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
                goto out_nfserr;
 
        if (access & MAY_WRITE) {
-               flags = O_WRONLY|O_LARGEFILE;
+               if (access & MAY_READ)
+                       flags = O_RDWR|O_LARGEFILE;
+               else
+                       flags = O_WRONLY|O_LARGEFILE;
 
                DQUOT_INIT(inode);
        }
@@ -833,7 +836,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
        if (ra && ra->p_set)
                file->f_ra = ra->p_ra;
 
-       if (file->f_op->sendfile) {
+       if (file->f_op->sendfile && rqstp->rq_sendfile_ok) {
                svc_pushback_unused_pages(rqstp);
                err = file->f_op->sendfile(file, &offset, *count,
                                                 nfsd_read_actor, rqstp);
@@ -1516,14 +1519,15 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
                        err = nfserrno(err);
        }
 
-       fh_unlock(ffhp);
        dput(dnew);
+out_unlock:
+       fh_unlock(ffhp);
 out:
        return err;
 
 out_nfserr:
        err = nfserrno(err);
-       goto out;
+       goto out_unlock;
 }
 
 /*
@@ -1552,7 +1556,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
        tdir = tdentry->d_inode;
 
        err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
-       if (fdir->i_sb != tdir->i_sb)
+       if (ffhp->fh_export != tfhp->fh_export)
                goto out;
 
        err = nfserr_perm;
index b8d4885..9f2cfc3 100644 (file)
@@ -119,7 +119,6 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
 {
        struct sysinfo i;
        int len;
-       struct page_state ps;
        unsigned long inactive;
        unsigned long active;
        unsigned long free;
@@ -128,7 +127,6 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
        struct vmalloc_info vmi;
        long cached;
 
-       get_page_state(&ps);
        get_zone_counts(&active, &inactive, &free);
 
 /*
@@ -141,7 +139,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
        allowed = ((totalram_pages - hugetlb_total_pages())
                * sysctl_overcommit_ratio / 100) + total_swap_pages;
 
-       cached = get_page_cache_size() - total_swapcache_pages - i.bufferram;
+       cached = global_page_state(NR_FILE_PAGES) -
+                       total_swapcache_pages - i.bufferram;
        if (cached < 0)
                cached = 0;
 
@@ -166,11 +165,14 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                "SwapFree:     %8lu kB\n"
                "Dirty:        %8lu kB\n"
                "Writeback:    %8lu kB\n"
+               "AnonPages:    %8lu kB\n"
                "Mapped:       %8lu kB\n"
                "Slab:         %8lu kB\n"
+               "PageTables:   %8lu kB\n"
+               "NFS Unstable: %8lu kB\n"
+               "Bounce:       %8lu kB\n"
                "CommitLimit:  %8lu kB\n"
                "Committed_AS: %8lu kB\n"
-               "PageTables:   %8lu kB\n"
                "VmallocTotal: %8lu kB\n"
                "VmallocUsed:  %8lu kB\n"
                "VmallocChunk: %8lu kB\n",
@@ -187,13 +189,16 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                K(i.freeram-i.freehigh),
                K(i.totalswap),
                K(i.freeswap),
-               K(ps.nr_dirty),
-               K(ps.nr_writeback),
-               K(ps.nr_mapped),
-               K(ps.nr_slab),
+               K(global_page_state(NR_FILE_DIRTY)),
+               K(global_page_state(NR_WRITEBACK)),
+               K(global_page_state(NR_ANON_PAGES)),
+               K(global_page_state(NR_FILE_MAPPED)),
+               K(global_page_state(NR_SLAB)),
+               K(global_page_state(NR_PAGETABLE)),
+               K(global_page_state(NR_UNSTABLE_NFS)),
+               K(global_page_state(NR_BOUNCE)),
                K(allowed),
                K(committed),
-               K(ps.nr_page_table_pages),
                (unsigned long)VMALLOC_TOTAL >> 10,
                vmi.used >> 10,
                vmi.largest_chunk >> 10
index b9beceb..b492857 100644 (file)
@@ -63,7 +63,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20060608
+#define ACPI_CA_VERSION                 0x20060623
 
 /*
  * OS name, used for the _OS object.  The _OS object is essentially obsolete,
index 288f849..a22fe9c 100644 (file)
@@ -201,7 +201,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
 acpi_status
 acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
                               union acpi_operand_object *obj_desc,
-                              struct acpi_namespace_node *calling_method_node);
+                              struct acpi_walk_state *walk_state);
 
 acpi_status
 acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state);
index 14531d4..06972e6 100644 (file)
@@ -181,6 +181,12 @@ ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
 extern struct acpi_table_list acpi_gbl_table_lists[ACPI_TABLE_ID_MAX + 1];
 extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1];
 
+/*****************************************************************************
+ *
+ * Mutual exlusion within ACPICA subsystem
+ *
+ ****************************************************************************/
+
 /*
  * Predefined mutex objects.  This array contains the
  * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
@@ -188,6 +194,20 @@ extern struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1];
  */
 ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
 
+/*
+ * Global lock semaphore works in conjunction with the actual HW global lock
+ */
+ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
+
+/*
+ * Spinlocks are used for interfaces that can be possibly called at
+ * interrupt level
+ */
+ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock;     /* For GPE data structs and registers */
+ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock;        /* For ACPI H/W except GPE registers */
+#define acpi_gbl_gpe_lock      &_acpi_gbl_gpe_lock
+#define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock
+
 /*****************************************************************************
  *
  * Miscellaneous globals
@@ -217,7 +237,6 @@ ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
 ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
 ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
 ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
-ACPI_EXTERN acpi_handle acpi_gbl_global_lock_semaphore;
 
 /* Misc */
 
@@ -315,11 +334,6 @@ ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
 ACPI_EXTERN struct acpi_gpe_block_info
     *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
 
-/* Spinlocks */
-
-ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;
-ACPI_EXTERN acpi_handle acpi_gbl_hardware_lock;
-
 /*****************************************************************************
  *
  * Debugger globals
index 9f22cfc..216339a 100644 (file)
@@ -287,7 +287,10 @@ acpi_ex_system_wait_event(union acpi_operand_object *time,
 
 acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
 
-acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout);
+acpi_status
+acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout);
+
+acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout);
 
 /*
  * exoparg1 - ACPI AML execution, 1 operand
index 1eeca7a..56b8024 100644 (file)
 /* acpisrc:struct_defs -- for acpisrc conversion */
 
 #define ACPI_WAIT_FOREVER               0xFFFF /* u16, as per ACPI spec */
-#define ACPI_INFINITE_CONCURRENCY       0xFF
+#define ACPI_DO_NOT_WAIT                0
+#define ACPI_SERIALIZED                 0xFF
 
-typedef void *acpi_mutex;
 typedef u32 acpi_mutex_handle;
+#define ACPI_GLOBAL_LOCK                (acpi_semaphore) (-1)
 
 /* Total number of aml opcodes defined */
 
@@ -79,16 +80,15 @@ union acpi_parse_object;
  * table below also!
  */
 #define ACPI_MTX_INTERPRETER            0      /* AML Interpreter, main lock */
-#define ACPI_MTX_CONTROL_METHOD         1      /* Control method termination [TBD: may no longer be necessary] */
-#define ACPI_MTX_TABLES                 2      /* Data for ACPI tables */
-#define ACPI_MTX_NAMESPACE              3      /* ACPI Namespace */
-#define ACPI_MTX_EVENTS                 4      /* Data for ACPI events */
-#define ACPI_MTX_CACHES                 5      /* Internal caches, general purposes */
-#define ACPI_MTX_MEMORY                 6      /* Debug memory tracking lists */
-#define ACPI_MTX_DEBUG_CMD_COMPLETE     7      /* AML debugger */
-#define ACPI_MTX_DEBUG_CMD_READY        8      /* AML debugger */
-
-#define ACPI_MAX_MUTEX                  8
+#define ACPI_MTX_TABLES                 1      /* Data for ACPI tables */
+#define ACPI_MTX_NAMESPACE              2      /* ACPI Namespace */
+#define ACPI_MTX_EVENTS                 3      /* Data for ACPI events */
+#define ACPI_MTX_CACHES                 4      /* Internal caches, general purposes */
+#define ACPI_MTX_MEMORY                 5      /* Debug memory tracking lists */
+#define ACPI_MTX_DEBUG_CMD_COMPLETE     6      /* AML debugger */
+#define ACPI_MTX_DEBUG_CMD_READY        7      /* AML debugger */
+
+#define ACPI_MAX_MUTEX                  7
 #define ACPI_NUM_MUTEX                  ACPI_MAX_MUTEX+1
 
 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
@@ -98,14 +98,13 @@ union acpi_parse_object;
 
 static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
        "ACPI_MTX_Interpreter",
-       "ACPI_MTX_Method",
        "ACPI_MTX_Tables",
        "ACPI_MTX_Namespace",
        "ACPI_MTX_Events",
        "ACPI_MTX_Caches",
        "ACPI_MTX_Memory",
-       "ACPI_MTX_DebugCmdComplete",
-       "ACPI_MTX_DebugCmdReady"
+       "ACPI_MTX_CommandComplete",
+       "ACPI_MTX_CommandReady"
 };
 
 #endif
@@ -705,6 +704,13 @@ struct acpi_bit_register_info {
 };
 
 /*
+ * Some ACPI registers have bits that must be ignored -- meaning that they
+ * must be preserved.
+ */
+#define ACPI_PM1_STATUS_PRESERVED_BITS          0x0800 /* Bit 11 */
+#define ACPI_PM1_CONTROL_PRESERVED_BITS         0x0201 /* Bit 9, Bit 0 (SCI_EN) */
+
+/*
  * Register IDs
  * These are the full ACPI registers
  */
index 38f9aa4..4bb3806 100644 (file)
 #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask)      ((val << pos) & mask)
 #define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val)  reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
 
+#define ACPI_INSERT_BITS(target, mask, source)          target = ((target & (~(mask))) | (source & mask))
+
 /* Generate a UUID */
 
 #define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
index 1747d94..8fdee31 100644 (file)
@@ -140,14 +140,14 @@ struct acpi_object_package {
  *****************************************************************************/
 
 struct acpi_object_event {
-       ACPI_OBJECT_COMMON_HEADER void *semaphore;
+       ACPI_OBJECT_COMMON_HEADER acpi_semaphore os_semaphore;  /* Actual OS synchronization object */
 };
 
 struct acpi_object_mutex {
        ACPI_OBJECT_COMMON_HEADER u8 sync_level;        /* 0-15, specified in Mutex() call */
        u16 acquisition_depth;  /* Allow multiple Acquires, same thread */
        struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
-       void *semaphore;        /* Actual OS synchronization object */
+       acpi_mutex os_mutex;    /* Actual OS synchronization object */
        union acpi_operand_object *prev;        /* Link for list of acquired mutexes */
        union acpi_operand_object *next;        /* Link for list of acquired mutexes */
        struct acpi_namespace_node *node;       /* Containing namespace node */
@@ -166,8 +166,8 @@ struct acpi_object_region {
 struct acpi_object_method {
        ACPI_OBJECT_COMMON_HEADER u8 method_flags;
        u8 param_count;
-       u8 concurrency;
-       void *semaphore;
+       u8 sync_level;
+       union acpi_operand_object *mutex;
        u8 *aml_start;
        ACPI_INTERNAL_METHOD implementation;
        u32 aml_length;
index a2b3e39..f338e40 100644 (file)
@@ -334,7 +334,7 @@ int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
                 acpi_handle handle, int type);
 int acpi_bus_trim(struct acpi_device *start, int rmdevice);
 int acpi_bus_start(struct acpi_device *device);
-
+acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd);
 int acpi_match_ids(struct acpi_device *device, char *ids);
 int acpi_create_dir(struct acpi_device *);
 void acpi_remove_dir(struct acpi_device *);
index b425f9b..6a5bdce 100644 (file)
@@ -110,4 +110,21 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
 
 extern int acpi_specific_hotkey_enabled;
 
+/*--------------------------------------------------------------------------
+                                  Dock Station
+  -------------------------------------------------------------------------- */
+#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE)
+extern int is_dock_device(acpi_handle handle);
+extern int register_dock_notifier(struct notifier_block *nb);
+extern void unregister_dock_notifier(struct notifier_block *nb);
+extern int register_hotplug_dock_device(acpi_handle handle,
+       acpi_notify_handler handler, void *context);
+extern void unregister_hotplug_dock_device(acpi_handle handle);
+#else
+#define is_dock_device(h)                      (0)
+#define register_dock_notifier(nb)             (-ENODEV)
+#define unregister_dock_notifier(nb)                   do { } while(0)
+#define register_hotplug_dock_device(h1, h2, c)        (-ENODEV)
+#define unregister_hotplug_dock_device(h)       do { } while(0)
+#endif
 #endif /*__ACPI_DRIVERS_H__*/
index 8f473c8..89bc4a1 100644 (file)
@@ -96,25 +96,47 @@ acpi_os_table_override(struct acpi_table_header *existing_table,
                       struct acpi_table_header **new_table);
 
 /*
- * Synchronization primitives
+ * Spinlock primitives
+ */
+acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
+
+void acpi_os_delete_lock(acpi_spinlock handle);
+
+acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
+
+void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
+
+/*
+ * Semaphore primitives
  */
 acpi_status
 acpi_os_create_semaphore(u32 max_units,
-                        u32 initial_units, acpi_handle * out_handle);
+                        u32 initial_units, acpi_semaphore * out_handle);
 
-acpi_status acpi_os_delete_semaphore(acpi_handle handle);
+acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
 
-acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout);
+acpi_status
+acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
+
+acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
+
+/*
+ * Mutex primitives
+ */
+acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
 
-acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units);
+void acpi_os_delete_mutex(acpi_mutex handle);
 
-acpi_status acpi_os_create_lock(acpi_handle * out_handle);
+acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
 
-void acpi_os_delete_lock(acpi_handle handle);
+void acpi_os_release_mutex(acpi_mutex handle);
 
-acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle);
+/* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */
 
-void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags);
+#define acpi_os_create_mutex(out_handle)    acpi_os_create_semaphore (1, 1, out_handle)
+#define acpi_os_delete_mutex(handle)        (void) acpi_os_delete_semaphore (handle)
+#define acpi_os_acquire_mutex(handle,time)  acpi_os_wait_semaphore (handle, 1, time)
+#define acpi_os_release_mutex(handle)       (void) acpi_os_signal_semaphore (handle, 1)
 
 /*
  * Memory allocation and mapping
index 77cf123..64b603c 100644 (file)
@@ -241,7 +241,7 @@ typedef acpi_native_uint acpi_size;
 
 /*******************************************************************************
  *
- * OS- or compiler-dependent types
+ * OS-dependent and compiler-dependent types
  *
  * If the defaults below are not appropriate for the host system, they can
  * be defined in the compiler-specific or OS-specific header, and this will
@@ -249,29 +249,36 @@ typedef acpi_native_uint acpi_size;
  *
  ******************************************************************************/
 
-/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
+/* Value returned by acpi_os_get_thread_id */
 
-#ifndef acpi_uintptr_t
-#define acpi_uintptr_t                  void *
+#ifndef acpi_thread_id
+#define acpi_thread_id                  acpi_native_uint
 #endif
 
-/*
- * If acpi_cache_t was not defined in the OS-dependent header,
- * define it now. This is typically the case where the local cache
- * manager implementation is to be used (ACPI_USE_LOCAL_CACHE)
- */
-#ifndef acpi_cache_t
-#define acpi_cache_t                    struct acpi_memory_list
+/* Object returned from acpi_os_create_lock */
+
+#ifndef acpi_spinlock
+#define acpi_spinlock                   void *
 #endif
 
-/*
- * Allow the CPU flags word to be defined per-OS to simplify the use of the
- * lock and unlock OSL interfaces.
- */
+/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */
+
 #ifndef acpi_cpu_flags
 #define acpi_cpu_flags                  acpi_native_uint
 #endif
 
+/* Object returned from acpi_os_create_cache */
+
+#ifndef acpi_cache_t
+#define acpi_cache_t                    struct acpi_memory_list
+#endif
+
+/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
+
+#ifndef acpi_uintptr_t
+#define acpi_uintptr_t                  void *
+#endif
+
 /*
  * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
  * some compilers can catch printf format string problems
@@ -298,13 +305,6 @@ typedef acpi_native_uint acpi_size;
 #define ACPI_EXPORT_SYMBOL(symbol)
 #endif
 
-/*
- * thread_id is returned by acpi_os_get_thread_id.
- */
-#ifndef acpi_thread_id
-#define acpi_thread_id                  acpi_native_uint
-#endif
-
 /*******************************************************************************
  *
  * Independent types
@@ -380,6 +380,11 @@ struct uint32_struct {
        u32 hi;
 };
 
+/* Synchronization objects */
+
+#define acpi_mutex                      void *
+#define acpi_semaphore                  void *
+
 /*
  * Acpi integer width. In ACPI version 1, integers are
  * 32 bits.  In ACPI version 2, integers are 64 bits.
index 277d35b..3f853ca 100644 (file)
 #include <asm/div64.h>
 #include <asm/acpi.h>
 #include <linux/slab.h>
+#include <linux/spinlock_types.h>
 
 /* Host-dependent types and defines */
 
 #define ACPI_MACHINE_WIDTH          BITS_PER_LONG
 #define acpi_cache_t                        kmem_cache_t
+#define acpi_spinlock                   spinlock_t *
 #define ACPI_EXPORT_SYMBOL(symbol)  EXPORT_SYMBOL(symbol);
 #define strtoul                     simple_strtoul
 
index 77371b3..9dd5b75 100644 (file)
@@ -62,6 +62,7 @@ struct acpi_processor_cx {
        u32 latency_ticks;
        u32 power;
        u32 usage;
+       u64 time;
        struct acpi_processor_cx_policy promotion;
        struct acpi_processor_cx_policy demotion;
 };
index 859b5e9..2431238 100644 (file)
@@ -657,13 +657,6 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
        __pte;                                                            \
 })
 
-#define SetPageUptodate(_page) \
-       do {                                                                  \
-               struct page *__page = (_page);                                \
-               if (!test_and_set_bit(PG_uptodate, &__page->flags))           \
-                       page_test_and_clear_dirty(_page);                     \
-       } while (0)
-
 #ifdef __s390x__
 
 #define pfn_pmd(pfn, pgprot)                                              \
index 1934d93..44e8b8c 100644 (file)
@@ -45,8 +45,13 @@ static inline void writel(unsigned int b, volatile void __iomem *addr)
 {
        *(volatile unsigned int __force *) addr = b;
 }
+static inline void writeq(unsigned int b, volatile void __iomem *addr)
+{
+       *(volatile unsigned long long __force *) addr = b;
+}
 #define __raw_writeb writeb
 #define __raw_writew writew
 #define __raw_writel writel
+#define __raw_writeq writeq
 
 #endif
index 466fbe9..35e1376 100644 (file)
@@ -100,8 +100,10 @@ struct cpufreq_policy {
 #define CPUFREQ_INCOMPATIBLE   (1)
 #define CPUFREQ_NOTIFY         (2)
 
-#define CPUFREQ_SHARED_TYPE_ALL        (0) /* All dependent CPUs should set freq */
-#define CPUFREQ_SHARED_TYPE_ANY        (1) /* Freq can be set from any dependent CPU */
+#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
+#define CPUFREQ_SHARED_TYPE_HW  (1) /* HW does needed coordination */
+#define CPUFREQ_SHARED_TYPE_ALL         (2) /* All dependent CPUs should set freq */
+#define CPUFREQ_SHARED_TYPE_ANY         (3) /* Freq can be set from any dependent CPU*/
 
 /******************** cpufreq transition notifiers *******************/
 
index 2d22932..0503b2e 100644 (file)
@@ -46,6 +46,8 @@ enum kobject_action {
        KOBJ_UMOUNT     = (__force kobject_action_t) 0x05,      /* umount event for block devices (broken) */
        KOBJ_OFFLINE    = (__force kobject_action_t) 0x06,      /* device offline */
        KOBJ_ONLINE     = (__force kobject_action_t) 0x07,      /* device online */
+       KOBJ_UNDOCK     = (__force kobject_action_t) 0x08,      /* undocking */
+       KOBJ_DOCK       = (__force kobject_action_t) 0x09,      /* dock */
 };
 
 struct kobject {
index c41a129..7517952 100644 (file)
@@ -36,7 +36,6 @@ extern int sysctl_legacy_va_layout;
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
-#include <asm/atomic.h>
 
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
@@ -515,6 +514,11 @@ static inline void set_page_links(struct page *page, unsigned long zone,
        set_page_section(page, pfn_to_section_nr(pfn));
 }
 
+/*
+ * Some inline functions in vmstat.h depend on page_zone()
+ */
+#include <linux/vmstat.h>
+
 #ifndef CONFIG_DISCONTIGMEM
 /* The array of struct pages - for discontigmem use pgdat->lmem_map */
 extern struct page *mem_map;
index d6120fa..27e748e 100644 (file)
@@ -46,6 +46,27 @@ struct zone_padding {
 #define ZONE_PADDING(name)
 #endif
 
+enum zone_stat_item {
+       NR_ANON_PAGES,  /* Mapped anonymous pages */
+       NR_FILE_MAPPED, /* pagecache pages mapped into pagetables.
+                          only modified from process context */
+       NR_FILE_PAGES,
+       NR_SLAB,        /* Pages used by slab allocator */
+       NR_PAGETABLE,   /* used for pagetables */
+       NR_FILE_DIRTY,
+       NR_WRITEBACK,
+       NR_UNSTABLE_NFS,        /* NFS unstable pages */
+       NR_BOUNCE,
+#ifdef CONFIG_NUMA
+       NUMA_HIT,               /* allocated in intended node */
+       NUMA_MISS,              /* allocated in non intended node */
+       NUMA_FOREIGN,           /* was intended here, hit elsewhere */
+       NUMA_INTERLEAVE_HIT,    /* interleaver preferred this zone */
+       NUMA_LOCAL,             /* allocation from local node */
+       NUMA_OTHER,             /* allocation from other node */
+#endif
+       NR_VM_ZONE_STAT_ITEMS };
+
 struct per_cpu_pages {
        int count;              /* number of pages in the list */
        int high;               /* high watermark, emptying needed */
@@ -55,13 +76,8 @@ struct per_cpu_pages {
 
 struct per_cpu_pageset {
        struct per_cpu_pages pcp[2];    /* 0: hot.  1: cold */
-#ifdef CONFIG_NUMA
-       unsigned long numa_hit;         /* allocated in intended node */
-       unsigned long numa_miss;        /* allocated in non intended node */
-       unsigned long numa_foreign;     /* was intended here, hit elsewhere */
-       unsigned long interleave_hit;   /* interleaver prefered this zone */
-       unsigned long local_node;       /* allocation from local node */
-       unsigned long other_node;       /* allocation from other node */
+#ifdef CONFIG_SMP
+       s8 vm_stat_diff[NR_VM_ZONE_STAT_ITEMS];
 #endif
 } ____cacheline_aligned_in_smp;
 
@@ -165,12 +181,8 @@ struct zone {
        /* A count of how many reclaimers are scanning this zone */
        atomic_t                reclaim_in_progress;
 
-       /*
-        * timestamp (in jiffies) of the last zone reclaim that did not
-        * result in freeing of pages. This is used to avoid repeated scans
-        * if all memory in the zone is in use.
-        */
-       unsigned long           last_unsuccessful_zone_reclaim;
+       /* Zone statistics */
+       atomic_long_t           vm_stat[NR_VM_ZONE_STAT_ITEMS];
 
        /*
         * prev_priority holds the scanning priority for this zone.  It is
index 0c076d5..5748642 100644 (file)
@@ -5,12 +5,8 @@
 #ifndef PAGE_FLAGS_H
 #define PAGE_FLAGS_H
 
-#include <linux/percpu.h>
-#include <linux/cache.h>
 #include <linux/types.h>
 
-#include <asm/pgtable.h>
-
 /*
  * Various page->flags bits:
  *
 #endif
 
 /*
- * Global page accounting.  One instance per CPU.  Only unsigned longs are
- * allowed.
- *
- * - Fields can be modified with xxx_page_state and xxx_page_state_zone at
- * any time safely (which protects the instance from modification by
- * interrupt.
- * - The __xxx_page_state variants can be used safely when interrupts are
- * disabled.
- * - The __xxx_page_state variants can be used if the field is only
- * modified from process context and protected from preemption, or only
- * modified from interrupt context.  In this case, the field should be
- * commented here.
- */
-struct page_state {
-       unsigned long nr_dirty;         /* Dirty writeable pages */
-       unsigned long nr_writeback;     /* Pages under writeback */
-       unsigned long nr_unstable;      /* NFS unstable pages */
-       unsigned long nr_page_table_pages;/* Pages used for pagetables */
-       unsigned long nr_mapped;        /* mapped into pagetables.
-                                        * only modified from process context */
-       unsigned long nr_slab;          /* In slab */
-#define GET_PAGE_STATE_LAST nr_slab
-
-       /*
-        * The below are zeroed by get_page_state().  Use get_full_page_state()
-        * to add up all these.
-        */
-       unsigned long pgpgin;           /* Disk reads */
-       unsigned long pgpgout;          /* Disk writes */
-       unsigned long pswpin;           /* swap reads */
-       unsigned long pswpout;          /* swap writes */
-
-       unsigned long pgalloc_high;     /* page allocations */
-       unsigned long pgalloc_normal;
-       unsigned long pgalloc_dma32;
-       unsigned long pgalloc_dma;
-
-       unsigned long pgfree;           /* page freeings */
-       unsigned long pgactivate;       /* pages moved inactive->active */
-       unsigned long pgdeactivate;     /* pages moved active->inactive */
-
-       unsigned long pgfault;          /* faults (major+minor) */
-       unsigned long pgmajfault;       /* faults (major only) */
-
-       unsigned long pgrefill_high;    /* inspected in refill_inactive_zone */
-       unsigned long pgrefill_normal;
-       unsigned long pgrefill_dma32;
-       unsigned long pgrefill_dma;
-
-       unsigned long pgsteal_high;     /* total highmem pages reclaimed */
-       unsigned long pgsteal_normal;
-       unsigned long pgsteal_dma32;
-       unsigned long pgsteal_dma;
-
-       unsigned long pgscan_kswapd_high;/* total highmem pages scanned */
-       unsigned long pgscan_kswapd_normal;
-       unsigned long pgscan_kswapd_dma32;
-       unsigned long pgscan_kswapd_dma;
-
-       unsigned long pgscan_direct_high;/* total highmem pages scanned */
-       unsigned long pgscan_direct_normal;
-       unsigned long pgscan_direct_dma32;
-       unsigned long pgscan_direct_dma;
-
-       unsigned long pginodesteal;     /* pages reclaimed via inode freeing */
-       unsigned long slabs_scanned;    /* slab objects scanned */
-       unsigned long kswapd_steal;     /* pages reclaimed by kswapd */
-       unsigned long kswapd_inodesteal;/* reclaimed via kswapd inode freeing */
-       unsigned long pageoutrun;       /* kswapd's calls to page reclaim */
-       unsigned long allocstall;       /* direct reclaim calls */
-
-       unsigned long pgrotated;        /* pages rotated to tail of the LRU */
-       unsigned long nr_bounce;        /* pages for bounce buffers */
-};
-
-extern void get_page_state(struct page_state *ret);
-extern void get_page_state_node(struct page_state *ret, int node);
-extern void get_full_page_state(struct page_state *ret);
-extern unsigned long read_page_state_offset(unsigned long offset);
-extern void mod_page_state_offset(unsigned long offset, unsigned long delta);
-extern void __mod_page_state_offset(unsigned long offset, unsigned long delta);
-
-#define read_page_state(member) \
-       read_page_state_offset(offsetof(struct page_state, member))
-
-#define mod_page_state(member, delta)  \
-       mod_page_state_offset(offsetof(struct page_state, member), (delta))
-
-#define __mod_page_state(member, delta)        \
-       __mod_page_state_offset(offsetof(struct page_state, member), (delta))
-
-#define inc_page_state(member)         mod_page_state(member, 1UL)
-#define dec_page_state(member)         mod_page_state(member, 0UL - 1)
-#define add_page_state(member,delta)   mod_page_state(member, (delta))
-#define sub_page_state(member,delta)   mod_page_state(member, 0UL - (delta))
-
-#define __inc_page_state(member)       __mod_page_state(member, 1UL)
-#define __dec_page_state(member)       __mod_page_state(member, 0UL - 1)
-#define __add_page_state(member,delta) __mod_page_state(member, (delta))
-#define __sub_page_state(member,delta) __mod_page_state(member, 0UL - (delta))
-
-#define page_state(member) (*__page_state(offsetof(struct page_state, member)))
-
-#define state_zone_offset(zone, member)                                        \
-({                                                                     \
-       unsigned offset;                                                \
-       if (is_highmem(zone))                                           \
-               offset = offsetof(struct page_state, member##_high);    \
-       else if (is_normal(zone))                                       \
-               offset = offsetof(struct page_state, member##_normal);  \
-       else if (is_dma32(zone))                                        \
-               offset = offsetof(struct page_state, member##_dma32);   \
-       else                                                            \
-               offset = offsetof(struct page_state, member##_dma);     \
-       offset;                                                         \
-})
-
-#define __mod_page_state_zone(zone, member, delta)                     \
- do {                                                                  \
-       __mod_page_state_offset(state_zone_offset(zone, member), (delta)); \
- } while (0)
-
-#define mod_page_state_zone(zone, member, delta)                       \
- do {                                                                  \
-       mod_page_state_offset(state_zone_offset(zone, member), (delta)); \
- } while (0)
-
-/*
  * Manipulation of page state flags
  */
 #define PageLocked(page)               \
@@ -254,7 +122,14 @@ extern void __mod_page_state_offset(unsigned long offset, unsigned long delta);
 #define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
 
 #define PageUptodate(page)     test_bit(PG_uptodate, &(page)->flags)
-#ifndef SetPageUptodate
+#ifdef CONFIG_S390
+#define SetPageUptodate(_page) \
+       do {                                                                  \
+               struct page *__page = (_page);                                \
+               if (!test_and_set_bit(PG_uptodate, &__page->flags))           \
+                       page_test_and_clear_dirty(_page);                     \
+       } while (0)
+#else
 #define SetPageUptodate(page)  set_bit(PG_uptodate, &(page)->flags)
 #endif
 #define ClearPageUptodate(page)        clear_bit(PG_uptodate, &(page)->flags)
@@ -306,7 +181,7 @@ extern void __mod_page_state_offset(unsigned long offset, unsigned long delta);
        do {                                                            \
                if (!test_and_set_bit(PG_writeback,                     \
                                &(page)->flags))                        \
-                       inc_page_state(nr_writeback);                   \
+                       inc_zone_page_state(page, NR_WRITEBACK);        \
        } while (0)
 #define TestSetPageWriteback(page)                                     \
        ({                                                              \
@@ -314,14 +189,14 @@ extern void __mod_page_state_offset(unsigned long offset, unsigned long delta);
                ret = test_and_set_bit(PG_writeback,                    \
                                        &(page)->flags);                \
                if (!ret)                                               \
-                       inc_page_state(nr_writeback);                   \
+                       inc_zone_page_state(page, NR_WRITEBACK);        \
                ret;                                                    \
        })
 #define ClearPageWriteback(page)                                       \
        do {                                                            \
                if (test_and_clear_bit(PG_writeback,                    \
                                &(page)->flags))                        \
-                       dec_page_state(nr_writeback);                   \
+                       dec_zone_page_state(page, NR_WRITEBACK);        \
        } while (0)
 #define TestClearPageWriteback(page)                                   \
        ({                                                              \
@@ -329,7 +204,7 @@ extern void __mod_page_state_offset(unsigned long offset, unsigned long delta);
                ret = test_and_clear_bit(PG_writeback,                  \
                                &(page)->flags);                        \
                if (ret)                                                \
-                       dec_page_state(nr_writeback);                   \
+                       dec_zone_page_state(page, NR_WRITEBACK);        \
                ret;                                                    \
        })
 
index 1245df7..0a2f5d2 100644 (file)
@@ -113,51 +113,6 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 extern void remove_from_page_cache(struct page *page);
 extern void __remove_from_page_cache(struct page *page);
 
-extern atomic_t nr_pagecache;
-
-#ifdef CONFIG_SMP
-
-#define PAGECACHE_ACCT_THRESHOLD        max(16, NR_CPUS * 2)
-DECLARE_PER_CPU(long, nr_pagecache_local);
-
-/*
- * pagecache_acct implements approximate accounting for pagecache.
- * vm_enough_memory() do not need high accuracy. Writers will keep
- * an offset in their per-cpu arena and will spill that into the
- * global count whenever the absolute value of the local count
- * exceeds the counter's threshold.
- *
- * MUST be protected from preemption.
- * current protection is mapping->page_lock.
- */
-static inline void pagecache_acct(int count)
-{
-       long *local;
-
-       local = &__get_cpu_var(nr_pagecache_local);
-       *local += count;
-       if (*local > PAGECACHE_ACCT_THRESHOLD || *local < -PAGECACHE_ACCT_THRESHOLD) {
-               atomic_add(*local, &nr_pagecache);
-               *local = 0;
-       }
-}
-
-#else
-
-static inline void pagecache_acct(int count)
-{
-       atomic_add(count, &nr_pagecache);
-}
-#endif
-
-static inline unsigned long get_page_cache_size(void)
-{
-       int ret = atomic_read(&nr_pagecache);
-       if (unlikely(ret < 0))
-               ret = 0;
-       return ret;
-}
-
 /*
  * Return byte-offset into filesystem object for page.
  */
index 9ae6b1a..b093479 100644 (file)
 #define PCI_DEVICE_ID_TI_4450          0x8011
 #define PCI_DEVICE_ID_TI_XX21_XX11     0x8031
 #define PCI_DEVICE_ID_TI_X515          0x8036
+#define PCI_DEVICE_ID_TI_XX12          0x8039
 #define PCI_DEVICE_ID_TI_1130          0xac12
 #define PCI_DEVICE_ID_TI_1031          0xac13
 #define PCI_DEVICE_ID_TI_1131          0xac15
index 48dfe00..b4ca73d 100644 (file)
@@ -163,14 +163,22 @@ extern int rcu_needs_cpu(int cpu);
  *
  * It is illegal to block while in an RCU read-side critical section.
  */
-#define rcu_read_lock()                preempt_disable()
+#define rcu_read_lock() \
+       do { \
+               preempt_disable(); \
+               __acquire(RCU); \
+       } while(0)
 
 /**
  * rcu_read_unlock - marks the end of an RCU read-side critical section.
  *
  * See rcu_read_lock() for more information.
  */
-#define rcu_read_unlock()      preempt_enable()
+#define rcu_read_unlock() \
+       do { \
+               __release(RCU); \
+               preempt_enable(); \
+       } while(0)
 
 /*
  * So where is rcu_write_lock()?  It does not exist, as there is no
@@ -193,14 +201,22 @@ extern int rcu_needs_cpu(int cpu);
  * can use just rcu_read_lock().
  *
  */
-#define rcu_read_lock_bh()     local_bh_disable()
+#define rcu_read_lock_bh() \
+       do { \
+               local_bh_disable(); \
+               __acquire(RCU_BH); \
+       } while(0)
 
 /*
  * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
  *
  * See rcu_read_lock_bh() for more information.
  */
-#define rcu_read_unlock_bh()   local_bh_enable()
+#define rcu_read_unlock_bh() \
+       do { \
+               __release(RCU_BH); \
+               local_bh_enable(); \
+       } while(0)
 
 /**
  * rcu_dereference - fetch an RCU-protected pointer in an
index 36e2bf4..5371e4e 100644 (file)
@@ -34,8 +34,8 @@ struct rtc_time {
  * alarm API.
  */
 struct rtc_wkalrm {
-       unsigned char enabled;  /* 0 = alarm disable, 1 = alarm disabled */
-       unsigned char pending;  /* 0 = alarm pending, 1 = alarm not pending */
+       unsigned char enabled;  /* 0 = alarm disabled, 1 = alarm enabled */
+       unsigned char pending;  /* 0 = alarm not pending, 1 = alarm pending */
        struct rtc_time time;   /* time the alarm is set to */
 };
 
index 821f048..aaf7233 100644 (file)
@@ -1153,7 +1153,7 @@ extern int force_sig_info(int, struct siginfo *, struct task_struct *);
 extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
 extern int kill_pg_info(int, struct siginfo *, pid_t);
 extern int kill_proc_info(int, struct siginfo *, pid_t);
-extern int kill_proc_info_as_uid(int, struct siginfo *, pid_t, uid_t, uid_t);
+extern int kill_proc_info_as_uid(int, struct siginfo *, pid_t, uid_t, uid_t, u32);
 extern void do_notify_parent(struct task_struct *, int);
 extern void force_sig(int, struct task_struct *);
 extern void force_sig_specific(int, struct task_struct *);
index c7ea157..f753038 100644 (file)
@@ -567,6 +567,9 @@ struct swap_info_struct;
  *     @p.
  *     @p contains the task_struct for the process.
  *     Return 0 if permission is granted.
+ * @task_getsecid:
+ *     Retrieve the security identifier of the process @p.
+ *     @p contains the task_struct for the process and place is into @secid.
  * @task_setgroups:
  *     Check permission before setting the supplementary group set of the
  *     current process.
@@ -582,6 +585,10 @@ struct swap_info_struct;
  *     @p contains the task_struct of process.
  *     @ioprio contains the new ioprio value
  *     Return 0 if permission is granted.
+ * @task_getioprio
+ *     Check permission before getting the ioprio value of @p.
+ *     @p contains the task_struct of process.
+ *     Return 0 if permission is granted.
  * @task_setrlimit:
  *     Check permission before setting the resource limits of the current
  *     process for @resource to @new_rlim.  The old resource limit values can
@@ -615,6 +622,7 @@ struct swap_info_struct;
  *     @p contains the task_struct for process.
  *     @info contains the signal information.
  *     @sig contains the signal value.
+ *     @secid contains the sid of the process where the signal originated
  *     Return 0 if permission is granted.
  * @task_wait:
  *     Check permission before allowing a process to reap a child process @p
@@ -1219,16 +1227,18 @@ struct security_operations {
        int (*task_setpgid) (struct task_struct * p, pid_t pgid);
        int (*task_getpgid) (struct task_struct * p);
        int (*task_getsid) (struct task_struct * p);
+       void (*task_getsecid) (struct task_struct * p, u32 * secid);
        int (*task_setgroups) (struct group_info *group_info);
        int (*task_setnice) (struct task_struct * p, int nice);
        int (*task_setioprio) (struct task_struct * p, int ioprio);
+       int (*task_getioprio) (struct task_struct * p);
        int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
        int (*task_setscheduler) (struct task_struct * p, int policy,
                                  struct sched_param * lp);
        int (*task_getscheduler) (struct task_struct * p);
        int (*task_movememory) (struct task_struct * p);
        int (*task_kill) (struct task_struct * p,
-                         struct siginfo * info, int sig);
+                         struct siginfo * info, int sig, u32 secid);
        int (*task_wait) (struct task_struct * p);
        int (*task_prctl) (int option, unsigned long arg2,
                           unsigned long arg3, unsigned long arg4,
@@ -1839,6 +1849,11 @@ static inline int security_task_getsid (struct task_struct *p)
        return security_ops->task_getsid (p);
 }
 
+static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
+{
+       security_ops->task_getsecid (p, secid);
+}
+
 static inline int security_task_setgroups (struct group_info *group_info)
 {
        return security_ops->task_setgroups (group_info);
@@ -1854,6 +1869,11 @@ static inline int security_task_setioprio (struct task_struct *p, int ioprio)
        return security_ops->task_setioprio (p, ioprio);
 }
 
+static inline int security_task_getioprio (struct task_struct *p)
+{
+       return security_ops->task_getioprio (p);
+}
+
 static inline int security_task_setrlimit (unsigned int resource,
                                           struct rlimit *new_rlim)
 {
@@ -1878,9 +1898,10 @@ static inline int security_task_movememory (struct task_struct *p)
 }
 
 static inline int security_task_kill (struct task_struct *p,
-                                     struct siginfo *info, int sig)
+                                     struct siginfo *info, int sig,
+                                     u32 secid)
 {
-       return security_ops->task_kill (p, info, sig);
+       return security_ops->task_kill (p, info, sig, secid);
 }
 
 static inline int security_task_wait (struct task_struct *p)
@@ -2491,6 +2512,9 @@ static inline int security_task_getsid (struct task_struct *p)
        return 0;
 }
 
+static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
+{ }
+
 static inline int security_task_setgroups (struct group_info *group_info)
 {
        return 0;
@@ -2506,6 +2530,11 @@ static inline int security_task_setioprio (struct task_struct *p, int ioprio)
        return 0;
 }
 
+static inline int security_task_getioprio (struct task_struct *p)
+{
+       return 0;
+}
+
 static inline int security_task_setrlimit (unsigned int resource,
                                           struct rlimit *new_rlim)
 {
@@ -2530,7 +2559,8 @@ static inline int security_task_movememory (struct task_struct *p)
 }
 
 static inline int security_task_kill (struct task_struct *p,
-                                     struct siginfo *info, int sig)
+                                     struct siginfo *info, int sig,
+                                     u32 secid)
 {
        return 0;
 }
index c93c3fe..837e8bc 100644 (file)
@@ -125,4 +125,6 @@ static inline void smp_send_reschedule(int cpu) { }
 #define put_cpu()              preempt_enable()
 #define put_cpu_no_resched()   preempt_enable_no_resched()
 
+void smp_setup_processor_id(void);
+
 #endif /* __LINUX_SMP_H */
index 5035643..7b27c09 100644 (file)
@@ -159,7 +159,9 @@ struct svc_rqst {
                                                 * determine what device number
                                                 * to report (real or virtual)
                                                 */
-
+       int                     rq_sendfile_ok; /* turned off in gss privacy
+                                                * to prevent encrypting page
+                                                * cache pages */
        wait_queue_head_t       rq_wait;        /* synchronization */
 };
 
index c41e2d6..cf6ca6e 100644 (file)
@@ -189,7 +189,6 @@ extern long vm_total_pages;
 
 #ifdef CONFIG_NUMA
 extern int zone_reclaim_mode;
-extern int zone_reclaim_interval;
 extern int zone_reclaim(struct zone *, gfp_t, unsigned int);
 #else
 #define zone_reclaim_mode 0
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
new file mode 100644 (file)
index 0000000..3e0daf5
--- /dev/null
@@ -0,0 +1,215 @@
+#ifndef _LINUX_VMSTAT_H
+#define _LINUX_VMSTAT_H
+
+#include <linux/types.h>
+#include <linux/percpu.h>
+#include <linux/config.h>
+#include <linux/mmzone.h>
+#include <asm/atomic.h>
+
+#ifdef CONFIG_VM_EVENT_COUNTERS
+/*
+ * Light weight per cpu counter implementation.
+ *
+ * Counters should only be incremented and no critical kernel component
+ * should rely on the counter values.
+ *
+ * Counters are handled completely inline. On many platforms the code
+ * generated will simply be the increment of a global address.
+ */
+
+#define FOR_ALL_ZONES(x) x##_DMA, x##_DMA32, x##_NORMAL, x##_HIGH
+
+enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
+               FOR_ALL_ZONES(PGALLOC),
+               PGFREE, PGACTIVATE, PGDEACTIVATE,
+               PGFAULT, PGMAJFAULT,
+               FOR_ALL_ZONES(PGREFILL),
+               FOR_ALL_ZONES(PGSTEAL),
+               FOR_ALL_ZONES(PGSCAN_KSWAPD),
+               FOR_ALL_ZONES(PGSCAN_DIRECT),
+               PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
+               PAGEOUTRUN, ALLOCSTALL, PGROTATED,
+               NR_VM_EVENT_ITEMS
+};
+
+struct vm_event_state {
+       unsigned long event[NR_VM_EVENT_ITEMS];
+};
+
+DECLARE_PER_CPU(struct vm_event_state, vm_event_states);
+
+static inline void __count_vm_event(enum vm_event_item item)
+{
+       __get_cpu_var(vm_event_states.event[item])++;
+}
+
+static inline void count_vm_event(enum vm_event_item item)
+{
+       get_cpu_var(vm_event_states.event[item])++;
+       put_cpu();
+}
+
+static inline void __count_vm_events(enum vm_event_item item, long delta)
+{
+       __get_cpu_var(vm_event_states.event[item]) += delta;
+}
+
+static inline void count_vm_events(enum vm_event_item item, long delta)
+{
+       get_cpu_var(vm_event_states.event[item])++;
+       put_cpu();
+}
+
+extern void all_vm_events(unsigned long *);
+extern void vm_events_fold_cpu(int cpu);
+
+#else
+
+/* Disable counters */
+#define get_cpu_vm_events(e)   0L
+#define count_vm_event(e)      do { } while (0)
+#define count_vm_events(e,d)   do { } while (0)
+#define __count_vm_event(e)    do { } while (0)
+#define __count_vm_events(e,d) do { } while (0)
+#define vm_events_fold_cpu(x)  do { } while (0)
+
+#endif /* CONFIG_VM_EVENT_COUNTERS */
+
+#define __count_zone_vm_events(item, zone, delta) \
+                       __count_vm_events(item##_DMA + zone_idx(zone), delta)
+
+/*
+ * Zone based page accounting with per cpu differentials.
+ */
+extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
+
+static inline void zone_page_state_add(long x, struct zone *zone,
+                                enum zone_stat_item item)
+{
+       atomic_long_add(x, &zone->vm_stat[item]);
+       atomic_long_add(x, &vm_stat[item]);
+}
+
+static inline unsigned long global_page_state(enum zone_stat_item item)
+{
+       long x = atomic_long_read(&vm_stat[item]);
+#ifdef CONFIG_SMP
+       if (x < 0)
+               x = 0;
+#endif
+       return x;
+}
+
+static inline unsigned long zone_page_state(struct zone *zone,
+                                       enum zone_stat_item item)
+{
+       long x = atomic_long_read(&zone->vm_stat[item]);
+#ifdef CONFIG_SMP
+       if (x < 0)
+               x = 0;
+#endif
+       return x;
+}
+
+#ifdef CONFIG_NUMA
+/*
+ * Determine the per node value of a stat item. This function
+ * is called frequently in a NUMA machine, so try to be as
+ * frugal as possible.
+ */
+static inline unsigned long node_page_state(int node,
+                                enum zone_stat_item item)
+{
+       struct zone *zones = NODE_DATA(node)->node_zones;
+
+       return
+#ifndef CONFIG_DMA_IS_NORMAL
+#if !defined(CONFIG_DMA_IS_DMA32) && BITS_PER_LONG >= 64
+               zone_page_state(&zones[ZONE_DMA32], item) +
+#endif
+               zone_page_state(&zones[ZONE_NORMAL], item) +
+#endif
+#ifdef CONFIG_HIGHMEM
+               zone_page_state(&zones[ZONE_HIGHMEM], item) +
+#endif
+               zone_page_state(&zones[ZONE_DMA], item);
+}
+
+extern void zone_statistics(struct zonelist *, struct zone *);
+
+#else
+
+#define node_page_state(node, item) global_page_state(item)
+#define zone_statistics(_zl,_z) do { } while (0)
+
+#endif /* CONFIG_NUMA */
+
+#define __add_zone_page_state(__z, __i, __d)   \
+               __mod_zone_page_state(__z, __i, __d)
+#define __sub_zone_page_state(__z, __i, __d)   \
+               __mod_zone_page_state(__z, __i,-(__d))
+
+#define add_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, __d)
+#define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d))
+
+static inline void zap_zone_vm_stats(struct zone *zone)
+{
+       memset(zone->vm_stat, 0, sizeof(zone->vm_stat));
+}
+
+extern void inc_zone_state(struct zone *, enum zone_stat_item);
+
+#ifdef CONFIG_SMP
+void __mod_zone_page_state(struct zone *, enum zone_stat_item item, int);
+void __inc_zone_page_state(struct page *, enum zone_stat_item);
+void __dec_zone_page_state(struct page *, enum zone_stat_item);
+
+void mod_zone_page_state(struct zone *, enum zone_stat_item, int);
+void inc_zone_page_state(struct page *, enum zone_stat_item);
+void dec_zone_page_state(struct page *, enum zone_stat_item);
+
+extern void inc_zone_state(struct zone *, enum zone_stat_item);
+
+void refresh_cpu_vm_stats(int);
+void refresh_vm_stats(void);
+
+#else /* CONFIG_SMP */
+
+/*
+ * We do not maintain differentials in a single processor configuration.
+ * The functions directly modify the zone and global counters.
+ */
+static inline void __mod_zone_page_state(struct zone *zone,
+                       enum zone_stat_item item, int delta)
+{
+       zone_page_state_add(delta, zone, item);
+}
+
+static inline void __inc_zone_page_state(struct page *page,
+                       enum zone_stat_item item)
+{
+       atomic_long_inc(&page_zone(page)->vm_stat[item]);
+       atomic_long_inc(&vm_stat[item]);
+}
+
+static inline void __dec_zone_page_state(struct page *page,
+                       enum zone_stat_item item)
+{
+       atomic_long_dec(&page_zone(page)->vm_stat[item]);
+       atomic_long_dec(&vm_stat[item]);
+}
+
+/*
+ * We only use atomic operations to update counters. So there is no need to
+ * disable interrupts.
+ */
+#define inc_zone_page_state __inc_zone_page_state
+#define dec_zone_page_state __dec_zone_page_state
+#define mod_zone_page_state __mod_zone_page_state
+
+static inline void refresh_cpu_vm_stats(int cpu) { }
+static inline void refresh_vm_stats(void) { }
+#endif
+
+#endif /* _LINUX_VMSTAT_H */
index ad9c171..3c43b95 100644 (file)
@@ -20,6 +20,7 @@ struct tuner_range {
 
 struct tuner_params {
        enum param_type type;
+
        /* Many Philips based tuners have a comment like this in their
         * datasheet:
         *
@@ -39,6 +40,60 @@ struct tuner_params {
         * static unless the control byte was sent first.
         */
        unsigned int cb_first_if_lower_freq:1;
+       /* Set to 1 if this tuner uses a tda9887 */
+       unsigned int has_tda9887:1;
+       /* Many Philips tuners use tda9887 PORT1 to select the FM radio
+          sensitivity. If this setting is 1, then set PORT1 to 1 to
+          get proper FM reception. */
+       unsigned int port1_fm_high_sensitivity:1;
+       /* Some Philips tuners use tda9887 PORT2 to select the FM radio
+          sensitivity. If this setting is 1, then set PORT2 to 1 to
+          get proper FM reception. */
+       unsigned int port2_fm_high_sensitivity:1;
+       /* Most tuners with a tda9887 use QSS mode. Some (cheaper) tuners
+          use Intercarrier mode. If this setting is 1, then the tuner
+          needs to be set to intercarrier mode. */
+       unsigned int intercarrier_mode:1;
+       /* This setting sets the default value for PORT1.
+          0 means inactive, 1 means active. Note: the actual bit
+          value written to the tda9887 is inverted. So a 0 here
+          means a 1 in the B6 bit. */
+       unsigned int port1_active:1;
+       /* This setting sets the default value for PORT2.
+          0 means inactive, 1 means active. Note: the actual bit
+          value written to the tda9887 is inverted. So a 0 here
+          means a 1 in the B7 bit. */
+       unsigned int port2_active:1;
+       /* Sometimes PORT1 is inverted when the SECAM-L' standard is selected.
+          Set this bit to 1 if this is needed. */
+       unsigned int port1_invert_for_secam_lc:1;
+       /* Sometimes PORT2 is inverted when the SECAM-L' standard is selected.
+          Set this bit to 1 if this is needed. */
+       unsigned int port2_invert_for_secam_lc:1;
+       /* Some cards require PORT1 to be 1 for mono Radio FM and 0 for stereo. */
+       unsigned int port1_set_for_fm_mono:1;
+       /* Default tda9887 TOP value in dB for the low band. Default is 0.
+          Range: -16:+15 */
+       signed int default_top_low:5;
+       /* Default tda9887 TOP value in dB for the mid band. Default is 0.
+          Range: -16:+15 */
+       signed int default_top_mid:5;
+       /* Default tda9887 TOP value in dB for the high band. Default is 0.
+          Range: -16:+15 */
+       signed int default_top_high:5;
+       /* Default tda9887 TOP value in dB for SECAM-L/L' for the low band.
+          Default is 0. Several tuners require a different TOP value for
+          the SECAM-L/L' standards. Range: -16:+15 */
+       signed int default_top_secam_low:5;
+       /* Default tda9887 TOP value in dB for SECAM-L/L' for the mid band.
+          Default is 0. Several tuners require a different TOP value for
+          the SECAM-L/L' standards. Range: -16:+15 */
+       signed int default_top_secam_mid:5;
+       /* Default tda9887 TOP value in dB for SECAM-L/L' for the high band.
+          Default is 0. Several tuners require a different TOP value for
+          the SECAM-L/L' standards. Range: -16:+15 */
+       signed int default_top_secam_high:5;
+
 
        unsigned int count;
        struct tuner_range *ranges;
index f70f2fd..a5b073a 100644 (file)
@@ -54,8 +54,8 @@ config LOCK_KERNEL
 
 config INIT_ENV_ARG_LIMIT
        int
-       default 32 if !USERMODE
-       default 128 if USERMODE
+       default 32 if !UML
+       default 128 if UML
        help
          Maximum of each of the number of arguments and environment
          variables passed to init from the kernel command line.
@@ -379,6 +379,15 @@ config SLAB
          SLOB is more space efficient but does not scale well and is
          more susceptible to fragmentation.
 
+config VM_EVENT_COUNTERS
+       default y
+       bool "Enable VM event counters for /proc/vmstat" if EMBEDDED
+       help
+         VM event counters are only needed to for event counts to be
+         shown. They have no function for the kernel itself. This
+         option allows the disabling of the VM event counters.
+         /proc/vmstat will only show page counts.
+
 endmenu                # General setup
 
 config TINY_SHMEM
index edff815..b2f3b56 100644 (file)
@@ -445,10 +445,17 @@ static void __init boot_cpu_init(void)
        cpu_set(cpu, cpu_possible_map);
 }
 
+void __init __attribute__((weak)) smp_setup_processor_id(void)
+{
+}
+
 asmlinkage void __init start_kernel(void)
 {
        char * command_line;
        extern struct kernel_param __start___param[], __stop___param[];
+
+       smp_setup_processor_id();
+
 /*
  * Interrupts are still disabled. Do necessary setups, then
  * enable them
index 2629c17..d5e3707 100644 (file)
@@ -4386,7 +4386,16 @@ asmlinkage long sys_sched_yield(void)
        return 0;
 }
 
-static inline void __cond_resched(void)
+static inline int __resched_legal(void)
+{
+       if (unlikely(preempt_count()))
+               return 0;
+       if (unlikely(system_state != SYSTEM_RUNNING))
+               return 0;
+       return 1;
+}
+
+static void __cond_resched(void)
 {
 #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
        __might_sleep(__FILE__, __LINE__);
@@ -4396,10 +4405,6 @@ static inline void __cond_resched(void)
         * PREEMPT_ACTIVE, which could trigger a second
         * cond_resched() call.
         */
-       if (unlikely(preempt_count()))
-               return;
-       if (unlikely(system_state != SYSTEM_RUNNING))
-               return;
        do {
                add_preempt_count(PREEMPT_ACTIVE);
                schedule();
@@ -4409,13 +4414,12 @@ static inline void __cond_resched(void)
 
 int __sched cond_resched(void)
 {
-       if (need_resched()) {
+       if (need_resched() && __resched_legal()) {
                __cond_resched();
                return 1;
        }
        return 0;
 }
-
 EXPORT_SYMBOL(cond_resched);
 
 /*
@@ -4436,7 +4440,7 @@ int cond_resched_lock(spinlock_t *lock)
                ret = 1;
                spin_lock(lock);
        }
-       if (need_resched()) {
+       if (need_resched() && __resched_legal()) {
                _raw_spin_unlock(lock);
                preempt_enable_no_resched();
                __cond_resched();
@@ -4445,14 +4449,13 @@ int cond_resched_lock(spinlock_t *lock)
        }
        return ret;
 }
-
 EXPORT_SYMBOL(cond_resched_lock);
 
 int __sched cond_resched_softirq(void)
 {
        BUG_ON(!in_softirq());
 
-       if (need_resched()) {
+       if (need_resched() && __resched_legal()) {
                __local_bh_enable();
                __cond_resched();
                local_bh_disable();
@@ -4460,10 +4463,8 @@ int __sched cond_resched_softirq(void)
        }
        return 0;
 }
-
 EXPORT_SYMBOL(cond_resched_softirq);
 
-
 /**
  * yield - yield the current processor to other threads.
  *
index ecb610d..7fe874d 100644 (file)
@@ -583,7 +583,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
            && !capable(CAP_KILL))
                return error;
 
-       error = security_task_kill(t, info, sig);
+       error = security_task_kill(t, info, sig, 0);
        if (!error)
                audit_signal_info(sig, t); /* Let audit system see the signal */
        return error;
@@ -1106,7 +1106,7 @@ kill_proc_info(int sig, struct siginfo *info, pid_t pid)
 
 /* like kill_proc_info(), but doesn't use uid/euid of "current" */
 int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid,
-                     uid_t uid, uid_t euid)
+                     uid_t uid, uid_t euid, u32 secid)
 {
        int ret = -EINVAL;
        struct task_struct *p;
@@ -1126,6 +1126,9 @@ int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid,
                ret = -EPERM;
                goto out_unlock;
        }
+       ret = security_task_kill(p, info, sig, secid);
+       if (ret)
+               goto out_unlock;
        if (sig && p->sighand) {
                unsigned long flags;
                spin_lock_irqsave(&p->sighand->siglock, flags);
index 6399c91..99a58f2 100644 (file)
@@ -932,15 +932,6 @@ static ctl_table vm_table[] = {
                .strategy       = &sysctl_intvec,
                .extra1         = &zero,
        },
-       {
-               .ctl_name       = VM_ZONE_RECLAIM_INTERVAL,
-               .procname       = "zone_reclaim_interval",
-               .data           = &zone_reclaim_interval,
-               .maxlen         = sizeof(zone_reclaim_interval),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_jiffies,
-               .strategy       = &sysctl_jiffies,
-       },
 #endif
 #ifdef CONFIG_X86_32
        {
index 7f20e7b..2b1530f 100644 (file)
@@ -50,6 +50,10 @@ static char *action_to_string(enum kobject_action action)
                return "offline";
        case KOBJ_ONLINE:
                return "online";
+       case KOBJ_DOCK:
+               return "dock";
+       case KOBJ_UNDOCK:
+               return "undock";
        default:
                return NULL;
        }
index 0b8f73f..9dd824c 100644 (file)
@@ -10,7 +10,7 @@ mmu-$(CONFIG_MMU)     := fremap.o highmem.o madvise.o memory.o mincore.o \
 obj-y                  := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
                           page_alloc.o page-writeback.o pdflush.o \
                           readahead.o swap.o truncate.o vmscan.o \
-                          prio_tree.o util.o mmzone.o $(mmu-y)
+                          prio_tree.o util.o mmzone.o vmstat.o $(mmu-y)
 
 obj-$(CONFIG_SWAP)     += page_io.o swap_state.o swapfile.o thrash.o
 obj-$(CONFIG_HUGETLBFS)        += hugetlb.o
index f02ca30..d087fc3 100644 (file)
@@ -119,7 +119,7 @@ void __remove_from_page_cache(struct page *page)
        radix_tree_delete(&mapping->page_tree, page->index);
        page->mapping = NULL;
        mapping->nrpages--;
-       pagecache_acct(-1);
+       __dec_zone_page_state(page, NR_FILE_PAGES);
 }
 
 void remove_from_page_cache(struct page *page)
@@ -448,7 +448,7 @@ int add_to_page_cache(struct page *page, struct address_space *mapping,
                        page->mapping = mapping;
                        page->index = offset;
                        mapping->nrpages++;
-                       pagecache_acct(1);
+                       __inc_zone_page_state(page, NR_FILE_PAGES);
                }
                write_unlock_irq(&mapping->tree_lock);
                radix_tree_preload_end();
@@ -1415,7 +1415,7 @@ retry_find:
                 */
                if (!did_readaround) {
                        majmin = VM_FAULT_MAJOR;
-                       inc_page_state(pgmajfault);
+                       count_vm_event(PGMAJFAULT);
                }
                did_readaround = 1;
                ra_pages = max_sane_readahead(file->f_ra.ra_pages);
@@ -1486,7 +1486,7 @@ no_cached_page:
 page_not_uptodate:
        if (!did_readaround) {
                majmin = VM_FAULT_MAJOR;
-               inc_page_state(pgmajfault);
+               count_vm_event(PGMAJFAULT);
        }
        lock_page(page);
 
index 9b274fd..9b2a540 100644 (file)
@@ -315,8 +315,8 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool, int err)
                if (bvec->bv_page == org_vec->bv_page)
                        continue;
 
-               mempool_free(bvec->bv_page, pool);      
-               dec_page_state(nr_bounce);
+               dec_zone_page_state(bvec->bv_page, NR_BOUNCE);
+               mempool_free(bvec->bv_page, pool);
        }
 
        bio_endio(bio_orig, bio_orig->bi_size, err);
@@ -397,7 +397,7 @@ static void __blk_queue_bounce(request_queue_t *q, struct bio **bio_orig,
                to->bv_page = mempool_alloc(pool, q->bounce_gfp);
                to->bv_len = from->bv_len;
                to->bv_offset = from->bv_offset;
-               inc_page_state(nr_bounce);
+               inc_zone_page_state(to->bv_page, NR_BOUNCE);
 
                if (rw == WRITE) {
                        char *vto, *vfrom;
index 247b5c3..7e2a4b1 100644 (file)
@@ -126,7 +126,7 @@ static void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd)
        pmd_clear(pmd);
        pte_lock_deinit(page);
        pte_free_tlb(tlb, page);
-       dec_page_state(nr_page_table_pages);
+       dec_zone_page_state(page, NR_PAGETABLE);
        tlb->mm->nr_ptes--;
 }
 
@@ -311,7 +311,7 @@ int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
                pte_free(new);
        } else {
                mm->nr_ptes++;
-               inc_page_state(nr_page_table_pages);
+               inc_zone_page_state(new, NR_PAGETABLE);
                pmd_populate(mm, pmd, new);
        }
        spin_unlock(&mm->page_table_lock);
@@ -1951,7 +1951,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
 
                /* Had to read the page from swap area: Major fault */
                ret = VM_FAULT_MAJOR;
-               inc_page_state(pgmajfault);
+               count_vm_event(PGMAJFAULT);
                grab_swap_token();
        }
 
@@ -2324,7 +2324,7 @@ int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
 
        __set_current_state(TASK_RUNNING);
 
-       inc_page_state(pgfault);
+       count_vm_event(PGFAULT);
 
        if (unlikely(is_vm_hugetlb_page(vma)))
                return hugetlb_fault(mm, vma, address, write_access);
index 6b9740b..e07e27e 100644 (file)
@@ -1209,10 +1209,8 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order,
 
        zl = NODE_DATA(nid)->node_zonelists + gfp_zone(gfp);
        page = __alloc_pages(gfp, order, zl);
-       if (page && page_zone(page) == zl->zones[0]) {
-               zone_pcp(zl->zones[0],get_cpu())->interleave_hit++;
-               put_cpu();
-       }
+       if (page && page_zone(page) == zl->zones[0])
+               inc_zone_page_state(page, NUMA_INTERLEAVE_HIT);
        return page;
 }
 
index 6446c61..c1868ec 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -96,7 +96,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
        if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
                unsigned long n;
 
-               free = get_page_cache_size();
+               free = global_page_state(NR_FILE_PAGES);
                free += nr_swap_pages;
 
                /*
index 029fada..5151c44 100644 (file)
@@ -1122,7 +1122,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
        if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
                unsigned long n;
 
-               free = get_page_cache_size();
+               free = global_page_state(NR_FILE_PAGES);
                free += nr_swap_pages;
 
                /*
index 4ec7026..e630188 100644 (file)
@@ -99,22 +99,6 @@ EXPORT_SYMBOL(laptop_mode);
 
 static void background_writeout(unsigned long _min_pages);
 
-struct writeback_state
-{
-       unsigned long nr_dirty;
-       unsigned long nr_unstable;
-       unsigned long nr_mapped;
-       unsigned long nr_writeback;
-};
-
-static void get_writeback_state(struct writeback_state *wbs)
-{
-       wbs->nr_dirty = read_page_state(nr_dirty);
-       wbs->nr_unstable = read_page_state(nr_unstable);
-       wbs->nr_mapped = read_page_state(nr_mapped);
-       wbs->nr_writeback = read_page_state(nr_writeback);
-}
-
 /*
  * Work out the current dirty-memory clamping and background writeout
  * thresholds.
@@ -133,8 +117,8 @@ static void get_writeback_state(struct writeback_state *wbs)
  * clamping level.
  */
 static void
-get_dirty_limits(struct writeback_state *wbs, long *pbackground, long *pdirty,
-               struct address_space *mapping)
+get_dirty_limits(long *pbackground, long *pdirty,
+                                       struct address_space *mapping)
 {
        int background_ratio;           /* Percentages */
        int dirty_ratio;
@@ -144,8 +128,6 @@ get_dirty_limits(struct writeback_state *wbs, long *pbackground, long *pdirty,
        unsigned long available_memory = total_pages;
        struct task_struct *tsk;
 
-       get_writeback_state(wbs);
-
 #ifdef CONFIG_HIGHMEM
        /*
         * If this mapping can only allocate from low memory,
@@ -156,7 +138,9 @@ get_dirty_limits(struct writeback_state *wbs, long *pbackground, long *pdirty,
 #endif
 
 
-       unmapped_ratio = 100 - (wbs->nr_mapped * 100) / total_pages;
+       unmapped_ratio = 100 - ((global_page_state(NR_FILE_MAPPED) +
+                               global_page_state(NR_ANON_PAGES)) * 100) /
+                                       total_pages;
 
        dirty_ratio = vm_dirty_ratio;
        if (dirty_ratio > unmapped_ratio / 2)
@@ -189,7 +173,6 @@ get_dirty_limits(struct writeback_state *wbs, long *pbackground, long *pdirty,
  */
 static void balance_dirty_pages(struct address_space *mapping)
 {
-       struct writeback_state wbs;
        long nr_reclaimable;
        long background_thresh;
        long dirty_thresh;
@@ -207,11 +190,12 @@ static void balance_dirty_pages(struct address_space *mapping)
                        .range_cyclic   = 1,
                };
 
-               get_dirty_limits(&wbs, &background_thresh,
-                                       &dirty_thresh, mapping);
-               nr_reclaimable = wbs.nr_dirty + wbs.nr_unstable;
-               if (nr_reclaimable + wbs.nr_writeback <= dirty_thresh)
-                       break;
+               get_dirty_limits(&background_thresh, &dirty_thresh, mapping);
+               nr_reclaimable = global_page_state(NR_FILE_DIRTY) +
+                                       global_page_state(NR_UNSTABLE_NFS);
+               if (nr_reclaimable + global_page_state(NR_WRITEBACK) <=
+                       dirty_thresh)
+                               break;
 
                if (!dirty_exceeded)
                        dirty_exceeded = 1;
@@ -224,11 +208,14 @@ static void balance_dirty_pages(struct address_space *mapping)
                 */
                if (nr_reclaimable) {
                        writeback_inodes(&wbc);
-                       get_dirty_limits(&wbs, &background_thresh,
-                                       &dirty_thresh, mapping);
-                       nr_reclaimable = wbs.nr_dirty + wbs.nr_unstable;
-                       if (nr_reclaimable + wbs.nr_writeback <= dirty_thresh)
-                               break;
+                       get_dirty_limits(&background_thresh,
+                                               &dirty_thresh, mapping);
+                       nr_reclaimable = global_page_state(NR_FILE_DIRTY) +
+                                       global_page_state(NR_UNSTABLE_NFS);
+                       if (nr_reclaimable +
+                               global_page_state(NR_WRITEBACK)
+                                       <= dirty_thresh)
+                                               break;
                        pages_written += write_chunk - wbc.nr_to_write;
                        if (pages_written >= write_chunk)
                                break;          /* We've done our duty */
@@ -236,8 +223,9 @@ static void balance_dirty_pages(struct address_space *mapping)
                blk_congestion_wait(WRITE, HZ/10);
        }
 
-       if (nr_reclaimable + wbs.nr_writeback <= dirty_thresh && dirty_exceeded)
-               dirty_exceeded = 0;
+       if (nr_reclaimable + global_page_state(NR_WRITEBACK)
+               <= dirty_thresh && dirty_exceeded)
+                       dirty_exceeded = 0;
 
        if (writeback_in_progress(bdi))
                return;         /* pdflush is already working this queue */
@@ -299,12 +287,11 @@ EXPORT_SYMBOL(balance_dirty_pages_ratelimited_nr);
 
 void throttle_vm_writeout(void)
 {
-       struct writeback_state wbs;
        long background_thresh;
        long dirty_thresh;
 
         for ( ; ; ) {
-               get_dirty_limits(&wbs, &background_thresh, &dirty_thresh, NULL);
+               get_dirty_limits(&background_thresh, &dirty_thresh, NULL);
 
                 /*
                  * Boost the allowable dirty threshold a bit for page
@@ -312,8 +299,9 @@ void throttle_vm_writeout(void)
                  */
                 dirty_thresh += dirty_thresh / 10;      /* wheeee... */
 
-                if (wbs.nr_unstable + wbs.nr_writeback <= dirty_thresh)
-                        break;
+                if (global_page_state(NR_UNSTABLE_NFS) +
+                       global_page_state(NR_WRITEBACK) <= dirty_thresh)
+                               break;
                 blk_congestion_wait(WRITE, HZ/10);
         }
 }
@@ -336,12 +324,12 @@ static void background_writeout(unsigned long _min_pages)
        };
 
        for ( ; ; ) {
-               struct writeback_state wbs;
                long background_thresh;
                long dirty_thresh;
 
-               get_dirty_limits(&wbs, &background_thresh, &dirty_thresh, NULL);
-               if (wbs.nr_dirty + wbs.nr_unstable < background_thresh
+               get_dirty_limits(&background_thresh, &dirty_thresh, NULL);
+               if (global_page_state(NR_FILE_DIRTY) +
+                       global_page_state(NR_UNSTABLE_NFS) < background_thresh
                                && min_pages <= 0)
                        break;
                wbc.encountered_congestion = 0;
@@ -365,12 +353,9 @@ static void background_writeout(unsigned long _min_pages)
  */
 int wakeup_pdflush(long nr_pages)
 {
-       if (nr_pages == 0) {
-               struct writeback_state wbs;
-
-               get_writeback_state(&wbs);
-               nr_pages = wbs.nr_dirty + wbs.nr_unstable;
-       }
+       if (nr_pages == 0)
+               nr_pages = global_page_state(NR_FILE_DIRTY) +
+                               global_page_state(NR_UNSTABLE_NFS);
        return pdflush_operation(background_writeout, nr_pages);
 }
 
@@ -401,7 +386,6 @@ static void wb_kupdate(unsigned long arg)
        unsigned long start_jif;
        unsigned long next_jif;
        long nr_to_write;
-       struct writeback_state wbs;
        struct writeback_control wbc = {
                .bdi            = NULL,
                .sync_mode      = WB_SYNC_NONE,
@@ -414,11 +398,11 @@ static void wb_kupdate(unsigned long arg)
 
        sync_supers();
 
-       get_writeback_state(&wbs);
        oldest_jif = jiffies - dirty_expire_interval;
        start_jif = jiffies;
        next_jif = start_jif + dirty_writeback_interval;
-       nr_to_write = wbs.nr_dirty + wbs.nr_unstable +
+       nr_to_write = global_page_state(NR_FILE_DIRTY) +
+                       global_page_state(NR_UNSTABLE_NFS) +
                        (inodes_stat.nr_inodes - inodes_stat.nr_unused);
        while (nr_to_write > 0) {
                wbc.encountered_congestion = 0;
@@ -640,7 +624,8 @@ int __set_page_dirty_nobuffers(struct page *page)
                        if (mapping2) { /* Race with truncate? */
                                BUG_ON(mapping2 != mapping);
                                if (mapping_cap_account_dirty(mapping))
-                                       inc_page_state(nr_dirty);
+                                       __inc_zone_page_state(page,
+                                                               NR_FILE_DIRTY);
                                radix_tree_tag_set(&mapping->page_tree,
                                        page_index(page), PAGECACHE_TAG_DIRTY);
                        }
@@ -727,9 +712,9 @@ int test_clear_page_dirty(struct page *page)
                        radix_tree_tag_clear(&mapping->page_tree,
                                                page_index(page),
                                                PAGECACHE_TAG_DIRTY);
-                       write_unlock_irqrestore(&mapping->tree_lock, flags);
                        if (mapping_cap_account_dirty(mapping))
-                               dec_page_state(nr_dirty);
+                               __dec_zone_page_state(page, NR_FILE_DIRTY);
+                       write_unlock_irqrestore(&mapping->tree_lock, flags);
                        return 1;
                }
                write_unlock_irqrestore(&mapping->tree_lock, flags);
@@ -760,7 +745,7 @@ int clear_page_dirty_for_io(struct page *page)
        if (mapping) {
                if (TestClearPageDirty(page)) {
                        if (mapping_cap_account_dirty(mapping))
-                               dec_page_state(nr_dirty);
+                               dec_zone_page_state(page, NR_FILE_DIRTY);
                        return 1;
                }
                return 0;
index 60f2fed..3e792a5 100644 (file)
@@ -455,7 +455,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
 
        kernel_map_pages(page, 1 << order, 0);
        local_irq_save(flags);
-       __mod_page_state(pgfree, 1 << order);
+       __count_vm_events(PGFREE, 1 << order);
        free_one_page(page_zone(page), page, order);
        local_irq_restore(flags);
 }
@@ -708,27 +708,6 @@ void drain_local_pages(void)
 }
 #endif /* CONFIG_PM */
 
-static void zone_statistics(struct zonelist *zonelist, struct zone *z, int cpu)
-{
-#ifdef CONFIG_NUMA
-       pg_data_t *pg = z->zone_pgdat;
-       pg_data_t *orig = zonelist->zones[0]->zone_pgdat;
-       struct per_cpu_pageset *p;
-
-       p = zone_pcp(z, cpu);
-       if (pg == orig) {
-               p->numa_hit++;
-       } else {
-               p->numa_miss++;
-               zone_pcp(zonelist->zones[0], cpu)->numa_foreign++;
-       }
-       if (pg == NODE_DATA(numa_node_id()))
-               p->local_node++;
-       else
-               p->other_node++;
-#endif
-}
-
 /*
  * Free a 0-order page
  */
@@ -749,7 +728,7 @@ static void fastcall free_hot_cold_page(struct page *page, int cold)
 
        pcp = &zone_pcp(zone, get_cpu())->pcp[cold];
        local_irq_save(flags);
-       __inc_page_state(pgfree);
+       __count_vm_event(PGFREE);
        list_add(&page->lru, &pcp->list);
        pcp->count++;
        if (pcp->count >= pcp->high) {
@@ -825,8 +804,8 @@ again:
                        goto failed;
        }
 
-       __mod_page_state_zone(zone, pgalloc, 1 << order);
-       zone_statistics(zonelist, zone, cpu);
+       __count_zone_vm_events(PGALLOC, zone, 1 << order);
+       zone_statistics(zonelist, zone);
        local_irq_restore(flags);
        put_cpu();
 
@@ -1230,141 +1209,6 @@ static void show_node(struct zone *zone)
 #define show_node(zone)        do { } while (0)
 #endif
 
-/*
- * Accumulate the page_state information across all CPUs.
- * The result is unavoidably approximate - it can change
- * during and after execution of this function.
- */
-static DEFINE_PER_CPU(struct page_state, page_states) = {0};
-
-atomic_t nr_pagecache = ATOMIC_INIT(0);
-EXPORT_SYMBOL(nr_pagecache);
-#ifdef CONFIG_SMP
-DEFINE_PER_CPU(long, nr_pagecache_local) = 0;
-#endif
-
-static void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask)
-{
-       unsigned cpu;
-
-       memset(ret, 0, nr * sizeof(unsigned long));
-       cpus_and(*cpumask, *cpumask, cpu_online_map);
-
-       for_each_cpu_mask(cpu, *cpumask) {
-               unsigned long *in;
-               unsigned long *out;
-               unsigned off;
-               unsigned next_cpu;
-
-               in = (unsigned long *)&per_cpu(page_states, cpu);
-
-               next_cpu = next_cpu(cpu, *cpumask);
-               if (likely(next_cpu < NR_CPUS))
-                       prefetch(&per_cpu(page_states, next_cpu));
-
-               out = (unsigned long *)ret;
-               for (off = 0; off < nr; off++)
-                       *out++ += *in++;
-       }
-}
-
-void get_page_state_node(struct page_state *ret, int node)
-{
-       int nr;
-       cpumask_t mask = node_to_cpumask(node);
-
-       nr = offsetof(struct page_state, GET_PAGE_STATE_LAST);
-       nr /= sizeof(unsigned long);
-
-       __get_page_state(ret, nr+1, &mask);
-}
-
-void get_page_state(struct page_state *ret)
-{
-       int nr;
-       cpumask_t mask = CPU_MASK_ALL;
-
-       nr = offsetof(struct page_state, GET_PAGE_STATE_LAST);
-       nr /= sizeof(unsigned long);
-
-       __get_page_state(ret, nr + 1, &mask);
-}
-
-void get_full_page_state(struct page_state *ret)
-{
-       cpumask_t mask = CPU_MASK_ALL;
-
-       __get_page_state(ret, sizeof(*ret) / sizeof(unsigned long), &mask);
-}
-
-unsigned long read_page_state_offset(unsigned long offset)
-{
-       unsigned long ret = 0;
-       int cpu;
-
-       for_each_online_cpu(cpu) {
-               unsigned long in;
-
-               in = (unsigned long)&per_cpu(page_states, cpu) + offset;
-               ret += *((unsigned long *)in);
-       }
-       return ret;
-}
-
-void __mod_page_state_offset(unsigned long offset, unsigned long delta)
-{
-       void *ptr;
-
-       ptr = &__get_cpu_var(page_states);
-       *(unsigned long *)(ptr + offset) += delta;
-}
-EXPORT_SYMBOL(__mod_page_state_offset);
-
-void mod_page_state_offset(unsigned long offset, unsigned long delta)
-{
-       unsigned long flags;
-       void *ptr;
-
-       local_irq_save(flags);
-       ptr = &__get_cpu_var(page_states);
-       *(unsigned long *)(ptr + offset) += delta;
-       local_irq_restore(flags);
-}
-EXPORT_SYMBOL(mod_page_state_offset);
-
-void __get_zone_counts(unsigned long *active, unsigned long *inactive,
-                       unsigned long *free, struct pglist_data *pgdat)
-{
-       struct zone *zones = pgdat->node_zones;
-       int i;
-
-       *active = 0;
-       *inactive = 0;
-       *free = 0;
-       for (i = 0; i < MAX_NR_ZONES; i++) {
-               *active += zones[i].nr_active;
-               *inactive += zones[i].nr_inactive;
-               *free += zones[i].free_pages;
-       }
-}
-
-void get_zone_counts(unsigned long *active,
-               unsigned long *inactive, unsigned long *free)
-{
-       struct pglist_data *pgdat;
-
-       *active = 0;
-       *inactive = 0;
-       *free = 0;
-       for_each_online_pgdat(pgdat) {
-               unsigned long l, m, n;
-               __get_zone_counts(&l, &m, &n, pgdat);
-               *active += l;
-               *inactive += m;
-               *free += n;
-       }
-}
-
 void si_meminfo(struct sysinfo *val)
 {
        val->totalram = totalram_pages;
@@ -1405,7 +1249,6 @@ void si_meminfo_node(struct sysinfo *val, int nid)
  */
 void show_free_areas(void)
 {
-       struct page_state ps;
        int cpu, temperature;
        unsigned long active;
        unsigned long inactive;
@@ -1437,7 +1280,6 @@ void show_free_areas(void)
                }
        }
 
-       get_page_state(&ps);
        get_zone_counts(&active, &inactive, &free);
 
        printk("Free pages: %11ukB (%ukB HighMem)\n",
@@ -1448,13 +1290,13 @@ void show_free_areas(void)
                "unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n",
                active,
                inactive,
-               ps.nr_dirty,
-               ps.nr_writeback,
-               ps.nr_unstable,
+               global_page_state(NR_FILE_DIRTY),
+               global_page_state(NR_WRITEBACK),
+               global_page_state(NR_UNSTABLE_NFS),
                nr_free_pages(),
-               ps.nr_slab,
-               ps.nr_mapped,
-               ps.nr_page_table_pages);
+               global_page_state(NR_SLAB),
+               global_page_state(NR_FILE_MAPPED),
+               global_page_state(NR_PAGETABLE));
 
        for_each_zone(zone) {
                int i;
@@ -2179,6 +2021,7 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
                zone->nr_scan_inactive = 0;
                zone->nr_active = 0;
                zone->nr_inactive = 0;
+               zap_zone_vm_stats(zone);
                atomic_set(&zone->reclaim_in_progress, 0);
                if (!size)
                        continue;
@@ -2252,307 +2095,18 @@ void __init free_area_init(unsigned long *zones_size)
                        __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
 }
 
-#ifdef CONFIG_PROC_FS
-
-#include <linux/seq_file.h>
-
-static void *frag_start(struct seq_file *m, loff_t *pos)
-{
-       pg_data_t *pgdat;
-       loff_t node = *pos;
-       for (pgdat = first_online_pgdat();
-            pgdat && node;
-            pgdat = next_online_pgdat(pgdat))
-               --node;
-
-       return pgdat;
-}
-
-static void *frag_next(struct seq_file *m, void *arg, loff_t *pos)
-{
-       pg_data_t *pgdat = (pg_data_t *)arg;
-
-       (*pos)++;
-       return next_online_pgdat(pgdat);
-}
-
-static void frag_stop(struct seq_file *m, void *arg)
-{
-}
-
-/* 
- * This walks the free areas for each zone.
- */
-static int frag_show(struct seq_file *m, void *arg)
-{
-       pg_data_t *pgdat = (pg_data_t *)arg;
-       struct zone *zone;
-       struct zone *node_zones = pgdat->node_zones;
-       unsigned long flags;
-       int order;
-
-       for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
-               if (!populated_zone(zone))
-                       continue;
-
-               spin_lock_irqsave(&zone->lock, flags);
-               seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name);
-               for (order = 0; order < MAX_ORDER; ++order)
-                       seq_printf(m, "%6lu ", zone->free_area[order].nr_free);
-               spin_unlock_irqrestore(&zone->lock, flags);
-               seq_putc(m, '\n');
-       }
-       return 0;
-}
-
-struct seq_operations fragmentation_op = {
-       .start  = frag_start,
-       .next   = frag_next,
-       .stop   = frag_stop,
-       .show   = frag_show,
-};
-
-/*
- * Output information about zones in @pgdat.
- */
-static int zoneinfo_show(struct seq_file *m, void *arg)
-{
-       pg_data_t *pgdat = arg;
-       struct zone *zone;
-       struct zone *node_zones = pgdat->node_zones;
-       unsigned long flags;
-
-       for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) {
-               int i;
-
-               if (!populated_zone(zone))
-                       continue;
-
-               spin_lock_irqsave(&zone->lock, flags);
-               seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name);
-               seq_printf(m,
-                          "\n  pages free     %lu"
-                          "\n        min      %lu"
-                          "\n        low      %lu"
-                          "\n        high     %lu"
-                          "\n        active   %lu"
-                          "\n        inactive %lu"
-                          "\n        scanned  %lu (a: %lu i: %lu)"
-                          "\n        spanned  %lu"
-                          "\n        present  %lu",
-                          zone->free_pages,
-                          zone->pages_min,
-                          zone->pages_low,
-                          zone->pages_high,
-                          zone->nr_active,
-                          zone->nr_inactive,
-                          zone->pages_scanned,
-                          zone->nr_scan_active, zone->nr_scan_inactive,
-                          zone->spanned_pages,
-                          zone->present_pages);
-               seq_printf(m,
-                          "\n        protection: (%lu",
-                          zone->lowmem_reserve[0]);
-               for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
-                       seq_printf(m, ", %lu", zone->lowmem_reserve[i]);
-               seq_printf(m,
-                          ")"
-                          "\n  pagesets");
-               for_each_online_cpu(i) {
-                       struct per_cpu_pageset *pageset;
-                       int j;
-
-                       pageset = zone_pcp(zone, i);
-                       for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
-                               if (pageset->pcp[j].count)
-                                       break;
-                       }
-                       if (j == ARRAY_SIZE(pageset->pcp))
-                               continue;
-                       for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
-                               seq_printf(m,
-                                          "\n    cpu: %i pcp: %i"
-                                          "\n              count: %i"
-                                          "\n              high:  %i"
-                                          "\n              batch: %i",
-                                          i, j,
-                                          pageset->pcp[j].count,
-                                          pageset->pcp[j].high,
-                                          pageset->pcp[j].batch);
-                       }
-#ifdef CONFIG_NUMA
-                       seq_printf(m,
-                                  "\n            numa_hit:       %lu"
-                                  "\n            numa_miss:      %lu"
-                                  "\n            numa_foreign:   %lu"
-                                  "\n            interleave_hit: %lu"
-                                  "\n            local_node:     %lu"
-                                  "\n            other_node:     %lu",
-                                  pageset->numa_hit,
-                                  pageset->numa_miss,
-                                  pageset->numa_foreign,
-                                  pageset->interleave_hit,
-                                  pageset->local_node,
-                                  pageset->other_node);
-#endif
-               }
-               seq_printf(m,
-                          "\n  all_unreclaimable: %u"
-                          "\n  prev_priority:     %i"
-                          "\n  temp_priority:     %i"
-                          "\n  start_pfn:         %lu",
-                          zone->all_unreclaimable,
-                          zone->prev_priority,
-                          zone->temp_priority,
-                          zone->zone_start_pfn);
-               spin_unlock_irqrestore(&zone->lock, flags);
-               seq_putc(m, '\n');
-       }
-       return 0;
-}
-
-struct seq_operations zoneinfo_op = {
-       .start  = frag_start, /* iterate over all zones. The same as in
-                              * fragmentation. */
-       .next   = frag_next,
-       .stop   = frag_stop,
-       .show   = zoneinfo_show,
-};
-
-static char *vmstat_text[] = {
-       "nr_dirty",
-       "nr_writeback",
-       "nr_unstable",
-       "nr_page_table_pages",
-       "nr_mapped",
-       "nr_slab",
-
-       "pgpgin",
-       "pgpgout",
-       "pswpin",
-       "pswpout",
-
-       "pgalloc_high",
-       "pgalloc_normal",
-       "pgalloc_dma32",
-       "pgalloc_dma",
-
-       "pgfree",
-       "pgactivate",
-       "pgdeactivate",
-
-       "pgfault",
-       "pgmajfault",
-
-       "pgrefill_high",
-       "pgrefill_normal",
-       "pgrefill_dma32",
-       "pgrefill_dma",
-
-       "pgsteal_high",
-       "pgsteal_normal",
-       "pgsteal_dma32",
-       "pgsteal_dma",
-
-       "pgscan_kswapd_high",
-       "pgscan_kswapd_normal",
-       "pgscan_kswapd_dma32",
-       "pgscan_kswapd_dma",
-
-       "pgscan_direct_high",
-       "pgscan_direct_normal",
-       "pgscan_direct_dma32",
-       "pgscan_direct_dma",
-
-       "pginodesteal",
-       "slabs_scanned",
-       "kswapd_steal",
-       "kswapd_inodesteal",
-       "pageoutrun",
-       "allocstall",
-
-       "pgrotated",
-       "nr_bounce",
-};
-
-static void *vmstat_start(struct seq_file *m, loff_t *pos)
-{
-       struct page_state *ps;
-
-       if (*pos >= ARRAY_SIZE(vmstat_text))
-               return NULL;
-
-       ps = kmalloc(sizeof(*ps), GFP_KERNEL);
-       m->private = ps;
-       if (!ps)
-               return ERR_PTR(-ENOMEM);
-       get_full_page_state(ps);
-       ps->pgpgin /= 2;                /* sectors -> kbytes */
-       ps->pgpgout /= 2;
-       return (unsigned long *)ps + *pos;
-}
-
-static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos)
-{
-       (*pos)++;
-       if (*pos >= ARRAY_SIZE(vmstat_text))
-               return NULL;
-       return (unsigned long *)m->private + *pos;
-}
-
-static int vmstat_show(struct seq_file *m, void *arg)
-{
-       unsigned long *l = arg;
-       unsigned long off = l - (unsigned long *)m->private;
-
-       seq_printf(m, "%s %lu\n", vmstat_text[off], *l);
-       return 0;
-}
-
-static void vmstat_stop(struct seq_file *m, void *arg)
-{
-       kfree(m->private);
-       m->private = NULL;
-}
-
-struct seq_operations vmstat_op = {
-       .start  = vmstat_start,
-       .next   = vmstat_next,
-       .stop   = vmstat_stop,
-       .show   = vmstat_show,
-};
-
-#endif /* CONFIG_PROC_FS */
-
 #ifdef CONFIG_HOTPLUG_CPU
 static int page_alloc_cpu_notify(struct notifier_block *self,
                                 unsigned long action, void *hcpu)
 {
        int cpu = (unsigned long)hcpu;
-       long *count;
-       unsigned long *src, *dest;
 
        if (action == CPU_DEAD) {
-               int i;
-
-               /* Drain local pagecache count. */
-               count = &per_cpu(nr_pagecache_local, cpu);
-               atomic_add(*count, &nr_pagecache);
-               *count = 0;
                local_irq_disable();
                __drain_pages(cpu);
-
-               /* Add dead cpu's page_states to our own. */
-               dest = (unsigned long *)&__get_cpu_var(page_states);
-               src = (unsigned long *)&per_cpu(page_states, cpu);
-
-               for (i = 0; i < sizeof(struct page_state)/sizeof(unsigned long);
-                               i++) {
-                       dest[i] += src[i];
-                       src[i] = 0;
-               }
-
+               vm_events_fold_cpu(cpu);
                local_irq_enable();
+               refresh_cpu_vm_stats(cpu);
        }
        return NOTIFY_OK;
 }
index bb2b0d5..8802994 100644 (file)
@@ -101,7 +101,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
        }
        if (wbc->sync_mode == WB_SYNC_ALL)
                rw |= (1 << BIO_RW_SYNC);
-       inc_page_state(pswpout);
+       count_vm_event(PSWPOUT);
        set_page_writeback(page);
        unlock_page(page);
        submit_bio(rw, bio);
@@ -123,7 +123,7 @@ int swap_readpage(struct file *file, struct page *page)
                ret = -ENOMEM;
                goto out;
        }
-       inc_page_state(pswpin);
+       count_vm_event(PSWPIN);
        submit_bio(READ, bio);
 out:
        return ret;
index e76909e..40158b5 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -455,7 +455,7 @@ static void __page_set_anon_rmap(struct page *page,
         * nr_mapped state can be updated without turning off
         * interrupts because it is not modified via interrupt.
         */
-       __inc_page_state(nr_mapped);
+       __inc_zone_page_state(page, NR_ANON_PAGES);
 }
 
 /**
@@ -499,7 +499,7 @@ void page_add_new_anon_rmap(struct page *page,
 void page_add_file_rmap(struct page *page)
 {
        if (atomic_inc_and_test(&page->_mapcount))
-               __inc_page_state(nr_mapped);
+               __inc_zone_page_state(page, NR_FILE_MAPPED);
 }
 
 /**
@@ -531,7 +531,8 @@ void page_remove_rmap(struct page *page)
                 */
                if (page_test_and_clear_dirty(page))
                        set_page_dirty(page);
-               __dec_page_state(nr_mapped);
+               __dec_zone_page_state(page,
+                               PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
        }
 }
 
index 83c9fea..db21c51 100644 (file)
@@ -1044,12 +1044,12 @@ repeat:
                swappage = lookup_swap_cache(swap);
                if (!swappage) {
                        shmem_swp_unmap(entry);
-                       spin_unlock(&info->lock);
                        /* here we actually do the io */
                        if (type && *type == VM_FAULT_MINOR) {
-                               inc_page_state(pgmajfault);
+                               __count_vm_event(PGMAJFAULT);
                                *type = VM_FAULT_MAJOR;
                        }
+                       spin_unlock(&info->lock);
                        swappage = shmem_swapin(info, swap, idx);
                        if (!swappage) {
                                spin_lock(&info->lock);
index 233e39d..3936af3 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -309,6 +309,13 @@ struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
 #define        SIZE_AC 1
 #define        SIZE_L3 (1 + MAX_NUMNODES)
 
+static int drain_freelist(struct kmem_cache *cache,
+                       struct kmem_list3 *l3, int tofree);
+static void free_block(struct kmem_cache *cachep, void **objpp, int len,
+                       int node);
+static void enable_cpucache(struct kmem_cache *cachep);
+static void cache_reap(void *unused);
+
 /*
  * This function must be completely optimized away if a constant is passed to
  * it.  Mostly the same as what is in linux/slab.h except it returns an index.
@@ -456,7 +463,7 @@ struct kmem_cache {
 #define        STATS_DEC_ACTIVE(x)     ((x)->num_active--)
 #define        STATS_INC_ALLOCED(x)    ((x)->num_allocations++)
 #define        STATS_INC_GROWN(x)      ((x)->grown++)
-#define        STATS_INC_REAPED(x)     ((x)->reaped++)
+#define        STATS_ADD_REAPED(x,y)   ((x)->reaped += (y))
 #define        STATS_SET_HIGH(x)                                               \
        do {                                                            \
                if ((x)->num_active > (x)->high_mark)                   \
@@ -480,7 +487,7 @@ struct kmem_cache {
 #define        STATS_DEC_ACTIVE(x)     do { } while (0)
 #define        STATS_INC_ALLOCED(x)    do { } while (0)
 #define        STATS_INC_GROWN(x)      do { } while (0)
-#define        STATS_INC_REAPED(x)     do { } while (0)
+#define        STATS_ADD_REAPED(x,y)   do { } while (0)
 #define        STATS_SET_HIGH(x)       do { } while (0)
 #define        STATS_INC_ERR(x)        do { } while (0)
 #define        STATS_INC_NODEALLOCS(x) do { } while (0)
@@ -700,12 +707,6 @@ int slab_is_available(void)
 
 static DEFINE_PER_CPU(struct work_struct, reap_work);
 
-static void free_block(struct kmem_cache *cachep, void **objpp, int len,
-                       int node);
-static void enable_cpucache(struct kmem_cache *cachep);
-static void cache_reap(void *unused);
-static int __node_shrink(struct kmem_cache *cachep, int node);
-
 static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
 {
        return cachep->array[smp_processor_id()];
@@ -1241,10 +1242,7 @@ free_array_cache:
                        l3 = cachep->nodelists[node];
                        if (!l3)
                                continue;
-                       spin_lock_irq(&l3->list_lock);
-                       /* free slabs belonging to this node */
-                       __node_shrink(cachep, node);
-                       spin_unlock_irq(&l3->list_lock);
+                       drain_freelist(cachep, l3, l3->free_objects);
                }
                mutex_unlock(&cache_chain_mutex);
                break;
@@ -1507,7 +1505,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
        nr_pages = (1 << cachep->gfporder);
        if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
                atomic_add(nr_pages, &slab_reclaim_pages);
-       add_page_state(nr_slab, nr_pages);
+       add_zone_page_state(page_zone(page), NR_SLAB, nr_pages);
        for (i = 0; i < nr_pages; i++)
                __SetPageSlab(page + i);
        return page_address(page);
@@ -1522,12 +1520,12 @@ static void kmem_freepages(struct kmem_cache *cachep, void *addr)
        struct page *page = virt_to_page(addr);
        const unsigned long nr_freed = i;
 
+       sub_zone_page_state(page_zone(page), NR_SLAB, nr_freed);
        while (i--) {
                BUG_ON(!PageSlab(page));
                __ClearPageSlab(page);
                page++;
        }
-       sub_page_state(nr_slab, nr_freed);
        if (current->reclaim_state)
                current->reclaim_state->reclaimed_slab += nr_freed;
        free_pages((unsigned long)addr, cachep->gfporder);
@@ -2248,32 +2246,45 @@ static void drain_cpu_caches(struct kmem_cache *cachep)
        }
 }
 
-static int __node_shrink(struct kmem_cache *cachep, int node)
+/*
+ * Remove slabs from the list of free slabs.
+ * Specify the number of slabs to drain in tofree.
+ *
+ * Returns the actual number of slabs released.
+ */
+static int drain_freelist(struct kmem_cache *cache,
+                       struct kmem_list3 *l3, int tofree)
 {
+       struct list_head *p;
+       int nr_freed;
        struct slab *slabp;
-       struct kmem_list3 *l3 = cachep->nodelists[node];
-       int ret;
 
-       for (;;) {
-               struct list_head *p;
+       nr_freed = 0;
+       while (nr_freed < tofree && !list_empty(&l3->slabs_free)) {
 
+               spin_lock_irq(&l3->list_lock);
                p = l3->slabs_free.prev;
-               if (p == &l3->slabs_free)
-                       break;
+               if (p == &l3->slabs_free) {
+                       spin_unlock_irq(&l3->list_lock);
+                       goto out;
+               }
 
-               slabp = list_entry(l3->slabs_free.prev, struct slab, list);
+               slabp = list_entry(p, struct slab, list);
 #if DEBUG
                BUG_ON(slabp->inuse);
 #endif
                list_del(&slabp->list);
-
-               l3->free_objects -= cachep->num;
+               /*
+                * Safe to drop the lock. The slab is no longer linked
+                * to the cache.
+                */
+               l3->free_objects -= cache->num;
                spin_unlock_irq(&l3->list_lock);
-               slab_destroy(cachep, slabp);
-               spin_lock_irq(&l3->list_lock);
+               slab_destroy(cache, slabp);
+               nr_freed++;
        }
-       ret = !list_empty(&l3->slabs_full) || !list_empty(&l3->slabs_partial);
-       return ret;
+out:
+       return nr_freed;
 }
 
 static int __cache_shrink(struct kmem_cache *cachep)
@@ -2286,11 +2297,13 @@ static int __cache_shrink(struct kmem_cache *cachep)
        check_irq_on();
        for_each_online_node(i) {
                l3 = cachep->nodelists[i];
-               if (l3) {
-                       spin_lock_irq(&l3->list_lock);
-                       ret += __node_shrink(cachep, i);
-                       spin_unlock_irq(&l3->list_lock);
-               }
+               if (!l3)
+                       continue;
+
+               drain_freelist(cachep, l3, l3->free_objects);
+
+               ret += !list_empty(&l3->slabs_full) ||
+                       !list_empty(&l3->slabs_partial);
        }
        return (ret ? 1 : 0);
 }
@@ -3694,10 +3707,6 @@ static void cache_reap(void *unused)
        }
 
        list_for_each_entry(searchp, &cache_chain, next) {
-               struct list_head *p;
-               int tofree;
-               struct slab *slabp;
-
                check_irq_on();
 
                /*
@@ -3722,47 +3731,22 @@ static void cache_reap(void *unused)
 
                drain_array(searchp, l3, l3->shared, 0, node);
 
-               if (l3->free_touched) {
+               if (l3->free_touched)
                        l3->free_touched = 0;
-                       goto next;
-               }
-
-               tofree = (l3->free_limit + 5 * searchp->num - 1) /
-                               (5 * searchp->num);
-               do {
-                       /*
-                        * Do not lock if there are no free blocks.
-                        */
-                       if (list_empty(&l3->slabs_free))
-                               break;
-
-                       spin_lock_irq(&l3->list_lock);
-                       p = l3->slabs_free.next;
-                       if (p == &(l3->slabs_free)) {
-                               spin_unlock_irq(&l3->list_lock);
-                               break;
-                       }
+               else {
+                       int freed;
 
-                       slabp = list_entry(p, struct slab, list);
-                       BUG_ON(slabp->inuse);
-                       list_del(&slabp->list);
-                       STATS_INC_REAPED(searchp);
-
-                       /*
-                        * Safe to drop the lock. The slab is no longer linked
-                        * to the cache. searchp cannot disappear, we hold
-                        * cache_chain_lock
-                        */
-                       l3->free_objects -= searchp->num;
-                       spin_unlock_irq(&l3->list_lock);
-                       slab_destroy(searchp, slabp);
-               } while (--tofree > 0);
+                       freed = drain_freelist(searchp, l3, (l3->free_limit +
+                               5 * searchp->num - 1) / (5 * searchp->num));
+                       STATS_ADD_REAPED(searchp, freed);
+               }
 next:
                cond_resched();
        }
        check_irq_on();
        mutex_unlock(&cache_chain_mutex);
        next_reap_node();
+       refresh_cpu_vm_stats(smp_processor_id());
        /* Set up the next iteration */
        schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC);
 }
index 990868a..8fd095c 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -87,7 +87,7 @@ int rotate_reclaimable_page(struct page *page)
        spin_lock_irqsave(&zone->lru_lock, flags);
        if (PageLRU(page) && !PageActive(page)) {
                list_move_tail(&page->lru, &zone->inactive_list);
-               inc_page_state(pgrotated);
+               __count_vm_event(PGROTATED);
        }
        if (!test_clear_page_writeback(page))
                BUG();
@@ -107,7 +107,7 @@ void fastcall activate_page(struct page *page)
                del_page_from_inactive_list(zone, page);
                SetPageActive(page);
                add_page_to_active_list(zone, page);
-               inc_page_state(pgactivate);
+               __count_vm_event(PGACTIVATE);
        }
        spin_unlock_irq(&zone->lru_lock);
 }
index 7535211..fccbd9b 100644 (file)
@@ -87,7 +87,7 @@ static int __add_to_swap_cache(struct page *page, swp_entry_t entry,
                        SetPageSwapCache(page);
                        set_page_private(page, entry.val);
                        total_swapcache_pages++;
-                       pagecache_acct(1);
+                       __inc_zone_page_state(page, NR_FILE_PAGES);
                }
                write_unlock_irq(&swapper_space.tree_lock);
                radix_tree_preload_end();
@@ -132,7 +132,7 @@ void __delete_from_swap_cache(struct page *page)
        set_page_private(page, 0);
        ClearPageSwapCache(page);
        total_swapcache_pages--;
-       pagecache_acct(-1);
+       __dec_zone_page_state(page, NR_FILE_PAGES);
        INC_CACHE_INFO(del_total);
 }
 
index eeacb0d..ff2ebe9 100644 (file)
@@ -47,8 +47,6 @@ struct scan_control {
        /* Incremented by the number of inactive pages that were scanned */
        unsigned long nr_scanned;
 
-       unsigned long nr_mapped;        /* From page_state */
-
        /* This context's GFP mask */
        gfp_t gfp_mask;
 
@@ -217,7 +215,7 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
                                break;
                        if (shrink_ret < nr_before)
                                ret += nr_before - shrink_ret;
-                       mod_page_state(slabs_scanned, this_scan);
+                       count_vm_events(SLABS_SCANNED, this_scan);
                        total_scan -= this_scan;
 
                        cond_resched();
@@ -571,7 +569,7 @@ keep:
        list_splice(&ret_pages, page_list);
        if (pagevec_count(&freed_pvec))
                __pagevec_release_nonlru(&freed_pvec);
-       mod_page_state(pgactivate, pgactivate);
+       count_vm_events(PGACTIVATE, pgactivate);
        return nr_reclaimed;
 }
 
@@ -661,11 +659,11 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
                nr_reclaimed += nr_freed;
                local_irq_disable();
                if (current_is_kswapd()) {
-                       __mod_page_state_zone(zone, pgscan_kswapd, nr_scan);
-                       __mod_page_state(kswapd_steal, nr_freed);
+                       __count_zone_vm_events(PGSCAN_KSWAPD, zone, nr_scan);
+                       __count_vm_events(KSWAPD_STEAL, nr_freed);
                } else
-                       __mod_page_state_zone(zone, pgscan_direct, nr_scan);
-               __mod_page_state_zone(zone, pgsteal, nr_freed);
+                       __count_zone_vm_events(PGSCAN_DIRECT, zone, nr_scan);
+               __count_vm_events(PGACTIVATE, nr_freed);
 
                if (nr_taken == 0)
                        goto done;
@@ -744,7 +742,9 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
                 * how much memory
                 * is mapped.
                 */
-               mapped_ratio = (sc->nr_mapped * 100) / vm_total_pages;
+               mapped_ratio = ((global_page_state(NR_FILE_MAPPED) +
+                               global_page_state(NR_ANON_PAGES)) * 100) /
+                                       vm_total_pages;
 
                /*
                 * Now decide how much we really want to unmap some pages.  The
@@ -841,11 +841,10 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
                }
        }
        zone->nr_active += pgmoved;
-       spin_unlock(&zone->lru_lock);
 
-       __mod_page_state_zone(zone, pgrefill, pgscanned);
-       __mod_page_state(pgdeactivate, pgdeactivate);
-       local_irq_enable();
+       __count_zone_vm_events(PGREFILL, zone, pgscanned);
+       __count_vm_events(PGDEACTIVATE, pgdeactivate);
+       spin_unlock_irq(&zone->lru_lock);
 
        pagevec_release(&pvec);
 }
@@ -977,7 +976,7 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
                .swappiness = vm_swappiness,
        };
 
-       inc_page_state(allocstall);
+       count_vm_event(ALLOCSTALL);
 
        for (i = 0; zones[i] != NULL; i++) {
                struct zone *zone = zones[i];
@@ -990,7 +989,6 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
        }
 
        for (priority = DEF_PRIORITY; priority >= 0; priority--) {
-               sc.nr_mapped = read_page_state(nr_mapped);
                sc.nr_scanned = 0;
                if (!priority)
                        disable_swap_token();
@@ -1075,9 +1073,7 @@ loop_again:
        total_scanned = 0;
        nr_reclaimed = 0;
        sc.may_writepage = !laptop_mode;
-       sc.nr_mapped = read_page_state(nr_mapped);
-
-       inc_page_state(pageoutrun);
+       count_vm_event(PAGEOUTRUN);
 
        for (i = 0; i < pgdat->nr_zones; i++) {
                struct zone *zone = pgdat->node_zones + i;
@@ -1365,7 +1361,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
        for_each_zone(zone)
                lru_pages += zone->nr_active + zone->nr_inactive;
 
-       nr_slab = read_page_state(nr_slab);
+       nr_slab = global_page_state(NR_SLAB);
        /* If slab caches are huge, it's better to hit them first */
        while (nr_slab >= lru_pages) {
                reclaim_state.reclaimed_slab = 0;
@@ -1407,9 +1403,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
                for (prio = DEF_PRIORITY; prio >= 0; prio--) {
                        unsigned long nr_to_scan = nr_pages - ret;
 
-                       sc.nr_mapped = read_page_state(nr_mapped);
                        sc.nr_scanned = 0;
-
                        ret += shrink_all_zones(nr_to_scan, prio, pass, &sc);
                        if (ret >= nr_pages)
                                goto out;
@@ -1523,11 +1517,6 @@ int zone_reclaim_mode __read_mostly;
 #define RECLAIM_SLAB (1<<3)    /* Do a global slab shrink if the zone is out of memory */
 
 /*
- * Mininum time between zone reclaim scans
- */
-int zone_reclaim_interval __read_mostly = 30*HZ;
-
-/*
  * Priority for ZONE_RECLAIM. This determines the fraction of pages
  * of a node considered for each zone_reclaim. 4 scans 1/16th of
  * a zone.
@@ -1548,7 +1537,6 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
        struct scan_control sc = {
                .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
                .may_swap = !!(zone_reclaim_mode & RECLAIM_SWAP),
-               .nr_mapped = read_page_state(nr_mapped),
                .swap_cluster_max = max_t(unsigned long, nr_pages,
                                        SWAP_CLUSTER_MAX),
                .gfp_mask = gfp_mask,
@@ -1593,16 +1581,6 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
 
        p->reclaim_state = NULL;
        current->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE);
-
-       if (nr_reclaimed == 0) {
-               /*
-                * We were unable to reclaim enough pages to stay on node.  We
-                * now allow off node accesses for a certain time period before
-                * trying again to reclaim pages from the local zone.
-                */
-               zone->last_unsuccessful_zone_reclaim = jiffies;
-       }
-
        return nr_reclaimed >= nr_pages;
 }
 
@@ -1612,13 +1590,17 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
        int node_id;
 
        /*
-        * Do not reclaim if there was a recent unsuccessful attempt at zone
-        * reclaim.  In that case we let allocations go off node for the
-        * zone_reclaim_interval.  Otherwise we would scan for each off-node
-        * page allocation.
+        * Do not reclaim if there are not enough reclaimable pages in this
+        * zone that would satify this allocations.
+        *
+        * All unmapped pagecache pages are reclaimable.
+        *
+        * Both counters may be temporarily off a bit so we use
+        * SWAP_CLUSTER_MAX as the boundary. It may also be good to
+        * leave a few frequently used unmapped pagecache pages around.
         */
-       if (time_before(jiffies,
-               zone->last_unsuccessful_zone_reclaim + zone_reclaim_interval))
+       if (zone_page_state(zone, NR_FILE_PAGES) -
+               zone_page_state(zone, NR_FILE_MAPPED) < SWAP_CLUSTER_MAX)
                        return 0;
 
        /*
diff --git a/mm/vmstat.c b/mm/vmstat.c
new file mode 100644 (file)
index 0000000..73b83d6
--- /dev/null
@@ -0,0 +1,614 @@
+/*
+ *  linux/mm/vmstat.c
+ *
+ *  Manages VM statistics
+ *  Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  zoned VM statistics
+ *  Copyright (C) 2006 Silicon Graphics, Inc.,
+ *             Christoph Lameter <christoph@lameter.com>
+ */
+
+#include <linux/config.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+
+void __get_zone_counts(unsigned long *active, unsigned long *inactive,
+                       unsigned long *free, struct pglist_data *pgdat)
+{
+       struct zone *zones = pgdat->node_zones;
+       int i;
+
+       *active = 0;
+       *inactive = 0;
+       *free = 0;
+       for (i = 0; i < MAX_NR_ZONES; i++) {
+               *active += zones[i].nr_active;
+               *inactive += zones[i].nr_inactive;
+               *free += zones[i].free_pages;
+       }
+}
+
+void get_zone_counts(unsigned long *active,
+               unsigned long *inactive, unsigned long *free)
+{
+       struct pglist_data *pgdat;
+
+       *active = 0;
+       *inactive = 0;
+       *free = 0;
+       for_each_online_pgdat(pgdat) {
+               unsigned long l, m, n;
+               __get_zone_counts(&l, &m, &n, pgdat);
+               *active += l;
+               *inactive += m;
+               *free += n;
+       }
+}
+
+#ifdef CONFIG_VM_EVENT_COUNTERS
+DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
+EXPORT_PER_CPU_SYMBOL(vm_event_states);
+
+static void sum_vm_events(unsigned long *ret, cpumask_t *cpumask)
+{
+       int cpu = 0;
+       int i;
+
+       memset(ret, 0, NR_VM_EVENT_ITEMS * sizeof(unsigned long));
+
+       cpu = first_cpu(*cpumask);
+       while (cpu < NR_CPUS) {
+               struct vm_event_state *this = &per_cpu(vm_event_states, cpu);
+
+               cpu = next_cpu(cpu, *cpumask);
+
+               if (cpu < NR_CPUS)
+                       prefetch(&per_cpu(vm_event_states, cpu));
+
+
+               for (i = 0; i < NR_VM_EVENT_ITEMS; i++)
+                       ret[i] += this->event[i];
+       }
+}
+
+/*
+ * Accumulate the vm event counters across all CPUs.
+ * The result is unavoidably approximate - it can change
+ * during and after execution of this function.
+*/
+void all_vm_events(unsigned long *ret)
+{
+       sum_vm_events(ret, &cpu_online_map);
+}
+
+#ifdef CONFIG_HOTPLUG
+/*
+ * Fold the foreign cpu events into our own.
+ *
+ * This is adding to the events on one processor
+ * but keeps the global counts constant.
+ */
+void vm_events_fold_cpu(int cpu)
+{
+       struct vm_event_state *fold_state = &per_cpu(vm_event_states, cpu);
+       int i;
+
+       for (i = 0; i < NR_VM_EVENT_ITEMS; i++) {
+               count_vm_events(i, fold_state->event[i]);
+               fold_state->event[i] = 0;
+       }
+}
+#endif /* CONFIG_HOTPLUG */
+
+#endif /* CONFIG_VM_EVENT_COUNTERS */
+
+/*
+ * Manage combined zone based / global counters
+ *
+ * vm_stat contains the global counters
+ */
+atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
+EXPORT_SYMBOL(vm_stat);
+
+#ifdef CONFIG_SMP
+
+#define STAT_THRESHOLD 32
+
+/*
+ * Determine pointer to currently valid differential byte given a zone and
+ * the item number.
+ *
+ * Preemption must be off
+ */
+static inline s8 *diff_pointer(struct zone *zone, enum zone_stat_item item)
+{
+       return &zone_pcp(zone, smp_processor_id())->vm_stat_diff[item];
+}
+
+/*
+ * For use when we know that interrupts are disabled.
+ */
+void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item,
+                               int delta)
+{
+       s8 *p;
+       long x;
+
+       p = diff_pointer(zone, item);
+       x = delta + *p;
+
+       if (unlikely(x > STAT_THRESHOLD || x < -STAT_THRESHOLD)) {
+               zone_page_state_add(x, zone, item);
+               x = 0;
+       }
+
+       *p = x;
+}
+EXPORT_SYMBOL(__mod_zone_page_state);
+
+/*
+ * For an unknown interrupt state
+ */
+void mod_zone_page_state(struct zone *zone, enum zone_stat_item item,
+                                       int delta)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       __mod_zone_page_state(zone, item, delta);
+       local_irq_restore(flags);
+}
+EXPORT_SYMBOL(mod_zone_page_state);
+
+/*
+ * Optimized increment and decrement functions.
+ *
+ * These are only for a single page and therefore can take a struct page *
+ * argument instead of struct zone *. This allows the inclusion of the code
+ * generated for page_zone(page) into the optimized functions.
+ *
+ * No overflow check is necessary and therefore the differential can be
+ * incremented or decremented in place which may allow the compilers to
+ * generate better code.
+ *
+ * The increment or decrement is known and therefore one boundary check can
+ * be omitted.
+ *
+ * Some processors have inc/dec instructions that are atomic vs an interrupt.
+ * However, the code must first determine the differential location in a zone
+ * based on the processor number and then inc/dec the counter. There is no
+ * guarantee without disabling preemption that the processor will not change
+ * in between and therefore the atomicity vs. interrupt cannot be exploited
+ * in a useful way here.
+ */
+static void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
+{
+       s8 *p = diff_pointer(zone, item);
+
+       (*p)++;
+
+       if (unlikely(*p > STAT_THRESHOLD)) {
+               zone_page_state_add(*p, zone, item);
+               *p = 0;
+       }
+}
+
+void __inc_zone_page_state(struct page *page, enum zone_stat_item item)
+{
+       __inc_zone_state(page_zone(page), item);
+}
+EXPORT_SYMBOL(__inc_zone_page_state);
+
+void __dec_zone_page_state(struct page *page, enum zone_stat_item item)
+{
+       struct zone *zone = page_zone(page);
+       s8 *p = diff_pointer(zone, item);
+
+       (*p)--;
+
+       if (unlikely(*p < -STAT_THRESHOLD)) {
+               zone_page_state_add(*p, zone, item);
+               *p = 0;
+       }
+}
+EXPORT_SYMBOL(__dec_zone_page_state);
+
+void inc_zone_state(struct zone *zone, enum zone_stat_item item)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       __inc_zone_state(zone, item);
+       local_irq_restore(flags);
+}
+
+void inc_zone_page_state(struct page *page, enum zone_stat_item item)
+{
+       unsigned long flags;
+       struct zone *zone;
+
+       zone = page_zone(page);
+       local_irq_save(flags);
+       __inc_zone_state(zone, item);
+       local_irq_restore(flags);
+}
+EXPORT_SYMBOL(inc_zone_page_state);
+
+void dec_zone_page_state(struct page *page, enum zone_stat_item item)
+{
+       unsigned long flags;
+       struct zone *zone;
+       s8 *p;
+
+       zone = page_zone(page);
+       local_irq_save(flags);
+       p = diff_pointer(zone, item);
+
+       (*p)--;
+
+       if (unlikely(*p < -STAT_THRESHOLD)) {
+               zone_page_state_add(*p, zone, item);
+               *p = 0;
+       }
+       local_irq_restore(flags);
+}
+EXPORT_SYMBOL(dec_zone_page_state);
+
+/*
+ * Update the zone counters for one cpu.
+ */
+void refresh_cpu_vm_stats(int cpu)
+{
+       struct zone *zone;
+       int i;
+       unsigned long flags;
+
+       for_each_zone(zone) {
+               struct per_cpu_pageset *pcp;
+
+               pcp = zone_pcp(zone, cpu);
+
+               for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
+                       if (pcp->vm_stat_diff[i]) {
+                               local_irq_save(flags);
+                               zone_page_state_add(pcp->vm_stat_diff[i],
+                                       zone, i);
+                               pcp->vm_stat_diff[i] = 0;
+                               local_irq_restore(flags);
+                       }
+       }
+}
+
+static void __refresh_cpu_vm_stats(void *dummy)
+{
+       refresh_cpu_vm_stats(smp_processor_id());
+}
+
+/*
+ * Consolidate all counters.
+ *
+ * Note that the result is less inaccurate but still inaccurate
+ * if concurrent processes are allowed to run.
+ */
+void refresh_vm_stats(void)
+{
+       on_each_cpu(__refresh_cpu_vm_stats, NULL, 0, 1);
+}
+EXPORT_SYMBOL(refresh_vm_stats);
+
+#endif
+
+#ifdef CONFIG_NUMA
+/*
+ * zonelist = the list of zones passed to the allocator
+ * z       = the zone from which the allocation occurred.
+ *
+ * Must be called with interrupts disabled.
+ */
+void zone_statistics(struct zonelist *zonelist, struct zone *z)
+{
+       if (z->zone_pgdat == zonelist->zones[0]->zone_pgdat) {
+               __inc_zone_state(z, NUMA_HIT);
+       } else {
+               __inc_zone_state(z, NUMA_MISS);
+               __inc_zone_state(zonelist->zones[0], NUMA_FOREIGN);
+       }
+       if (z->zone_pgdat == NODE_DATA(numa_node_id()))
+               __inc_zone_state(z, NUMA_LOCAL);
+       else
+               __inc_zone_state(z, NUMA_OTHER);
+}
+#endif
+
+#ifdef CONFIG_PROC_FS
+
+#include <linux/seq_file.h>
+
+static void *frag_start(struct seq_file *m, loff_t *pos)
+{
+       pg_data_t *pgdat;
+       loff_t node = *pos;
+       for (pgdat = first_online_pgdat();
+            pgdat && node;
+            pgdat = next_online_pgdat(pgdat))
+               --node;
+
+       return pgdat;
+}
+
+static void *frag_next(struct seq_file *m, void *arg, loff_t *pos)
+{
+       pg_data_t *pgdat = (pg_data_t *)arg;
+
+       (*pos)++;
+       return next_online_pgdat(pgdat);
+}
+
+static void frag_stop(struct seq_file *m, void *arg)
+{
+}
+
+/*
+ * This walks the free areas for each zone.
+ */
+static int frag_show(struct seq_file *m, void *arg)
+{
+       pg_data_t *pgdat = (pg_data_t *)arg;
+       struct zone *zone;
+       struct zone *node_zones = pgdat->node_zones;
+       unsigned long flags;
+       int order;
+
+       for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
+               if (!populated_zone(zone))
+                       continue;
+
+               spin_lock_irqsave(&zone->lock, flags);
+               seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name);
+               for (order = 0; order < MAX_ORDER; ++order)
+                       seq_printf(m, "%6lu ", zone->free_area[order].nr_free);
+               spin_unlock_irqrestore(&zone->lock, flags);
+               seq_putc(m, '\n');
+       }
+       return 0;
+}
+
+struct seq_operations fragmentation_op = {
+       .start  = frag_start,
+       .next   = frag_next,
+       .stop   = frag_stop,
+       .show   = frag_show,
+};
+
+static char *vmstat_text[] = {
+       /* Zoned VM counters */
+       "nr_anon_pages",
+       "nr_mapped",
+       "nr_file_pages",
+       "nr_slab",
+       "nr_page_table_pages",
+       "nr_dirty",
+       "nr_writeback",
+       "nr_unstable",
+       "nr_bounce",
+
+#ifdef CONFIG_NUMA
+       "numa_hit",
+       "numa_miss",
+       "numa_foreign",
+       "numa_interleave",
+       "numa_local",
+       "numa_other",
+#endif
+
+#ifdef CONFIG_VM_EVENT_COUNTERS
+       "pgpgin",
+       "pgpgout",
+       "pswpin",
+       "pswpout",
+
+       "pgalloc_dma",
+       "pgalloc_dma32",
+       "pgalloc_normal",
+       "pgalloc_high",
+
+       "pgfree",
+       "pgactivate",
+       "pgdeactivate",
+
+       "pgfault",
+       "pgmajfault",
+
+       "pgrefill_dma",
+       "pgrefill_dma32",
+       "pgrefill_normal",
+       "pgrefill_high",
+
+       "pgsteal_dma",
+       "pgsteal_dma32",
+       "pgsteal_normal",
+       "pgsteal_high",
+
+       "pgscan_kswapd_dma",
+       "pgscan_kswapd_dma32",
+       "pgscan_kswapd_normal",
+       "pgscan_kswapd_high",
+
+       "pgscan_direct_dma",
+       "pgscan_direct_dma32",
+       "pgscan_direct_normal",
+       "pgscan_direct_high",
+
+       "pginodesteal",
+       "slabs_scanned",
+       "kswapd_steal",
+       "kswapd_inodesteal",
+       "pageoutrun",
+       "allocstall",
+
+       "pgrotated",
+#endif
+};
+
+/*
+ * Output information about zones in @pgdat.
+ */
+static int zoneinfo_show(struct seq_file *m, void *arg)
+{
+       pg_data_t *pgdat = arg;
+       struct zone *zone;
+       struct zone *node_zones = pgdat->node_zones;
+       unsigned long flags;
+
+       for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) {
+               int i;
+
+               if (!populated_zone(zone))
+                       continue;
+
+               spin_lock_irqsave(&zone->lock, flags);
+               seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name);
+               seq_printf(m,
+                          "\n  pages free     %lu"
+                          "\n        min      %lu"
+                          "\n        low      %lu"
+                          "\n        high     %lu"
+                          "\n        active   %lu"
+                          "\n        inactive %lu"
+                          "\n        scanned  %lu (a: %lu i: %lu)"
+                          "\n        spanned  %lu"
+                          "\n        present  %lu",
+                          zone->free_pages,
+                          zone->pages_min,
+                          zone->pages_low,
+                          zone->pages_high,
+                          zone->nr_active,
+                          zone->nr_inactive,
+                          zone->pages_scanned,
+                          zone->nr_scan_active, zone->nr_scan_inactive,
+                          zone->spanned_pages,
+                          zone->present_pages);
+
+               for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
+                       seq_printf(m, "\n    %-12s %lu", vmstat_text[i],
+                                       zone_page_state(zone, i));
+
+               seq_printf(m,
+                          "\n        protection: (%lu",
+                          zone->lowmem_reserve[0]);
+               for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
+                       seq_printf(m, ", %lu", zone->lowmem_reserve[i]);
+               seq_printf(m,
+                          ")"
+                          "\n  pagesets");
+               for_each_online_cpu(i) {
+                       struct per_cpu_pageset *pageset;
+                       int j;
+
+                       pageset = zone_pcp(zone, i);
+                       for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
+                               if (pageset->pcp[j].count)
+                                       break;
+                       }
+                       if (j == ARRAY_SIZE(pageset->pcp))
+                               continue;
+                       for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
+                               seq_printf(m,
+                                          "\n    cpu: %i pcp: %i"
+                                          "\n              count: %i"
+                                          "\n              high:  %i"
+                                          "\n              batch: %i",
+                                          i, j,
+                                          pageset->pcp[j].count,
+                                          pageset->pcp[j].high,
+                                          pageset->pcp[j].batch);
+                       }
+               }
+               seq_printf(m,
+                          "\n  all_unreclaimable: %u"
+                          "\n  prev_priority:     %i"
+                          "\n  temp_priority:     %i"
+                          "\n  start_pfn:         %lu",
+                          zone->all_unreclaimable,
+                          zone->prev_priority,
+                          zone->temp_priority,
+                          zone->zone_start_pfn);
+               spin_unlock_irqrestore(&zone->lock, flags);
+               seq_putc(m, '\n');
+       }
+       return 0;
+}
+
+struct seq_operations zoneinfo_op = {
+       .start  = frag_start, /* iterate over all zones. The same as in
+                              * fragmentation. */
+       .next   = frag_next,
+       .stop   = frag_stop,
+       .show   = zoneinfo_show,
+};
+
+static void *vmstat_start(struct seq_file *m, loff_t *pos)
+{
+       unsigned long *v;
+#ifdef CONFIG_VM_EVENT_COUNTERS
+       unsigned long *e;
+#endif
+       int i;
+
+       if (*pos >= ARRAY_SIZE(vmstat_text))
+               return NULL;
+
+#ifdef CONFIG_VM_EVENT_COUNTERS
+       v = kmalloc(NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long)
+                       + sizeof(struct vm_event_state), GFP_KERNEL);
+#else
+       v = kmalloc(NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long),
+                       GFP_KERNEL);
+#endif
+       m->private = v;
+       if (!v)
+               return ERR_PTR(-ENOMEM);
+       for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
+               v[i] = global_page_state(i);
+#ifdef CONFIG_VM_EVENT_COUNTERS
+       e = v + NR_VM_ZONE_STAT_ITEMS;
+       all_vm_events(e);
+       e[PGPGIN] /= 2;         /* sectors -> kbytes */
+       e[PGPGOUT] /= 2;
+#endif
+       return v + *pos;
+}
+
+static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos)
+{
+       (*pos)++;
+       if (*pos >= ARRAY_SIZE(vmstat_text))
+               return NULL;
+       return (unsigned long *)m->private + *pos;
+}
+
+static int vmstat_show(struct seq_file *m, void *arg)
+{
+       unsigned long *l = arg;
+       unsigned long off = l - (unsigned long *)m->private;
+
+       seq_printf(m, "%s %lu\n", vmstat_text[off], *l);
+       return 0;
+}
+
+static void vmstat_stop(struct seq_file *m, void *arg)
+{
+       kfree(m->private);
+       m->private = NULL;
+}
+
+struct seq_operations vmstat_op = {
+       .start  = vmstat_start,
+       .next   = vmstat_next,
+       .stop   = vmstat_stop,
+       .show   = vmstat_show,
+};
+
+#endif /* CONFIG_PROC_FS */
+
index f8bac6c..d88468d 100644 (file)
@@ -224,7 +224,8 @@ EXPORT_SYMBOL(gss_service_to_auth_domain_name);
 void
 gss_mech_put(struct gss_api_mech * gm)
 {
-       module_put(gm->gm_owner);
+       if (gm)
+               module_put(gm->gm_owner);
 }
 
 EXPORT_SYMBOL(gss_mech_put);
@@ -307,8 +308,7 @@ gss_delete_sec_context(struct gss_ctx       **context_handle)
                (*context_handle)->mech_type->gm_ops
                        ->gss_delete_sec_context((*context_handle)
                                                        ->internal_ctx_id);
-       if ((*context_handle)->mech_type)
-               gss_mech_put((*context_handle)->mech_type);
+       gss_mech_put((*context_handle)->mech_type);
        kfree(*context_handle);
        *context_handle=NULL;
        return GSS_S_COMPLETE;
index d51e316..94217ec 100644 (file)
@@ -425,6 +425,7 @@ static int rsc_parse(struct cache_detail *cd,
        struct rsc rsci, *rscp = NULL;
        time_t expiry;
        int status = -EINVAL;
+       struct gss_api_mech *gm = NULL;
 
        memset(&rsci, 0, sizeof(rsci));
        /* context handle */
@@ -453,7 +454,6 @@ static int rsc_parse(struct cache_detail *cd,
                set_bit(CACHE_NEGATIVE, &rsci.h.flags);
        else {
                int N, i;
-               struct gss_api_mech *gm;
 
                /* gid */
                if (get_int(&mesg, &rsci.cred.cr_gid))
@@ -488,21 +488,17 @@ static int rsc_parse(struct cache_detail *cd,
                status = -EINVAL;
                /* mech-specific data: */
                len = qword_get(&mesg, buf, mlen);
-               if (len < 0) {
-                       gss_mech_put(gm);
+               if (len < 0)
                        goto out;
-               }
                status = gss_import_sec_context(buf, len, gm, &rsci.mechctx);
-               if (status) {
-                       gss_mech_put(gm);
+               if (status)
                        goto out;
-               }
-               gss_mech_put(gm);
        }
        rsci.h.expiry_time = expiry;
        rscp = rsc_update(&rsci, rscp);
        status = 0;
 out:
+       gss_mech_put(gm);
        rsc_free(&rsci);
        if (rscp)
                cache_put(&rscp->h, &rsc_cache);
@@ -836,6 +832,74 @@ out:
        return stat;
 }
 
+static inline int
+total_buf_len(struct xdr_buf *buf)
+{
+       return buf->head[0].iov_len + buf->page_len + buf->tail[0].iov_len;
+}
+
+static void
+fix_priv_head(struct xdr_buf *buf, int pad)
+{
+       if (buf->page_len == 0) {
+               /* We need to adjust head and buf->len in tandem in this
+                * case to make svc_defer() work--it finds the original
+                * buffer start using buf->len - buf->head[0].iov_len. */
+               buf->head[0].iov_len -= pad;
+       }
+}
+
+static int
+unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
+{
+       u32 priv_len, maj_stat;
+       int pad, saved_len, remaining_len, offset;
+
+       rqstp->rq_sendfile_ok = 0;
+
+       priv_len = ntohl(svc_getu32(&buf->head[0]));
+       if (rqstp->rq_deferred) {
+               /* Already decrypted last time through! The sequence number
+                * check at out_seq is unnecessary but harmless: */
+               goto out_seq;
+       }
+       /* buf->len is the number of bytes from the original start of the
+        * request to the end, where head[0].iov_len is just the bytes
+        * not yet read from the head, so these two values are different: */
+       remaining_len = total_buf_len(buf);
+       if (priv_len > remaining_len)
+               return -EINVAL;
+       pad = remaining_len - priv_len;
+       buf->len -= pad;
+       fix_priv_head(buf, pad);
+
+       /* Maybe it would be better to give gss_unwrap a length parameter: */
+       saved_len = buf->len;
+       buf->len = priv_len;
+       maj_stat = gss_unwrap(ctx, 0, buf);
+       pad = priv_len - buf->len;
+       buf->len = saved_len;
+       buf->len -= pad;
+       /* The upper layers assume the buffer is aligned on 4-byte boundaries.
+        * In the krb5p case, at least, the data ends up offset, so we need to
+        * move it around. */
+       /* XXX: This is very inefficient.  It would be better to either do
+        * this while we encrypt, or maybe in the receive code, if we can peak
+        * ahead and work out the service and mechanism there. */
+       offset = buf->head[0].iov_len % 4;
+       if (offset) {
+               buf->buflen = RPCSVC_MAXPAYLOAD;
+               xdr_shift_buf(buf, offset);
+               fix_priv_head(buf, pad);
+       }
+       if (maj_stat != GSS_S_COMPLETE)
+               return -EINVAL;
+out_seq:
+       if (ntohl(svc_getu32(&buf->head[0])) != seq)
+               return -EINVAL;
+       return 0;
+}
+
 struct gss_svc_data {
        /* decoded gss client cred: */
        struct rpc_gss_wire_cred        clcred;
@@ -1051,7 +1115,14 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
                        svc_putu32(resv, 0);
                        break;
                case RPC_GSS_SVC_PRIVACY:
-                       /* currently unsupported */
+                       if (unwrap_priv_data(rqstp, &rqstp->rq_arg,
+                                       gc->gc_seq, rsci->mechctx))
+                               goto auth_err;
+                       /* placeholders for length and seq. number: */
+                       svcdata->body_start = resv->iov_base + resv->iov_len;
+                       svc_putu32(resv, 0);
+                       svc_putu32(resv, 0);
+                       break;
                default:
                        goto auth_err;
                }
@@ -1076,8 +1147,8 @@ out:
        return ret;
 }
 
-static int
-svcauth_gss_release(struct svc_rqst *rqstp)
+static inline int
+svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
 {
        struct gss_svc_data *gsd = (struct gss_svc_data *)rqstp->rq_auth_data;
        struct rpc_gss_wire_cred *gc = &gsd->clcred;
@@ -1089,69 +1160,147 @@ svcauth_gss_release(struct svc_rqst *rqstp)
        int integ_offset, integ_len;
        int stat = -EINVAL;
 
+       p = gsd->body_start;
+       gsd->body_start = NULL;
+       /* move accept_stat to right place: */
+       memcpy(p, p + 2, 4);
+       /* Don't wrap in failure case: */
+       /* Counting on not getting here if call was not even accepted! */
+       if (*p != rpc_success) {
+               resbuf->head[0].iov_len -= 2 * 4;
+               goto out;
+       }
+       p++;
+       integ_offset = (u8 *)(p + 1) - (u8 *)resbuf->head[0].iov_base;
+       integ_len = resbuf->len - integ_offset;
+       BUG_ON(integ_len % 4);
+       *p++ = htonl(integ_len);
+       *p++ = htonl(gc->gc_seq);
+       if (xdr_buf_subsegment(resbuf, &integ_buf, integ_offset,
+                               integ_len))
+               BUG();
+       if (resbuf->page_len == 0
+                       && resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE
+                       < PAGE_SIZE) {
+               BUG_ON(resbuf->tail[0].iov_len);
+               /* Use head for everything */
+               resv = &resbuf->head[0];
+       } else if (resbuf->tail[0].iov_base == NULL) {
+               if (resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE > PAGE_SIZE)
+                       goto out_err;
+               resbuf->tail[0].iov_base = resbuf->head[0].iov_base
+                                               + resbuf->head[0].iov_len;
+               resbuf->tail[0].iov_len = 0;
+               rqstp->rq_restailpage = 0;
+               resv = &resbuf->tail[0];
+       } else {
+               resv = &resbuf->tail[0];
+       }
+       mic.data = (u8 *)resv->iov_base + resv->iov_len + 4;
+       if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic))
+               goto out_err;
+       svc_putu32(resv, htonl(mic.len));
+       memset(mic.data + mic.len, 0,
+                       round_up_to_quad(mic.len) - mic.len);
+       resv->iov_len += XDR_QUADLEN(mic.len) << 2;
+       /* not strictly required: */
+       resbuf->len += XDR_QUADLEN(mic.len) << 2;
+       BUG_ON(resv->iov_len > PAGE_SIZE);
+out:
+       stat = 0;
+out_err:
+       return stat;
+}
+
+static inline int
+svcauth_gss_wrap_resp_priv(struct svc_rqst *rqstp)
+{
+       struct gss_svc_data *gsd = (struct gss_svc_data *)rqstp->rq_auth_data;
+       struct rpc_gss_wire_cred *gc = &gsd->clcred;
+       struct xdr_buf *resbuf = &rqstp->rq_res;
+       struct page **inpages = NULL;
+       u32 *p;
+       int offset, *len;
+       int pad;
+
+       p = gsd->body_start;
+       gsd->body_start = NULL;
+       /* move accept_stat to right place: */
+       memcpy(p, p + 2, 4);
+       /* Don't wrap in failure case: */
+       /* Counting on not getting here if call was not even accepted! */
+       if (*p != rpc_success) {
+               resbuf->head[0].iov_len -= 2 * 4;
+               return 0;
+       }
+       p++;
+       len = p++;
+       offset = (u8 *)p - (u8 *)resbuf->head[0].iov_base;
+       *p++ = htonl(gc->gc_seq);
+       inpages = resbuf->pages;
+       /* XXX: Would be better to write some xdr helper functions for
+        * nfs{2,3,4}xdr.c that place the data right, instead of copying: */
+       if (resbuf->tail[0].iov_base && rqstp->rq_restailpage == 0) {
+               BUG_ON(resbuf->tail[0].iov_base >= resbuf->head[0].iov_base
+                                                       + PAGE_SIZE);
+               BUG_ON(resbuf->tail[0].iov_base < resbuf->head[0].iov_base);
+               if (resbuf->tail[0].iov_len + resbuf->head[0].iov_len
+                               + 2 * RPC_MAX_AUTH_SIZE > PAGE_SIZE)
+                       return -ENOMEM;
+               memmove(resbuf->tail[0].iov_base + RPC_MAX_AUTH_SIZE,
+                       resbuf->tail[0].iov_base,
+                       resbuf->tail[0].iov_len);
+               resbuf->tail[0].iov_base += RPC_MAX_AUTH_SIZE;
+       }
+       if (resbuf->tail[0].iov_base == NULL) {
+               if (resbuf->head[0].iov_len + 2*RPC_MAX_AUTH_SIZE > PAGE_SIZE)
+                       return -ENOMEM;
+               resbuf->tail[0].iov_base = resbuf->head[0].iov_base
+                       + resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE;
+               resbuf->tail[0].iov_len = 0;
+               rqstp->rq_restailpage = 0;
+       }
+       if (gss_wrap(gsd->rsci->mechctx, offset, resbuf, inpages))
+               return -ENOMEM;
+       *len = htonl(resbuf->len - offset);
+       pad = 3 - ((resbuf->len - offset - 1)&3);
+       p = (u32 *)(resbuf->tail[0].iov_base + resbuf->tail[0].iov_len);
+       memset(p, 0, pad);
+       resbuf->tail[0].iov_len += pad;
+       resbuf->len += pad;
+       return 0;
+}
+
+static int
+svcauth_gss_release(struct svc_rqst *rqstp)
+{
+       struct gss_svc_data *gsd = (struct gss_svc_data *)rqstp->rq_auth_data;
+       struct rpc_gss_wire_cred *gc = &gsd->clcred;
+       struct xdr_buf *resbuf = &rqstp->rq_res;
+       int stat = -EINVAL;
+
        if (gc->gc_proc != RPC_GSS_PROC_DATA)
                goto out;
        /* Release can be called twice, but we only wrap once. */
        if (gsd->body_start == NULL)
                goto out;
        /* normally not set till svc_send, but we need it here: */
-       resbuf->len = resbuf->head[0].iov_len
-               + resbuf->page_len + resbuf->tail[0].iov_len;
+       /* XXX: what for?  Do we mess it up the moment we call svc_putu32
+        * or whatever? */
+       resbuf->len = total_buf_len(resbuf);
        switch (gc->gc_svc) {
        case RPC_GSS_SVC_NONE:
                break;
        case RPC_GSS_SVC_INTEGRITY:
-               p = gsd->body_start;
-               gsd->body_start = NULL;
-               /* move accept_stat to right place: */
-               memcpy(p, p + 2, 4);
-               /* don't wrap in failure case: */
-               /* Note: counting on not getting here if call was not even
-                * accepted! */
-               if (*p != rpc_success) {
-                       resbuf->head[0].iov_len -= 2 * 4;
-                       goto out;
-               }
-               p++;
-               integ_offset = (u8 *)(p + 1) - (u8 *)resbuf->head[0].iov_base;
-               integ_len = resbuf->len - integ_offset;
-               BUG_ON(integ_len % 4);
-               *p++ = htonl(integ_len);
-               *p++ = htonl(gc->gc_seq);
-               if (xdr_buf_subsegment(resbuf, &integ_buf, integ_offset,
-                                       integ_len))
-                       BUG();
-               if (resbuf->page_len == 0
-                       && resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE
-                               < PAGE_SIZE) {
-                       BUG_ON(resbuf->tail[0].iov_len);
-                       /* Use head for everything */
-                       resv = &resbuf->head[0];
-               } else if (resbuf->tail[0].iov_base == NULL) {
-                       if (resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE
-                                       > PAGE_SIZE)
-                               goto out_err;
-                       resbuf->tail[0].iov_base =
-                               resbuf->head[0].iov_base
-                               + resbuf->head[0].iov_len;
-                       resbuf->tail[0].iov_len = 0;
-                       rqstp->rq_restailpage = 0;
-                       resv = &resbuf->tail[0];
-               } else {
-                       resv = &resbuf->tail[0];
-               }
-               mic.data = (u8 *)resv->iov_base + resv->iov_len + 4;
-               if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic))
+               stat = svcauth_gss_wrap_resp_integ(rqstp);
+               if (stat)
                        goto out_err;
-               svc_putu32(resv, htonl(mic.len));
-               memset(mic.data + mic.len, 0,
-                               round_up_to_quad(mic.len) - mic.len);
-               resv->iov_len += XDR_QUADLEN(mic.len) << 2;
-               /* not strictly required: */
-               resbuf->len += XDR_QUADLEN(mic.len) << 2;
-               BUG_ON(resv->iov_len > PAGE_SIZE);
                break;
        case RPC_GSS_SVC_PRIVACY:
+               stat = svcauth_gss_wrap_resp_priv(rqstp);
+               if (stat)
+                       goto out_err;
+               break;
        default:
                goto out_err;
        }
index b08419e..01ba60a 100644 (file)
@@ -280,7 +280,10 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
        rqstp->rq_res.page_base = 0;
        rqstp->rq_res.page_len = 0;
        rqstp->rq_res.buflen = PAGE_SIZE;
+       rqstp->rq_res.tail[0].iov_base = NULL;
        rqstp->rq_res.tail[0].iov_len = 0;
+       /* Will be turned off only in gss privacy case: */
+       rqstp->rq_sendfile_ok = 1;
        /* tcp needs a space for the record length... */
        if (rqstp->rq_prot == IPPROTO_TCP)
                svc_putu32(resv, 0);
index eddedf7..bbbfda7 100644 (file)
@@ -505,6 +505,9 @@ static int dummy_task_getsid (struct task_struct *p)
        return 0;
 }
 
+static void dummy_task_getsecid (struct task_struct *p, u32 *secid)
+{ }
+
 static int dummy_task_setgroups (struct group_info *group_info)
 {
        return 0;
@@ -520,6 +523,11 @@ static int dummy_task_setioprio (struct task_struct *p, int ioprio)
        return 0;
 }
 
+static int dummy_task_getioprio (struct task_struct *p)
+{
+       return 0;
+}
+
 static int dummy_task_setrlimit (unsigned int resource, struct rlimit *new_rlim)
 {
        return 0;
@@ -547,7 +555,7 @@ static int dummy_task_wait (struct task_struct *p)
 }
 
 static int dummy_task_kill (struct task_struct *p, struct siginfo *info,
-                           int sig)
+                           int sig, u32 secid)
 {
        return 0;
 }
@@ -980,9 +988,11 @@ void security_fixup_ops (struct security_operations *ops)
        set_to_dummy_if_null(ops, task_setpgid);
        set_to_dummy_if_null(ops, task_getpgid);
        set_to_dummy_if_null(ops, task_getsid);
+       set_to_dummy_if_null(ops, task_getsecid);
        set_to_dummy_if_null(ops, task_setgroups);
        set_to_dummy_if_null(ops, task_setnice);
        set_to_dummy_if_null(ops, task_setioprio);
+       set_to_dummy_if_null(ops, task_getioprio);
        set_to_dummy_if_null(ops, task_setrlimit);
        set_to_dummy_if_null(ops, task_setscheduler);
        set_to_dummy_if_null(ops, task_getscheduler);
index 3e59358..24caaee 100644 (file)
@@ -2643,6 +2643,11 @@ static int selinux_task_getsid(struct task_struct *p)
        return task_has_perm(current, p, PROCESS__GETSESSION);
 }
 
+static void selinux_task_getsecid(struct task_struct *p, u32 *secid)
+{
+       selinux_get_task_sid(p, secid);
+}
+
 static int selinux_task_setgroups(struct group_info *group_info)
 {
        /* See the comment for setuid above. */
@@ -2665,6 +2670,11 @@ static int selinux_task_setioprio(struct task_struct *p, int ioprio)
        return task_has_perm(current, p, PROCESS__SETSCHED);
 }
 
+static int selinux_task_getioprio(struct task_struct *p)
+{
+       return task_has_perm(current, p, PROCESS__GETSCHED);
+}
+
 static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
 {
        struct rlimit *old_rlim = current->signal->rlim + resource;
@@ -2699,12 +2709,14 @@ static int selinux_task_movememory(struct task_struct *p)
        return task_has_perm(current, p, PROCESS__SETSCHED);
 }
 
-static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int sig)
+static int selinux_task_kill(struct task_struct *p, struct siginfo *info,
+                               int sig, u32 secid)
 {
        u32 perm;
        int rc;
+       struct task_security_struct *tsec;
 
-       rc = secondary_ops->task_kill(p, info, sig);
+       rc = secondary_ops->task_kill(p, info, sig, secid);
        if (rc)
                return rc;
 
@@ -2715,8 +2727,12 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int si
                perm = PROCESS__SIGNULL; /* null signal; existence test */
        else
                perm = signal_to_av(sig);
-
-       return task_has_perm(current, p, perm);
+       tsec = p->security;
+       if (secid)
+               rc = avc_has_perm(secid, tsec->sid, SECCLASS_PROCESS, perm, NULL);
+       else
+               rc = task_has_perm(current, p, perm);
+       return rc;
 }
 
 static int selinux_task_prctl(int option,
@@ -4433,9 +4449,11 @@ static struct security_operations selinux_ops = {
        .task_setpgid =                 selinux_task_setpgid,
        .task_getpgid =                 selinux_task_getpgid,
        .task_getsid =                  selinux_task_getsid,
+       .task_getsecid =                selinux_task_getsecid,
        .task_setgroups =               selinux_task_setgroups,
        .task_setnice =                 selinux_task_setnice,
        .task_setioprio =               selinux_task_setioprio,
+       .task_getioprio =               selinux_task_getioprio,
        .task_setrlimit =               selinux_task_setrlimit,
        .task_setscheduler =            selinux_task_setscheduler,
        .task_getscheduler =            selinux_task_getscheduler,