aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/acpi_memhotplug.c17
-rw-r--r--drivers/acpi/asus_acpi.c35
-rw-r--r--drivers/acpi/dispatcher/dsfield.c37
-rw-r--r--drivers/acpi/dispatcher/dsinit.c51
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c360
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c37
-rw-r--r--drivers/acpi/dispatcher/dsobject.c106
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c58
-rw-r--r--drivers/acpi/dispatcher/dsutils.c33
-rw-r--r--drivers/acpi/dispatcher/dswexec.c80
-rw-r--r--drivers/acpi/dispatcher/dswload.c270
-rw-r--r--drivers/acpi/dispatcher/dswscope.c6
-rw-r--r--drivers/acpi/dispatcher/dswstate.c128
-rw-r--r--drivers/acpi/ec.c291
-rw-r--r--drivers/acpi/events/evevent.c63
-rw-r--r--drivers/acpi/events/evgpe.c54
-rw-r--r--drivers/acpi/events/evgpeblk.c215
-rw-r--r--drivers/acpi/events/evmisc.c26
-rw-r--r--drivers/acpi/events/evregion.c63
-rw-r--r--drivers/acpi/events/evrgnini.c8
-rw-r--r--drivers/acpi/events/evsci.c6
-rw-r--r--drivers/acpi/events/evxface.c19
-rw-r--r--drivers/acpi/events/evxfevnt.c34
-rw-r--r--drivers/acpi/events/evxfregn.c2
-rw-r--r--drivers/acpi/executer/exconfig.c8
-rw-r--r--drivers/acpi/executer/exconvrt.c36
-rw-r--r--drivers/acpi/executer/excreate.c6
-rw-r--r--drivers/acpi/executer/exdump.c671
-rw-r--r--drivers/acpi/executer/exfield.c11
-rw-r--r--drivers/acpi/executer/exfldio.c93
-rw-r--r--drivers/acpi/executer/exmisc.c113
-rw-r--r--drivers/acpi/executer/exmutex.c28
-rw-r--r--drivers/acpi/executer/exnames.c23
-rw-r--r--drivers/acpi/executer/exoparg1.c72
-rw-r--r--drivers/acpi/executer/exoparg2.c46
-rw-r--r--drivers/acpi/executer/exoparg3.c12
-rw-r--r--drivers/acpi/executer/exoparg6.c16
-rw-r--r--drivers/acpi/executer/exprep.c34
-rw-r--r--drivers/acpi/executer/exregion.c35
-rw-r--r--drivers/acpi/executer/exresnte.c51
-rw-r--r--drivers/acpi/executer/exresolv.c35
-rw-r--r--drivers/acpi/executer/exresop.c143
-rw-r--r--drivers/acpi/executer/exstore.c27
-rw-r--r--drivers/acpi/executer/exstoren.c24
-rw-r--r--drivers/acpi/executer/exstorob.c6
-rw-r--r--drivers/acpi/executer/exsystem.c6
-rw-r--r--drivers/acpi/executer/exutils.c20
-rw-r--r--drivers/acpi/glue.c8
-rw-r--r--drivers/acpi/hardware/hwacpi.c25
-rw-r--r--drivers/acpi/hardware/hwgpe.c2
-rw-r--r--drivers/acpi/hardware/hwregs.c59
-rw-r--r--drivers/acpi/hardware/hwsleep.c23
-rw-r--r--drivers/acpi/hardware/hwtimer.c2
-rw-r--r--drivers/acpi/motherboard.c30
-rw-r--r--drivers/acpi/namespace/nsaccess.c35
-rw-r--r--drivers/acpi/namespace/nsalloc.c11
-rw-r--r--drivers/acpi/namespace/nsdump.c13
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c2
-rw-r--r--drivers/acpi/namespace/nseval.c5
-rw-r--r--drivers/acpi/namespace/nsinit.c105
-rw-r--r--drivers/acpi/namespace/nsload.c10
-rw-r--r--drivers/acpi/namespace/nsnames.c14
-rw-r--r--drivers/acpi/namespace/nsobject.c13
-rw-r--r--drivers/acpi/namespace/nsparse.c2
-rw-r--r--drivers/acpi/namespace/nssearch.c30
-rw-r--r--drivers/acpi/namespace/nsutils.c43
-rw-r--r--drivers/acpi/namespace/nswalk.c2
-rw-r--r--drivers/acpi/namespace/nsxfeval.c29
-rw-r--r--drivers/acpi/namespace/nsxfname.c5
-rw-r--r--drivers/acpi/namespace/nsxfobj.c2
-rw-r--r--drivers/acpi/osl.c10
-rw-r--r--drivers/acpi/parser/psargs.c358
-rw-r--r--drivers/acpi/parser/psloop.c39
-rw-r--r--drivers/acpi/parser/psopcode.c4
-rw-r--r--drivers/acpi/parser/psparse.c55
-rw-r--r--drivers/acpi/parser/psscope.c2
-rw-r--r--drivers/acpi/parser/pstree.c5
-rw-r--r--drivers/acpi/parser/psutils.c2
-rw-r--r--drivers/acpi/parser/pswalk.c2
-rw-r--r--drivers/acpi/parser/psxface.c144
-rw-r--r--drivers/acpi/pci_irq.c48
-rw-r--r--drivers/acpi/pci_link.c100
-rw-r--r--drivers/acpi/pci_root.c8
-rw-r--r--drivers/acpi/processor_core.c30
-rw-r--r--drivers/acpi/processor_idle.c133
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/acpi/processor_thermal.c7
-rw-r--r--drivers/acpi/processor_throttling.c7
-rw-r--r--drivers/acpi/resources/Makefile2
-rw-r--r--drivers/acpi/resources/rsaddr.c1164
-rw-r--r--drivers/acpi/resources/rscalc.c831
-rw-r--r--drivers/acpi/resources/rscreate.c231
-rw-r--r--drivers/acpi/resources/rsdump.c1399
-rw-r--r--drivers/acpi/resources/rsinfo.c204
-rw-r--r--drivers/acpi/resources/rsio.c544
-rw-r--r--drivers/acpi/resources/rsirq.c568
-rw-r--r--drivers/acpi/resources/rslist.c534
-rw-r--r--drivers/acpi/resources/rsmemory.c517
-rw-r--r--drivers/acpi/resources/rsmisc.c860
-rw-r--r--drivers/acpi/resources/rsutils.c390
-rw-r--r--drivers/acpi/resources/rsxface.c230
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/sleep/poweroff.c15
-rw-r--r--drivers/acpi/sleep/sleep.h2
-rw-r--r--drivers/acpi/sleep/wakeup.c6
-rw-r--r--drivers/acpi/tables/tbconvrt.c23
-rw-r--r--drivers/acpi/tables/tbget.c39
-rw-r--r--drivers/acpi/tables/tbgetall.c27
-rw-r--r--drivers/acpi/tables/tbinstal.c12
-rw-r--r--drivers/acpi/tables/tbrsdt.c30
-rw-r--r--drivers/acpi/tables/tbutils.c50
-rw-r--r--drivers/acpi/tables/tbxface.c18
-rw-r--r--drivers/acpi/tables/tbxfroot.c35
-rw-r--r--drivers/acpi/utilities/Makefile5
-rw-r--r--drivers/acpi/utilities/utalloc.c61
-rw-r--r--drivers/acpi/utilities/utcache.c2
-rw-r--r--drivers/acpi/utilities/utcopy.c27
-rw-r--r--drivers/acpi/utilities/utdebug.c2
-rw-r--r--drivers/acpi/utilities/utdelete.c15
-rw-r--r--drivers/acpi/utilities/uteval.c46
-rw-r--r--drivers/acpi/utilities/utglobal.c108
-rw-r--r--drivers/acpi/utilities/utinit.c13
-rw-r--r--drivers/acpi/utilities/utmath.c10
-rw-r--r--drivers/acpi/utilities/utmisc.c209
-rw-r--r--drivers/acpi/utilities/utmutex.c58
-rw-r--r--drivers/acpi/utilities/utobject.c33
-rw-r--r--drivers/acpi/utilities/utresrc.c554
-rw-r--r--drivers/acpi/utilities/utstate.c4
-rw-r--r--drivers/acpi/utilities/utxface.c69
-rw-r--r--drivers/acpi/video.c8
-rw-r--r--drivers/base/Makefile1
-rw-r--r--drivers/base/topology.c148
-rw-r--r--drivers/block/umem.c2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/cyclades.c6
-rw-r--r--drivers/char/drm/ati_pcigart.c17
-rw-r--r--drivers/char/drm/drmP.h5
-rw-r--r--drivers/char/drm/drm_auth.c20
-rw-r--r--drivers/char/drm/drm_bufs.c80
-rw-r--r--drivers/char/drm/drm_context.c52
-rw-r--r--drivers/char/drm/drm_drv.c4
-rw-r--r--drivers/char/drm/drm_fops.c12
-rw-r--r--drivers/char/drm/drm_ioctl.c18
-rw-r--r--drivers/char/drm/drm_irq.c16
-rw-r--r--drivers/char/drm/drm_pciids.h2
-rw-r--r--drivers/char/drm/drm_proc.c28
-rw-r--r--drivers/char/drm/drm_stub.c4
-rw-r--r--drivers/char/drm/drm_vm.c12
-rw-r--r--drivers/char/drm/i810_dma.c2
-rw-r--r--drivers/char/drm/i810_drv.h2
-rw-r--r--drivers/char/drm/i830_dma.c2
-rw-r--r--drivers/char/drm/i830_drv.h3
-rw-r--r--drivers/char/drm/i915_dma.c42
-rw-r--r--drivers/char/drm/i915_drm.h33
-rw-r--r--drivers/char/drm/i915_drv.h6
-rw-r--r--drivers/char/drm/i915_mem.c31
-rw-r--r--drivers/char/drm/radeon_cp.c2
-rw-r--r--drivers/char/drm/savage_bci.c4
-rw-r--r--drivers/char/drm/savage_drv.h1
-rw-r--r--drivers/char/drm/via_dma.c10
-rw-r--r--drivers/char/drm/via_dmablit.c6
-rw-r--r--drivers/char/drm/via_drv.h7
-rw-r--r--drivers/char/drm/via_irq.c2
-rw-r--r--drivers/char/esp.c4
-rw-r--r--drivers/char/hangcheck-timer.c12
-rw-r--r--drivers/char/hpet.c26
-rw-r--r--drivers/char/ip2/i2cmd.c1
-rw-r--r--drivers/char/ip2main.c67
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c4
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c32
-rw-r--r--drivers/char/rio/cirrus.h142
-rw-r--r--drivers/char/rio/defaults.h7
-rw-r--r--drivers/char/rio/link.h34
-rw-r--r--drivers/char/rio/list.h140
-rw-r--r--drivers/char/rio/parmmap.h5
-rw-r--r--drivers/char/rio/phb.h133
-rw-r--r--drivers/char/rio/pkt.h27
-rw-r--r--drivers/char/rio/qbuf.h4
-rw-r--r--drivers/char/rio/riotypes.h66
-rw-r--r--drivers/char/rio/rup.h5
-rw-r--r--drivers/char/rio/sam.h4
-rw-r--r--drivers/char/rocket.c2
-rw-r--r--drivers/char/sx.c6
-rw-r--r--drivers/char/tpm/tpm_bios.c25
-rw-r--r--drivers/char/tpm/tpm_infineon.c2
-rw-r--r--drivers/char/tty_io.c77
-rw-r--r--drivers/char/vt.c1
-rw-r--r--drivers/char/watchdog/sbc_epx_c3.c13
-rw-r--r--drivers/edac/Kconfig2
-rw-r--r--drivers/edac/e752x_edac.c8
-rw-r--r--drivers/edac/edac_mc.c1
-rw-r--r--drivers/ide/Kconfig25
-rw-r--r--drivers/ide/ide-disk.c8
-rw-r--r--drivers/ide/ide-io.c5
-rw-r--r--drivers/ide/ide-iops.c1
-rw-r--r--drivers/ide/ide-probe.c51
-rw-r--r--drivers/ide/ide.c1
-rw-r--r--drivers/ide/pci/aec62xx.c15
-rw-r--r--drivers/ide/pci/hpt366.c4
-rw-r--r--drivers/ide/pci/it821x.c2
-rw-r--r--drivers/ide/pci/pdc202xx_new.c6
-rw-r--r--drivers/ide/pci/pdc202xx_old.c15
-rw-r--r--drivers/ide/pci/piix.c4
-rw-r--r--drivers/ide/pci/sgiioc4.c9
-rw-r--r--drivers/isdn/hisax/hisax.h2
-rw-r--r--drivers/isdn/sc/ioctl.c4
-rw-r--r--drivers/macintosh/macio_asic.c72
-rw-r--r--drivers/md/dm-ioctl.c14
-rw-r--r--drivers/md/dm-log.c48
-rw-r--r--drivers/md/dm-snap.c29
-rw-r--r--drivers/md/dm-snap.h4
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/md/dm.c39
-rw-r--r--drivers/md/md.c48
-rw-r--r--drivers/md/raid0.c2
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/md/raid5.c3
-rw-r--r--drivers/md/raid6main.c152
-rw-r--r--drivers/media/video/hexium_orion.c2
-rw-r--r--drivers/message/i2o/core.h3
-rw-r--r--drivers/message/i2o/pci.c47
-rw-r--r--drivers/mtd/maps/dc21285.c9
-rw-r--r--drivers/mtd/maps/tsunami_flash.c2
-rw-r--r--drivers/net/3c59x.c33
-rw-r--r--drivers/net/lp486e.c2
-rw-r--r--drivers/net/tg3.c30
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/wireless/ipw2200.c2
-rw-r--r--drivers/parport/Kconfig9
-rw-r--r--drivers/parport/Makefile1
-rw-r--r--drivers/parport/ieee1284.c10
-rw-r--r--drivers/parport/parport_ip32.c2253
-rw-r--r--drivers/parport/parport_serial.c4
-rw-r--r--drivers/parport/probe.c4
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c1
-rw-r--r--drivers/pnp/card.c9
-rw-r--r--drivers/pnp/pnpacpi/core.c14
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c547
-rw-r--r--drivers/s390/Kconfig7
-rw-r--r--drivers/s390/block/Kconfig14
-rw-r--r--drivers/s390/block/Makefile2
-rw-r--r--drivers/s390/block/dasd.c122
-rw-r--r--drivers/s390/block/dasd_3370_erp.c1
-rw-r--r--drivers/s390/block/dasd_3990_erp.c4
-rw-r--r--drivers/s390/block/dasd_9336_erp.c1
-rw-r--r--drivers/s390/block/dasd_9343_erp.c1
-rw-r--r--drivers/s390/block/dasd_cmb.c2
-rw-r--r--drivers/s390/block/dasd_devmap.c1
-rw-r--r--drivers/s390/block/dasd_diag.c1
-rw-r--r--drivers/s390/block/dasd_diag.h1
-rw-r--r--drivers/s390/block/dasd_eckd.c1
-rw-r--r--drivers/s390/block/dasd_eckd.h2
-rw-r--r--drivers/s390/block/dasd_eer.c1090
-rw-r--r--drivers/s390/block/dasd_erp.c1
-rw-r--r--drivers/s390/block/dasd_fba.c1
-rw-r--r--drivers/s390/block/dasd_fba.h1
-rw-r--r--drivers/s390/block/dasd_genhd.c1
-rw-r--r--drivers/s390/block/dasd_int.h38
-rw-r--r--drivers/s390/block/dasd_ioctl.c11
-rw-r--r--drivers/s390/block/dasd_proc.c1
-rw-r--r--drivers/s390/char/con3215.c3
-rw-r--r--drivers/s390/char/con3270.c3
-rw-r--r--drivers/s390/char/keyboard.c6
-rw-r--r--drivers/s390/char/tape_34xx.c5
-rw-r--r--drivers/s390/char/tape_class.c4
-rw-r--r--drivers/s390/char/tape_class.h2
-rw-r--r--drivers/s390/char/tape_core.c5
-rw-r--r--drivers/s390/cio/airq.c2
-rw-r--r--drivers/s390/cio/blacklist.c1
-rw-r--r--drivers/s390/cio/ccwgroup.c1
-rw-r--r--drivers/s390/cio/chsc.c1
-rw-r--r--drivers/s390/cio/chsc.h2
-rw-r--r--drivers/s390/cio/cio.c1
-rw-r--r--drivers/s390/cio/cmf.c2
-rw-r--r--drivers/s390/cio/css.c1
-rw-r--r--drivers/s390/cio/device.c5
-rw-r--r--drivers/s390/cio/device_ops.c2
-rw-r--r--drivers/s390/cio/qdio.c5
-rw-r--r--drivers/s390/cio/qdio.h2
-rw-r--r--drivers/s390/crypto/z90common.h2
-rw-r--r--drivers/s390/crypto/z90crypt.h2
-rw-r--r--drivers/s390/crypto/z90hardware.c6
-rw-r--r--drivers/s390/crypto/z90main.c10
-rw-r--r--drivers/s390/net/claw.c11
-rw-r--r--drivers/s390/net/claw.h2
-rw-r--r--drivers/s390/net/ctcdbug.c5
-rw-r--r--drivers/s390/net/ctcdbug.h4
-rw-r--r--drivers/s390/net/ctcmain.c19
-rw-r--r--drivers/s390/net/ctcmain.h4
-rw-r--r--drivers/s390/net/ctctty.c2
-rw-r--r--drivers/s390/net/ctctty.h2
-rw-r--r--drivers/s390/net/cu3088.c2
-rw-r--r--drivers/s390/net/fsm.c2
-rw-r--r--drivers/s390/net/fsm.h2
-rw-r--r--drivers/s390/net/iucv.c16
-rw-r--r--drivers/s390/net/lcs.c5
-rw-r--r--drivers/s390/net/lcs.h2
-rw-r--r--drivers/s390/net/netiucv.c15
-rw-r--r--drivers/s390/net/qeth.h2
-rw-r--r--drivers/s390/net/qeth_eddp.c5
-rw-r--r--drivers/s390/net/qeth_eddp.h6
-rw-r--r--drivers/s390/net/qeth_fs.h5
-rw-r--r--drivers/s390/net/qeth_main.c13
-rw-r--r--drivers/s390/net/qeth_mpc.c2
-rw-r--r--drivers/s390/net/qeth_mpc.h4
-rw-r--r--drivers/s390/net/qeth_proc.c4
-rw-r--r--drivers/s390/net/qeth_sys.c4
-rw-r--r--drivers/s390/net/qeth_tso.h4
-rw-r--r--drivers/s390/s390_rdev.c1
-rw-r--r--drivers/s390/s390mach.h17
-rw-r--r--drivers/s390/scsi/zfcp_aux.c2
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c2
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c2
-rw-r--r--drivers/s390/scsi/zfcp_def.h2
-rw-r--r--drivers/s390/scsi/zfcp_erp.c2
-rw-r--r--drivers/s390/scsi/zfcp_ext.h2
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c2
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c2
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_adapter.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_driver.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_port.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_unit.c2
-rw-r--r--drivers/scsi/ide-scsi.c14
-rw-r--r--drivers/serial/8250_acpi.c22
-rw-r--r--drivers/serial/Kconfig28
-rw-r--r--drivers/serial/jsm/jsm.h1
-rw-r--r--drivers/serial/jsm/jsm_driver.c3
-rw-r--r--drivers/serial/jsm/jsm_neo.c85
-rw-r--r--drivers/serial/jsm/jsm_tty.c209
-rw-r--r--drivers/serial/mcfserial.c3
-rw-r--r--drivers/serial/sh-sci.c225
-rw-r--r--drivers/serial/sh-sci.h114
-rw-r--r--drivers/sn/ioc3.c12
-rw-r--r--drivers/telephony/ixj.c14
-rw-r--r--drivers/video/backlight/Kconfig8
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/hp680_bl.c189
-rw-r--r--drivers/video/i810/i810-i2c.c6
-rw-r--r--drivers/video/i810/i810.h1
-rw-r--r--drivers/video/i810/i810_main.c13
342 files changed, 12237 insertions, 9157 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 6d61945260a8..0cce28c4025b 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -267,7 +267,6 @@ config ACPI_DEBUG
267 267
268config ACPI_EC 268config ACPI_EC
269 bool 269 bool
270 depends on X86
271 default y 270 default y
272 help 271 help
273 This driver is required on some systems for the proper operation of 272 This driver is required on some systems for the proper operation of
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 2143609d2936..d882bf87fa96 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -71,8 +71,8 @@ static struct acpi_driver acpi_memory_device_driver = {
71struct acpi_memory_device { 71struct acpi_memory_device {
72 acpi_handle handle; 72 acpi_handle handle;
73 unsigned int state; /* State of the memory device */ 73 unsigned int state; /* State of the memory device */
74 unsigned short cache_attribute; /* memory cache attribute */ 74 unsigned short caching; /* memory cache attribute */
75 unsigned short read_write_attribute; /* memory read/write attribute */ 75 unsigned short write_protect; /* memory read/write attribute */
76 u64 start_addr; /* Memory Range start physical addr */ 76 u64 start_addr; /* Memory Range start physical addr */
77 u64 end_addr; /* Memory Range end physical addr */ 77 u64 end_addr; /* Memory Range end physical addr */
78}; 78};
@@ -97,12 +97,12 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
97 if (ACPI_SUCCESS(status)) { 97 if (ACPI_SUCCESS(status)) {
98 if (address64.resource_type == ACPI_MEMORY_RANGE) { 98 if (address64.resource_type == ACPI_MEMORY_RANGE) {
99 /* Populate the structure */ 99 /* Populate the structure */
100 mem_device->cache_attribute = 100 mem_device->caching =
101 address64.attribute.memory.cache_attribute; 101 address64.info.mem.caching;
102 mem_device->read_write_attribute = 102 mem_device->write_protect =
103 address64.attribute.memory.read_write_attribute; 103 address64.info.mem.write_protect;
104 mem_device->start_addr = address64.min_address_range; 104 mem_device->start_addr = address64.minimum;
105 mem_device->end_addr = address64.max_address_range; 105 mem_device->end_addr = address64.maximum;
106 } 106 }
107 } 107 }
108 108
@@ -250,7 +250,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
250 int result; 250 int result;
251 u64 start = mem_device->start_addr; 251 u64 start = mem_device->start_addr;
252 u64 len = mem_device->end_addr - start + 1; 252 u64 len = mem_device->end_addr - start + 1;
253 unsigned long attr = mem_device->read_write_attribute;
254 253
255 ACPI_FUNCTION_TRACE("acpi_memory_disable_device"); 254 ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
256 255
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index fec895af6ae6..f4c87750dbf2 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -78,9 +78,9 @@ MODULE_LICENSE("GPL");
78static uid_t asus_uid; 78static uid_t asus_uid;
79static gid_t asus_gid; 79static gid_t asus_gid;
80module_param(asus_uid, uint, 0); 80module_param(asus_uid, uint, 0);
81MODULE_PARM_DESC(uid, "UID for entries in /proc/acpi/asus.\n"); 81MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus.\n");
82module_param(asus_gid, uint, 0); 82module_param(asus_gid, uint, 0);
83MODULE_PARM_DESC(gid, "GID for entries in /proc/acpi/asus.\n"); 83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus.\n");
84 84
85/* For each model, all features implemented, 85/* For each model, all features implemented,
86 * those marked with R are relative to HOTK, A for absolute */ 86 * those marked with R are relative to HOTK, A for absolute */
@@ -302,7 +302,7 @@ static struct model_data model_conf[END_MODEL] = {
302 .brightness_set = "SPLV", 302 .brightness_set = "SPLV",
303 .brightness_get = "GPLV", 303 .brightness_get = "GPLV",
304 .display_set = "SDSP", 304 .display_set = "SDSP",
305 .display_get = "\\SSTE"}, 305 .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
306 { 306 {
307 .name = "M6R", 307 .name = "M6R",
308 .mt_mled = "MLED", 308 .mt_mled = "MLED",
@@ -851,6 +851,8 @@ static int __init asus_hotk_add_fs(struct acpi_device *device)
851 mode = S_IFREG | S_IRUGO | S_IWUGO; 851 mode = S_IFREG | S_IRUGO | S_IWUGO;
852 } else { 852 } else {
853 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP; 853 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
854 printk(KERN_WARNING " asus_uid and asus_gid parameters are "
855 "deprecated, use chown and chmod instead!\n");
854 } 856 }
855 857
856 acpi_device_dir(device) = asus_proc_dir; 858 acpi_device_dir(device) = asus_proc_dir;
@@ -987,9 +989,21 @@ static int __init asus_hotk_get_info(void)
987 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n", 989 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n",
988 bsts_result); 990 bsts_result);
989 991
990 /* Samsung P30 has a device with a valid _HID whose INIT does not 992 /* This is unlikely with implicit return */
991 * return anything. Catch this one and any similar here */ 993 if (buffer.pointer == NULL)
992 if (buffer.pointer == NULL) { 994 return -EINVAL;
995
996 model = (union acpi_object *) buffer.pointer;
997 /*
998 * Samsung P30 has a device with a valid _HID whose INIT does not
999 * return anything. It used to be possible to catch this exception,
1000 * but the implicit return code will now happily confuse the
1001 * driver. We assume that every ACPI_TYPE_STRING is a valid model
1002 * identifier but it's still possible to get completely bogus data.
1003 */
1004 if (model->type == ACPI_TYPE_STRING) {
1005 printk(KERN_NOTICE " %s model detected, ", model->string.pointer);
1006 } else {
993 if (asus_info && /* Samsung P30 */ 1007 if (asus_info && /* Samsung P30 */
994 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) { 1008 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) {
995 hotk->model = P30; 1009 hotk->model = P30;
@@ -1002,13 +1016,10 @@ static int __init asus_hotk_get_info(void)
1002 "the developers with your DSDT\n"); 1016 "the developers with your DSDT\n");
1003 } 1017 }
1004 hotk->methods = &model_conf[hotk->model]; 1018 hotk->methods = &model_conf[hotk->model];
1005 return AE_OK; 1019
1006 } 1020 acpi_os_free(model);
1007 1021
1008 model = (union acpi_object *)buffer.pointer; 1022 return AE_OK;
1009 if (model->type == ACPI_TYPE_STRING) {
1010 printk(KERN_NOTICE " %s model detected, ",
1011 model->string.pointer);
1012 } 1023 }
1013 1024
1014 hotk->model = END_MODEL; 1025 hotk->model = END_MODEL;
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c
index 2022aeaecfbb..76bc0463f6de 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/dispatcher/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -128,7 +128,7 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
128 ACPI_IMODE_LOAD_PASS1, flags, walk_state, 128 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
129 &(node)); 129 &(node));
130 if (ACPI_FAILURE(status)) { 130 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_NSERROR(arg->common.value.string, status); 131 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
132 return_ACPI_STATUS(status); 132 return_ACPI_STATUS(status);
133 } 133 }
134 } 134 }
@@ -232,7 +232,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
232 + (acpi_integer) arg->common.value.size; 232 + (acpi_integer) arg->common.value.size;
233 233
234 if (position > ACPI_UINT32_MAX) { 234 if (position > ACPI_UINT32_MAX) {
235 ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n")); 235 ACPI_ERROR((AE_INFO,
236 "Bit offset within field too large (> 0xFFFFFFFF)"));
236 return_ACPI_STATUS(AE_SUPPORT); 237 return_ACPI_STATUS(AE_SUPPORT);
237 } 238 }
238 239
@@ -268,8 +269,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
268 ACPI_NS_DONT_OPEN_SCOPE, 269 ACPI_NS_DONT_OPEN_SCOPE,
269 walk_state, &info->field_node); 270 walk_state, &info->field_node);
270 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
271 ACPI_REPORT_NSERROR((char *)&arg->named.name, 272 ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
272 status); 273 status);
273 if (status != AE_ALREADY_EXISTS) { 274 if (status != AE_ALREADY_EXISTS) {
274 return_ACPI_STATUS(status); 275 return_ACPI_STATUS(status);
275 } 276 }
@@ -293,7 +294,11 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
293 + (acpi_integer) arg->common.value.size; 294 + (acpi_integer) arg->common.value.size;
294 295
295 if (position > ACPI_UINT32_MAX) { 296 if (position > ACPI_UINT32_MAX) {
296 ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *)&info->field_node->name)); 297 ACPI_ERROR((AE_INFO,
298 "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
299 ACPI_CAST_PTR(char,
300 &info->field_node->
301 name)));
297 return_ACPI_STATUS(AE_SUPPORT); 302 return_ACPI_STATUS(AE_SUPPORT);
298 } 303 }
299 304
@@ -302,9 +307,9 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
302 307
303 default: 308 default:
304 309
305 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 310 ACPI_ERROR((AE_INFO,
306 "Invalid opcode in field list: %X\n", 311 "Invalid opcode in field list: %X",
307 arg->common.aml_opcode)); 312 arg->common.aml_opcode));
308 return_ACPI_STATUS(AE_AML_BAD_OPCODE); 313 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
309 } 314 }
310 315
@@ -349,7 +354,7 @@ acpi_ds_create_field(union acpi_parse_object *op,
349 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 354 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
350 walk_state, &region_node); 355 walk_state, &region_node);
351 if (ACPI_FAILURE(status)) { 356 if (ACPI_FAILURE(status)) {
352 ACPI_REPORT_NSERROR(arg->common.value.name, status); 357 ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
353 return_ACPI_STATUS(status); 358 return_ACPI_STATUS(status);
354 } 359 }
355 } 360 }
@@ -431,8 +436,8 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
431 ACPI_NS_ERROR_IF_FOUND, 436 ACPI_NS_ERROR_IF_FOUND,
432 walk_state, &node); 437 walk_state, &node);
433 if (ACPI_FAILURE(status)) { 438 if (ACPI_FAILURE(status)) {
434 ACPI_REPORT_NSERROR((char *)&arg->named.name, 439 ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
435 status); 440 status);
436 if (status != AE_ALREADY_EXISTS) { 441 if (status != AE_ALREADY_EXISTS) {
437 return_ACPI_STATUS(status); 442 return_ACPI_STATUS(status);
438 } 443 }
@@ -488,7 +493,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
488 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 493 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
489 walk_state, &region_node); 494 walk_state, &region_node);
490 if (ACPI_FAILURE(status)) { 495 if (ACPI_FAILURE(status)) {
491 ACPI_REPORT_NSERROR(arg->common.value.name, status); 496 ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
492 return_ACPI_STATUS(status); 497 return_ACPI_STATUS(status);
493 } 498 }
494 } 499 }
@@ -502,7 +507,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
502 ACPI_NS_SEARCH_PARENT, walk_state, 507 ACPI_NS_SEARCH_PARENT, walk_state,
503 &info.register_node); 508 &info.register_node);
504 if (ACPI_FAILURE(status)) { 509 if (ACPI_FAILURE(status)) {
505 ACPI_REPORT_NSERROR(arg->common.value.string, status); 510 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
506 return_ACPI_STATUS(status); 511 return_ACPI_STATUS(status);
507 } 512 }
508 513
@@ -560,7 +565,7 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
560 ACPI_NS_SEARCH_PARENT, walk_state, 565 ACPI_NS_SEARCH_PARENT, walk_state,
561 &info.register_node); 566 &info.register_node);
562 if (ACPI_FAILURE(status)) { 567 if (ACPI_FAILURE(status)) {
563 ACPI_REPORT_NSERROR(arg->common.value.string, status); 568 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
564 return_ACPI_STATUS(status); 569 return_ACPI_STATUS(status);
565 } 570 }
566 571
@@ -573,7 +578,7 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
573 ACPI_NS_SEARCH_PARENT, walk_state, 578 ACPI_NS_SEARCH_PARENT, walk_state,
574 &info.data_register_node); 579 &info.data_register_node);
575 if (ACPI_FAILURE(status)) { 580 if (ACPI_FAILURE(status)) {
576 ACPI_REPORT_NSERROR(arg->common.value.string, status); 581 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
577 return_ACPI_STATUS(status); 582 return_ACPI_STATUS(status);
578 } 583 }
579 584
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index 8693c704aea6..e65a07ad2422 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -84,7 +84,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
84 acpi_object_type type; 84 acpi_object_type type;
85 acpi_status status; 85 acpi_status status;
86 86
87 ACPI_FUNCTION_NAME("ds_init_one_object"); 87 ACPI_FUNCTION_ENTRY();
88 88
89 /* 89 /*
90 * We are only interested in NS nodes owned by the table that 90 * We are only interested in NS nodes owned by the table that
@@ -105,11 +105,10 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
105 105
106 status = acpi_ds_initialize_region(obj_handle); 106 status = acpi_ds_initialize_region(obj_handle);
107 if (ACPI_FAILURE(status)) { 107 if (ACPI_FAILURE(status)) {
108 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 108 ACPI_EXCEPTION((AE_INFO, status,
109 "Region %p [%4.4s] - Init failure, %s\n", 109 "During Region initialization %p [%4.4s]",
110 obj_handle, 110 obj_handle,
111 acpi_ut_get_node_name(obj_handle), 111 acpi_ut_get_node_name(obj_handle)));
112 acpi_format_exception(status)));
113 } 112 }
114 113
115 info->op_region_count++; 114 info->op_region_count++;
@@ -118,14 +117,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
118 case ACPI_TYPE_METHOD: 117 case ACPI_TYPE_METHOD:
119 118
120 /* 119 /*
121 * Print a dot for each method unless we are going to print
122 * the entire pathname
123 */
124 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
125 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
126 }
127
128 /*
129 * Set the execution data width (32 or 64) based upon the 120 * Set the execution data width (32 or 64) based upon the
130 * revision number of the parent ACPI table. 121 * revision number of the parent ACPI table.
131 * TBD: This is really for possible future support of integer width 122 * TBD: This is really for possible future support of integer width
@@ -134,6 +125,21 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
134 if (info->table_desc->pointer->revision == 1) { 125 if (info->table_desc->pointer->revision == 1) {
135 node->flags |= ANOBJ_DATA_WIDTH_32; 126 node->flags |= ANOBJ_DATA_WIDTH_32;
136 } 127 }
128#ifdef ACPI_INIT_PARSE_METHODS
129 /*
130 * Note 11/2005: Removed this code to parse all methods during table
131 * load because it causes problems if there are any errors during the
132 * parse. Also, it seems like overkill and we probably don't want to
133 * abort a table load because of an issue with a single method.
134 */
135
136 /*
137 * Print a dot for each method unless we are going to print
138 * the entire pathname
139 */
140 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
141 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
142 }
137 143
138 /* 144 /*
139 * Always parse methods to detect errors, we will delete 145 * Always parse methods to detect errors, we will delete
@@ -141,15 +147,15 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
141 */ 147 */
142 status = acpi_ds_parse_method(obj_handle); 148 status = acpi_ds_parse_method(obj_handle);
143 if (ACPI_FAILURE(status)) { 149 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 150 ACPI_ERROR((AE_INFO,
145 "\n+Method %p [%4.4s] - parse failure, %s\n", 151 "Method %p [%4.4s] - parse failure, %s",
146 obj_handle, 152 obj_handle,
147 acpi_ut_get_node_name(obj_handle), 153 acpi_ut_get_node_name(obj_handle),
148 acpi_format_exception(status))); 154 acpi_format_exception(status)));
149 155
150 /* This parse failed, but we will continue parsing more methods */ 156 /* This parse failed, but we will continue parsing more methods */
151 } 157 }
152 158#endif
153 info->method_count++; 159 info->method_count++;
154 break; 160 break;
155 161
@@ -207,8 +213,7 @@ acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
207 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, 213 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
208 acpi_ds_init_one_object, &info, NULL); 214 acpi_ds_init_one_object, &info, NULL);
209 if (ACPI_FAILURE(status)) { 215 if (ACPI_FAILURE(status)) {
210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n", 216 ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
211 acpi_format_exception(status)));
212 } 217 }
213 218
214 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 219 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 36c1ca0b9adb..c475546535b6 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,135 +47,66 @@
47#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
50#include <acpi/acdisasm.h>
50 51
51#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsmethod") 53ACPI_MODULE_NAME("dsmethod")
53 54
54/******************************************************************************* 55/*******************************************************************************
55 * 56 *
56 * FUNCTION: acpi_ds_parse_method 57 * FUNCTION: acpi_ds_method_error
57 * 58 *
58 * PARAMETERS: Node - Method node 59 * PARAMETERS: Status - Execution status
60 * walk_state - Current state
59 * 61 *
60 * RETURN: Status 62 * RETURN: Status
61 * 63 *
62 * DESCRIPTION: Parse the AML that is associated with the method. 64 * DESCRIPTION: Called on method error. Invoke the global exception handler if
65 * present, dump the method data if the disassembler is configured
63 * 66 *
64 * MUTEX: Assumes parser is locked 67 * Note: Allows the exception handler to change the status code
65 * 68 *
66 ******************************************************************************/ 69 ******************************************************************************/
67acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) 70acpi_status
71acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
68{ 72{
69 acpi_status status; 73 ACPI_FUNCTION_ENTRY();
70 union acpi_operand_object *obj_desc;
71 union acpi_parse_object *op;
72 struct acpi_walk_state *walk_state;
73
74 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
75 74
76 /* Parameter Validation */ 75 /* Ignore AE_OK and control exception codes */
77 76
78 if (!node) { 77 if (ACPI_SUCCESS(status) || (status & AE_CODE_CONTROL)) {
79 return_ACPI_STATUS(AE_NULL_ENTRY); 78 return (status);
80 } 79 }
81 80
82 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 81 /* Invoke the global exception handler */
83 "**** Parsing [%4.4s] **** named_obj=%p\n",
84 acpi_ut_get_node_name(node), node));
85
86 /* Extract the method object from the method Node */
87 82
88 obj_desc = acpi_ns_get_attached_object(node); 83 if (acpi_gbl_exception_handler) {
89 if (!obj_desc) { 84 /* Exit the interpreter, allow handler to execute methods */
90 return_ACPI_STATUS(AE_NULL_OBJECT);
91 }
92 85
93 /* Create a mutex for the method if there is a concurrency limit */ 86 acpi_ex_exit_interpreter();
94 87
95 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && 88 /*
96 (!obj_desc->method.semaphore)) { 89 * Handler can map the exception code to anything it wants, including
97 status = acpi_os_create_semaphore(obj_desc->method.concurrency, 90 * AE_OK, in which case the executing method will not be aborted.
98 obj_desc->method.concurrency, 91 */
99 &obj_desc->method.semaphore); 92 status = acpi_gbl_exception_handler(status,
100 if (ACPI_FAILURE(status)) { 93 walk_state->method_node ?
101 return_ACPI_STATUS(status); 94 walk_state->method_node->
102 } 95 name.integer : 0,
103 } 96 walk_state->opcode,
104 97 walk_state->aml_offset,
105 /* 98 NULL);
106 * Allocate a new parser op to be the root of the parsed 99 (void)acpi_ex_enter_interpreter();
107 * method tree
108 */
109 op = acpi_ps_alloc_op(AML_METHOD_OP);
110 if (!op) {
111 return_ACPI_STATUS(AE_NO_MEMORY);
112 }
113
114 /* Init new op with the method name and pointer back to the Node */
115
116 acpi_ps_set_name(op, node->name.integer);
117 op->common.node = node;
118
119 /*
120 * Get a new owner_id for objects created by this method. Namespace
121 * objects (such as Operation Regions) can be created during the
122 * first pass parse.
123 */
124 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
125 if (ACPI_FAILURE(status)) {
126 goto cleanup;
127 }
128
129 /* Create and initialize a new walk state */
130
131 walk_state =
132 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
133 NULL);
134 if (!walk_state) {
135 status = AE_NO_MEMORY;
136 goto cleanup2;
137 } 100 }
138 101#ifdef ACPI_DISASSEMBLER
139 status = acpi_ds_init_aml_walk(walk_state, op, node,
140 obj_desc->method.aml_start,
141 obj_desc->method.aml_length, NULL, 1);
142 if (ACPI_FAILURE(status)) { 102 if (ACPI_FAILURE(status)) {
143 acpi_ds_delete_walk_state(walk_state); 103 /* Display method locals/args if disassembler is present */
144 goto cleanup2;
145 }
146 104
147 /* 105 acpi_dm_dump_method_info(status, walk_state, walk_state->op);
148 * Parse the method, first pass
149 *
150 * The first pass load is where newly declared named objects are added into
151 * the namespace. Actual evaluation of the named objects (what would be
152 * called a "second pass") happens during the actual execution of the
153 * method so that operands to the named objects can take on dynamic
154 * run-time values.
155 */
156 status = acpi_ps_parse_aml(walk_state);
157 if (ACPI_FAILURE(status)) {
158 goto cleanup2;
159 } 106 }
107#endif
160 108
161 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 109 return (status);
162 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
163 acpi_ut_get_node_name(node), node, op));
164
165 /*
166 * Delete the parse tree. We simply re-parse the method for every
167 * execution since there isn't much overhead (compared to keeping lots
168 * of parse trees around)
169 */
170 acpi_ns_delete_namespace_subtree(node);
171 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
172
173 cleanup2:
174 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
175
176 cleanup:
177 acpi_ps_delete_parse_tree(op);
178 return_ACPI_STATUS(status);
179} 110}
180 111
181/******************************************************************************* 112/*******************************************************************************
@@ -195,9 +126,9 @@ acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
195 ******************************************************************************/ 126 ******************************************************************************/
196 127
197acpi_status 128acpi_status
198acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, 129acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
199 union acpi_operand_object *obj_desc, 130 union acpi_operand_object * obj_desc,
200 struct acpi_namespace_node *calling_method_node) 131 struct acpi_namespace_node * calling_method_node)
201{ 132{
202 acpi_status status = AE_OK; 133 acpi_status status = AE_OK;
203 134
@@ -210,7 +141,8 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
210 /* Prevent wraparound of thread count */ 141 /* Prevent wraparound of thread count */
211 142
212 if (obj_desc->method.thread_count == ACPI_UINT8_MAX) { 143 if (obj_desc->method.thread_count == ACPI_UINT8_MAX) {
213 ACPI_REPORT_ERROR(("Method reached maximum reentrancy limit (255)\n")); 144 ACPI_ERROR((AE_INFO,
145 "Method reached maximum reentrancy limit (255)"));
214 return_ACPI_STATUS(AE_AML_METHOD_LIMIT); 146 return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
215 } 147 }
216 148
@@ -539,22 +471,61 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
539 acpi_os_signal_semaphore(walk_state->method_desc->method. 471 acpi_os_signal_semaphore(walk_state->method_desc->method.
540 semaphore, 1); 472 semaphore, 1);
541 if (ACPI_FAILURE(status)) { 473 if (ACPI_FAILURE(status)) {
542 ACPI_REPORT_ERROR(("Could not signal method semaphore\n")); 474 ACPI_ERROR((AE_INFO,
475 "Could not signal method semaphore"));
543 476
544 /* Ignore error and continue cleanup */ 477 /* Ignore error and continue cleanup */
545 } 478 }
546 } 479 }
547 480
481 /*
482 * There are no more threads executing this method. Perform
483 * additional cleanup.
484 *
485 * The method Node is stored in the walk state
486 */
487 method_node = walk_state->method_node;
488
489 /* Lock namespace for possible update */
490
491 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
492 if (ACPI_FAILURE(status)) {
493 goto exit;
494 }
495
496 /*
497 * Delete any namespace entries created immediately underneath
498 * the method
499 */
500 if (method_node->child) {
501 acpi_ns_delete_namespace_subtree(method_node);
502 }
503
504 /*
505 * Delete any namespace entries created anywhere else within
506 * the namespace by the execution of this method
507 */
508 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->method.
509 owner_id);
510 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
511
512 /* Are there any other threads currently executing this method? */
513
548 if (walk_state->method_desc->method.thread_count) { 514 if (walk_state->method_desc->method.thread_count) {
515 /*
516 * Additional threads. Do not release the owner_id in this case,
517 * we immediately reuse it for the next thread executing this method
518 */
549 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 519 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
550 "*** Not deleting method namespace, there are still %d threads\n", 520 "*** Completed execution of one thread, %d threads remaining\n",
551 walk_state->method_desc->method. 521 walk_state->method_desc->method.
552 thread_count)); 522 thread_count));
553 } else { /* This is the last executing thread */ 523 } else {
524 /* This is the only executing thread for this method */
554 525
555 /* 526 /*
556 * Support to dynamically change a method from not_serialized to 527 * Support to dynamically change a method from not_serialized to
557 * Serialized if it appears that the method is written foolishly and 528 * Serialized if it appears that the method is incorrectly written and
558 * does not support multiple thread execution. The best example of this 529 * does not support multiple thread execution. The best example of this
559 * is if such a method creates namespace objects and blocks. A second 530 * is if such a method creates namespace objects and blocks. A second
560 * thread will fail with an AE_ALREADY_EXISTS exception 531 * thread will fail with an AE_ALREADY_EXISTS exception
@@ -570,34 +541,8 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
570 semaphore); 541 semaphore);
571 } 542 }
572 543
573 /* 544 /* No more threads, we can free the owner_id */
574 * There are no more threads executing this method. Perform
575 * additional cleanup.
576 *
577 * The method Node is stored in the walk state
578 */
579 method_node = walk_state->method_node;
580
581 /*
582 * Delete any namespace entries created immediately underneath
583 * the method
584 */
585 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
586 if (ACPI_FAILURE(status)) {
587 goto exit;
588 }
589
590 if (method_node->child) {
591 acpi_ns_delete_namespace_subtree(method_node);
592 }
593 545
594 /*
595 * Delete any namespace entries created anywhere else within
596 * the namespace
597 */
598 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->
599 method.owner_id);
600 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
601 acpi_ut_release_owner_id(&walk_state->method_desc->method. 546 acpi_ut_release_owner_id(&walk_state->method_desc->method.
602 owner_id); 547 owner_id);
603 } 548 }
@@ -606,3 +551,140 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
606 (void)acpi_ut_release_mutex(ACPI_MTX_PARSER); 551 (void)acpi_ut_release_mutex(ACPI_MTX_PARSER);
607 return_VOID; 552 return_VOID;
608} 553}
554
555#ifdef ACPI_INIT_PARSE_METHODS
556 /*
557 * Note 11/2005: Removed this code to parse all methods during table
558 * load because it causes problems if there are any errors during the
559 * parse. Also, it seems like overkill and we probably don't want to
560 * abort a table load because of an issue with a single method.
561 */
562
563/*******************************************************************************
564 *
565 * FUNCTION: acpi_ds_parse_method
566 *
567 * PARAMETERS: Node - Method node
568 *
569 * RETURN: Status
570 *
571 * DESCRIPTION: Parse the AML that is associated with the method.
572 *
573 * MUTEX: Assumes parser is locked
574 *
575 ******************************************************************************/
576
577acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
578{
579 acpi_status status;
580 union acpi_operand_object *obj_desc;
581 union acpi_parse_object *op;
582 struct acpi_walk_state *walk_state;
583
584 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
585
586 /* Parameter Validation */
587
588 if (!node) {
589 return_ACPI_STATUS(AE_NULL_ENTRY);
590 }
591
592 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
593 "**** Parsing [%4.4s] **** named_obj=%p\n",
594 acpi_ut_get_node_name(node), node));
595
596 /* Extract the method object from the method Node */
597
598 obj_desc = acpi_ns_get_attached_object(node);
599 if (!obj_desc) {
600 return_ACPI_STATUS(AE_NULL_OBJECT);
601 }
602
603 /* Create a mutex for the method if there is a concurrency limit */
604
605 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
606 (!obj_desc->method.semaphore)) {
607 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
608 obj_desc->method.concurrency,
609 &obj_desc->method.semaphore);
610 if (ACPI_FAILURE(status)) {
611 return_ACPI_STATUS(status);
612 }
613 }
614
615 /*
616 * Allocate a new parser op to be the root of the parsed
617 * method tree
618 */
619 op = acpi_ps_alloc_op(AML_METHOD_OP);
620 if (!op) {
621 return_ACPI_STATUS(AE_NO_MEMORY);
622 }
623
624 /* Init new op with the method name and pointer back to the Node */
625
626 acpi_ps_set_name(op, node->name.integer);
627 op->common.node = node;
628
629 /*
630 * Get a new owner_id for objects created by this method. Namespace
631 * objects (such as Operation Regions) can be created during the
632 * first pass parse.
633 */
634 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
635 if (ACPI_FAILURE(status)) {
636 goto cleanup;
637 }
638
639 /* Create and initialize a new walk state */
640
641 walk_state =
642 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
643 NULL);
644 if (!walk_state) {
645 status = AE_NO_MEMORY;
646 goto cleanup2;
647 }
648
649 status = acpi_ds_init_aml_walk(walk_state, op, node,
650 obj_desc->method.aml_start,
651 obj_desc->method.aml_length, NULL, 1);
652 if (ACPI_FAILURE(status)) {
653 acpi_ds_delete_walk_state(walk_state);
654 goto cleanup2;
655 }
656
657 /*
658 * Parse the method, first pass
659 *
660 * The first pass load is where newly declared named objects are added into
661 * the namespace. Actual evaluation of the named objects (what would be
662 * called a "second pass") happens during the actual execution of the
663 * method so that operands to the named objects can take on dynamic
664 * run-time values.
665 */
666 status = acpi_ps_parse_aml(walk_state);
667 if (ACPI_FAILURE(status)) {
668 goto cleanup2;
669 }
670
671 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
672 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
673 acpi_ut_get_node_name(node), node, op));
674
675 /*
676 * Delete the parse tree. We simply re-parse the method for every
677 * execution since there isn't much overhead (compared to keeping lots
678 * of parse trees around)
679 */
680 acpi_ns_delete_namespace_subtree(node);
681 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
682
683 cleanup2:
684 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
685
686 cleanup:
687 acpi_ps_delete_parse_tree(op);
688 return_ACPI_STATUS(status);
689}
690#endif
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index 4095ce70982b..c025674f938b 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -260,9 +260,9 @@ acpi_ds_method_data_get_node(u16 opcode,
260 case AML_LOCAL_OP: 260 case AML_LOCAL_OP:
261 261
262 if (index > ACPI_METHOD_MAX_LOCAL) { 262 if (index > ACPI_METHOD_MAX_LOCAL) {
263 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 263 ACPI_ERROR((AE_INFO,
264 "Local index %d is invalid (max %d)\n", 264 "Local index %d is invalid (max %d)",
265 index, ACPI_METHOD_MAX_LOCAL)); 265 index, ACPI_METHOD_MAX_LOCAL));
266 return_ACPI_STATUS(AE_AML_INVALID_INDEX); 266 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
267 } 267 }
268 268
@@ -274,9 +274,9 @@ acpi_ds_method_data_get_node(u16 opcode,
274 case AML_ARG_OP: 274 case AML_ARG_OP:
275 275
276 if (index > ACPI_METHOD_MAX_ARG) { 276 if (index > ACPI_METHOD_MAX_ARG) {
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 277 ACPI_ERROR((AE_INFO,
278 "Arg index %d is invalid (max %d)\n", 278 "Arg index %d is invalid (max %d)",
279 index, ACPI_METHOD_MAX_ARG)); 279 index, ACPI_METHOD_MAX_ARG));
280 return_ACPI_STATUS(AE_AML_INVALID_INDEX); 280 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
281 } 281 }
282 282
@@ -286,8 +286,7 @@ acpi_ds_method_data_get_node(u16 opcode,
286 break; 286 break;
287 287
288 default: 288 default:
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Opcode %d is invalid\n", 289 ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode));
290 opcode));
291 return_ACPI_STATUS(AE_AML_BAD_OPCODE); 290 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
292 } 291 }
293 292
@@ -378,8 +377,7 @@ acpi_ds_method_data_get_value(u16 opcode,
378 /* Validate the object descriptor */ 377 /* Validate the object descriptor */
379 378
380 if (!dest_desc) { 379 if (!dest_desc) {
381 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 380 ACPI_ERROR((AE_INFO, "Null object descriptor pointer"));
382 "Null object descriptor pointer\n"));
383 return_ACPI_STATUS(AE_BAD_PARAMETER); 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
384 } 382 }
385 383
@@ -424,23 +422,24 @@ acpi_ds_method_data_get_value(u16 opcode,
424 switch (opcode) { 422 switch (opcode) {
425 case AML_ARG_OP: 423 case AML_ARG_OP:
426 424
427 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 425 ACPI_ERROR((AE_INFO,
428 "Uninitialized Arg[%d] at node %p\n", 426 "Uninitialized Arg[%d] at node %p",
429 index, node)); 427 index, node));
430 428
431 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); 429 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
432 430
433 case AML_LOCAL_OP: 431 case AML_LOCAL_OP:
434 432
435 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 433 ACPI_ERROR((AE_INFO,
436 "Uninitialized Local[%d] at node %p\n", 434 "Uninitialized Local[%d] at node %p",
437 index, node)); 435 index, node));
438 436
439 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); 437 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
440 438
441 default: 439 default:
442 ACPI_REPORT_ERROR(("Not Arg/Local opcode: %X\n", 440 ACPI_ERROR((AE_INFO,
443 opcode)); 441 "Not a Arg/Local opcode: %X",
442 opcode));
444 return_ACPI_STATUS(AE_AML_INTERNAL); 443 return_ACPI_STATUS(AE_AML_INTERNAL);
445 } 444 }
446 } 445 }
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index 8ac0cd93adb5..8b21f0f9e517 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/dispatcher/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,7 @@
51#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsobject") 52ACPI_MODULE_NAME("dsobject")
53 53
54/* Local prototypes */
54static acpi_status 55static acpi_status
55acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, 56acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
56 union acpi_parse_object *op, 57 union acpi_parse_object *op,
@@ -85,7 +86,7 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
85 *obj_desc_ptr = NULL; 86 *obj_desc_ptr = NULL;
86 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 87 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
87 /* 88 /*
88 * This is an named object reference. If this name was 89 * This is a named object reference. If this name was
89 * previously looked up in the namespace, it was stored in this op. 90 * previously looked up in the namespace, it was stored in this op.
90 * Otherwise, go ahead and look it up now 91 * Otherwise, go ahead and look it up now
91 */ 92 */
@@ -96,18 +97,48 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
96 ACPI_IMODE_EXECUTE, 97 ACPI_IMODE_EXECUTE,
97 ACPI_NS_SEARCH_PARENT | 98 ACPI_NS_SEARCH_PARENT |
98 ACPI_NS_DONT_OPEN_SCOPE, NULL, 99 ACPI_NS_DONT_OPEN_SCOPE, NULL,
99 (struct acpi_namespace_node **) 100 ACPI_CAST_INDIRECT_PTR(struct
100 &(op->common.node)); 101 acpi_namespace_node,
101 102 &(op->
103 common.
104 node)));
102 if (ACPI_FAILURE(status)) { 105 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_NSERROR(op->common.value.string, 106 /* Check if we are resolving a named reference within a package */
104 status); 107
108 if ((status == AE_NOT_FOUND)
109 && (acpi_gbl_enable_interpreter_slack)
110 &&
111 ((op->common.parent->common.aml_opcode ==
112 AML_PACKAGE_OP)
113 || (op->common.parent->common.aml_opcode ==
114 AML_VAR_PACKAGE_OP))) {
115 /*
116 * We didn't find the target and we are populating elements
117 * of a package - ignore if slack enabled. Some ASL code
118 * contains dangling invalid references in packages and
119 * expects that no exception will be issued. Leave the
120 * element as a null element. It cannot be used, but it
121 * can be overwritten by subsequent ASL code - this is
122 * typically the case.
123 */
124 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
125 "Ignoring unresolved reference in package [%4.4s]\n",
126 walk_state->
127 scope_info->scope.
128 node->name.ascii));
129
130 return_ACPI_STATUS(AE_OK);
131 } else {
132 ACPI_ERROR_NAMESPACE(op->common.value.
133 string, status);
134 }
135
105 return_ACPI_STATUS(status); 136 return_ACPI_STATUS(status);
106 } 137 }
107 } 138 }
108 } 139 }
109 140
110 /* Create and init the internal ACPI object */ 141 /* Create and init a new internal ACPI object */
111 142
112 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info 143 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
113 (op->common.aml_opcode))-> 144 (op->common.aml_opcode))->
@@ -157,13 +188,13 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
157 188
158 ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj"); 189 ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj");
159 190
191 /*
192 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
193 * The buffer object already exists (from the NS node), otherwise it must
194 * be created.
195 */
160 obj_desc = *obj_desc_ptr; 196 obj_desc = *obj_desc_ptr;
161 if (obj_desc) { 197 if (!obj_desc) {
162 /*
163 * We are evaluating a Named buffer object "Name (xxxx, Buffer)".
164 * The buffer object already exists (from the NS node)
165 */
166 } else {
167 /* Create a new buffer object */ 198 /* Create a new buffer object */
168 199
169 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); 200 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
@@ -183,10 +214,9 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
183 byte_list = arg->named.next; 214 byte_list = arg->named.next;
184 if (byte_list) { 215 if (byte_list) {
185 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { 216 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 217 ACPI_ERROR((AE_INFO,
187 "Expecting bytelist, got AML opcode %X in op %p\n", 218 "Expecting bytelist, got AML opcode %X in op %p",
188 byte_list->common.aml_opcode, 219 byte_list->common.aml_opcode, byte_list));
189 byte_list));
190 220
191 acpi_ut_remove_reference(obj_desc); 221 acpi_ut_remove_reference(obj_desc);
192 return (AE_TYPE); 222 return (AE_TYPE);
@@ -259,7 +289,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
259 union acpi_operand_object *obj_desc = NULL; 289 union acpi_operand_object *obj_desc = NULL;
260 u32 package_list_length; 290 u32 package_list_length;
261 acpi_status status = AE_OK; 291 acpi_status status = AE_OK;
262 u32 i; 292 acpi_native_uint i;
263 293
264 ACPI_FUNCTION_TRACE("ds_build_internal_package_obj"); 294 ACPI_FUNCTION_TRACE("ds_build_internal_package_obj");
265 295
@@ -271,13 +301,12 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
271 parent = parent->common.parent; 301 parent = parent->common.parent;
272 } 302 }
273 303
304 /*
305 * If we are evaluating a Named package object "Name (xxxx, Package)",
306 * the package object already exists, otherwise it must be created.
307 */
274 obj_desc = *obj_desc_ptr; 308 obj_desc = *obj_desc_ptr;
275 if (obj_desc) { 309 if (!obj_desc) {
276 /*
277 * We are evaluating a Named package object "Name (xxxx, Package)".
278 * Get the existing package object from the NS node
279 */
280 } else {
281 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); 310 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
282 *obj_desc_ptr = obj_desc; 311 *obj_desc_ptr = obj_desc;
283 if (!obj_desc) { 312 if (!obj_desc) {
@@ -291,11 +320,9 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
291 320
292 /* Count the number of items in the package list */ 321 /* Count the number of items in the package list */
293 322
294 package_list_length = 0;
295 arg = op->common.value.arg; 323 arg = op->common.value.arg;
296 arg = arg->common.next; 324 arg = arg->common.next;
297 while (arg) { 325 for (package_list_length = 0; arg; package_list_length++) {
298 package_list_length++;
299 arg = arg->common.next; 326 arg = arg->common.next;
300 } 327 }
301 328
@@ -322,12 +349,11 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
322 } 349 }
323 350
324 /* 351 /*
325 * Now init the elements of the package 352 * Initialize all elements of the package
326 */ 353 */
327 i = 0;
328 arg = op->common.value.arg; 354 arg = op->common.value.arg;
329 arg = arg->common.next; 355 arg = arg->common.next;
330 while (arg) { 356 for (i = 0; arg; i++) {
331 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 357 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
332 /* Object (package or buffer) is already built */ 358 /* Object (package or buffer) is already built */
333 359
@@ -340,8 +366,6 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
340 package. 366 package.
341 elements[i]); 367 elements[i]);
342 } 368 }
343
344 i++;
345 arg = arg->common.next; 369 arg = arg->common.next;
346 } 370 }
347 371
@@ -518,9 +542,9 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
518 542
519 default: 543 default:
520 544
521 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 545 ACPI_ERROR((AE_INFO,
522 "Unknown constant opcode %X\n", 546 "Unknown constant opcode %X",
523 opcode)); 547 opcode));
524 status = AE_AML_OPERAND_TYPE; 548 status = AE_AML_OPERAND_TYPE;
525 break; 549 break;
526 } 550 }
@@ -535,9 +559,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
535 break; 559 break;
536 560
537 default: 561 default:
538 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 562 ACPI_ERROR((AE_INFO, "Unknown Integer type %X",
539 "Unknown Integer type %X\n", 563 op_info->type));
540 op_info->type));
541 status = AE_AML_OPERAND_TYPE; 564 status = AE_AML_OPERAND_TYPE;
542 break; 565 break;
543 } 566 }
@@ -615,9 +638,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
615 638
616 default: 639 default:
617 640
618 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 641 ACPI_ERROR((AE_INFO, "Unimplemented data type: %X",
619 "Unimplemented data type: %X\n", 642 ACPI_GET_OBJECT_TYPE(obj_desc)));
620 ACPI_GET_OBJECT_TYPE(obj_desc)));
621 643
622 status = AE_AML_OPERAND_TYPE; 644 status = AE_AML_OPERAND_TYPE;
623 break; 645 break;
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 939d167bf87b..6229c10674e1 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -245,7 +245,9 @@ acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
245 245
246 node = obj_desc->buffer.node; 246 node = obj_desc->buffer.node;
247 if (!node) { 247 if (!node) {
248 ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc)); 248 ACPI_ERROR((AE_INFO,
249 "No pointer back to NS node in buffer obj %p",
250 obj_desc));
249 return_ACPI_STATUS(AE_AML_INTERNAL); 251 return_ACPI_STATUS(AE_AML_INTERNAL);
250 } 252 }
251 253
@@ -287,8 +289,9 @@ acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
287 289
288 node = obj_desc->package.node; 290 node = obj_desc->package.node;
289 if (!node) { 291 if (!node) {
290 ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n", 292 ACPI_ERROR((AE_INFO,
291 obj_desc)); 293 "No pointer back to NS node in package %p",
294 obj_desc));
292 return_ACPI_STATUS(AE_AML_INTERNAL); 295 return_ACPI_STATUS(AE_AML_INTERNAL);
293 } 296 }
294 297
@@ -413,9 +416,9 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
413 /* Host object must be a Buffer */ 416 /* Host object must be a Buffer */
414 417
415 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { 418 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) {
416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 419 ACPI_ERROR((AE_INFO,
417 "Target of Create Field is not a Buffer object - %s\n", 420 "Target of Create Field is not a Buffer object - %s",
418 acpi_ut_get_object_type_name(buffer_desc))); 421 acpi_ut_get_object_type_name(buffer_desc)));
419 422
420 status = AE_AML_OPERAND_TYPE; 423 status = AE_AML_OPERAND_TYPE;
421 goto cleanup; 424 goto cleanup;
@@ -427,10 +430,10 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
427 * after resolution in acpi_ex_resolve_operands(). 430 * after resolution in acpi_ex_resolve_operands().
428 */ 431 */
429 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { 432 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
430 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 433 ACPI_ERROR((AE_INFO,
431 "(%s) destination not a NS Node [%s]\n", 434 "(%s) destination not a NS Node [%s]",
432 acpi_ps_get_opcode_name(aml_opcode), 435 acpi_ps_get_opcode_name(aml_opcode),
433 acpi_ut_get_descriptor_name(result_desc))); 436 acpi_ut_get_descriptor_name(result_desc)));
434 437
435 status = AE_AML_OPERAND_TYPE; 438 status = AE_AML_OPERAND_TYPE;
436 goto cleanup; 439 goto cleanup;
@@ -453,8 +456,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
453 /* Must have a valid (>0) bit count */ 456 /* Must have a valid (>0) bit count */
454 457
455 if (bit_count == 0) { 458 if (bit_count == 0) {
456 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 459 ACPI_ERROR((AE_INFO,
457 "Attempt to create_field of length 0\n")); 460 "Attempt to create_field of length zero"));
458 status = AE_AML_OPERAND_VALUE; 461 status = AE_AML_OPERAND_VALUE;
459 goto cleanup; 462 goto cleanup;
460 } 463 }
@@ -507,9 +510,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
507 510
508 default: 511 default:
509 512
510 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 513 ACPI_ERROR((AE_INFO,
511 "Unknown field creation opcode %02x\n", 514 "Unknown field creation opcode %02x", aml_opcode));
512 aml_opcode));
513 status = AE_AML_BAD_OPCODE; 515 status = AE_AML_BAD_OPCODE;
514 goto cleanup; 516 goto cleanup;
515 } 517 }
@@ -517,13 +519,12 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
517 /* Entire field must fit within the current length of the buffer */ 519 /* Entire field must fit within the current length of the buffer */
518 520
519 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { 521 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
520 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 522 ACPI_ERROR((AE_INFO,
521 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 523 "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)",
522 acpi_ut_get_node_name(result_desc), 524 acpi_ut_get_node_name(result_desc),
523 bit_offset + bit_count, 525 bit_offset + bit_count,
524 acpi_ut_get_node_name(buffer_desc->buffer. 526 acpi_ut_get_node_name(buffer_desc->buffer.node),
525 node), 527 8 * (u32) buffer_desc->buffer.length));
526 8 * (u32) buffer_desc->buffer.length));
527 status = AE_AML_BUFFER_LIMIT; 528 status = AE_AML_BUFFER_LIMIT;
528 goto cleanup; 529 goto cleanup;
529 } 530 }
@@ -629,9 +630,9 @@ acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
629 "after acpi_ex_resolve_operands"); 630 "after acpi_ex_resolve_operands");
630 631
631 if (ACPI_FAILURE(status)) { 632 if (ACPI_FAILURE(status)) {
632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 633 ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)",
633 acpi_ps_get_opcode_name(op->common. 634 acpi_ps_get_opcode_name(op->common.aml_opcode),
634 aml_opcode), status)); 635 status));
635 636
636 return_ACPI_STATUS(status); 637 return_ACPI_STATUS(status);
637 } 638 }
@@ -1155,9 +1156,8 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1155 1156
1156 default: 1157 default:
1157 1158
1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1159 ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p",
1159 "Unknown control opcode=%X Op=%p\n", 1160 op->common.aml_opcode, op));
1160 op->common.aml_opcode, op));
1161 1161
1162 status = AE_AML_BAD_OPCODE; 1162 status = AE_AML_BAD_OPCODE;
1163 break; 1163 break;
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
index 83ae1c1aa286..53356a591ac1 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/dispatcher/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -176,8 +176,8 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
176 /* Must have both an Op and a Result Object */ 176 /* Must have both an Op and a Result Object */
177 177
178 if (!op) { 178 if (!op) {
179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); 179 ACPI_ERROR((AE_INFO, "Null Op"));
180 return_VALUE(TRUE); 180 return_UINT8(TRUE);
181 } 181 }
182 182
183 /* 183 /*
@@ -208,7 +208,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
208 "At Method level, result of [%s] not used\n", 208 "At Method level, result of [%s] not used\n",
209 acpi_ps_get_opcode_name(op->common. 209 acpi_ps_get_opcode_name(op->common.
210 aml_opcode))); 210 aml_opcode)));
211 return_VALUE(FALSE); 211 return_UINT8(FALSE);
212 } 212 }
213 213
214 /* Get info on the parent. The root_op is AML_SCOPE */ 214 /* Get info on the parent. The root_op is AML_SCOPE */
@@ -216,9 +216,8 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
216 parent_info = 216 parent_info =
217 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); 217 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
218 if (parent_info->class == AML_CLASS_UNKNOWN) { 218 if (parent_info->class == AML_CLASS_UNKNOWN) {
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op));
220 "Unknown parent opcode. Op=%p\n", op)); 220 return_UINT8(FALSE);
221 return_VALUE(FALSE);
222 } 221 }
223 222
224 /* 223 /*
@@ -304,7 +303,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
304 acpi_ps_get_opcode_name(op->common.parent->common. 303 acpi_ps_get_opcode_name(op->common.parent->common.
305 aml_opcode), op)); 304 aml_opcode), op));
306 305
307 return_VALUE(TRUE); 306 return_UINT8(TRUE);
308 307
309 result_not_used: 308 result_not_used:
310 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 309 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -313,7 +312,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
313 acpi_ps_get_opcode_name(op->common.parent->common. 312 acpi_ps_get_opcode_name(op->common.parent->common.
314 aml_opcode), op)); 313 aml_opcode), op));
315 314
316 return_VALUE(FALSE); 315 return_UINT8(FALSE);
317} 316}
318 317
319/******************************************************************************* 318/*******************************************************************************
@@ -344,7 +343,7 @@ acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
344 ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj); 343 ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj);
345 344
346 if (!op) { 345 if (!op) {
347 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); 346 ACPI_ERROR((AE_INFO, "Null Op"));
348 return_VOID; 347 return_VOID;
349 } 348 }
350 349
@@ -567,7 +566,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
567 } 566 }
568 567
569 if (ACPI_FAILURE(status)) { 568 if (ACPI_FAILURE(status)) {
570 ACPI_REPORT_NSERROR(name_string, status); 569 ACPI_ERROR_NAMESPACE(name_string, status);
571 } 570 }
572 } 571 }
573 572
@@ -616,7 +615,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
616 615
617 if (op_info->flags & AML_HAS_RETVAL) { 616 if (op_info->flags & AML_HAS_RETVAL) {
618 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 617 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
619 "Argument previously created, already stacked \n")); 618 "Argument previously created, already stacked\n"));
620 619
621 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object 620 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
622 (walk_state-> 621 (walk_state->
@@ -635,10 +634,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
635 * Only error is underflow, and this indicates 634 * Only error is underflow, and this indicates
636 * a missing or null operand! 635 * a missing or null operand!
637 */ 636 */
638 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 637 ACPI_EXCEPTION((AE_INFO, status,
639 "Missing or null operand, %s\n", 638 "Missing or null operand"));
640 acpi_format_exception
641 (status)));
642 return_ACPI_STATUS(status); 639 return_ACPI_STATUS(status);
643 } 640 }
644 } else { 641 } else {
@@ -730,7 +727,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
730 */ 727 */
731 (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state); 728 (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
732 729
733 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "While creating Arg %d - %s\n", 730 ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %d",
734 (arg_count + 1), acpi_format_exception(status))); 731 (arg_count + 1)));
735 return_ACPI_STATUS(status); 732 return_ACPI_STATUS(status);
736} 733}
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index e522763bb692..f1af655ff113 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -100,9 +100,8 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
100 if (result_obj) { 100 if (result_obj) {
101 status = acpi_ds_result_pop(&obj_desc, walk_state); 101 status = acpi_ds_result_pop(&obj_desc, walk_state);
102 if (ACPI_FAILURE(status)) { 102 if (ACPI_FAILURE(status)) {
103 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 103 ACPI_EXCEPTION((AE_INFO, status,
104 "Could not get result from predicate evaluation, %s\n", 104 "Could not get result from predicate evaluation"));
105 acpi_format_exception(status)));
106 105
107 return_ACPI_STATUS(status); 106 return_ACPI_STATUS(status);
108 } 107 }
@@ -123,9 +122,9 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
123 } 122 }
124 123
125 if (!obj_desc) { 124 if (!obj_desc) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 125 ACPI_ERROR((AE_INFO,
127 "No predicate obj_desc=%p State=%p\n", 126 "No predicate obj_desc=%p State=%p",
128 obj_desc, walk_state)); 127 obj_desc, walk_state));
129 128
130 return_ACPI_STATUS(AE_AML_NO_OPERAND); 129 return_ACPI_STATUS(AE_AML_NO_OPERAND);
131 } 130 }
@@ -140,10 +139,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
140 } 139 }
141 140
142 if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { 141 if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) {
143 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 142 ACPI_ERROR((AE_INFO,
144 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", 143 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X",
145 obj_desc, walk_state, 144 obj_desc, walk_state,
146 ACPI_GET_OBJECT_TYPE(obj_desc))); 145 ACPI_GET_OBJECT_TYPE(obj_desc)));
147 146
148 status = AE_AML_OPERAND_TYPE; 147 status = AE_AML_OPERAND_TYPE;
149 goto cleanup; 148 goto cleanup;
@@ -314,12 +313,13 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
314 313
315 case AML_CLASS_EXECUTE: 314 case AML_CLASS_EXECUTE:
316 case AML_CLASS_CREATE: 315 case AML_CLASS_CREATE:
317
318 /* 316 /*
319 * Most operators with arguments. 317 * Most operators with arguments.
320 * Start a new result/operand state 318 * Start a new result/operand state
321 */ 319 */
322 status = acpi_ds_result_stack_push(walk_state); 320 if (walk_state->opcode != AML_CREATE_FIELD_OP) {
321 status = acpi_ds_result_stack_push(walk_state);
322 }
323 break; 323 break;
324 324
325 default: 325 default:
@@ -361,8 +361,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
361 op_class = walk_state->op_info->class; 361 op_class = walk_state->op_info->class;
362 362
363 if (op_class == AML_CLASS_UNKNOWN) { 363 if (op_class == AML_CLASS_UNKNOWN) {
364 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n", 364 ACPI_ERROR((AE_INFO, "Unknown opcode %X",
365 op->common.aml_opcode)); 365 op->common.aml_opcode));
366 return_ACPI_STATUS(AE_NOT_IMPLEMENTED); 366 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
367 } 367 }
368 368
@@ -452,12 +452,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
452 walk_state->operands[1]->reference.offset)) { 452 walk_state->operands[1]->reference.offset)) {
453 status = AE_OK; 453 status = AE_OK;
454 } else { 454 } else {
455 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 455 ACPI_EXCEPTION((AE_INFO, status,
456 "[%s]: Could not resolve operands, %s\n", 456 "While resolving operands for [%s]",
457 acpi_ps_get_opcode_name 457 acpi_ps_get_opcode_name
458 (walk_state->opcode), 458 (walk_state->opcode)));
459 acpi_format_exception
460 (status)));
461 } 459 }
462 } 460 }
463 461
@@ -676,8 +674,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
676 674
677 case AML_TYPE_UNDEFINED: 675 case AML_TYPE_UNDEFINED:
678 676
679 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 677 ACPI_ERROR((AE_INFO,
680 "Undefined opcode type Op=%p\n", op)); 678 "Undefined opcode type Op=%p", op));
681 return_ACPI_STATUS(AE_NOT_IMPLEMENTED); 679 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
682 680
683 case AML_TYPE_BOGUS: 681 case AML_TYPE_BOGUS:
@@ -689,10 +687,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
689 687
690 default: 688 default:
691 689
692 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 690 ACPI_ERROR((AE_INFO,
693 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", 691 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p",
694 op_class, op_type, 692 op_class, op_type, op->common.aml_opcode,
695 op->common.aml_opcode, op)); 693 op));
696 694
697 status = AE_NOT_IMPLEMENTED; 695 status = AE_NOT_IMPLEMENTED;
698 break; 696 break;
@@ -723,20 +721,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
723 721
724 cleanup: 722 cleanup:
725 723
726 /* Invoke exception handler on error */
727
728 if (ACPI_FAILURE(status) &&
729 acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) {
730 acpi_ex_exit_interpreter();
731 status = acpi_gbl_exception_handler(status,
732 walk_state->method_node->
733 name.integer,
734 walk_state->opcode,
735 walk_state->aml_offset,
736 NULL);
737 (void)acpi_ex_enter_interpreter();
738 }
739
740 if (walk_state->result_obj) { 724 if (walk_state->result_obj) {
741 /* Break to debugger to display result */ 725 /* Break to debugger to display result */
742 726
@@ -758,18 +742,14 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
758 } 742 }
759#endif 743#endif
760 744
761 /* Always clear the object stack */ 745 /* Invoke exception handler on error */
762
763 walk_state->num_operands = 0;
764
765#ifdef ACPI_DISASSEMBLER
766
767 /* On error, display method locals/args */
768 746
769 if (ACPI_FAILURE(status)) { 747 if (ACPI_FAILURE(status)) {
770 acpi_dm_dump_method_info(status, walk_state, op); 748 status = acpi_ds_method_error(status, walk_state);
771 } 749 }
772#endif
773 750
751 /* Always clear the object stack */
752
753 walk_state->num_operands = 0;
774 return_ACPI_STATUS(status); 754 return_ACPI_STATUS(status);
775} 755}
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 411731261c29..d3d24da31c81 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -127,7 +127,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
127 char *path; 127 char *path;
128 u32 flags; 128 u32 flags;
129 129
130 ACPI_FUNCTION_NAME("ds_load1_begin_op"); 130 ACPI_FUNCTION_TRACE("ds_load1_begin_op");
131 131
132 op = walk_state->op; 132 op = walk_state->op;
133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
@@ -138,14 +138,14 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
138 if (op) { 138 if (op) {
139 if (!(walk_state->op_info->flags & AML_NAMED)) { 139 if (!(walk_state->op_info->flags & AML_NAMED)) {
140 *out_op = op; 140 *out_op = op;
141 return (AE_OK); 141 return_ACPI_STATUS(AE_OK);
142 } 142 }
143 143
144 /* Check if this object has already been installed in the namespace */ 144 /* Check if this object has already been installed in the namespace */
145 145
146 if (op->common.node) { 146 if (op->common.node) {
147 *out_op = op; 147 *out_op = op;
148 return (AE_OK); 148 return_ACPI_STATUS(AE_OK);
149 } 149 }
150 } 150 }
151 151
@@ -187,8 +187,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
187 } 187 }
188#endif 188#endif
189 if (ACPI_FAILURE(status)) { 189 if (ACPI_FAILURE(status)) {
190 ACPI_REPORT_NSERROR(path, status); 190 ACPI_ERROR_NAMESPACE(path, status);
191 return (status); 191 return_ACPI_STATUS(status);
192 } 192 }
193 193
194 /* 194 /*
@@ -233,9 +233,11 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
233 233
234 /* All other types are an error */ 234 /* All other types are an error */
235 235
236 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path)); 236 ACPI_ERROR((AE_INFO,
237 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)",
238 acpi_ut_get_type_name(node->type), path));
237 239
238 return (AE_AML_OPERAND_TYPE); 240 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
239 } 241 }
240 break; 242 break;
241 243
@@ -257,6 +259,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
257 * buffer_field, or Package), the name of the object is already 259 * buffer_field, or Package), the name of the object is already
258 * in the namespace. 260 * in the namespace.
259 */ 261 */
262
260 if (walk_state->deferred_node) { 263 if (walk_state->deferred_node) {
261 /* This name is already in the namespace, get the node */ 264 /* This name is already in the namespace, get the node */
262 265
@@ -265,6 +268,16 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
265 break; 268 break;
266 } 269 }
267 270
271 /*
272 * If we are executing a method, do not create any namespace objects
273 * during the load phase, only during execution.
274 */
275 if (walk_state->method_node) {
276 node = NULL;
277 status = AE_OK;
278 break;
279 }
280
268 flags = ACPI_NS_NO_UPSEARCH; 281 flags = ACPI_NS_NO_UPSEARCH;
269 if ((walk_state->opcode != AML_SCOPE_OP) && 282 if ((walk_state->opcode != AML_SCOPE_OP) &&
270 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { 283 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
@@ -289,8 +302,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
289 ACPI_IMODE_LOAD_PASS1, flags, walk_state, 302 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
290 &(node)); 303 &(node));
291 if (ACPI_FAILURE(status)) { 304 if (ACPI_FAILURE(status)) {
292 ACPI_REPORT_NSERROR(path, status); 305 ACPI_ERROR_NAMESPACE(path, status);
293 return (status); 306 return_ACPI_STATUS(status);
294 } 307 }
295 break; 308 break;
296 } 309 }
@@ -302,28 +315,29 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
302 315
303 op = acpi_ps_alloc_op(walk_state->opcode); 316 op = acpi_ps_alloc_op(walk_state->opcode);
304 if (!op) { 317 if (!op) {
305 return (AE_NO_MEMORY); 318 return_ACPI_STATUS(AE_NO_MEMORY);
306 } 319 }
307 } 320 }
308 321
309 /* Initialize */ 322 /* Initialize the op */
310
311 op->named.name = node->name.integer;
312 323
313#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) 324#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
314 op->named.path = (u8 *) path; 325 op->named.path = ACPI_CAST_PTR(u8, path);
315#endif 326#endif
316 327
317 /* 328 if (node) {
318 * Put the Node in the "op" object that the parser uses, so we 329 /*
319 * can get it again quickly when this scope is closed 330 * Put the Node in the "op" object that the parser uses, so we
320 */ 331 * can get it again quickly when this scope is closed
321 op->common.node = node; 332 */
333 op->common.node = node;
334 op->named.name = node->name.integer;
335 }
336
322 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state), 337 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
323 op); 338 op);
324
325 *out_op = op; 339 *out_op = op;
326 return (status); 340 return_ACPI_STATUS(status);
327} 341}
328 342
329/******************************************************************************* 343/*******************************************************************************
@@ -339,13 +353,13 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
339 * 353 *
340 ******************************************************************************/ 354 ******************************************************************************/
341 355
342acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) 356acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
343{ 357{
344 union acpi_parse_object *op; 358 union acpi_parse_object *op;
345 acpi_object_type object_type; 359 acpi_object_type object_type;
346 acpi_status status = AE_OK; 360 acpi_status status = AE_OK;
347 361
348 ACPI_FUNCTION_NAME("ds_load1_end_op"); 362 ACPI_FUNCTION_TRACE("ds_load1_end_op");
349 363
350 op = walk_state->op; 364 op = walk_state->op;
351 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 365 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
@@ -354,7 +368,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
354 /* We are only interested in opcodes that have an associated name */ 368 /* We are only interested in opcodes that have an associated name */
355 369
356 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) { 370 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
357 return (AE_OK); 371 return_ACPI_STATUS(AE_OK);
358 } 372 }
359 373
360 /* Get the object type to determine if we should pop the scope */ 374 /* Get the object type to determine if we should pop the scope */
@@ -363,21 +377,37 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
363 377
364#ifndef ACPI_NO_METHOD_EXECUTION 378#ifndef ACPI_NO_METHOD_EXECUTION
365 if (walk_state->op_info->flags & AML_FIELD) { 379 if (walk_state->op_info->flags & AML_FIELD) {
366 if (walk_state->opcode == AML_FIELD_OP || 380 /*
367 walk_state->opcode == AML_BANK_FIELD_OP || 381 * If we are executing a method, do not create any namespace objects
368 walk_state->opcode == AML_INDEX_FIELD_OP) { 382 * during the load phase, only during execution.
369 status = acpi_ds_init_field_objects(op, walk_state); 383 */
384 if (!walk_state->method_node) {
385 if (walk_state->opcode == AML_FIELD_OP ||
386 walk_state->opcode == AML_BANK_FIELD_OP ||
387 walk_state->opcode == AML_INDEX_FIELD_OP) {
388 status =
389 acpi_ds_init_field_objects(op, walk_state);
390 }
370 } 391 }
371 return (status); 392 return_ACPI_STATUS(status);
372 } 393 }
373 394
374 if (op->common.aml_opcode == AML_REGION_OP) { 395 /*
375 status = acpi_ex_create_region(op->named.data, op->named.length, 396 * If we are executing a method, do not create any namespace objects
376 (acpi_adr_space_type) 397 * during the load phase, only during execution.
377 ((op->common.value.arg)->common. 398 */
378 value.integer), walk_state); 399 if (!walk_state->method_node) {
379 if (ACPI_FAILURE(status)) { 400 if (op->common.aml_opcode == AML_REGION_OP) {
380 return (status); 401 status =
402 acpi_ex_create_region(op->named.data,
403 op->named.length,
404 (acpi_adr_space_type)
405 ((op->common.value.arg)->
406 common.value.integer),
407 walk_state);
408 if (ACPI_FAILURE(status)) {
409 return_ACPI_STATUS(status);
410 }
381 } 411 }
382 } 412 }
383#endif 413#endif
@@ -391,47 +421,63 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
391 common. 421 common.
392 aml_opcode))-> 422 aml_opcode))->
393 object_type; 423 object_type;
394 op->common.node->type = (u8) object_type; 424
425 /* Set node type if we have a namespace node */
426
427 if (op->common.node) {
428 op->common.node->type = (u8) object_type;
429 }
395 } 430 }
396 } 431 }
397 432
398 if (op->common.aml_opcode == AML_METHOD_OP) { 433 /*
399 /* 434 * If we are executing a method, do not create any namespace objects
400 * method_op pkg_length name_string method_flags term_list 435 * during the load phase, only during execution.
401 * 436 */
402 * Note: We must create the method node/object pair as soon as we 437 if (!walk_state->method_node) {
403 * see the method declaration. This allows later pass1 parsing 438 if (op->common.aml_opcode == AML_METHOD_OP) {
404 * of invocations of the method (need to know the number of 439 /*
405 * arguments.) 440 * method_op pkg_length name_string method_flags term_list
406 */ 441 *
407 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 442 * Note: We must create the method node/object pair as soon as we
408 "LOADING-Method: State=%p Op=%p named_obj=%p\n", 443 * see the method declaration. This allows later pass1 parsing
409 walk_state, op, op->named.node)); 444 * of invocations of the method (need to know the number of
445 * arguments.)
446 */
447 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
448 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
449 walk_state, op, op->named.node));
410 450
411 if (!acpi_ns_get_attached_object(op->named.node)) { 451 if (!acpi_ns_get_attached_object(op->named.node)) {
412 walk_state->operands[0] = (void *)op->named.node; 452 walk_state->operands[0] =
413 walk_state->num_operands = 1; 453 ACPI_CAST_PTR(void, op->named.node);
454 walk_state->num_operands = 1;
414 455
415 status = 456 status =
416 acpi_ds_create_operands(walk_state, 457 acpi_ds_create_operands(walk_state,
417 op->common.value.arg); 458 op->common.value.
418 if (ACPI_SUCCESS(status)) { 459 arg);
419 status = acpi_ex_create_method(op->named.data, 460 if (ACPI_SUCCESS(status)) {
420 op->named.length, 461 status =
421 walk_state); 462 acpi_ex_create_method(op->named.
422 } 463 data,
423 walk_state->operands[0] = NULL; 464 op->named.
424 walk_state->num_operands = 0; 465 length,
466 walk_state);
467 }
468 walk_state->operands[0] = NULL;
469 walk_state->num_operands = 0;
425 470
426 if (ACPI_FAILURE(status)) { 471 if (ACPI_FAILURE(status)) {
427 return (status); 472 return_ACPI_STATUS(status);
473 }
428 } 474 }
429 } 475 }
430 } 476 }
431 477
432 /* Pop the scope stack */ 478 /* Pop the scope stack (only if loading a table) */
433 479
434 if (acpi_ns_opens_scope(object_type)) { 480 if (!walk_state->method_node && acpi_ns_opens_scope(object_type)) {
435 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 481 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
436 "(%s): Popping scope for Op %p\n", 482 "(%s): Popping scope for Op %p\n",
437 acpi_ut_get_type_name(object_type), op)); 483 acpi_ut_get_type_name(object_type), op));
@@ -439,7 +485,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
439 status = acpi_ds_scope_stack_pop(walk_state); 485 status = acpi_ds_scope_stack_pop(walk_state);
440 } 486 }
441 487
442 return (status); 488 return_ACPI_STATUS(status);
443} 489}
444 490
445/******************************************************************************* 491/*******************************************************************************
@@ -456,8 +502,8 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
456 ******************************************************************************/ 502 ******************************************************************************/
457 503
458acpi_status 504acpi_status
459acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, 505acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
460 union acpi_parse_object ** out_op) 506 union acpi_parse_object **out_op)
461{ 507{
462 union acpi_parse_object *op; 508 union acpi_parse_object *op;
463 struct acpi_namespace_node *node; 509 struct acpi_namespace_node *node;
@@ -574,10 +620,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
574 if (status == AE_NOT_FOUND) { 620 if (status == AE_NOT_FOUND) {
575 status = AE_OK; 621 status = AE_OK;
576 } else { 622 } else {
577 ACPI_REPORT_NSERROR(buffer_ptr, status); 623 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
578 } 624 }
579#else 625#else
580 ACPI_REPORT_NSERROR(buffer_ptr, status); 626 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
581#endif 627#endif
582 return_ACPI_STATUS(status); 628 return_ACPI_STATUS(status);
583 } 629 }
@@ -607,7 +653,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
607 * Scope (DEB) { ... } 653 * Scope (DEB) { ... }
608 */ 654 */
609 655
610 ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type))); 656 ACPI_WARNING((AE_INFO,
657 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
658 buffer_ptr,
659 acpi_ut_get_type_name(node->type)));
611 660
612 node->type = ACPI_TYPE_ANY; 661 node->type = ACPI_TYPE_ANY;
613 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 662 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -617,7 +666,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
617 666
618 /* All other types are an error */ 667 /* All other types are an error */
619 668
620 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr)); 669 ACPI_ERROR((AE_INFO,
670 "Invalid type (%s) for target of Scope operator [%4.4s]",
671 acpi_ut_get_type_name(node->type),
672 buffer_ptr));
621 673
622 return (AE_AML_OPERAND_TYPE); 674 return (AE_AML_OPERAND_TYPE);
623 } 675 }
@@ -670,7 +722,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
670 } 722 }
671 723
672 if (ACPI_FAILURE(status)) { 724 if (ACPI_FAILURE(status)) {
673 ACPI_REPORT_NSERROR(buffer_ptr, status); 725 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
674 return_ACPI_STATUS(status); 726 return_ACPI_STATUS(status);
675 } 727 }
676 728
@@ -840,6 +892,13 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
840 892
841 case AML_TYPE_NAMED_FIELD: 893 case AML_TYPE_NAMED_FIELD:
842 894
895 /*
896 * If we are executing a method, initialize the field
897 */
898 if (walk_state->method_node) {
899 status = acpi_ds_init_field_objects(op, walk_state);
900 }
901
843 switch (op->common.aml_opcode) { 902 switch (op->common.aml_opcode) {
844 case AML_INDEX_FIELD_OP: 903 case AML_INDEX_FIELD_OP:
845 904
@@ -929,6 +988,24 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
929 switch (op->common.aml_opcode) { 988 switch (op->common.aml_opcode) {
930#ifndef ACPI_NO_METHOD_EXECUTION 989#ifndef ACPI_NO_METHOD_EXECUTION
931 case AML_REGION_OP: 990 case AML_REGION_OP:
991
992 /*
993 * If we are executing a method, initialize the region
994 */
995 if (walk_state->method_node) {
996 status =
997 acpi_ex_create_region(op->named.data,
998 op->named.length,
999 (acpi_adr_space_type)
1000 ((op->common.value.
1001 arg)->common.value.
1002 integer),
1003 walk_state);
1004 if (ACPI_FAILURE(status)) {
1005 return (status);
1006 }
1007 }
1008
932 /* 1009 /*
933 * The op_region is not fully parsed at this time. Only valid 1010 * The op_region is not fully parsed at this time. Only valid
934 * argument is the space_id. (We must save the address of the 1011 * argument is the space_id. (We must save the address of the
@@ -957,11 +1034,50 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
957 1034
958 status = acpi_ds_create_node(walk_state, node, op); 1035 status = acpi_ds_create_node(walk_state, node, op);
959 break; 1036 break;
1037
1038 case AML_METHOD_OP:
1039 /*
1040 * method_op pkg_length name_string method_flags term_list
1041 *
1042 * Note: We must create the method node/object pair as soon as we
1043 * see the method declaration. This allows later pass1 parsing
1044 * of invocations of the method (need to know the number of
1045 * arguments.)
1046 */
1047 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1048 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
1049 walk_state, op, op->named.node));
1050
1051 if (!acpi_ns_get_attached_object(op->named.node)) {
1052 walk_state->operands[0] =
1053 ACPI_CAST_PTR(void, op->named.node);
1054 walk_state->num_operands = 1;
1055
1056 status =
1057 acpi_ds_create_operands(walk_state,
1058 op->common.value.
1059 arg);
1060 if (ACPI_SUCCESS(status)) {
1061 status =
1062 acpi_ex_create_method(op->named.
1063 data,
1064 op->named.
1065 length,
1066 walk_state);
1067 }
1068 walk_state->operands[0] = NULL;
1069 walk_state->num_operands = 0;
1070
1071 if (ACPI_FAILURE(status)) {
1072 return_ACPI_STATUS(status);
1073 }
1074 }
1075 break;
1076
960#endif /* ACPI_NO_METHOD_EXECUTION */ 1077#endif /* ACPI_NO_METHOD_EXECUTION */
961 1078
962 default: 1079 default:
963 /* All NAMED_COMPLEX opcodes must be handled above */ 1080 /* All NAMED_COMPLEX opcodes must be handled above */
964 /* Note: Method objects were already created in Pass 1 */
965 break; 1081 break;
966 } 1082 }
967 break; 1083 break;
@@ -1004,7 +1120,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1004 */ 1120 */
1005 op->common.node = new_node; 1121 op->common.node = new_node;
1006 } else { 1122 } else {
1007 ACPI_REPORT_NSERROR(arg->common.value.string, status); 1123 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
1008 } 1124 }
1009 break; 1125 break;
1010 1126
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c
index defe956ef751..ada21ef4a174 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/dispatcher/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -107,14 +107,14 @@ acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
107 if (!node) { 107 if (!node) {
108 /* Invalid scope */ 108 /* Invalid scope */
109 109
110 ACPI_REPORT_ERROR(("ds_scope_stack_push: null scope passed\n")); 110 ACPI_ERROR((AE_INFO, "Null scope parameter"));
111 return_ACPI_STATUS(AE_BAD_PARAMETER); 111 return_ACPI_STATUS(AE_BAD_PARAMETER);
112 } 112 }
113 113
114 /* Make sure object type is valid */ 114 /* Make sure object type is valid */
115 115
116 if (!acpi_ut_valid_object_type(type)) { 116 if (!acpi_ut_valid_object_type(type)) {
117 ACPI_REPORT_WARNING(("ds_scope_stack_push: Invalid object type: 0x%X\n", type)); 117 ACPI_WARNING((AE_INFO, "Invalid object type: 0x%X", type));
118 } 118 }
119 119
120 /* Allocate a new scope object */ 120 /* Allocate a new scope object */
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index 7d68a5aaf3c4..fa78cb74ee36 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -92,26 +92,23 @@ acpi_ds_result_remove(union acpi_operand_object **object,
92 92
93 state = walk_state->results; 93 state = walk_state->results;
94 if (!state) { 94 if (!state) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 95 ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
96 "No result object pushed! State=%p\n", 96 walk_state));
97 walk_state));
98 return (AE_NOT_EXIST); 97 return (AE_NOT_EXIST);
99 } 98 }
100 99
101 if (index >= ACPI_OBJ_MAX_OPERAND) { 100 if (index >= ACPI_OBJ_MAX_OPERAND) {
102 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 101 ACPI_ERROR((AE_INFO,
103 "Index out of range: %X State=%p Num=%X\n", 102 "Index out of range: %X State=%p Num=%X",
104 index, walk_state, 103 index, walk_state, state->results.num_results));
105 state->results.num_results));
106 } 104 }
107 105
108 /* Check for a valid result object */ 106 /* Check for a valid result object */
109 107
110 if (!state->results.obj_desc[index]) { 108 if (!state->results.obj_desc[index]) {
111 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 109 ACPI_ERROR((AE_INFO,
112 "Null operand! State=%p #Ops=%X, Index=%X\n", 110 "Null operand! State=%p #Ops=%X, Index=%X",
113 walk_state, state->results.num_results, 111 walk_state, state->results.num_results, index));
114 index));
115 return (AE_AML_NO_RETURN_VALUE); 112 return (AE_AML_NO_RETURN_VALUE);
116 } 113 }
117 114
@@ -163,9 +160,8 @@ acpi_ds_result_pop(union acpi_operand_object ** object,
163 } 160 }
164 161
165 if (!state->results.num_results) { 162 if (!state->results.num_results) {
166 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 163 ACPI_ERROR((AE_INFO, "Result stack is empty! State=%p",
167 "Result stack is empty! State=%p\n", 164 walk_state));
168 walk_state));
169 return (AE_AML_NO_RETURN_VALUE); 165 return (AE_AML_NO_RETURN_VALUE);
170 } 166 }
171 167
@@ -192,8 +188,7 @@ acpi_ds_result_pop(union acpi_operand_object ** object,
192 } 188 }
193 } 189 }
194 190
195 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 191 ACPI_ERROR((AE_INFO, "No result objects! State=%p", walk_state));
196 "No result objects! State=%p\n", walk_state));
197 return (AE_AML_NO_RETURN_VALUE); 192 return (AE_AML_NO_RETURN_VALUE);
198} 193}
199 194
@@ -222,15 +217,14 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
222 217
223 state = walk_state->results; 218 state = walk_state->results;
224 if (!state) { 219 if (!state) {
225 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 220 ACPI_ERROR((AE_INFO,
226 "Warning: No result object pushed! State=%p\n", 221 "No result object pushed! State=%p", walk_state));
227 walk_state));
228 return (AE_NOT_EXIST); 222 return (AE_NOT_EXIST);
229 } 223 }
230 224
231 if (!state->results.num_results) { 225 if (!state->results.num_results) {
232 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 226 ACPI_ERROR((AE_INFO, "No result objects! State=%p",
233 "No result objects! State=%p\n", walk_state)); 227 walk_state));
234 return (AE_AML_NO_RETURN_VALUE); 228 return (AE_AML_NO_RETURN_VALUE);
235 } 229 }
236 230
@@ -250,10 +244,10 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
250 /* Check for a valid result object */ 244 /* Check for a valid result object */
251 245
252 if (!*object) { 246 if (!*object) {
253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 247 ACPI_ERROR((AE_INFO,
254 "Null operand! State=%p #Ops=%X Index=%X\n", 248 "Null operand! State=%p #Ops=%X Index=%X",
255 walk_state, state->results.num_results, 249 walk_state, state->results.num_results,
256 (u32) index)); 250 (u32) index));
257 return (AE_AML_NO_RETURN_VALUE); 251 return (AE_AML_NO_RETURN_VALUE);
258 } 252 }
259 253
@@ -288,23 +282,21 @@ acpi_ds_result_push(union acpi_operand_object * object,
288 282
289 state = walk_state->results; 283 state = walk_state->results;
290 if (!state) { 284 if (!state) {
291 ACPI_REPORT_ERROR(("No result stack frame during push\n")); 285 ACPI_ERROR((AE_INFO, "No result stack frame during push"));
292 return (AE_AML_INTERNAL); 286 return (AE_AML_INTERNAL);
293 } 287 }
294 288
295 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { 289 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
296 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 290 ACPI_ERROR((AE_INFO,
297 "Result stack overflow: Obj=%p State=%p Num=%X\n", 291 "Result stack overflow: Obj=%p State=%p Num=%X",
298 object, walk_state, 292 object, walk_state, state->results.num_results));
299 state->results.num_results));
300 return (AE_STACK_OVERFLOW); 293 return (AE_STACK_OVERFLOW);
301 } 294 }
302 295
303 if (!object) { 296 if (!object) {
304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 297 ACPI_ERROR((AE_INFO,
305 "Null Object! Obj=%p State=%p Num=%X\n", 298 "Null Object! Obj=%p State=%p Num=%X",
306 object, walk_state, 299 object, walk_state, state->results.num_results));
307 state->results.num_results));
308 return (AE_BAD_PARAMETER); 300 return (AE_BAD_PARAMETER);
309 } 301 }
310 302
@@ -413,10 +405,9 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
413 /* Check for stack overflow */ 405 /* Check for stack overflow */
414 406
415 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { 407 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 408 ACPI_ERROR((AE_INFO,
417 "overflow! Obj=%p State=%p #Ops=%X\n", 409 "Object stack overflow! Obj=%p State=%p #Ops=%X",
418 object, walk_state, 410 object, walk_state, walk_state->num_operands));
419 walk_state->num_operands));
420 return (AE_STACK_OVERFLOW); 411 return (AE_STACK_OVERFLOW);
421 } 412 }
422 413
@@ -460,10 +451,10 @@ acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state)
460 /* Check for stack underflow */ 451 /* Check for stack underflow */
461 452
462 if (walk_state->num_operands == 0) { 453 if (walk_state->num_operands == 0) {
463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 454 ACPI_ERROR((AE_INFO,
464 "Underflow! Count=%X State=%p #Ops=%X\n", 455 "Object stack underflow! Count=%X State=%p #Ops=%X",
465 pop_count, walk_state, 456 pop_count, walk_state,
466 walk_state->num_operands)); 457 walk_state->num_operands));
467 return (AE_STACK_UNDERFLOW); 458 return (AE_STACK_UNDERFLOW);
468 } 459 }
469 460
@@ -506,10 +497,10 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
506 /* Check for stack underflow */ 497 /* Check for stack underflow */
507 498
508 if (walk_state->num_operands == 0) { 499 if (walk_state->num_operands == 0) {
509 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 500 ACPI_ERROR((AE_INFO,
510 "Underflow! Count=%X State=%p #Ops=%X\n", 501 "Object stack underflow! Count=%X State=%p #Ops=%X",
511 pop_count, walk_state, 502 pop_count, walk_state,
512 walk_state->num_operands)); 503 walk_state->num_operands));
513 return (AE_STACK_UNDERFLOW); 504 return (AE_STACK_UNDERFLOW);
514 } 505 }
515 506
@@ -826,16 +817,14 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
826 } 817 }
827 818
828 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 819 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
829 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 820 ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
830 "%p is not a valid walk state\n", 821 walk_state));
831 walk_state));
832 return; 822 return;
833 } 823 }
834 824
835 if (walk_state->parser_state.scope) { 825 if (walk_state->parser_state.scope) {
836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 826 ACPI_ERROR((AE_INFO, "%p walk still has a scope list",
837 "%p walk still has a scope list\n", 827 walk_state));
838 walk_state));
839 } 828 }
840 829
841 /* Always must free any linked control states */ 830 /* Always must free any linked control states */
@@ -894,25 +883,24 @@ acpi_ds_result_insert(void *object,
894 883
895 state = walk_state->results; 884 state = walk_state->results;
896 if (!state) { 885 if (!state) {
897 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 886 ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
898 "No result object pushed! State=%p\n", 887 walk_state));
899 walk_state));
900 return (AE_NOT_EXIST); 888 return (AE_NOT_EXIST);
901 } 889 }
902 890
903 if (index >= ACPI_OBJ_NUM_OPERANDS) { 891 if (index >= ACPI_OBJ_NUM_OPERANDS) {
904 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 892 ACPI_ERROR((AE_INFO,
905 "Index out of range: %X Obj=%p State=%p Num=%X\n", 893 "Index out of range: %X Obj=%p State=%p Num=%X",
906 index, object, walk_state, 894 index, object, walk_state,
907 state->results.num_results)); 895 state->results.num_results));
908 return (AE_BAD_PARAMETER); 896 return (AE_BAD_PARAMETER);
909 } 897 }
910 898
911 if (!object) { 899 if (!object) {
912 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 900 ACPI_ERROR((AE_INFO,
913 "Null Object! Index=%X Obj=%p State=%p Num=%X\n", 901 "Null Object! Index=%X Obj=%p State=%p Num=%X",
914 index, object, walk_state, 902 index, object, walk_state,
915 state->results.num_results)); 903 state->results.num_results));
916 return (AE_BAD_PARAMETER); 904 return (AE_BAD_PARAMETER);
917 } 905 }
918 906
@@ -986,9 +974,9 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
986 /* Check for stack underflow */ 974 /* Check for stack underflow */
987 975
988 if (walk_state->num_operands == 0) { 976 if (walk_state->num_operands == 0) {
989 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 977 ACPI_ERROR((AE_INFO,
990 "Missing operand/stack empty! State=%p #Ops=%X\n", 978 "Missing operand/stack empty! State=%p #Ops=%X",
991 walk_state, walk_state->num_operands)); 979 walk_state, walk_state->num_operands));
992 *object = NULL; 980 *object = NULL;
993 return (AE_AML_NO_OPERAND); 981 return (AE_AML_NO_OPERAND);
994 } 982 }
@@ -1000,9 +988,9 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
1000 /* Check for a valid operand */ 988 /* Check for a valid operand */
1001 989
1002 if (!walk_state->operands[walk_state->num_operands]) { 990 if (!walk_state->operands[walk_state->num_operands]) {
1003 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 991 ACPI_ERROR((AE_INFO,
1004 "Null operand! State=%p #Ops=%X\n", 992 "Null operand! State=%p #Ops=%X",
1005 walk_state, walk_state->num_operands)); 993 walk_state, walk_state->num_operands));
1006 *object = NULL; 994 *object = NULL;
1007 return (AE_AML_NO_OPERAND); 995 return (AE_AML_NO_OPERAND);
1008 } 996 }
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 3758b558d2b5..79b09d76c180 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -60,20 +60,20 @@ ACPI_MODULE_NAME("acpi_ec")
60#define ACPI_EC_BURST_ENABLE 0x82 60#define ACPI_EC_BURST_ENABLE 0x82
61#define ACPI_EC_BURST_DISABLE 0x83 61#define ACPI_EC_BURST_DISABLE 0x83
62#define ACPI_EC_COMMAND_QUERY 0x84 62#define ACPI_EC_COMMAND_QUERY 0x84
63#define EC_POLLING 0xFF 63#define EC_POLL 0xFF
64#define EC_BURST 0x00 64#define EC_INTR 0x00
65static int acpi_ec_remove(struct acpi_device *device, int type); 65static int acpi_ec_remove(struct acpi_device *device, int type);
66static int acpi_ec_start(struct acpi_device *device); 66static int acpi_ec_start(struct acpi_device *device);
67static int acpi_ec_stop(struct acpi_device *device, int type); 67static int acpi_ec_stop(struct acpi_device *device, int type);
68static int acpi_ec_burst_add(struct acpi_device *device); 68static int acpi_ec_intr_add(struct acpi_device *device);
69static int acpi_ec_polling_add(struct acpi_device *device); 69static int acpi_ec_poll_add(struct acpi_device *device);
70 70
71static struct acpi_driver acpi_ec_driver = { 71static struct acpi_driver acpi_ec_driver = {
72 .name = ACPI_EC_DRIVER_NAME, 72 .name = ACPI_EC_DRIVER_NAME,
73 .class = ACPI_EC_CLASS, 73 .class = ACPI_EC_CLASS,
74 .ids = ACPI_EC_HID, 74 .ids = ACPI_EC_HID,
75 .ops = { 75 .ops = {
76 .add = acpi_ec_polling_add, 76 .add = acpi_ec_intr_add,
77 .remove = acpi_ec_remove, 77 .remove = acpi_ec_remove,
78 .start = acpi_ec_start, 78 .start = acpi_ec_start,
79 .stop = acpi_ec_stop, 79 .stop = acpi_ec_stop,
@@ -105,7 +105,7 @@ union acpi_ec {
105 atomic_t pending_gpe; 105 atomic_t pending_gpe;
106 struct semaphore sem; 106 struct semaphore sem;
107 wait_queue_head_t wait; 107 wait_queue_head_t wait;
108 } burst; 108 } intr;
109 109
110 struct { 110 struct {
111 u32 mode; 111 u32 mode;
@@ -117,37 +117,37 @@ union acpi_ec {
117 struct acpi_generic_address data_addr; 117 struct acpi_generic_address data_addr;
118 unsigned long global_lock; 118 unsigned long global_lock;
119 spinlock_t lock; 119 spinlock_t lock;
120 } polling; 120 } poll;
121}; 121};
122 122
123static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event); 123static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event);
124static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); 124static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event);
125static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data); 125static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data);
126static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data); 126static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data);
127static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data); 127static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data);
128static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data); 128static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data);
129static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data); 129static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data);
130static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data); 130static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data);
131static void acpi_ec_gpe_polling_query(void *ec_cxt); 131static void acpi_ec_gpe_poll_query(void *ec_cxt);
132static void acpi_ec_gpe_burst_query(void *ec_cxt); 132static void acpi_ec_gpe_intr_query(void *ec_cxt);
133static u32 acpi_ec_gpe_polling_handler(void *data); 133static u32 acpi_ec_gpe_poll_handler(void *data);
134static u32 acpi_ec_gpe_burst_handler(void *data); 134static u32 acpi_ec_gpe_intr_handler(void *data);
135static acpi_status __init 135static acpi_status __init
136acpi_fake_ecdt_polling_callback(acpi_handle handle, 136acpi_fake_ecdt_poll_callback(acpi_handle handle,
137 u32 Level, void *context, void **retval); 137 u32 Level, void *context, void **retval);
138 138
139static acpi_status __init 139static acpi_status __init
140acpi_fake_ecdt_burst_callback(acpi_handle handle, 140acpi_fake_ecdt_intr_callback(acpi_handle handle,
141 u32 Level, void *context, void **retval); 141 u32 Level, void *context, void **retval);
142 142
143static int __init acpi_ec_polling_get_real_ecdt(void); 143static int __init acpi_ec_poll_get_real_ecdt(void);
144static int __init acpi_ec_burst_get_real_ecdt(void); 144static int __init acpi_ec_intr_get_real_ecdt(void);
145/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 145/* If we find an EC via the ECDT, we need to keep a ptr to its context */
146static union acpi_ec *ec_ecdt; 146static union acpi_ec *ec_ecdt;
147 147
148/* External interfaces use first EC only, so remember */ 148/* External interfaces use first EC only, so remember */
149static struct acpi_device *first_ec; 149static struct acpi_device *first_ec;
150static int acpi_ec_polling_mode = EC_POLLING; 150static int acpi_ec_poll_mode = EC_INTR;
151 151
152/* -------------------------------------------------------------------------- 152/* --------------------------------------------------------------------------
153 Transaction Management 153 Transaction Management
@@ -163,13 +163,13 @@ static u32 acpi_ec_read_status(union acpi_ec *ec)
163 163
164static int acpi_ec_wait(union acpi_ec *ec, u8 event) 164static int acpi_ec_wait(union acpi_ec *ec, u8 event)
165{ 165{
166 if (acpi_ec_polling_mode) 166 if (acpi_ec_poll_mode)
167 return acpi_ec_polling_wait(ec, event); 167 return acpi_ec_poll_wait(ec, event);
168 else 168 else
169 return acpi_ec_burst_wait(ec, event); 169 return acpi_ec_intr_wait(ec, event);
170} 170}
171 171
172static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event) 172static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event)
173{ 173{
174 u32 acpi_ec_status = 0; 174 u32 acpi_ec_status = 0;
175 u32 i = ACPI_EC_UDELAY_COUNT; 175 u32 i = ACPI_EC_UDELAY_COUNT;
@@ -203,36 +203,31 @@ static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event)
203 203
204 return -ETIME; 204 return -ETIME;
205} 205}
206static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) 206static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
207{ 207{
208 int result = 0; 208 int result = 0;
209 209
210 ACPI_FUNCTION_TRACE("acpi_ec_wait"); 210 ACPI_FUNCTION_TRACE("acpi_ec_wait");
211 211
212 ec->burst.expect_event = event; 212 ec->intr.expect_event = event;
213 smp_mb(); 213 smp_mb();
214 214
215 switch (event) { 215 switch (event) {
216 case ACPI_EC_EVENT_OBF:
217 if (acpi_ec_read_status(ec) & event) {
218 ec->burst.expect_event = 0;
219 return_VALUE(0);
220 }
221 break;
222
223 case ACPI_EC_EVENT_IBE: 216 case ACPI_EC_EVENT_IBE:
224 if (~acpi_ec_read_status(ec) & event) { 217 if (~acpi_ec_read_status(ec) & event) {
225 ec->burst.expect_event = 0; 218 ec->intr.expect_event = 0;
226 return_VALUE(0); 219 return_VALUE(0);
227 } 220 }
228 break; 221 break;
222 default:
223 break;
229 } 224 }
230 225
231 result = wait_event_timeout(ec->burst.wait, 226 result = wait_event_timeout(ec->intr.wait,
232 !ec->burst.expect_event, 227 !ec->intr.expect_event,
233 msecs_to_jiffies(ACPI_EC_DELAY)); 228 msecs_to_jiffies(ACPI_EC_DELAY));
234 229
235 ec->burst.expect_event = 0; 230 ec->intr.expect_event = 0;
236 smp_mb(); 231 smp_mb();
237 232
238 /* 233 /*
@@ -255,7 +250,12 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
255 return_VALUE(-ETIME); 250 return_VALUE(-ETIME);
256} 251}
257 252
258static int acpi_ec_enter_burst_mode(union acpi_ec *ec) 253#ifdef ACPI_FUTURE_USAGE
254/*
255 * Note: samsung nv5000 doesn't work with ec burst mode.
256 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
257 */
258int acpi_ec_enter_burst_mode(union acpi_ec *ec)
259{ 259{
260 u32 tmp = 0; 260 u32 tmp = 0;
261 int status = 0; 261 int status = 0;
@@ -270,45 +270,56 @@ static int acpi_ec_enter_burst_mode(union acpi_ec *ec)
270 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, 270 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE,
271 &ec->common.command_addr); 271 &ec->common.command_addr);
272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
273 if (status)
274 return_VALUE(-EINVAL);
275 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 273 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
276 if (tmp != 0x90) { /* Burst ACK byte */ 274 if (tmp != 0x90) { /* Burst ACK byte */
277 return_VALUE(-EINVAL); 275 return_VALUE(-EINVAL);
278 } 276 }
279 } 277 }
280 278
281 atomic_set(&ec->burst.leaving_burst, 0); 279 atomic_set(&ec->intr.leaving_burst, 0);
282 return_VALUE(0); 280 return_VALUE(0);
283 end: 281 end:
284 printk("Error in acpi_ec_wait\n"); 282 printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n");
285 return_VALUE(-1); 283 return_VALUE(-1);
286} 284}
287 285
288static int acpi_ec_leave_burst_mode(union acpi_ec *ec) 286int acpi_ec_leave_burst_mode(union acpi_ec *ec)
289{ 287{
288 int status = 0;
290 289
291 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 290 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
292 291
293 atomic_set(&ec->burst.leaving_burst, 1); 292 status = acpi_ec_read_status(ec);
293 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
294 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
295 if(status)
296 goto end;
297 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr);
298 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
299 }
300 atomic_set(&ec->intr.leaving_burst, 1);
294 return_VALUE(0); 301 return_VALUE(0);
302end:
303 printk(KERN_WARNING PREFIX "leave burst_mode:error\n");
304 return_VALUE(-1);
295} 305}
306#endif /* ACPI_FUTURE_USAGE */
296 307
297static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) 308static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data)
298{ 309{
299 if (acpi_ec_polling_mode) 310 if (acpi_ec_poll_mode)
300 return acpi_ec_polling_read(ec, address, data); 311 return acpi_ec_poll_read(ec, address, data);
301 else 312 else
302 return acpi_ec_burst_read(ec, address, data); 313 return acpi_ec_intr_read(ec, address, data);
303} 314}
304static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) 315static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data)
305{ 316{
306 if (acpi_ec_polling_mode) 317 if (acpi_ec_poll_mode)
307 return acpi_ec_polling_write(ec, address, data); 318 return acpi_ec_poll_write(ec, address, data);
308 else 319 else
309 return acpi_ec_burst_write(ec, address, data); 320 return acpi_ec_intr_write(ec, address, data);
310} 321}
311static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data) 322static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
312{ 323{
313 acpi_status status = AE_OK; 324 acpi_status status = AE_OK;
314 int result = 0; 325 int result = 0;
@@ -328,7 +339,7 @@ static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
328 return_VALUE(-ENODEV); 339 return_VALUE(-ENODEV);
329 } 340 }
330 341
331 spin_lock_irqsave(&ec->polling.lock, flags); 342 spin_lock_irqsave(&ec->poll.lock, flags);
332 343
333 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, 344 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
334 &ec->common.command_addr); 345 &ec->common.command_addr);
@@ -347,7 +358,7 @@ static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
347 *data, address)); 358 *data, address));
348 359
349 end: 360 end:
350 spin_unlock_irqrestore(&ec->polling.lock, flags); 361 spin_unlock_irqrestore(&ec->poll.lock, flags);
351 362
352 if (ec->common.global_lock) 363 if (ec->common.global_lock)
353 acpi_release_global_lock(glk); 364 acpi_release_global_lock(glk);
@@ -355,7 +366,7 @@ static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
355 return_VALUE(result); 366 return_VALUE(result);
356} 367}
357 368
358static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data) 369static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
359{ 370{
360 int result = 0; 371 int result = 0;
361 acpi_status status = AE_OK; 372 acpi_status status = AE_OK;
@@ -373,7 +384,7 @@ static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
373 return_VALUE(-ENODEV); 384 return_VALUE(-ENODEV);
374 } 385 }
375 386
376 spin_lock_irqsave(&ec->polling.lock, flags); 387 spin_lock_irqsave(&ec->poll.lock, flags);
377 388
378 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, 389 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
379 &ec->common.command_addr); 390 &ec->common.command_addr);
@@ -395,7 +406,7 @@ static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
395 data, address)); 406 data, address));
396 407
397 end: 408 end:
398 spin_unlock_irqrestore(&ec->polling.lock, flags); 409 spin_unlock_irqrestore(&ec->poll.lock, flags);
399 410
400 if (ec->common.global_lock) 411 if (ec->common.global_lock)
401 acpi_release_global_lock(glk); 412 acpi_release_global_lock(glk);
@@ -403,7 +414,7 @@ static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
403 return_VALUE(result); 414 return_VALUE(result);
404} 415}
405 416
406static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data) 417static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
407{ 418{
408 int status = 0; 419 int status = 0;
409 u32 glk; 420 u32 glk;
@@ -422,25 +433,24 @@ static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
422 } 433 }
423 434
424 WARN_ON(in_interrupt()); 435 WARN_ON(in_interrupt());
425 down(&ec->burst.sem); 436 down(&ec->intr.sem);
426 437
427 acpi_ec_enter_burst_mode(ec);
428 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 438 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
429 if (status) { 439 if (status) {
430 printk("read EC, IB not empty\n"); 440 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
431 goto end; 441 goto end;
432 } 442 }
433 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, 443 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
434 &ec->common.command_addr); 444 &ec->common.command_addr);
435 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 445 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
436 if (status) { 446 if (status) {
437 printk("read EC, IB not empty\n"); 447 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
438 } 448 }
439 449
440 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 450 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
441 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 451 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
442 if (status) { 452 if (status) {
443 printk("read EC, OB not full\n"); 453 printk(KERN_DEBUG PREFIX "read EC, OB not full\n");
444 goto end; 454 goto end;
445 } 455 }
446 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 456 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
@@ -448,8 +458,7 @@ static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
448 *data, address)); 458 *data, address));
449 459
450 end: 460 end:
451 acpi_ec_leave_burst_mode(ec); 461 up(&ec->intr.sem);
452 up(&ec->burst.sem);
453 462
454 if (ec->common.global_lock) 463 if (ec->common.global_lock)
455 acpi_release_global_lock(glk); 464 acpi_release_global_lock(glk);
@@ -457,7 +466,7 @@ static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
457 return_VALUE(status); 466 return_VALUE(status);
458} 467}
459 468
460static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data) 469static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
461{ 470{
462 int status = 0; 471 int status = 0;
463 u32 glk; 472 u32 glk;
@@ -474,25 +483,23 @@ static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data)
474 } 483 }
475 484
476 WARN_ON(in_interrupt()); 485 WARN_ON(in_interrupt());
477 down(&ec->burst.sem); 486 down(&ec->intr.sem);
478
479 acpi_ec_enter_burst_mode(ec);
480 487
481 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 488 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
482 if (status) { 489 if (status) {
483 printk("write EC, IB not empty\n"); 490 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
484 } 491 }
485 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, 492 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
486 &ec->common.command_addr); 493 &ec->common.command_addr);
487 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 494 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
488 if (status) { 495 if (status) {
489 printk("write EC, IB not empty\n"); 496 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
490 } 497 }
491 498
492 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 499 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
493 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 500 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
494 if (status) { 501 if (status) {
495 printk("write EC, IB not empty\n"); 502 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
496 } 503 }
497 504
498 acpi_hw_low_level_write(8, data, &ec->common.data_addr); 505 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
@@ -500,8 +507,7 @@ static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data)
500 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 507 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
501 data, address)); 508 data, address));
502 509
503 acpi_ec_leave_burst_mode(ec); 510 up(&ec->intr.sem);
504 up(&ec->burst.sem);
505 511
506 if (ec->common.global_lock) 512 if (ec->common.global_lock)
507 acpi_release_global_lock(glk); 513 acpi_release_global_lock(glk);
@@ -553,12 +559,12 @@ EXPORT_SYMBOL(ec_write);
553 559
554static int acpi_ec_query(union acpi_ec *ec, u32 * data) 560static int acpi_ec_query(union acpi_ec *ec, u32 * data)
555{ 561{
556 if (acpi_ec_polling_mode) 562 if (acpi_ec_poll_mode)
557 return acpi_ec_polling_query(ec, data); 563 return acpi_ec_poll_query(ec, data);
558 else 564 else
559 return acpi_ec_burst_query(ec, data); 565 return acpi_ec_intr_query(ec, data);
560} 566}
561static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data) 567static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
562{ 568{
563 int result = 0; 569 int result = 0;
564 acpi_status status = AE_OK; 570 acpi_status status = AE_OK;
@@ -583,7 +589,7 @@ static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data)
583 * Note that successful completion of the query causes the ACPI_EC_SCI 589 * Note that successful completion of the query causes the ACPI_EC_SCI
584 * bit to be cleared (and thus clearing the interrupt source). 590 * bit to be cleared (and thus clearing the interrupt source).
585 */ 591 */
586 spin_lock_irqsave(&ec->polling.lock, flags); 592 spin_lock_irqsave(&ec->poll.lock, flags);
587 593
588 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, 594 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
589 &ec->common.command_addr); 595 &ec->common.command_addr);
@@ -596,14 +602,14 @@ static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data)
596 result = -ENODATA; 602 result = -ENODATA;
597 603
598 end: 604 end:
599 spin_unlock_irqrestore(&ec->polling.lock, flags); 605 spin_unlock_irqrestore(&ec->poll.lock, flags);
600 606
601 if (ec->common.global_lock) 607 if (ec->common.global_lock)
602 acpi_release_global_lock(glk); 608 acpi_release_global_lock(glk);
603 609
604 return_VALUE(result); 610 return_VALUE(result);
605} 611}
606static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data) 612static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
607{ 613{
608 int status = 0; 614 int status = 0;
609 u32 glk; 615 u32 glk;
@@ -620,11 +626,11 @@ static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
620 return_VALUE(-ENODEV); 626 return_VALUE(-ENODEV);
621 } 627 }
622 628
623 down(&ec->burst.sem); 629 down(&ec->intr.sem);
624 630
625 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 631 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
626 if (status) { 632 if (status) {
627 printk("query EC, IB not empty\n"); 633 printk(KERN_DEBUG PREFIX "query EC, IB not empty\n");
628 goto end; 634 goto end;
629 } 635 }
630 /* 636 /*
@@ -636,7 +642,7 @@ static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
636 &ec->common.command_addr); 642 &ec->common.command_addr);
637 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 643 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
638 if (status) { 644 if (status) {
639 printk("query EC, OB not full\n"); 645 printk(KERN_DEBUG PREFIX "query EC, OB not full\n");
640 goto end; 646 goto end;
641 } 647 }
642 648
@@ -645,7 +651,7 @@ static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
645 status = -ENODATA; 651 status = -ENODATA;
646 652
647 end: 653 end:
648 up(&ec->burst.sem); 654 up(&ec->intr.sem);
649 655
650 if (ec->common.global_lock) 656 if (ec->common.global_lock)
651 acpi_release_global_lock(glk); 657 acpi_release_global_lock(glk);
@@ -664,13 +670,13 @@ union acpi_ec_query_data {
664 670
665static void acpi_ec_gpe_query(void *ec_cxt) 671static void acpi_ec_gpe_query(void *ec_cxt)
666{ 672{
667 if (acpi_ec_polling_mode) 673 if (acpi_ec_poll_mode)
668 acpi_ec_gpe_polling_query(ec_cxt); 674 acpi_ec_gpe_poll_query(ec_cxt);
669 else 675 else
670 acpi_ec_gpe_burst_query(ec_cxt); 676 acpi_ec_gpe_intr_query(ec_cxt);
671} 677}
672 678
673static void acpi_ec_gpe_polling_query(void *ec_cxt) 679static void acpi_ec_gpe_poll_query(void *ec_cxt)
674{ 680{
675 union acpi_ec *ec = (union acpi_ec *)ec_cxt; 681 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
676 u32 value = 0; 682 u32 value = 0;
@@ -685,9 +691,9 @@ static void acpi_ec_gpe_polling_query(void *ec_cxt)
685 if (!ec_cxt) 691 if (!ec_cxt)
686 goto end; 692 goto end;
687 693
688 spin_lock_irqsave(&ec->polling.lock, flags); 694 spin_lock_irqsave(&ec->poll.lock, flags);
689 acpi_hw_low_level_read(8, &value, &ec->common.command_addr); 695 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
690 spin_unlock_irqrestore(&ec->polling.lock, flags); 696 spin_unlock_irqrestore(&ec->poll.lock, flags);
691 697
692 /* TBD: Implement asynch events! 698 /* TBD: Implement asynch events!
693 * NOTE: All we care about are EC-SCI's. Other EC events are 699 * NOTE: All we care about are EC-SCI's. Other EC events are
@@ -711,7 +717,7 @@ static void acpi_ec_gpe_polling_query(void *ec_cxt)
711 end: 717 end:
712 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 718 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
713} 719}
714static void acpi_ec_gpe_burst_query(void *ec_cxt) 720static void acpi_ec_gpe_intr_query(void *ec_cxt)
715{ 721{
716 union acpi_ec *ec = (union acpi_ec *)ec_cxt; 722 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
717 u32 value; 723 u32 value;
@@ -736,18 +742,18 @@ static void acpi_ec_gpe_burst_query(void *ec_cxt)
736 742
737 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 743 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
738 end: 744 end:
739 atomic_dec(&ec->burst.pending_gpe); 745 atomic_dec(&ec->intr.pending_gpe);
740 return; 746 return;
741} 747}
742 748
743static u32 acpi_ec_gpe_handler(void *data) 749static u32 acpi_ec_gpe_handler(void *data)
744{ 750{
745 if (acpi_ec_polling_mode) 751 if (acpi_ec_poll_mode)
746 return acpi_ec_gpe_polling_handler(data); 752 return acpi_ec_gpe_poll_handler(data);
747 else 753 else
748 return acpi_ec_gpe_burst_handler(data); 754 return acpi_ec_gpe_intr_handler(data);
749} 755}
750static u32 acpi_ec_gpe_polling_handler(void *data) 756static u32 acpi_ec_gpe_poll_handler(void *data)
751{ 757{
752 acpi_status status = AE_OK; 758 acpi_status status = AE_OK;
753 union acpi_ec *ec = (union acpi_ec *)data; 759 union acpi_ec *ec = (union acpi_ec *)data;
@@ -765,7 +771,7 @@ static u32 acpi_ec_gpe_polling_handler(void *data)
765 else 771 else
766 return ACPI_INTERRUPT_NOT_HANDLED; 772 return ACPI_INTERRUPT_NOT_HANDLED;
767} 773}
768static u32 acpi_ec_gpe_burst_handler(void *data) 774static u32 acpi_ec_gpe_intr_handler(void *data)
769{ 775{
770 acpi_status status = AE_OK; 776 acpi_status status = AE_OK;
771 u32 value; 777 u32 value;
@@ -777,22 +783,22 @@ static u32 acpi_ec_gpe_burst_handler(void *data)
777 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 783 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
778 value = acpi_ec_read_status(ec); 784 value = acpi_ec_read_status(ec);
779 785
780 switch (ec->burst.expect_event) { 786 switch (ec->intr.expect_event) {
781 case ACPI_EC_EVENT_OBF: 787 case ACPI_EC_EVENT_OBF:
782 if (!(value & ACPI_EC_FLAG_OBF)) 788 if (!(value & ACPI_EC_FLAG_OBF))
783 break; 789 break;
784 case ACPI_EC_EVENT_IBE: 790 case ACPI_EC_EVENT_IBE:
785 if ((value & ACPI_EC_FLAG_IBF)) 791 if ((value & ACPI_EC_FLAG_IBF))
786 break; 792 break;
787 ec->burst.expect_event = 0; 793 ec->intr.expect_event = 0;
788 wake_up(&ec->burst.wait); 794 wake_up(&ec->intr.wait);
789 return ACPI_INTERRUPT_HANDLED; 795 return ACPI_INTERRUPT_HANDLED;
790 default: 796 default:
791 break; 797 break;
792 } 798 }
793 799
794 if (value & ACPI_EC_FLAG_SCI) { 800 if (value & ACPI_EC_FLAG_SCI) {
795 atomic_add(1, &ec->burst.pending_gpe); 801 atomic_add(1, &ec->intr.pending_gpe);
796 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 802 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
797 acpi_ec_gpe_query, ec); 803 acpi_ec_gpe_query, ec);
798 return status == AE_OK ? 804 return status == AE_OK ?
@@ -980,7 +986,7 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
980 Driver Interface 986 Driver Interface
981 -------------------------------------------------------------------------- */ 987 -------------------------------------------------------------------------- */
982 988
983static int acpi_ec_polling_add(struct acpi_device *device) 989static int acpi_ec_poll_add(struct acpi_device *device)
984{ 990{
985 int result = 0; 991 int result = 0;
986 acpi_status status = AE_OK; 992 acpi_status status = AE_OK;
@@ -999,7 +1005,7 @@ static int acpi_ec_polling_add(struct acpi_device *device)
999 1005
1000 ec->common.handle = device->handle; 1006 ec->common.handle = device->handle;
1001 ec->common.uid = -1; 1007 ec->common.uid = -1;
1002 spin_lock_init(&ec->polling.lock); 1008 spin_lock_init(&ec->poll.lock);
1003 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1009 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1004 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1010 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1005 acpi_driver_data(device) = ec; 1011 acpi_driver_data(device) = ec;
@@ -1038,7 +1044,7 @@ static int acpi_ec_polling_add(struct acpi_device *device)
1038 if (result) 1044 if (result)
1039 goto end; 1045 goto end;
1040 1046
1041 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1047 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) polling mode.\n",
1042 acpi_device_name(device), acpi_device_bid(device), 1048 acpi_device_name(device), acpi_device_bid(device),
1043 (u32) ec->common.gpe_bit); 1049 (u32) ec->common.gpe_bit);
1044 1050
@@ -1051,7 +1057,7 @@ static int acpi_ec_polling_add(struct acpi_device *device)
1051 1057
1052 return_VALUE(result); 1058 return_VALUE(result);
1053} 1059}
1054static int acpi_ec_burst_add(struct acpi_device *device) 1060static int acpi_ec_intr_add(struct acpi_device *device)
1055{ 1061{
1056 int result = 0; 1062 int result = 0;
1057 acpi_status status = AE_OK; 1063 acpi_status status = AE_OK;
@@ -1070,10 +1076,10 @@ static int acpi_ec_burst_add(struct acpi_device *device)
1070 1076
1071 ec->common.handle = device->handle; 1077 ec->common.handle = device->handle;
1072 ec->common.uid = -1; 1078 ec->common.uid = -1;
1073 atomic_set(&ec->burst.pending_gpe, 0); 1079 atomic_set(&ec->intr.pending_gpe, 0);
1074 atomic_set(&ec->burst.leaving_burst, 1); 1080 atomic_set(&ec->intr.leaving_burst, 1);
1075 init_MUTEX(&ec->burst.sem); 1081 init_MUTEX(&ec->intr.sem);
1076 init_waitqueue_head(&ec->burst.wait); 1082 init_waitqueue_head(&ec->intr.wait);
1077 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1083 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1078 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1084 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1079 acpi_driver_data(device) = ec; 1085 acpi_driver_data(device) = ec;
@@ -1112,8 +1118,7 @@ static int acpi_ec_burst_add(struct acpi_device *device)
1112 if (result) 1118 if (result)
1113 goto end; 1119 goto end;
1114 1120
1115 printk("burst-mode-ec-10-Aug\n"); 1121 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) interrupt mode.\n",
1116 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1117 acpi_device_name(device), acpi_device_bid(device), 1122 acpi_device_name(device), acpi_device_bid(device),
1118 (u32) ec->common.gpe_bit); 1123 (u32) ec->common.gpe_bit);
1119 1124
@@ -1151,7 +1156,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1151 union acpi_ec *ec = (union acpi_ec *)context; 1156 union acpi_ec *ec = (union acpi_ec *)context;
1152 struct acpi_generic_address *addr; 1157 struct acpi_generic_address *addr;
1153 1158
1154 if (resource->id != ACPI_RSTYPE_IO) { 1159 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
1155 return AE_OK; 1160 return AE_OK;
1156 } 1161 }
1157 1162
@@ -1171,7 +1176,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1171 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 1176 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1172 addr->register_bit_width = 8; 1177 addr->register_bit_width = 8;
1173 addr->register_bit_offset = 0; 1178 addr->register_bit_offset = 0;
1174 addr->address = resource->data.io.min_base_address; 1179 addr->address = resource->data.io.minimum;
1175 1180
1176 return AE_OK; 1181 return AE_OK;
1177} 1182}
@@ -1267,16 +1272,16 @@ acpi_fake_ecdt_callback(acpi_handle handle,
1267 u32 Level, void *context, void **retval) 1272 u32 Level, void *context, void **retval)
1268{ 1273{
1269 1274
1270 if (acpi_ec_polling_mode) 1275 if (acpi_ec_poll_mode)
1271 return acpi_fake_ecdt_polling_callback(handle, 1276 return acpi_fake_ecdt_poll_callback(handle,
1272 Level, context, retval); 1277 Level, context, retval);
1273 else 1278 else
1274 return acpi_fake_ecdt_burst_callback(handle, 1279 return acpi_fake_ecdt_intr_callback(handle,
1275 Level, context, retval); 1280 Level, context, retval);
1276} 1281}
1277 1282
1278static acpi_status __init 1283static acpi_status __init
1279acpi_fake_ecdt_polling_callback(acpi_handle handle, 1284acpi_fake_ecdt_poll_callback(acpi_handle handle,
1280 u32 Level, void *context, void **retval) 1285 u32 Level, void *context, void **retval)
1281{ 1286{
1282 acpi_status status; 1287 acpi_status status;
@@ -1295,7 +1300,7 @@ acpi_fake_ecdt_polling_callback(acpi_handle handle,
1295 &ec_ecdt->common.gpe_bit); 1300 &ec_ecdt->common.gpe_bit);
1296 if (ACPI_FAILURE(status)) 1301 if (ACPI_FAILURE(status))
1297 return status; 1302 return status;
1298 spin_lock_init(&ec_ecdt->polling.lock); 1303 spin_lock_init(&ec_ecdt->poll.lock);
1299 ec_ecdt->common.global_lock = TRUE; 1304 ec_ecdt->common.global_lock = TRUE;
1300 ec_ecdt->common.handle = handle; 1305 ec_ecdt->common.handle = handle;
1301 1306
@@ -1308,13 +1313,13 @@ acpi_fake_ecdt_polling_callback(acpi_handle handle,
1308} 1313}
1309 1314
1310static acpi_status __init 1315static acpi_status __init
1311acpi_fake_ecdt_burst_callback(acpi_handle handle, 1316acpi_fake_ecdt_intr_callback(acpi_handle handle,
1312 u32 Level, void *context, void **retval) 1317 u32 Level, void *context, void **retval)
1313{ 1318{
1314 acpi_status status; 1319 acpi_status status;
1315 1320
1316 init_MUTEX(&ec_ecdt->burst.sem); 1321 init_MUTEX(&ec_ecdt->intr.sem);
1317 init_waitqueue_head(&ec_ecdt->burst.wait); 1322 init_waitqueue_head(&ec_ecdt->intr.wait);
1318 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1323 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1319 acpi_ec_io_ports, ec_ecdt); 1324 acpi_ec_io_ports, ec_ecdt);
1320 if (ACPI_FAILURE(status)) 1325 if (ACPI_FAILURE(status))
@@ -1380,13 +1385,13 @@ static int __init acpi_ec_fake_ecdt(void)
1380 1385
1381static int __init acpi_ec_get_real_ecdt(void) 1386static int __init acpi_ec_get_real_ecdt(void)
1382{ 1387{
1383 if (acpi_ec_polling_mode) 1388 if (acpi_ec_poll_mode)
1384 return acpi_ec_polling_get_real_ecdt(); 1389 return acpi_ec_poll_get_real_ecdt();
1385 else 1390 else
1386 return acpi_ec_burst_get_real_ecdt(); 1391 return acpi_ec_intr_get_real_ecdt();
1387} 1392}
1388 1393
1389static int __init acpi_ec_polling_get_real_ecdt(void) 1394static int __init acpi_ec_poll_get_real_ecdt(void)
1390{ 1395{
1391 acpi_status status; 1396 acpi_status status;
1392 struct acpi_table_ecdt *ecdt_ptr; 1397 struct acpi_table_ecdt *ecdt_ptr;
@@ -1411,7 +1416,7 @@ static int __init acpi_ec_polling_get_real_ecdt(void)
1411 ec_ecdt->common.status_addr = ecdt_ptr->ec_control; 1416 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1412 ec_ecdt->common.data_addr = ecdt_ptr->ec_data; 1417 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1413 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit; 1418 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1414 spin_lock_init(&ec_ecdt->polling.lock); 1419 spin_lock_init(&ec_ecdt->poll.lock);
1415 /* use the GL just to be safe */ 1420 /* use the GL just to be safe */
1416 ec_ecdt->common.global_lock = TRUE; 1421 ec_ecdt->common.global_lock = TRUE;
1417 ec_ecdt->common.uid = ecdt_ptr->uid; 1422 ec_ecdt->common.uid = ecdt_ptr->uid;
@@ -1431,7 +1436,7 @@ static int __init acpi_ec_polling_get_real_ecdt(void)
1431 return -ENODEV; 1436 return -ENODEV;
1432} 1437}
1433 1438
1434static int __init acpi_ec_burst_get_real_ecdt(void) 1439static int __init acpi_ec_intr_get_real_ecdt(void)
1435{ 1440{
1436 acpi_status status; 1441 acpi_status status;
1437 struct acpi_table_ecdt *ecdt_ptr; 1442 struct acpi_table_ecdt *ecdt_ptr;
@@ -1452,8 +1457,8 @@ static int __init acpi_ec_burst_get_real_ecdt(void)
1452 return -ENOMEM; 1457 return -ENOMEM;
1453 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 1458 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1454 1459
1455 init_MUTEX(&ec_ecdt->burst.sem); 1460 init_MUTEX(&ec_ecdt->intr.sem);
1456 init_waitqueue_head(&ec_ecdt->burst.wait); 1461 init_waitqueue_head(&ec_ecdt->intr.wait);
1457 ec_ecdt->common.command_addr = ecdt_ptr->ec_control; 1462 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1458 ec_ecdt->common.status_addr = ecdt_ptr->ec_control; 1463 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1459 ec_ecdt->common.data_addr = ecdt_ptr->ec_data; 1464 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
@@ -1571,22 +1576,22 @@ static int __init acpi_fake_ecdt_setup(char *str)
1571} 1576}
1572 1577
1573__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup); 1578__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1574static int __init acpi_ec_set_polling_mode(char *str) 1579static int __init acpi_ec_set_intr_mode(char *str)
1575{ 1580{
1576 int burst; 1581 int intr;
1577 1582
1578 if (!get_option(&str, &burst)) 1583 if (!get_option(&str, &intr))
1579 return 0; 1584 return 0;
1580 1585
1581 if (burst) { 1586 if (intr) {
1582 acpi_ec_polling_mode = EC_BURST; 1587 acpi_ec_poll_mode = EC_INTR;
1583 acpi_ec_driver.ops.add = acpi_ec_burst_add; 1588 acpi_ec_driver.ops.add = acpi_ec_intr_add;
1584 } else { 1589 } else {
1585 acpi_ec_polling_mode = EC_POLLING; 1590 acpi_ec_poll_mode = EC_POLL;
1586 acpi_ec_driver.ops.add = acpi_ec_polling_add; 1591 acpi_ec_driver.ops.add = acpi_ec_poll_add;
1587 } 1592 }
1588 printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling"); 1593 printk(KERN_INFO PREFIX "EC %s mode.\n", intr ? "interrupt" : "polling");
1589 return 0; 1594 return 0;
1590} 1595}
1591 1596
1592__setup("ec_burst=", acpi_ec_set_polling_mode); 1597__setup("ec_intr=", acpi_ec_set_intr_mode);
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index 842d1e3fb37b..c9ac05c4685f 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -73,7 +73,7 @@ acpi_status acpi_ev_initialize_events(void)
73 /* Make sure we have ACPI tables */ 73 /* Make sure we have ACPI tables */
74 74
75 if (!acpi_gbl_DSDT) { 75 if (!acpi_gbl_DSDT) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n")); 76 ACPI_WARNING((AE_INFO, "No ACPI tables present!"));
77 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 77 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
78 } 78 }
79 79
@@ -84,14 +84,15 @@ acpi_status acpi_ev_initialize_events(void)
84 */ 84 */
85 status = acpi_ev_fixed_event_initialize(); 85 status = acpi_ev_fixed_event_initialize();
86 if (ACPI_FAILURE(status)) { 86 if (ACPI_FAILURE(status)) {
87 ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n", 87 ACPI_EXCEPTION((AE_INFO, status,
88 acpi_format_exception(status))); 88 "Unable to initialize fixed events"));
89 return_ACPI_STATUS(status); 89 return_ACPI_STATUS(status);
90 } 90 }
91 91
92 status = acpi_ev_gpe_initialize(); 92 status = acpi_ev_gpe_initialize();
93 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
94 ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status))); 94 ACPI_EXCEPTION((AE_INFO, status,
95 "Unable to initialize general purpose events"));
95 return_ACPI_STATUS(status); 96 return_ACPI_STATUS(status);
96 } 97 }
97 98
@@ -100,6 +101,48 @@ acpi_status acpi_ev_initialize_events(void)
100 101
101/******************************************************************************* 102/*******************************************************************************
102 * 103 *
104 * FUNCTION: acpi_ev_install_fadt_gpes
105 *
106 * PARAMETERS: None
107 *
108 * RETURN: Status
109 *
110 * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks
111 * (0 and 1). This causes the _PRW methods to be run, so the HW
112 * must be fully initialized at this point, including global lock
113 * support.
114 *
115 ******************************************************************************/
116
117acpi_status acpi_ev_install_fadt_gpes(void)
118{
119 acpi_status status;
120
121 ACPI_FUNCTION_TRACE("ev_install_fadt_gpes");
122
123 /* Namespace must be locked */
124
125 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
126 if (ACPI_FAILURE(status)) {
127 return (status);
128 }
129
130 /* FADT GPE Block 0 */
131
132 (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device,
133 acpi_gbl_gpe_fadt_blocks[0]);
134
135 /* FADT GPE Block 1 */
136
137 (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device,
138 acpi_gbl_gpe_fadt_blocks[1]);
139
140 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
141 return_ACPI_STATUS(AE_OK);
142}
143
144/*******************************************************************************
145 *
103 * FUNCTION: acpi_ev_install_xrupt_handlers 146 * FUNCTION: acpi_ev_install_xrupt_handlers
104 * 147 *
105 * PARAMETERS: None 148 * PARAMETERS: None
@@ -120,7 +163,8 @@ acpi_status acpi_ev_install_xrupt_handlers(void)
120 163
121 status = acpi_ev_install_sci_handler(); 164 status = acpi_ev_install_sci_handler();
122 if (ACPI_FAILURE(status)) { 165 if (ACPI_FAILURE(status)) {
123 ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status))); 166 ACPI_EXCEPTION((AE_INFO, status,
167 "Unable to install System Control Interrupt handler"));
124 return_ACPI_STATUS(status); 168 return_ACPI_STATUS(status);
125 } 169 }
126 170
@@ -128,7 +172,8 @@ acpi_status acpi_ev_install_xrupt_handlers(void)
128 172
129 status = acpi_ev_init_global_lock_handler(); 173 status = acpi_ev_init_global_lock_handler();
130 if (ACPI_FAILURE(status)) { 174 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status))); 175 ACPI_EXCEPTION((AE_INFO, status,
176 "Unable to initialize Global Lock handler"));
132 return_ACPI_STATUS(status); 177 return_ACPI_STATUS(status);
133 } 178 }
134 179
@@ -262,7 +307,9 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
262 enable_register_id, 0, 307 enable_register_id, 0,
263 ACPI_MTX_DO_NOT_LOCK); 308 ACPI_MTX_DO_NOT_LOCK);
264 309
265 ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event)); 310 ACPI_ERROR((AE_INFO,
311 "No installed handler for fixed event [%08X]",
312 event));
266 313
267 return (ACPI_INTERRUPT_NOT_HANDLED); 314 return (ACPI_INTERRUPT_NOT_HANDLED);
268 } 315 }
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index b2f232df13d8..f64f977dd3d5 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -372,14 +372,14 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
372 372
373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) 373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
374{ 374{
375 acpi_status status;
376 struct acpi_gpe_block_info *gpe_block;
377 struct acpi_gpe_register_info *gpe_register_info;
375 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 378 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
376 u8 enabled_status_byte; 379 u8 enabled_status_byte;
377 struct acpi_gpe_register_info *gpe_register_info;
378 u32 status_reg; 380 u32 status_reg;
379 u32 enable_reg; 381 u32 enable_reg;
380 u32 flags; 382 acpi_cpu_flags flags;
381 acpi_status status;
382 struct acpi_gpe_block_info *gpe_block;
383 acpi_native_uint i; 383 acpi_native_uint i;
384 acpi_native_uint j; 384 acpi_native_uint j;
385 385
@@ -546,7 +546,11 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
546 546
547 status = acpi_ns_evaluate_by_handle(&info); 547 status = acpi_ns_evaluate_by_handle(&info);
548 if (ACPI_FAILURE(status)) { 548 if (ACPI_FAILURE(status)) {
549 ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number)); 549 ACPI_EXCEPTION((AE_INFO, status,
550 "While evaluating method [%4.4s] for GPE[%2X]",
551 acpi_ut_get_node_name
552 (local_gpe_event_info.dispatch.
553 method_node), gpe_number));
550 } 554 }
551 } 555 }
552 556
@@ -599,8 +603,10 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
599 ACPI_GPE_EDGE_TRIGGERED) { 603 ACPI_GPE_EDGE_TRIGGERED) {
600 status = acpi_hw_clear_gpe(gpe_event_info); 604 status = acpi_hw_clear_gpe(gpe_event_info);
601 if (ACPI_FAILURE(status)) { 605 if (ACPI_FAILURE(status)) {
602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 606 ACPI_EXCEPTION((AE_INFO, status,
603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 607 "Unable to clear GPE[%2X]",
608 gpe_number));
609 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
604 } 610 }
605 } 611 }
606 612
@@ -637,8 +643,10 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
637 ACPI_GPE_LEVEL_TRIGGERED) { 643 ACPI_GPE_LEVEL_TRIGGERED) {
638 status = acpi_hw_clear_gpe(gpe_event_info); 644 status = acpi_hw_clear_gpe(gpe_event_info);
639 if (ACPI_FAILURE(status)) { 645 if (ACPI_FAILURE(status)) {
640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 646 ACPI_EXCEPTION((AE_INFO, status,
641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 647 "Unable to clear GPE[%2X]",
648 gpe_number));
649 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
642 } 650 }
643 } 651 }
644 break; 652 break;
@@ -651,8 +659,10 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
651 */ 659 */
652 status = acpi_ev_disable_gpe(gpe_event_info); 660 status = acpi_ev_disable_gpe(gpe_event_info);
653 if (ACPI_FAILURE(status)) { 661 if (ACPI_FAILURE(status)) {
654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 662 ACPI_EXCEPTION((AE_INFO, status,
655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 663 "Unable to disable GPE[%2X]",
664 gpe_number));
665 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
656 } 666 }
657 667
658 /* 668 /*
@@ -663,7 +673,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
663 acpi_ev_asynch_execute_gpe_method, 673 acpi_ev_asynch_execute_gpe_method,
664 gpe_event_info); 674 gpe_event_info);
665 if (ACPI_FAILURE(status)) { 675 if (ACPI_FAILURE(status)) {
666 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number)); 676 ACPI_EXCEPTION((AE_INFO, status,
677 "Unable to queue handler for GPE[%2X] - event disabled",
678 gpe_number));
667 } 679 }
668 break; 680 break;
669 681
@@ -671,7 +683,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
671 683
672 /* No handler or method to run! */ 684 /* No handler or method to run! */
673 685
674 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number)); 686 ACPI_ERROR((AE_INFO,
687 "No handler or method for GPE[%2X], disabling event",
688 gpe_number));
675 689
676 /* 690 /*
677 * Disable the GPE. The GPE will remain disabled until the ACPI 691 * Disable the GPE. The GPE will remain disabled until the ACPI
@@ -679,13 +693,15 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
679 */ 693 */
680 status = acpi_ev_disable_gpe(gpe_event_info); 694 status = acpi_ev_disable_gpe(gpe_event_info);
681 if (ACPI_FAILURE(status)) { 695 if (ACPI_FAILURE(status)) {
682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 696 ACPI_EXCEPTION((AE_INFO, status,
683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 697 "Unable to disable GPE[%2X]",
698 gpe_number));
699 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
684 } 700 }
685 break; 701 break;
686 } 702 }
687 703
688 return_VALUE(ACPI_INTERRUPT_HANDLED); 704 return_UINT32(ACPI_INTERRUPT_HANDLED);
689} 705}
690 706
691#ifdef ACPI_GPE_NOTIFY_CHECK 707#ifdef ACPI_GPE_NOTIFY_CHECK
@@ -722,7 +738,9 @@ acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
722 738
723 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 739 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
724 740
725 ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info)); 741 ACPI_INFO((AE_INFO,
742 "GPE %p was updated from wake/run to wake-only",
743 gpe_event_info));
726 744
727 /* This was a wake-only GPE */ 745 /* This was a wake-only GPE */
728 746
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index b312eb33c43e..0fd00b5ad650 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -78,7 +78,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
78 * 78 *
79 * RETURN: TRUE if the gpe_event is valid 79 * RETURN: TRUE if the gpe_event is valid
80 * 80 *
81 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. 81 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL.
82 * Should be called only when the GPE lists are semaphore locked 82 * Should be called only when the GPE lists are semaphore locked
83 * and not subject to change. 83 * and not subject to change.
84 * 84 *
@@ -136,7 +136,7 @@ acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
136 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
137 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
138 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
139 u32 flags; 139 acpi_cpu_flags flags;
140 140
141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list"); 141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list");
142 142
@@ -264,7 +264,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
264 * 2) Edge/Level determination is based on the 2nd character 264 * 2) Edge/Level determination is based on the 2nd character
265 * of the method name 265 * of the method name
266 * 266 *
267 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE 267 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE
268 * if a _PRW object is found that points to this GPE. 268 * if a _PRW object is found that points to this GPE.
269 */ 269 */
270 switch (name[1]) { 270 switch (name[1]) {
@@ -279,9 +279,9 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
279 default: 279 default:
280 /* Unknown method type, just ignore it! */ 280 /* Unknown method type, just ignore it! */
281 281
282 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 282 ACPI_ERROR((AE_INFO,
283 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", 283 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)",
284 name)); 284 name));
285 return_ACPI_STATUS(AE_OK); 285 return_ACPI_STATUS(AE_OK);
286 } 286 }
287 287
@@ -291,9 +291,9 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
291 if (gpe_number == ACPI_UINT32_MAX) { 291 if (gpe_number == ACPI_UINT32_MAX) {
292 /* Conversion failed; invalid method, just ignore it */ 292 /* Conversion failed; invalid method, just ignore it */
293 293
294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 294 ACPI_ERROR((AE_INFO,
295 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", 295 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)",
296 name)); 296 name));
297 return_ACPI_STATUS(AE_OK); 297 return_ACPI_STATUS(AE_OK);
298 } 298 }
299 299
@@ -313,14 +313,14 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
313 313
314 /* 314 /*
315 * Now we can add this information to the gpe_event_info block 315 * Now we can add this information to the gpe_event_info block
316 * for use during dispatch of this GPE. Default type is RUNTIME, although 316 * for use during dispatch of this GPE. Default type is RUNTIME, although
317 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
318 */ 318 */
319 gpe_event_info = 319 gpe_event_info =
320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
321 321
322 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 322 gpe_event_info->flags = (u8)
323 ACPI_GPE_TYPE_RUNTIME); 323 (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME);
324 324
325 gpe_event_info->dispatch.method_node = 325 gpe_event_info->dispatch.method_node =
326 (struct acpi_namespace_node *)obj_handle; 326 (struct acpi_namespace_node *)obj_handle;
@@ -341,11 +341,11 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
341 * 341 *
342 * PARAMETERS: Callback from walk_namespace 342 * PARAMETERS: Callback from walk_namespace
343 * 343 *
344 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is 344 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is
345 * not aborted on a single _PRW failure. 345 * not aborted on a single _PRW failure.
346 * 346 *
347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a 347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a
348 * Device. Run the _PRW method. If present, extract the GPE 348 * Device. Run the _PRW method. If present, extract the GPE
349 * number and mark the GPE as a WAKE GPE. 349 * number and mark the GPE as a WAKE GPE.
350 * 350 *
351 ******************************************************************************/ 351 ******************************************************************************/
@@ -443,6 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
443 443
444 gpe_event_info->flags &= 444 gpe_event_info->flags &=
445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
446
446 status = 447 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 448 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) { 449 if (ACPI_FAILURE(status)) {
@@ -466,7 +467,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
466 * 467 *
467 * RETURN: A GPE interrupt block 468 * RETURN: A GPE interrupt block
468 * 469 *
469 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 470 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
470 * block per unique interrupt level used for GPEs. 471 * block per unique interrupt level used for GPEs.
471 * Should be called only when the GPE lists are semaphore locked 472 * Should be called only when the GPE lists are semaphore locked
472 * and not subject to change. 473 * and not subject to change.
@@ -479,7 +480,7 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
479 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 480 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
480 struct acpi_gpe_xrupt_info *gpe_xrupt; 481 struct acpi_gpe_xrupt_info *gpe_xrupt;
481 acpi_status status; 482 acpi_status status;
482 u32 flags; 483 acpi_cpu_flags flags;
483 484
484 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block"); 485 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block");
485 486
@@ -526,9 +527,9 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
526 acpi_ev_gpe_xrupt_handler, 527 acpi_ev_gpe_xrupt_handler,
527 gpe_xrupt); 528 gpe_xrupt);
528 if (ACPI_FAILURE(status)) { 529 if (ACPI_FAILURE(status)) {
529 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 530 ACPI_ERROR((AE_INFO,
530 "Could not install GPE interrupt handler at level 0x%X\n", 531 "Could not install GPE interrupt handler at level 0x%X",
531 interrupt_number)); 532 interrupt_number));
532 return_PTR(NULL); 533 return_PTR(NULL);
533 } 534 }
534 } 535 }
@@ -553,7 +554,7 @@ static acpi_status
553acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) 554acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
554{ 555{
555 acpi_status status; 556 acpi_status status;
556 u32 flags; 557 acpi_cpu_flags flags;
557 558
558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt"); 559 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt");
559 560
@@ -566,8 +567,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
566 567
567 /* Disable this interrupt */ 568 /* Disable this interrupt */
568 569
569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, 570 status =
570 acpi_ev_gpe_xrupt_handler); 571 acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
572 acpi_ev_gpe_xrupt_handler);
571 if (ACPI_FAILURE(status)) { 573 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS(status); 574 return_ACPI_STATUS(status);
573 } 575 }
@@ -610,7 +612,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
610 struct acpi_gpe_block_info *next_gpe_block; 612 struct acpi_gpe_block_info *next_gpe_block;
611 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 613 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
612 acpi_status status; 614 acpi_status status;
613 u32 flags; 615 acpi_cpu_flags flags;
614 616
615 ACPI_FUNCTION_TRACE("ev_install_gpe_block"); 617 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
616 618
@@ -663,7 +665,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) 665acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
664{ 666{
665 acpi_status status; 667 acpi_status status;
666 u32 flags; 668 acpi_cpu_flags flags;
667 669
668 ACPI_FUNCTION_TRACE("ev_install_gpe_block"); 670 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
669 671
@@ -743,22 +745,22 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
743 sizeof(struct 745 sizeof(struct
744 acpi_gpe_register_info)); 746 acpi_gpe_register_info));
745 if (!gpe_register_info) { 747 if (!gpe_register_info) {
746 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 748 ACPI_ERROR((AE_INFO,
747 "Could not allocate the gpe_register_info table\n")); 749 "Could not allocate the gpe_register_info table"));
748 return_ACPI_STATUS(AE_NO_MEMORY); 750 return_ACPI_STATUS(AE_NO_MEMORY);
749 } 751 }
750 752
751 /* 753 /*
752 * Allocate the GPE event_info block. There are eight distinct GPEs 754 * Allocate the GPE event_info block. There are eight distinct GPEs
753 * per register. Initialization to zeros is sufficient. 755 * per register. Initialization to zeros is sufficient.
754 */ 756 */
755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> 757 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
756 register_count * 758 register_count *
757 ACPI_GPE_REGISTER_WIDTH) * 759 ACPI_GPE_REGISTER_WIDTH) *
758 sizeof(struct acpi_gpe_event_info)); 760 sizeof(struct acpi_gpe_event_info));
759 if (!gpe_event_info) { 761 if (!gpe_event_info) {
760 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 762 ACPI_ERROR((AE_INFO,
761 "Could not allocate the gpe_event_info table\n")); 763 "Could not allocate the gpe_event_info table"));
762 status = AE_NO_MEMORY; 764 status = AE_NO_MEMORY;
763 goto error_exit; 765 goto error_exit;
764 } 766 }
@@ -769,9 +771,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
769 gpe_block->event_info = gpe_event_info; 771 gpe_block->event_info = gpe_event_info;
770 772
771 /* 773 /*
772 * Initialize the GPE Register and Event structures. A goal of these 774 * Initialize the GPE Register and Event structures. A goal of these
773 * tables is to hide the fact that there are two separate GPE register sets 775 * tables is to hide the fact that there are two separate GPE register sets
774 * in a given gpe hardware block, the status registers occupy the first half, 776 * in a given GPE hardware block, the status registers occupy the first half,
775 * and the enable registers occupy the second half. 777 * and the enable registers occupy the second half.
776 */ 778 */
777 this_register = gpe_register_info; 779 this_register = gpe_register_info;
@@ -812,11 +814,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
812 this_event++; 814 this_event++;
813 } 815 }
814 816
815 /* 817 /* Disable all GPEs within this register */
816 * Clear the status/enable registers. Note that status registers 818
817 * are cleared by writing a '1', while enable registers are cleared
818 * by writing a '0'.
819 */
820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 819 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
821 &this_register-> 820 &this_register->
822 enable_address); 821 enable_address);
@@ -824,6 +823,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
824 goto error_exit; 823 goto error_exit;
825 } 824 }
826 825
826 /* Clear any pending GPE events within this register */
827
827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 828 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
828 &this_register-> 829 &this_register->
829 status_address); 830 status_address);
@@ -860,7 +861,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
860 * 861 *
861 * RETURN: Status 862 * RETURN: Status
862 * 863 *
863 * DESCRIPTION: Create and Install a block of GPE registers 864 * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
865 * the block are disabled at exit.
866 * Note: Assumes namespace is locked.
864 * 867 *
865 ******************************************************************************/ 868 ******************************************************************************/
866 869
@@ -872,14 +875,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
872 u32 interrupt_number, 875 u32 interrupt_number,
873 struct acpi_gpe_block_info **return_gpe_block) 876 struct acpi_gpe_block_info **return_gpe_block)
874{ 877{
875 struct acpi_gpe_block_info *gpe_block;
876 struct acpi_gpe_event_info *gpe_event_info;
877 acpi_native_uint i;
878 acpi_native_uint j;
879 u32 wake_gpe_count;
880 u32 gpe_enabled_count;
881 acpi_status status; 878 acpi_status status;
882 struct acpi_gpe_walk_info gpe_info; 879 struct acpi_gpe_block_info *gpe_block;
883 880
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block"); 881 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
885 882
@@ -896,22 +893,24 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
896 893
897 /* Initialize the new GPE block */ 894 /* Initialize the new GPE block */
898 895
896 gpe_block->node = gpe_device;
899 gpe_block->register_count = register_count; 897 gpe_block->register_count = register_count;
900 gpe_block->block_base_number = gpe_block_base_number; 898 gpe_block->block_base_number = gpe_block_base_number;
901 gpe_block->node = gpe_device;
902 899
903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, 900 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
904 sizeof(struct acpi_generic_address)); 901 sizeof(struct acpi_generic_address));
905 902
906 /* Create the register_info and event_info sub-structures */ 903 /*
907 904 * Create the register_info and event_info sub-structures
905 * Note: disables and clears all GPEs in the block
906 */
908 status = acpi_ev_create_gpe_info_blocks(gpe_block); 907 status = acpi_ev_create_gpe_info_blocks(gpe_block);
909 if (ACPI_FAILURE(status)) { 908 if (ACPI_FAILURE(status)) {
910 ACPI_MEM_FREE(gpe_block); 909 ACPI_MEM_FREE(gpe_block);
911 return_ACPI_STATUS(status); 910 return_ACPI_STATUS(status);
912 } 911 }
913 912
914 /* Install the new block in the global list(s) */ 913 /* Install the new block in the global lists */
915 914
916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); 915 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
917 if (ACPI_FAILURE(status)) { 916 if (ACPI_FAILURE(status)) {
@@ -926,16 +925,70 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
926 acpi_ev_save_method_info, gpe_block, 925 acpi_ev_save_method_info, gpe_block,
927 NULL); 926 NULL);
928 927
928 /* Return the new block */
929
930 if (return_gpe_block) {
931 (*return_gpe_block) = gpe_block;
932 }
933
934 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
935 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
936 (u32) gpe_block->block_base_number,
937 (u32) (gpe_block->block_base_number +
938 ((gpe_block->register_count *
939 ACPI_GPE_REGISTER_WIDTH) - 1)),
940 gpe_device->name.ascii, gpe_block->register_count,
941 interrupt_number));
942
943 return_ACPI_STATUS(AE_OK);
944}
945
946/*******************************************************************************
947 *
948 * FUNCTION: acpi_ev_initialize_gpe_block
949 *
950 * PARAMETERS: gpe_device - Handle to the parent GPE block
951 * gpe_block - Gpe Block info
952 *
953 * RETURN: Status
954 *
955 * DESCRIPTION: Initialize and enable a GPE block. First find and run any
956 * _PRT methods associated with the block, then enable the
957 * appropriate GPEs.
958 * Note: Assumes namespace is locked.
959 *
960 ******************************************************************************/
961
962acpi_status
963acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
964 struct acpi_gpe_block_info *gpe_block)
965{
966 acpi_status status;
967 struct acpi_gpe_event_info *gpe_event_info;
968 struct acpi_gpe_walk_info gpe_info;
969 u32 wake_gpe_count;
970 u32 gpe_enabled_count;
971 acpi_native_uint i;
972 acpi_native_uint j;
973
974 ACPI_FUNCTION_TRACE("ev_initialize_gpe_block");
975
976 /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */
977
978 if (!gpe_block) {
979 return_ACPI_STATUS(AE_OK);
980 }
981
929 /* 982 /*
930 * Runtime option: Should Wake GPEs be enabled at runtime? The default 983 * Runtime option: Should wake GPEs be enabled at runtime? The default
931 * is No, they should only be enabled just as the machine goes to sleep. 984 * is no, they should only be enabled just as the machine goes to sleep.
932 */ 985 */
933 if (acpi_gbl_leave_wake_gpes_disabled) { 986 if (acpi_gbl_leave_wake_gpes_disabled) {
934 /* 987 /*
935 * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. 988 * Differentiate runtime vs wake GPEs, via the _PRW control methods.
936 * (Each GPE that has one or more _PRWs that reference it is by 989 * Each GPE that has one or more _PRWs that reference it is by
937 * definition a WAKE GPE and will not be enabled while the machine 990 * definition a wake GPE and will not be enabled while the machine
938 * is running.) 991 * is running.
939 */ 992 */
940 gpe_info.gpe_block = gpe_block; 993 gpe_info.gpe_block = gpe_block;
941 gpe_info.gpe_device = gpe_device; 994 gpe_info.gpe_device = gpe_device;
@@ -948,9 +1001,12 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
948 } 1001 }
949 1002
950 /* 1003 /*
951 * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, 1004 * Enable all GPEs in this block that have these attributes:
952 * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must 1005 * 1) are "runtime" or "run/wake" GPEs, and
953 * be enabled via the acpi_enable_gpe() external interface. 1006 * 2) have a corresponding _Lxx or _Exx method
1007 *
1008 * Any other GPEs within this block must be enabled via the acpi_enable_gpe()
1009 * external interface.
954 */ 1010 */
955 wake_gpe_count = 0; 1011 wake_gpe_count = 0;
956 gpe_enabled_count = 0; 1012 gpe_enabled_count = 0;
@@ -976,32 +1032,19 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
976 } 1032 }
977 } 1033 }
978 1034
979 /* Dump info about this GPE block */
980
981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
982 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
983 (u32) gpe_block->block_base_number,
984 (u32) (gpe_block->block_base_number +
985 ((gpe_block->register_count *
986 ACPI_GPE_REGISTER_WIDTH) - 1)),
987 gpe_device->name.ascii, gpe_block->register_count,
988 interrupt_number));
989
990 /* Enable all valid GPEs found above */
991
992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
993
994 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 1035 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 1036 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
996 wake_gpe_count, gpe_enabled_count)); 1037 wake_gpe_count, gpe_enabled_count));
997 1038
998 /* Return the new block */ 1039 /* Enable all valid runtime GPEs found above */
999 1040
1000 if (return_gpe_block) { 1041 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1001 (*return_gpe_block) = gpe_block; 1042 if (ACPI_FAILURE(status)) {
1043 ACPI_ERROR((AE_INFO, "Could not enable GPEs in gpe_block %p",
1044 gpe_block));
1002 } 1045 }
1003 1046
1004 return_ACPI_STATUS(AE_OK); 1047 return_ACPI_STATUS(status);
1005} 1048}
1006 1049
1007/******************************************************************************* 1050/*******************************************************************************
@@ -1072,8 +1115,8 @@ acpi_status acpi_ev_gpe_initialize(void)
1072 &acpi_gbl_gpe_fadt_blocks[0]); 1115 &acpi_gbl_gpe_fadt_blocks[0]);
1073 1116
1074 if (ACPI_FAILURE(status)) { 1117 if (ACPI_FAILURE(status)) {
1075 ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n", 1118 ACPI_EXCEPTION((AE_INFO, status,
1076 acpi_format_exception(status))); 1119 "Could not create GPE Block 0"));
1077 } 1120 }
1078 } 1121 }
1079 1122
@@ -1086,7 +1129,12 @@ acpi_status acpi_ev_gpe_initialize(void)
1086 1129
1087 if ((register_count0) && 1130 if ((register_count0) &&
1088 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { 1131 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) {
1089 ACPI_REPORT_ERROR(("GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", gpe_number_max, acpi_gbl_FADT->gpe1_base, acpi_gbl_FADT->gpe1_base + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1))); 1132 ACPI_ERROR((AE_INFO,
1133 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1",
1134 gpe_number_max, acpi_gbl_FADT->gpe1_base,
1135 acpi_gbl_FADT->gpe1_base +
1136 ((register_count1 *
1137 ACPI_GPE_REGISTER_WIDTH) - 1)));
1090 1138
1091 /* Ignore GPE1 block by setting the register count to zero */ 1139 /* Ignore GPE1 block by setting the register count to zero */
1092 1140
@@ -1104,7 +1152,8 @@ acpi_status acpi_ev_gpe_initialize(void)
1104 [1]); 1152 [1]);
1105 1153
1106 if (ACPI_FAILURE(status)) { 1154 if (ACPI_FAILURE(status)) {
1107 ACPI_REPORT_ERROR(("Could not create GPE Block 1, %s\n", acpi_format_exception(status))); 1155 ACPI_EXCEPTION((AE_INFO, status,
1156 "Could not create GPE Block 1"));
1108 } 1157 }
1109 1158
1110 /* 1159 /*
@@ -1130,7 +1179,9 @@ acpi_status acpi_ev_gpe_initialize(void)
1130 /* Check for Max GPE number out-of-range */ 1179 /* Check for Max GPE number out-of-range */
1131 1180
1132 if (gpe_number_max > ACPI_GPE_MAX) { 1181 if (gpe_number_max > ACPI_GPE_MAX) {
1133 ACPI_REPORT_ERROR(("Maximum GPE number from FADT is too large: 0x%X\n", gpe_number_max)); 1182 ACPI_ERROR((AE_INFO,
1183 "Maximum GPE number from FADT is too large: 0x%X",
1184 gpe_number_max));
1134 status = AE_BAD_VALUE; 1185 status = AE_BAD_VALUE;
1135 goto cleanup; 1186 goto cleanup;
1136 } 1187 }
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 7e57b8470f55..0909ba69577e 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -303,7 +303,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context)
303 acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 303 acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore,
304 acpi_gbl_global_lock_thread_count); 304 acpi_gbl_global_lock_thread_count);
305 if (ACPI_FAILURE(status)) { 305 if (ACPI_FAILURE(status)) {
306 ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n")); 306 ACPI_ERROR((AE_INFO,
307 "Could not signal Global Lock semaphore"));
307 } 308 }
308 } 309 }
309} 310}
@@ -344,7 +345,8 @@ static u32 acpi_ev_global_lock_handler(void *context)
344 acpi_ev_global_lock_thread, 345 acpi_ev_global_lock_thread,
345 context); 346 context);
346 if (ACPI_FAILURE(status)) { 347 if (ACPI_FAILURE(status)) {
347 ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status))); 348 ACPI_EXCEPTION((AE_INFO, status,
349 "Could not queue Global Lock thread"));
348 350
349 return (ACPI_INTERRUPT_NOT_HANDLED); 351 return (ACPI_INTERRUPT_NOT_HANDLED);
350 } 352 }
@@ -384,7 +386,8 @@ acpi_status acpi_ev_init_global_lock_handler(void)
384 * with an error. 386 * with an error.
385 */ 387 */
386 if (status == AE_NO_HARDWARE_RESPONSE) { 388 if (status == AE_NO_HARDWARE_RESPONSE) {
387 ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n")); 389 ACPI_ERROR((AE_INFO,
390 "No response from Global Lock hardware, disabling lock"));
388 391
389 acpi_gbl_global_lock_present = FALSE; 392 acpi_gbl_global_lock_present = FALSE;
390 status = AE_OK; 393 status = AE_OK;
@@ -480,7 +483,8 @@ acpi_status acpi_ev_release_global_lock(void)
480 ACPI_FUNCTION_TRACE("ev_release_global_lock"); 483 ACPI_FUNCTION_TRACE("ev_release_global_lock");
481 484
482 if (!acpi_gbl_global_lock_thread_count) { 485 if (!acpi_gbl_global_lock_thread_count) {
483 ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); 486 ACPI_WARNING((AE_INFO,
487 "Cannot release HW Global Lock, it has not been acquired"));
484 return_ACPI_STATUS(AE_NOT_ACQUIRED); 488 return_ACPI_STATUS(AE_NOT_ACQUIRED);
485 } 489 }
486 490
@@ -542,9 +546,9 @@ void acpi_ev_terminate(void)
542 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 546 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
543 status = acpi_disable_event((u32) i, 0); 547 status = acpi_disable_event((u32) i, 0);
544 if (ACPI_FAILURE(status)) { 548 if (ACPI_FAILURE(status)) {
545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 549 ACPI_ERROR((AE_INFO,
546 "Could not disable fixed event %d\n", 550 "Could not disable fixed event %d",
547 (u32) i)); 551 (u32) i));
548 } 552 }
549 } 553 }
550 554
@@ -556,8 +560,7 @@ void acpi_ev_terminate(void)
556 560
557 status = acpi_ev_remove_sci_handler(); 561 status = acpi_ev_remove_sci_handler();
558 if (ACPI_FAILURE(status)) { 562 if (ACPI_FAILURE(status)) {
559 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 563 ACPI_ERROR((AE_INFO, "Could not remove SCI handler"));
560 "Could not remove SCI handler\n"));
561 } 564 }
562 } 565 }
563 566
@@ -570,8 +573,7 @@ void acpi_ev_terminate(void)
570 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { 573 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
571 status = acpi_disable(); 574 status = acpi_disable();
572 if (ACPI_FAILURE(status)) { 575 if (ACPI_FAILURE(status)) {
573 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 576 ACPI_WARNING((AE_INFO, "acpi_disable failed"));
574 "acpi_disable failed\n"));
575 } 577 }
576 } 578 }
577 return_VOID; 579 return_VOID;
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index 84fad082d80d..6da58e776413 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -295,12 +295,12 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
295 295
296 handler_desc = region_obj->region.handler; 296 handler_desc = region_obj->region.handler;
297 if (!handler_desc) { 297 if (!handler_desc) {
298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 298 ACPI_ERROR((AE_INFO,
299 "No handler for Region [%4.4s] (%p) [%s]\n", 299 "No handler for Region [%4.4s] (%p) [%s]",
300 acpi_ut_get_node_name(region_obj->region. 300 acpi_ut_get_node_name(region_obj->region.node),
301 node), region_obj, 301 region_obj,
302 acpi_ut_get_region_name(region_obj->region. 302 acpi_ut_get_region_name(region_obj->region.
303 space_id))); 303 space_id)));
304 304
305 return_ACPI_STATUS(AE_NOT_EXIST); 305 return_ACPI_STATUS(AE_NOT_EXIST);
306 } 306 }
@@ -317,12 +317,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
317 if (!region_setup) { 317 if (!region_setup) {
318 /* No initialization routine, exit with error */ 318 /* No initialization routine, exit with error */
319 319
320 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 320 ACPI_ERROR((AE_INFO,
321 "No init routine for region(%p) [%s]\n", 321 "No init routine for region(%p) [%s]",
322 region_obj, 322 region_obj,
323 acpi_ut_get_region_name(region_obj-> 323 acpi_ut_get_region_name(region_obj->region.
324 region. 324 space_id)));
325 space_id)));
326 return_ACPI_STATUS(AE_NOT_EXIST); 325 return_ACPI_STATUS(AE_NOT_EXIST);
327 } 326 }
328 327
@@ -347,12 +346,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
347 /* Check for failure of the Region Setup */ 346 /* Check for failure of the Region Setup */
348 347
349 if (ACPI_FAILURE(status)) { 348 if (ACPI_FAILURE(status)) {
350 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 349 ACPI_EXCEPTION((AE_INFO, status,
351 "Region Init: %s [%s]\n", 350 "During region initialization: [%s]",
352 acpi_format_exception(status), 351 acpi_ut_get_region_name(region_obj->
353 acpi_ut_get_region_name(region_obj-> 352 region.
354 region. 353 space_id)));
355 space_id)));
356 return_ACPI_STATUS(status); 354 return_ACPI_STATUS(status);
357 } 355 }
358 356
@@ -406,10 +404,9 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
406 region_obj2->extra.region_context); 404 region_obj2->extra.region_context);
407 405
408 if (ACPI_FAILURE(status)) { 406 if (ACPI_FAILURE(status)) {
409 ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n", 407 ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]",
410 acpi_ut_get_region_name(region_obj->region. 408 acpi_ut_get_region_name(region_obj->region.
411 space_id), 409 space_id)));
412 acpi_format_exception(status)));
413 } 410 }
414 411
415 if (! 412 if (!
@@ -501,12 +498,10 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
501 498
502 status = acpi_ev_execute_reg_method(region_obj, 0); 499 status = acpi_ev_execute_reg_method(region_obj, 0);
503 if (ACPI_FAILURE(status)) { 500 if (ACPI_FAILURE(status)) {
504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 501 ACPI_EXCEPTION((AE_INFO, status,
505 "%s from region _REG, [%s]\n", 502 "from region _REG, [%s]",
506 acpi_format_exception(status), 503 acpi_ut_get_region_name
507 acpi_ut_get_region_name 504 (region_obj->region.space_id)));
508 (region_obj->region.
509 space_id)));
510 } 505 }
511 506
512 if (acpi_ns_is_locked) { 507 if (acpi_ns_is_locked) {
@@ -528,12 +523,10 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
528 /* Init routine may fail, Just ignore errors */ 523 /* Init routine may fail, Just ignore errors */
529 524
530 if (ACPI_FAILURE(status)) { 525 if (ACPI_FAILURE(status)) {
531 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 526 ACPI_EXCEPTION((AE_INFO, status,
532 "%s from region init, [%s]\n", 527 "from region init, [%s]",
533 acpi_format_exception(status), 528 acpi_ut_get_region_name
534 acpi_ut_get_region_name 529 (region_obj->region.space_id)));
535 (region_obj->region.
536 space_id)));
537 } 530 }
538 531
539 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); 532 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index a1bd2da27c45..baed8c1a1b9f 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -233,7 +233,11 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
233 */ 233 */
234 status = AE_OK; 234 status = AE_OK;
235 } else { 235 } else {
236 ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status))); 236 ACPI_EXCEPTION((AE_INFO,
237 status,
238 "Could not install pci_config handler for Root Bridge %4.4s",
239 acpi_ut_get_node_name
240 (pci_root_node)));
237 } 241 }
238 } 242 }
239 break; 243 break;
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index 141835977002..9a622169008a 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -88,7 +88,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
88 */ 88 */
89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
90 90
91 return_VALUE(interrupt_handled); 91 return_UINT32(interrupt_handled);
92} 92}
93 93
94/******************************************************************************* 94/*******************************************************************************
@@ -121,7 +121,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
121 */ 121 */
122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
123 123
124 return_VALUE(interrupt_handled); 124 return_UINT32(interrupt_handled);
125} 125}
126 126
127/****************************************************************************** 127/******************************************************************************
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 43b33d19cdf9..b38b39dde543 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -143,8 +143,8 @@ acpi_install_fixed_event_handler(u32 event,
143 if (ACPI_SUCCESS(status)) 143 if (ACPI_SUCCESS(status))
144 status = acpi_enable_event(event, 0); 144 status = acpi_enable_event(event, 0);
145 if (ACPI_FAILURE(status)) { 145 if (ACPI_FAILURE(status)) {
146 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 146 ACPI_WARNING((AE_INFO, "Could not enable fixed event %X",
147 "Could not enable fixed event.\n")); 147 event));
148 148
149 /* Remove the handler */ 149 /* Remove the handler */
150 150
@@ -204,10 +204,11 @@ acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
204 acpi_gbl_fixed_event_handlers[event].context = NULL; 204 acpi_gbl_fixed_event_handlers[event].context = NULL;
205 205
206 if (ACPI_FAILURE(status)) { 206 if (ACPI_FAILURE(status)) {
207 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 207 ACPI_WARNING((AE_INFO,
208 "Could not write to fixed event enable register.\n")); 208 "Could not write to fixed event enable register %X",
209 event));
209 } else { 210 } else {
210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n", 211 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n",
211 event)); 212 event));
212 } 213 }
213 214
@@ -434,7 +435,7 @@ acpi_remove_notify_handler(acpi_handle device,
434 435
435 if (device == ACPI_ROOT_OBJECT) { 436 if (device == ACPI_ROOT_OBJECT) {
436 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 437 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
437 "Removing notify handler for ROOT object.\n")); 438 "Removing notify handler for namespace root object\n"));
438 439
439 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 440 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
440 !acpi_gbl_system_notify.handler) || 441 !acpi_gbl_system_notify.handler) ||
@@ -562,7 +563,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
562 struct acpi_gpe_event_info *gpe_event_info; 563 struct acpi_gpe_event_info *gpe_event_info;
563 struct acpi_handler_info *handler; 564 struct acpi_handler_info *handler;
564 acpi_status status; 565 acpi_status status;
565 u32 flags; 566 acpi_cpu_flags flags;
566 567
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler"); 568 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
568 569
@@ -653,7 +654,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
653 struct acpi_gpe_event_info *gpe_event_info; 654 struct acpi_gpe_event_info *gpe_event_info;
654 struct acpi_handler_info *handler; 655 struct acpi_handler_info *handler;
655 acpi_status status; 656 acpi_status status;
656 u32 flags; 657 acpi_cpu_flags flags;
657 658
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler"); 659 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
659 660
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index 887ff9f28a0d..ec9ce8429f15 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -70,8 +70,7 @@ acpi_status acpi_enable(void)
70 /* Make sure we have the FADT */ 70 /* Make sure we have the FADT */
71 71
72 if (!acpi_gbl_FADT) { 72 if (!acpi_gbl_FADT) {
73 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 73 ACPI_WARNING((AE_INFO, "No FADT information present!"));
74 "No FADT information present!\n"));
75 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 74 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
76 } 75 }
77 76
@@ -83,7 +82,8 @@ acpi_status acpi_enable(void)
83 82
84 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); 83 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
85 if (ACPI_FAILURE(status)) { 84 if (ACPI_FAILURE(status)) {
86 ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n")); 85 ACPI_ERROR((AE_INFO,
86 "Could not transition to ACPI mode"));
87 return_ACPI_STATUS(status); 87 return_ACPI_STATUS(status);
88 } 88 }
89 89
@@ -113,8 +113,7 @@ acpi_status acpi_disable(void)
113 ACPI_FUNCTION_TRACE("acpi_disable"); 113 ACPI_FUNCTION_TRACE("acpi_disable");
114 114
115 if (!acpi_gbl_FADT) { 115 if (!acpi_gbl_FADT) {
116 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 116 ACPI_WARNING((AE_INFO, "No FADT information present!"));
117 "No FADT information present!\n"));
118 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 117 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
119 } 118 }
120 119
@@ -127,8 +126,8 @@ acpi_status acpi_disable(void)
127 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); 126 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
128 127
129 if (ACPI_FAILURE(status)) { 128 if (ACPI_FAILURE(status)) {
130 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 129 ACPI_ERROR((AE_INFO,
131 "Could not exit ACPI mode to legacy mode")); 130 "Could not exit ACPI mode to legacy mode"));
132 return_ACPI_STATUS(status); 131 return_ACPI_STATUS(status);
133 } 132 }
134 133
@@ -185,9 +184,9 @@ acpi_status acpi_enable_event(u32 event, u32 flags)
185 } 184 }
186 185
187 if (value != 1) { 186 if (value != 1) {
188 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 187 ACPI_ERROR((AE_INFO,
189 "Could not enable %s event\n", 188 "Could not enable %s event",
190 acpi_ut_get_event_name(event))); 189 acpi_ut_get_event_name(event)));
191 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 190 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
192 } 191 }
193 192
@@ -384,9 +383,9 @@ acpi_status acpi_disable_event(u32 event, u32 flags)
384 } 383 }
385 384
386 if (value != 0) { 385 if (value != 0) {
387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 386 ACPI_ERROR((AE_INFO,
388 "Could not disable %s events\n", 387 "Could not disable %s events",
389 acpi_ut_get_event_name(event))); 388 acpi_ut_get_event_name(event)));
390 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 389 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
391 } 390 }
392 391
@@ -626,6 +625,13 @@ acpi_install_gpe_block(acpi_handle gpe_device,
626 goto unlock_and_exit; 625 goto unlock_and_exit;
627 } 626 }
628 627
628 /* Run the _PRW methods and enable the GPEs */
629
630 status = acpi_ev_initialize_gpe_block(node, gpe_block);
631 if (ACPI_FAILURE(status)) {
632 goto unlock_and_exit;
633 }
634
629 /* Get the device_object attached to the node */ 635 /* Get the device_object attached to the node */
630 636
631 obj_desc = acpi_ns_get_attached_object(node); 637 obj_desc = acpi_ns_get_attached_object(node);
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
index 6f28ea2db5ba..abf5caca9ae5 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/events/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 1ce365d651d8..a29782fe3ecf 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -413,9 +413,9 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
413 (!ACPI_STRNCMP(table_ptr->signature, 413 (!ACPI_STRNCMP(table_ptr->signature,
414 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, 414 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
415 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { 415 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 416 ACPI_ERROR((AE_INFO,
417 "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", 417 "Table has invalid signature [%4.4s], must be SSDT or PSDT",
418 table_ptr->signature)); 418 table_ptr->signature));
419 status = AE_BAD_SIGNATURE; 419 status = AE_BAD_SIGNATURE;
420 goto cleanup; 420 goto cleanup;
421 } 421 }
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 04e5194989a6..e6d52e12d77a 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -504,18 +504,12 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
504 } 504 }
505 505
506 /* 506 /*
507 * Perform the conversion. 507 * Create a new string object and string buffer
508 * (-1 because of extra separator included in string_length from above) 508 * (-1 because of extra separator included in string_length from above)
509 */ 509 */
510 string_length--;
511 if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */
512 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
513 }
514
515 /* Create a new string object and string buffer */
516
517 return_desc = 510 return_desc =
518 acpi_ut_create_string_object((acpi_size) string_length); 511 acpi_ut_create_string_object((acpi_size)
512 (string_length - 1));
519 if (!return_desc) { 513 if (!return_desc) {
520 return_ACPI_STATUS(AE_NO_MEMORY); 514 return_ACPI_STATUS(AE_NO_MEMORY);
521 } 515 }
@@ -647,7 +641,9 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
647 break; 641 break;
648 642
649 default: 643 default:
650 ACPI_REPORT_ERROR(("Bad destination type during conversion: %X\n", destination_type)); 644 ACPI_ERROR((AE_INFO,
645 "Bad destination type during conversion: %X",
646 destination_type));
651 status = AE_AML_INTERNAL; 647 status = AE_AML_INTERNAL;
652 break; 648 break;
653 } 649 }
@@ -660,17 +656,13 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
660 break; 656 break;
661 657
662 default: 658 default:
663 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 659 ACPI_ERROR((AE_INFO,
664 "Unknown Target type ID 0x%X Op %s dest_type %s\n", 660 "Unknown Target type ID 0x%X aml_opcode %X dest_type %s",
665 GET_CURRENT_ARG_TYPE(walk_state->op_info-> 661 GET_CURRENT_ARG_TYPE(walk_state->op_info->
666 runtime_args), 662 runtime_args),
667 walk_state->op_info->name, 663 walk_state->opcode,
668 acpi_ut_get_type_name(destination_type))); 664 acpi_ut_get_type_name(destination_type)));
669 665 status = AE_AML_INTERNAL;
670 ACPI_REPORT_ERROR(("Bad Target Type (ARGI): %X\n",
671 GET_CURRENT_ARG_TYPE(walk_state->op_info->
672 runtime_args)))
673 status = AE_AML_INTERNAL;
674 } 666 }
675 667
676 /* 668 /*
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index 91c49188fb07..680575402835 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -300,8 +300,8 @@ acpi_ex_create_region(u8 * aml_start,
300 */ 300 */
301 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && 301 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
302 (region_space < ACPI_USER_REGION_BEGIN)) { 302 (region_space < ACPI_USER_REGION_BEGIN)) {
303 ACPI_REPORT_ERROR(("Invalid address_space type %X\n", 303 ACPI_ERROR((AE_INFO, "Invalid address_space type %X",
304 region_space)); 304 region_space));
305 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID); 305 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
306 } 306 }
307 307
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index bc2fa996047e..a7cca8d4f855 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,20 +55,386 @@ ACPI_MODULE_NAME("exdump")
55 */ 55 */
56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
57/* Local prototypes */ 57/* Local prototypes */
58#ifdef ACPI_FUTURE_USAGE
59static void acpi_ex_out_string(char *title, char *value); 58static void acpi_ex_out_string(char *title, char *value);
60 59
61static void acpi_ex_out_pointer(char *title, void *value); 60static void acpi_ex_out_pointer(char *title, void *value);
62 61
63static void acpi_ex_out_integer(char *title, u32 value);
64
65static void acpi_ex_out_address(char *title, acpi_physical_address value); 62static void acpi_ex_out_address(char *title, acpi_physical_address value);
66 63
67static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc); 64static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
68 65
69static void 66static void
70acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index); 67acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
71#endif /* ACPI_FUTURE_USAGE */ 68 u32 level, u32 index);
69
70/*******************************************************************************
71 *
72 * Object Descriptor info tables
73 *
74 * Note: The first table entry must be an INIT opcode and must contain
75 * the table length (number of table entries)
76 *
77 ******************************************************************************/
78
79static struct acpi_exdump_info acpi_ex_dump_integer[2] = {
80 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL},
81 {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"}
82};
83
84static struct acpi_exdump_info acpi_ex_dump_string[4] = {
85 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL},
86 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"},
87 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"},
88 {ACPI_EXD_STRING, 0, NULL}
89};
90
91static struct acpi_exdump_info acpi_ex_dump_buffer[4] = {
92 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
93 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
94 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
95 {ACPI_EXD_BUFFER, 0, NULL}
96};
97
98static struct acpi_exdump_info acpi_ex_dump_package[5] = {
99 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
100 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
101 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"},
102 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
103 {ACPI_EXD_PACKAGE, 0, NULL}
104};
105
106static struct acpi_exdump_info acpi_ex_dump_device[4] = {
107 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
108 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"},
109 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify),
110 "System Notify"},
111 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify),
112 "Device Notify"}
113};
114
115static struct acpi_exdump_info acpi_ex_dump_event[2] = {
116 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
117 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"}
118};
119
120static struct acpi_exdump_info acpi_ex_dump_method[8] = {
121 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
122 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"},
123 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"},
124 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"},
125 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
127 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
129};
130
131static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
132 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
133 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
134 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
135 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
136 "Acquire Depth"},
137 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"}
138};
139
140static struct acpi_exdump_info acpi_ex_dump_region[7] = {
141 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
142 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
143 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
144 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
145 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
146 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"},
147 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
148};
149
150static struct acpi_exdump_info acpi_ex_dump_power[5] = {
151 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
152 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
153 "System Level"},
154 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
155 "Resource Order"},
156 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify),
157 "System Notify"},
158 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify),
159 "Device Notify"}
160};
161
162static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
163 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL},
164 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
165 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.length), "Length"},
166 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
167 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify),
168 "System Notify"},
169 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify),
170 "Device Notify"},
171 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
172};
173
174static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
175 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
176 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify),
177 "System Notify"},
178 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify),
179 "Device Notify"},
180 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
181};
182
183static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
184 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL},
185 {ACPI_EXD_FIELD, 0, NULL},
186 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj),
187 "Buffer Object"}
188};
189
190static struct acpi_exdump_info acpi_ex_dump_region_field[3] = {
191 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
192 {ACPI_EXD_FIELD, 0, NULL},
193 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"}
194};
195
196static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
197 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
198 {ACPI_EXD_FIELD, 0, NULL},
199 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"},
200 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj),
201 "Region Object"},
202 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"}
203};
204
205static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
206 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
207 {ACPI_EXD_FIELD, 0, NULL},
208 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"},
209 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj),
210 "Index Object"},
211 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
212};
213
214static struct acpi_exdump_info acpi_ex_dump_reference[7] = {
215 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
216 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
217 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"},
218 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
219 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"},
220 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
221 {ACPI_EXD_REFERENCE, 0, NULL}
222};
223
224static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
225 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler),
226 NULL},
227 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"},
228 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.next), "Next"},
229 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.region_list),
230 "Region List"},
231 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.node), "Node"},
232 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
233};
234
235static struct acpi_exdump_info acpi_ex_dump_notify[3] = {
236 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
237 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"},
238 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"}
239};
240
241/* Miscellaneous tables */
242
243static struct acpi_exdump_info acpi_ex_dump_common[4] = {
244 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL},
245 {ACPI_EXD_TYPE, 0, NULL},
246 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count),
247 "Reference Count"},
248 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"}
249};
250
251static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
252 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL},
253 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags),
254 "Field Flags"},
255 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width),
256 "Access Byte Width"},
257 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length),
258 "Bit Length"},
259 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset),
260 "Field Bit Offset"},
261 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset),
262 "Base Byte Offset"},
263 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(common_field.node), "Parent Node"}
264};
265
266static struct acpi_exdump_info acpi_ex_dump_node[6] = {
267 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
268 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
269 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
270 {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count),
271 "Reference Count"},
272 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"},
273 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"}
274};
275
276/* Dispatch table, indexed by object type */
277
278static struct acpi_exdump_info *acpi_ex_dump_info[] = {
279 NULL,
280 acpi_ex_dump_integer,
281 acpi_ex_dump_string,
282 acpi_ex_dump_buffer,
283 acpi_ex_dump_package,
284 NULL,
285 acpi_ex_dump_device,
286 acpi_ex_dump_event,
287 acpi_ex_dump_method,
288 acpi_ex_dump_mutex,
289 acpi_ex_dump_region,
290 acpi_ex_dump_power,
291 acpi_ex_dump_processor,
292 acpi_ex_dump_thermal,
293 acpi_ex_dump_buffer_field,
294 NULL,
295 NULL,
296 acpi_ex_dump_region_field,
297 acpi_ex_dump_bank_field,
298 acpi_ex_dump_index_field,
299 acpi_ex_dump_reference,
300 NULL,
301 NULL,
302 acpi_ex_dump_notify,
303 acpi_ex_dump_address_handler,
304 NULL,
305 NULL,
306 NULL
307};
308
309/*******************************************************************************
310 *
311 * FUNCTION: acpi_ex_dump_object
312 *
313 * PARAMETERS: obj_desc - Descriptor to dump
314 * Info - Info table corresponding to this object
315 * type
316 *
317 * RETURN: None
318 *
319 * DESCRIPTION: Walk the info table for this object
320 *
321 ******************************************************************************/
322
323static void
324acpi_ex_dump_object(union acpi_operand_object *obj_desc,
325 struct acpi_exdump_info *info)
326{
327 u8 *target;
328 char *name;
329 u8 count;
330
331 if (!info) {
332 acpi_os_printf
333 ("ex_dump_object: Display not implemented for object type %s\n",
334 acpi_ut_get_object_type_name(obj_desc));
335 return;
336 }
337
338 /* First table entry must contain the table length (# of table entries) */
339
340 count = info->offset;
341
342 while (count) {
343 target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
344 name = info->name;
345
346 switch (info->opcode) {
347 case ACPI_EXD_INIT:
348 break;
349
350 case ACPI_EXD_TYPE:
351 acpi_ex_out_string("Type",
352 acpi_ut_get_object_type_name
353 (obj_desc));
354 break;
355
356 case ACPI_EXD_UINT8:
357
358 acpi_os_printf("%20s : %2.2X\n", name, *target);
359 break;
360
361 case ACPI_EXD_UINT16:
362
363 acpi_os_printf("%20s : %4.4X\n", name,
364 ACPI_GET16(target));
365 break;
366
367 case ACPI_EXD_UINT32:
368
369 acpi_os_printf("%20s : %8.8X\n", name,
370 ACPI_GET32(target));
371 break;
372
373 case ACPI_EXD_UINT64:
374
375 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
376 ACPI_FORMAT_UINT64(ACPI_GET64(target)));
377 break;
378
379 case ACPI_EXD_POINTER:
380
381 acpi_ex_out_pointer(name,
382 *ACPI_CAST_PTR(void *, target));
383 break;
384
385 case ACPI_EXD_ADDRESS:
386
387 acpi_ex_out_address(name,
388 *ACPI_CAST_PTR
389 (acpi_physical_address, target));
390 break;
391
392 case ACPI_EXD_STRING:
393
394 acpi_ut_print_string(obj_desc->string.pointer,
395 ACPI_UINT8_MAX);
396 acpi_os_printf("\n");
397 break;
398
399 case ACPI_EXD_BUFFER:
400
401 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
402 obj_desc->buffer.length);
403 break;
404
405 case ACPI_EXD_PACKAGE:
406
407 /* Dump the package contents */
408
409 acpi_os_printf("\nPackage Contents:\n");
410 acpi_ex_dump_package_obj(obj_desc, 0, 0);
411 break;
412
413 case ACPI_EXD_FIELD:
414
415 acpi_ex_dump_object(obj_desc,
416 acpi_ex_dump_field_common);
417 break;
418
419 case ACPI_EXD_REFERENCE:
420
421 acpi_ex_out_string("Opcode",
422 (acpi_ps_get_opcode_info
423 (obj_desc->reference.opcode))->
424 name);
425 acpi_ex_dump_reference_obj(obj_desc);
426 break;
427
428 default:
429 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
430 info->opcode);
431 return;
432 }
433
434 info++;
435 count--;
436 }
437}
72 438
73/******************************************************************************* 439/*******************************************************************************
74 * 440 *
@@ -214,7 +580,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
214 580
215 case ACPI_TYPE_BUFFER: 581 case ACPI_TYPE_BUFFER:
216 582
217 acpi_os_printf("Buffer len %X @ %p \n", 583 acpi_os_printf("Buffer len %X @ %p\n",
218 obj_desc->buffer.length, 584 obj_desc->buffer.length,
219 obj_desc->buffer.pointer); 585 obj_desc->buffer.pointer);
220 586
@@ -320,17 +686,17 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
320 686
321 case ACPI_TYPE_BUFFER_FIELD: 687 case ACPI_TYPE_BUFFER_FIELD:
322 688
323 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n", 689 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n",
324 obj_desc->buffer_field.bit_length, 690 obj_desc->buffer_field.bit_length,
325 obj_desc->buffer_field.base_byte_offset, 691 obj_desc->buffer_field.base_byte_offset,
326 obj_desc->buffer_field.start_field_bit_offset); 692 obj_desc->buffer_field.start_field_bit_offset);
327 693
328 if (!obj_desc->buffer_field.buffer_obj) { 694 if (!obj_desc->buffer_field.buffer_obj) {
329 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n")); 695 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
330 } else 696 } else
331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) 697 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
332 != ACPI_TYPE_BUFFER) { 698 != ACPI_TYPE_BUFFER) {
333 acpi_os_printf("*not a Buffer* \n"); 699 acpi_os_printf("*not a Buffer*\n");
334 } else { 700 } else {
335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, 701 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
336 depth + 1); 702 depth + 1);
@@ -441,7 +807,6 @@ acpi_ex_dump_operands(union acpi_operand_object **operands,
441 return; 807 return;
442} 808}
443 809
444#ifdef ACPI_FUTURE_USAGE
445/******************************************************************************* 810/*******************************************************************************
446 * 811 *
447 * FUNCTION: acpi_ex_out* functions 812 * FUNCTION: acpi_ex_out* functions
@@ -465,11 +830,6 @@ static void acpi_ex_out_pointer(char *title, void *value)
465 acpi_os_printf("%20s : %p\n", title, value); 830 acpi_os_printf("%20s : %p\n", title, value);
466} 831}
467 832
468static void acpi_ex_out_integer(char *title, u32 value)
469{
470 acpi_os_printf("%20s : %.2X\n", title, value);
471}
472
473static void acpi_ex_out_address(char *title, acpi_physical_address value) 833static void acpi_ex_out_address(char *title, acpi_physical_address value)
474{ 834{
475 835
@@ -482,16 +842,16 @@ static void acpi_ex_out_address(char *title, acpi_physical_address value)
482 842
483/******************************************************************************* 843/*******************************************************************************
484 * 844 *
485 * FUNCTION: acpi_ex_dump_node 845 * FUNCTION: acpi_ex_dump_namespace_node
486 * 846 *
487 * PARAMETERS: *Node - Descriptor to dump 847 * PARAMETERS: Node - Descriptor to dump
488 * Flags - Force display if TRUE 848 * Flags - Force display if TRUE
489 * 849 *
490 * DESCRIPTION: Dumps the members of the given.Node 850 * DESCRIPTION: Dumps the members of the given.Node
491 * 851 *
492 ******************************************************************************/ 852 ******************************************************************************/
493 853
494void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) 854void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
495{ 855{
496 856
497 ACPI_FUNCTION_ENTRY(); 857 ACPI_FUNCTION_ENTRY();
@@ -506,19 +866,17 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
506 866
507 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); 867 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
508 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); 868 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
509 acpi_ex_out_integer("Flags", node->flags);
510 acpi_ex_out_integer("Owner Id", node->owner_id);
511 acpi_ex_out_integer("Reference Count", node->reference_count);
512 acpi_ex_out_pointer("Attached Object", 869 acpi_ex_out_pointer("Attached Object",
513 acpi_ns_get_attached_object(node)); 870 acpi_ns_get_attached_object(node));
514 acpi_ex_out_pointer("child_list", node->child);
515 acpi_ex_out_pointer("next_peer", node->peer);
516 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); 871 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
872
873 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
874 acpi_ex_dump_node);
517} 875}
518 876
519/******************************************************************************* 877/*******************************************************************************
520 * 878 *
521 * FUNCTION: acpi_ex_dump_reference 879 * FUNCTION: acpi_ex_dump_reference_obj
522 * 880 *
523 * PARAMETERS: Object - Descriptor to dump 881 * PARAMETERS: Object - Descriptor to dump
524 * 882 *
@@ -526,14 +884,16 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
526 * 884 *
527 ******************************************************************************/ 885 ******************************************************************************/
528 886
529static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) 887static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
530{ 888{
531 struct acpi_buffer ret_buf; 889 struct acpi_buffer ret_buf;
532 acpi_status status; 890 acpi_status status;
533 891
892 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
893
534 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { 894 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
535 acpi_os_printf("Named Object %p ", obj_desc->reference.node); 895 acpi_os_printf("Named Object %p ", obj_desc->reference.node);
536 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 896
537 status = 897 status =
538 acpi_ns_handle_to_pathname(obj_desc->reference.node, 898 acpi_ns_handle_to_pathname(obj_desc->reference.node,
539 &ret_buf); 899 &ret_buf);
@@ -551,9 +911,9 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
551 911
552/******************************************************************************* 912/*******************************************************************************
553 * 913 *
554 * FUNCTION: acpi_ex_dump_package 914 * FUNCTION: acpi_ex_dump_package_obj
555 * 915 *
556 * PARAMETERS: Object - Descriptor to dump 916 * PARAMETERS: obj_desc - Descriptor to dump
557 * Level - Indentation Level 917 * Level - Indentation Level
558 * Index - Package index for this object 918 * Index - Package index for this object
559 * 919 *
@@ -562,7 +922,8 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
562 ******************************************************************************/ 922 ******************************************************************************/
563 923
564static void 924static void
565acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) 925acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
926 u32 level, u32 index)
566{ 927{
567 u32 i; 928 u32 i;
568 929
@@ -608,7 +969,8 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
608 acpi_os_printf("[Buffer] Length %.2X = ", 969 acpi_os_printf("[Buffer] Length %.2X = ",
609 obj_desc->buffer.length); 970 obj_desc->buffer.length);
610 if (obj_desc->buffer.length) { 971 if (obj_desc->buffer.length) {
611 acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer, 972 acpi_ut_dump_buffer(ACPI_CAST_PTR
973 (u8, obj_desc->buffer.pointer),
612 obj_desc->buffer.length, 974 obj_desc->buffer.length,
613 DB_DWORD_DISPLAY, _COMPONENT); 975 DB_DWORD_DISPLAY, _COMPONENT);
614 } else { 976 } else {
@@ -618,19 +980,19 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
618 980
619 case ACPI_TYPE_PACKAGE: 981 case ACPI_TYPE_PACKAGE:
620 982
621 acpi_os_printf("[Package] Contains %d Elements: \n", 983 acpi_os_printf("[Package] Contains %d Elements:\n",
622 obj_desc->package.count); 984 obj_desc->package.count);
623 985
624 for (i = 0; i < obj_desc->package.count; i++) { 986 for (i = 0; i < obj_desc->package.count; i++) {
625 acpi_ex_dump_package(obj_desc->package.elements[i], 987 acpi_ex_dump_package_obj(obj_desc->package.elements[i],
626 level + 1, i); 988 level + 1, i);
627 } 989 }
628 break; 990 break;
629 991
630 case ACPI_TYPE_LOCAL_REFERENCE: 992 case ACPI_TYPE_LOCAL_REFERENCE:
631 993
632 acpi_os_printf("[Object Reference] "); 994 acpi_os_printf("[Object Reference] ");
633 acpi_ex_dump_reference(obj_desc); 995 acpi_ex_dump_reference_obj(obj_desc);
634 break; 996 break;
635 997
636 default: 998 default:
@@ -645,7 +1007,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
645 * 1007 *
646 * FUNCTION: acpi_ex_dump_object_descriptor 1008 * FUNCTION: acpi_ex_dump_object_descriptor
647 * 1009 *
648 * PARAMETERS: Object - Descriptor to dump 1010 * PARAMETERS: obj_desc - Descriptor to dump
649 * Flags - Force display if TRUE 1011 * Flags - Force display if TRUE
650 * 1012 *
651 * DESCRIPTION: Dumps the members of the object descriptor given. 1013 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -670,11 +1032,13 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
670 } 1032 }
671 1033
672 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { 1034 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
673 acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc, 1035 acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
674 flags); 1036 obj_desc, flags);
1037
675 acpi_os_printf("\nAttached Object (%p):\n", 1038 acpi_os_printf("\nAttached Object (%p):\n",
676 ((struct acpi_namespace_node *)obj_desc)-> 1039 ((struct acpi_namespace_node *)obj_desc)->
677 object); 1040 object);
1041
678 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) 1042 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
679 obj_desc)->object, flags); 1043 obj_desc)->object, flags);
680 return_VOID; 1044 return_VOID;
@@ -687,233 +1051,18 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
687 return_VOID; 1051 return_VOID;
688 } 1052 }
689 1053
690 /* Common Fields */ 1054 if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) {
691 1055 return_VOID;
692 acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc)); 1056 }
693 acpi_ex_out_integer("Reference Count",
694 obj_desc->common.reference_count);
695 acpi_ex_out_integer("Flags", obj_desc->common.flags);
696
697 /* Object-specific Fields */
698
699 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
700 case ACPI_TYPE_INTEGER:
701
702 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
703 ACPI_FORMAT_UINT64(obj_desc->integer.value));
704 break;
705
706 case ACPI_TYPE_STRING:
707
708 acpi_ex_out_integer("Length", obj_desc->string.length);
709
710 acpi_os_printf("%20s : %p ", "Pointer",
711 obj_desc->string.pointer);
712 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
713 acpi_os_printf("\n");
714 break;
715
716 case ACPI_TYPE_BUFFER:
717
718 acpi_ex_out_integer("Length", obj_desc->buffer.length);
719 acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer);
720 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
721 obj_desc->buffer.length);
722 break;
723
724 case ACPI_TYPE_PACKAGE:
725
726 acpi_ex_out_integer("Flags", obj_desc->package.flags);
727 acpi_ex_out_integer("Elements", obj_desc->package.count);
728 acpi_ex_out_pointer("Element List", obj_desc->package.elements);
729
730 /* Dump the package contents */
731
732 acpi_os_printf("\nPackage Contents:\n");
733 acpi_ex_dump_package(obj_desc, 0, 0);
734 break;
735
736 case ACPI_TYPE_DEVICE:
737
738 acpi_ex_out_pointer("Handler", obj_desc->device.handler);
739 acpi_ex_out_pointer("system_notify",
740 obj_desc->device.system_notify);
741 acpi_ex_out_pointer("device_notify",
742 obj_desc->device.device_notify);
743 break;
744
745 case ACPI_TYPE_EVENT:
746
747 acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore);
748 break;
749
750 case ACPI_TYPE_METHOD:
751
752 acpi_ex_out_integer("param_count",
753 obj_desc->method.param_count);
754 acpi_ex_out_integer("Concurrency",
755 obj_desc->method.concurrency);
756 acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore);
757 acpi_ex_out_integer("owner_id", obj_desc->method.owner_id);
758 acpi_ex_out_integer("aml_length", obj_desc->method.aml_length);
759 acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start);
760 break;
761
762 case ACPI_TYPE_MUTEX:
763
764 acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level);
765 acpi_ex_out_pointer("owner_thread",
766 obj_desc->mutex.owner_thread);
767 acpi_ex_out_integer("acquire_depth",
768 obj_desc->mutex.acquisition_depth);
769 acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore);
770 break;
771
772 case ACPI_TYPE_REGION:
773
774 acpi_ex_out_integer("space_id", obj_desc->region.space_id);
775 acpi_ex_out_integer("Flags", obj_desc->region.flags);
776 acpi_ex_out_address("Address", obj_desc->region.address);
777 acpi_ex_out_integer("Length", obj_desc->region.length);
778 acpi_ex_out_pointer("Handler", obj_desc->region.handler);
779 acpi_ex_out_pointer("Next", obj_desc->region.next);
780 break;
781
782 case ACPI_TYPE_POWER:
783
784 acpi_ex_out_integer("system_level",
785 obj_desc->power_resource.system_level);
786 acpi_ex_out_integer("resource_order",
787 obj_desc->power_resource.resource_order);
788 acpi_ex_out_pointer("system_notify",
789 obj_desc->power_resource.system_notify);
790 acpi_ex_out_pointer("device_notify",
791 obj_desc->power_resource.device_notify);
792 break;
793
794 case ACPI_TYPE_PROCESSOR:
795
796 acpi_ex_out_integer("Processor ID",
797 obj_desc->processor.proc_id);
798 acpi_ex_out_integer("Length", obj_desc->processor.length);
799 acpi_ex_out_address("Address",
800 (acpi_physical_address) obj_desc->processor.
801 address);
802 acpi_ex_out_pointer("system_notify",
803 obj_desc->processor.system_notify);
804 acpi_ex_out_pointer("device_notify",
805 obj_desc->processor.device_notify);
806 acpi_ex_out_pointer("Handler", obj_desc->processor.handler);
807 break;
808
809 case ACPI_TYPE_THERMAL:
810
811 acpi_ex_out_pointer("system_notify",
812 obj_desc->thermal_zone.system_notify);
813 acpi_ex_out_pointer("device_notify",
814 obj_desc->thermal_zone.device_notify);
815 acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler);
816 break;
817
818 case ACPI_TYPE_BUFFER_FIELD:
819 case ACPI_TYPE_LOCAL_REGION_FIELD:
820 case ACPI_TYPE_LOCAL_BANK_FIELD:
821 case ACPI_TYPE_LOCAL_INDEX_FIELD:
822
823 acpi_ex_out_integer("field_flags",
824 obj_desc->common_field.field_flags);
825 acpi_ex_out_integer("access_byte_width",
826 obj_desc->common_field.access_byte_width);
827 acpi_ex_out_integer("bit_length",
828 obj_desc->common_field.bit_length);
829 acpi_ex_out_integer("fld_bit_offset",
830 obj_desc->common_field.
831 start_field_bit_offset);
832 acpi_ex_out_integer("base_byte_offset",
833 obj_desc->common_field.base_byte_offset);
834 acpi_ex_out_pointer("parent_node", obj_desc->common_field.node);
835
836 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
837 case ACPI_TYPE_BUFFER_FIELD:
838 acpi_ex_out_pointer("buffer_obj",
839 obj_desc->buffer_field.buffer_obj);
840 break;
841
842 case ACPI_TYPE_LOCAL_REGION_FIELD:
843 acpi_ex_out_pointer("region_obj",
844 obj_desc->field.region_obj);
845 break;
846
847 case ACPI_TYPE_LOCAL_BANK_FIELD:
848 acpi_ex_out_integer("Value",
849 obj_desc->bank_field.value);
850 acpi_ex_out_pointer("region_obj",
851 obj_desc->bank_field.region_obj);
852 acpi_ex_out_pointer("bank_obj",
853 obj_desc->bank_field.bank_obj);
854 break;
855
856 case ACPI_TYPE_LOCAL_INDEX_FIELD:
857 acpi_ex_out_integer("Value",
858 obj_desc->index_field.value);
859 acpi_ex_out_pointer("Index",
860 obj_desc->index_field.index_obj);
861 acpi_ex_out_pointer("Data",
862 obj_desc->index_field.data_obj);
863 break;
864
865 default:
866 /* All object types covered above */
867 break;
868 }
869 break;
870
871 case ACPI_TYPE_LOCAL_REFERENCE:
872
873 acpi_ex_out_integer("target_type",
874 obj_desc->reference.target_type);
875 acpi_ex_out_string("Opcode",
876 (acpi_ps_get_opcode_info
877 (obj_desc->reference.opcode))->name);
878 acpi_ex_out_integer("Offset", obj_desc->reference.offset);
879 acpi_ex_out_pointer("obj_desc", obj_desc->reference.object);
880 acpi_ex_out_pointer("Node", obj_desc->reference.node);
881 acpi_ex_out_pointer("Where", obj_desc->reference.where);
882
883 acpi_ex_dump_reference(obj_desc);
884 break;
885
886 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
887
888 acpi_ex_out_integer("space_id",
889 obj_desc->address_space.space_id);
890 acpi_ex_out_pointer("Next", obj_desc->address_space.next);
891 acpi_ex_out_pointer("region_list",
892 obj_desc->address_space.region_list);
893 acpi_ex_out_pointer("Node", obj_desc->address_space.node);
894 acpi_ex_out_pointer("Context", obj_desc->address_space.context);
895 break;
896 1057
897 case ACPI_TYPE_LOCAL_NOTIFY: 1058 /* Common Fields */
898 1059
899 acpi_ex_out_pointer("Node", obj_desc->notify.node); 1060 acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
900 acpi_ex_out_pointer("Context", obj_desc->notify.context);
901 break;
902 1061
903 case ACPI_TYPE_LOCAL_ALIAS: 1062 /* Object-specific fields */
904 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
905 case ACPI_TYPE_LOCAL_EXTRA:
906 case ACPI_TYPE_LOCAL_DATA:
907 default:
908
909 acpi_os_printf
910 ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
911 acpi_ut_get_object_type_name(obj_desc));
912 break;
913 }
914 1063
1064 acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
915 return_VOID; 1065 return_VOID;
916} 1066}
917 1067
918#endif /* ACPI_FUTURE_USAGE */
919#endif 1068#endif
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index ab1ba399aa28..e259201ce9a0 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/executer/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -249,13 +249,18 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
249 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). 249 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
250 */ 250 */
251 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { 251 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
252 ACPI_REPORT_ERROR(("SMBus write requires Buffer, found type %s\n", acpi_ut_get_object_type_name(source_desc))); 252 ACPI_ERROR((AE_INFO,
253 "SMBus write requires Buffer, found type %s",
254 acpi_ut_get_object_type_name(source_desc)));
253 255
254 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 256 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
255 } 257 }
256 258
257 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { 259 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
258 ACPI_REPORT_ERROR(("SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length)); 260 ACPI_ERROR((AE_INFO,
261 "SMBus write requires Buffer of length %X, found length %X",
262 ACPI_SMBUS_BUFFER_SIZE,
263 source_desc->buffer.length));
259 264
260 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); 265 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
261 } 266 }
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index ba6e08843c29..bd1af35f7fcf 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -94,10 +94,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
94 /* We must have a valid region */ 94 /* We must have a valid region */
95 95
96 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { 96 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) {
97 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 97 ACPI_ERROR((AE_INFO, "Needed Region, found type %X (%s)",
98 "Needed Region, found type %X (%s)\n", 98 ACPI_GET_OBJECT_TYPE(rgn_desc),
99 ACPI_GET_OBJECT_TYPE(rgn_desc), 99 acpi_ut_get_object_type_name(rgn_desc)));
100 acpi_ut_get_object_type_name(rgn_desc)));
101 100
102 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 101 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
103 } 102 }
@@ -162,31 +161,28 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
162 * than the region itself. For example, a region of length one 161 * than the region itself. For example, a region of length one
163 * byte, and a field with Dword access specified. 162 * byte, and a field with Dword access specified.
164 */ 163 */
165 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 164 ACPI_ERROR((AE_INFO,
166 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", 165 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)",
167 acpi_ut_get_node_name(obj_desc-> 166 acpi_ut_get_node_name(obj_desc->
168 common_field. 167 common_field.node),
169 node), 168 obj_desc->common_field.access_byte_width,
170 obj_desc->common_field. 169 acpi_ut_get_node_name(rgn_desc->region.
171 access_byte_width, 170 node),
172 acpi_ut_get_node_name(rgn_desc-> 171 rgn_desc->region.length));
173 region.node),
174 rgn_desc->region.length));
175 } 172 }
176 173
177 /* 174 /*
178 * Offset rounded up to next multiple of field width 175 * Offset rounded up to next multiple of field width
179 * exceeds region length, indicate an error 176 * exceeds region length, indicate an error
180 */ 177 */
181 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 178 ACPI_ERROR((AE_INFO,
182 "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", 179 "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)",
183 acpi_ut_get_node_name(obj_desc->common_field. 180 acpi_ut_get_node_name(obj_desc->common_field.node),
184 node), 181 obj_desc->common_field.base_byte_offset,
185 obj_desc->common_field.base_byte_offset, 182 field_datum_byte_offset,
186 field_datum_byte_offset, 183 obj_desc->common_field.access_byte_width,
187 obj_desc->common_field.access_byte_width, 184 acpi_ut_get_node_name(rgn_desc->region.node),
188 acpi_ut_get_node_name(rgn_desc->region.node), 185 rgn_desc->region.length));
189 rgn_desc->region.length));
190 186
191 return_ACPI_STATUS(AE_AML_REGION_LIMIT); 187 return_ACPI_STATUS(AE_AML_REGION_LIMIT);
192 } 188 }
@@ -270,18 +266,17 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
270 266
271 if (ACPI_FAILURE(status)) { 267 if (ACPI_FAILURE(status)) {
272 if (status == AE_NOT_IMPLEMENTED) { 268 if (status == AE_NOT_IMPLEMENTED) {
273 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 269 ACPI_ERROR((AE_INFO,
274 "Region %s(%X) not implemented\n", 270 "Region %s(%X) not implemented",
275 acpi_ut_get_region_name(rgn_desc-> 271 acpi_ut_get_region_name(rgn_desc->region.
276 region. 272 space_id),
277 space_id), 273 rgn_desc->region.space_id));
278 rgn_desc->region.space_id));
279 } else if (status == AE_NOT_EXIST) { 274 } else if (status == AE_NOT_EXIST) {
280 ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n", 275 ACPI_ERROR((AE_INFO,
281 acpi_ut_get_region_name(rgn_desc-> 276 "Region %s(%X) has no handler",
282 region. 277 acpi_ut_get_region_name(rgn_desc->region.
283 space_id), 278 space_id),
284 rgn_desc->region.space_id)); 279 rgn_desc->region.space_id));
285 } 280 }
286 } 281 }
287 282
@@ -514,8 +509,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
514 509
515 default: 510 default:
516 511
517 ACPI_REPORT_ERROR(("Wrong object type in field I/O %X\n", 512 ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %X",
518 ACPI_GET_OBJECT_TYPE(obj_desc))); 513 ACPI_GET_OBJECT_TYPE(obj_desc)));
519 status = AE_AML_INTERNAL; 514 status = AE_AML_INTERNAL;
520 break; 515 break;
521 } 516 }
@@ -618,11 +613,11 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
618 613
619 default: 614 default:
620 615
621 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 616 ACPI_ERROR((AE_INFO,
622 "write_with_update_rule: Unknown update_rule setting: %X\n", 617 "Unknown update_rule value: %X",
623 (obj_desc->common_field. 618 (obj_desc->common_field.
624 field_flags & 619 field_flags &
625 AML_FIELD_UPDATE_RULE_MASK))); 620 AML_FIELD_UPDATE_RULE_MASK)));
626 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 621 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
627 } 622 }
628 } 623 }
@@ -677,10 +672,9 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
677 672
678 if (buffer_length < 673 if (buffer_length <
679 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { 674 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
680 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 675 ACPI_ERROR((AE_INFO,
681 "Field size %X (bits) is too large for buffer (%X)\n", 676 "Field size %X (bits) is too large for buffer (%X)",
682 obj_desc->common_field.bit_length, 677 obj_desc->common_field.bit_length, buffer_length));
683 buffer_length));
684 678
685 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 679 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
686 } 680 }
@@ -792,10 +786,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
792 786
793 if (buffer_length < 787 if (buffer_length <
794 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { 788 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 789 ACPI_ERROR((AE_INFO,
796 "Field size %X (bits) is too large for buffer (%X)\n", 790 "Field size %X (bits) is too large for buffer (%X)",
797 obj_desc->common_field.bit_length, 791 obj_desc->common_field.bit_length, buffer_length));
798 buffer_length));
799 792
800 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 793 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
801 } 794 }
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index a3f4d72bedc9..48c18d29222a 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
48#include <acpi/amlresrc.h>
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exmisc") 51ACPI_MODULE_NAME("exmisc")
@@ -97,7 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
97 98
98 default: 99 default:
99 100
100 ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode)); 101 ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
102 obj_desc->reference.opcode));
101 return_ACPI_STATUS(AE_AML_INTERNAL); 103 return_ACPI_STATUS(AE_AML_INTERNAL);
102 } 104 }
103 break; 105 break;
@@ -112,7 +114,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
112 114
113 default: 115 default:
114 116
115 ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); 117 ACPI_ERROR((AE_INFO, "Invalid descriptor type %X",
118 ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
116 return_ACPI_STATUS(AE_TYPE); 119 return_ACPI_STATUS(AE_TYPE);
117 } 120 }
118 121
@@ -157,48 +160,65 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
157 union acpi_operand_object **actual_return_desc, 160 union acpi_operand_object **actual_return_desc,
158 struct acpi_walk_state *walk_state) 161 struct acpi_walk_state *walk_state)
159{ 162{
163 acpi_status status;
160 union acpi_operand_object *return_desc; 164 union acpi_operand_object *return_desc;
161 u8 *new_buf; 165 u8 *new_buf;
162 u8 *end_tag1; 166 u8 *end_tag;
163 u8 *end_tag2; 167 acpi_size length0;
164 acpi_size length1; 168 acpi_size length1;
165 acpi_size length2; 169 acpi_size new_length;
166 170
167 ACPI_FUNCTION_TRACE("ex_concat_template"); 171 ACPI_FUNCTION_TRACE("ex_concat_template");
168 172
169 /* Find the end_tags in each resource template */ 173 /*
174 * Find the end_tag descriptor in each resource template.
175 * Note1: returned pointers point TO the end_tag, not past it.
176 * Note2: zero-length buffers are allowed; treated like one end_tag
177 */
178
179 /* Get the length of the first resource template */
170 180
171 end_tag1 = acpi_ut_get_resource_end_tag(operand0); 181 status = acpi_ut_get_resource_end_tag(operand0, &end_tag);
172 end_tag2 = acpi_ut_get_resource_end_tag(operand1); 182 if (ACPI_FAILURE(status)) {
173 if (!end_tag1 || !end_tag2) { 183 return_ACPI_STATUS(status);
174 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
175 } 184 }
176 185
177 /* Compute the length of each part */ 186 length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer);
187
188 /* Get the length of the second resource template */
189
190 status = acpi_ut_get_resource_end_tag(operand1, &end_tag);
191 if (ACPI_FAILURE(status)) {
192 return_ACPI_STATUS(status);
193 }
178 194
179 length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); 195 length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer);
180 length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */
181 196
182 /* Create a new buffer object for the result */ 197 /* Combine both lengths, minimum size will be 2 for end_tag */
183 198
184 return_desc = acpi_ut_create_buffer_object(length1 + length2); 199 new_length = length0 + length1 + sizeof(struct aml_resource_end_tag);
200
201 /* Create a new buffer object for the result (with one end_tag) */
202
203 return_desc = acpi_ut_create_buffer_object(new_length);
185 if (!return_desc) { 204 if (!return_desc) {
186 return_ACPI_STATUS(AE_NO_MEMORY); 205 return_ACPI_STATUS(AE_NO_MEMORY);
187 } 206 }
188 207
189 /* Copy the templates to the new descriptor */ 208 /*
190 209 * Copy the templates to the new buffer, 0 first, then 1 follows. One
210 * end_tag descriptor is copied from Operand1.
211 */
191 new_buf = return_desc->buffer.pointer; 212 new_buf = return_desc->buffer.pointer;
192 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); 213 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
193 ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); 214 ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
194 215
195 /* Compute the new checksum */ 216 /* Insert end_tag and set the checksum to zero, means "ignore checksum" */
196 217
197 new_buf[return_desc->buffer.length - 1] = 218 new_buf[new_length - 1] = 0;
198 acpi_ut_generate_checksum(return_desc->buffer.pointer, 219 new_buf[new_length - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
199 (return_desc->buffer.length - 1));
200 220
201 /* Return the completed template descriptor */ 221 /* Return the completed resource template */
202 222
203 *actual_return_desc = return_desc; 223 *actual_return_desc = return_desc;
204 return_ACPI_STATUS(AE_OK); 224 return_ACPI_STATUS(AE_OK);
@@ -229,7 +249,6 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
229 union acpi_operand_object *return_desc; 249 union acpi_operand_object *return_desc;
230 char *new_buf; 250 char *new_buf;
231 acpi_status status; 251 acpi_status status;
232 acpi_size new_length;
233 252
234 ACPI_FUNCTION_TRACE("ex_do_concatenate"); 253 ACPI_FUNCTION_TRACE("ex_do_concatenate");
235 254
@@ -256,8 +275,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
256 break; 275 break;
257 276
258 default: 277 default:
259 ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", 278 ACPI_ERROR((AE_INFO, "Invalid object type: %X",
260 ACPI_GET_OBJECT_TYPE(operand0))); 279 ACPI_GET_OBJECT_TYPE(operand0)));
261 status = AE_AML_INTERNAL; 280 status = AE_AML_INTERNAL;
262 } 281 }
263 282
@@ -296,8 +315,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
296 315
297 /* Copy the first integer, LSB first */ 316 /* Copy the first integer, LSB first */
298 317
299 ACPI_MEMCPY(new_buf, 318 ACPI_MEMCPY(new_buf, &operand0->integer.value,
300 &operand0->integer.value,
301 acpi_gbl_integer_byte_width); 319 acpi_gbl_integer_byte_width);
302 320
303 /* Copy the second integer (LSB first) after the first */ 321 /* Copy the second integer (LSB first) after the first */
@@ -311,14 +329,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
311 329
312 /* Result of two Strings is a String */ 330 /* Result of two Strings is a String */
313 331
314 new_length = (acpi_size) operand0->string.length + 332 return_desc = acpi_ut_create_string_object((acpi_size)
315 (acpi_size) local_operand1->string.length; 333 (operand0->string.
316 if (new_length > ACPI_MAX_STRING_CONVERSION) { 334 length +
317 status = AE_AML_STRING_LIMIT; 335 local_operand1->
318 goto cleanup; 336 string.length));
319 }
320
321 return_desc = acpi_ut_create_string_object(new_length);
322 if (!return_desc) { 337 if (!return_desc) {
323 status = AE_NO_MEMORY; 338 status = AE_NO_MEMORY;
324 goto cleanup; 339 goto cleanup;
@@ -338,11 +353,10 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
338 /* Result of two Buffers is a Buffer */ 353 /* Result of two Buffers is a Buffer */
339 354
340 return_desc = acpi_ut_create_buffer_object((acpi_size) 355 return_desc = acpi_ut_create_buffer_object((acpi_size)
341 operand0->buffer. 356 (operand0->buffer.
342 length + 357 length +
343 (acpi_size) 358 local_operand1->
344 local_operand1-> 359 buffer.length));
345 buffer.length);
346 if (!return_desc) { 360 if (!return_desc) {
347 status = AE_NO_MEMORY; 361 status = AE_NO_MEMORY;
348 goto cleanup; 362 goto cleanup;
@@ -352,8 +366,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
352 366
353 /* Concatenate the buffers */ 367 /* Concatenate the buffers */
354 368
355 ACPI_MEMCPY(new_buf, 369 ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
356 operand0->buffer.pointer, operand0->buffer.length); 370 operand0->buffer.length);
357 ACPI_MEMCPY(new_buf + operand0->buffer.length, 371 ACPI_MEMCPY(new_buf + operand0->buffer.length,
358 local_operand1->buffer.pointer, 372 local_operand1->buffer.pointer,
359 local_operand1->buffer.length); 373 local_operand1->buffer.length);
@@ -363,8 +377,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
363 377
364 /* Invalid object type, should not happen here */ 378 /* Invalid object type, should not happen here */
365 379
366 ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n", 380 ACPI_ERROR((AE_INFO, "Invalid object type: %X",
367 ACPI_GET_OBJECT_TYPE(operand0))); 381 ACPI_GET_OBJECT_TYPE(operand0)));
368 status = AE_AML_INTERNAL; 382 status = AE_AML_INTERNAL;
369 goto cleanup; 383 goto cleanup;
370 } 384 }
@@ -625,9 +639,8 @@ acpi_ex_do_logical_op(u16 opcode,
625 639
626 /* Lexicographic compare: compare the data bytes */ 640 /* Lexicographic compare: compare the data bytes */
627 641
628 compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer, 642 compare = ACPI_MEMCMP(operand0->buffer.pointer,
629 (const char *)local_operand1->buffer. 643 local_operand1->buffer.pointer,
630 pointer,
631 (length0 > length1) ? length1 : length0); 644 (length0 > length1) ? length1 : length0);
632 645
633 switch (opcode) { 646 switch (opcode) {
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index ab47f6d8b5c0..f843b22e20b9 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -153,7 +153,9 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
153 /* Sanity check -- we must have a valid thread ID */ 153 /* Sanity check -- we must have a valid thread ID */
154 154
155 if (!walk_state->thread) { 155 if (!walk_state->thread) {
156 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 156 ACPI_ERROR((AE_INFO,
157 "Cannot acquire Mutex [%4.4s], null thread info",
158 acpi_ut_get_node_name(obj_desc->mutex.node)));
157 return_ACPI_STATUS(AE_AML_INTERNAL); 159 return_ACPI_STATUS(AE_AML_INTERNAL);
158 } 160 }
159 161
@@ -162,7 +164,9 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
162 * mutex. This mechanism provides some deadlock prevention 164 * mutex. This mechanism provides some deadlock prevention
163 */ 165 */
164 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
165 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 167 ACPI_ERROR((AE_INFO,
168 "Cannot acquire Mutex [%4.4s], incorrect sync_level",
169 acpi_ut_get_node_name(obj_desc->mutex.node)));
166 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 170 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
167 } 171 }
168 172
@@ -237,14 +241,18 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
237 /* The mutex must have been previously acquired in order to release it */ 241 /* The mutex must have been previously acquired in order to release it */
238 242
239 if (!obj_desc->mutex.owner_thread) { 243 if (!obj_desc->mutex.owner_thread) {
240 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 244 ACPI_ERROR((AE_INFO,
245 "Cannot release Mutex [%4.4s], not acquired",
246 acpi_ut_get_node_name(obj_desc->mutex.node)));
241 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); 247 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
242 } 248 }
243 249
244 /* Sanity check -- we must have a valid thread ID */ 250 /* Sanity check -- we must have a valid thread ID */
245 251
246 if (!walk_state->thread) { 252 if (!walk_state->thread) {
247 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 253 ACPI_ERROR((AE_INFO,
254 "Cannot release Mutex [%4.4s], null thread info",
255 acpi_ut_get_node_name(obj_desc->mutex.node)));
248 return_ACPI_STATUS(AE_AML_INTERNAL); 256 return_ACPI_STATUS(AE_AML_INTERNAL);
249 } 257 }
250 258
@@ -255,7 +263,11 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
255 if ((obj_desc->mutex.owner_thread->thread_id != 263 if ((obj_desc->mutex.owner_thread->thread_id !=
256 walk_state->thread->thread_id) 264 walk_state->thread->thread_id)
257 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { 265 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
258 ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id)); 266 ACPI_ERROR((AE_INFO,
267 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X",
268 walk_state->thread->thread_id,
269 acpi_ut_get_node_name(obj_desc->mutex.node),
270 obj_desc->mutex.owner_thread->thread_id));
259 return_ACPI_STATUS(AE_AML_NOT_OWNER); 271 return_ACPI_STATUS(AE_AML_NOT_OWNER);
260 } 272 }
261 273
@@ -264,7 +276,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
264 * equal to the current sync level 276 * equal to the current sync level
265 */ 277 */
266 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { 278 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
267 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 279 ACPI_ERROR((AE_INFO,
280 "Cannot release Mutex [%4.4s], incorrect sync_level",
281 acpi_ut_get_node_name(obj_desc->mutex.node)));
268 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 282 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
269 } 283 }
270 284
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 239d8473e9a5..054fe5e1a314 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -99,7 +99,8 @@ static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
99 */ 99 */
100 name_string = ACPI_MEM_ALLOCATE(size_needed); 100 name_string = ACPI_MEM_ALLOCATE(size_needed);
101 if (!name_string) { 101 if (!name_string) {
102 ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed)); 102 ACPI_ERROR((AE_INFO,
103 "Could not allocate size %d", size_needed));
103 return_PTR(NULL); 104 return_PTR(NULL);
104 } 105 }
105 106
@@ -167,8 +168,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
167 char_buf[0] = *aml_address; 168 char_buf[0] = *aml_address;
168 169
169 if ('0' <= char_buf[0] && char_buf[0] <= '9') { 170 if ('0' <= char_buf[0] && char_buf[0] <= '9') {
170 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n", 171 ACPI_ERROR((AE_INFO, "Invalid leading digit: %c", char_buf[0]));
171 char_buf[0]));
172 return_ACPI_STATUS(AE_CTRL_PENDING); 172 return_ACPI_STATUS(AE_CTRL_PENDING);
173 } 173 }
174 174
@@ -191,10 +191,10 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
191 if (name_string) { 191 if (name_string) {
192 ACPI_STRCAT(name_string, char_buf); 192 ACPI_STRCAT(name_string, char_buf);
193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
194 "Appended to - %s \n", name_string)); 194 "Appended to - %s\n", name_string));
195 } else { 195 } else {
196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
197 "No Name string - %s \n", char_buf)); 197 "No Name string - %s\n", char_buf));
198 } 198 }
199 } else if (index == 0) { 199 } else if (index == 0) {
200 /* 200 /*
@@ -211,12 +211,12 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
211 * the required 4 211 * the required 4
212 */ 212 */
213 status = AE_AML_BAD_NAME; 213 status = AE_AML_BAD_NAME;
214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 214 ACPI_ERROR((AE_INFO,
215 "Bad character %02x in name, at %p\n", 215 "Bad character %02x in name, at %p",
216 *aml_address, aml_address)); 216 *aml_address, aml_address));
217 } 217 }
218 218
219 *in_aml_address = (u8 *) aml_address; 219 *in_aml_address = ACPI_CAST_PTR(u8, aml_address);
220 return_ACPI_STATUS(status); 220 return_ACPI_STATUS(status);
221} 221}
222 222
@@ -412,8 +412,7 @@ acpi_ex_get_name_string(acpi_object_type data_type,
412 if (AE_CTRL_PENDING == status && has_prefix) { 412 if (AE_CTRL_PENDING == status && has_prefix) {
413 /* Ran out of segments after processing a prefix */ 413 /* Ran out of segments after processing a prefix */
414 414
415 ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n", 415 ACPI_ERROR((AE_INFO, "Malformed Name at %p", name_string));
416 name_string));
417 status = AE_AML_BAD_NAME; 416 status = AE_AML_BAD_NAME;
418 } 417 }
419 418
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index 97e34542f5e4..23d0823bcd5e 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,8 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
111 111
112 default: /* Unknown opcode */ 112 default: /* Unknown opcode */
113 113
114 ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 114 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
115 walk_state->opcode));
115 status = AE_AML_BAD_OPCODE; 116 status = AE_AML_BAD_OPCODE;
116 break; 117 break;
117 } 118 }
@@ -188,7 +189,8 @@ acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
188 189
189 default: /* Unknown opcode */ 190 default: /* Unknown opcode */
190 191
191 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 192 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
193 walk_state->opcode));
192 status = AE_AML_BAD_OPCODE; 194 status = AE_AML_BAD_OPCODE;
193 break; 195 break;
194 } 196 }
@@ -227,7 +229,8 @@ acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
227 229
228 default: /* Unknown opcode */ 230 default: /* Unknown opcode */
229 231
230 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode)); 232 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
233 walk_state->opcode));
231 status = AE_AML_BAD_OPCODE; 234 status = AE_AML_BAD_OPCODE;
232 goto cleanup; 235 goto cleanup;
233 } 236 }
@@ -346,9 +349,9 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
346 /* Check the range of the digit */ 349 /* Check the range of the digit */
347 350
348 if (temp32 > 9) { 351 if (temp32 > 9) {
349 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 352 ACPI_ERROR((AE_INFO,
350 "BCD digit too large (not decimal): 0x%X\n", 353 "BCD digit too large (not decimal): 0x%X",
351 temp32)); 354 temp32));
352 355
353 status = AE_AML_NUMERIC_OVERFLOW; 356 status = AE_AML_NUMERIC_OVERFLOW;
354 goto cleanup; 357 goto cleanup;
@@ -393,12 +396,10 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
393 /* Overflow if there is any data left in Digit */ 396 /* Overflow if there is any data left in Digit */
394 397
395 if (digit > 0) { 398 if (digit > 0) {
396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 399 ACPI_ERROR((AE_INFO,
397 "Integer too large to convert to BCD: %8.8X%8.8X\n", 400 "Integer too large to convert to BCD: %8.8X%8.8X",
398 ACPI_FORMAT_UINT64(operand 401 ACPI_FORMAT_UINT64(operand[0]->
399 [0]-> 402 integer.value)));
400 integer.
401 value)));
402 status = AE_AML_NUMERIC_OVERFLOW; 403 status = AE_AML_NUMERIC_OVERFLOW;
403 goto cleanup; 404 goto cleanup;
404 } 405 }
@@ -525,15 +526,16 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
525 526
526 /* These are two obsolete opcodes */ 527 /* These are two obsolete opcodes */
527 528
528 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 529 ACPI_ERROR((AE_INFO,
529 "%s is obsolete and not implemented\n", 530 "%s is obsolete and not implemented",
530 acpi_ps_get_opcode_name(walk_state->opcode))); 531 acpi_ps_get_opcode_name(walk_state->opcode)));
531 status = AE_SUPPORT; 532 status = AE_SUPPORT;
532 goto cleanup; 533 goto cleanup;
533 534
534 default: /* Unknown opcode */ 535 default: /* Unknown opcode */
535 536
536 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); 537 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
538 walk_state->opcode));
537 status = AE_AML_BAD_OPCODE; 539 status = AE_AML_BAD_OPCODE;
538 goto cleanup; 540 goto cleanup;
539 } 541 }
@@ -639,11 +641,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
639 acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc, 641 acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc,
640 walk_state); 642 walk_state);
641 if (ACPI_FAILURE(status)) { 643 if (ACPI_FAILURE(status)) {
642 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 644 ACPI_EXCEPTION((AE_INFO, status,
643 "%s: bad operand(s) %s\n", 645 "While resolving operands for [%s]",
644 acpi_ps_get_opcode_name(walk_state-> 646 acpi_ps_get_opcode_name(walk_state->
645 opcode), 647 opcode)));
646 acpi_format_exception(status)));
647 648
648 goto cleanup; 649 goto cleanup;
649 } 650 }
@@ -742,9 +743,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
742 break; 743 break;
743 744
744 default: 745 default:
745 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 746 ACPI_ERROR((AE_INFO,
746 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n", 747 "Operand is not Buf/Int/Str/Pkg - found type %s",
747 acpi_ut_get_type_name(type))); 748 acpi_ut_get_type_name(type)));
748 status = AE_AML_OPERAND_TYPE; 749 status = AE_AML_OPERAND_TYPE;
749 goto cleanup; 750 goto cleanup;
750 } 751 }
@@ -941,11 +942,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
941 942
942 default: 943 default:
943 944
944 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 945 ACPI_ERROR((AE_INFO,
945 "Unknown Index target_type %X in obj %p\n", 946 "Unknown Index target_type %X in obj %p",
946 operand[0]->reference. 947 operand[0]->reference.
947 target_type, 948 target_type, operand[0]));
948 operand[0]));
949 status = AE_AML_OPERAND_TYPE; 949 status = AE_AML_OPERAND_TYPE;
950 goto cleanup; 950 goto cleanup;
951 } 951 }
@@ -971,11 +971,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
971 break; 971 break;
972 972
973 default: 973 default:
974 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 974 ACPI_ERROR((AE_INFO,
975 "Unknown opcode in ref(%p) - %X\n", 975 "Unknown opcode in ref(%p) - %X",
976 operand[0], 976 operand[0],
977 operand[0]->reference. 977 operand[0]->reference.opcode));
978 opcode));
979 978
980 status = AE_TYPE; 979 status = AE_TYPE;
981 goto cleanup; 980 goto cleanup;
@@ -985,7 +984,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
985 984
986 default: 985 default:
987 986
988 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 987 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
988 walk_state->opcode));
989 status = AE_AML_BAD_OPCODE; 989 status = AE_AML_BAD_OPCODE;
990 goto cleanup; 990 goto cleanup;
991 } 991 }
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 8d70c6beef00..e263a5ddd405 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -111,9 +111,9 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
111 /* Are notifies allowed on this object? */ 111 /* Are notifies allowed on this object? */
112 112
113 if (!acpi_ev_is_notify_object(node)) { 113 if (!acpi_ev_is_notify_object(node)) {
114 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 114 ACPI_ERROR((AE_INFO,
115 "Unexpected notify object type [%s]\n", 115 "Unexpected notify object type [%s]",
116 acpi_ut_get_type_name(node->type))); 116 acpi_ut_get_type_name(node->type)));
117 117
118 status = AE_AML_OPERAND_TYPE; 118 status = AE_AML_OPERAND_TYPE;
119 break; 119 break;
@@ -157,7 +157,8 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
157 157
158 default: 158 default:
159 159
160 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 160 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
161 walk_state->opcode));
161 status = AE_AML_BAD_OPCODE; 162 status = AE_AML_BAD_OPCODE;
162 } 163 }
163 164
@@ -221,7 +222,8 @@ acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state)
221 222
222 default: 223 default:
223 224
224 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", walk_state->opcode)); 225 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
226 walk_state->opcode));
225 status = AE_AML_BAD_OPCODE; 227 status = AE_AML_BAD_OPCODE;
226 goto cleanup; 228 goto cleanup;
227 } 229 }
@@ -344,10 +346,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
344 (length < operand[1]->integer.value) && 346 (length < operand[1]->integer.value) &&
345 (operand[0]->buffer.pointer[length])) { 347 (operand[0]->buffer.pointer[length])) {
346 length++; 348 length++;
347 if (length > ACPI_MAX_STRING_CONVERSION) {
348 status = AE_AML_STRING_LIMIT;
349 goto cleanup;
350 }
351 } 349 }
352 350
353 /* Allocate a new string object */ 351 /* Allocate a new string object */
@@ -358,8 +356,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
358 goto cleanup; 356 goto cleanup;
359 } 357 }
360 358
361 /* Copy the raw buffer data with no transform. NULL terminated already */ 359 /*
362 360 * Copy the raw buffer data with no transform.
361 * (NULL terminated already)
362 */
363 ACPI_MEMCPY(return_desc->string.pointer, 363 ACPI_MEMCPY(return_desc->string.pointer,
364 operand[0]->buffer.pointer, length); 364 operand[0]->buffer.pointer, length);
365 break; 365 break;
@@ -391,10 +391,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
391 /* Object to be indexed is a Package */ 391 /* Object to be indexed is a Package */
392 392
393 if (index >= operand[0]->package.count) { 393 if (index >= operand[0]->package.count) {
394 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 394 ACPI_ERROR((AE_INFO,
395 "Index value (%X%8.8X) beyond package end (%X)\n", 395 "Index value (%X%8.8X) beyond package end (%X)",
396 ACPI_FORMAT_UINT64(index), 396 ACPI_FORMAT_UINT64(index),
397 operand[0]->package.count)); 397 operand[0]->package.count));
398 status = AE_AML_PACKAGE_LIMIT; 398 status = AE_AML_PACKAGE_LIMIT;
399 goto cleanup; 399 goto cleanup;
400 } 400 }
@@ -407,10 +407,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
407 /* Object to be indexed is a Buffer/String */ 407 /* Object to be indexed is a Buffer/String */
408 408
409 if (index >= operand[0]->buffer.length) { 409 if (index >= operand[0]->buffer.length) {
410 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 410 ACPI_ERROR((AE_INFO,
411 "Index value (%X%8.8X) beyond end of buffer (%X)\n", 411 "Index value (%X%8.8X) beyond end of buffer (%X)",
412 ACPI_FORMAT_UINT64(index), 412 ACPI_FORMAT_UINT64(index),
413 operand[0]->buffer.length)); 413 operand[0]->buffer.length));
414 status = AE_AML_BUFFER_LIMIT; 414 status = AE_AML_BUFFER_LIMIT;
415 goto cleanup; 415 goto cleanup;
416 } 416 }
@@ -442,7 +442,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
442 442
443 default: 443 default:
444 444
445 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); 445 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
446 walk_state->opcode));
446 status = AE_AML_BAD_OPCODE; 447 status = AE_AML_BAD_OPCODE;
447 break; 448 break;
448 } 449 }
@@ -546,7 +547,8 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
546 547
547 default: 548 default:
548 549
549 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 550 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
551 walk_state->opcode));
550 status = AE_AML_BAD_OPCODE; 552 status = AE_AML_BAD_OPCODE;
551 goto cleanup; 553 goto cleanup;
552 } 554 }
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 483365777670..6a3a883cb8a3 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -119,7 +119,8 @@ acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
119 119
120 default: 120 default:
121 121
122 ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 122 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
123 walk_state->opcode));
123 status = AE_AML_BAD_OPCODE; 124 status = AE_AML_BAD_OPCODE;
124 goto cleanup; 125 goto cleanup;
125 } 126 }
@@ -223,8 +224,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
223 goto cleanup; 224 goto cleanup;
224 } 225 }
225 226
226 if (length > 0) { 227 if (buffer) {
227 /* Copy the portion requested */ 228 /* We have a buffer, copy the portion requested */
228 229
229 ACPI_MEMCPY(buffer, operand[0]->string.pointer + index, 230 ACPI_MEMCPY(buffer, operand[0]->string.pointer + index,
230 length); 231 length);
@@ -242,7 +243,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
242 243
243 default: 244 default:
244 245
245 ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 246 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
247 walk_state->opcode));
246 status = AE_AML_BAD_OPCODE; 248 status = AE_AML_BAD_OPCODE;
247 goto cleanup; 249 goto cleanup;
248 } 250 }
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c
index 5dee77139576..e043d924444f 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/executer/exoparg6.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -234,8 +234,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
234 234
235 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || 235 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) ||
236 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { 236 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 237 ACPI_ERROR((AE_INFO, "Match operator out of range"));
238 "Match operator out of range\n"));
239 status = AE_AML_OPERAND_VALUE; 238 status = AE_AML_OPERAND_VALUE;
240 goto cleanup; 239 goto cleanup;
241 } 240 }
@@ -244,10 +243,10 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
244 243
245 index = operand[5]->integer.value; 244 index = operand[5]->integer.value;
246 if (index >= operand[0]->package.count) { 245 if (index >= operand[0]->package.count) {
247 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 246 ACPI_ERROR((AE_INFO,
248 "Index (%X%8.8X) beyond package end (%X)\n", 247 "Index (%X%8.8X) beyond package end (%X)",
249 ACPI_FORMAT_UINT64(index), 248 ACPI_FORMAT_UINT64(index),
250 operand[0]->package.count)); 249 operand[0]->package.count));
251 status = AE_AML_PACKAGE_LIMIT; 250 status = AE_AML_PACKAGE_LIMIT;
252 goto cleanup; 251 goto cleanup;
253 } 252 }
@@ -316,7 +315,8 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
316 315
317 default: 316 default:
318 317
319 ACPI_REPORT_ERROR(("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 318 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
319 walk_state->opcode));
320 status = AE_AML_BAD_OPCODE; 320 status = AE_AML_BAD_OPCODE;
321 goto cleanup; 321 goto cleanup;
322 } 322 }
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
index 7476c363e407..7719ae5d4f16 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/executer/exprep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -274,9 +274,8 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
274 default: 274 default:
275 /* Invalid field access type */ 275 /* Invalid field access type */
276 276
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 277 ACPI_ERROR((AE_INFO, "Unknown field access type %X", access));
278 "Unknown field access type %X\n", access)); 278 return_UINT32(0);
279 return_VALUE(0);
280 } 279 }
281 280
282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 281 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
@@ -289,7 +288,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
289 } 288 }
290 289
291 *return_byte_alignment = byte_alignment; 290 *return_byte_alignment = byte_alignment;
292 return_VALUE(bit_length); 291 return_UINT32(bit_length);
293} 292}
294 293
295/******************************************************************************* 294/*******************************************************************************
@@ -422,15 +421,15 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
422 421
423 if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) { 422 if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) {
424 if (!info->region_node) { 423 if (!info->region_node) {
425 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null region_node\n")); 424 ACPI_ERROR((AE_INFO, "Null region_node"));
426 return_ACPI_STATUS(AE_AML_NO_OPERAND); 425 return_ACPI_STATUS(AE_AML_NO_OPERAND);
427 } 426 }
428 427
429 type = acpi_ns_get_type(info->region_node); 428 type = acpi_ns_get_type(info->region_node);
430 if (type != ACPI_TYPE_REGION) { 429 if (type != ACPI_TYPE_REGION) {
431 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 430 ACPI_ERROR((AE_INFO,
432 "Needed Region, found type %X (%s)\n", 431 "Needed Region, found type %X (%s)",
433 type, acpi_ut_get_type_name(type))); 432 type, acpi_ut_get_type_name(type)));
434 433
435 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 434 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
436 } 435 }
@@ -499,17 +498,17 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
499 498
500 case ACPI_TYPE_LOCAL_INDEX_FIELD: 499 case ACPI_TYPE_LOCAL_INDEX_FIELD:
501 500
501 /* Get the Index and Data registers */
502
502 obj_desc->index_field.index_obj = 503 obj_desc->index_field.index_obj =
503 acpi_ns_get_attached_object(info->register_node); 504 acpi_ns_get_attached_object(info->register_node);
504 obj_desc->index_field.data_obj = 505 obj_desc->index_field.data_obj =
505 acpi_ns_get_attached_object(info->data_register_node); 506 acpi_ns_get_attached_object(info->data_register_node);
506 obj_desc->index_field.value = (u32)
507 (info->field_bit_position /
508 ACPI_MUL_8(obj_desc->field.access_byte_width));
509 507
510 if (!obj_desc->index_field.data_obj 508 if (!obj_desc->index_field.data_obj
511 || !obj_desc->index_field.index_obj) { 509 || !obj_desc->index_field.index_obj) {
512 ACPI_REPORT_ERROR(("Null Index Object during field prep\n")); 510 ACPI_ERROR((AE_INFO,
511 "Null Index Object during field prep"));
513 acpi_ut_delete_object_desc(obj_desc); 512 acpi_ut_delete_object_desc(obj_desc);
514 return_ACPI_STATUS(AE_AML_INTERNAL); 513 return_ACPI_STATUS(AE_AML_INTERNAL);
515 } 514 }
@@ -519,6 +518,15 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
519 acpi_ut_add_reference(obj_desc->index_field.data_obj); 518 acpi_ut_add_reference(obj_desc->index_field.data_obj);
520 acpi_ut_add_reference(obj_desc->index_field.index_obj); 519 acpi_ut_add_reference(obj_desc->index_field.index_obj);
521 520
521 /*
522 * The value written to the Index register is the byte offset of the
523 * target field
524 * Note: may change code to: ACPI_DIV_8 (Info->field_bit_position)
525 */
526 obj_desc->index_field.value = (u32)
527 (info->field_bit_position /
528 ACPI_MUL_8(obj_desc->field.access_byte_width));
529
522 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 530 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
523 "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", 531 "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
524 obj_desc->index_field.start_field_bit_offset, 532 obj_desc->index_field.start_field_bit_offset,
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 9a2f5bea3afe..6a4cfdff606d 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -77,7 +77,7 @@ acpi_ex_system_memory_space_handler(u32 function,
77 struct acpi_mem_space_context *mem_info = region_context; 77 struct acpi_mem_space_context *mem_info = region_context;
78 u32 length; 78 u32 length;
79 acpi_size window_size; 79 acpi_size window_size;
80#ifndef ACPI_MISALIGNED_TRANSFERS 80#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
81 u32 remainder; 81 u32 remainder;
82#endif 82#endif
83 83
@@ -103,13 +103,12 @@ acpi_ex_system_memory_space_handler(u32 function,
103 break; 103 break;
104 104
105 default: 105 default:
106 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 106 ACPI_ERROR((AE_INFO, "Invalid system_memory width %d",
107 "Invalid system_memory width %d\n", 107 bit_width));
108 bit_width));
109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 108 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
110 } 109 }
111 110
112#ifndef ACPI_MISALIGNED_TRANSFERS 111#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
113 /* 112 /*
114 * Hardware does not support non-aligned data transfers, we must verify 113 * Hardware does not support non-aligned data transfers, we must verify
115 * the request. 114 * the request.
@@ -159,10 +158,10 @@ acpi_ex_system_memory_space_handler(u32 function,
159 (void **)&mem_info-> 158 (void **)&mem_info->
160 mapped_logical_address); 159 mapped_logical_address);
161 if (ACPI_FAILURE(status)) { 160 if (ACPI_FAILURE(status)) {
162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 161 ACPI_ERROR((AE_INFO,
163 "Could not map memory at %8.8X%8.8X, size %X\n", 162 "Could not map memory at %8.8X%8.8X, size %X",
164 ACPI_FORMAT_UINT64(address), 163 ACPI_FORMAT_UINT64(address),
165 (u32) window_size)); 164 (u32) window_size));
166 mem_info->mapped_length = 0; 165 mem_info->mapped_length = 0;
167 return_ACPI_STATUS(status); 166 return_ACPI_STATUS(status);
168 } 167 }
@@ -199,20 +198,20 @@ acpi_ex_system_memory_space_handler(u32 function,
199 *value = 0; 198 *value = 0;
200 switch (bit_width) { 199 switch (bit_width) {
201 case 8: 200 case 8:
202 *value = (acpi_integer) * ((u8 *) logical_addr_ptr); 201 *value = (acpi_integer) ACPI_GET8(logical_addr_ptr);
203 break; 202 break;
204 203
205 case 16: 204 case 16:
206 *value = (acpi_integer) * ((u16 *) logical_addr_ptr); 205 *value = (acpi_integer) ACPI_GET16(logical_addr_ptr);
207 break; 206 break;
208 207
209 case 32: 208 case 32:
210 *value = (acpi_integer) * ((u32 *) logical_addr_ptr); 209 *value = (acpi_integer) ACPI_GET32(logical_addr_ptr);
211 break; 210 break;
212 211
213#if ACPI_MACHINE_WIDTH != 16 212#if ACPI_MACHINE_WIDTH != 16
214 case 64: 213 case 64:
215 *value = (acpi_integer) * ((u64 *) logical_addr_ptr); 214 *value = (acpi_integer) ACPI_GET64(logical_addr_ptr);
216 break; 215 break;
217#endif 216#endif
218 default: 217 default:
@@ -225,20 +224,20 @@ acpi_ex_system_memory_space_handler(u32 function,
225 224
226 switch (bit_width) { 225 switch (bit_width) {
227 case 8: 226 case 8:
228 *(u8 *) logical_addr_ptr = (u8) * value; 227 ACPI_SET8(logical_addr_ptr) = (u8) * value;
229 break; 228 break;
230 229
231 case 16: 230 case 16:
232 *(u16 *) logical_addr_ptr = (u16) * value; 231 ACPI_SET16(logical_addr_ptr) = (u16) * value;
233 break; 232 break;
234 233
235 case 32: 234 case 32:
236 *(u32 *) logical_addr_ptr = (u32) * value; 235 ACPI_SET32(logical_addr_ptr) = (u32) * value;
237 break; 236 break;
238 237
239#if ACPI_MACHINE_WIDTH != 16 238#if ACPI_MACHINE_WIDTH != 16
240 case 64: 239 case 64:
241 *(u64 *) logical_addr_ptr = (u64) * value; 240 ACPI_SET64(logical_addr_ptr) = (u64) * value;
242 break; 241 break;
243#endif 242#endif
244 243
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c
index ff5d8f97e8eb..01b26c80d22b 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/executer/exresnte.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -122,8 +122,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
122 } 122 }
123 123
124 if (!source_desc) { 124 if (!source_desc) {
125 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 125 ACPI_ERROR((AE_INFO, "No object attached to node %p", node));
126 "No object attached to node %p\n", node));
127 return_ACPI_STATUS(AE_AML_NO_OPERAND); 126 return_ACPI_STATUS(AE_AML_NO_OPERAND);
128 } 127 }
129 128
@@ -135,10 +134,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
135 case ACPI_TYPE_PACKAGE: 134 case ACPI_TYPE_PACKAGE:
136 135
137 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { 136 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) {
138 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 137 ACPI_ERROR((AE_INFO, "Object not a Package, type %s",
139 "Object not a Package, type %s\n", 138 acpi_ut_get_object_type_name(source_desc)));
140 acpi_ut_get_object_type_name
141 (source_desc)));
142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 139 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
143 } 140 }
144 141
@@ -154,10 +151,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
154 case ACPI_TYPE_BUFFER: 151 case ACPI_TYPE_BUFFER:
155 152
156 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { 153 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
157 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 154 ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s",
158 "Object not a Buffer, type %s\n", 155 acpi_ut_get_object_type_name(source_desc)));
159 acpi_ut_get_object_type_name
160 (source_desc)));
161 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 156 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
162 } 157 }
163 158
@@ -173,10 +168,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
173 case ACPI_TYPE_STRING: 168 case ACPI_TYPE_STRING:
174 169
175 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { 170 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) {
176 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 171 ACPI_ERROR((AE_INFO, "Object not a String, type %s",
177 "Object not a String, type %s\n", 172 acpi_ut_get_object_type_name(source_desc)));
178 acpi_ut_get_object_type_name
179 (source_desc)));
180 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 173 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
181 } 174 }
182 175
@@ -189,10 +182,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
189 case ACPI_TYPE_INTEGER: 182 case ACPI_TYPE_INTEGER:
190 183
191 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { 184 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) {
192 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 185 ACPI_ERROR((AE_INFO, "Object not a Integer, type %s",
193 "Object not a Integer, type %s\n", 186 acpi_ut_get_object_type_name(source_desc)));
194 acpi_ut_get_object_type_name
195 (source_desc)));
196 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 187 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
197 } 188 }
198 189
@@ -236,9 +227,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
236 227
237 case ACPI_TYPE_ANY: 228 case ACPI_TYPE_ANY:
238 229
239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 230 ACPI_ERROR((AE_INFO,
240 "Untyped entry %p, no attached object!\n", 231 "Untyped entry %p, no attached object!", node));
241 node));
242 232
243 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ 233 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
244 234
@@ -257,12 +247,11 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
257 default: 247 default:
258 /* No named references are allowed here */ 248 /* No named references are allowed here */
259 249
260 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 250 ACPI_ERROR((AE_INFO,
261 "Unsupported Reference opcode %X (%s)\n", 251 "Unsupported Reference opcode %X (%s)",
262 source_desc->reference.opcode, 252 source_desc->reference.opcode,
263 acpi_ps_get_opcode_name(source_desc-> 253 acpi_ps_get_opcode_name(source_desc->
264 reference. 254 reference.opcode)));
265 opcode)));
266 255
267 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 256 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
268 } 257 }
@@ -272,9 +261,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
272 261
273 /* Default case is for unknown types */ 262 /* Default case is for unknown types */
274 263
275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 264 ACPI_ERROR((AE_INFO,
276 "Node %p - Unknown object type %X\n", 265 "Node %p - Unknown object type %X",
277 node, entry_type)); 266 node, entry_type));
278 267
279 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 268 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
280 269
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
index 97eecbd3242d..1deed492fe88 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/executer/exresolv.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -81,7 +81,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
81 ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr); 81 ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr);
82 82
83 if (!stack_ptr || !*stack_ptr) { 83 if (!stack_ptr || !*stack_ptr) {
84 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Internal - null pointer\n")); 84 ACPI_ERROR((AE_INFO, "Internal - null pointer"));
85 return_ACPI_STATUS(AE_AML_NO_OPERAND); 85 return_ACPI_STATUS(AE_AML_NO_OPERAND);
86 } 86 }
87 87
@@ -97,8 +97,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
97 } 97 }
98 98
99 if (!*stack_ptr) { 99 if (!*stack_ptr) {
100 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 100 ACPI_ERROR((AE_INFO, "Internal - null pointer"));
101 "Internal - null pointer\n"));
102 return_ACPI_STATUS(AE_AML_NO_OPERAND); 101 return_ACPI_STATUS(AE_AML_NO_OPERAND);
103 } 102 }
104 } 103 }
@@ -228,9 +227,9 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
228 * A NULL object descriptor means an unitialized element of 227 * A NULL object descriptor means an unitialized element of
229 * the package, can't dereference it 228 * the package, can't dereference it
230 */ 229 */
231 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 230 ACPI_ERROR((AE_INFO,
232 "Attempt to deref an Index to NULL pkg element Idx=%p\n", 231 "Attempt to deref an Index to NULL pkg element Idx=%p",
233 stack_desc)); 232 stack_desc));
234 status = AE_AML_UNINITIALIZED_ELEMENT; 233 status = AE_AML_UNINITIALIZED_ELEMENT;
235 } 234 }
236 break; 235 break;
@@ -239,7 +238,10 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
239 238
240 /* Invalid reference object */ 239 /* Invalid reference object */
241 240
242 ACPI_REPORT_ERROR(("During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); 241 ACPI_ERROR((AE_INFO,
242 "Unknown target_type %X in Index/Reference obj %p",
243 stack_desc->reference.target_type,
244 stack_desc));
243 status = AE_AML_INTERNAL; 245 status = AE_AML_INTERNAL;
244 break; 246 break;
245 } 247 }
@@ -264,7 +266,10 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
264 266
265 default: 267 default:
266 268
267 ACPI_REPORT_ERROR(("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc)); 269 ACPI_ERROR((AE_INFO,
270 "Unknown Reference opcode %X (%s) in %p",
271 opcode, acpi_ps_get_opcode_name(opcode),
272 stack_desc));
268 status = AE_AML_INTERNAL; 273 status = AE_AML_INTERNAL;
269 break; 274 break;
270 } 275 }
@@ -386,7 +391,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
386 391
387 if (ACPI_GET_DESCRIPTOR_TYPE(node) != 392 if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
388 ACPI_DESC_TYPE_NAMED) { 393 ACPI_DESC_TYPE_NAMED) {
389 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); 394 ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]",
395 node,
396 acpi_ut_get_descriptor_name(node)));
390 return_ACPI_STATUS(AE_AML_INTERNAL); 397 return_ACPI_STATUS(AE_AML_INTERNAL);
391 } 398 }
392 399
@@ -442,7 +449,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
442 449
443 if (ACPI_GET_DESCRIPTOR_TYPE(node) != 450 if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
444 ACPI_DESC_TYPE_NAMED) { 451 ACPI_DESC_TYPE_NAMED) {
445 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); 452 ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]",
453 node,
454 acpi_ut_get_descriptor_name(node)));
446 return_ACPI_STATUS(AE_AML_INTERNAL); 455 return_ACPI_STATUS(AE_AML_INTERNAL);
447 } 456 }
448 457
@@ -511,7 +520,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
511 520
512 default: 521 default:
513 522
514 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", obj_desc->reference.opcode)); 523 ACPI_ERROR((AE_INFO,
524 "Unknown Reference subtype %X",
525 obj_desc->reference.opcode));
515 return_ACPI_STATUS(AE_AML_INTERNAL); 526 return_ACPI_STATUS(AE_AML_INTERNAL);
516 } 527 }
517 } 528 }
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index ff064e79ab90..a1c000f5a415 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,7 @@
46#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
47#include <acpi/acparser.h> 47#include <acpi/acparser.h>
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h>
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exresop") 52ACPI_MODULE_NAME("exresop")
@@ -73,7 +74,7 @@ static acpi_status
73acpi_ex_check_object_type(acpi_object_type type_needed, 74acpi_ex_check_object_type(acpi_object_type type_needed,
74 acpi_object_type this_type, void *object) 75 acpi_object_type this_type, void *object)
75{ 76{
76 ACPI_FUNCTION_NAME("ex_check_object_type"); 77 ACPI_FUNCTION_ENTRY();
77 78
78 if (type_needed == ACPI_TYPE_ANY) { 79 if (type_needed == ACPI_TYPE_ANY) {
79 /* All types OK, so we don't perform any typechecks */ 80 /* All types OK, so we don't perform any typechecks */
@@ -95,10 +96,10 @@ acpi_ex_check_object_type(acpi_object_type type_needed,
95 } 96 }
96 97
97 if (type_needed != this_type) { 98 if (type_needed != this_type) {
98 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 99 ACPI_ERROR((AE_INFO,
99 "Needed [%s], found [%s] %p\n", 100 "Needed type [%s], found [%s] %p",
100 acpi_ut_get_type_name(type_needed), 101 acpi_ut_get_type_name(type_needed),
101 acpi_ut_get_type_name(this_type), object)); 102 acpi_ut_get_type_name(this_type), object));
102 103
103 return (AE_AML_OPERAND_TYPE); 104 return (AE_AML_OPERAND_TYPE);
104 } 105 }
@@ -151,13 +152,13 @@ acpi_ex_resolve_operands(u16 opcode,
151 152
152 arg_types = op_info->runtime_args; 153 arg_types = op_info->runtime_args;
153 if (arg_types == ARGI_INVALID_OPCODE) { 154 if (arg_types == ARGI_INVALID_OPCODE) {
154 ACPI_REPORT_ERROR(("resolve_operands: %X is not a valid AML opcode\n", opcode)); 155 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", opcode));
155 156
156 return_ACPI_STATUS(AE_AML_INTERNAL); 157 return_ACPI_STATUS(AE_AML_INTERNAL);
157 } 158 }
158 159
159 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 160 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
160 "Opcode %X [%s] required_operand_types=%8.8X \n", 161 "Opcode %X [%s] required_operand_types=%8.8X\n",
161 opcode, op_info->name, arg_types)); 162 opcode, op_info->name, arg_types));
162 163
163 /* 164 /*
@@ -169,7 +170,8 @@ acpi_ex_resolve_operands(u16 opcode,
169 */ 170 */
170 while (GET_CURRENT_ARG_TYPE(arg_types)) { 171 while (GET_CURRENT_ARG_TYPE(arg_types)) {
171 if (!stack_ptr || !*stack_ptr) { 172 if (!stack_ptr || !*stack_ptr) {
172 ACPI_REPORT_ERROR(("resolve_operands: Null stack entry at %p\n", stack_ptr)); 173 ACPI_ERROR((AE_INFO, "Null stack entry at %p",
174 stack_ptr));
173 175
174 return_ACPI_STATUS(AE_AML_INTERNAL); 176 return_ACPI_STATUS(AE_AML_INTERNAL);
175 } 177 }
@@ -187,6 +189,22 @@ acpi_ex_resolve_operands(u16 opcode,
187 189
188 object_type = 190 object_type =
189 ((struct acpi_namespace_node *)obj_desc)->type; 191 ((struct acpi_namespace_node *)obj_desc)->type;
192
193 /*
194 * Resolve an alias object. The construction of these objects
195 * guarantees that there is only one level of alias indirection;
196 * thus, the attached object is always the aliased namespace node
197 */
198 if (object_type == ACPI_TYPE_LOCAL_ALIAS) {
199 obj_desc =
200 acpi_ns_get_attached_object((struct
201 acpi_namespace_node
202 *)obj_desc);
203 *stack_ptr = obj_desc;
204 object_type =
205 ((struct acpi_namespace_node *)obj_desc)->
206 type;
207 }
190 break; 208 break;
191 209
192 case ACPI_DESC_TYPE_OPERAND: 210 case ACPI_DESC_TYPE_OPERAND:
@@ -198,9 +216,9 @@ acpi_ex_resolve_operands(u16 opcode,
198 /* Check for bad acpi_object_type */ 216 /* Check for bad acpi_object_type */
199 217
200 if (!acpi_ut_valid_object_type(object_type)) { 218 if (!acpi_ut_valid_object_type(object_type)) {
201 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_ERROR((AE_INFO,
202 "Bad operand object type [%X]\n", 220 "Bad operand object type [%X]",
203 object_type)); 221 object_type));
204 222
205 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 223 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
206 } 224 }
@@ -238,13 +256,10 @@ acpi_ex_resolve_operands(u16 opcode,
238 break; 256 break;
239 257
240 default: 258 default:
241 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 259 ACPI_ERROR((AE_INFO,
242 "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", 260 "Operand is a Reference, Unknown Reference Opcode: %X",
243 obj_desc->reference. 261 obj_desc->reference.
244 opcode, 262 opcode));
245 (acpi_ps_get_opcode_info
246 (obj_desc->reference.
247 opcode))->name));
248 263
249 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
250 } 265 }
@@ -255,11 +270,10 @@ acpi_ex_resolve_operands(u16 opcode,
255 270
256 /* Invalid descriptor */ 271 /* Invalid descriptor */
257 272
258 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 273 ACPI_ERROR((AE_INFO,
259 "Invalid descriptor %p [%s]\n", 274 "Invalid descriptor %p [%s]",
260 obj_desc, 275 obj_desc,
261 acpi_ut_get_descriptor_name 276 acpi_ut_get_descriptor_name(obj_desc)));
262 (obj_desc)));
263 277
264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 278 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
265 } 279 }
@@ -417,11 +431,10 @@ acpi_ex_resolve_operands(u16 opcode,
417 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); 431 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
418 if (ACPI_FAILURE(status)) { 432 if (ACPI_FAILURE(status)) {
419 if (status == AE_TYPE) { 433 if (status == AE_TYPE) {
420 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 434 ACPI_ERROR((AE_INFO,
421 "Needed [Integer/String/Buffer], found [%s] %p\n", 435 "Needed [Integer/String/Buffer], found [%s] %p",
422 acpi_ut_get_object_type_name 436 acpi_ut_get_object_type_name
423 (obj_desc), 437 (obj_desc), obj_desc));
424 obj_desc));
425 438
426 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 439 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
427 } 440 }
@@ -444,11 +457,10 @@ acpi_ex_resolve_operands(u16 opcode,
444 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); 457 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
445 if (ACPI_FAILURE(status)) { 458 if (ACPI_FAILURE(status)) {
446 if (status == AE_TYPE) { 459 if (status == AE_TYPE) {
447 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 460 ACPI_ERROR((AE_INFO,
448 "Needed [Integer/String/Buffer], found [%s] %p\n", 461 "Needed [Integer/String/Buffer], found [%s] %p",
449 acpi_ut_get_object_type_name 462 acpi_ut_get_object_type_name
450 (obj_desc), 463 (obj_desc), obj_desc));
451 obj_desc));
452 464
453 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 465 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
454 } 466 }
@@ -472,11 +484,10 @@ acpi_ex_resolve_operands(u16 opcode,
472 ACPI_IMPLICIT_CONVERT_HEX); 484 ACPI_IMPLICIT_CONVERT_HEX);
473 if (ACPI_FAILURE(status)) { 485 if (ACPI_FAILURE(status)) {
474 if (status == AE_TYPE) { 486 if (status == AE_TYPE) {
475 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 487 ACPI_ERROR((AE_INFO,
476 "Needed [Integer/String/Buffer], found [%s] %p\n", 488 "Needed [Integer/String/Buffer], found [%s] %p",
477 acpi_ut_get_object_type_name 489 acpi_ut_get_object_type_name
478 (obj_desc), 490 (obj_desc), obj_desc));
479 obj_desc));
480 491
481 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 492 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
482 } 493 }
@@ -502,10 +513,10 @@ acpi_ex_resolve_operands(u16 opcode,
502 break; 513 break;
503 514
504 default: 515 default:
505 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 516 ACPI_ERROR((AE_INFO,
506 "Needed [Integer/String/Buffer], found [%s] %p\n", 517 "Needed [Integer/String/Buffer], found [%s] %p",
507 acpi_ut_get_object_type_name 518 acpi_ut_get_object_type_name
508 (obj_desc), obj_desc)); 519 (obj_desc), obj_desc));
509 520
510 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 521 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
511 } 522 }
@@ -539,10 +550,10 @@ acpi_ex_resolve_operands(u16 opcode,
539 break; 550 break;
540 551
541 default: 552 default:
542 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 553 ACPI_ERROR((AE_INFO,
543 "Needed [Integer/String/Buffer], found [%s] %p\n", 554 "Needed [Integer/String/Buffer], found [%s] %p",
544 acpi_ut_get_object_type_name 555 acpi_ut_get_object_type_name
545 (obj_desc), obj_desc)); 556 (obj_desc), obj_desc));
546 557
547 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 558 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
548 } 559 }
@@ -566,10 +577,10 @@ acpi_ex_resolve_operands(u16 opcode,
566 break; 577 break;
567 578
568 default: 579 default:
569 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 580 ACPI_ERROR((AE_INFO,
570 "Needed [Buffer/String/Package/Reference], found [%s] %p\n", 581 "Needed [Buffer/String/Package/Reference], found [%s] %p",
571 acpi_ut_get_object_type_name 582 acpi_ut_get_object_type_name
572 (obj_desc), obj_desc)); 583 (obj_desc), obj_desc));
573 584
574 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 585 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
575 } 586 }
@@ -588,10 +599,10 @@ acpi_ex_resolve_operands(u16 opcode,
588 break; 599 break;
589 600
590 default: 601 default:
591 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 602 ACPI_ERROR((AE_INFO,
592 "Needed [Buffer/String/Package], found [%s] %p\n", 603 "Needed [Buffer/String/Package], found [%s] %p",
593 acpi_ut_get_object_type_name 604 acpi_ut_get_object_type_name
594 (obj_desc), obj_desc)); 605 (obj_desc), obj_desc));
595 606
596 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 607 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
597 } 608 }
@@ -611,10 +622,10 @@ acpi_ex_resolve_operands(u16 opcode,
611 break; 622 break;
612 623
613 default: 624 default:
614 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 625 ACPI_ERROR((AE_INFO,
615 "Needed [Region/region_field], found [%s] %p\n", 626 "Needed [Region/region_field], found [%s] %p",
616 acpi_ut_get_object_type_name 627 acpi_ut_get_object_type_name
617 (obj_desc), obj_desc)); 628 (obj_desc), obj_desc));
618 629
619 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 630 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
620 } 631 }
@@ -656,10 +667,10 @@ acpi_ex_resolve_operands(u16 opcode,
656 break; 667 break;
657 } 668 }
658 669
659 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 670 ACPI_ERROR((AE_INFO,
660 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", 671 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
661 acpi_ut_get_object_type_name 672 acpi_ut_get_object_type_name
662 (obj_desc), obj_desc)); 673 (obj_desc), obj_desc));
663 674
664 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 675 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
665 } 676 }
@@ -669,9 +680,9 @@ acpi_ex_resolve_operands(u16 opcode,
669 680
670 /* Unknown type */ 681 /* Unknown type */
671 682
672 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 683 ACPI_ERROR((AE_INFO,
673 "Internal - Unknown ARGI (required operand) type %X\n", 684 "Internal - Unknown ARGI (required operand) type %X",
674 this_arg_type)); 685 this_arg_type));
675 686
676 return_ACPI_STATUS(AE_BAD_PARAMETER); 687 return_ACPI_STATUS(AE_BAD_PARAMETER);
677 } 688 }
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index a7d8eea305c2..3f020c0e2b95 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -250,7 +250,7 @@ acpi_ex_store(union acpi_operand_object *source_desc,
250 /* Validate parameters */ 250 /* Validate parameters */
251 251
252 if (!source_desc || !dest_desc) { 252 if (!source_desc || !dest_desc) {
253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null parameter\n")); 253 ACPI_ERROR((AE_INFO, "Null parameter"));
254 return_ACPI_STATUS(AE_AML_NO_OPERAND); 254 return_ACPI_STATUS(AE_AML_NO_OPERAND);
255 } 255 }
256 256
@@ -290,10 +290,10 @@ acpi_ex_store(union acpi_operand_object *source_desc,
290 290
291 /* Destination is not a Reference object */ 291 /* Destination is not a Reference object */
292 292
293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 293 ACPI_ERROR((AE_INFO,
294 "Target is not a Reference or Constant object - %s [%p]\n", 294 "Target is not a Reference or Constant object - %s [%p]",
295 acpi_ut_get_object_type_name(dest_desc), 295 acpi_ut_get_object_type_name(dest_desc),
296 dest_desc)); 296 dest_desc));
297 297
298 ACPI_DUMP_STACK_ENTRY(source_desc); 298 ACPI_DUMP_STACK_ENTRY(source_desc);
299 ACPI_DUMP_STACK_ENTRY(dest_desc); 299 ACPI_DUMP_STACK_ENTRY(dest_desc);
@@ -360,8 +360,8 @@ acpi_ex_store(union acpi_operand_object *source_desc,
360 360
361 default: 361 default:
362 362
363 ACPI_REPORT_ERROR(("ex_store: Unknown Reference opcode %X\n", 363 ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
364 ref_desc->reference.opcode)); 364 ref_desc->reference.opcode));
365 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); 365 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR);
366 366
367 status = AE_AML_INTERNAL; 367 status = AE_AML_INTERNAL;
@@ -490,10 +490,9 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
490 490
491 /* All other types are invalid */ 491 /* All other types are invalid */
492 492
493 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 493 ACPI_ERROR((AE_INFO,
494 "Source must be Integer/Buffer/String type, not %s\n", 494 "Source must be Integer/Buffer/String type, not %s",
495 acpi_ut_get_object_type_name 495 acpi_ut_get_object_type_name(source_desc)));
496 (source_desc)));
497 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 496 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
498 } 497 }
499 498
@@ -503,8 +502,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
503 break; 502 break;
504 503
505 default: 504 default:
506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 505 ACPI_ERROR((AE_INFO,
507 "Target is not a Package or buffer_field\n")); 506 "Target is not a Package or buffer_field"));
508 status = AE_AML_OPERAND_TYPE; 507 status = AE_AML_OPERAND_TYPE;
509 break; 508 break;
510 } 509 }
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index 382f63c14ea1..42967baf760d 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2005, R. Byron Moore 10 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -123,11 +123,10 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
123 && (source_desc->reference.opcode == AML_LOAD_OP))) { 123 && (source_desc->reference.opcode == AML_LOAD_OP))) {
124 /* Conversion successful but still not a valid type */ 124 /* Conversion successful but still not a valid type */
125 125
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_ERROR((AE_INFO,
127 "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", 127 "Cannot assign type %s to %s (must be type Int/Str/Buf)",
128 acpi_ut_get_object_type_name 128 acpi_ut_get_object_type_name(source_desc),
129 (source_desc), 129 acpi_ut_get_type_name(target_type)));
130 acpi_ut_get_type_name(target_type)));
131 status = AE_AML_OPERAND_TYPE; 130 status = AE_AML_OPERAND_TYPE;
132 } 131 }
133 break; 132 break;
@@ -135,9 +134,11 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
135 case ACPI_TYPE_LOCAL_ALIAS: 134 case ACPI_TYPE_LOCAL_ALIAS:
136 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 135 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
137 136
138 /* Aliases are resolved by acpi_ex_prep_operands */ 137 /*
139 138 * All aliases should have been resolved earlier, during the
140 ACPI_REPORT_ERROR(("Store into Alias - should never happen\n")); 139 * operand resolution phase.
140 */
141 ACPI_ERROR((AE_INFO, "Store into an unresolved Alias object"));
141 status = AE_AML_INTERNAL; 142 status = AE_AML_INTERNAL;
142 break; 143 break;
143 144
@@ -280,9 +281,8 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
280 /* 281 /*
281 * All other types come here. 282 * All other types come here.
282 */ 283 */
283 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 284 ACPI_WARNING((AE_INFO, "Store into type %s not implemented",
284 "Store into type %s not implemented\n", 285 acpi_ut_get_object_type_name(dest_desc)));
285 acpi_ut_get_object_type_name(dest_desc)));
286 286
287 status = AE_NOT_IMPLEMENTED; 287 status = AE_NOT_IMPLEMENTED;
288 break; 288 break;
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c
index c4ff654a6697..6ab707087750 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/executer/exstorob.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -71,7 +71,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
71 71
72 /* We know that source_desc is a buffer by now */ 72 /* We know that source_desc is a buffer by now */
73 73
74 buffer = (u8 *) source_desc->buffer.pointer; 74 buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer);
75 length = source_desc->buffer.length; 75 length = source_desc->buffer.length;
76 76
77 /* 77 /*
@@ -160,7 +160,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
160 160
161 /* We know that source_desc is a string by now */ 161 /* We know that source_desc is a string by now */
162 162
163 buffer = (u8 *) source_desc->string.pointer; 163 buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer);
164 length = source_desc->string.length; 164 length = source_desc->string.length;
165 165
166 /* 166 /*
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index 8a88b841237d..ea9144f42e1f 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -129,8 +129,8 @@ acpi_status acpi_ex_system_do_stall(u32 how_long)
129 * (ACPI specifies 100 usec as max, but this gives some slack in 129 * (ACPI specifies 100 usec as max, but this gives some slack in
130 * order to support existing BIOSs) 130 * order to support existing BIOSs)
131 */ 131 */
132 ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n", 132 ACPI_ERROR((AE_INFO, "Time parameter is too large (%d)",
133 how_long)); 133 how_long));
134 status = AE_AML_OPERAND_VALUE; 134 status = AE_AML_OPERAND_VALUE;
135 } else { 135 } else {
136 acpi_os_stall(how_long); 136 acpi_os_stall(how_long);
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 1ee79d8c8f88..f73a61aeb7ec 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -91,7 +91,7 @@ acpi_status acpi_ex_enter_interpreter(void)
91 91
92 status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE); 92 status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE);
93 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
94 ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n")); 94 ACPI_ERROR((AE_INFO, "Could not acquire interpreter mutex"));
95 } 95 }
96 96
97 return_ACPI_STATUS(status); 97 return_ACPI_STATUS(status);
@@ -127,7 +127,7 @@ void acpi_ex_exit_interpreter(void)
127 127
128 status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE); 128 status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE);
129 if (ACPI_FAILURE(status)) { 129 if (ACPI_FAILURE(status)) {
130 ACPI_REPORT_ERROR(("Could not release interpreter mutex\n")); 130 ACPI_ERROR((AE_INFO, "Could not release interpreter mutex"));
131 } 131 }
132 132
133 return_VOID; 133 return_VOID;
@@ -200,13 +200,12 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags)
200 if (ACPI_SUCCESS(status)) { 200 if (ACPI_SUCCESS(status)) {
201 locked = TRUE; 201 locked = TRUE;
202 } else { 202 } else {
203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 203 ACPI_EXCEPTION((AE_INFO, status,
204 "Could not acquire Global Lock, %s\n", 204 "Could not acquire Global Lock"));
205 acpi_format_exception(status)));
206 } 205 }
207 } 206 }
208 207
209 return_VALUE(locked); 208 return_UINT8(locked);
210} 209}
211 210
212/******************************************************************************* 211/*******************************************************************************
@@ -237,7 +236,8 @@ void acpi_ex_release_global_lock(u8 locked_by_me)
237 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
238 /* Report the error, but there isn't much else we can do */ 237 /* Report the error, but there isn't much else we can do */
239 238
240 ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status))); 239 ACPI_EXCEPTION((AE_INFO, status,
240 "Could not release ACPI Global Lock"));
241 } 241 }
242 } 242 }
243 243
@@ -268,7 +268,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */
269 269
270 if (value == 0) { 270 if (value == 0) {
271 return_VALUE(1); 271 return_UINT32(1);
272 } 272 }
273 273
274 current_value = value; 274 current_value = value;
@@ -282,7 +282,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
282 num_digits++; 282 num_digits++;
283 } 283 }
284 284
285 return_VALUE(num_digits); 285 return_UINT32(num_digits);
286} 286}
287 287
288/******************************************************************************* 288/*******************************************************************************
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index aa993715d644..8daef57b994c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -99,15 +99,15 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
99 unsigned long *busnr = (unsigned long *)data; 99 unsigned long *busnr = (unsigned long *)data;
100 struct acpi_resource_address64 address; 100 struct acpi_resource_address64 address;
101 101
102 if (resource->id != ACPI_RSTYPE_ADDRESS16 && 102 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
103 resource->id != ACPI_RSTYPE_ADDRESS32 && 103 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
104 resource->id != ACPI_RSTYPE_ADDRESS64) 104 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
105 return AE_OK; 105 return AE_OK;
106 106
107 acpi_resource_to_address64(resource, &address); 107 acpi_resource_to_address64(resource, &address);
108 if ((address.address_length > 0) && 108 if ((address.address_length > 0) &&
109 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 109 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
110 *busnr = address.min_address_range; 110 *busnr = address.minimum;
111 111
112 return AE_OK; 112 return AE_OK;
113} 113}
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index 1bb3463d7040..ea2f13271ff1 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -68,8 +68,7 @@ acpi_status acpi_hw_initialize(void)
68 /* We must have the ACPI tables by the time we get here */ 68 /* We must have the ACPI tables by the time we get here */
69 69
70 if (!acpi_gbl_FADT) { 70 if (!acpi_gbl_FADT) {
71 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No FADT is present\n")); 71 ACPI_ERROR((AE_INFO, "No FADT is present"));
72
73 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 72 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
74 } 73 }
75 74
@@ -108,7 +107,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
108 * system does not support mode transition. 107 * system does not support mode transition.
109 */ 108 */
110 if (!acpi_gbl_FADT->smi_cmd) { 109 if (!acpi_gbl_FADT->smi_cmd) {
111 ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed.\n")); 110 ACPI_ERROR((AE_INFO,
111 "No SMI_CMD in FADT, mode transition failed"));
112 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 112 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
113 } 113 }
114 114
@@ -120,7 +120,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
120 * transitions are not supported. 120 * transitions are not supported.
121 */ 121 */
122 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { 122 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
123 ACPI_REPORT_ERROR(("No ACPI mode transition supported in this system (enable/disable both zero)\n")); 123 ACPI_ERROR((AE_INFO,
124 "No ACPI mode transition supported in this system (enable/disable both zero)"));
124 return_ACPI_STATUS(AE_OK); 125 return_ACPI_STATUS(AE_OK);
125 } 126 }
126 127
@@ -154,8 +155,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
154 } 155 }
155 156
156 if (ACPI_FAILURE(status)) { 157 if (ACPI_FAILURE(status)) {
157 ACPI_REPORT_ERROR(("Could not write mode change, %s\n", 158 ACPI_EXCEPTION((AE_INFO, status,
158 acpi_format_exception(status))); 159 "Could not write ACPI mode change"));
159 return_ACPI_STATUS(status); 160 return_ACPI_STATUS(status);
160 } 161 }
161 162
@@ -175,7 +176,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
175 retry--; 176 retry--;
176 } 177 }
177 178
178 ACPI_REPORT_ERROR(("Hardware never changed modes\n")); 179 ACPI_ERROR((AE_INFO, "Hardware did not change modes"));
179 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 180 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
180} 181}
181 182
@@ -204,18 +205,18 @@ u32 acpi_hw_get_mode(void)
204 * system does not support mode transition. 205 * system does not support mode transition.
205 */ 206 */
206 if (!acpi_gbl_FADT->smi_cmd) { 207 if (!acpi_gbl_FADT->smi_cmd) {
207 return_VALUE(ACPI_SYS_MODE_ACPI); 208 return_UINT32(ACPI_SYS_MODE_ACPI);
208 } 209 }
209 210
210 status = 211 status =
211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); 212 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
212 if (ACPI_FAILURE(status)) { 213 if (ACPI_FAILURE(status)) {
213 return_VALUE(ACPI_SYS_MODE_LEGACY); 214 return_UINT32(ACPI_SYS_MODE_LEGACY);
214 } 215 }
215 216
216 if (value) { 217 if (value) {
217 return_VALUE(ACPI_SYS_MODE_ACPI); 218 return_UINT32(ACPI_SYS_MODE_ACPI);
218 } else { 219 } else {
219 return_VALUE(ACPI_SYS_MODE_LEGACY); 220 return_UINT32(ACPI_SYS_MODE_LEGACY);
220 } 221 }
221} 222}
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 5c8e5dfd024e..d84942d22dd5 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 536a7aea80c9..e1fe75498415 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2005, R. Byron Moore 10 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -144,7 +144,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
144 144
145 info.parameters = NULL; 145 info.parameters = NULL;
146 info.return_object = NULL; 146 info.return_object = NULL;
147 sleep_state_name = (char *)acpi_gbl_sleep_state_names[sleep_state]; 147 sleep_state_name =
148 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
148 149
149 status = acpi_ns_evaluate_by_name(sleep_state_name, &info); 150 status = acpi_ns_evaluate_by_name(sleep_state_name, &info);
150 if (ACPI_FAILURE(status)) { 151 if (ACPI_FAILURE(status)) {
@@ -159,15 +160,16 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
159 /* Must have a return object */ 160 /* Must have a return object */
160 161
161 if (!info.return_object) { 162 if (!info.return_object) {
162 ACPI_REPORT_ERROR(("No Sleep State object returned from [%s]\n", 163 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
163 sleep_state_name)); 164 sleep_state_name));
164 status = AE_NOT_EXIST; 165 status = AE_NOT_EXIST;
165 } 166 }
166 167
167 /* It must be of type Package */ 168 /* It must be of type Package */
168 169
169 else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) { 170 else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) {
170 ACPI_REPORT_ERROR(("Sleep State return object is not a Package\n")); 171 ACPI_ERROR((AE_INFO,
172 "Sleep State return object is not a Package"));
171 status = AE_AML_OPERAND_TYPE; 173 status = AE_AML_OPERAND_TYPE;
172 } 174 }
173 175
@@ -179,7 +181,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
179 * one per sleep type (A/B). 181 * one per sleep type (A/B).
180 */ 182 */
181 else if (info.return_object->package.count < 2) { 183 else if (info.return_object->package.count < 2) {
182 ACPI_REPORT_ERROR(("Sleep State return package does not have at least two elements\n")); 184 ACPI_ERROR((AE_INFO,
185 "Sleep State return package does not have at least two elements"));
183 status = AE_AML_NO_OPERAND; 186 status = AE_AML_NO_OPERAND;
184 } 187 }
185 188
@@ -189,7 +192,12 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
189 != ACPI_TYPE_INTEGER) || 192 != ACPI_TYPE_INTEGER) ||
190 (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1]) 193 (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1])
191 != ACPI_TYPE_INTEGER)) { 194 != ACPI_TYPE_INTEGER)) {
192 ACPI_REPORT_ERROR(("Sleep State return package elements are not both Integers (%s, %s)\n", acpi_ut_get_object_type_name(info.return_object->package.elements[0]), acpi_ut_get_object_type_name(info.return_object->package.elements[1]))); 195 ACPI_ERROR((AE_INFO,
196 "Sleep State return package elements are not both Integers (%s, %s)",
197 acpi_ut_get_object_type_name(info.return_object->
198 package.elements[0]),
199 acpi_ut_get_object_type_name(info.return_object->
200 package.elements[1])));
193 status = AE_AML_OPERAND_TYPE; 201 status = AE_AML_OPERAND_TYPE;
194 } else { 202 } else {
195 /* Valid _Sx_ package size, type, and value */ 203 /* Valid _Sx_ package size, type, and value */
@@ -201,12 +209,11 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
201 } 209 }
202 210
203 if (ACPI_FAILURE(status)) { 211 if (ACPI_FAILURE(status)) {
204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 212 ACPI_EXCEPTION((AE_INFO, status,
205 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", 213 "While evaluating sleep_state [%s], bad Sleep object %p type %s",
206 acpi_format_exception(status), 214 sleep_state_name, info.return_object,
207 sleep_state_name, info.return_object, 215 acpi_ut_get_object_type_name(info.
208 acpi_ut_get_object_type_name(info. 216 return_object)));
209 return_object)));
210 } 217 }
211 218
212 acpi_ut_remove_reference(info.return_object); 219 acpi_ut_remove_reference(info.return_object);
@@ -229,12 +236,11 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data);
229 236
230struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) 237struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
231{ 238{
232 ACPI_FUNCTION_NAME("hw_get_bit_register_info"); 239 ACPI_FUNCTION_ENTRY();
233 240
234 if (register_id > ACPI_BITREG_MAX) { 241 if (register_id > ACPI_BITREG_MAX) {
235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 242 ACPI_ERROR((AE_INFO, "Invalid bit_register ID: %X",
236 "Invalid bit_register ID: %X\n", 243 register_id));
237 register_id));
238 return (NULL); 244 return (NULL);
239 } 245 }
240 246
@@ -334,8 +340,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
334 340
335 bit_reg_info = acpi_hw_get_bit_register_info(register_id); 341 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
336 if (!bit_reg_info) { 342 if (!bit_reg_info) {
337 ACPI_REPORT_ERROR(("Bad ACPI HW register_id: %X\n", 343 ACPI_ERROR((AE_INFO, "Bad ACPI HW register_id: %X",
338 register_id)); 344 register_id));
339 return_ACPI_STATUS(AE_BAD_PARAMETER); 345 return_ACPI_STATUS(AE_BAD_PARAMETER);
340 } 346 }
341 347
@@ -569,8 +575,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
569 break; 575 break;
570 576
571 default: 577 default:
572 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown Register ID: %X\n", 578 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
573 register_id));
574 status = AE_BAD_PARAMETER; 579 status = AE_BAD_PARAMETER;
575 break; 580 break;
576 } 581 }
@@ -765,9 +770,9 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
765 break; 770 break;
766 771
767 default: 772 default:
768 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 773 ACPI_ERROR((AE_INFO,
769 "Unsupported address space: %X\n", 774 "Unsupported address space: %X",
770 reg->address_space_id)); 775 reg->address_space_id));
771 return (AE_BAD_PARAMETER); 776 return (AE_BAD_PARAMETER);
772 } 777 }
773 778
@@ -836,9 +841,9 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
836 break; 841 break;
837 842
838 default: 843 default:
839 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 844 ACPI_ERROR((AE_INFO,
840 "Unsupported address space: %X\n", 845 "Unsupported address space: %X",
841 reg->address_space_id)); 846 reg->address_space_id));
842 return (AE_BAD_PARAMETER); 847 return (AE_BAD_PARAMETER);
843 } 848 }
844 849
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 34519069050c..89269272fd62 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -199,8 +199,8 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
199 199
200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
202 ACPI_REPORT_ERROR(("Method _SST failed, %s\n", 202 ACPI_EXCEPTION((AE_INFO, status,
203 acpi_format_exception(status))); 203 "While executing method _SST"));
204 } 204 }
205 205
206 return_ACPI_STATUS(AE_OK); 206 return_ACPI_STATUS(AE_OK);
@@ -232,9 +232,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
232 232
233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
235 ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n", 235 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=%X B=%X",
236 acpi_gbl_sleep_type_a, 236 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
237 acpi_gbl_sleep_type_b));
238 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 237 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
239 } 238 }
240 239
@@ -533,21 +532,18 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
533 arg.integer.value = ACPI_SST_WAKING; 532 arg.integer.value = ACPI_SST_WAKING;
534 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 533 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
535 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 534 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
536 ACPI_REPORT_ERROR(("Method _SST failed, %s\n", 535 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
537 acpi_format_exception(status)));
538 } 536 }
539 537
540 arg.integer.value = sleep_state; 538 arg.integer.value = sleep_state;
541 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); 539 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
542 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 540 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
543 ACPI_REPORT_ERROR(("Method _BFS failed, %s\n", 541 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
544 acpi_format_exception(status)));
545 } 542 }
546 543
547 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); 544 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
548 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 545 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
549 ACPI_REPORT_ERROR(("Method _WAK failed, %s\n", 546 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
550 acpi_format_exception(status)));
551 } 547 }
552 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 548 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
553 549
@@ -582,8 +578,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
582 arg.integer.value = ACPI_SST_WORKING; 578 arg.integer.value = ACPI_SST_WORKING;
583 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 579 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
584 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 580 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
585 ACPI_REPORT_ERROR(("Method _SST failed, %s\n", 581 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
586 acpi_format_exception(status)));
587 } 582 }
588 583
589 return_ACPI_STATUS(status); 584 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
index aff6dc141784..fc10b7cb456f 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/hardware/hwtimer.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index e928e8c2c6ec..468244147ec1 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -54,36 +54,36 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
54 54
55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); 55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
56 56
57 if (res->id == ACPI_RSTYPE_IO) { 57 if (res->type == ACPI_RESOURCE_TYPE_IO) {
58 struct acpi_resource_io *io_res = &res->data.io; 58 struct acpi_resource_io *io_res = &res->data.io;
59 59
60 if (io_res->min_base_address != io_res->max_base_address) 60 if (io_res->minimum != io_res->maximum)
61 return_VALUE(AE_OK); 61 return_VALUE(AE_OK);
62 if (IS_RESERVED_ADDR 62 if (IS_RESERVED_ADDR
63 (io_res->min_base_address, io_res->range_length)) { 63 (io_res->minimum, io_res->address_length)) {
64 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 64 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
65 "Motherboard resources 0x%08x - 0x%08x\n", 65 "Motherboard resources 0x%08x - 0x%08x\n",
66 io_res->min_base_address, 66 io_res->minimum,
67 io_res->min_base_address + 67 io_res->minimum +
68 io_res->range_length)); 68 io_res->address_length));
69 requested_res = 69 requested_res =
70 request_region(io_res->min_base_address, 70 request_region(io_res->minimum,
71 io_res->range_length, "motherboard"); 71 io_res->address_length, "motherboard");
72 } 72 }
73 } else if (res->id == ACPI_RSTYPE_FIXED_IO) { 73 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) {
74 struct acpi_resource_fixed_io *fixed_io_res = 74 struct acpi_resource_fixed_io *fixed_io_res =
75 &res->data.fixed_io; 75 &res->data.fixed_io;
76 76
77 if (IS_RESERVED_ADDR 77 if (IS_RESERVED_ADDR
78 (fixed_io_res->base_address, fixed_io_res->range_length)) { 78 (fixed_io_res->address, fixed_io_res->address_length)) {
79 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
80 "Motherboard resources 0x%08x - 0x%08x\n", 80 "Motherboard resources 0x%08x - 0x%08x\n",
81 fixed_io_res->base_address, 81 fixed_io_res->address,
82 fixed_io_res->base_address + 82 fixed_io_res->address +
83 fixed_io_res->range_length)); 83 fixed_io_res->address_length));
84 requested_res = 84 requested_res =
85 request_region(fixed_io_res->base_address, 85 request_region(fixed_io_res->address,
86 fixed_io_res->range_length, 86 fixed_io_res->address_length,
87 "motherboard"); 87 "motherboard");
88 } 88 }
89 } else { 89 } else {
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index edfbe34600f5..1149bc18fb35 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -110,10 +110,9 @@ acpi_status acpi_ns_root_initialize(void)
110 ACPI_NS_NO_UPSEARCH, NULL, &new_node); 110 ACPI_NS_NO_UPSEARCH, NULL, &new_node);
111 111
112 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */ 112 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */
113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 113 ACPI_EXCEPTION((AE_INFO, status,
114 "Could not create predefined name %s, %s\n", 114 "Could not create predefined name %s",
115 init_val->name, 115 init_val->name));
116 acpi_format_exception(status)));
117 } 116 }
118 117
119 /* 118 /*
@@ -124,9 +123,9 @@ acpi_status acpi_ns_root_initialize(void)
124 if (init_val->val) { 123 if (init_val->val) {
125 status = acpi_os_predefined_override(init_val, &val); 124 status = acpi_os_predefined_override(init_val, &val);
126 if (ACPI_FAILURE(status)) { 125 if (ACPI_FAILURE(status)) {
127 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_ERROR((AE_INFO,
128 "Could not override predefined %s\n", 127 "Could not override predefined %s",
129 init_val->name)); 128 init_val->name));
130 } 129 }
131 130
132 if (!val) { 131 if (!val) {
@@ -233,7 +232,9 @@ acpi_status acpi_ns_root_initialize(void)
233 232
234 default: 233 default:
235 234
236 ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type)); 235 ACPI_ERROR((AE_INFO,
236 "Unsupported initial type value %X",
237 init_val->type));
237 acpi_ut_remove_reference(obj_desc); 238 acpi_ut_remove_reference(obj_desc);
238 obj_desc = NULL; 239 obj_desc = NULL;
239 continue; 240 continue;
@@ -339,7 +340,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
339 prefix_node = scope_info->scope.node; 340 prefix_node = scope_info->scope.node;
340 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) != 341 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
341 ACPI_DESC_TYPE_NAMED) { 342 ACPI_DESC_TYPE_NAMED) {
342 ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node))); 343 ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]",
344 prefix_node,
345 acpi_ut_get_descriptor_name(prefix_node)));
343 return_ACPI_STATUS(AE_AML_INTERNAL); 346 return_ACPI_STATUS(AE_AML_INTERNAL);
344 } 347 }
345 348
@@ -429,7 +432,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
429 if (!this_node) { 432 if (!this_node) {
430 /* Current scope has no parent scope */ 433 /* Current scope has no parent scope */
431 434
432 ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); 435 ACPI_ERROR((AE_INFO,
436 "ACPI path has too many parent prefixes (^) - reached beyond root node"));
433 return_ACPI_STATUS(AE_NOT_FOUND); 437 return_ACPI_STATUS(AE_NOT_FOUND);
434 } 438 }
435 } 439 }
@@ -498,7 +502,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
498 path++; 502 path++;
499 503
500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 504 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
501 "Multi Pathname (%d Segments, Flags=%X) \n", 505 "Multi Pathname (%d Segments, Flags=%X)\n",
502 num_segments, flags)); 506 num_segments, flags));
503 break; 507 break;
504 508
@@ -600,7 +604,12 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
600 (this_node->type != type_to_check_for)) { 604 (this_node->type != type_to_check_for)) {
601 /* Complain about a type mismatch */ 605 /* Complain about a type mismatch */
602 606
603 ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for))); 607 ACPI_WARNING((AE_INFO,
608 "ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)",
609 ACPI_CAST_PTR(char, &simple_name),
610 acpi_ut_get_type_name(this_node->type),
611 acpi_ut_get_type_name
612 (type_to_check_for)));
604 } 613 }
605 614
606 /* 615 /*
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index cc7a85f8cfe6..9b871f38b61b 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -272,9 +272,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
272 /* Grandchildren should have all been deleted already */ 272 /* Grandchildren should have all been deleted already */
273 273
274 if (child_node->child) { 274 if (child_node->child) {
275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 275 ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p",
276 "Found a grandchild! P=%p C=%p\n", 276 parent_node, child_node));
277 parent_node, child_node));
278 } 277 }
279 278
280 /* Now we can free this child object */ 279 /* Now we can free this child object */
@@ -302,7 +301,9 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
302 /* There should be only one reference remaining on this node */ 301 /* There should be only one reference remaining on this node */
303 302
304 if (child_node->reference_count != 1) { 303 if (child_node->reference_count != 1) {
305 ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node)); 304 ACPI_WARNING((AE_INFO,
305 "Existing references (%d) on node being deleted (%p)",
306 child_node->reference_count, child_node));
306 } 307 }
307 308
308 /* Now we can delete the node */ 309 /* Now we can delete the node */
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 9faf1d5c86ed..a2807317a84b 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -198,12 +198,13 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
198 /* Check the node type and name */ 198 /* Check the node type and name */
199 199
200 if (type > ACPI_TYPE_LOCAL_MAX) { 200 if (type > ACPI_TYPE_LOCAL_MAX) {
201 ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type)); 201 ACPI_WARNING((AE_INFO, "Invalid ACPI Object Type %08X",
202 type));
202 } 203 }
203 204
204 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { 205 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
205 ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n", 206 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
206 this_node->name.integer)); 207 this_node->name.integer));
207 } 208 }
208 209
209 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); 210 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
@@ -212,7 +213,9 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
212 /* 213 /*
213 * Now we can print out the pertinent information 214 * Now we can print out the pertinent information
214 */ 215 */
215 acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node); 216 acpi_os_printf(" %-12s %p %2.2X ",
217 acpi_ut_get_type_name(type), this_node,
218 this_node->owner_id);
216 219
217 dbg_level = acpi_dbg_level; 220 dbg_level = acpi_dbg_level;
218 acpi_dbg_level = 0; 221 acpi_dbg_level = 0;
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index 55de883943d6..aff899a935e3 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 0191c7d92824..19d7b94d40c3 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -373,8 +373,7 @@ acpi_ns_execute_control_method(struct acpi_parameter_info *info)
373 373
374 info->obj_desc = acpi_ns_get_attached_object(info->node); 374 info->obj_desc = acpi_ns_get_attached_object(info->node);
375 if (!info->obj_desc) { 375 if (!info->obj_desc) {
376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 376 ACPI_ERROR((AE_INFO, "No attached method object"));
377 "No attached method object\n"));
378 377
379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 378 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
380 return_ACPI_STATUS(AE_NULL_OBJECT); 379 return_ACPI_STATUS(AE_NULL_OBJECT);
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 0a08d2f04a06..9f929e479fd8 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -93,8 +93,7 @@ acpi_status acpi_ns_initialize_objects(void)
93 ACPI_UINT32_MAX, acpi_ns_init_one_object, 93 ACPI_UINT32_MAX, acpi_ns_init_one_object,
94 &info, NULL); 94 &info, NULL);
95 if (ACPI_FAILURE(status)) { 95 if (ACPI_FAILURE(status)) {
96 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 96 ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
97 acpi_format_exception(status)));
98 } 97 }
99 98
100 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 99 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
@@ -159,12 +158,11 @@ acpi_status acpi_ns_initialize_devices(void)
159 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 158 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
160 159
161 if (ACPI_FAILURE(status)) { 160 if (ACPI_FAILURE(status)) {
162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 161 ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
163 acpi_format_exception(status)));
164 } 162 }
165 163
166 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 164 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
167 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", 165 "\n%hd Devices found - executed %hd _STA, %hd _INI methods\n",
168 info.device_count, info.num_STA, info.num_INI)); 166 info.device_count, info.num_STA, info.num_INI));
169 167
170 return_ACPI_STATUS(status); 168 return_ACPI_STATUS(status);
@@ -289,12 +287,10 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
289 } 287 }
290 288
291 if (ACPI_FAILURE(status)) { 289 if (ACPI_FAILURE(status)) {
292 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n")); 290 ACPI_EXCEPTION((AE_INFO, status,
293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 291 "Could not execute arguments for [%4.4s] (%s)",
294 "Could not execute arguments for [%4.4s] (%s), %s\n", 292 acpi_ut_get_node_name(node),
295 acpi_ut_get_node_name(node), 293 acpi_ut_get_type_name(type)));
296 acpi_ut_get_type_name(type),
297 acpi_format_exception(status)));
298 } 294 }
299 295
300 /* 296 /*
@@ -336,23 +332,22 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
336 struct acpi_parameter_info pinfo; 332 struct acpi_parameter_info pinfo;
337 u32 flags; 333 u32 flags;
338 acpi_status status; 334 acpi_status status;
335 struct acpi_namespace_node *ini_node;
336 struct acpi_namespace_node *device_node;
339 337
340 ACPI_FUNCTION_TRACE("ns_init_one_device"); 338 ACPI_FUNCTION_TRACE("ns_init_one_device");
341 339
342 pinfo.parameters = NULL; 340 device_node = acpi_ns_map_handle_to_node(obj_handle);
343 pinfo.parameter_type = ACPI_PARAM_ARGS; 341 if (!device_node) {
344
345 pinfo.node = acpi_ns_map_handle_to_node(obj_handle);
346 if (!pinfo.node) {
347 return_ACPI_STATUS(AE_BAD_PARAMETER); 342 return_ACPI_STATUS(AE_BAD_PARAMETER);
348 } 343 }
349 344
350 /* 345 /*
351 * We will run _STA/_INI on Devices, Processors and thermal_zones only 346 * We will run _STA/_INI on Devices, Processors and thermal_zones only
352 */ 347 */
353 if ((pinfo.node->type != ACPI_TYPE_DEVICE) && 348 if ((device_node->type != ACPI_TYPE_DEVICE) &&
354 (pinfo.node->type != ACPI_TYPE_PROCESSOR) && 349 (device_node->type != ACPI_TYPE_PROCESSOR) &&
355 (pinfo.node->type != ACPI_TYPE_THERMAL)) { 350 (device_node->type != ACPI_TYPE_THERMAL)) {
356 return_ACPI_STATUS(AE_OK); 351 return_ACPI_STATUS(AE_OK);
357 } 352 }
358 353
@@ -364,57 +359,69 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
364 info->device_count++; 359 info->device_count++;
365 360
366 /* 361 /*
367 * Run _STA to determine if we can run _INI on the device. 362 * Check if the _INI method exists for this device -
363 * if _INI does not exist, there is no need to run _STA
364 * No _INI means device requires no initialization
365 */
366 status = acpi_ns_search_node(*ACPI_CAST_PTR(u32, METHOD_NAME__INI),
367 device_node, ACPI_TYPE_METHOD, &ini_node);
368 if (ACPI_FAILURE(status)) {
369 /* No _INI method found - move on to next device */
370
371 return_ACPI_STATUS(AE_OK);
372 }
373
374 /*
375 * Run _STA to determine if we can run _INI on the device -
376 * the device must be present before _INI can be run.
377 * However, _STA is not required - assume device present if no _STA
368 */ 378 */
369 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, 379 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
370 pinfo.node, 380 device_node,
371 METHOD_NAME__STA)); 381 METHOD_NAME__STA));
372 status = acpi_ut_execute_STA(pinfo.node, &flags);
373 382
383 pinfo.node = device_node;
384 pinfo.parameters = NULL;
385 pinfo.parameter_type = ACPI_PARAM_ARGS;
386
387 status = acpi_ut_execute_STA(pinfo.node, &flags);
374 if (ACPI_FAILURE(status)) { 388 if (ACPI_FAILURE(status)) {
375 if (pinfo.node->type == ACPI_TYPE_DEVICE) { 389 /* Ignore error and move on to next device */
376 /* Ignore error and move on to next device */
377 390
378 return_ACPI_STATUS(AE_OK); 391 return_ACPI_STATUS(AE_OK);
379 } 392 }
380 393
381 /* _STA is not required for Processor or thermal_zone objects */ 394 if (flags != ACPI_UINT32_MAX) {
382 } else {
383 info->num_STA++; 395 info->num_STA++;
396 }
384 397
385 if (!(flags & 0x01)) { 398 if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
386 /* Don't look at children of a not present device */ 399 /* Don't look at children of a not present device */
387 400
388 return_ACPI_STATUS(AE_CTRL_DEPTH); 401 return_ACPI_STATUS(AE_CTRL_DEPTH);
389 }
390 } 402 }
391 403
392 /* 404 /*
393 * The device is present. Run _INI. 405 * The device is present and _INI exists. Run the _INI method.
406 * (We already have the _INI node from above)
394 */ 407 */
395 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, 408 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
396 pinfo.node, 409 pinfo.node,
397 METHOD_NAME__INI)); 410 METHOD_NAME__INI));
398 status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo);
399 if (ACPI_FAILURE(status)) {
400 /* No _INI (AE_NOT_FOUND) means device requires no initialization */
401 411
402 if (status != AE_NOT_FOUND) { 412 pinfo.node = ini_node;
403 /* Ignore error and move on to next device */ 413 status = acpi_ns_evaluate_by_handle(&pinfo);
414 if (ACPI_FAILURE(status)) {
415 /* Ignore error and move on to next device */
404 416
405#ifdef ACPI_DEBUG_OUTPUT 417#ifdef ACPI_DEBUG_OUTPUT
406 char *scope_name = 418 char *scope_name = acpi_ns_get_external_pathname(ini_node);
407 acpi_ns_get_external_pathname(pinfo.node);
408 419
409 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", 420 ACPI_WARNING((AE_INFO, "%s._INI failed: %s",
410 scope_name, 421 scope_name, acpi_format_exception(status)));
411 acpi_format_exception(status)));
412 422
413 ACPI_MEM_FREE(scope_name); 423 ACPI_MEM_FREE(scope_name);
414#endif 424#endif
415 }
416
417 status = AE_OK;
418 } else { 425 } else {
419 /* Delete any return object (especially if implicit_return is enabled) */ 426 /* Delete any return object (especially if implicit_return is enabled) */
420 427
@@ -434,5 +441,5 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
434 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI); 441 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI);
435 } 442 }
436 443
437 return_ACPI_STATUS(status); 444 return_ACPI_STATUS(AE_OK);
438} 445}
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index c28849de465a..4e0b0524c188 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -92,7 +92,7 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
92 /* Check validity of the AML start and length */ 92 /* Check validity of the AML start and length */
93 93
94 if (!table_desc->aml_start) { 94 if (!table_desc->aml_start) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null AML pointer\n")); 95 ACPI_ERROR((AE_INFO, "Null AML pointer"));
96 return_ACPI_STATUS(AE_BAD_PARAMETER); 96 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 97 }
98 98
@@ -102,8 +102,8 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
102 /* Ignore table if there is no AML contained within */ 102 /* Ignore table if there is no AML contained within */
103 103
104 if (!table_desc->aml_length) { 104 if (!table_desc->aml_length) {
105 ACPI_REPORT_WARNING(("Zero-length AML block in table [%4.4s]\n", 105 ACPI_WARNING((AE_INFO, "Zero-length AML block in table [%4.4s]",
106 table_desc->pointer->signature)); 106 table_desc->pointer->signature));
107 return_ACPI_STATUS(AE_OK); 107 return_ACPI_STATUS(AE_OK);
108 } 108 }
109 109
@@ -263,7 +263,7 @@ acpi_status acpi_ns_load_namespace(void)
263 /* There must be at least a DSDT installed */ 263 /* There must be at least a DSDT installed */
264 264
265 if (acpi_gbl_DSDT == NULL) { 265 if (acpi_gbl_DSDT == NULL) {
266 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "DSDT is not in memory\n")); 266 ACPI_ERROR((AE_INFO, "DSDT is not in memory"));
267 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 267 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
268 } 268 }
269 269
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index d5e8dea61c27..639f653b4b6b 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,7 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
75 acpi_size index; 75 acpi_size index;
76 struct acpi_namespace_node *parent_node; 76 struct acpi_namespace_node *parent_node;
77 77
78 ACPI_FUNCTION_NAME("ns_build_external_path"); 78 ACPI_FUNCTION_ENTRY();
79 79
80 /* Special case for root */ 80 /* Special case for root */
81 81
@@ -110,9 +110,9 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
110 name_buffer[index] = AML_ROOT_PREFIX; 110 name_buffer[index] = AML_ROOT_PREFIX;
111 111
112 if (index != 0) { 112 if (index != 0) {
113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 113 ACPI_ERROR((AE_INFO,
114 "Could not construct pathname; index=%X, size=%X, Path=%s\n", 114 "Could not construct pathname; index=%X, size=%X, Path=%s",
115 (u32) index, (u32) size, &name_buffer[size])); 115 (u32) index, (u32) size, &name_buffer[size]));
116 } 116 }
117 117
118 return; 118 return;
@@ -148,7 +148,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
148 148
149 name_buffer = ACPI_MEM_CALLOCATE(size); 149 name_buffer = ACPI_MEM_CALLOCATE(size);
150 if (!name_buffer) { 150 if (!name_buffer) {
151 ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n")); 151 ACPI_ERROR((AE_INFO, "Allocation failure"));
152 return_PTR(NULL); 152 return_PTR(NULL);
153 } 153 }
154 154
@@ -241,7 +241,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
241 241
242 acpi_ns_build_external_path(node, required_size, buffer->pointer); 242 acpi_ns_build_external_path(node, required_size, buffer->pointer);
243 243
244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n", 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n",
245 (char *)buffer->pointer, (u32) required_size)); 245 (char *)buffer->pointer, (u32) required_size));
246 return_ACPI_STATUS(AE_OK); 246 return_ACPI_STATUS(AE_OK);
247} 247}
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index fc9be946ebed..10ae6292bca4 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -84,22 +84,23 @@ acpi_ns_attach_object(struct acpi_namespace_node *node,
84 if (!node) { 84 if (!node) {
85 /* Invalid handle */ 85 /* Invalid handle */
86 86
87 ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n")); 87 ACPI_ERROR((AE_INFO, "Null named_obj handle"));
88 return_ACPI_STATUS(AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
89 } 89 }
90 90
91 if (!object && (ACPI_TYPE_ANY != type)) { 91 if (!object && (ACPI_TYPE_ANY != type)) {
92 /* Null object */ 92 /* Null object */
93 93
94 ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); 94 ACPI_ERROR((AE_INFO,
95 "Null object, but type not ACPI_TYPE_ANY"));
95 return_ACPI_STATUS(AE_BAD_PARAMETER); 96 return_ACPI_STATUS(AE_BAD_PARAMETER);
96 } 97 }
97 98
98 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { 99 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
99 /* Not a name handle */ 100 /* Not a name handle */
100 101
101 ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n", 102 ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]",
102 node, acpi_ut_get_descriptor_name(node))); 103 node, acpi_ut_get_descriptor_name(node)));
103 return_ACPI_STATUS(AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
104 } 105 }
105 106
@@ -254,7 +255,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct
254 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node); 255 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node);
255 256
256 if (!node) { 257 if (!node) {
257 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n")); 258 ACPI_WARNING((AE_INFO, "Null Node ptr"));
258 return_PTR(NULL); 259 return_PTR(NULL);
259 } 260 }
260 261
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c
index 433442a9ec74..232be4303653 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/namespace/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 50a3ca5470ed..d64b78952f24 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -99,8 +99,8 @@ acpi_ns_search_node(u32 target_name,
99 if (scope_name) { 99 if (scope_name) {
100 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 100 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
101 "Searching %s (%p) For [%4.4s] (%s)\n", 101 "Searching %s (%p) For [%4.4s] (%s)\n",
102 scope_name, node, 102 scope_name, node, ACPI_CAST_PTR(char,
103 (char *)&target_name, 103 &target_name),
104 acpi_ut_get_type_name(type))); 104 acpi_ut_get_type_name(type)));
105 105
106 ACPI_MEM_FREE(scope_name); 106 ACPI_MEM_FREE(scope_name);
@@ -131,7 +131,7 @@ acpi_ns_search_node(u32 target_name,
131 */ 131 */
132 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 132 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
133 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", 133 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
134 (char *)&target_name, 134 ACPI_CAST_PTR(char, &target_name),
135 acpi_ut_get_type_name(next_node-> 135 acpi_ut_get_type_name(next_node->
136 type), 136 type),
137 next_node, 137 next_node,
@@ -160,7 +160,8 @@ acpi_ns_search_node(u32 target_name,
160 160
161 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 161 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
162 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", 162 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n",
163 (char *)&target_name, acpi_ut_get_type_name(type), 163 ACPI_CAST_PTR(char, &target_name),
164 acpi_ut_get_type_name(type),
164 acpi_ut_get_node_name(node), node, node->child)); 165 acpi_ut_get_node_name(node), node, node->child));
165 166
166 return_ACPI_STATUS(AE_NOT_FOUND); 167 return_ACPI_STATUS(AE_NOT_FOUND);
@@ -210,14 +211,14 @@ acpi_ns_search_parent_tree(u32 target_name,
210 */ 211 */
211 if (!parent_node) { 212 if (!parent_node) {
212 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n", 213 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
213 (char *)&target_name)); 214 ACPI_CAST_PTR(char, &target_name)));
214 return_ACPI_STATUS(AE_NOT_FOUND); 215 return_ACPI_STATUS(AE_NOT_FOUND);
215 } 216 }
216 217
217 if (acpi_ns_local(type)) { 218 if (acpi_ns_local(type)) {
218 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 219 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
219 "[%4.4s] type [%s] must be local to this scope (no parent search)\n", 220 "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
220 (char *)&target_name, 221 ACPI_CAST_PTR(char, &target_name),
221 acpi_ut_get_type_name(type))); 222 acpi_ut_get_type_name(type)));
222 return_ACPI_STATUS(AE_NOT_FOUND); 223 return_ACPI_STATUS(AE_NOT_FOUND);
223 } 224 }
@@ -227,7 +228,7 @@ acpi_ns_search_parent_tree(u32 target_name,
227 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 228 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
228 "Searching parent [%4.4s] for [%4.4s]\n", 229 "Searching parent [%4.4s] for [%4.4s]\n",
229 acpi_ut_get_node_name(parent_node), 230 acpi_ut_get_node_name(parent_node),
230 (char *)&target_name)); 231 ACPI_CAST_PTR(char, &target_name)));
231 232
232 /* 233 /*
233 * Search parents until target is found or we have backed up to the root 234 * Search parents until target is found or we have backed up to the root
@@ -297,18 +298,17 @@ acpi_ns_search_and_enter(u32 target_name,
297 /* Parameter validation */ 298 /* Parameter validation */
298 299
299 if (!node || !target_name || !return_node) { 300 if (!node || !target_name || !return_node) {
300 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 301 ACPI_ERROR((AE_INFO,
301 "Null param: Node %p Name %X return_node %p\n", 302 "Null param: Node %p Name %X return_node %p",
302 node, target_name, return_node)); 303 node, target_name, return_node));
303
304 ACPI_REPORT_ERROR(("ns_search_and_enter: Null parameter\n"));
305 return_ACPI_STATUS(AE_BAD_PARAMETER); 304 return_ACPI_STATUS(AE_BAD_PARAMETER);
306 } 305 }
307 306
308 /* Name must consist of printable characters */ 307 /* Name must consist of printable characters */
309 308
310 if (!acpi_ut_valid_acpi_name(target_name)) { 309 if (!acpi_ut_valid_acpi_name(target_name)) {
311 ACPI_REPORT_ERROR(("ns_search_and_enter: Bad character in ACPI Name: %X\n", target_name)); 310 ACPI_ERROR((AE_INFO, "Bad character in ACPI Name: %X",
311 target_name));
312 return_ACPI_STATUS(AE_BAD_CHARACTER); 312 return_ACPI_STATUS(AE_BAD_CHARACTER);
313 } 313 }
314 314
@@ -360,7 +360,7 @@ acpi_ns_search_and_enter(u32 target_name,
360 if (interpreter_mode == ACPI_IMODE_EXECUTE) { 360 if (interpreter_mode == ACPI_IMODE_EXECUTE) {
361 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 361 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
362 "%4.4s Not found in %p [Not adding]\n", 362 "%4.4s Not found in %p [Not adding]\n",
363 (char *)&target_name, node)); 363 ACPI_CAST_PTR(char, &target_name), node));
364 364
365 return_ACPI_STATUS(AE_NOT_FOUND); 365 return_ACPI_STATUS(AE_NOT_FOUND);
366 } 366 }
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index ebec036423c9..3e7cad549a38 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,6 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
63 * 63 *
64 * PARAMETERS: module_name - Caller's module name (for error output) 64 * PARAMETERS: module_name - Caller's module name (for error output)
65 * line_number - Caller's line number (for error output) 65 * line_number - Caller's line number (for error output)
66 * component_id - Caller's component ID (for error output)
67 * internal_name - Name or path of the namespace node 66 * internal_name - Name or path of the namespace node
68 * lookup_status - Exception code from NS lookup 67 * lookup_status - Exception code from NS lookup
69 * 68 *
@@ -76,19 +75,17 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
76void 75void
77acpi_ns_report_error(char *module_name, 76acpi_ns_report_error(char *module_name,
78 u32 line_number, 77 u32 line_number,
79 u32 component_id,
80 char *internal_name, acpi_status lookup_status) 78 char *internal_name, acpi_status lookup_status)
81{ 79{
82 acpi_status status; 80 acpi_status status;
83 char *name = NULL; 81 char *name = NULL;
84 82
85 acpi_os_printf("%8s-%04d: *** Error: Looking up ", 83 acpi_ut_report_error(module_name, line_number);
86 module_name, line_number);
87 84
88 if (lookup_status == AE_BAD_CHARACTER) { 85 if (lookup_status == AE_BAD_CHARACTER) {
89 /* There is a non-ascii character in the name */ 86 /* There is a non-ascii character in the name */
90 87
91 acpi_os_printf("[0x%4.4X] (NON-ASCII)\n", 88 acpi_os_printf("[0x%4.4X] (NON-ASCII)",
92 *(ACPI_CAST_PTR(u32, internal_name))); 89 *(ACPI_CAST_PTR(u32, internal_name)));
93 } else { 90 } else {
94 /* Convert path to external format */ 91 /* Convert path to external format */
@@ -109,7 +106,7 @@ acpi_ns_report_error(char *module_name,
109 } 106 }
110 } 107 }
111 108
112 acpi_os_printf(" in namespace, %s\n", 109 acpi_os_printf(" Namespace lookup failure, %s\n",
113 acpi_format_exception(lookup_status)); 110 acpi_format_exception(lookup_status));
114} 111}
115 112
@@ -119,10 +116,9 @@ acpi_ns_report_error(char *module_name,
119 * 116 *
120 * PARAMETERS: module_name - Caller's module name (for error output) 117 * PARAMETERS: module_name - Caller's module name (for error output)
121 * line_number - Caller's line number (for error output) 118 * line_number - Caller's line number (for error output)
122 * component_id - Caller's component ID (for error output)
123 * Message - Error message to use on failure 119 * Message - Error message to use on failure
124 * prefix_node - Prefix relative to the path 120 * prefix_node - Prefix relative to the path
125 * Path - Path to the node 121 * Path - Path to the node (optional)
126 * method_status - Execution status 122 * method_status - Execution status
127 * 123 *
128 * RETURN: None 124 * RETURN: None
@@ -134,7 +130,6 @@ acpi_ns_report_error(char *module_name,
134void 130void
135acpi_ns_report_method_error(char *module_name, 131acpi_ns_report_method_error(char *module_name,
136 u32 line_number, 132 u32 line_number,
137 u32 component_id,
138 char *message, 133 char *message,
139 struct acpi_namespace_node *prefix_node, 134 struct acpi_namespace_node *prefix_node,
140 char *path, acpi_status method_status) 135 char *path, acpi_status method_status)
@@ -142,17 +137,16 @@ acpi_ns_report_method_error(char *module_name,
142 acpi_status status; 137 acpi_status status;
143 struct acpi_namespace_node *node = prefix_node; 138 struct acpi_namespace_node *node = prefix_node;
144 139
140 acpi_ut_report_error(module_name, line_number);
141
145 if (path) { 142 if (path) {
146 status = acpi_ns_get_node_by_path(path, prefix_node, 143 status = acpi_ns_get_node_by_path(path, prefix_node,
147 ACPI_NS_NO_UPSEARCH, &node); 144 ACPI_NS_NO_UPSEARCH, &node);
148 if (ACPI_FAILURE(status)) { 145 if (ACPI_FAILURE(status)) {
149 acpi_os_printf 146 acpi_os_printf("[Could not get node by pathname]");
150 ("report_method_error: Could not get node\n");
151 return;
152 } 147 }
153 } 148 }
154 149
155 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
156 acpi_ns_print_node_pathname(node, message); 150 acpi_ns_print_node_pathname(node, message);
157 acpi_os_printf(", %s\n", acpi_format_exception(method_status)); 151 acpi_os_printf(", %s\n", acpi_format_exception(method_status));
158} 152}
@@ -248,11 +242,11 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
248 ACPI_FUNCTION_TRACE("ns_get_type"); 242 ACPI_FUNCTION_TRACE("ns_get_type");
249 243
250 if (!node) { 244 if (!node) {
251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); 245 ACPI_WARNING((AE_INFO, "Null Node parameter"));
252 return_VALUE(ACPI_TYPE_ANY); 246 return_UINT32(ACPI_TYPE_ANY);
253 } 247 }
254 248
255 return_VALUE((acpi_object_type) node->type); 249 return_UINT32((acpi_object_type) node->type);
256} 250}
257 251
258/******************************************************************************* 252/*******************************************************************************
@@ -275,11 +269,11 @@ u32 acpi_ns_local(acpi_object_type type)
275 if (!acpi_ut_valid_object_type(type)) { 269 if (!acpi_ut_valid_object_type(type)) {
276 /* Type code out of range */ 270 /* Type code out of range */
277 271
278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); 272 ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type));
279 return_VALUE(ACPI_NS_NORMAL); 273 return_UINT32(ACPI_NS_NORMAL);
280 } 274 }
281 275
282 return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 276 return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
283} 277}
284 278
285/******************************************************************************* 279/*******************************************************************************
@@ -627,7 +621,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
627 * with internal_name (invalid format). 621 * with internal_name (invalid format).
628 */ 622 */
629 if (required_length > internal_name_length) { 623 if (required_length > internal_name_length) {
630 ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n")); 624 ACPI_ERROR((AE_INFO, "Invalid internal name"));
631 return_ACPI_STATUS(AE_BAD_PATHNAME); 625 return_ACPI_STATUS(AE_BAD_PATHNAME);
632 } 626 }
633 627
@@ -803,12 +797,11 @@ u32 acpi_ns_opens_scope(acpi_object_type type)
803 if (!acpi_ut_valid_object_type(type)) { 797 if (!acpi_ut_valid_object_type(type)) {
804 /* type code out of range */ 798 /* type code out of range */
805 799
806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", 800 ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type));
807 type)); 801 return_UINT32(ACPI_NS_NORMAL);
808 return_VALUE(ACPI_NS_NORMAL);
809 } 802 }
810 803
811 return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 804 return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
812} 805}
813 806
814/******************************************************************************* 807/*******************************************************************************
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index 5f164c0df33b..fcab1e784b81 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index c07b046659ff..a95f636dc35d 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -112,8 +112,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
112 if (return_buffer->length == 0) { 112 if (return_buffer->length == 0) {
113 /* Error because caller specifically asked for a return value */ 113 /* Error because caller specifically asked for a return value */
114 114
115 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n")); 115 ACPI_ERROR((AE_INFO, "No return value"));
116
117 return_ACPI_STATUS(AE_NULL_OBJECT); 116 return_ACPI_STATUS(AE_NULL_OBJECT);
118 } 117 }
119 118
@@ -125,11 +124,11 @@ acpi_evaluate_object_typed(acpi_handle handle,
125 124
126 /* Return object type does not match requested type */ 125 /* Return object type does not match requested type */
127 126
128 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 127 ACPI_ERROR((AE_INFO,
129 "Incorrect return type [%s] requested [%s]\n", 128 "Incorrect return type [%s] requested [%s]",
130 acpi_ut_get_type_name(((union acpi_object *) 129 acpi_ut_get_type_name(((union acpi_object *)return_buffer->
131 return_buffer->pointer)->type), 130 pointer)->type),
132 acpi_ut_get_type_name(return_type))); 131 acpi_ut_get_type_name(return_type)));
133 132
134 if (must_free) { 133 if (must_free) {
135 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 134 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
@@ -236,11 +235,11 @@ acpi_evaluate_object(acpi_handle handle,
236 * qualified names above, this is an error 235 * qualified names above, this is an error
237 */ 236 */
238 if (!pathname) { 237 if (!pathname) {
239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 238 ACPI_ERROR((AE_INFO,
240 "Both Handle and Pathname are NULL\n")); 239 "Both Handle and Pathname are NULL"));
241 } else { 240 } else {
242 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 241 ACPI_ERROR((AE_INFO,
243 "Handle is NULL and Pathname is relative\n")); 242 "Handle is NULL and Pathname is relative"));
244 } 243 }
245 244
246 status = AE_BAD_PARAMETER; 245 status = AE_BAD_PARAMETER;
@@ -399,7 +398,7 @@ acpi_walk_namespace(acpi_object_type type,
399 398
400 /* Parameter validation */ 399 /* Parameter validation */
401 400
402 if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) { 401 if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) {
403 return_ACPI_STATUS(AE_BAD_PARAMETER); 402 return_ACPI_STATUS(AE_BAD_PARAMETER);
404 } 403 }
405 404
@@ -473,8 +472,8 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
473 return (AE_CTRL_DEPTH); 472 return (AE_CTRL_DEPTH);
474 } 473 }
475 474
476 if (!(flags & 0x01)) { 475 if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
477 /* Don't return at the device or children of the device if not there */ 476 /* Don't examine children of the device if not present */
478 477
479 return (AE_CTRL_DEPTH); 478 return (AE_CTRL_DEPTH);
480 } 479 }
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index 6b5f8d4481d1..8cd8675a47c0 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -300,8 +300,7 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
300 300
301 status = acpi_ut_execute_CID(node, &cid_list); 301 status = acpi_ut_execute_CID(node, &cid_list);
302 if (ACPI_SUCCESS(status)) { 302 if (ACPI_SUCCESS(status)) {
303 size += ((acpi_size) cid_list->count - 1) * 303 size += cid_list->size;
304 sizeof(struct acpi_compatible_id);
305 info->valid |= ACPI_VALID_CID; 304 info->valid |= ACPI_VALID_CID;
306 } 305 }
307 306
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 0856d42e6909..a0332595677a 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 20c9a37643c7..ac5bbaedac1b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -838,7 +838,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
838 static const int quantum_ms = 1000 / HZ; 838 static const int quantum_ms = 1000 / HZ;
839 839
840 ret = down_trylock(sem); 840 ret = down_trylock(sem);
841 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { 841 for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) {
842 schedule_timeout_interruptible(1); 842 schedule_timeout_interruptible(1);
843 ret = down_trylock(sem); 843 ret = down_trylock(sem);
844 } 844 }
@@ -1060,13 +1060,11 @@ EXPORT_SYMBOL(max_cstate);
1060 * Acquire a spinlock. 1060 * Acquire a spinlock.
1061 * 1061 *
1062 * handle is a pointer to the spinlock_t. 1062 * handle is a pointer to the spinlock_t.
1063 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1064 * that indicates whether we are at interrupt level.
1065 */ 1063 */
1066 1064
1067unsigned long acpi_os_acquire_lock(acpi_handle handle) 1065acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
1068{ 1066{
1069 unsigned long flags; 1067 acpi_cpu_flags flags;
1070 spin_lock_irqsave((spinlock_t *) handle, flags); 1068 spin_lock_irqsave((spinlock_t *) handle, flags);
1071 return flags; 1069 return flags;
1072} 1070}
@@ -1075,7 +1073,7 @@ unsigned long acpi_os_acquire_lock(acpi_handle handle)
1075 * Release a spinlock. See above. 1073 * Release a spinlock. See above.
1076 */ 1074 */
1077 1075
1078void acpi_os_release_lock(acpi_handle handle, unsigned long flags) 1076void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags)
1079{ 1077{
1080 spin_unlock_irqrestore((spinlock_t *) handle, flags); 1078 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1081} 1079}
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index 5858188f94a6..de573be52718 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include <acpi/acparser.h> 45#include <acpi/acparser.h>
46#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
48#include <acpi/acdispat.h>
48 49
49#define _COMPONENT ACPI_PARSER 50#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psargs") 51ACPI_MODULE_NAME("psargs")
@@ -62,61 +63,51 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
62 * 63 *
63 * PARAMETERS: parser_state - Current parser state object 64 * PARAMETERS: parser_state - Current parser state object
64 * 65 *
65 * RETURN: Decoded package length. On completion, the AML pointer points 66 * RETURN: Decoded package length. On completion, the AML pointer points
66 * past the length byte or bytes. 67 * past the length byte or bytes.
67 * 68 *
68 * DESCRIPTION: Decode and return a package length field 69 * DESCRIPTION: Decode and return a package length field.
70 * Note: Largest package length is 28 bits, from ACPI specification
69 * 71 *
70 ******************************************************************************/ 72 ******************************************************************************/
71 73
72static u32 74static u32
73acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) 75acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
74{ 76{
75 u32 encoded_length; 77 u8 *aml = parser_state->aml;
76 u32 length = 0; 78 u32 package_length = 0;
79 acpi_native_uint byte_count;
80 u8 byte_zero_mask = 0x3F; /* Default [0:5] */
77 81
78 ACPI_FUNCTION_TRACE("ps_get_next_package_length"); 82 ACPI_FUNCTION_TRACE("ps_get_next_package_length");
79 83
80 encoded_length = (u32) ACPI_GET8(parser_state->aml); 84 /*
81 parser_state->aml++; 85 * Byte 0 bits [6:7] contain the number of additional bytes
82 86 * used to encode the package length, either 0,1,2, or 3
83 switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */ 87 */
84 case 0: /* 1-byte encoding (bits 0-5) */ 88 byte_count = (aml[0] >> 6);
85 89 parser_state->aml += (byte_count + 1);
86 length = (encoded_length & 0x3F);
87 break;
88
89 case 1: /* 2-byte encoding (next byte + bits 0-3) */
90
91 length = ((ACPI_GET8(parser_state->aml) << 04) |
92 (encoded_length & 0x0F));
93 parser_state->aml++;
94 break;
95
96 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
97
98 length = ((ACPI_GET8(parser_state->aml + 1) << 12) |
99 (ACPI_GET8(parser_state->aml) << 04) |
100 (encoded_length & 0x0F));
101 parser_state->aml += 2;
102 break;
103 90
104 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ 91 /* Get bytes 3, 2, 1 as needed */
105 92
106 length = ((ACPI_GET8(parser_state->aml + 2) << 20) | 93 while (byte_count) {
107 (ACPI_GET8(parser_state->aml + 1) << 12) | 94 /*
108 (ACPI_GET8(parser_state->aml) << 04) | 95 * Final bit positions for the package length bytes:
109 (encoded_length & 0x0F)); 96 * Byte3->[20:27]
110 parser_state->aml += 3; 97 * Byte2->[12:19]
111 break; 98 * Byte1->[04:11]
112 99 * Byte0->[00:03]
113 default: 100 */
101 package_length |= (aml[byte_count] << ((byte_count << 3) - 4));
114 102
115 /* Can't get here, only 2 bits / 4 cases */ 103 byte_zero_mask = 0x0F; /* Use bits [0:3] of byte 0 */
116 break; 104 byte_count--;
117 } 105 }
118 106
119 return_VALUE(length); 107 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
108
109 package_length |= (aml[0] & byte_zero_mask);
110 return_UINT32(package_length);
120} 111}
121 112
122/******************************************************************************* 113/*******************************************************************************
@@ -135,16 +126,15 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
135u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) 126u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
136{ 127{
137 u8 *start = parser_state->aml; 128 u8 *start = parser_state->aml;
138 acpi_native_uint length; 129 u32 package_length;
139 130
140 ACPI_FUNCTION_TRACE("ps_get_next_package_end"); 131 ACPI_FUNCTION_TRACE("ps_get_next_package_end");
141 132
142 /* Function below changes parser_state->Aml */ 133 /* Function below updates parser_state->Aml */
143 134
144 length = 135 package_length = acpi_ps_get_next_package_length(parser_state);
145 (acpi_native_uint) acpi_ps_get_next_package_length(parser_state);
146 136
147 return_PTR(start + length); /* end of package */ 137 return_PTR(start + package_length); /* end of package */
148} 138}
149 139
150/******************************************************************************* 140/*******************************************************************************
@@ -169,17 +159,15 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
169 159
170 ACPI_FUNCTION_TRACE("ps_get_next_namestring"); 160 ACPI_FUNCTION_TRACE("ps_get_next_namestring");
171 161
172 /* Handle multiple prefix characters */ 162 /* Point past any namestring prefix characters (backslash or carat) */
173
174 while (acpi_ps_is_prefix_char(ACPI_GET8(end))) {
175 /* Include prefix '\\' or '^' */
176 163
164 while (acpi_ps_is_prefix_char(*end)) {
177 end++; 165 end++;
178 } 166 }
179 167
180 /* Decode the path */ 168 /* Decode the path prefix character */
181 169
182 switch (ACPI_GET8(end)) { 170 switch (*end) {
183 case 0: 171 case 0:
184 172
185 /* null_name */ 173 /* null_name */
@@ -199,9 +187,9 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
199 187
200 case AML_MULTI_NAME_PREFIX_OP: 188 case AML_MULTI_NAME_PREFIX_OP:
201 189
202 /* Multiple name segments, 4 chars each */ 190 /* Multiple name segments, 4 chars each, count in next byte */
203 191
204 end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE); 192 end += 2 + (*(end + 1) * ACPI_NAME_SIZE);
205 break; 193 break;
206 194
207 default: 195 default:
@@ -212,7 +200,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
212 break; 200 break;
213 } 201 }
214 202
215 parser_state->aml = (u8 *) end; 203 parser_state->aml = end;
216 return_PTR((char *)start); 204 return_PTR((char *)start);
217} 205}
218 206
@@ -224,7 +212,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
224 * Arg - Where the namepath will be stored 212 * Arg - Where the namepath will be stored
225 * arg_count - If the namepath points to a control method 213 * arg_count - If the namepath points to a control method
226 * the method's argument is returned here. 214 * the method's argument is returned here.
227 * method_call - Whether the namepath can possibly be the 215 * possible_method_call - Whether the namepath can possibly be the
228 * start of a method call 216 * start of a method call
229 * 217 *
230 * RETURN: Status 218 * RETURN: Status
@@ -240,11 +228,11 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
240acpi_status 228acpi_status
241acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, 229acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
242 struct acpi_parse_state *parser_state, 230 struct acpi_parse_state *parser_state,
243 union acpi_parse_object *arg, u8 method_call) 231 union acpi_parse_object *arg, u8 possible_method_call)
244{ 232{
245 char *path; 233 char *path;
246 union acpi_parse_object *name_op; 234 union acpi_parse_object *name_op;
247 acpi_status status = AE_OK; 235 acpi_status status;
248 union acpi_operand_object *method_desc; 236 union acpi_operand_object *method_desc;
249 struct acpi_namespace_node *node; 237 struct acpi_namespace_node *node;
250 union acpi_generic_state scope_info; 238 union acpi_generic_state scope_info;
@@ -252,115 +240,129 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
252 ACPI_FUNCTION_TRACE("ps_get_next_namepath"); 240 ACPI_FUNCTION_TRACE("ps_get_next_namepath");
253 241
254 path = acpi_ps_get_next_namestring(parser_state); 242 path = acpi_ps_get_next_namestring(parser_state);
243 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
255 244
256 /* Null path case is allowed */ 245 /* Null path case is allowed, just exit */
257 246
258 if (path) { 247 if (!path) {
259 /* 248 arg->common.value.name = path;
260 * Lookup the name in the internal namespace 249 return_ACPI_STATUS(AE_OK);
261 */ 250 }
262 scope_info.scope.node = NULL;
263 node = parser_state->start_node;
264 if (node) {
265 scope_info.scope.node = node;
266 }
267 251
268 /* 252 /* Setup search scope info */
269 * Lookup object. We don't want to add anything new to the namespace
270 * here, however. So we use MODE_EXECUTE. Allow searching of the
271 * parent tree, but don't open a new scope -- we just want to lookup the
272 * object (MUST BE mode EXECUTE to perform upsearch)
273 */
274 status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY,
275 ACPI_IMODE_EXECUTE,
276 ACPI_NS_SEARCH_PARENT |
277 ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
278 if (ACPI_SUCCESS(status) && method_call) {
279 if (node->type == ACPI_TYPE_METHOD) {
280 /* This name is actually a control method invocation */
281
282 method_desc = acpi_ns_get_attached_object(node);
283 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
284 "Control Method - %p Desc %p Path=%p\n",
285 node, method_desc, path));
286
287 name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
288 if (!name_op) {
289 return_ACPI_STATUS(AE_NO_MEMORY);
290 }
291 253
292 /* Change arg into a METHOD CALL and attach name to it */ 254 scope_info.scope.node = NULL;
255 node = parser_state->start_node;
256 if (node) {
257 scope_info.scope.node = node;
258 }
293 259
294 acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); 260 /*
295 name_op->common.value.name = path; 261 * Lookup the name in the internal namespace. We don't want to add
262 * anything new to the namespace here, however, so we use MODE_EXECUTE.
263 * Allow searching of the parent tree, but don't open a new scope -
264 * we just want to lookup the object (must be mode EXECUTE to perform
265 * the upsearch)
266 */
267 status =
268 acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
269 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
270 NULL, &node);
296 271
297 /* Point METHODCALL/NAME to the METHOD Node */ 272 /*
273 * If this name is a control method invocation, we must
274 * setup the method call
275 */
276 if (ACPI_SUCCESS(status) &&
277 possible_method_call && (node->type == ACPI_TYPE_METHOD)) {
278 /* This name is actually a control method invocation */
298 279
299 name_op->common.node = node; 280 method_desc = acpi_ns_get_attached_object(node);
300 acpi_ps_append_arg(arg, name_op); 281 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
282 "Control Method - %p Desc %p Path=%p\n", node,
283 method_desc, path));
301 284
302 if (!method_desc) { 285 name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
303 ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); 286 if (!name_op) {
304 return_ACPI_STATUS(AE_AML_INTERNAL); 287 return_ACPI_STATUS(AE_NO_MEMORY);
305 } 288 }
306 289
307 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 290 /* Change Arg into a METHOD CALL and attach name to it */
308 "Control Method - %p Args %X\n",
309 node,
310 method_desc->method.
311 param_count));
312 291
313 /* Get the number of arguments to expect */ 292 acpi_ps_init_op(arg, AML_INT_METHODCALL_OP);
293 name_op->common.value.name = path;
314 294
315 walk_state->arg_count = 295 /* Point METHODCALL/NAME to the METHOD Node */
316 method_desc->method.param_count;
317 return_ACPI_STATUS(AE_OK);
318 }
319 296
320 /* 297 name_op->common.node = node;
321 * Else this is normal named object reference. 298 acpi_ps_append_arg(arg, name_op);
322 * Just init the NAMEPATH object with the pathname.
323 * (See code below)
324 */
325 }
326 299
327 if (ACPI_FAILURE(status)) { 300 if (!method_desc) {
328 /* 301 ACPI_ERROR((AE_INFO,
329 * 1) Any error other than NOT_FOUND is always severe 302 "Control Method %p has no attached object",
330 * 2) NOT_FOUND is only important if we are executing a method. 303 node));
331 * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. 304 return_ACPI_STATUS(AE_AML_INTERNAL);
332 */
333 if ((((walk_state->
334 parse_flags & ACPI_PARSE_MODE_MASK) ==
335 ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND)
336 && (walk_state->op->common.aml_opcode !=
337 AML_COND_REF_OF_OP))
338 || (status != AE_NOT_FOUND)) {
339 ACPI_REPORT_NSERROR(path, status);
340
341 acpi_os_printf
342 ("search_node %p start_node %p return_node %p\n",
343 scope_info.scope.node,
344 parser_state->start_node, node);
345
346 } else {
347 /*
348 * We got a NOT_FOUND during table load or we encountered
349 * a cond_ref_of(x) where the target does not exist.
350 * Either case is ok
351 */
352 status = AE_OK;
353 }
354 } 305 }
306
307 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
308 "Control Method - %p Args %X\n",
309 node, method_desc->method.param_count));
310
311 /* Get the number of arguments to expect */
312
313 walk_state->arg_count = method_desc->method.param_count;
314 return_ACPI_STATUS(AE_OK);
355 } 315 }
356 316
357 /* 317 /*
358 * Regardless of success/failure above, 318 * Special handling if the name was not found during the lookup -
359 * Just initialize the Op with the pathname. 319 * some not_found cases are allowed
360 */ 320 */
361 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); 321 if (status == AE_NOT_FOUND) {
362 arg->common.value.name = path; 322 /* 1) not_found is ok during load pass 1/2 (allow forward references) */
323
324 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) !=
325 ACPI_PARSE_EXECUTE) {
326 status = AE_OK;
327 }
328
329 /* 2) not_found during a cond_ref_of(x) is ok by definition */
330
331 else if (walk_state->op->common.aml_opcode ==
332 AML_COND_REF_OF_OP) {
333 status = AE_OK;
334 }
335
336 /*
337 * 3) not_found while building a Package is ok at this point, we
338 * may flag as an error later if slack mode is not enabled.
339 * (Some ASL code depends on allowing this behavior)
340 */
341 else if ((arg->common.parent) &&
342 ((arg->common.parent->common.aml_opcode ==
343 AML_PACKAGE_OP)
344 || (arg->common.parent->common.aml_opcode ==
345 AML_VAR_PACKAGE_OP))) {
346 status = AE_OK;
347 }
348 }
349
350 /* Final exception check (may have been changed from code above) */
363 351
352 if (ACPI_FAILURE(status)) {
353 ACPI_ERROR_NAMESPACE(path, status);
354
355 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
356 ACPI_PARSE_EXECUTE) {
357 /* Report a control method execution error */
358
359 status = acpi_ds_method_error(status, walk_state);
360 }
361 }
362
363 /* Save the namepath */
364
365 arg->common.value.name = path;
364 return_ACPI_STATUS(status); 366 return_ACPI_STATUS(status);
365} 367}
366 368
@@ -382,59 +384,63 @@ void
382acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, 384acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
383 u32 arg_type, union acpi_parse_object *arg) 385 u32 arg_type, union acpi_parse_object *arg)
384{ 386{
387 u32 length;
388 u16 opcode;
389 u8 *aml = parser_state->aml;
385 390
386 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); 391 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type);
387 392
388 switch (arg_type) { 393 switch (arg_type) {
389 case ARGP_BYTEDATA: 394 case ARGP_BYTEDATA:
390 395
391 acpi_ps_init_op(arg, AML_BYTE_OP); 396 /* Get 1 byte from the AML stream */
392 arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); 397
393 parser_state->aml++; 398 opcode = AML_BYTE_OP;
399 arg->common.value.integer = (acpi_integer) * aml;
400 length = 1;
394 break; 401 break;
395 402
396 case ARGP_WORDDATA: 403 case ARGP_WORDDATA:
397 404
398 acpi_ps_init_op(arg, AML_WORD_OP);
399
400 /* Get 2 bytes from the AML stream */ 405 /* Get 2 bytes from the AML stream */
401 406
402 ACPI_MOVE_16_TO_32(&arg->common.value.integer, 407 opcode = AML_WORD_OP;
403 parser_state->aml); 408 ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml);
404 parser_state->aml += 2; 409 length = 2;
405 break; 410 break;
406 411
407 case ARGP_DWORDDATA: 412 case ARGP_DWORDDATA:
408 413
409 acpi_ps_init_op(arg, AML_DWORD_OP);
410
411 /* Get 4 bytes from the AML stream */ 414 /* Get 4 bytes from the AML stream */
412 415
413 ACPI_MOVE_32_TO_32(&arg->common.value.integer, 416 opcode = AML_DWORD_OP;
414 parser_state->aml); 417 ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml);
415 parser_state->aml += 4; 418 length = 4;
416 break; 419 break;
417 420
418 case ARGP_QWORDDATA: 421 case ARGP_QWORDDATA:
419 422
420 acpi_ps_init_op(arg, AML_QWORD_OP);
421
422 /* Get 8 bytes from the AML stream */ 423 /* Get 8 bytes from the AML stream */
423 424
424 ACPI_MOVE_64_TO_64(&arg->common.value.integer, 425 opcode = AML_QWORD_OP;
425 parser_state->aml); 426 ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml);
426 parser_state->aml += 8; 427 length = 8;
427 break; 428 break;
428 429
429 case ARGP_CHARLIST: 430 case ARGP_CHARLIST:
430 431
431 acpi_ps_init_op(arg, AML_STRING_OP); 432 /* Get a pointer to the string, point past the string */
432 arg->common.value.string = (char *)parser_state->aml; 433
434 opcode = AML_STRING_OP;
435 arg->common.value.string = ACPI_CAST_PTR(char, aml);
433 436
434 while (ACPI_GET8(parser_state->aml) != '\0') { 437 /* Find the null terminator */
435 parser_state->aml++; 438
439 length = 0;
440 while (aml[length]) {
441 length++;
436 } 442 }
437 parser_state->aml++; 443 length++;
438 break; 444 break;
439 445
440 case ARGP_NAME: 446 case ARGP_NAME:
@@ -443,14 +449,16 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
443 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); 449 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
444 arg->common.value.name = 450 arg->common.value.name =
445 acpi_ps_get_next_namestring(parser_state); 451 acpi_ps_get_next_namestring(parser_state);
446 break; 452 return_VOID;
447 453
448 default: 454 default:
449 455
450 ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); 456 ACPI_ERROR((AE_INFO, "Invalid arg_type %X", arg_type));
451 break; 457 return_VOID;
452 } 458 }
453 459
460 acpi_ps_init_op(arg, opcode);
461 parser_state->aml += length;
454 return_VOID; 462 return_VOID;
455} 463}
456 464
@@ -540,7 +548,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
540 * access_type is first operand, access_attribute is second 548 * access_type is first operand, access_attribute is second
541 */ 549 */
542 field->common.value.integer = 550 field->common.value.integer =
543 (ACPI_GET8(parser_state->aml) << 8); 551 (((u32) ACPI_GET8(parser_state->aml) << 8));
544 parser_state->aml++; 552 parser_state->aml++;
545 field->common.value.integer |= ACPI_GET8(parser_state->aml); 553 field->common.value.integer |= ACPI_GET8(parser_state->aml);
546 parser_state->aml++; 554 parser_state->aml++;
@@ -703,7 +711,7 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
703 711
704 default: 712 default:
705 713
706 ACPI_REPORT_ERROR(("Invalid arg_type: %X\n", arg_type)); 714 ACPI_ERROR((AE_INFO, "Invalid arg_type: %X", arg_type));
707 status = AE_AML_OPERAND_TYPE; 715 status = AE_AML_OPERAND_TYPE;
708 break; 716 break;
709 } 717 }
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c
index 088d33999d90..00b072e15d19 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/parser/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -123,16 +123,12 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
123 && ((status & AE_CODE_MASK) != 123 && ((status & AE_CODE_MASK) !=
124 AE_CODE_CONTROL)) { 124 AE_CODE_CONTROL)) {
125 if (status == AE_AML_NO_RETURN_VALUE) { 125 if (status == AE_AML_NO_RETURN_VALUE) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_EXCEPTION((AE_INFO, status,
127 "Invoked method did not return a value, %s\n", 127 "Invoked method did not return a value"));
128 acpi_format_exception
129 (status)));
130 128
131 } 129 }
132 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 130 ACPI_EXCEPTION((AE_INFO, status,
133 "get_predicate Failed, %s\n", 131 "get_predicate Failed"));
134 acpi_format_exception
135 (status)));
136 return_ACPI_STATUS(status); 132 return_ACPI_STATUS(status);
137 } 133 }
138 134
@@ -190,11 +186,11 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
190 186
191 /* The opcode is unrecognized. Just skip unknown opcodes */ 187 /* The opcode is unrecognized. Just skip unknown opcodes */
192 188
193 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 189 ACPI_ERROR((AE_INFO,
194 "Found unknown opcode %X at AML address %p offset %X, ignoring\n", 190 "Found unknown opcode %X at AML address %p offset %X, ignoring",
195 walk_state->opcode, 191 walk_state->opcode,
196 parser_state->aml, 192 parser_state->aml,
197 walk_state->aml_offset)); 193 walk_state->aml_offset));
198 194
199 ACPI_DUMP_BUFFER(parser_state->aml, 128); 195 ACPI_DUMP_BUFFER(parser_state->aml, 128);
200 196
@@ -281,10 +277,8 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
281 walk_state->descending_callback(walk_state, 277 walk_state->descending_callback(walk_state,
282 &op); 278 &op);
283 if (ACPI_FAILURE(status)) { 279 if (ACPI_FAILURE(status)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 280 ACPI_EXCEPTION((AE_INFO, status,
285 "During name lookup/catalog, %s\n", 281 "During name lookup/catalog"));
286 acpi_format_exception
287 (status)));
288 goto close_this_op; 282 goto close_this_op;
289 } 283 }
290 284
@@ -704,6 +698,15 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
704 acpi_ps_pop_scope(parser_state, &op, 698 acpi_ps_pop_scope(parser_state, &op,
705 &walk_state->arg_types, 699 &walk_state->arg_types,
706 &walk_state->arg_count); 700 &walk_state->arg_count);
701
702 if (op->common.aml_opcode != AML_WHILE_OP) {
703 status2 =
704 acpi_ds_result_stack_pop
705 (walk_state);
706 if (ACPI_FAILURE(status2)) {
707 return_ACPI_STATUS(status2);
708 }
709 }
707 } 710 }
708 711
709 /* Close this iteration of the While loop */ 712 /* Close this iteration of the While loop */
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 229ae86afe8b..11d6351ab8b2 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/parser/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -747,7 +747,7 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
747 747
748 /* Unknown AML opcode */ 748 /* Unknown AML opcode */
749 749
750 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 750 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
751 "Unknown AML opcode [%4.4X]\n", opcode)); 751 "Unknown AML opcode [%4.4X]\n", opcode));
752 752
753 return (&acpi_gbl_aml_op_info[_UNK]); 753 return (&acpi_gbl_aml_op_info[_UNK]);
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 76d4d640d83c..a9f3229f4106 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -333,7 +333,6 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
333 333
334 switch (callback_status) { 334 switch (callback_status) {
335 case AE_CTRL_TERMINATE: 335 case AE_CTRL_TERMINATE:
336
337 /* 336 /*
338 * A control method was terminated via a RETURN statement. 337 * A control method was terminated via a RETURN statement.
339 * The walk of this method is complete. 338 * The walk of this method is complete.
@@ -346,13 +345,19 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
346 345
347 parser_state->aml = walk_state->aml_last_while; 346 parser_state->aml = walk_state->aml_last_while;
348 walk_state->control_state->common.value = FALSE; 347 walk_state->control_state->common.value = FALSE;
349 status = AE_CTRL_BREAK; 348 status = acpi_ds_result_stack_pop(walk_state);
349 if (ACPI_SUCCESS(status)) {
350 status = AE_CTRL_BREAK;
351 }
350 break; 352 break;
351 353
352 case AE_CTRL_CONTINUE: 354 case AE_CTRL_CONTINUE:
353 355
354 parser_state->aml = walk_state->aml_last_while; 356 parser_state->aml = walk_state->aml_last_while;
355 status = AE_CTRL_CONTINUE; 357 status = acpi_ds_result_stack_pop(walk_state);
358 if (ACPI_SUCCESS(status)) {
359 status = AE_CTRL_CONTINUE;
360 }
356 break; 361 break;
357 362
358 case AE_CTRL_PENDING: 363 case AE_CTRL_PENDING:
@@ -369,16 +374,18 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
369#endif 374#endif
370 375
371 case AE_CTRL_TRUE: 376 case AE_CTRL_TRUE:
372
373 /* 377 /*
374 * Predicate of an IF was true, and we are at the matching ELSE. 378 * Predicate of an IF was true, and we are at the matching ELSE.
375 * Just close out this package 379 * Just close out this package
376 */ 380 */
377 parser_state->aml = acpi_ps_get_next_package_end(parser_state); 381 parser_state->aml = acpi_ps_get_next_package_end(parser_state);
382 status = acpi_ds_result_stack_pop(walk_state);
383 if (ACPI_SUCCESS(status)) {
384 status = AE_CTRL_PENDING;
385 }
378 break; 386 break;
379 387
380 case AE_CTRL_FALSE: 388 case AE_CTRL_FALSE:
381
382 /* 389 /*
383 * Either an IF/WHILE Predicate was false or we encountered a BREAK 390 * Either an IF/WHILE Predicate was false or we encountered a BREAK
384 * opcode. In both cases, we do not execute the rest of the 391 * opcode. In both cases, we do not execute the rest of the
@@ -503,22 +510,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
503 } else if (status == AE_CTRL_TERMINATE) { 510 } else if (status == AE_CTRL_TERMINATE) {
504 status = AE_OK; 511 status = AE_OK;
505 } else if ((status != AE_OK) && (walk_state->method_desc)) { 512 } else if ((status != AE_OK) && (walk_state->method_desc)) {
506 ACPI_REPORT_METHOD_ERROR("Method execution failed", 513 /* Either the method parse or actual execution failed */
507 walk_state->method_node, NULL,
508 status);
509
510 /* Ensure proper cleanup */
511 514
512 walk_state->parse_flags |= ACPI_PARSE_EXECUTE; 515 ACPI_ERROR_METHOD("Method parse/execution failed",
516 walk_state->method_node, NULL,
517 status);
513 518
514 /* Check for possible multi-thread reentrancy problem */ 519 /* Check for possible multi-thread reentrancy problem */
515 520
516 if ((status == AE_ALREADY_EXISTS) && 521 if ((status == AE_ALREADY_EXISTS) &&
517 (!walk_state->method_desc->method.semaphore)) { 522 (!walk_state->method_desc->method.semaphore)) {
518 /* 523 /*
519 * This method is marked not_serialized, but it tried to create 524 * Method tried to create an object twice. The probable cause is
525 * that the method cannot handle reentrancy.
526 *
527 * The method is marked not_serialized, but it tried to create
520 * a named object, causing the second thread entrance to fail. 528 * a named object, causing the second thread entrance to fail.
521 * We will workaround this by marking the method permanently 529 * Workaround this problem by marking the method permanently
522 * as Serialized. 530 * as Serialized.
523 */ 531 */
524 walk_state->method_desc->method.method_flags |= 532 walk_state->method_desc->method.method_flags |=
@@ -536,15 +544,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
536 acpi_ds_scope_stack_clear(walk_state); 544 acpi_ds_scope_stack_clear(walk_state);
537 545
538 /* 546 /*
539 * If we just returned from the execution of a control method, 547 * If we just returned from the execution of a control method or if we
540 * there's lots of cleanup to do 548 * encountered an error during the method parse phase, there's lots of
549 * cleanup to do
541 */ 550 */
542 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == 551 if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
543 ACPI_PARSE_EXECUTE) { 552 ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) {
544 if (walk_state->method_desc) { 553 if (walk_state->method_desc) {
545 /* Decrement the thread count on the method parse tree */ 554 /* Decrement the thread count on the method parse tree */
546 555
547 walk_state->method_desc->method.thread_count--; 556 if (walk_state->method_desc->method.
557 thread_count) {
558 walk_state->method_desc->method.
559 thread_count--;
560 } else {
561 ACPI_ERROR((AE_INFO,
562 "Invalid zero thread count in method"));
563 }
548 } 564 }
549 565
550 acpi_ds_terminate_control_method(walk_state); 566 acpi_ds_terminate_control_method(walk_state);
@@ -553,7 +569,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
553 /* Delete this walk state and all linked control states */ 569 /* Delete this walk state and all linked control states */
554 570
555 acpi_ps_cleanup_scope(&walk_state->parser_state); 571 acpi_ps_cleanup_scope(&walk_state->parser_state);
556
557 previous_walk_state = walk_state; 572 previous_walk_state = walk_state;
558 573
559 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 574 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
index 1c953b6f1af1..bc6047caccd9 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/parser/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
index f0e755884eea..dd6f16726fc4 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/parser/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -132,7 +132,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
132 if (op_info->class == AML_CLASS_UNKNOWN) { 132 if (op_info->class == AML_CLASS_UNKNOWN) {
133 /* Invalid opcode */ 133 /* Invalid opcode */
134 134
135 ACPI_REPORT_ERROR(("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->common.aml_opcode)); 135 ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
136 op->common.aml_opcode));
136 return; 137 return;
137 } 138 }
138 139
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index 2075efbb4324..3e07cb9cb748 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c
index 08f2321b6ded..06f05bfd7612 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/parser/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index 4dcbd443160e..2dd48cbb7c02 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,10 @@
50ACPI_MODULE_NAME("psxface") 50ACPI_MODULE_NAME("psxface")
51 51
52/* Local Prototypes */ 52/* Local Prototypes */
53static void acpi_ps_start_trace(struct acpi_parameter_info *info);
54
55static void acpi_ps_stop_trace(struct acpi_parameter_info *info);
56
53static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info); 57static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info);
54 58
55static void 59static void
@@ -57,6 +61,136 @@ acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action);
57 61
58/******************************************************************************* 62/*******************************************************************************
59 * 63 *
64 * FUNCTION: acpi_debug_trace
65 *
66 * PARAMETERS: method_name - Valid ACPI name string
67 * debug_level - Optional level mask. 0 to use default
68 * debug_layer - Optional layer mask. 0 to use default
69 * Flags - bit 1: one shot(1) or persistent(0)
70 *
71 * RETURN: Status
72 *
73 * DESCRIPTION: External interface to enable debug tracing during control
74 * method execution
75 *
76 ******************************************************************************/
77
78acpi_status
79acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
80{
81 acpi_status status;
82
83 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
84 if (ACPI_FAILURE(status)) {
85 return (status);
86 }
87
88 /* TBDs: Validate name, allow full path or just nameseg */
89
90 acpi_gbl_trace_method_name = *ACPI_CAST_PTR(u32, name);
91 acpi_gbl_trace_flags = flags;
92
93 if (debug_level) {
94 acpi_gbl_trace_dbg_level = debug_level;
95 }
96 if (debug_layer) {
97 acpi_gbl_trace_dbg_layer = debug_layer;
98 }
99
100 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
101 return (AE_OK);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_ps_start_trace
107 *
108 * PARAMETERS: Info - Method info struct
109 *
110 * RETURN: None
111 *
112 * DESCRIPTION: Start control method execution trace
113 *
114 ******************************************************************************/
115
116static void acpi_ps_start_trace(struct acpi_parameter_info *info)
117{
118 acpi_status status;
119
120 ACPI_FUNCTION_ENTRY();
121
122 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
123 if (ACPI_FAILURE(status)) {
124 return;
125 }
126
127 if ((!acpi_gbl_trace_method_name) ||
128 (acpi_gbl_trace_method_name != info->node->name.integer)) {
129 goto exit;
130 }
131
132 acpi_gbl_original_dbg_level = acpi_dbg_level;
133 acpi_gbl_original_dbg_layer = acpi_dbg_layer;
134
135 acpi_dbg_level = 0x00FFFFFF;
136 acpi_dbg_layer = ACPI_UINT32_MAX;
137
138 if (acpi_gbl_trace_dbg_level) {
139 acpi_dbg_level = acpi_gbl_trace_dbg_level;
140 }
141 if (acpi_gbl_trace_dbg_layer) {
142 acpi_dbg_layer = acpi_gbl_trace_dbg_layer;
143 }
144
145 exit:
146 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_ps_stop_trace
152 *
153 * PARAMETERS: Info - Method info struct
154 *
155 * RETURN: None
156 *
157 * DESCRIPTION: Stop control method execution trace
158 *
159 ******************************************************************************/
160
161static void acpi_ps_stop_trace(struct acpi_parameter_info *info)
162{
163 acpi_status status;
164
165 ACPI_FUNCTION_ENTRY();
166
167 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
168 if (ACPI_FAILURE(status)) {
169 return;
170 }
171
172 if ((!acpi_gbl_trace_method_name) ||
173 (acpi_gbl_trace_method_name != info->node->name.integer)) {
174 goto exit;
175 }
176
177 /* Disable further tracing if type is one-shot */
178
179 if (acpi_gbl_trace_flags & 1) {
180 acpi_gbl_trace_method_name = 0;
181 acpi_gbl_trace_dbg_level = 0;
182 acpi_gbl_trace_dbg_layer = 0;
183 }
184
185 acpi_dbg_level = acpi_gbl_original_dbg_level;
186 acpi_dbg_layer = acpi_gbl_original_dbg_layer;
187
188 exit:
189 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
190}
191
192/*******************************************************************************
193 *
60 * FUNCTION: acpi_ps_execute_method 194 * FUNCTION: acpi_ps_execute_method
61 * 195 *
62 * PARAMETERS: Info - Method info block, contains: 196 * PARAMETERS: Info - Method info block, contains:
@@ -104,6 +238,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
104 */ 238 */
105 acpi_ps_update_parameter_list(info, REF_INCREMENT); 239 acpi_ps_update_parameter_list(info, REF_INCREMENT);
106 240
241 /* Begin tracing if requested */
242
243 acpi_ps_start_trace(info);
244
107 /* 245 /*
108 * 1) Perform the first pass parse of the method to enter any 246 * 1) Perform the first pass parse of the method to enter any
109 * named objects that it creates into the namespace 247 * named objects that it creates into the namespace
@@ -129,6 +267,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
129 status = acpi_ps_execute_pass(info); 267 status = acpi_ps_execute_pass(info);
130 268
131 cleanup: 269 cleanup:
270 /* End optional tracing */
271
272 acpi_ps_stop_trace(info);
273
132 /* Take away the extra reference that we gave the parameters above */ 274 /* Take away the extra reference that we gave the parameters above */
133 275
134 acpi_ps_update_parameter_list(info, REF_DECREMENT); 276 acpi_ps_update_parameter_list(info, REF_DECREMENT);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index e567c03b238e..65aee79b3971 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -258,7 +258,7 @@ typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **);
258 258
259static int 259static int
260acpi_pci_allocate_irq(struct acpi_prt_entry *entry, 260acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
261 int *edge_level, int *active_high_low, char **link) 261 int *triggering, int *polarity, char **link)
262{ 262{
263 int irq; 263 int irq;
264 264
@@ -266,8 +266,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
266 266
267 if (entry->link.handle) { 267 if (entry->link.handle) {
268 irq = acpi_pci_link_allocate_irq(entry->link.handle, 268 irq = acpi_pci_link_allocate_irq(entry->link.handle,
269 entry->link.index, edge_level, 269 entry->link.index, triggering,
270 active_high_low, link); 270 polarity, link);
271 if (irq < 0) { 271 if (irq < 0) {
272 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 272 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
273 "Invalid IRQ link routing entry\n")); 273 "Invalid IRQ link routing entry\n"));
@@ -275,8 +275,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
275 } 275 }
276 } else { 276 } else {
277 irq = entry->link.index; 277 irq = entry->link.index;
278 *edge_level = ACPI_LEVEL_SENSITIVE; 278 *triggering = ACPI_LEVEL_SENSITIVE;
279 *active_high_low = ACPI_ACTIVE_LOW; 279 *polarity = ACPI_ACTIVE_LOW;
280 } 280 }
281 281
282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); 282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
@@ -285,7 +285,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
285 285
286static int 286static int
287acpi_pci_free_irq(struct acpi_prt_entry *entry, 287acpi_pci_free_irq(struct acpi_prt_entry *entry,
288 int *edge_level, int *active_high_low, char **link) 288 int *triggering, int *polarity, char **link)
289{ 289{
290 int irq; 290 int irq;
291 291
@@ -307,8 +307,8 @@ static int
307acpi_pci_irq_lookup(struct pci_bus *bus, 307acpi_pci_irq_lookup(struct pci_bus *bus,
308 int device, 308 int device,
309 int pin, 309 int pin,
310 int *edge_level, 310 int *triggering,
311 int *active_high_low, char **link, irq_lookup_func func) 311 int *polarity, char **link, irq_lookup_func func)
312{ 312{
313 struct acpi_prt_entry *entry = NULL; 313 struct acpi_prt_entry *entry = NULL;
314 int segment = pci_domain_nr(bus); 314 int segment = pci_domain_nr(bus);
@@ -327,7 +327,7 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
327 return_VALUE(-1); 327 return_VALUE(-1);
328 } 328 }
329 329
330 ret = func(entry, edge_level, active_high_low, link); 330 ret = func(entry, triggering, polarity, link);
331 return_VALUE(ret); 331 return_VALUE(ret);
332} 332}
333 333
@@ -339,8 +339,8 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
339static int 339static int
340acpi_pci_irq_derive(struct pci_dev *dev, 340acpi_pci_irq_derive(struct pci_dev *dev,
341 int pin, 341 int pin,
342 int *edge_level, 342 int *triggering,
343 int *active_high_low, char **link, irq_lookup_func func) 343 int *polarity, char **link, irq_lookup_func func)
344{ 344{
345 struct pci_dev *bridge = dev; 345 struct pci_dev *bridge = dev;
346 int irq = -1; 346 int irq = -1;
@@ -374,7 +374,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
374 } 374 }
375 375
376 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 376 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
377 pin, edge_level, active_high_low, 377 pin, triggering, polarity,
378 link, func); 378 link, func);
379 } 379 }
380 380
@@ -401,8 +401,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
401{ 401{
402 int irq = 0; 402 int irq = 0;
403 u8 pin = 0; 403 u8 pin = 0;
404 int edge_level = ACPI_LEVEL_SENSITIVE; 404 int triggering = ACPI_LEVEL_SENSITIVE;
405 int active_high_low = ACPI_ACTIVE_LOW; 405 int polarity = ACPI_ACTIVE_LOW;
406 char *link = NULL; 406 char *link = NULL;
407 int rc; 407 int rc;
408 408
@@ -431,7 +431,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
431 * values override any BIOS-assigned IRQs set during boot. 431 * values override any BIOS-assigned IRQs set during boot.
432 */ 432 */
433 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 433 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
434 &edge_level, &active_high_low, &link, 434 &triggering, &polarity, &link,
435 acpi_pci_allocate_irq); 435 acpi_pci_allocate_irq);
436 436
437 /* 437 /*
@@ -439,8 +439,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
439 * device's parent bridge. 439 * device's parent bridge.
440 */ 440 */
441 if (irq < 0) 441 if (irq < 0)
442 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 442 irq = acpi_pci_irq_derive(dev, pin, &triggering,
443 &active_high_low, &link, 443 &polarity, &link,
444 acpi_pci_allocate_irq); 444 acpi_pci_allocate_irq);
445 445
446 /* 446 /*
@@ -462,7 +462,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
462 } 462 }
463 } 463 }
464 464
465 rc = acpi_register_gsi(irq, edge_level, active_high_low); 465 rc = acpi_register_gsi(irq, triggering, polarity);
466 if (rc < 0) { 466 if (rc < 0) {
467 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " 467 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
468 "to register GSI\n", pci_name(dev), ('A' + pin)); 468 "to register GSI\n", pci_name(dev), ('A' + pin));
@@ -477,8 +477,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
477 printk("Link [%s] -> ", link); 477 printk("Link [%s] -> ", link);
478 478
479 printk("GSI %u (%s, %s) -> IRQ %d\n", irq, 479 printk("GSI %u (%s, %s) -> IRQ %d\n", irq,
480 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 480 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
481 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 481 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
482 482
483 return_VALUE(0); 483 return_VALUE(0);
484} 484}
@@ -494,8 +494,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
494{ 494{
495 int gsi = 0; 495 int gsi = 0;
496 u8 pin = 0; 496 u8 pin = 0;
497 int edge_level = ACPI_LEVEL_SENSITIVE; 497 int triggering = ACPI_LEVEL_SENSITIVE;
498 int active_high_low = ACPI_ACTIVE_LOW; 498 int polarity = ACPI_ACTIVE_LOW;
499 499
500 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); 500 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
501 501
@@ -511,7 +511,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
511 * First we check the PCI IRQ routing table (PRT) for an IRQ. 511 * First we check the PCI IRQ routing table (PRT) for an IRQ.
512 */ 512 */
513 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 513 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
514 &edge_level, &active_high_low, NULL, 514 &triggering, &polarity, NULL,
515 acpi_pci_free_irq); 515 acpi_pci_free_irq);
516 /* 516 /*
517 * If no PRT entry was found, we'll try to derive an IRQ from the 517 * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -519,7 +519,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
519 */ 519 */
520 if (gsi < 0) 520 if (gsi < 0)
521 gsi = acpi_pci_irq_derive(dev, pin, 521 gsi = acpi_pci_irq_derive(dev, pin,
522 &edge_level, &active_high_low, NULL, 522 &triggering, &polarity, NULL,
523 acpi_pci_free_irq); 523 acpi_pci_free_irq);
524 if (gsi < 0) 524 if (gsi < 0)
525 return_VOID; 525 return_VOID;
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 78927c0f1551..07bc6dfe662b 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -70,8 +70,8 @@ static struct acpi_driver acpi_pci_link_driver = {
70 */ 70 */
71struct acpi_pci_link_irq { 71struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */ 72 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */ 73 u8 triggering; /* All IRQs */
74 u8 active_high_low; /* All IRQs */ 74 u8 polarity; /* All IRQs */
75 u8 resource_type; 75 u8 resource_type;
76 u8 possible_count; 76 u8 possible_count;
77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
@@ -108,19 +108,19 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
108 108
109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); 109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
110 110
111 switch (resource->id) { 111 switch (resource->type) {
112 case ACPI_RSTYPE_START_DPF: 112 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
113 return_ACPI_STATUS(AE_OK); 113 return_ACPI_STATUS(AE_OK);
114 case ACPI_RSTYPE_IRQ: 114 case ACPI_RESOURCE_TYPE_IRQ:
115 { 115 {
116 struct acpi_resource_irq *p = &resource->data.irq; 116 struct acpi_resource_irq *p = &resource->data.irq;
117 if (!p || !p->number_of_interrupts) { 117 if (!p || !p->interrupt_count) {
118 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 118 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
119 "Blank IRQ resource\n")); 119 "Blank IRQ resource\n"));
120 return_ACPI_STATUS(AE_OK); 120 return_ACPI_STATUS(AE_OK);
121 } 121 }
122 for (i = 0; 122 for (i = 0;
123 (i < p->number_of_interrupts 123 (i < p->interrupt_count
124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
125 if (!p->interrupts[i]) { 125 if (!p->interrupts[i]) {
126 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 126 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -131,22 +131,22 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
131 link->irq.possible[i] = p->interrupts[i]; 131 link->irq.possible[i] = p->interrupts[i];
132 link->irq.possible_count++; 132 link->irq.possible_count++;
133 } 133 }
134 link->irq.edge_level = p->edge_level; 134 link->irq.triggering = p->triggering;
135 link->irq.active_high_low = p->active_high_low; 135 link->irq.polarity = p->polarity;
136 link->irq.resource_type = ACPI_RSTYPE_IRQ; 136 link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ;
137 break; 137 break;
138 } 138 }
139 case ACPI_RSTYPE_EXT_IRQ: 139 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
140 { 140 {
141 struct acpi_resource_ext_irq *p = 141 struct acpi_resource_extended_irq *p =
142 &resource->data.extended_irq; 142 &resource->data.extended_irq;
143 if (!p || !p->number_of_interrupts) { 143 if (!p || !p->interrupt_count) {
144 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 144 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
145 "Blank EXT IRQ resource\n")); 145 "Blank EXT IRQ resource\n"));
146 return_ACPI_STATUS(AE_OK); 146 return_ACPI_STATUS(AE_OK);
147 } 147 }
148 for (i = 0; 148 for (i = 0;
149 (i < p->number_of_interrupts 149 (i < p->interrupt_count
150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
151 if (!p->interrupts[i]) { 151 if (!p->interrupts[i]) {
152 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 152 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -157,9 +157,9 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
157 link->irq.possible[i] = p->interrupts[i]; 157 link->irq.possible[i] = p->interrupts[i];
158 link->irq.possible_count++; 158 link->irq.possible_count++;
159 } 159 }
160 link->irq.edge_level = p->edge_level; 160 link->irq.triggering = p->triggering;
161 link->irq.active_high_low = p->active_high_low; 161 link->irq.polarity = p->polarity;
162 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; 162 link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
163 break; 163 break;
164 } 164 }
165 default: 165 default:
@@ -201,11 +201,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
201 201
202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); 202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
203 203
204 switch (resource->id) { 204 switch (resource->type) {
205 case ACPI_RSTYPE_IRQ: 205 case ACPI_RESOURCE_TYPE_IRQ:
206 { 206 {
207 struct acpi_resource_irq *p = &resource->data.irq; 207 struct acpi_resource_irq *p = &resource->data.irq;
208 if (!p || !p->number_of_interrupts) { 208 if (!p || !p->interrupt_count) {
209 /* 209 /*
210 * IRQ descriptors may have no IRQ# bits set, 210 * IRQ descriptors may have no IRQ# bits set,
211 * particularly those those w/ _STA disabled 211 * particularly those those w/ _STA disabled
@@ -217,11 +217,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
217 *irq = p->interrupts[0]; 217 *irq = p->interrupts[0];
218 break; 218 break;
219 } 219 }
220 case ACPI_RSTYPE_EXT_IRQ: 220 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
221 { 221 {
222 struct acpi_resource_ext_irq *p = 222 struct acpi_resource_extended_irq *p =
223 &resource->data.extended_irq; 223 &resource->data.extended_irq;
224 if (!p || !p->number_of_interrupts) { 224 if (!p || !p->interrupt_count) {
225 /* 225 /*
226 * extended IRQ descriptors must 226 * extended IRQ descriptors must
227 * return at least 1 IRQ 227 * return at least 1 IRQ
@@ -233,8 +233,10 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
233 *irq = p->interrupts[0]; 233 *irq = p->interrupts[0];
234 break; 234 break;
235 } 235 }
236 break;
236 default: 237 default:
237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource isn't an IRQ\n")); 238 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type));
239 case ACPI_RESOURCE_TYPE_END_TAG:
238 return_ACPI_STATUS(AE_OK); 240 return_ACPI_STATUS(AE_OK);
239 } 241 }
240 return_ACPI_STATUS(AE_CTRL_TERMINATE); 242 return_ACPI_STATUS(AE_CTRL_TERMINATE);
@@ -325,36 +327,36 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
325 buffer.pointer = resource; 327 buffer.pointer = resource;
326 328
327 switch (link->irq.resource_type) { 329 switch (link->irq.resource_type) {
328 case ACPI_RSTYPE_IRQ: 330 case ACPI_RESOURCE_TYPE_IRQ:
329 resource->res.id = ACPI_RSTYPE_IRQ; 331 resource->res.type = ACPI_RESOURCE_TYPE_IRQ;
330 resource->res.length = sizeof(struct acpi_resource); 332 resource->res.length = sizeof(struct acpi_resource);
331 resource->res.data.irq.edge_level = link->irq.edge_level; 333 resource->res.data.irq.triggering = link->irq.triggering;
332 resource->res.data.irq.active_high_low = 334 resource->res.data.irq.polarity =
333 link->irq.active_high_low; 335 link->irq.polarity;
334 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 336 if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
335 resource->res.data.irq.shared_exclusive = 337 resource->res.data.irq.sharable =
336 ACPI_EXCLUSIVE; 338 ACPI_EXCLUSIVE;
337 else 339 else
338 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 340 resource->res.data.irq.sharable = ACPI_SHARED;
339 resource->res.data.irq.number_of_interrupts = 1; 341 resource->res.data.irq.interrupt_count = 1;
340 resource->res.data.irq.interrupts[0] = irq; 342 resource->res.data.irq.interrupts[0] = irq;
341 break; 343 break;
342 344
343 case ACPI_RSTYPE_EXT_IRQ: 345 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
344 resource->res.id = ACPI_RSTYPE_EXT_IRQ; 346 resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
345 resource->res.length = sizeof(struct acpi_resource); 347 resource->res.length = sizeof(struct acpi_resource);
346 resource->res.data.extended_irq.producer_consumer = 348 resource->res.data.extended_irq.producer_consumer =
347 ACPI_CONSUMER; 349 ACPI_CONSUMER;
348 resource->res.data.extended_irq.edge_level = 350 resource->res.data.extended_irq.triggering =
349 link->irq.edge_level; 351 link->irq.triggering;
350 resource->res.data.extended_irq.active_high_low = 352 resource->res.data.extended_irq.polarity =
351 link->irq.active_high_low; 353 link->irq.polarity;
352 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 354 if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
353 resource->res.data.irq.shared_exclusive = 355 resource->res.data.irq.sharable =
354 ACPI_EXCLUSIVE; 356 ACPI_EXCLUSIVE;
355 else 357 else
356 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 358 resource->res.data.irq.sharable = ACPI_SHARED;
357 resource->res.data.extended_irq.number_of_interrupts = 1; 359 resource->res.data.extended_irq.interrupt_count = 1;
358 resource->res.data.extended_irq.interrupts[0] = irq; 360 resource->res.data.extended_irq.interrupts[0] = irq;
359 /* ignore resource_source, it's optional */ 361 /* ignore resource_source, it's optional */
360 break; 362 break;
@@ -364,7 +366,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
364 goto end; 366 goto end;
365 367
366 } 368 }
367 resource->end.id = ACPI_RSTYPE_END_TAG; 369 resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
368 370
369 /* Attempt to set the resource */ 371 /* Attempt to set the resource */
370 status = acpi_set_current_resources(link->handle, &buffer); 372 status = acpi_set_current_resources(link->handle, &buffer);
@@ -613,7 +615,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
613int 615int
614acpi_pci_link_allocate_irq(acpi_handle handle, 616acpi_pci_link_allocate_irq(acpi_handle handle,
615 int index, 617 int index,
616 int *edge_level, int *active_high_low, char **name) 618 int *triggering, int *polarity, char **name)
617{ 619{
618 int result = 0; 620 int result = 0;
619 struct acpi_device *device = NULL; 621 struct acpi_device *device = NULL;
@@ -653,10 +655,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
653 link->refcnt++; 655 link->refcnt++;
654 up(&acpi_link_lock); 656 up(&acpi_link_lock);
655 657
656 if (edge_level) 658 if (triggering)
657 *edge_level = link->irq.edge_level; 659 *triggering = link->irq.triggering;
658 if (active_high_low) 660 if (polarity)
659 *active_high_low = link->irq.active_high_low; 661 *polarity = link->irq.polarity;
660 if (name) 662 if (name)
661 *name = acpi_device_bid(link->device); 663 *name = acpi_device_bid(link->device);
662 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 664 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 0fd9988c283d..4c313eab6313 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -122,15 +122,15 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
122 int *busnr = (int *)data; 122 int *busnr = (int *)data;
123 struct acpi_resource_address64 address; 123 struct acpi_resource_address64 address;
124 124
125 if (resource->id != ACPI_RSTYPE_ADDRESS16 && 125 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
126 resource->id != ACPI_RSTYPE_ADDRESS32 && 126 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
127 resource->id != ACPI_RSTYPE_ADDRESS64) 127 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
128 return AE_OK; 128 return AE_OK;
129 129
130 acpi_resource_to_address64(resource, &address); 130 acpi_resource_to_address64(resource, &address);
131 if ((address.address_length > 0) && 131 if ((address.address_length > 0) &&
132 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 132 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
133 *busnr = address.min_address_range; 133 *busnr = address.minimum;
134 134
135 return AE_OK; 135 return AE_OK;
136} 136}
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 1278aca96fe3..99a3a28594da 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -253,31 +253,21 @@ static int acpi_processor_errata(struct acpi_processor *pr)
253 * _PDC is required for a BIOS-OS handshake for most of the newer 253 * _PDC is required for a BIOS-OS handshake for most of the newer
254 * ACPI processor features. 254 * ACPI processor features.
255 */ 255 */
256 256static int acpi_processor_set_pdc(struct acpi_processor *pr)
257int acpi_processor_set_pdc(struct acpi_processor *pr,
258 struct acpi_object_list *pdc_in)
259{ 257{
258 struct acpi_object_list *pdc_in = pr->pdc;
260 acpi_status status = AE_OK; 259 acpi_status status = AE_OK;
261 u32 arg0_buf[3];
262 union acpi_object arg0 = { ACPI_TYPE_BUFFER };
263 struct acpi_object_list no_object = { 1, &arg0 };
264 struct acpi_object_list *pdc;
265 260
266 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); 261 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
267 262
268 arg0.buffer.length = 12; 263 if (!pdc_in)
269 arg0.buffer.pointer = (u8 *) arg0_buf; 264 return_VALUE(status);
270 arg0_buf[0] = ACPI_PDC_REVISION_ID;
271 arg0_buf[1] = 0;
272 arg0_buf[2] = 0;
273
274 pdc = (pdc_in) ? pdc_in : &no_object;
275 265
276 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL); 266 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
277 267
278 if ((ACPI_FAILURE(status)) && (pdc_in)) 268 if (ACPI_FAILURE(status))
279 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 269 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
280 "Error evaluating _PDC, using legacy perf. control...\n")); 270 "Could not evaluate _PDC, using legacy perf. control...\n"));
281 271
282 return_VALUE(status); 272 return_VALUE(status);
283} 273}
@@ -357,7 +347,6 @@ static int acpi_processor_add_fs(struct acpi_device *device)
357 ACPI_PROCESSOR_FILE_THROTTLING)); 347 ACPI_PROCESSOR_FILE_THROTTLING));
358 else { 348 else {
359 entry->proc_fops = &acpi_processor_throttling_fops; 349 entry->proc_fops = &acpi_processor_throttling_fops;
360 entry->proc_fops->write = acpi_processor_write_throttling;
361 entry->data = acpi_driver_data(device); 350 entry->data = acpi_driver_data(device);
362 entry->owner = THIS_MODULE; 351 entry->owner = THIS_MODULE;
363 } 352 }
@@ -372,7 +361,6 @@ static int acpi_processor_add_fs(struct acpi_device *device)
372 ACPI_PROCESSOR_FILE_LIMIT)); 361 ACPI_PROCESSOR_FILE_LIMIT));
373 else { 362 else {
374 entry->proc_fops = &acpi_processor_limit_fops; 363 entry->proc_fops = &acpi_processor_limit_fops;
375 entry->proc_fops->write = acpi_processor_write_limit;
376 entry->data = acpi_driver_data(device); 364 entry->data = acpi_driver_data(device);
377 entry->owner = THIS_MODULE; 365 entry->owner = THIS_MODULE;
378 } 366 }
@@ -589,6 +577,10 @@ static int acpi_processor_start(struct acpi_device *device)
589 "Error installing device notify handler\n")); 577 "Error installing device notify handler\n"));
590 } 578 }
591 579
580 /* _PDC call should be done before doing anything else (if reqd.). */
581 arch_acpi_processor_init_pdc(pr);
582 acpi_processor_set_pdc(pr);
583
592 acpi_processor_power_init(pr, device); 584 acpi_processor_power_init(pr, device);
593 585
594 if (pr->flags.throttling) { 586 if (pr->flags.throttling) {
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index cc049338e418..be2dae52f6fa 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -95,22 +95,57 @@ static int set_max_cstate(struct dmi_system_id *id)
95} 95}
96 96
97static struct dmi_system_id __initdata processor_power_dmi_table[] = { 97static struct dmi_system_id __initdata processor_power_dmi_table[] = {
98 {set_max_cstate, "IBM ThinkPad R40e", { 98 { set_max_cstate, "IBM ThinkPad R40e", {
99 DMI_MATCH(DMI_BIOS_VENDOR, 99 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
100 "IBM"), 100 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1},
101 DMI_MATCH(DMI_BIOS_VERSION, 101 { set_max_cstate, "IBM ThinkPad R40e", {
102 "1SET60WW")}, 102 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
103 (void *)1}, 103 DMI_MATCH(DMI_BIOS_VERSION,"1SET43WW") }, (void*)1},
104 {set_max_cstate, "Medion 41700", { 104 { set_max_cstate, "IBM ThinkPad R40e", {
105 DMI_MATCH(DMI_BIOS_VENDOR, 105 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
106 "Phoenix Technologies LTD"), 106 DMI_MATCH(DMI_BIOS_VERSION,"1SET45WW") }, (void*)1},
107 DMI_MATCH(DMI_BIOS_VERSION, 107 { set_max_cstate, "IBM ThinkPad R40e", {
108 "R01-A1J")}, (void *)1}, 108 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
109 {set_max_cstate, "Clevo 5600D", { 109 DMI_MATCH(DMI_BIOS_VERSION,"1SET47WW") }, (void*)1},
110 DMI_MATCH(DMI_BIOS_VENDOR, 110 { set_max_cstate, "IBM ThinkPad R40e", {
111 "Phoenix Technologies LTD"), 111 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
112 DMI_MATCH(DMI_BIOS_VERSION, 112 DMI_MATCH(DMI_BIOS_VERSION,"1SET50WW") }, (void*)1},
113 "SHE845M0.86C.0013.D.0302131307")}, 113 { set_max_cstate, "IBM ThinkPad R40e", {
114 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
115 DMI_MATCH(DMI_BIOS_VERSION,"1SET52WW") }, (void*)1},
116 { set_max_cstate, "IBM ThinkPad R40e", {
117 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
118 DMI_MATCH(DMI_BIOS_VERSION,"1SET55WW") }, (void*)1},
119 { set_max_cstate, "IBM ThinkPad R40e", {
120 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
121 DMI_MATCH(DMI_BIOS_VERSION,"1SET56WW") }, (void*)1},
122 { set_max_cstate, "IBM ThinkPad R40e", {
123 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
124 DMI_MATCH(DMI_BIOS_VERSION,"1SET59WW") }, (void*)1},
125 { set_max_cstate, "IBM ThinkPad R40e", {
126 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
127 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }, (void*)1},
128 { set_max_cstate, "IBM ThinkPad R40e", {
129 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
130 DMI_MATCH(DMI_BIOS_VERSION,"1SET61WW") }, (void*)1},
131 { set_max_cstate, "IBM ThinkPad R40e", {
132 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
133 DMI_MATCH(DMI_BIOS_VERSION,"1SET62WW") }, (void*)1},
134 { set_max_cstate, "IBM ThinkPad R40e", {
135 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
136 DMI_MATCH(DMI_BIOS_VERSION,"1SET64WW") }, (void*)1},
137 { set_max_cstate, "IBM ThinkPad R40e", {
138 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
139 DMI_MATCH(DMI_BIOS_VERSION,"1SET65WW") }, (void*)1},
140 { set_max_cstate, "IBM ThinkPad R40e", {
141 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
142 DMI_MATCH(DMI_BIOS_VERSION,"1SET68WW") }, (void*)1},
143 { set_max_cstate, "Medion 41700", {
144 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
145 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J")}, (void *)1},
146 { set_max_cstate, "Clevo 5600D", {
147 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
148 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")},
114 (void *)2}, 149 (void *)2},
115 {}, 150 {},
116}; 151};
@@ -550,18 +585,10 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
550 if (!pr->pblk) 585 if (!pr->pblk)
551 return_VALUE(-ENODEV); 586 return_VALUE(-ENODEV);
552 587
553 memset(pr->power.states, 0, sizeof(pr->power.states));
554
555 /* if info is obtained from pblk/fadt, type equals state */ 588 /* if info is obtained from pblk/fadt, type equals state */
556 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
557 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2; 589 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
558 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3; 590 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3;
559 591
560 /* the C0 state only exists as a filler in our array,
561 * and all processors need to support C1 */
562 pr->power.states[ACPI_STATE_C0].valid = 1;
563 pr->power.states[ACPI_STATE_C1].valid = 1;
564
565#ifndef CONFIG_HOTPLUG_CPU 592#ifndef CONFIG_HOTPLUG_CPU
566 /* 593 /*
567 * Check for P_LVL2_UP flag before entering C2 and above on 594 * Check for P_LVL2_UP flag before entering C2 and above on
@@ -591,12 +618,11 @@ static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
591{ 618{
592 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 619 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
593 620
621 /* Zero initialize all the C-states info. */
594 memset(pr->power.states, 0, sizeof(pr->power.states)); 622 memset(pr->power.states, 0, sizeof(pr->power.states));
595 623
596 /* if info is obtained from pblk/fadt, type equals state */ 624 /* set the first C-State to C1 */
597 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 625 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
598 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
599 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3;
600 626
601 /* the C0 state only exists as a filler in our array, 627 /* the C0 state only exists as a filler in our array,
602 * and all processors need to support C1 */ 628 * and all processors need to support C1 */
@@ -610,6 +636,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
610{ 636{
611 acpi_status status = 0; 637 acpi_status status = 0;
612 acpi_integer count; 638 acpi_integer count;
639 int current_count;
613 int i; 640 int i;
614 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 641 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
615 union acpi_object *cst; 642 union acpi_object *cst;
@@ -619,10 +646,12 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
619 if (nocst) 646 if (nocst)
620 return_VALUE(-ENODEV); 647 return_VALUE(-ENODEV);
621 648
622 pr->power.count = 0; 649 current_count = 1;
623 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 650
624 memset(&(pr->power.states[i]), 0, 651 /* Zero initialize C2 onwards and prepare for fresh CST lookup */
625 sizeof(struct acpi_processor_cx)); 652 for (i = 2; i < ACPI_PROCESSOR_MAX_POWER; i++)
653 memset(&(pr->power.states[i]), 0,
654 sizeof(struct acpi_processor_cx));
626 655
627 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 656 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
628 if (ACPI_FAILURE(status)) { 657 if (ACPI_FAILURE(status)) {
@@ -650,16 +679,6 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
650 goto end; 679 goto end;
651 } 680 }
652 681
653 /* We support up to ACPI_PROCESSOR_MAX_POWER. */
654 if (count > ACPI_PROCESSOR_MAX_POWER) {
655 printk(KERN_WARNING
656 "Limiting number of power states to max (%d)\n",
657 ACPI_PROCESSOR_MAX_POWER);
658 printk(KERN_WARNING
659 "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n");
660 count = ACPI_PROCESSOR_MAX_POWER;
661 }
662
663 /* Tell driver that at least _CST is supported. */ 682 /* Tell driver that at least _CST is supported. */
664 pr->flags.has_cst = 1; 683 pr->flags.has_cst = 1;
665 684
@@ -703,7 +722,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
703 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) 722 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
704 continue; 723 continue;
705 724
706 if ((cx.type < ACPI_STATE_C1) || (cx.type > ACPI_STATE_C3)) 725 if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3))
707 continue; 726 continue;
708 727
709 obj = (union acpi_object *)&(element->package.elements[2]); 728 obj = (union acpi_object *)&(element->package.elements[2]);
@@ -718,15 +737,28 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
718 737
719 cx.power = obj->integer.value; 738 cx.power = obj->integer.value;
720 739
721 (pr->power.count)++; 740 current_count++;
722 memcpy(&(pr->power.states[pr->power.count]), &cx, sizeof(cx)); 741 memcpy(&(pr->power.states[current_count]), &cx, sizeof(cx));
742
743 /*
744 * We support total ACPI_PROCESSOR_MAX_POWER - 1
745 * (From 1 through ACPI_PROCESSOR_MAX_POWER - 1)
746 */
747 if (current_count >= (ACPI_PROCESSOR_MAX_POWER - 1)) {
748 printk(KERN_WARNING
749 "Limiting number of power states to max (%d)\n",
750 ACPI_PROCESSOR_MAX_POWER);
751 printk(KERN_WARNING
752 "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n");
753 break;
754 }
723 } 755 }
724 756
725 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n", 757 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n",
726 pr->power.count)); 758 current_count));
727 759
728 /* Validate number of power states discovered */ 760 /* Validate number of power states discovered */
729 if (pr->power.count < 2) 761 if (current_count < 2)
730 status = -EFAULT; 762 status = -EFAULT;
731 763
732 end: 764 end:
@@ -892,12 +924,13 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
892 /* NOTE: the idle thread may not be running while calling 924 /* NOTE: the idle thread may not be running while calling
893 * this function */ 925 * this function */
894 926
927 /* Adding C1 state */
928 acpi_processor_get_power_info_default_c1(pr);
895 result = acpi_processor_get_power_info_cst(pr); 929 result = acpi_processor_get_power_info_cst(pr);
896 if (result == -ENODEV) 930 if (result == -ENODEV)
897 result = acpi_processor_get_power_info_fadt(pr); 931 acpi_processor_get_power_info_fadt(pr);
898 932
899 if ((result) || (acpi_processor_power_verify(pr) < 2)) 933 pr->power.count = acpi_processor_power_verify(pr);
900 result = acpi_processor_get_power_info_default_c1(pr);
901 934
902 /* 935 /*
903 * Set Default Policy 936 * Set Default Policy
@@ -1066,8 +1099,6 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1066 } 1099 }
1067 } 1100 }
1068 1101
1069 acpi_processor_power_init_pdc(&(pr->power), pr->id);
1070 acpi_processor_set_pdc(pr, pr->power.pdc);
1071 acpi_processor_get_power_info(pr); 1102 acpi_processor_get_power_info(pr);
1072 1103
1073 /* 1104 /*
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 22c7bb66c200..abbdb37a7f5f 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -315,8 +315,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
315 if (!pr || !pr->performance || !pr->handle) 315 if (!pr || !pr->performance || !pr->handle)
316 return_VALUE(-EINVAL); 316 return_VALUE(-EINVAL);
317 317
318 acpi_processor_set_pdc(pr, pr->performance->pdc);
319
320 status = acpi_get_handle(pr->handle, "_PCT", &handle); 318 status = acpi_get_handle(pr->handle, "_PCT", &handle);
321 if (ACPI_FAILURE(status)) { 319 if (ACPI_FAILURE(status)) {
322 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 320 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -520,8 +518,8 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
520 "Unable to create '%s' fs entry\n", 518 "Unable to create '%s' fs entry\n",
521 ACPI_PROCESSOR_FILE_PERFORMANCE)); 519 ACPI_PROCESSOR_FILE_PERFORMANCE));
522 else { 520 else {
521 acpi_processor_perf_fops.write = acpi_processor_write_performance;
523 entry->proc_fops = &acpi_processor_perf_fops; 522 entry->proc_fops = &acpi_processor_perf_fops;
524 entry->proc_fops->write = acpi_processor_write_performance;
525 entry->data = acpi_driver_data(device); 523 entry->data = acpi_driver_data(device);
526 entry->owner = THIS_MODULE; 524 entry->owner = THIS_MODULE;
527 } 525 }
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index dc9817cfb882..f99ad05cd6a2 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -348,9 +348,9 @@ static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
348 PDE(inode)->data); 348 PDE(inode)->data);
349} 349}
350 350
351ssize_t acpi_processor_write_limit(struct file * file, 351static ssize_t acpi_processor_write_limit(struct file * file,
352 const char __user * buffer, 352 const char __user * buffer,
353 size_t count, loff_t * data) 353 size_t count, loff_t * data)
354{ 354{
355 int result = 0; 355 int result = 0;
356 struct seq_file *m = (struct seq_file *)file->private_data; 356 struct seq_file *m = (struct seq_file *)file->private_data;
@@ -394,6 +394,7 @@ ssize_t acpi_processor_write_limit(struct file * file,
394struct file_operations acpi_processor_limit_fops = { 394struct file_operations acpi_processor_limit_fops = {
395 .open = acpi_processor_limit_open_fs, 395 .open = acpi_processor_limit_open_fs,
396 .read = seq_read, 396 .read = seq_read,
397 .write = acpi_processor_write_limit,
397 .llseek = seq_lseek, 398 .llseek = seq_lseek,
398 .release = single_release, 399 .release = single_release,
399}; 400};
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 74a52d4e79ae..b966549ec000 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -306,9 +306,9 @@ static int acpi_processor_throttling_open_fs(struct inode *inode,
306 PDE(inode)->data); 306 PDE(inode)->data);
307} 307}
308 308
309ssize_t acpi_processor_write_throttling(struct file * file, 309static ssize_t acpi_processor_write_throttling(struct file * file,
310 const char __user * buffer, 310 const char __user * buffer,
311 size_t count, loff_t * data) 311 size_t count, loff_t * data)
312{ 312{
313 int result = 0; 313 int result = 0;
314 struct seq_file *m = (struct seq_file *)file->private_data; 314 struct seq_file *m = (struct seq_file *)file->private_data;
@@ -337,6 +337,7 @@ ssize_t acpi_processor_write_throttling(struct file * file,
337struct file_operations acpi_processor_throttling_fops = { 337struct file_operations acpi_processor_throttling_fops = {
338 .open = acpi_processor_throttling_open_fs, 338 .open = acpi_processor_throttling_open_fs,
339 .read = seq_read, 339 .read = seq_read,
340 .write = acpi_processor_write_throttling,
340 .llseek = seq_lseek, 341 .llseek = seq_lseek,
341 .release = single_release, 342 .release = single_release,
342}; 343};
diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
index 2130b74170c3..8de4f69dfa09 100644
--- a/drivers/acpi/resources/Makefile
+++ b/drivers/acpi/resources/Makefile
@@ -2,7 +2,7 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \ 5obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
6 rscalc.o rsirq.o rsmemory.o rsutils.o 6 rscalc.o rsirq.o rsmemory.o rsutils.o
7 7
8obj-$(ACPI_FUTURE_USAGE) += rsdump.o 8obj-$(ACPI_FUTURE_USAGE) += rsdump.o
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 23b54baa0cb2..8fa3213ce000 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,1072 +47,334 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsaddr") 48ACPI_MODULE_NAME("rsaddr")
49 49
50/* Local prototypes */
51static void
52acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags);
53
54static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource);
55
56static void
57acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
58
59static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
60
61/******************************************************************************* 50/*******************************************************************************
62 * 51 *
63 * FUNCTION: acpi_rs_decode_general_flags 52 * acpi_rs_convert_address16 - All WORD (16-bit) address resources
64 *
65 * PARAMETERS: Resource - Address resource data struct
66 * Flags - Actual flag byte
67 *
68 * RETURN: Decoded flag bits in resource struct
69 *
70 * DESCRIPTION: Decode a general flag byte to an address resource struct
71 * 53 *
72 ******************************************************************************/ 54 ******************************************************************************/
55struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {
56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
57 ACPI_RS_SIZE(struct acpi_resource_address16),
58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)},
73 59
74static void 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
75acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) 61 sizeof(struct aml_resource_address16),
76{ 62 0},
77 ACPI_FUNCTION_ENTRY();
78
79 /* Producer / Consumer - flag bit[0] */
80
81 resource->address.producer_consumer = (u32) (flags & 0x01);
82 63
83 /* Decode (_DEC) - flag bit[1] */ 64 /* Resource Type, General Flags, and Type-Specific Flags */
84 65
85 resource->address.decode = (u32) ((flags >> 1) & 0x01); 66 {ACPI_RSC_ADDRESS, 0, 0, 0},
86 67
87 /* Min Address Fixed (_MIF) - flag bit[2] */ 68 /*
69 * These fields are contiguous in both the source and destination:
70 * Address Granularity
71 * Address Range Minimum
72 * Address Range Maximum
73 * Address Translation Offset
74 * Address Length
75 */
76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity),
77 AML_OFFSET(address16.granularity),
78 5},
88 79
89 resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01); 80 /* Optional resource_source (Index and String) */
90 81
91 /* Max Address Fixed (_MAF) - flag bit[3] */ 82 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source),
92 83 0,
93 resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01); 84 sizeof(struct aml_resource_address16)}
94} 85};
95 86
96/******************************************************************************* 87/*******************************************************************************
97 * 88 *
98 * FUNCTION: acpi_rs_encode_general_flags 89 * acpi_rs_convert_address32 - All DWORD (32-bit) address resources
99 *
100 * PARAMETERS: Resource - Address resource data struct
101 *
102 * RETURN: Encoded general flag byte
103 *
104 * DESCRIPTION: Construct a general flag byte from an address resource struct
105 * 90 *
106 ******************************************************************************/ 91 ******************************************************************************/
107 92
108static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) 93struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {
109{ 94 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
110 u8 flags; 95 ACPI_RS_SIZE(struct acpi_resource_address32),
111 96 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)},
112 ACPI_FUNCTION_ENTRY();
113
114 /* Producer / Consumer - flag bit[0] */
115
116 flags = (u8) (resource->address.producer_consumer & 0x01);
117
118 /* Decode (_DEC) - flag bit[1] */
119
120 flags |= (u8) ((resource->address.decode & 0x01) << 1);
121
122 /* Min Address Fixed (_MIF) - flag bit[2] */
123
124 flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2);
125 97
126 /* Max Address Fixed (_MAF) - flag bit[3] */ 98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
99 sizeof(struct aml_resource_address32),
100 0},
127 101
128 flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); 102 /* Resource Type, General Flags, and Type-Specific Flags */
129 103
130 return (flags); 104 {ACPI_RSC_ADDRESS, 0, 0, 0},
131}
132
133/*******************************************************************************
134 *
135 * FUNCTION: acpi_rs_decode_specific_flags
136 *
137 * PARAMETERS: Resource - Address resource data struct
138 * Flags - Actual flag byte
139 *
140 * RETURN: Decoded flag bits in attribute struct
141 *
142 * DESCRIPTION: Decode a type-specific flag byte to an attribute struct.
143 * Type-specific flags are only defined for the Memory and IO
144 * resource types.
145 *
146 ******************************************************************************/
147 105
148static void 106 /*
149acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) 107 * These fields are contiguous in both the source and destination:
150{ 108 * Address Granularity
151 ACPI_FUNCTION_ENTRY(); 109 * Address Range Minimum
152 110 * Address Range Maximum
153 if (resource->address.resource_type == ACPI_MEMORY_RANGE) { 111 * Address Translation Offset
154 /* Write Status (_RW) - flag bit[0] */ 112 * Address Length
155 113 */
156 resource->address.attribute.memory.read_write_attribute = 114 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity),
157 (u16) (flags & 0x01); 115 AML_OFFSET(address32.granularity),
158 116 5},
159 /* Memory Attributes (_MEM) - flag bits[2:1] */
160
161 resource->address.attribute.memory.cache_attribute =
162 (u16) ((flags >> 1) & 0x03);
163 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
164 /* Ranges (_RNG) - flag bits[1:0] */
165
166 resource->address.attribute.io.range_attribute =
167 (u16) (flags & 0x03);
168 117
169 /* Translations (_TTP and _TRS) - flag bits[5:4] */ 118 /* Optional resource_source (Index and String) */
170 119
171 resource->address.attribute.io.translation_attribute = 120 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source),
172 (u16) ((flags >> 4) & 0x03); 121 0,
173 } 122 sizeof(struct aml_resource_address32)}
174} 123};
175 124
176/******************************************************************************* 125/*******************************************************************************
177 * 126 *
178 * FUNCTION: acpi_rs_encode_specific_flags 127 * acpi_rs_convert_address64 - All QWORD (64-bit) address resources
179 *
180 * PARAMETERS: Resource - Address resource data struct
181 *
182 * RETURN: Encoded type-specific flag byte
183 *
184 * DESCRIPTION: Construct a type-specific flag byte from an attribute struct.
185 * Type-specific flags are only defined for the Memory and IO
186 * resource types.
187 * 128 *
188 ******************************************************************************/ 129 ******************************************************************************/
189 130
190static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) 131struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {
191{ 132 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
192 u8 flags = 0; 133 ACPI_RS_SIZE(struct acpi_resource_address64),
193 134 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)},
194 ACPI_FUNCTION_ENTRY();
195
196 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
197 /* Write Status (_RW) - flag bit[0] */
198 135
199 flags = (u8) 136 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
200 (resource->address.attribute.memory. 137 sizeof(struct aml_resource_address64),
201 read_write_attribute & 0x01); 138 0},
202 139
203 /* Memory Attributes (_MEM) - flag bits[2:1] */ 140 /* Resource Type, General Flags, and Type-Specific Flags */
204 141
205 flags |= (u8) 142 {ACPI_RSC_ADDRESS, 0, 0, 0},
206 ((resource->address.attribute.memory.
207 cache_attribute & 0x03) << 1);
208 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
209 /* Ranges (_RNG) - flag bits[1:0] */
210 143
211 flags = (u8) 144 /*
212 (resource->address.attribute.io.range_attribute & 0x03); 145 * These fields are contiguous in both the source and destination:
146 * Address Granularity
147 * Address Range Minimum
148 * Address Range Maximum
149 * Address Translation Offset
150 * Address Length
151 */
152 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity),
153 AML_OFFSET(address64.granularity),
154 5},
213 155
214 /* Translations (_TTP and _TRS) - flag bits[5:4] */ 156 /* Optional resource_source (Index and String) */
215 157
216 flags |= (u8) 158 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source),
217 ((resource->address.attribute.io. 159 0,
218 translation_attribute & 0x03) << 4); 160 sizeof(struct aml_resource_address64)}
219 } 161};
220
221 return (flags);
222}
223 162
224/******************************************************************************* 163/*******************************************************************************
225 * 164 *
226 * FUNCTION: acpi_rs_address16_resource 165 * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources
227 *
228 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
229 * stream
230 * bytes_consumed - Pointer to where the number of bytes
231 * consumed the byte_stream_buffer is
232 * returned
233 * output_buffer - Pointer to the return data buffer
234 * structure_size - Pointer to where the number of bytes
235 * in the return data struct is returned
236 *
237 * RETURN: Status
238 *
239 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
240 * structure pointed to by the output_buffer. Return the
241 * number of bytes consumed from the byte stream.
242 * 166 *
243 ******************************************************************************/ 167 ******************************************************************************/
244 168
245acpi_status 169struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
246acpi_rs_address16_resource(u8 * byte_stream_buffer, 170 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
247 acpi_size * bytes_consumed, 171 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
248 u8 ** output_buffer, acpi_size * structure_size) 172 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)},
249{
250 u32 index;
251 u16 temp16;
252 u8 temp8;
253 u8 *temp_ptr;
254 u8 *buffer = byte_stream_buffer;
255 struct acpi_resource *output_struct = (void *)*output_buffer;
256 acpi_size struct_size =
257 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16);
258
259 ACPI_FUNCTION_TRACE("rs_address16_resource");
260
261 /* Get the Descriptor Length field */
262
263 buffer += 1;
264 ACPI_MOVE_16_TO_16(&temp16, buffer);
265
266 /* Validate minimum descriptor length */
267
268 if (temp16 < 13) {
269 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
270 }
271
272 *bytes_consumed = temp16 + 3;
273 output_struct->id = ACPI_RSTYPE_ADDRESS16;
274
275 /* Get the Resource Type (Byte3) */
276 173
277 buffer += 2; 174 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
278 temp8 = *buffer; 175 sizeof(struct aml_resource_extended_address64),
176 0},
279 177
280 /* Values 0-2 and 0xC0-0xFF are valid */ 178 /* Resource Type, General Flags, and Type-Specific Flags */
281 179
282 if ((temp8 > 2) && (temp8 < 0xC0)) { 180 {ACPI_RSC_ADDRESS, 0, 0, 0},
283 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
284 }
285
286 output_struct->data.address16.resource_type = temp8;
287
288 /* Get the General Flags (Byte4) */
289
290 buffer += 1;
291 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
292
293 /* Get the Type Specific Flags (Byte5) */
294
295 buffer += 1;
296 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
297
298 /* Get Granularity (Bytes 6-7) */
299
300 buffer += 1;
301 ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer);
302
303 /* Get min_address_range (Bytes 8-9) */
304 181
305 buffer += 2; 182 /* Revision ID */
306 ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range,
307 buffer);
308
309 /* Get max_address_range (Bytes 10-11) */
310
311 buffer += 2;
312 ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range,
313 buffer);
314
315 /* Get address_translation_offset (Bytes 12-13) */
316
317 buffer += 2;
318 ACPI_MOVE_16_TO_32(&output_struct->data.address16.
319 address_translation_offset, buffer);
320
321 /* Get address_length (Bytes 14-15) */
322
323 buffer += 2;
324 ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length,
325 buffer);
326
327 /* Resource Source Index (if present) */
328
329 buffer += 2;
330 183
184 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD),
185 AML_OFFSET(ext_address64.revision_iD),
186 1},
331 /* 187 /*
332 * This will leave us pointing to the Resource Source Index 188 * These fields are contiguous in both the source and destination:
333 * If it is present, then save it off and calculate the 189 * Address Granularity
334 * pointer to where the null terminated string goes: 190 * Address Range Minimum
335 * Each Interrupt takes 32-bits + the 5 bytes of the 191 * Address Range Maximum
336 * stream that are default. 192 * Address Translation Offset
337 * 193 * Address Length
338 * Note: Some resource descriptors will have an additional null, so 194 * Type-Specific Attribute
339 * we add 1 to the length.
340 */ 195 */
341 if (*bytes_consumed > (16 + 1)) { 196 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity),
342 /* Dereference the Index */ 197 AML_OFFSET(ext_address64.granularity),
343 198 6}
344 output_struct->data.address16.resource_source.index = 199};
345 (u32) * buffer;
346
347 /* Point to the String */
348
349 buffer += 1;
350
351 /* Point the String pointer to the end of this structure */
352
353 output_struct->data.address16.resource_source.string_ptr =
354 (char *)((u8 *) output_struct + struct_size);
355
356 temp_ptr = (u8 *)
357 output_struct->data.address16.resource_source.string_ptr;
358
359 /* Copy the resource_source string into the buffer */
360
361 index = 0;
362 while (*buffer) {
363 *temp_ptr = *buffer;
364
365 temp_ptr++;
366 buffer++;
367 index++;
368 }
369
370 /* Add the terminating null and set the string length */
371
372 *temp_ptr = 0;
373 output_struct->data.address16.resource_source.string_length =
374 index + 1;
375
376 /*
377 * In order for the struct_size to fall on a 32-bit boundary,
378 * calculate the length of the string and expand the
379 * struct_size to the next 32-bit boundary.
380 */
381 temp8 = (u8) (index + 1);
382 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
383 } else {
384 output_struct->data.address16.resource_source.index = 0;
385 output_struct->data.address16.resource_source.string_length = 0;
386 output_struct->data.address16.resource_source.string_ptr = NULL;
387 }
388
389 /* Set the Length parameter */
390
391 output_struct->length = (u32) struct_size;
392
393 /* Return the final size of the structure */
394
395 *structure_size = struct_size;
396 return_ACPI_STATUS(AE_OK);
397}
398 200
399/******************************************************************************* 201/*******************************************************************************
400 * 202 *
401 * FUNCTION: acpi_rs_address16_stream 203 * acpi_rs_convert_general_flags - Flags common to all address descriptors
402 *
403 * PARAMETERS: linked_list - Pointer to the resource linked list
404 * output_buffer - Pointer to the user's return buffer
405 * bytes_consumed - Pointer to where the number of bytes
406 * used in the output_buffer is returned
407 *
408 * RETURN: Status
409 *
410 * DESCRIPTION: Take the linked list resource structure and fills in the
411 * the appropriate bytes in a byte stream
412 * 204 *
413 ******************************************************************************/ 205 ******************************************************************************/
414 206
415acpi_status 207static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
416acpi_rs_address16_stream(struct acpi_resource *linked_list, 208 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags),
417 u8 ** output_buffer, acpi_size * bytes_consumed) 209 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)},
418{
419 u8 *buffer = *output_buffer;
420 u8 *length_field;
421 acpi_size actual_bytes;
422
423 ACPI_FUNCTION_TRACE("rs_address16_stream");
424
425 /* Set the Descriptor Type field */
426
427 *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE;
428 buffer += 1;
429
430 /* Save a pointer to the Length field - to be filled in later */
431
432 length_field = buffer;
433 buffer += 2;
434
435 /* Set the Resource Type (Memory, Io, bus_number) */
436
437 *buffer = (u8) (linked_list->data.address16.resource_type & 0x03);
438 buffer += 1;
439
440 /* Set the general flags */
441
442 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
443 buffer += 1;
444
445 /* Set the type specific flags */
446
447 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
448 buffer += 1;
449
450 /* Set the address space granularity */
451
452 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.granularity);
453 buffer += 2;
454
455 /* Set the address range minimum */
456 210
457 ACPI_MOVE_32_TO_16(buffer, 211 /* Resource Type (Memory, Io, bus_number, etc.) */
458 &linked_list->data.address16.min_address_range);
459 buffer += 2;
460 212
461 /* Set the address range maximum */ 213 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type),
214 AML_OFFSET(address.resource_type),
215 1},
462 216
463 ACPI_MOVE_32_TO_16(buffer, 217 /* General Flags - Consume, Decode, min_fixed, max_fixed */
464 &linked_list->data.address16.max_address_range);
465 buffer += 2;
466 218
467 /* Set the address translation offset */ 219 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
220 AML_OFFSET(address.flags),
221 0},
468 222
469 ACPI_MOVE_32_TO_16(buffer, 223 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode),
470 &linked_list->data.address16. 224 AML_OFFSET(address.flags),
471 address_translation_offset); 225 1},
472 buffer += 2;
473 226
474 /* Set the address length */ 227 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed),
228 AML_OFFSET(address.flags),
229 2},
475 230
476 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.address_length); 231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed),
477 buffer += 2; 232 AML_OFFSET(address.flags),
478 233 3}
479 /* Resource Source Index and Resource Source are optional */ 234};
480
481 if (linked_list->data.address16.resource_source.string_length) {
482 *buffer =
483 (u8) linked_list->data.address16.resource_source.index;
484 buffer += 1;
485
486 /* Copy the resource_source string */
487
488 ACPI_STRCPY((char *)buffer,
489 linked_list->data.address16.resource_source.
490 string_ptr);
491
492 /*
493 * Buffer needs to be set to the length of the string + one for the
494 * terminating null
495 */
496 buffer +=
497 (acpi_size) (ACPI_STRLEN
498 (linked_list->data.address16.resource_source.
499 string_ptr) + 1);
500 }
501
502 /* Return the number of bytes consumed in this operation */
503
504 actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer);
505 *bytes_consumed = actual_bytes;
506
507 /*
508 * Set the length field to the number of bytes consumed
509 * minus the header size (3 bytes)
510 */
511 actual_bytes -= 3;
512 ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes);
513 return_ACPI_STATUS(AE_OK);
514}
515 235
516/******************************************************************************* 236/*******************************************************************************
517 * 237 *
518 * FUNCTION: acpi_rs_address32_resource 238 * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors
519 *
520 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
521 * stream
522 * bytes_consumed - Pointer to where the number of bytes
523 * consumed the byte_stream_buffer is
524 * returned
525 * output_buffer - Pointer to the return data buffer
526 * structure_size - Pointer to where the number of bytes
527 * in the return data struct is returned
528 *
529 * RETURN: Status
530 *
531 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
532 * structure pointed to by the output_buffer. Return the
533 * number of bytes consumed from the byte stream.
534 * 239 *
535 ******************************************************************************/ 240 ******************************************************************************/
536 241
537acpi_status 242static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = {
538acpi_rs_address32_resource(u8 * byte_stream_buffer, 243 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
539 acpi_size * bytes_consumed, 244 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)},
540 u8 ** output_buffer, acpi_size * structure_size)
541{
542 u16 temp16;
543 u8 temp8;
544 u8 *temp_ptr;
545 u32 index;
546 u8 *buffer = byte_stream_buffer;
547 struct acpi_resource *output_struct = (void *)*output_buffer;
548 acpi_size struct_size =
549 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32);
550 245
551 ACPI_FUNCTION_TRACE("rs_address32_resource"); 246 /* Memory-specific flags */
552 247
553 /* Get the Descriptor Length field */ 248 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect),
249 AML_OFFSET(address.specific_flags),
250 0},
554 251
555 buffer += 1; 252 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching),
556 ACPI_MOVE_16_TO_16(&temp16, buffer); 253 AML_OFFSET(address.specific_flags),
254 1},
557 255
558 /* Validate minimum descriptor length */ 256 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type),
257 AML_OFFSET(address.specific_flags),
258 3},
559 259
560 if (temp16 < 23) { 260 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation),
561 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 261 AML_OFFSET(address.specific_flags),
562 } 262 5}
563 263};
564 *bytes_consumed = temp16 + 3;
565 output_struct->id = ACPI_RSTYPE_ADDRESS32;
566
567 /* Get the Resource Type (Byte3) */
568
569 buffer += 2;
570 temp8 = *buffer;
571
572 /* Values 0-2 and 0xC0-0xFF are valid */
573
574 if ((temp8 > 2) && (temp8 < 0xC0)) {
575 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
576 }
577
578 output_struct->data.address32.resource_type = temp8;
579
580 /* Get the General Flags (Byte4) */
581
582 buffer += 1;
583 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
584
585 /* Get the Type Specific Flags (Byte5) */
586
587 buffer += 1;
588 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
589
590 /* Get Granularity (Bytes 6-9) */
591
592 buffer += 1;
593 ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer);
594
595 /* Get min_address_range (Bytes 10-13) */
596
597 buffer += 4;
598 ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range,
599 buffer);
600
601 /* Get max_address_range (Bytes 14-17) */
602
603 buffer += 4;
604 ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range,
605 buffer);
606
607 /* Get address_translation_offset (Bytes 18-21) */
608
609 buffer += 4;
610 ACPI_MOVE_32_TO_32(&output_struct->data.address32.
611 address_translation_offset, buffer);
612
613 /* Get address_length (Bytes 22-25) */
614
615 buffer += 4;
616 ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length,
617 buffer);
618
619 /* Resource Source Index (if present) */
620
621 buffer += 4;
622
623 /*
624 * This will leave us pointing to the Resource Source Index
625 * If it is present, then save it off and calculate the
626 * pointer to where the null terminated string goes:
627 *
628 * Note: Some resource descriptors will have an additional null, so
629 * we add 1 to the length.
630 */
631 if (*bytes_consumed > (26 + 1)) {
632 /* Dereference the Index */
633
634 output_struct->data.address32.resource_source.index =
635 (u32) * buffer;
636
637 /* Point to the String */
638
639 buffer += 1;
640
641 /* Point the String pointer to the end of this structure */
642
643 output_struct->data.address32.resource_source.string_ptr =
644 (char *)((u8 *) output_struct + struct_size);
645
646 temp_ptr = (u8 *)
647 output_struct->data.address32.resource_source.string_ptr;
648
649 /* Copy the resource_source string into the buffer */
650
651 index = 0;
652 while (*buffer) {
653 *temp_ptr = *buffer;
654
655 temp_ptr++;
656 buffer++;
657 index++;
658 }
659
660 /* Add the terminating null and set the string length */
661
662 *temp_ptr = 0;
663 output_struct->data.address32.resource_source.string_length =
664 index + 1;
665
666 /*
667 * In order for the struct_size to fall on a 32-bit boundary,
668 * calculate the length of the string and expand the
669 * struct_size to the next 32-bit boundary.
670 */
671 temp8 = (u8) (index + 1);
672 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
673 } else {
674 output_struct->data.address32.resource_source.index = 0;
675 output_struct->data.address32.resource_source.string_length = 0;
676 output_struct->data.address32.resource_source.string_ptr = NULL;
677 }
678
679 /* Set the Length parameter */
680
681 output_struct->length = (u32) struct_size;
682
683 /* Return the final size of the structure */
684
685 *structure_size = struct_size;
686 return_ACPI_STATUS(AE_OK);
687}
688 264
689/******************************************************************************* 265/*******************************************************************************
690 * 266 *
691 * FUNCTION: acpi_rs_address32_stream 267 * acpi_rs_convert_io_flags - Flags common to I/O address descriptors
692 *
693 * PARAMETERS: linked_list - Pointer to the resource linked list
694 * output_buffer - Pointer to the user's return buffer
695 * bytes_consumed - Pointer to where the number of bytes
696 * used in the output_buffer is returned
697 *
698 * RETURN: Status
699 *
700 * DESCRIPTION: Take the linked list resource structure and fills in the
701 * the appropriate bytes in a byte stream
702 * 268 *
703 ******************************************************************************/ 269 ******************************************************************************/
704 270
705acpi_status 271static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
706acpi_rs_address32_stream(struct acpi_resource *linked_list, 272 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
707 u8 ** output_buffer, acpi_size * bytes_consumed) 273 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)},
708{
709 u8 *buffer;
710 u16 *length_field;
711
712 ACPI_FUNCTION_TRACE("rs_address32_stream");
713
714 buffer = *output_buffer;
715
716 /* Set the Descriptor Type field */
717
718 *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE;
719 buffer += 1;
720
721 /* Save a pointer to the Length field - to be filled in later */
722
723 length_field = ACPI_CAST_PTR(u16, buffer);
724 buffer += 2;
725
726 /* Set the Resource Type (Memory, Io, bus_number) */
727
728 *buffer = (u8) (linked_list->data.address32.resource_type & 0x03);
729 buffer += 1;
730
731 /* Set the general flags */
732
733 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
734 buffer += 1;
735
736 /* Set the type specific flags */
737
738 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
739 buffer += 1;
740
741 /* Set the address space granularity */
742
743 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.granularity);
744 buffer += 4;
745
746 /* Set the address range minimum */
747
748 ACPI_MOVE_32_TO_32(buffer,
749 &linked_list->data.address32.min_address_range);
750 buffer += 4;
751
752 /* Set the address range maximum */
753
754 ACPI_MOVE_32_TO_32(buffer,
755 &linked_list->data.address32.max_address_range);
756 buffer += 4;
757
758 /* Set the address translation offset */
759
760 ACPI_MOVE_32_TO_32(buffer,
761 &linked_list->data.address32.
762 address_translation_offset);
763 buffer += 4;
764
765 /* Set the address length */
766
767 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.address_length);
768 buffer += 4;
769 274
770 /* Resource Source Index and Resource Source are optional */ 275 /* I/O-specific flags */
771 276
772 if (linked_list->data.address32.resource_source.string_length) { 277 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type),
773 *buffer = 278 AML_OFFSET(address.specific_flags),
774 (u8) linked_list->data.address32.resource_source.index; 279 0},
775 buffer += 1;
776 280
777 /* Copy the resource_source string */ 281 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation),
282 AML_OFFSET(address.specific_flags),
283 4},
778 284
779 ACPI_STRCPY((char *)buffer, 285 {ACPI_RSC_1BITFLAG,
780 linked_list->data.address32.resource_source. 286 ACPI_RS_OFFSET(data.address.info.io.translation_type),
781 string_ptr); 287 AML_OFFSET(address.specific_flags),
782 288 5}
783 /* 289};
784 * Buffer needs to be set to the length of the string + one for the
785 * terminating null
786 */
787 buffer +=
788 (acpi_size) (ACPI_STRLEN
789 (linked_list->data.address32.resource_source.
790 string_ptr) + 1);
791 }
792
793 /* Return the number of bytes consumed in this operation */
794
795 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
796
797 /*
798 * Set the length field to the number of bytes consumed
799 * minus the header size (3 bytes)
800 */
801 *length_field = (u16) (*bytes_consumed - 3);
802 return_ACPI_STATUS(AE_OK);
803}
804 290
805/******************************************************************************* 291/*******************************************************************************
806 * 292 *
807 * FUNCTION: acpi_rs_address64_resource 293 * FUNCTION: acpi_rs_get_address_common
808 * 294 *
809 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 295 * PARAMETERS: Resource - Pointer to the internal resource struct
810 * stream 296 * Aml - Pointer to the AML resource descriptor
811 * bytes_consumed - Pointer to where the number of bytes
812 * consumed the byte_stream_buffer is
813 * returned
814 * output_buffer - Pointer to the return data buffer
815 * structure_size - Pointer to where the number of bytes
816 * in the return data struct is returned
817 * 297 *
818 * RETURN: Status 298 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
819 * 299 *
820 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 300 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
821 * structure pointed to by the output_buffer. Return the 301 * to an internal resource descriptor
822 * number of bytes consumed from the byte stream.
823 * 302 *
824 ******************************************************************************/ 303 ******************************************************************************/
825 304
826acpi_status 305u8
827acpi_rs_address64_resource(u8 * byte_stream_buffer, 306acpi_rs_get_address_common(struct acpi_resource *resource,
828 acpi_size * bytes_consumed, 307 union aml_resource *aml)
829 u8 ** output_buffer, acpi_size * structure_size)
830{ 308{
831 u16 temp16; 309 ACPI_FUNCTION_ENTRY();
832 u8 temp8;
833 u8 resource_type;
834 u8 *temp_ptr;
835 u32 index;
836 u8 *buffer = byte_stream_buffer;
837 struct acpi_resource *output_struct = (void *)*output_buffer;
838 acpi_size struct_size =
839 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64);
840
841 ACPI_FUNCTION_TRACE("rs_address64_resource");
842
843 /* Get the Descriptor Type */
844
845 resource_type = *buffer;
846
847 /* Get the Descriptor Length field */
848
849 buffer += 1;
850 ACPI_MOVE_16_TO_16(&temp16, buffer);
851
852 /* Validate minimum descriptor length */
853
854 if (temp16 < 43) {
855 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
856 }
857
858 *bytes_consumed = temp16 + 3;
859 output_struct->id = ACPI_RSTYPE_ADDRESS64;
860
861 /* Get the Resource Type (Byte3) */
862
863 buffer += 2;
864 temp8 = *buffer;
865
866 /* Values 0-2 and 0xC0-0xFF are valid */
867
868 if ((temp8 > 2) && (temp8 < 0xC0)) {
869 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
870 }
871
872 output_struct->data.address64.resource_type = temp8;
873
874 /* Get the General Flags (Byte4) */
875
876 buffer += 1;
877 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
878
879 /* Get the Type Specific Flags (Byte5) */
880
881 buffer += 1;
882 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
883 310
884 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 311 /* Validate the Resource Type */
885 /* Move past revision_id and Reserved byte */
886 312
887 buffer += 2; 313 if ((aml->address.resource_type > 2)
314 && (aml->address.resource_type < 0xC0)) {
315 return (FALSE);
888 } 316 }
889 317
890 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ 318 /* Get the Resource Type and General Flags */
891
892 buffer += 1;
893 ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer);
894
895 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
896
897 buffer += 8;
898 ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range,
899 buffer);
900
901 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
902
903 buffer += 8;
904 ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range,
905 buffer);
906
907 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
908
909 buffer += 8;
910 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
911 address_translation_offset, buffer);
912 319
913 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ 320 (void)acpi_rs_convert_aml_to_resource(resource, aml,
321 acpi_rs_convert_general_flags);
914 322
915 buffer += 8; 323 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
916 ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length,
917 buffer);
918 324
919 output_struct->data.address64.resource_source.index = 0; 325 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
920 output_struct->data.address64.resource_source.string_length = 0; 326 (void)acpi_rs_convert_aml_to_resource(resource, aml,
921 output_struct->data.address64.resource_source.string_ptr = NULL; 327 acpi_rs_convert_mem_flags);
922 328 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
923 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 329 (void)acpi_rs_convert_aml_to_resource(resource, aml,
924 /* Get type_specific_attribute (Bytes 48-55) */ 330 acpi_rs_convert_io_flags);
925
926 buffer += 8;
927 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
928 type_specific_attributes, buffer);
929 } else { 331 } else {
930 output_struct->data.address64.type_specific_attributes = 0; 332 /* Generic resource type, just grab the type_specific byte */
931
932 /* Resource Source Index (if present) */
933
934 buffer += 8;
935
936 /*
937 * This will leave us pointing to the Resource Source Index
938 * If it is present, then save it off and calculate the
939 * pointer to where the null terminated string goes:
940 * Each Interrupt takes 32-bits + the 5 bytes of the
941 * stream that are default.
942 *
943 * Note: Some resource descriptors will have an additional null, so
944 * we add 1 to the length.
945 */
946 if (*bytes_consumed > (46 + 1)) {
947 /* Dereference the Index */
948
949 output_struct->data.address64.resource_source.index =
950 (u32) * buffer;
951
952 /* Point to the String */
953
954 buffer += 1;
955
956 /* Point the String pointer to the end of this structure */
957
958 output_struct->data.address64.resource_source.
959 string_ptr =
960 (char *)((u8 *) output_struct + struct_size);
961
962 temp_ptr = (u8 *)
963 output_struct->data.address64.resource_source.
964 string_ptr;
965
966 /* Copy the resource_source string into the buffer */
967
968 index = 0;
969 while (*buffer) {
970 *temp_ptr = *buffer;
971
972 temp_ptr++;
973 buffer++;
974 index++;
975 }
976
977 /*
978 * Add the terminating null and set the string length
979 */
980 *temp_ptr = 0;
981 output_struct->data.address64.resource_source.
982 string_length = index + 1;
983
984 /*
985 * In order for the struct_size to fall on a 32-bit boundary,
986 * calculate the length of the string and expand the
987 * struct_size to the next 32-bit boundary.
988 */
989 temp8 = (u8) (index + 1);
990 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
991 }
992 }
993
994 /* Set the Length parameter */
995
996 output_struct->length = (u32) struct_size;
997 333
998 /* Return the final size of the structure */ 334 resource->data.address.info.type_specific =
335 aml->address.specific_flags;
336 }
999 337
1000 *structure_size = struct_size; 338 return (TRUE);
1001 return_ACPI_STATUS(AE_OK);
1002} 339}
1003 340
1004/******************************************************************************* 341/*******************************************************************************
1005 * 342 *
1006 * FUNCTION: acpi_rs_address64_stream 343 * FUNCTION: acpi_rs_set_address_common
1007 * 344 *
1008 * PARAMETERS: linked_list - Pointer to the resource linked list 345 * PARAMETERS: Aml - Pointer to the AML resource descriptor
1009 * output_buffer - Pointer to the user's return buffer 346 * Resource - Pointer to the internal resource struct
1010 * bytes_consumed - Pointer to where the number of bytes
1011 * used in the output_buffer is returned
1012 * 347 *
1013 * RETURN: Status 348 * RETURN: None
1014 * 349 *
1015 * DESCRIPTION: Take the linked list resource structure and fills in the 350 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
1016 * the appropriate bytes in a byte stream 351 * AML descriptor
1017 * 352 *
1018 ******************************************************************************/ 353 ******************************************************************************/
1019 354
1020acpi_status 355void
1021acpi_rs_address64_stream(struct acpi_resource *linked_list, 356acpi_rs_set_address_common(union aml_resource *aml,
1022 u8 ** output_buffer, acpi_size * bytes_consumed) 357 struct acpi_resource *resource)
1023{ 358{
1024 u8 *buffer; 359 ACPI_FUNCTION_ENTRY();
1025 u16 *length_field;
1026
1027 ACPI_FUNCTION_TRACE("rs_address64_stream");
1028
1029 buffer = *output_buffer;
1030
1031 /* Set the Descriptor Type field */
1032
1033 *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
1034 buffer += 1;
1035
1036 /* Save a pointer to the Length field - to be filled in later */
1037
1038 length_field = ACPI_CAST_PTR(u16, buffer);
1039 buffer += 2;
1040
1041 /* Set the Resource Type (Memory, Io, bus_number) */
1042
1043 *buffer = (u8) (linked_list->data.address64.resource_type & 0x03);
1044 buffer += 1;
1045
1046 /* Set the general flags */
1047
1048 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
1049 buffer += 1;
1050
1051 /* Set the type specific flags */
1052
1053 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
1054 buffer += 1;
1055
1056 /* Set the address space granularity */
1057
1058 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.granularity);
1059 buffer += 8;
1060
1061 /* Set the address range minimum */
1062
1063 ACPI_MOVE_64_TO_64(buffer,
1064 &linked_list->data.address64.min_address_range);
1065 buffer += 8;
1066
1067 /* Set the address range maximum */
1068
1069 ACPI_MOVE_64_TO_64(buffer,
1070 &linked_list->data.address64.max_address_range);
1071 buffer += 8;
1072
1073 /* Set the address translation offset */
1074
1075 ACPI_MOVE_64_TO_64(buffer,
1076 &linked_list->data.address64.
1077 address_translation_offset);
1078 buffer += 8;
1079
1080 /* Set the address length */
1081
1082 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.address_length);
1083 buffer += 8;
1084 360
1085 /* Resource Source Index and Resource Source are optional */ 361 /* Set the Resource Type and General Flags */
1086 362
1087 if (linked_list->data.address64.resource_source.string_length) { 363 (void)acpi_rs_convert_resource_to_aml(resource, aml,
1088 *buffer = 364 acpi_rs_convert_general_flags);
1089 (u8) linked_list->data.address64.resource_source.index;
1090 buffer += 1;
1091 365
1092 /* Copy the resource_source string */ 366 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
1093 367
1094 ACPI_STRCPY((char *)buffer, 368 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
1095 linked_list->data.address64.resource_source. 369 (void)acpi_rs_convert_resource_to_aml(resource, aml,
1096 string_ptr); 370 acpi_rs_convert_mem_flags);
371 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
372 (void)acpi_rs_convert_resource_to_aml(resource, aml,
373 acpi_rs_convert_io_flags);
374 } else {
375 /* Generic resource type, just copy the type_specific byte */
1097 376
1098 /* 377 aml->address.specific_flags =
1099 * Buffer needs to be set to the length of the string + one for the 378 resource->data.address.info.type_specific;
1100 * terminating null
1101 */
1102 buffer +=
1103 (acpi_size) (ACPI_STRLEN
1104 (linked_list->data.address64.resource_source.
1105 string_ptr) + 1);
1106 } 379 }
1107
1108 /* Return the number of bytes consumed in this operation */
1109
1110 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
1111
1112 /*
1113 * Set the length field to the number of bytes consumed
1114 * minus the header size (3 bytes)
1115 */
1116 *length_field = (u16) (*bytes_consumed - 3);
1117 return_ACPI_STATUS(AE_OK);
1118} 380}
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 378f58390fc1..7d6481d9fbec 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,652 +49,433 @@
49#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
50ACPI_MODULE_NAME("rscalc") 50ACPI_MODULE_NAME("rscalc")
51 51
52/* Local prototypes */
53static u8 acpi_rs_count_set_bits(u16 bit_field);
54
55static acpi_rs_length
56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
57
58static u32
59acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length);
60
52/******************************************************************************* 61/*******************************************************************************
53 * 62 *
54 * FUNCTION: acpi_rs_get_byte_stream_length 63 * FUNCTION: acpi_rs_count_set_bits
55 * 64 *
56 * PARAMETERS: linked_list - Pointer to the resource linked list 65 * PARAMETERS: bit_field - Field in which to count bits
57 * size_needed - u32 pointer of the size buffer needed
58 * to properly return the parsed data
59 * 66 *
60 * RETURN: Status 67 * RETURN: Number of bits set within the field
61 * 68 *
62 * DESCRIPTION: Takes the resource byte stream and parses it once, calculating 69 * DESCRIPTION: Count the number of bits set in a resource field. Used for
63 * the size buffer needed to hold the linked list that conveys 70 * (Short descriptor) interrupt and DMA lists.
64 * the resource data.
65 * 71 *
66 ******************************************************************************/ 72 ******************************************************************************/
67acpi_status
68acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list,
69 acpi_size * size_needed)
70{
71 acpi_size byte_stream_size_needed = 0;
72 acpi_size segment_size;
73 u8 done = FALSE;
74
75 ACPI_FUNCTION_TRACE("rs_get_byte_stream_length");
76
77 while (!done) {
78 /* Init the variable that will hold the size to add to the total. */
79
80 segment_size = 0;
81
82 switch (linked_list->id) {
83 case ACPI_RSTYPE_IRQ:
84 /*
85 * IRQ Resource
86 * For an IRQ Resource, Byte 3, although optional, will always be
87 * created - it holds IRQ information.
88 */
89 segment_size = 4;
90 break;
91
92 case ACPI_RSTYPE_DMA:
93 /*
94 * DMA Resource
95 * For this resource the size is static
96 */
97 segment_size = 3;
98 break;
99
100 case ACPI_RSTYPE_START_DPF:
101 /*
102 * Start Dependent Functions Resource
103 * For a start_dependent_functions Resource, Byte 1, although
104 * optional, will always be created.
105 */
106 segment_size = 2;
107 break;
108
109 case ACPI_RSTYPE_END_DPF:
110 /*
111 * End Dependent Functions Resource
112 * For this resource the size is static
113 */
114 segment_size = 1;
115 break;
116
117 case ACPI_RSTYPE_IO:
118 /*
119 * IO Port Resource
120 * For this resource the size is static
121 */
122 segment_size = 8;
123 break;
124 73
125 case ACPI_RSTYPE_FIXED_IO: 74static u8 acpi_rs_count_set_bits(u16 bit_field)
126 /* 75{
127 * Fixed IO Port Resource 76 u8 bits_set;
128 * For this resource the size is static
129 */
130 segment_size = 4;
131 break;
132
133 case ACPI_RSTYPE_VENDOR:
134 /*
135 * Vendor Defined Resource
136 * For a Vendor Specific resource, if the Length is between 1 and 7
137 * it will be created as a Small Resource data type, otherwise it
138 * is a Large Resource data type.
139 */
140 if (linked_list->data.vendor_specific.length > 7) {
141 segment_size = 3;
142 } else {
143 segment_size = 1;
144 }
145 segment_size +=
146 linked_list->data.vendor_specific.length;
147 break;
148
149 case ACPI_RSTYPE_END_TAG:
150 /*
151 * End Tag
152 * For this resource the size is static
153 */
154 segment_size = 2;
155 done = TRUE;
156 break;
157
158 case ACPI_RSTYPE_MEM24:
159 /*
160 * 24-Bit Memory Resource
161 * For this resource the size is static
162 */
163 segment_size = 12;
164 break;
165 77
166 case ACPI_RSTYPE_MEM32: 78 ACPI_FUNCTION_ENTRY();
167 /*
168 * 32-Bit Memory Range Resource
169 * For this resource the size is static
170 */
171 segment_size = 20;
172 break;
173 79
174 case ACPI_RSTYPE_FIXED_MEM32: 80 for (bits_set = 0; bit_field; bits_set++) {
175 /* 81 /* Zero the least significant bit that is set */
176 * 32-Bit Fixed Memory Resource
177 * For this resource the size is static
178 */
179 segment_size = 12;
180 break;
181 82
182 case ACPI_RSTYPE_ADDRESS16: 83 bit_field &= (bit_field - 1);
183 /* 84 }
184 * 16-Bit Address Resource
185 * The base size of this byte stream is 16. If a Resource Source
186 * string is not NULL, add 1 for the Index + the length of the null
187 * terminated string Resource Source + 1 for the null.
188 */
189 segment_size = 16;
190
191 if (linked_list->data.address16.resource_source.
192 string_ptr) {
193 segment_size +=
194 linked_list->data.address16.resource_source.
195 string_length;
196 segment_size++;
197 }
198 break;
199 85
200 case ACPI_RSTYPE_ADDRESS32: 86 return (bits_set);
201 /* 87}
202 * 32-Bit Address Resource
203 * The base size of this byte stream is 26. If a Resource
204 * Source string is not NULL, add 1 for the Index + the
205 * length of the null terminated string Resource Source +
206 * 1 for the null.
207 */
208 segment_size = 26;
209
210 if (linked_list->data.address32.resource_source.
211 string_ptr) {
212 segment_size +=
213 linked_list->data.address32.resource_source.
214 string_length;
215 segment_size++;
216 }
217 break;
218 88
219 case ACPI_RSTYPE_ADDRESS64: 89/*******************************************************************************
220 /* 90 *
221 * 64-Bit Address Resource 91 * FUNCTION: acpi_rs_struct_option_length
222 * The base size of this byte stream is 46. If a resource_source 92 *
223 * string is not NULL, add 1 for the Index + the length of the null 93 * PARAMETERS: resource_source - Pointer to optional descriptor field
224 * terminated string Resource Source + 1 for the null. 94 *
225 */ 95 * RETURN: Status
226 segment_size = 46; 96 *
227 97 * DESCRIPTION: Common code to handle optional resource_source_index and
228 if (linked_list->data.address64.resource_source. 98 * resource_source fields in some Large descriptors. Used during
229 string_ptr) { 99 * list-to-stream conversion
230 segment_size += 100 *
231 linked_list->data.address64.resource_source. 101 ******************************************************************************/
232 string_length;
233 segment_size++;
234 }
235 break;
236 102
237 case ACPI_RSTYPE_EXT_IRQ: 103static acpi_rs_length
238 /* 104acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
239 * Extended IRQ Resource 105{
240 * The base size of this byte stream is 9. This is for an Interrupt 106 ACPI_FUNCTION_ENTRY();
241 * table length of 1. For each additional interrupt, add 4.
242 * If a Resource Source string is not NULL, add 1 for the
243 * Index + the length of the null terminated string
244 * Resource Source + 1 for the null.
245 */
246 segment_size = 9 + (((acpi_size)
247 linked_list->data.extended_irq.
248 number_of_interrupts - 1) * 4);
249
250 if (linked_list->data.extended_irq.resource_source.
251 string_ptr) {
252 segment_size +=
253 linked_list->data.extended_irq.
254 resource_source.string_length;
255 segment_size++;
256 }
257 break;
258 107
259 default: 108 /*
109 * If the resource_source string is valid, return the size of the string
110 * (string_length includes the NULL terminator) plus the size of the
111 * resource_source_index (1).
112 */
113 if (resource_source->string_ptr) {
114 return ((acpi_rs_length) (resource_source->string_length + 1));
115 }
260 116
261 /* If we get here, everything is out of sync, exit with error */ 117 return (0);
118}
262 119
263 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 120/*******************************************************************************
121 *
122 * FUNCTION: acpi_rs_stream_option_length
123 *
124 * PARAMETERS: resource_length - Length from the resource header
125 * minimum_total_length - Minimum length of this resource, before
126 * any optional fields. Includes header size
127 *
128 * RETURN: Length of optional string (0 if no string present)
129 *
130 * DESCRIPTION: Common code to handle optional resource_source_index and
131 * resource_source fields in some Large descriptors. Used during
132 * stream-to-list conversion
133 *
134 ******************************************************************************/
264 135
265 } /* switch (linked_list->Id) */ 136static u32
137acpi_rs_stream_option_length(u32 resource_length,
138 u32 minimum_aml_resource_length)
139{
140 u32 string_length = 0;
266 141
267 /* Update the total */ 142 ACPI_FUNCTION_ENTRY();
268 143
269 byte_stream_size_needed += segment_size; 144 /*
145 * The resource_source_index and resource_source are optional elements of some
146 * Large-type resource descriptors.
147 */
270 148
271 /* Point to the next object */ 149 /*
150 * If the length of the actual resource descriptor is greater than the ACPI
151 * spec-defined minimum length, it means that a resource_source_index exists
152 * and is followed by a (required) null terminated string. The string length
153 * (including the null terminator) is the resource length minus the minimum
154 * length, minus one byte for the resource_source_index itself.
155 */
156 if (resource_length > minimum_aml_resource_length) {
157 /* Compute the length of the optional string */
272 158
273 linked_list = ACPI_PTR_ADD(struct acpi_resource, 159 string_length =
274 linked_list, linked_list->length); 160 resource_length - minimum_aml_resource_length - 1;
275 } 161 }
276 162
277 /* This is the data the caller needs */ 163 /* Round up length to 32 bits for internal structure alignment */
278 164
279 *size_needed = byte_stream_size_needed; 165 return (ACPI_ROUND_UP_to_32_bITS(string_length));
280 return_ACPI_STATUS(AE_OK);
281} 166}
282 167
283/******************************************************************************* 168/*******************************************************************************
284 * 169 *
285 * FUNCTION: acpi_rs_get_list_length 170 * FUNCTION: acpi_rs_get_aml_length
286 * 171 *
287 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 172 * PARAMETERS: Resource - Pointer to the resource linked list
288 * byte_stream_buffer_length - Size of byte_stream_buffer 173 * size_needed - Where the required size is returned
289 * size_needed - u32 pointer of the size buffer
290 * needed to properly return the
291 * parsed data
292 * 174 *
293 * RETURN: Status 175 * RETURN: Status
294 * 176 *
295 * DESCRIPTION: Takes the resource byte stream and parses it once, calculating 177 * DESCRIPTION: Takes a linked list of internal resource descriptors and
296 * the size buffer needed to hold the linked list that conveys 178 * calculates the size buffer needed to hold the corresponding
297 * the resource data. 179 * external resource byte stream.
298 * 180 *
299 ******************************************************************************/ 181 ******************************************************************************/
300 182
301acpi_status 183acpi_status
302acpi_rs_get_list_length(u8 * byte_stream_buffer, 184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
303 u32 byte_stream_buffer_length, acpi_size * size_needed)
304{ 185{
305 u32 buffer_size = 0; 186 acpi_size aml_size_needed = 0;
306 u32 bytes_parsed = 0; 187 acpi_rs_length total_size;
307 u8 number_of_interrupts = 0;
308 u8 number_of_channels = 0;
309 u8 resource_type;
310 u32 structure_size;
311 u32 bytes_consumed;
312 u8 *buffer;
313 u8 temp8;
314 u16 temp16;
315 u8 index;
316 u8 additional_bytes;
317
318 ACPI_FUNCTION_TRACE("rs_get_list_length");
319 188
320 while (bytes_parsed < byte_stream_buffer_length) { 189 ACPI_FUNCTION_TRACE("rs_get_aml_length");
321 /* The next byte in the stream is the resource type */
322 190
323 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); 191 /* Traverse entire list of internal resource descriptors */
324 192
325 switch (resource_type) { 193 while (resource) {
326 case ACPI_RDESC_TYPE_MEMORY_24: 194 /* Validate the descriptor type */
327 /*
328 * 24-Bit Memory Resource
329 */
330 bytes_consumed = 12;
331
332 structure_size =
333 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
334 break;
335 195
336 case ACPI_RDESC_TYPE_LARGE_VENDOR: 196 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
337 /* 197 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
338 * Vendor Defined Resource 198 }
339 */
340 buffer = byte_stream_buffer;
341 ++buffer;
342
343 ACPI_MOVE_16_TO_16(&temp16, buffer);
344 bytes_consumed = temp16 + 3;
345
346 /* Ensure a 32-bit boundary for the structure */
347 199
348 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS(temp16); 200 /* Get the base size of the (external stream) resource descriptor */
349 201
350 structure_size = 202 total_size = acpi_gbl_aml_resource_sizes[resource->type];
351 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
352 (temp16 * sizeof(u8));
353 break;
354 203
355 case ACPI_RDESC_TYPE_MEMORY_32: 204 /*
205 * Augment the base size for descriptors with optional and/or
206 * variable-length fields
207 */
208 switch (resource->type) {
209 case ACPI_RESOURCE_TYPE_VENDOR:
356 /* 210 /*
357 * 32-Bit Memory Range Resource 211 * Vendor Defined Resource:
212 * For a Vendor Specific resource, if the Length is between 1 and 7
213 * it will be created as a Small Resource data type, otherwise it
214 * is a Large Resource data type.
358 */ 215 */
359 bytes_consumed = 20; 216 if (resource->data.vendor.byte_length > 7) {
217 /* Base size of a Large resource descriptor */
360 218
361 structure_size = 219 total_size =
362 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); 220 sizeof(struct aml_resource_large_header);
363 break; 221 }
364 222
365 case ACPI_RDESC_TYPE_FIXED_MEMORY_32: 223 /* Add the size of the vendor-specific data */
366 /*
367 * 32-Bit Fixed Memory Resource
368 */
369 bytes_consumed = 12;
370 224
371 structure_size = 225 total_size = (acpi_rs_length)
372 ACPI_SIZEOF_RESOURCE(struct 226 (total_size + resource->data.vendor.byte_length);
373 acpi_resource_fixed_mem32);
374 break; 227 break;
375 228
376 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: 229 case ACPI_RESOURCE_TYPE_END_TAG:
377 /* 230 /*
378 * 64-Bit Address Resource 231 * End Tag:
232 * We are done -- return the accumulated total size.
379 */ 233 */
380 buffer = byte_stream_buffer; 234 *size_needed = aml_size_needed + total_size;
381 235
382 ++buffer; 236 /* Normal exit */
383 ACPI_MOVE_16_TO_16(&temp16, buffer);
384 237
385 bytes_consumed = temp16 + 3; 238 return_ACPI_STATUS(AE_OK);
386 structure_size =
387 ACPI_SIZEOF_RESOURCE(struct
388 acpi_resource_address64);
389 break;
390 239
391 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 240 case ACPI_RESOURCE_TYPE_ADDRESS16:
392 /* 241 /*
393 * 64-Bit Address Resource 242 * 16-Bit Address Resource:
243 * Add the size of the optional resource_source info
394 */ 244 */
395 buffer = byte_stream_buffer; 245 total_size = (acpi_rs_length)
396 246 (total_size +
397 ++buffer; 247 acpi_rs_struct_option_length(&resource->data.
398 ACPI_MOVE_16_TO_16(&temp16, buffer); 248 address16.
399 249 resource_source));
400 bytes_consumed = temp16 + 3; 250 break;
401 251
252 case ACPI_RESOURCE_TYPE_ADDRESS32:
402 /* 253 /*
403 * Resource Source Index and Resource Source are optional elements. 254 * 32-Bit Address Resource:
404 * Check the length of the Bytestream. If it is greater than 43, 255 * Add the size of the optional resource_source info
405 * that means that an Index exists and is followed by a null
406 * terminated string. Therefore, set the temp variable to the
407 * length minus the minimum byte stream length plus the byte for
408 * the Index to determine the size of the NULL terminated string.
409 */ 256 */
410 if (43 < temp16) { 257 total_size = (acpi_rs_length)
411 temp8 = (u8) (temp16 - 44); 258 (total_size +
412 } else { 259 acpi_rs_struct_option_length(&resource->data.
413 temp8 = 0; 260 address32.
414 } 261 resource_source));
415
416 /* Ensure a 64-bit boundary for the structure */
417
418 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS(temp8);
419
420 structure_size =
421 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)
422 + (temp8 * sizeof(u8));
423 break; 262 break;
424 263
425 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 264 case ACPI_RESOURCE_TYPE_ADDRESS64:
426 /* 265 /*
427 * 32-Bit Address Resource 266 * 64-Bit Address Resource:
267 * Add the size of the optional resource_source info
428 */ 268 */
429 buffer = byte_stream_buffer; 269 total_size = (acpi_rs_length)
430 270 (total_size +
431 ++buffer; 271 acpi_rs_struct_option_length(&resource->data.
432 ACPI_MOVE_16_TO_16(&temp16, buffer); 272 address64.
433 273 resource_source));
434 bytes_consumed = temp16 + 3; 274 break;
435 275
276 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
436 /* 277 /*
437 * Resource Source Index and Resource Source are optional elements. 278 * Extended IRQ Resource:
438 * Check the length of the Bytestream. If it is greater than 23, 279 * Add the size of each additional optional interrupt beyond the
439 * that means that an Index exists and is followed by a null 280 * required 1 (4 bytes for each u32 interrupt number)
440 * terminated string. Therefore, set the temp variable to the
441 * length minus the minimum byte stream length plus the byte for
442 * the Index to determine the size of the NULL terminated string.
443 */ 281 */
444 if (23 < temp16) { 282 total_size = (acpi_rs_length)
445 temp8 = (u8) (temp16 - 24); 283 (total_size +
446 } else { 284 ((resource->data.extended_irq.interrupt_count -
447 temp8 = 0; 285 1) * 4) +
448 } 286 /* Add the size of the optional resource_source info */
449 287 acpi_rs_struct_option_length(&resource->data.
450 /* Ensure a 32-bit boundary for the structure */ 288 extended_irq.
451 289 resource_source));
452 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 290 break;
453 291
454 structure_size = 292 default:
455 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)
456 + (temp8 * sizeof(u8));
457 break; 293 break;
294 }
458 295
459 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 296 /* Update the total */
460 /*
461 * 16-Bit Address Resource
462 */
463 buffer = byte_stream_buffer;
464 297
465 ++buffer; 298 aml_size_needed += total_size;
466 ACPI_MOVE_16_TO_16(&temp16, buffer);
467 299
468 bytes_consumed = temp16 + 3; 300 /* Point to the next object */
469 301
470 /* 302 resource =
471 * Resource Source Index and Resource Source are optional elements. 303 ACPI_ADD_PTR(struct acpi_resource, resource,
472 * Check the length of the Bytestream. If it is greater than 13, 304 resource->length);
473 * that means that an Index exists and is followed by a null 305 }
474 * terminated string. Therefore, set the temp variable to the
475 * length minus the minimum byte stream length plus the byte for
476 * the Index to determine the size of the NULL terminated string.
477 */
478 if (13 < temp16) {
479 temp8 = (u8) (temp16 - 14);
480 } else {
481 temp8 = 0;
482 }
483 306
484 /* Ensure a 32-bit boundary for the structure */ 307 /* Did not find an end_tag resource descriptor */
485 308
486 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 309 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
310}
487 311
488 structure_size = 312/*******************************************************************************
489 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) 313 *
490 + (temp8 * sizeof(u8)); 314 * FUNCTION: acpi_rs_get_list_length
491 break; 315 *
316 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
317 * aml_buffer_length - Size of aml_buffer
318 * size_needed - Where the size needed is returned
319 *
320 * RETURN: Status
321 *
322 * DESCRIPTION: Takes an external resource byte stream and calculates the size
323 * buffer needed to hold the corresponding internal resource
324 * descriptor linked list.
325 *
326 ******************************************************************************/
492 327
493 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 328acpi_status
494 /* 329acpi_rs_get_list_length(u8 * aml_buffer,
495 * Extended IRQ 330 u32 aml_buffer_length, acpi_size * size_needed)
496 */ 331{
497 buffer = byte_stream_buffer; 332 acpi_status status;
333 u8 *end_aml;
334 u8 *buffer;
335 u32 buffer_size = 0;
336 u16 temp16;
337 u16 resource_length;
338 u32 extra_struct_bytes;
339 u8 resource_index;
340 u8 minimum_aml_resource_length;
498 341
499 ++buffer; 342 ACPI_FUNCTION_TRACE("rs_get_list_length");
500 ACPI_MOVE_16_TO_16(&temp16, buffer);
501 343
502 bytes_consumed = temp16 + 3; 344 end_aml = aml_buffer + aml_buffer_length;
503 345
504 /* 346 /* Walk the list of AML resource descriptors */
505 * Point past the length field and the Interrupt vector flags to
506 * save off the Interrupt table length to the Temp8 variable.
507 */
508 buffer += 3;
509 temp8 = *buffer;
510 347
511 /* 348 while (aml_buffer < end_aml) {
512 * To compensate for multiple interrupt numbers, add 4 bytes for 349 /* Validate the Resource Type and Resource Length */
513 * each additional interrupts greater than 1
514 */
515 additional_bytes = (u8) ((temp8 - 1) * 4);
516 350
517 /* 351 status = acpi_ut_validate_resource(aml_buffer, &resource_index);
518 * Resource Source Index and Resource Source are optional elements. 352 if (ACPI_FAILURE(status)) {
519 * Check the length of the Bytestream. If it is greater than 9, 353 return_ACPI_STATUS(status);
520 * that means that an Index exists and is followed by a null 354 }
521 * terminated string. Therefore, set the temp variable to the
522 * length minus the minimum byte stream length plus the byte for
523 * the Index to determine the size of the NULL terminated string.
524 */
525 if (9 + additional_bytes < temp16) {
526 temp8 = (u8) (temp16 - (9 + additional_bytes));
527 } else {
528 temp8 = 0;
529 }
530 355
531 /* Ensure a 32-bit boundary for the structure */ 356 /* Get the resource length and base (minimum) AML size */
532 357
533 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 358 resource_length = acpi_ut_get_resource_length(aml_buffer);
359 minimum_aml_resource_length =
360 acpi_gbl_resource_aml_sizes[resource_index];
534 361
535 structure_size = 362 /*
536 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq) + 363 * Augment the size for descriptors with optional
537 (additional_bytes * sizeof(u8)) + 364 * and/or variable length fields
538 (temp8 * sizeof(u8)); 365 */
539 break; 366 extra_struct_bytes = 0;
367 buffer =
368 aml_buffer + acpi_ut_get_resource_header_length(aml_buffer);
540 369
541 case ACPI_RDESC_TYPE_IRQ_FORMAT: 370 switch (acpi_ut_get_resource_type(aml_buffer)) {
371 case ACPI_RESOURCE_NAME_IRQ:
542 /* 372 /*
543 * IRQ Resource. 373 * IRQ Resource:
544 * Determine if it there are two or three trailing bytes 374 * Get the number of bits set in the 16-bit IRQ mask
545 */ 375 */
546 buffer = byte_stream_buffer;
547 temp8 = *buffer;
548
549 if (temp8 & 0x01) {
550 bytes_consumed = 4;
551 } else {
552 bytes_consumed = 3;
553 }
554
555 /* Point past the descriptor */
556
557 ++buffer;
558
559 /* Look at the number of bits set */
560
561 ACPI_MOVE_16_TO_16(&temp16, buffer); 376 ACPI_MOVE_16_TO_16(&temp16, buffer);
562 377 extra_struct_bytes = acpi_rs_count_set_bits(temp16);
563 for (index = 0; index < 16; index++) {
564 if (temp16 & 0x1) {
565 ++number_of_interrupts;
566 }
567
568 temp16 >>= 1;
569 }
570
571 structure_size =
572 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io) +
573 (number_of_interrupts * sizeof(u32));
574 break; 378 break;
575 379
576 case ACPI_RDESC_TYPE_DMA_FORMAT: 380 case ACPI_RESOURCE_NAME_DMA:
577 /* 381 /*
578 * DMA Resource 382 * DMA Resource:
383 * Get the number of bits set in the 8-bit DMA mask
579 */ 384 */
580 buffer = byte_stream_buffer; 385 extra_struct_bytes = acpi_rs_count_set_bits(*buffer);
581 bytes_consumed = 3;
582
583 /* Point past the descriptor */
584
585 ++buffer;
586
587 /* Look at the number of bits set */
588
589 temp8 = *buffer;
590
591 for (index = 0; index < 8; index++) {
592 if (temp8 & 0x1) {
593 ++number_of_channels;
594 }
595
596 temp8 >>= 1;
597 }
598
599 structure_size =
600 ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma) +
601 (number_of_channels * sizeof(u32));
602 break; 386 break;
603 387
604 case ACPI_RDESC_TYPE_START_DEPENDENT: 388 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
605 /* 389 /*
606 * Start Dependent Functions Resource 390 * Vendor Resource:
607 * Determine if it there are two or three trailing bytes 391 * Ensure a 32-bit boundary for the structure
608 */ 392 */
609 buffer = byte_stream_buffer; 393 extra_struct_bytes =
610 temp8 = *buffer; 394 ACPI_ROUND_UP_to_32_bITS(resource_length) -
611 395 resource_length;
612 if (temp8 & 0x01) {
613 bytes_consumed = 2;
614 } else {
615 bytes_consumed = 1;
616 }
617
618 structure_size =
619 ACPI_SIZEOF_RESOURCE(struct
620 acpi_resource_start_dpf);
621 break; 396 break;
622 397
623 case ACPI_RDESC_TYPE_END_DEPENDENT: 398 case ACPI_RESOURCE_NAME_END_TAG:
624 /* 399 /*
625 * End Dependent Functions Resource 400 * End Tag: This is the normal exit, add size of end_tag
626 */ 401 */
627 bytes_consumed = 1; 402 *size_needed = buffer_size + ACPI_RS_SIZE_MIN;
628 structure_size = ACPI_RESOURCE_LENGTH; 403 return_ACPI_STATUS(AE_OK);
629 break;
630 404
631 case ACPI_RDESC_TYPE_IO_PORT: 405 case ACPI_RESOURCE_NAME_VENDOR_LARGE:
632 /* 406 /*
633 * IO Port Resource 407 * Vendor Resource:
408 * Add vendor data and ensure a 32-bit boundary for the structure
634 */ 409 */
635 bytes_consumed = 8; 410 extra_struct_bytes =
636 structure_size = 411 ACPI_ROUND_UP_to_32_bITS(resource_length) -
637 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); 412 resource_length;
638 break; 413 break;
639 414
640 case ACPI_RDESC_TYPE_FIXED_IO_PORT: 415 case ACPI_RESOURCE_NAME_ADDRESS32:
416 case ACPI_RESOURCE_NAME_ADDRESS16:
641 /* 417 /*
642 * Fixed IO Port Resource 418 * 32-Bit or 16-bit Address Resource:
419 * Add the size of any optional data (resource_source)
643 */ 420 */
644 bytes_consumed = 4; 421 extra_struct_bytes =
645 structure_size = 422 acpi_rs_stream_option_length(resource_length,
646 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 423 minimum_aml_resource_length);
647 break; 424 break;
648 425
649 case ACPI_RDESC_TYPE_SMALL_VENDOR: 426 case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
650 /* 427 /*
651 * Vendor Specific Resource 428 * Extended IRQ:
429 * Point past the interrupt_vector_flags to get the
430 * interrupt_table_length.
652 */ 431 */
653 buffer = byte_stream_buffer; 432 buffer++;
654 433
655 temp8 = *buffer; 434 extra_struct_bytes =
656 temp8 = (u8) (temp8 & 0x7); 435 /*
657 bytes_consumed = temp8 + 1; 436 * Add 4 bytes for each additional interrupt. Note: at
658 437 * least one interrupt is required and is included in
659 /* Ensure a 32-bit boundary for the structure */ 438 * the minimum descriptor size
660 439 */
661 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 440 ((*buffer - 1) * sizeof(u32)) +
662 structure_size = 441 /* Add the size of any optional data (resource_source) */
663 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + 442 acpi_rs_stream_option_length(resource_length -
664 (temp8 * sizeof(u8)); 443 extra_struct_bytes,
444 minimum_aml_resource_length);
665 break; 445 break;
666 446
667 case ACPI_RDESC_TYPE_END_TAG: 447 case ACPI_RESOURCE_NAME_ADDRESS64:
668 /* 448 /*
669 * End Tag 449 * 64-Bit Address Resource:
450 * Add the size of any optional data (resource_source)
451 * Ensure a 64-bit boundary for the structure
670 */ 452 */
671 bytes_consumed = 2; 453 extra_struct_bytes =
672 structure_size = ACPI_RESOURCE_LENGTH; 454 ACPI_ROUND_UP_to_64_bITS
673 byte_stream_buffer_length = bytes_parsed; 455 (acpi_rs_stream_option_length
456 (resource_length, minimum_aml_resource_length));
674 break; 457 break;
675 458
676 default: 459 default:
677 /* 460 break;
678 * If we get here, everything is out of sync,
679 * exit with an error
680 */
681 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
682 } 461 }
683 462
684 /* Update the return value and counter */ 463 /* Update the required buffer size for the internal descriptor structs */
685
686 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(structure_size);
687 bytes_parsed += bytes_consumed;
688 464
689 /* Set the byte stream to point to the next resource */ 465 temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] +
466 extra_struct_bytes);
467 buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16);
690 468
691 byte_stream_buffer += bytes_consumed; 469 /*
470 * Point to the next resource within the stream
471 * using the size of the header plus the length contained in the header
472 */
473 aml_buffer += acpi_ut_get_descriptor_length(aml_buffer);
692 } 474 }
693 475
694 /* This is the data the caller needs */ 476 /* Did not find an end_tag resource descriptor */
695 477
696 *size_needed = buffer_size; 478 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
697 return_ACPI_STATUS(AE_OK);
698} 479}
699 480
700/******************************************************************************* 481/*******************************************************************************
@@ -760,13 +541,13 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
760 541
761 for (table_index = 0; table_index < 4 && !name_found; 542 for (table_index = 0; table_index < 4 && !name_found;
762 table_index++) { 543 table_index++) {
763 if ((ACPI_TYPE_STRING == 544 if (*sub_object_list && /* Null object allowed */
764 ACPI_GET_OBJECT_TYPE(*sub_object_list)) 545 ((ACPI_TYPE_STRING ==
765 || 546 ACPI_GET_OBJECT_TYPE(*sub_object_list)) ||
766 ((ACPI_TYPE_LOCAL_REFERENCE == 547 ((ACPI_TYPE_LOCAL_REFERENCE ==
767 ACPI_GET_OBJECT_TYPE(*sub_object_list)) 548 ACPI_GET_OBJECT_TYPE(*sub_object_list)) &&
768 && ((*sub_object_list)->reference.opcode == 549 ((*sub_object_list)->reference.opcode ==
769 AML_INT_NAMEPATH_OP))) { 550 AML_INT_NAMEPATH_OP)))) {
770 name_found = TRUE; 551 name_found = TRUE;
771 } else { 552 } else {
772 /* Look at the next element */ 553 /* Look at the next element */
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index 0911526b7ad8..8c128dea3252 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate")
53 * 53 *
54 * FUNCTION: acpi_rs_create_resource_list 54 * FUNCTION: acpi_rs_create_resource_list
55 * 55 *
56 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 56 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
57 * output_buffer - Pointer to the user's buffer 57 * output_buffer - Pointer to the user's buffer
58 * 58 *
59 * RETURN: Status - AE_OK if okay, else a valid acpi_status code 59 * RETURN: Status: AE_OK if okay, else a valid acpi_status code
60 * If output_buffer is not large enough, output_buffer_length 60 * If output_buffer is not large enough, output_buffer_length
61 * indicates how large output_buffer should be, else it 61 * indicates how large output_buffer should be, else it
62 * indicates how may u8 elements of output_buffer are valid. 62 * indicates how may u8 elements of output_buffer are valid.
@@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate")
67 * 67 *
68 ******************************************************************************/ 68 ******************************************************************************/
69acpi_status 69acpi_status
70acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, 70acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
71 struct acpi_buffer *output_buffer) 71 struct acpi_buffer *output_buffer)
72{ 72{
73 73
74 acpi_status status; 74 acpi_status status;
75 u8 *byte_stream_start; 75 u8 *aml_start;
76 acpi_size list_size_needed = 0; 76 acpi_size list_size_needed = 0;
77 u32 byte_stream_buffer_length; 77 u32 aml_buffer_length;
78 78
79 ACPI_FUNCTION_TRACE("rs_create_resource_list"); 79 ACPI_FUNCTION_TRACE("rs_create_resource_list");
80 80
81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", 81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer));
82 byte_stream_buffer));
83 82
84 /* Params already validated, so we don't re-validate here */ 83 /* Params already validated, so we don't re-validate here */
85 84
86 byte_stream_buffer_length = byte_stream_buffer->buffer.length; 85 aml_buffer_length = aml_buffer->buffer.length;
87 byte_stream_start = byte_stream_buffer->buffer.pointer; 86 aml_start = aml_buffer->buffer.pointer;
88 87
89 /* 88 /*
90 * Pass the byte_stream_buffer into a module that can calculate 89 * Pass the aml_buffer into a module that can calculate
91 * the buffer size needed for the linked list 90 * the buffer size needed for the linked list
92 */ 91 */
93 status = 92 status = acpi_rs_get_list_length(aml_start, aml_buffer_length,
94 acpi_rs_get_list_length(byte_stream_start, 93 &list_size_needed);
95 byte_stream_buffer_length,
96 &list_size_needed);
97 94
98 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", 95 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
99 status, (u32) list_size_needed)); 96 status, (u32) list_size_needed));
@@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
110 107
111 /* Do the conversion */ 108 /* Do the conversion */
112 109
113 status = 110 status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length,
114 acpi_rs_byte_stream_to_list(byte_stream_start, 111 output_buffer->pointer);
115 byte_stream_buffer_length,
116 output_buffer->pointer);
117 if (ACPI_FAILURE(status)) { 112 if (ACPI_FAILURE(status)) {
118 return_ACPI_STATUS(status); 113 return_ACPI_STATUS(status);
119 } 114 }
@@ -212,21 +207,20 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
212 /* Each element of the top-level package must also be a package */ 207 /* Each element of the top-level package must also be a package */
213 208
214 if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { 209 if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) {
215 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 210 ACPI_ERROR((AE_INFO,
216 "(PRT[%X]) Need sub-package, found %s\n", 211 "(PRT[%X]) Need sub-package, found %s",
217 index, 212 index,
218 acpi_ut_get_object_type_name 213 acpi_ut_get_object_type_name
219 (*top_object_list))); 214 (*top_object_list)));
220 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 215 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
221 } 216 }
222 217
223 /* Each sub-package must be of length 4 */ 218 /* Each sub-package must be of length 4 */
224 219
225 if ((*top_object_list)->package.count != 4) { 220 if ((*top_object_list)->package.count != 4) {
226 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 221 ACPI_ERROR((AE_INFO,
227 "(PRT[%X]) Need package of length 4, found length %d\n", 222 "(PRT[%X]) Need package of length 4, found length %d",
228 index, 223 index, (*top_object_list)->package.count));
229 (*top_object_list)->package.count));
230 return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); 224 return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT);
231 } 225 }
232 226
@@ -243,11 +237,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
243 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 237 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
244 user_prt->address = obj_desc->integer.value; 238 user_prt->address = obj_desc->integer.value;
245 } else { 239 } else {
246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 240 ACPI_ERROR((AE_INFO,
247 "(PRT[%X].Address) Need Integer, found %s\n", 241 "(PRT[%X].Address) Need Integer, found %s",
248 index, 242 index,
249 acpi_ut_get_object_type_name 243 acpi_ut_get_object_type_name(obj_desc)));
250 (obj_desc)));
251 return_ACPI_STATUS(AE_BAD_DATA); 244 return_ACPI_STATUS(AE_BAD_DATA);
252 } 245 }
253 246
@@ -257,76 +250,83 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
257 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 250 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
258 user_prt->pin = (u32) obj_desc->integer.value; 251 user_prt->pin = (u32) obj_desc->integer.value;
259 } else { 252 } else {
260 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 253 ACPI_ERROR((AE_INFO,
261 "(PRT[%X].Pin) Need Integer, found %s\n", 254 "(PRT[%X].Pin) Need Integer, found %s",
262 index, 255 index,
263 acpi_ut_get_object_type_name 256 acpi_ut_get_object_type_name(obj_desc)));
264 (obj_desc)));
265 return_ACPI_STATUS(AE_BAD_DATA); 257 return_ACPI_STATUS(AE_BAD_DATA);
266 } 258 }
267 259
268 /* 3) Third subobject: Dereference the PRT.source_name */ 260 /*
269 261 * 3) Third subobject: Dereference the PRT.source_name
262 * The name may be unresolved (slack mode), so allow a null object
263 */
270 obj_desc = sub_object_list[2]; 264 obj_desc = sub_object_list[2];
271 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 265 if (obj_desc) {
272 case ACPI_TYPE_LOCAL_REFERENCE: 266 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
273 267 case ACPI_TYPE_LOCAL_REFERENCE:
274 if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { 268
275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 269 if (obj_desc->reference.opcode !=
276 "(PRT[%X].Source) Need name, found reference op %X\n", 270 AML_INT_NAMEPATH_OP) {
277 index, 271 ACPI_ERROR((AE_INFO,
278 obj_desc->reference.opcode)); 272 "(PRT[%X].Source) Need name, found reference op %X",
273 index,
274 obj_desc->reference.
275 opcode));
276 return_ACPI_STATUS(AE_BAD_DATA);
277 }
278
279 node = obj_desc->reference.node;
280
281 /* Use *remaining* length of the buffer as max for pathname */
282
283 path_buffer.length = output_buffer->length -
284 (u32) ((u8 *) user_prt->source -
285 (u8 *) output_buffer->pointer);
286 path_buffer.pointer = user_prt->source;
287
288 status =
289 acpi_ns_handle_to_pathname((acpi_handle)
290 node,
291 &path_buffer);
292
293 /* +1 to include null terminator */
294
295 user_prt->length +=
296 (u32) ACPI_STRLEN(user_prt->source) + 1;
297 break;
298
299 case ACPI_TYPE_STRING:
300
301 ACPI_STRCPY(user_prt->source,
302 obj_desc->string.pointer);
303
304 /*
305 * Add to the Length field the length of the string
306 * (add 1 for terminator)
307 */
308 user_prt->length += obj_desc->string.length + 1;
309 break;
310
311 case ACPI_TYPE_INTEGER:
312 /*
313 * If this is a number, then the Source Name is NULL, since the
314 * entire buffer was zeroed out, we can leave this alone.
315 *
316 * Add to the Length field the length of the u32 NULL
317 */
318 user_prt->length += sizeof(u32);
319 break;
320
321 default:
322
323 ACPI_ERROR((AE_INFO,
324 "(PRT[%X].Source) Need Ref/String/Integer, found %s",
325 index,
326 acpi_ut_get_object_type_name
327 (obj_desc)));
279 return_ACPI_STATUS(AE_BAD_DATA); 328 return_ACPI_STATUS(AE_BAD_DATA);
280 } 329 }
281
282 node = obj_desc->reference.node;
283
284 /* Use *remaining* length of the buffer as max for pathname */
285
286 path_buffer.length = output_buffer->length -
287 (u32) ((u8 *) user_prt->source -
288 (u8 *) output_buffer->pointer);
289 path_buffer.pointer = user_prt->source;
290
291 status =
292 acpi_ns_handle_to_pathname((acpi_handle) node,
293 &path_buffer);
294
295 /* +1 to include null terminator */
296
297 user_prt->length +=
298 (u32) ACPI_STRLEN(user_prt->source) + 1;
299 break;
300
301 case ACPI_TYPE_STRING:
302
303 ACPI_STRCPY(user_prt->source, obj_desc->string.pointer);
304
305 /*
306 * Add to the Length field the length of the string
307 * (add 1 for terminator)
308 */
309 user_prt->length += obj_desc->string.length + 1;
310 break;
311
312 case ACPI_TYPE_INTEGER:
313 /*
314 * If this is a number, then the Source Name is NULL, since the
315 * entire buffer was zeroed out, we can leave this alone.
316 *
317 * Add to the Length field the length of the u32 NULL
318 */
319 user_prt->length += sizeof(u32);
320 break;
321
322 default:
323
324 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
325 "(PRT[%X].Source) Need Ref/String/Integer, found %s\n",
326 index,
327 acpi_ut_get_object_type_name
328 (obj_desc)));
329 return_ACPI_STATUS(AE_BAD_DATA);
330 } 330 }
331 331
332 /* Now align the current length */ 332 /* Now align the current length */
@@ -340,11 +340,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
340 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 340 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
341 user_prt->source_index = (u32) obj_desc->integer.value; 341 user_prt->source_index = (u32) obj_desc->integer.value;
342 } else { 342 } else {
343 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 343 ACPI_ERROR((AE_INFO,
344 "(PRT[%X].source_index) Need Integer, found %s\n", 344 "(PRT[%X].source_index) Need Integer, found %s",
345 index, 345 index,
346 acpi_ut_get_object_type_name 346 acpi_ut_get_object_type_name(obj_desc)));
347 (obj_desc)));
348 return_ACPI_STATUS(AE_BAD_DATA); 347 return_ACPI_STATUS(AE_BAD_DATA);
349 } 348 }
350 349
@@ -360,7 +359,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
360 359
361/******************************************************************************* 360/*******************************************************************************
362 * 361 *
363 * FUNCTION: acpi_rs_create_byte_stream 362 * FUNCTION: acpi_rs_create_aml_resources
364 * 363 *
365 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list 364 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list
366 * output_buffer - Pointer to the user's buffer 365 * output_buffer - Pointer to the user's buffer
@@ -377,13 +376,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
377 ******************************************************************************/ 376 ******************************************************************************/
378 377
379acpi_status 378acpi_status
380acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, 379acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
381 struct acpi_buffer *output_buffer) 380 struct acpi_buffer *output_buffer)
382{ 381{
383 acpi_status status; 382 acpi_status status;
384 acpi_size byte_stream_size_needed = 0; 383 acpi_size aml_size_needed = 0;
385 384
386 ACPI_FUNCTION_TRACE("rs_create_byte_stream"); 385 ACPI_FUNCTION_TRACE("rs_create_aml_resources");
387 386
388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", 387 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n",
389 linked_list_buffer)); 388 linked_list_buffer));
@@ -394,11 +393,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
394 * Pass the linked_list_buffer into a module that calculates 393 * Pass the linked_list_buffer into a module that calculates
395 * the buffer size needed for the byte stream. 394 * the buffer size needed for the byte stream.
396 */ 395 */
397 status = acpi_rs_get_byte_stream_length(linked_list_buffer, 396 status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed);
398 &byte_stream_size_needed);
399 397
400 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", 398 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n",
401 (u32) byte_stream_size_needed, 399 (u32) aml_size_needed,
402 acpi_format_exception(status))); 400 acpi_format_exception(status)));
403 if (ACPI_FAILURE(status)) { 401 if (ACPI_FAILURE(status)) {
404 return_ACPI_STATUS(status); 402 return_ACPI_STATUS(status);
@@ -406,8 +404,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
406 404
407 /* Validate/Allocate/Clear caller buffer */ 405 /* Validate/Allocate/Clear caller buffer */
408 406
409 status = 407 status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed);
410 acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed);
411 if (ACPI_FAILURE(status)) { 408 if (ACPI_FAILURE(status)) {
412 return_ACPI_STATUS(status); 409 return_ACPI_STATUS(status);
413 } 410 }
@@ -415,9 +412,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
415 /* Do the conversion */ 412 /* Do the conversion */
416 413
417 status = 414 status =
418 acpi_rs_list_to_byte_stream(linked_list_buffer, 415 acpi_rs_convert_resources_to_aml(linked_list_buffer,
419 byte_stream_size_needed, 416 aml_size_needed,
420 output_buffer->pointer); 417 output_buffer->pointer);
421 if (ACPI_FAILURE(status)) { 418 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status); 419 return_ACPI_STATUS(status);
423 } 420 }
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index 75bd34d1783f..e7de061cf883 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,1063 +49,720 @@ ACPI_MODULE_NAME("rsdump")
49 49
50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
51/* Local prototypes */ 51/* Local prototypes */
52static void acpi_rs_dump_irq(union acpi_resource_data *data); 52static void acpi_rs_out_string(char *title, char *value);
53 53
54static void acpi_rs_dump_address16(union acpi_resource_data *data); 54static void acpi_rs_out_integer8(char *title, u8 value);
55 55
56static void acpi_rs_dump_address32(union acpi_resource_data *data); 56static void acpi_rs_out_integer16(char *title, u16 value);
57 57
58static void acpi_rs_dump_address64(union acpi_resource_data *data); 58static void acpi_rs_out_integer32(char *title, u32 value);
59 59
60static void acpi_rs_dump_dma(union acpi_resource_data *data); 60static void acpi_rs_out_integer64(char *title, u64 value);
61 61
62static void acpi_rs_dump_io(union acpi_resource_data *data); 62static void acpi_rs_out_title(char *title);
63 63
64static void acpi_rs_dump_extended_irq(union acpi_resource_data *data); 64static void acpi_rs_dump_byte_list(u16 length, u8 * data);
65 65
66static void acpi_rs_dump_fixed_io(union acpi_resource_data *data); 66static void acpi_rs_dump_dword_list(u8 length, u32 * data);
67 67
68static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data); 68static void acpi_rs_dump_short_byte_list(u8 length, u8 * data);
69 69
70static void acpi_rs_dump_memory24(union acpi_resource_data *data); 70static void
71acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
71 72
72static void acpi_rs_dump_memory32(union acpi_resource_data *data); 73static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
73 74
74static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data); 75static void
76acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
75 77
76static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data); 78#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
79#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
80#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
77 81
78/******************************************************************************* 82/*******************************************************************************
79 * 83 *
80 * FUNCTION: acpi_rs_dump_irq 84 * Resource Descriptor info tables
81 * 85 *
82 * PARAMETERS: Data - pointer to the resource structure to dump. 86 * Note: The first table entry must be a Title or Literal and must contain
83 * 87 * the table length (number of table entries)
84 * RETURN: None
85 *
86 * DESCRIPTION: Prints out the various members of the Data structure type.
87 * 88 *
88 ******************************************************************************/ 89 ******************************************************************************/
89 90
90static void acpi_rs_dump_irq(union acpi_resource_data *data) 91struct acpi_rsdump_info acpi_rs_dump_irq[6] = {
91{ 92 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
92 struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *)data; 93 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
93 u8 index = 0; 94 acpi_gbl_HEdecode},
94 95 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
95 ACPI_FUNCTION_ENTRY(); 96 acpi_gbl_LLdecode},
96 97 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
97 acpi_os_printf("IRQ Resource\n"); 98 acpi_gbl_SHRdecode},
99 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
100 "Interrupt Count", NULL},
101 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
102 "Interrupt List", NULL}
103};
104
105struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
106 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
107 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
108 acpi_gbl_TYPdecode},
109 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
110 acpi_gbl_BMdecode},
111 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
112 acpi_gbl_SIZdecode},
113 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
114 NULL},
115 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
116 NULL}
117};
118
119struct acpi_rsdump_info acpi_rs_dump_start_dpf[3] = {
120 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
121 "Start-Dependent-Functions", NULL},
122 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
123 "Compatibility Priority", acpi_gbl_config_decode},
124 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
125 "Performance/Robustness", acpi_gbl_config_decode}
126};
127
128struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
129 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
130 "End-Dependent-Functions", NULL}
131};
132
133struct acpi_rsdump_info acpi_rs_dump_io[6] = {
134 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
135 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
136 acpi_gbl_io_decode},
137 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
138 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
139 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
140 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
141 NULL}
142};
143
144struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
145 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
146 "Fixed I/O", NULL},
147 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
148 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
149 "Address Length", NULL}
150};
151
152struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
153 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
154 "Vendor Specific", NULL},
155 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
156 {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
157 NULL}
158};
159
160struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
161 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "end_tag",
162 NULL}
163};
164
165struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
166 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
167 "24-Bit Memory Range", NULL},
168 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
169 "Write Protect", acpi_gbl_RWdecode},
170 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
171 NULL},
172 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
173 NULL},
174 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
175 NULL},
176 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
177 "Address Length", NULL}
178};
179
180struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
181 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
182 "32-Bit Memory Range", NULL},
183 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
184 "Write Protect", acpi_gbl_RWdecode},
185 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
186 NULL},
187 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
188 NULL},
189 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
190 NULL},
191 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
192 "Address Length", NULL}
193};
194
195struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
196 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
197 "32-Bit Fixed Memory Range", NULL},
198 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
199 "Write Protect", acpi_gbl_RWdecode},
200 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
201 NULL},
202 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
203 "Address Length", NULL}
204};
205
206struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
207 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
208 "16-Bit WORD Address Space", NULL},
209 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
210 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
211 NULL},
212 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
213 NULL},
214 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
215 NULL},
216 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
217 "Translation Offset", NULL},
218 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
219 "Address Length", NULL},
220 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
221};
222
223struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
224 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
225 "32-Bit DWORD Address Space", NULL},
226 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
227 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
228 NULL},
229 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
230 NULL},
231 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
232 NULL},
233 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
234 "Translation Offset", NULL},
235 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
236 "Address Length", NULL},
237 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
238};
239
240struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
241 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
242 "64-Bit QWORD Address Space", NULL},
243 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
244 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
245 NULL},
246 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
247 NULL},
248 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
249 NULL},
250 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
251 "Translation Offset", NULL},
252 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
253 "Address Length", NULL},
254 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
255};
256
257struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
258 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
259 "64-Bit Extended Address Space", NULL},
260 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
261 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
262 "Granularity", NULL},
263 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
264 "Address Minimum", NULL},
265 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
266 "Address Maximum", NULL},
267 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
268 "Translation Offset", NULL},
269 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
270 "Address Length", NULL},
271 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
272 "Type-Specific Attribute", NULL}
273};
274
275struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
276 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
277 "Extended IRQ", NULL},
278 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
279 "Type", acpi_gbl_consume_decode},
280 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
281 "Triggering", acpi_gbl_HEdecode},
282 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
283 acpi_gbl_LLdecode},
284 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
285 acpi_gbl_SHRdecode},
286 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
287 NULL},
288 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
289 "Interrupt Count", NULL},
290 {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
291 "Interrupt List", NULL}
292};
293
294struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
295 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
296 "Generic Register", NULL},
297 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
298 NULL},
299 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
300 NULL},
301 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
302 NULL},
303 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
304 "Access Size", NULL},
305 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
306};
98 307
99 acpi_os_printf(" %s Triggered\n", 308/*
100 ACPI_LEVEL_SENSITIVE == 309 * Tables used for common address descriptor flag fields
101 irq_data->edge_level ? "Level" : "Edge"); 310 */
102 311static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
103 acpi_os_printf(" Active %s\n", 312 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
104 ACPI_ACTIVE_LOW == 313 NULL},
105 irq_data->active_high_low ? "Low" : "High"); 314 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
106 315 "Consumer/Producer", acpi_gbl_consume_decode},
107 acpi_os_printf(" %s\n", 316 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
108 ACPI_SHARED == 317 acpi_gbl_DECdecode},
109 irq_data->shared_exclusive ? "Shared" : "Exclusive"); 318 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
110 319 "Min Relocatability", acpi_gbl_min_decode},
111 acpi_os_printf(" %X Interrupts ( ", irq_data->number_of_interrupts); 320 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
112 321 "Max Relocatability", acpi_gbl_max_decode}
113 for (index = 0; index < irq_data->number_of_interrupts; index++) { 322};
114 acpi_os_printf("%X ", irq_data->interrupts[index]); 323
115 } 324static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
325 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
326 "Resource Type", (void *)"Memory Range"},
327 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
328 "Write Protect", acpi_gbl_RWdecode},
329 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
330 "Caching", acpi_gbl_MEMdecode},
331 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
332 "Range Type", acpi_gbl_MTPdecode},
333 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
334 "Translation", acpi_gbl_TTPdecode}
335};
336
337static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
338 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
339 "Resource Type", (void *)"I/O Range"},
340 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
341 "Range Type", acpi_gbl_RNGdecode},
342 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
343 "Translation", acpi_gbl_TTPdecode},
344 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
345 "Translation Type", acpi_gbl_TRSdecode}
346};
116 347
117 acpi_os_printf(")\n"); 348/*
118 return; 349 * Table used to dump _PRT contents
119} 350 */
351static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
352 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
353 {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
354 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
355 {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
356 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
357};
120 358
121/******************************************************************************* 359/*******************************************************************************
122 * 360 *
123 * FUNCTION: acpi_rs_dump_dma 361 * FUNCTION: acpi_rs_dump_descriptor
124 * 362 *
125 * PARAMETERS: Data - pointer to the resource structure to dump. 363 * PARAMETERS: Resource
126 * 364 *
127 * RETURN: None 365 * RETURN: None
128 * 366 *
129 * DESCRIPTION: Prints out the various members of the Data structure type. 367 * DESCRIPTION:
130 * 368 *
131 ******************************************************************************/ 369 ******************************************************************************/
132 370
133static void acpi_rs_dump_dma(union acpi_resource_data *data) 371static void
372acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
134{ 373{
135 struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *)data; 374 u8 *target = NULL;
136 u8 index = 0; 375 u8 *previous_target;
137 376 char *name;
138 ACPI_FUNCTION_ENTRY(); 377 u8 count;
139 378
140 acpi_os_printf("DMA Resource\n"); 379 /* First table entry must contain the table length (# of table entries) */
141 380
142 switch (dma_data->type) { 381 count = table->offset;
143 case ACPI_COMPATIBILITY: 382
144 acpi_os_printf(" Compatibility mode\n"); 383 while (count) {
145 break; 384 previous_target = target;
146 385 target = ACPI_ADD_PTR(u8, resource, table->offset);
147 case ACPI_TYPE_A: 386 name = table->name;
148 acpi_os_printf(" Type A\n"); 387
149 break; 388 switch (table->opcode) {
150 389 case ACPI_RSD_TITLE:
151 case ACPI_TYPE_B: 390 /*
152 acpi_os_printf(" Type B\n"); 391 * Optional resource title
153 break; 392 */
154 393 if (table->name) {
155 case ACPI_TYPE_F: 394 acpi_os_printf("%s Resource\n", name);
156 acpi_os_printf(" Type F\n"); 395 }
157 break; 396 break;
158
159 default:
160 acpi_os_printf(" Invalid DMA type\n");
161 break;
162 }
163
164 acpi_os_printf(" %sBus Master\n",
165 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
166
167 switch (dma_data->transfer) {
168 case ACPI_TRANSFER_8:
169 acpi_os_printf(" 8-bit only transfer\n");
170 break;
171 397
172 case ACPI_TRANSFER_8_16: 398 /* Strings */
173 acpi_os_printf(" 8 and 16-bit transfer\n");
174 break;
175 399
176 case ACPI_TRANSFER_16: 400 case ACPI_RSD_LITERAL:
177 acpi_os_printf(" 16 bit only transfer\n"); 401 acpi_rs_out_string(name,
178 break; 402 ACPI_CAST_PTR(char, table->pointer));
403 break;
179 404
180 default: 405 case ACPI_RSD_STRING:
181 acpi_os_printf(" Invalid transfer preference\n"); 406 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
182 break; 407 break;
183 }
184 408
185 acpi_os_printf(" Number of Channels: %X ( ", 409 /* Data items, 8/16/32/64 bit */
186 dma_data->number_of_channels);
187 410
188 for (index = 0; index < dma_data->number_of_channels; index++) { 411 case ACPI_RSD_UINT8:
189 acpi_os_printf("%X ", dma_data->channels[index]); 412 acpi_rs_out_integer8(name, ACPI_GET8(target));
190 } 413 break;
191 414
192 acpi_os_printf(")\n"); 415 case ACPI_RSD_UINT16:
193 return; 416 acpi_rs_out_integer16(name, ACPI_GET16(target));
194} 417 break;
195 418
196/******************************************************************************* 419 case ACPI_RSD_UINT32:
197 * 420 acpi_rs_out_integer32(name, ACPI_GET32(target));
198 * FUNCTION: acpi_rs_dump_start_depend_fns 421 break;
199 *
200 * PARAMETERS: Data - pointer to the resource structure to dump.
201 *
202 * RETURN: None
203 *
204 * DESCRIPTION: Prints out the various members of the Data structure type.
205 *
206 ******************************************************************************/
207 422
208static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data) 423 case ACPI_RSD_UINT64:
209{ 424 acpi_rs_out_integer64(name, ACPI_GET64(target));
210 struct acpi_resource_start_dpf *sdf_data = 425 break;
211 (struct acpi_resource_start_dpf *)data;
212 426
213 ACPI_FUNCTION_ENTRY(); 427 /* Flags: 1-bit and 2-bit flags supported */
214 428
215 acpi_os_printf("Start Dependent Functions Resource\n"); 429 case ACPI_RSD_1BITFLAG:
430 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
431 table->
432 pointer[*target &
433 0x01]));
434 break;
216 435
217 switch (sdf_data->compatibility_priority) { 436 case ACPI_RSD_2BITFLAG:
218 case ACPI_GOOD_CONFIGURATION: 437 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
219 acpi_os_printf(" Good configuration\n"); 438 table->
220 break; 439 pointer[*target &
440 0x03]));
441 break;
221 442
222 case ACPI_ACCEPTABLE_CONFIGURATION: 443 case ACPI_RSD_SHORTLIST:
223 acpi_os_printf(" Acceptable configuration\n"); 444 /*
224 break; 445 * Short byte list (single line output) for DMA and IRQ resources
446 * Note: The list length is obtained from the previous table entry
447 */
448 if (previous_target) {
449 acpi_rs_out_title(name);
450 acpi_rs_dump_short_byte_list(*previous_target,
451 target);
452 }
453 break;
225 454
226 case ACPI_SUB_OPTIMAL_CONFIGURATION: 455 case ACPI_RSD_LONGLIST:
227 acpi_os_printf(" Sub-optimal configuration\n"); 456 /*
228 break; 457 * Long byte list for Vendor resource data
458 * Note: The list length is obtained from the previous table entry
459 */
460 if (previous_target) {
461 acpi_rs_dump_byte_list(ACPI_GET16
462 (previous_target),
463 target);
464 }
465 break;
229 466
230 default: 467 case ACPI_RSD_DWORDLIST:
231 acpi_os_printf(" Invalid compatibility priority\n"); 468 /*
232 break; 469 * Dword list for Extended Interrupt resources
233 } 470 * Note: The list length is obtained from the previous table entry
471 */
472 if (previous_target) {
473 acpi_rs_dump_dword_list(*previous_target,
474 ACPI_CAST_PTR(u32,
475 target));
476 }
477 break;
234 478
235 switch (sdf_data->performance_robustness) { 479 case ACPI_RSD_ADDRESS:
236 case ACPI_GOOD_CONFIGURATION: 480 /*
237 acpi_os_printf(" Good configuration\n"); 481 * Common flags for all Address resources
238 break; 482 */
483 acpi_rs_dump_address_common(ACPI_CAST_PTR
484 (union acpi_resource_data,
485 target));
486 break;
239 487
240 case ACPI_ACCEPTABLE_CONFIGURATION: 488 case ACPI_RSD_SOURCE:
241 acpi_os_printf(" Acceptable configuration\n"); 489 /*
242 break; 490 * Optional resource_source for Address resources
491 */
492 acpi_rs_dump_resource_source(ACPI_CAST_PTR
493 (struct
494 acpi_resource_source,
495 target));
496 break;
243 497
244 case ACPI_SUB_OPTIMAL_CONFIGURATION: 498 default:
245 acpi_os_printf(" Sub-optimal configuration\n"); 499 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
246 break; 500 table->opcode);
501 return;
502 }
247 503
248 default: 504 table++;
249 acpi_os_printf(" Invalid performance robustness preference\n"); 505 count--;
250 break;
251 } 506 }
252
253 return;
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_rs_dump_io
259 *
260 * PARAMETERS: Data - pointer to the resource structure to dump.
261 *
262 * RETURN: None
263 *
264 * DESCRIPTION: Prints out the various members of the Data structure type.
265 *
266 ******************************************************************************/
267
268static void acpi_rs_dump_io(union acpi_resource_data *data)
269{
270 struct acpi_resource_io *io_data = (struct acpi_resource_io *)data;
271
272 ACPI_FUNCTION_ENTRY();
273
274 acpi_os_printf("Io Resource\n");
275
276 acpi_os_printf(" %d bit decode\n",
277 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
278
279 acpi_os_printf(" Range minimum base: %08X\n",
280 io_data->min_base_address);
281
282 acpi_os_printf(" Range maximum base: %08X\n",
283 io_data->max_base_address);
284
285 acpi_os_printf(" Alignment: %08X\n", io_data->alignment);
286
287 acpi_os_printf(" Range Length: %08X\n", io_data->range_length);
288
289 return;
290}
291
292/*******************************************************************************
293 *
294 * FUNCTION: acpi_rs_dump_fixed_io
295 *
296 * PARAMETERS: Data - pointer to the resource structure to dump.
297 *
298 * RETURN: None
299 *
300 * DESCRIPTION: Prints out the various members of the Data structure type.
301 *
302 ******************************************************************************/
303
304static void acpi_rs_dump_fixed_io(union acpi_resource_data *data)
305{
306 struct acpi_resource_fixed_io *fixed_io_data =
307 (struct acpi_resource_fixed_io *)data;
308
309 ACPI_FUNCTION_ENTRY();
310
311 acpi_os_printf("Fixed Io Resource\n");
312 acpi_os_printf(" Range base address: %08X",
313 fixed_io_data->base_address);
314
315 acpi_os_printf(" Range length: %08X", fixed_io_data->range_length);
316
317 return;
318} 507}
319 508
320/******************************************************************************* 509/*******************************************************************************
321 * 510 *
322 * FUNCTION: acpi_rs_dump_vendor_specific 511 * FUNCTION: acpi_rs_dump_resource_source
323 * 512 *
324 * PARAMETERS: Data - pointer to the resource structure to dump. 513 * PARAMETERS: resource_source - Pointer to a Resource Source struct
325 * 514 *
326 * RETURN: None 515 * RETURN: None
327 * 516 *
328 * DESCRIPTION: Prints out the various members of the Data structure type. 517 * DESCRIPTION: Common routine for dumping the optional resource_source and the
518 * corresponding resource_source_index.
329 * 519 *
330 ******************************************************************************/ 520 ******************************************************************************/
331 521
332static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data) 522static void
523acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
333{ 524{
334 struct acpi_resource_vendor *vendor_data =
335 (struct acpi_resource_vendor *)data;
336 u16 index = 0;
337
338 ACPI_FUNCTION_ENTRY(); 525 ACPI_FUNCTION_ENTRY();
339 526
340 acpi_os_printf("Vendor Specific Resource\n"); 527 if (resource_source->index == 0xFF) {
341 528 return;
342 acpi_os_printf(" Length: %08X\n", vendor_data->length);
343
344 for (index = 0; index < vendor_data->length; index++) {
345 acpi_os_printf(" Byte %X: %08X\n",
346 index, vendor_data->reserved[index]);
347 } 529 }
348 530
349 return; 531 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
350}
351
352/*******************************************************************************
353 *
354 * FUNCTION: acpi_rs_dump_memory24
355 *
356 * PARAMETERS: Data - pointer to the resource structure to dump.
357 *
358 * RETURN: None
359 *
360 * DESCRIPTION: Prints out the various members of the Data structure type.
361 *
362 ******************************************************************************/
363
364static void acpi_rs_dump_memory24(union acpi_resource_data *data)
365{
366 struct acpi_resource_mem24 *memory24_data =
367 (struct acpi_resource_mem24 *)data;
368
369 ACPI_FUNCTION_ENTRY();
370
371 acpi_os_printf("24-Bit Memory Range Resource\n");
372
373 acpi_os_printf(" Read%s\n",
374 ACPI_READ_WRITE_MEMORY ==
375 memory24_data->read_write_attribute ?
376 "/Write" : " only");
377
378 acpi_os_printf(" Range minimum base: %08X\n",
379 memory24_data->min_base_address);
380
381 acpi_os_printf(" Range maximum base: %08X\n",
382 memory24_data->max_base_address);
383
384 acpi_os_printf(" Alignment: %08X\n", memory24_data->alignment);
385
386 acpi_os_printf(" Range length: %08X\n", memory24_data->range_length);
387
388 return;
389}
390
391/*******************************************************************************
392 *
393 * FUNCTION: acpi_rs_dump_memory32
394 *
395 * PARAMETERS: Data - pointer to the resource structure to dump.
396 *
397 * RETURN: None
398 *
399 * DESCRIPTION: Prints out the various members of the Data structure type.
400 *
401 ******************************************************************************/
402
403static void acpi_rs_dump_memory32(union acpi_resource_data *data)
404{
405 struct acpi_resource_mem32 *memory32_data =
406 (struct acpi_resource_mem32 *)data;
407
408 ACPI_FUNCTION_ENTRY();
409
410 acpi_os_printf("32-Bit Memory Range Resource\n");
411
412 acpi_os_printf(" Read%s\n",
413 ACPI_READ_WRITE_MEMORY ==
414 memory32_data->read_write_attribute ?
415 "/Write" : " only");
416
417 acpi_os_printf(" Range minimum base: %08X\n",
418 memory32_data->min_base_address);
419
420 acpi_os_printf(" Range maximum base: %08X\n",
421 memory32_data->max_base_address);
422
423 acpi_os_printf(" Alignment: %08X\n", memory32_data->alignment);
424
425 acpi_os_printf(" Range length: %08X\n", memory32_data->range_length);
426 532
427 return; 533 acpi_rs_out_string("Resource Source",
534 resource_source->string_ptr ?
535 resource_source->string_ptr : "[Not Specified]");
428} 536}
429 537
430/******************************************************************************* 538/*******************************************************************************
431 * 539 *
432 * FUNCTION: acpi_rs_dump_fixed_memory32 540 * FUNCTION: acpi_rs_dump_address_common
433 * 541 *
434 * PARAMETERS: Data - pointer to the resource structure to dump. 542 * PARAMETERS: Resource - Pointer to an internal resource descriptor
435 *
436 * RETURN:
437 *
438 * DESCRIPTION: Prints out the various members of the Data structure type.
439 *
440 ******************************************************************************/
441
442static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data)
443{
444 struct acpi_resource_fixed_mem32 *fixed_memory32_data =
445 (struct acpi_resource_fixed_mem32 *)data;
446
447 ACPI_FUNCTION_ENTRY();
448
449 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
450
451 acpi_os_printf(" Read%s\n",
452 ACPI_READ_WRITE_MEMORY ==
453 fixed_memory32_data->
454 read_write_attribute ? "/Write" : " Only");
455
456 acpi_os_printf(" Range base address: %08X\n",
457 fixed_memory32_data->range_base_address);
458
459 acpi_os_printf(" Range length: %08X\n",
460 fixed_memory32_data->range_length);
461
462 return;
463}
464
465/*******************************************************************************
466 *
467 * FUNCTION: acpi_rs_dump_address16
468 *
469 * PARAMETERS: Data - pointer to the resource structure to dump.
470 * 543 *
471 * RETURN: None 544 * RETURN: None
472 * 545 *
473 * DESCRIPTION: Prints out the various members of the Data structure type. 546 * DESCRIPTION: Dump the fields that are common to all Address resource
547 * descriptors
474 * 548 *
475 ******************************************************************************/ 549 ******************************************************************************/
476 550
477static void acpi_rs_dump_address16(union acpi_resource_data *data) 551static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
478{ 552{
479 struct acpi_resource_address16 *address16_data =
480 (struct acpi_resource_address16 *)data;
481
482 ACPI_FUNCTION_ENTRY(); 553 ACPI_FUNCTION_ENTRY();
483 554
484 acpi_os_printf("16-Bit Address Space Resource\n"); 555 /* Decode the type-specific flags */
485 acpi_os_printf(" Resource Type: ");
486 556
487 switch (address16_data->resource_type) { 557 switch (resource->address.resource_type) {
488 case ACPI_MEMORY_RANGE: 558 case ACPI_MEMORY_RANGE:
489 559
490 acpi_os_printf("Memory Range\n"); 560 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
491
492 switch (address16_data->attribute.memory.cache_attribute) {
493 case ACPI_NON_CACHEABLE_MEMORY:
494 acpi_os_printf
495 (" Type Specific: Noncacheable memory\n");
496 break;
497
498 case ACPI_CACHABLE_MEMORY:
499 acpi_os_printf(" Type Specific: Cacheable memory\n");
500 break;
501
502 case ACPI_WRITE_COMBINING_MEMORY:
503 acpi_os_printf
504 (" Type Specific: Write-combining memory\n");
505 break;
506
507 case ACPI_PREFETCHABLE_MEMORY:
508 acpi_os_printf
509 (" Type Specific: Prefetchable memory\n");
510 break;
511
512 default:
513 acpi_os_printf
514 (" Type Specific: Invalid cache attribute\n");
515 break;
516 }
517
518 acpi_os_printf(" Type Specific: Read%s\n",
519 ACPI_READ_WRITE_MEMORY ==
520 address16_data->attribute.memory.
521 read_write_attribute ? "/Write" : " Only");
522 break; 561 break;
523 562
524 case ACPI_IO_RANGE: 563 case ACPI_IO_RANGE:
525 564
526 acpi_os_printf("I/O Range\n"); 565 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
527
528 switch (address16_data->attribute.io.range_attribute) {
529 case ACPI_NON_ISA_ONLY_RANGES:
530 acpi_os_printf
531 (" Type Specific: Non-ISA Io Addresses\n");
532 break;
533
534 case ACPI_ISA_ONLY_RANGES:
535 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
536 break;
537
538 case ACPI_ENTIRE_RANGE:
539 acpi_os_printf
540 (" Type Specific: ISA and non-ISA Io Addresses\n");
541 break;
542
543 default:
544 acpi_os_printf
545 (" Type Specific: Invalid range attribute\n");
546 break;
547 }
548
549 acpi_os_printf(" Type Specific: %s Translation\n",
550 ACPI_SPARSE_TRANSLATION ==
551 address16_data->attribute.io.
552 translation_attribute ? "Sparse" : "Dense");
553 break; 566 break;
554 567
555 case ACPI_BUS_NUMBER_RANGE: 568 case ACPI_BUS_NUMBER_RANGE:
556 569
557 acpi_os_printf("Bus Number Range\n"); 570 acpi_rs_out_string("Resource Type", "Bus Number Range");
558 break; 571 break;
559 572
560 default: 573 default:
561 574
562 acpi_os_printf("0x%2.2X\n", address16_data->resource_type); 575 acpi_rs_out_integer8("Resource Type",
576 (u8) resource->address.resource_type);
563 break; 577 break;
564 } 578 }
565 579
566 acpi_os_printf(" Resource %s\n", 580 /* Decode the general flags */
567 ACPI_CONSUMER == address16_data->producer_consumer ?
568 "Consumer" : "Producer");
569
570 acpi_os_printf(" %s decode\n",
571 ACPI_SUB_DECODE == address16_data->decode ?
572 "Subtractive" : "Positive");
573 581
574 acpi_os_printf(" Min address is %s fixed\n", 582 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
575 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
576 "" : "not");
577
578 acpi_os_printf(" Max address is %s fixed\n",
579 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
580 "" : "not");
581
582 acpi_os_printf(" Granularity: %08X\n", address16_data->granularity);
583
584 acpi_os_printf(" Address range min: %08X\n",
585 address16_data->min_address_range);
586
587 acpi_os_printf(" Address range max: %08X\n",
588 address16_data->max_address_range);
589
590 acpi_os_printf(" Address translation offset: %08X\n",
591 address16_data->address_translation_offset);
592
593 acpi_os_printf(" Address Length: %08X\n",
594 address16_data->address_length);
595
596 if (0xFF != address16_data->resource_source.index) {
597 acpi_os_printf(" Resource Source Index: %X\n",
598 address16_data->resource_source.index);
599
600 acpi_os_printf(" Resource Source: %s\n",
601 address16_data->resource_source.string_ptr);
602 }
603
604 return;
605} 583}
606 584
607/******************************************************************************* 585/*******************************************************************************
608 * 586 *
609 * FUNCTION: acpi_rs_dump_address32 587 * FUNCTION: acpi_rs_dump_resource_list
610 * 588 *
611 * PARAMETERS: Data - pointer to the resource structure to dump. 589 * PARAMETERS: resource_list - Pointer to a resource descriptor list
612 * 590 *
613 * RETURN: None 591 * RETURN: None
614 * 592 *
615 * DESCRIPTION: Prints out the various members of the Data structure type. 593 * DESCRIPTION: Dispatches the structure to the correct dump routine.
616 * 594 *
617 ******************************************************************************/ 595 ******************************************************************************/
618 596
619static void acpi_rs_dump_address32(union acpi_resource_data *data) 597void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
620{ 598{
621 struct acpi_resource_address32 *address32_data = 599 u32 count = 0;
622 (struct acpi_resource_address32 *)data; 600 u32 type;
623 601
624 ACPI_FUNCTION_ENTRY(); 602 ACPI_FUNCTION_ENTRY();
625 603
626 acpi_os_printf("32-Bit Address Space Resource\n"); 604 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
627 605 || !(_COMPONENT & acpi_dbg_layer)) {
628 switch (address32_data->resource_type) { 606 return;
629 case ACPI_MEMORY_RANGE: 607 }
630
631 acpi_os_printf(" Resource Type: Memory Range\n");
632
633 switch (address32_data->attribute.memory.cache_attribute) {
634 case ACPI_NON_CACHEABLE_MEMORY:
635 acpi_os_printf
636 (" Type Specific: Noncacheable memory\n");
637 break;
638
639 case ACPI_CACHABLE_MEMORY:
640 acpi_os_printf(" Type Specific: Cacheable memory\n");
641 break;
642
643 case ACPI_WRITE_COMBINING_MEMORY:
644 acpi_os_printf
645 (" Type Specific: Write-combining memory\n");
646 break;
647
648 case ACPI_PREFETCHABLE_MEMORY:
649 acpi_os_printf
650 (" Type Specific: Prefetchable memory\n");
651 break;
652
653 default:
654 acpi_os_printf
655 (" Type Specific: Invalid cache attribute\n");
656 break;
657 }
658
659 acpi_os_printf(" Type Specific: Read%s\n",
660 ACPI_READ_WRITE_MEMORY ==
661 address32_data->attribute.memory.
662 read_write_attribute ? "/Write" : " Only");
663 break;
664
665 case ACPI_IO_RANGE:
666
667 acpi_os_printf(" Resource Type: Io Range\n");
668 608
669 switch (address32_data->attribute.io.range_attribute) { 609 /* Walk list and dump all resource descriptors (END_TAG terminates) */
670 case ACPI_NON_ISA_ONLY_RANGES:
671 acpi_os_printf
672 (" Type Specific: Non-ISA Io Addresses\n");
673 break;
674 610
675 case ACPI_ISA_ONLY_RANGES: 611 do {
676 acpi_os_printf(" Type Specific: ISA Io Addresses\n"); 612 acpi_os_printf("\n[%02X] ", count);
677 break; 613 count++;
678 614
679 case ACPI_ENTIRE_RANGE: 615 /* Validate Type before dispatch */
680 acpi_os_printf
681 (" Type Specific: ISA and non-ISA Io Addresses\n");
682 break;
683 616
684 default: 617 type = resource_list->type;
618 if (type > ACPI_RESOURCE_TYPE_MAX) {
685 acpi_os_printf 619 acpi_os_printf
686 (" Type Specific: Invalid Range attribute"); 620 ("Invalid descriptor type (%X) in resource list\n",
687 break; 621 resource_list->type);
622 return;
688 } 623 }
689 624
690 acpi_os_printf(" Type Specific: %s Translation\n", 625 /* Dump the resource descriptor */
691 ACPI_SPARSE_TRANSLATION ==
692 address32_data->attribute.io.
693 translation_attribute ? "Sparse" : "Dense");
694 break;
695
696 case ACPI_BUS_NUMBER_RANGE:
697
698 acpi_os_printf(" Resource Type: Bus Number Range\n");
699 break;
700
701 default:
702
703 acpi_os_printf(" Resource Type: 0x%2.2X\n",
704 address32_data->resource_type);
705 break;
706 }
707
708 acpi_os_printf(" Resource %s\n",
709 ACPI_CONSUMER == address32_data->producer_consumer ?
710 "Consumer" : "Producer");
711
712 acpi_os_printf(" %s decode\n",
713 ACPI_SUB_DECODE == address32_data->decode ?
714 "Subtractive" : "Positive");
715
716 acpi_os_printf(" Min address is %s fixed\n",
717 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
718 "" : "not ");
719
720 acpi_os_printf(" Max address is %s fixed\n",
721 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
722 "" : "not ");
723 626
724 acpi_os_printf(" Granularity: %08X\n", address32_data->granularity); 627 acpi_rs_dump_descriptor(&resource_list->data,
628 acpi_gbl_dump_resource_dispatch[type]);
725 629
726 acpi_os_printf(" Address range min: %08X\n", 630 /* Point to the next resource structure */
727 address32_data->min_address_range);
728 631
729 acpi_os_printf(" Address range max: %08X\n", 632 resource_list =
730 address32_data->max_address_range); 633 ACPI_ADD_PTR(struct acpi_resource, resource_list,
634 resource_list->length);
731 635
732 acpi_os_printf(" Address translation offset: %08X\n", 636 /* Exit when END_TAG descriptor is reached */
733 address32_data->address_translation_offset);
734 637
735 acpi_os_printf(" Address Length: %08X\n", 638 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
736 address32_data->address_length);
737
738 if (0xFF != address32_data->resource_source.index) {
739 acpi_os_printf(" Resource Source Index: %X\n",
740 address32_data->resource_source.index);
741
742 acpi_os_printf(" Resource Source: %s\n",
743 address32_data->resource_source.string_ptr);
744 }
745
746 return;
747} 639}
748 640
749/******************************************************************************* 641/*******************************************************************************
750 * 642 *
751 * FUNCTION: acpi_rs_dump_address64 643 * FUNCTION: acpi_rs_dump_irq_list
752 * 644 *
753 * PARAMETERS: Data - pointer to the resource structure to dump. 645 * PARAMETERS: route_table - Pointer to the routing table to dump.
754 * 646 *
755 * RETURN: None 647 * RETURN: None
756 * 648 *
757 * DESCRIPTION: Prints out the various members of the Data structure type. 649 * DESCRIPTION: Print IRQ routing table
758 * 650 *
759 ******************************************************************************/ 651 ******************************************************************************/
760 652
761static void acpi_rs_dump_address64(union acpi_resource_data *data) 653void acpi_rs_dump_irq_list(u8 * route_table)
762{ 654{
763 struct acpi_resource_address64 *address64_data = 655 struct acpi_pci_routing_table *prt_element;
764 (struct acpi_resource_address64 *)data; 656 u8 count;
765 657
766 ACPI_FUNCTION_ENTRY(); 658 ACPI_FUNCTION_ENTRY();
767 659
768 acpi_os_printf("64-Bit Address Space Resource\n"); 660 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
769 661 || !(_COMPONENT & acpi_dbg_layer)) {
770 switch (address64_data->resource_type) { 662 return;
771 case ACPI_MEMORY_RANGE:
772
773 acpi_os_printf(" Resource Type: Memory Range\n");
774
775 switch (address64_data->attribute.memory.cache_attribute) {
776 case ACPI_NON_CACHEABLE_MEMORY:
777 acpi_os_printf
778 (" Type Specific: Noncacheable memory\n");
779 break;
780
781 case ACPI_CACHABLE_MEMORY:
782 acpi_os_printf(" Type Specific: Cacheable memory\n");
783 break;
784
785 case ACPI_WRITE_COMBINING_MEMORY:
786 acpi_os_printf
787 (" Type Specific: Write-combining memory\n");
788 break;
789
790 case ACPI_PREFETCHABLE_MEMORY:
791 acpi_os_printf
792 (" Type Specific: Prefetchable memory\n");
793 break;
794
795 default:
796 acpi_os_printf
797 (" Type Specific: Invalid cache attribute\n");
798 break;
799 }
800
801 acpi_os_printf(" Type Specific: Read%s\n",
802 ACPI_READ_WRITE_MEMORY ==
803 address64_data->attribute.memory.
804 read_write_attribute ? "/Write" : " Only");
805 break;
806
807 case ACPI_IO_RANGE:
808
809 acpi_os_printf(" Resource Type: Io Range\n");
810
811 switch (address64_data->attribute.io.range_attribute) {
812 case ACPI_NON_ISA_ONLY_RANGES:
813 acpi_os_printf
814 (" Type Specific: Non-ISA Io Addresses\n");
815 break;
816
817 case ACPI_ISA_ONLY_RANGES:
818 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
819 break;
820
821 case ACPI_ENTIRE_RANGE:
822 acpi_os_printf
823 (" Type Specific: ISA and non-ISA Io Addresses\n");
824 break;
825
826 default:
827 acpi_os_printf
828 (" Type Specific: Invalid Range attribute");
829 break;
830 }
831
832 acpi_os_printf(" Type Specific: %s Translation\n",
833 ACPI_SPARSE_TRANSLATION ==
834 address64_data->attribute.io.
835 translation_attribute ? "Sparse" : "Dense");
836 break;
837
838 case ACPI_BUS_NUMBER_RANGE:
839
840 acpi_os_printf(" Resource Type: Bus Number Range\n");
841 break;
842
843 default:
844
845 acpi_os_printf(" Resource Type: 0x%2.2X\n",
846 address64_data->resource_type);
847 break;
848 } 663 }
849 664
850 acpi_os_printf(" Resource %s\n", 665 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
851 ACPI_CONSUMER == address64_data->producer_consumer ?
852 "Consumer" : "Producer");
853
854 acpi_os_printf(" %s decode\n",
855 ACPI_SUB_DECODE == address64_data->decode ?
856 "Subtractive" : "Positive");
857
858 acpi_os_printf(" Min address is %s fixed\n",
859 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
860 "" : "not ");
861
862 acpi_os_printf(" Max address is %s fixed\n",
863 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
864 "" : "not ");
865 666
866 acpi_os_printf(" Granularity: %8.8X%8.8X\n", 667 /* Dump all table elements, Exit on zero length element */
867 ACPI_FORMAT_UINT64(address64_data->granularity));
868 668
869 acpi_os_printf(" Address range min: %8.8X%8.8X\n", 669 for (count = 0; prt_element->length; count++) {
870 ACPI_FORMAT_UINT64(address64_data->min_address_range)); 670 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
671 count);
672 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
871 673
872 acpi_os_printf(" Address range max: %8.8X%8.8X\n", 674 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
873 ACPI_FORMAT_UINT64(address64_data->max_address_range)); 675 prt_element, prt_element->length);
874
875 acpi_os_printf(" Address translation offset: %8.8X%8.8X\n",
876 ACPI_FORMAT_UINT64(address64_data->
877 address_translation_offset));
878
879 acpi_os_printf(" Address Length: %8.8X%8.8X\n",
880 ACPI_FORMAT_UINT64(address64_data->address_length));
881
882 acpi_os_printf(" Type Specific Attributes: %8.8X%8.8X\n",
883 ACPI_FORMAT_UINT64(address64_data->
884 type_specific_attributes));
885
886 if (0xFF != address64_data->resource_source.index) {
887 acpi_os_printf(" Resource Source Index: %X\n",
888 address64_data->resource_source.index);
889
890 acpi_os_printf(" Resource Source: %s\n",
891 address64_data->resource_source.string_ptr);
892 } 676 }
893
894 return;
895} 677}
896 678
897/******************************************************************************* 679/*******************************************************************************
898 * 680 *
899 * FUNCTION: acpi_rs_dump_extended_irq 681 * FUNCTION: acpi_rs_out*
900 * 682 *
901 * PARAMETERS: Data - pointer to the resource structure to dump. 683 * PARAMETERS: Title - Name of the resource field
684 * Value - Value of the resource field
902 * 685 *
903 * RETURN: None 686 * RETURN: None
904 * 687 *
905 * DESCRIPTION: Prints out the various members of the Data structure type. 688 * DESCRIPTION: Miscellaneous helper functions to consistently format the
689 * output of the resource dump routines
906 * 690 *
907 ******************************************************************************/ 691 ******************************************************************************/
908 692
909static void acpi_rs_dump_extended_irq(union acpi_resource_data *data) 693static void acpi_rs_out_string(char *title, char *value)
910{ 694{
911 struct acpi_resource_ext_irq *ext_irq_data = 695 acpi_os_printf("%27s : %s", title, value);
912 (struct acpi_resource_ext_irq *)data; 696 if (!*value) {
913 u8 index = 0; 697 acpi_os_printf("[NULL NAMESTRING]");
914
915 ACPI_FUNCTION_ENTRY();
916
917 acpi_os_printf("Extended IRQ Resource\n");
918
919 acpi_os_printf(" Resource %s\n",
920 ACPI_CONSUMER == ext_irq_data->producer_consumer ?
921 "Consumer" : "Producer");
922
923 acpi_os_printf(" %s\n",
924 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
925 "Level" : "Edge");
926
927 acpi_os_printf(" Active %s\n",
928 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
929 "low" : "high");
930
931 acpi_os_printf(" %s\n",
932 ACPI_SHARED == ext_irq_data->shared_exclusive ?
933 "Shared" : "Exclusive");
934
935 acpi_os_printf(" Interrupts : %X ( ",
936 ext_irq_data->number_of_interrupts);
937
938 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) {
939 acpi_os_printf("%X ", ext_irq_data->interrupts[index]);
940 }
941
942 acpi_os_printf(")\n");
943
944 if (0xFF != ext_irq_data->resource_source.index) {
945 acpi_os_printf(" Resource Source Index: %X",
946 ext_irq_data->resource_source.index);
947
948 acpi_os_printf(" Resource Source: %s",
949 ext_irq_data->resource_source.string_ptr);
950 } 698 }
951 699 acpi_os_printf("\n");
952 return;
953} 700}
954 701
955/******************************************************************************* 702static void acpi_rs_out_integer8(char *title, u8 value)
956 *
957 * FUNCTION: acpi_rs_dump_resource_list
958 *
959 * PARAMETERS: Resource - pointer to the resource structure to dump.
960 *
961 * RETURN: None
962 *
963 * DESCRIPTION: Dispatches the structure to the correct dump routine.
964 *
965 ******************************************************************************/
966
967void acpi_rs_dump_resource_list(struct acpi_resource *resource)
968{ 703{
969 u8 count = 0; 704 acpi_os_printf("%27s : %2.2X\n", title, value);
970 u8 done = FALSE; 705}
971
972 ACPI_FUNCTION_ENTRY();
973
974 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
975 while (!done) {
976 acpi_os_printf("Resource structure %X.\n", count++);
977
978 switch (resource->id) {
979 case ACPI_RSTYPE_IRQ:
980 acpi_rs_dump_irq(&resource->data);
981 break;
982
983 case ACPI_RSTYPE_DMA:
984 acpi_rs_dump_dma(&resource->data);
985 break;
986
987 case ACPI_RSTYPE_START_DPF:
988 acpi_rs_dump_start_depend_fns(&resource->data);
989 break;
990
991 case ACPI_RSTYPE_END_DPF:
992 acpi_os_printf
993 ("end_dependent_functions Resource\n");
994 /* acpi_rs_dump_end_dependent_functions (Resource->Data); */
995 break;
996
997 case ACPI_RSTYPE_IO:
998 acpi_rs_dump_io(&resource->data);
999 break;
1000
1001 case ACPI_RSTYPE_FIXED_IO:
1002 acpi_rs_dump_fixed_io(&resource->data);
1003 break;
1004
1005 case ACPI_RSTYPE_VENDOR:
1006 acpi_rs_dump_vendor_specific(&resource->data);
1007 break;
1008
1009 case ACPI_RSTYPE_END_TAG:
1010 /*rs_dump_end_tag (Resource->Data); */
1011 acpi_os_printf("end_tag Resource\n");
1012 done = TRUE;
1013 break;
1014
1015 case ACPI_RSTYPE_MEM24:
1016 acpi_rs_dump_memory24(&resource->data);
1017 break;
1018
1019 case ACPI_RSTYPE_MEM32:
1020 acpi_rs_dump_memory32(&resource->data);
1021 break;
1022
1023 case ACPI_RSTYPE_FIXED_MEM32:
1024 acpi_rs_dump_fixed_memory32(&resource->data);
1025 break;
1026
1027 case ACPI_RSTYPE_ADDRESS16:
1028 acpi_rs_dump_address16(&resource->data);
1029 break;
1030
1031 case ACPI_RSTYPE_ADDRESS32:
1032 acpi_rs_dump_address32(&resource->data);
1033 break;
1034
1035 case ACPI_RSTYPE_ADDRESS64:
1036 acpi_rs_dump_address64(&resource->data);
1037 break;
1038
1039 case ACPI_RSTYPE_EXT_IRQ:
1040 acpi_rs_dump_extended_irq(&resource->data);
1041 break;
1042 706
1043 default: 707static void acpi_rs_out_integer16(char *title, u16 value)
1044 acpi_os_printf("Invalid resource type\n"); 708{
1045 break; 709 acpi_os_printf("%27s : %4.4X\n", title, value);
710}
1046 711
1047 } 712static void acpi_rs_out_integer32(char *title, u32 value)
713{
714 acpi_os_printf("%27s : %8.8X\n", title, value);
715}
1048 716
1049 resource = 717static void acpi_rs_out_integer64(char *title, u64 value)
1050 ACPI_PTR_ADD(struct acpi_resource, resource, 718{
1051 resource->length); 719 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
1052 } 720}
1053 }
1054 721
1055 return; 722static void acpi_rs_out_title(char *title)
723{
724 acpi_os_printf("%27s : ", title);
1056} 725}
1057 726
1058/******************************************************************************* 727/*******************************************************************************
1059 * 728 *
1060 * FUNCTION: acpi_rs_dump_irq_list 729 * FUNCTION: acpi_rs_dump*List
1061 * 730 *
1062 * PARAMETERS: route_table - pointer to the routing table to dump. 731 * PARAMETERS: Length - Number of elements in the list
732 * Data - Start of the list
1063 * 733 *
1064 * RETURN: None 734 * RETURN: None
1065 * 735 *
1066 * DESCRIPTION: Dispatches the structures to the correct dump routine. 736 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
1067 * 737 *
1068 ******************************************************************************/ 738 ******************************************************************************/
1069 739
1070void acpi_rs_dump_irq_list(u8 * route_table) 740static void acpi_rs_dump_byte_list(u16 length, u8 * data)
1071{ 741{
1072 u8 *buffer = route_table; 742 u8 i;
1073 u8 count = 0;
1074 u8 done = FALSE;
1075 struct acpi_pci_routing_table *prt_element;
1076 743
1077 ACPI_FUNCTION_ENTRY(); 744 for (i = 0; i < length; i++) {
1078 745 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
1079 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { 746 }
1080 prt_element = 747}
1081 ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
1082
1083 while (!done) {
1084 acpi_os_printf("PCI IRQ Routing Table structure %X.\n",
1085 count++);
1086
1087 acpi_os_printf(" Address: %8.8X%8.8X\n",
1088 ACPI_FORMAT_UINT64(prt_element->
1089 address));
1090 748
1091 acpi_os_printf(" Pin: %X\n", prt_element->pin); 749static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
750{
751 u8 i;
1092 752
1093 acpi_os_printf(" Source: %s\n", prt_element->source); 753 for (i = 0; i < length; i++) {
754 acpi_os_printf("%X ", data[i]);
755 }
756 acpi_os_printf("\n");
757}
1094 758
1095 acpi_os_printf(" source_index: %X\n", 759static void acpi_rs_dump_dword_list(u8 length, u32 * data)
1096 prt_element->source_index); 760{
761 u8 i;
1097 762
1098 buffer += prt_element->length; 763 for (i = 0; i < length; i++) {
1099 prt_element = 764 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
1100 ACPI_CAST_PTR(struct acpi_pci_routing_table,
1101 buffer);
1102 if (0 == prt_element->length) {
1103 done = TRUE;
1104 }
1105 }
1106 } 765 }
1107
1108 return;
1109} 766}
1110 767
1111#endif 768#endif
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c
new file mode 100644
index 000000000000..d9ae64b77bd9
--- /dev/null
+++ b/drivers/acpi/resources/rsinfo.c
@@ -0,0 +1,204 @@
1/*******************************************************************************
2 *
3 * Module Name: rsinfo - Dispatch and Info tables
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsinfo")
49
50/*
51 * Resource dispatch and information tables. Any new resource types (either
52 * Large or Small) must be reflected in each of these tables, so they are here
53 * in one place.
54 *
55 * The tables for Large descriptors are indexed by bits 6:0 of the AML
56 * descriptor type byte. The tables for Small descriptors are indexed by
57 * bits 6:3 of the descriptor byte. The tables for internal resource
58 * descriptors are indexed by the acpi_resource_type field.
59 */
60/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
61struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
62 acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
63 acpi_rs_convert_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
64 acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
65 acpi_rs_convert_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
66 acpi_rs_convert_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */
67 acpi_rs_convert_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
68 acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
69 acpi_rs_convert_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
70 acpi_rs_convert_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
71 acpi_rs_convert_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
72 acpi_rs_convert_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
73 acpi_rs_convert_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
74 acpi_rs_convert_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
75 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
76 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
77 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
78 acpi_rs_convert_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
79};
80
81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
82
83struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
84 /* Small descriptors */
85
86 NULL, /* 0x00, Reserved */
87 NULL, /* 0x01, Reserved */
88 NULL, /* 0x02, Reserved */
89 NULL, /* 0x03, Reserved */
90 acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
91 acpi_rs_convert_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
92 acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
93 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
94 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
95 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
96 NULL, /* 0x0A, Reserved */
97 NULL, /* 0x0B, Reserved */
98 NULL, /* 0x0C, Reserved */
99 NULL, /* 0x0D, Reserved */
100 acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
101 acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
102
103 /* Large descriptors */
104
105 NULL, /* 0x00, Reserved */
106 acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
107 acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
108 NULL, /* 0x03, Reserved */
109 acpi_rs_get_vendor_large, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
110 acpi_rs_convert_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
111 acpi_rs_convert_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
112 acpi_rs_convert_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
113 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
114 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
115 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
116 acpi_rs_convert_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
117};
118
119#ifdef ACPI_FUTURE_USAGE
120#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
121
122/* Dispatch table for resource dump functions */
123
124struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
125 acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */
126 acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */
127 acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
128 acpi_rs_dump_end_dpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
129 acpi_rs_dump_io, /* ACPI_RESOURCE_TYPE_IO */
130 acpi_rs_dump_fixed_io, /* ACPI_RESOURCE_TYPE_FIXED_IO */
131 acpi_rs_dump_vendor, /* ACPI_RESOURCE_TYPE_VENDOR */
132 acpi_rs_dump_end_tag, /* ACPI_RESOURCE_TYPE_END_TAG */
133 acpi_rs_dump_memory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
134 acpi_rs_dump_memory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
135 acpi_rs_dump_fixed_memory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
136 acpi_rs_dump_address16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
137 acpi_rs_dump_address32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
138 acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
139 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
140 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
141 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
142};
143#endif
144#endif /* ACPI_FUTURE_USAGE */
145/*
146 * Base sizes for external AML resource descriptors, indexed by internal type.
147 * Includes size of the descriptor header (1 byte for small descriptors,
148 * 3 bytes for large descriptors)
149 */
150const u8 acpi_gbl_aml_resource_sizes[] = {
151 sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
152 sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */
153 sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
154 sizeof(struct aml_resource_end_dependent), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
155 sizeof(struct aml_resource_io), /* ACPI_RESOURCE_TYPE_IO */
156 sizeof(struct aml_resource_fixed_io), /* ACPI_RESOURCE_TYPE_FIXED_IO */
157 sizeof(struct aml_resource_vendor_small), /* ACPI_RESOURCE_TYPE_VENDOR */
158 sizeof(struct aml_resource_end_tag), /* ACPI_RESOURCE_TYPE_END_TAG */
159 sizeof(struct aml_resource_memory24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
160 sizeof(struct aml_resource_memory32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
161 sizeof(struct aml_resource_fixed_memory32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
162 sizeof(struct aml_resource_address16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
163 sizeof(struct aml_resource_address32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
164 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
165 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
166 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
167 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
168};
169
170const u8 acpi_gbl_resource_struct_sizes[] = {
171 /* Small descriptors */
172
173 0,
174 0,
175 0,
176 0,
177 ACPI_RS_SIZE(struct acpi_resource_irq),
178 ACPI_RS_SIZE(struct acpi_resource_dma),
179 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
180 ACPI_RS_SIZE_MIN,
181 ACPI_RS_SIZE(struct acpi_resource_io),
182 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
183 0,
184 0,
185 0,
186 0,
187 ACPI_RS_SIZE(struct acpi_resource_vendor),
188 ACPI_RS_SIZE_MIN,
189
190 /* Large descriptors */
191
192 0,
193 ACPI_RS_SIZE(struct acpi_resource_memory24),
194 ACPI_RS_SIZE(struct acpi_resource_generic_register),
195 0,
196 ACPI_RS_SIZE(struct acpi_resource_vendor),
197 ACPI_RS_SIZE(struct acpi_resource_memory32),
198 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
199 ACPI_RS_SIZE(struct acpi_resource_address32),
200 ACPI_RS_SIZE(struct acpi_resource_address16),
201 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
202 ACPI_RS_SIZE(struct acpi_resource_address64),
203 ACPI_RS_SIZE(struct acpi_resource_extended_address64)
204};
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index d53bbe89e851..ea567167c4f2 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,428 +49,206 @@ ACPI_MODULE_NAME("rsio")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_io_resource 52 * acpi_rs_convert_io
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 ******************************************************************************/
55 * stream 55struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
56 * bytes_consumed - Pointer to where the number of bytes 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
57 * consumed the byte_stream_buffer is 57 ACPI_RS_SIZE(struct acpi_resource_io),
58 * returned 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
59 * output_buffer - Pointer to the return data buffer 59
60 * structure_size - Pointer to where the number of bytes 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
61 * in the return data struct is returned 61 sizeof(struct aml_resource_io),
62 * 62 0},
63 * RETURN: Status 63
64 /* Decode flag */
65
66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
67 AML_OFFSET(io.flags),
68 0},
69 /*
70 * These fields are contiguous in both the source and destination:
71 * Address Alignment
72 * Length
73 * Minimum Base Address
74 * Maximum Base Address
75 */
76 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
77 AML_OFFSET(io.alignment),
78 2},
79
80 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
81 AML_OFFSET(io.minimum),
82 2}
83};
84
85/*******************************************************************************
64 * 86 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 87 * acpi_rs_convert_fixed_io
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 88 *
69 ******************************************************************************/ 89 ******************************************************************************/
70acpi_status
71acpi_rs_io_resource(u8 * byte_stream_buffer,
72 acpi_size * bytes_consumed,
73 u8 ** output_buffer, acpi_size * structure_size)
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
80
81 ACPI_FUNCTION_TRACE("rs_io_resource");
82
83 /* The number of bytes consumed are Constant */
84
85 *bytes_consumed = 8;
86
87 output_struct->id = ACPI_RSTYPE_IO;
88
89 /* Check Decode */
90
91 buffer += 1;
92 temp8 = *buffer;
93
94 output_struct->data.io.io_decode = temp8 & 0x01;
95
96 /* Check min_base Address */
97
98 buffer += 1;
99 ACPI_MOVE_16_TO_16(&temp16, buffer);
100
101 output_struct->data.io.min_base_address = temp16;
102
103 /* Check max_base Address */
104 90
105 buffer += 2; 91struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
106 ACPI_MOVE_16_TO_16(&temp16, buffer); 92 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
107 93 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
108 output_struct->data.io.max_base_address = temp16; 94 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
109 95
110 /* Check Base alignment */ 96 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
111 97 sizeof(struct aml_resource_fixed_io),
112 buffer += 2; 98 0},
113 temp8 = *buffer; 99 /*
114 100 * These fields are contiguous in both the source and destination:
115 output_struct->data.io.alignment = temp8; 101 * Base Address
116 102 * Length
117 /* Check range_length */ 103 */
118 104 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
119 buffer += 1; 105 AML_OFFSET(fixed_io.address_length),
120 temp8 = *buffer; 106 1},
121 107
122 output_struct->data.io.range_length = temp8; 108 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
123 109 AML_OFFSET(fixed_io.address),
124 /* Set the Length parameter */ 110 1}
125 111};
126 output_struct->length = (u32) struct_size;
127
128 /* Return the final size of the structure */
129
130 *structure_size = struct_size;
131 return_ACPI_STATUS(AE_OK);
132}
133 112
134/******************************************************************************* 113/*******************************************************************************
135 * 114 *
136 * FUNCTION: acpi_rs_fixed_io_resource 115 * acpi_rs_convert_generic_reg
137 *
138 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
139 * stream
140 * bytes_consumed - Pointer to where the number of bytes
141 * consumed the byte_stream_buffer is
142 * returned
143 * output_buffer - Pointer to the return data buffer
144 * structure_size - Pointer to where the number of bytes
145 * in the return data struct is returned
146 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
150 * structure pointed to by the output_buffer. Return the
151 * number of bytes consumed from the byte stream.
152 * 116 *
153 ******************************************************************************/ 117 ******************************************************************************/
154 118
155acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
156acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
157 acpi_size * bytes_consumed, 121 ACPI_RS_SIZE(struct acpi_resource_generic_register),
158 u8 ** output_buffer, acpi_size * structure_size) 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
159{ 123
160 u8 *buffer = byte_stream_buffer; 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
161 struct acpi_resource *output_struct = (void *)*output_buffer; 125 sizeof(struct aml_resource_generic_register),
162 u16 temp16 = 0; 126 0},
163 u8 temp8 = 0; 127 /*
164 acpi_size struct_size = 128 * These fields are contiguous in both the source and destination:
165 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 129 * Address Space ID
166 130 * Register Bit Width
167 ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); 131 * Register Bit Offset
168 132 * Access Size
169 /* The number of bytes consumed are Constant */ 133 */
170 134 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
171 *bytes_consumed = 4; 135 AML_OFFSET(generic_reg.address_space_id),
172 136 4},
173 output_struct->id = ACPI_RSTYPE_FIXED_IO; 137
174 138 /* Get the Register Address */
175 /* Check Range Base Address */ 139
176 140 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
177 buffer += 1; 141 AML_OFFSET(generic_reg.address),
178 ACPI_MOVE_16_TO_16(&temp16, buffer); 142 1}
179 143};
180 output_struct->data.fixed_io.base_address = temp16;
181
182 /* Check range_length */
183
184 buffer += 2;
185 temp8 = *buffer;
186
187 output_struct->data.fixed_io.range_length = temp8;
188
189 /* Set the Length parameter */
190
191 output_struct->length = (u32) struct_size;
192
193 /* Return the final size of the structure */
194
195 *structure_size = struct_size;
196 return_ACPI_STATUS(AE_OK);
197}
198 144
199/******************************************************************************* 145/*******************************************************************************
200 * 146 *
201 * FUNCTION: acpi_rs_io_stream 147 * acpi_rs_convert_end_dpf
202 *
203 * PARAMETERS: linked_list - Pointer to the resource linked list
204 * output_buffer - Pointer to the user's return buffer
205 * bytes_consumed - Pointer to where the number of bytes
206 * used in the output_buffer is returned
207 *
208 * RETURN: Status
209 *
210 * DESCRIPTION: Take the linked list resource structure and fills in the
211 * the appropriate bytes in a byte stream
212 * 148 *
213 ******************************************************************************/ 149 ******************************************************************************/
214 150
215acpi_status 151struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
216acpi_rs_io_stream(struct acpi_resource *linked_list, 152 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
217 u8 ** output_buffer, acpi_size * bytes_consumed) 153 ACPI_RS_SIZE_MIN,
218{ 154 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
219 u8 *buffer = *output_buffer;
220 u16 temp16 = 0;
221 u8 temp8 = 0;
222
223 ACPI_FUNCTION_TRACE("rs_io_stream");
224
225 /* The descriptor field is static */
226
227 *buffer = 0x47;
228 buffer += 1;
229
230 /* Io Information Byte */
231
232 temp8 = (u8) (linked_list->data.io.io_decode & 0x01);
233
234 *buffer = temp8;
235 buffer += 1;
236
237 /* Set the Range minimum base address */
238
239 temp16 = (u16) linked_list->data.io.min_base_address;
240
241 ACPI_MOVE_16_TO_16(buffer, &temp16);
242 buffer += 2;
243
244 /* Set the Range maximum base address */
245
246 temp16 = (u16) linked_list->data.io.max_base_address;
247 155
248 ACPI_MOVE_16_TO_16(buffer, &temp16); 156 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
249 buffer += 2; 157 sizeof(struct aml_resource_end_dependent),
250 158 0}
251 /* Set the base alignment */ 159};
252
253 temp8 = (u8) linked_list->data.io.alignment;
254
255 *buffer = temp8;
256 buffer += 1;
257
258 /* Set the range length */
259
260 temp8 = (u8) linked_list->data.io.range_length;
261
262 *buffer = temp8;
263 buffer += 1;
264
265 /* Return the number of bytes consumed in this operation */
266
267 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
268 return_ACPI_STATUS(AE_OK);
269}
270 160
271/******************************************************************************* 161/*******************************************************************************
272 * 162 *
273 * FUNCTION: acpi_rs_fixed_io_stream 163 * acpi_rs_convert_end_tag
274 *
275 * PARAMETERS: linked_list - Pointer to the resource linked list
276 * output_buffer - Pointer to the user's return buffer
277 * bytes_consumed - Pointer to where the number of bytes
278 * used in the output_buffer is returned
279 *
280 * RETURN: Status
281 *
282 * DESCRIPTION: Take the linked list resource structure and fills in the
283 * the appropriate bytes in a byte stream
284 * 164 *
285 ******************************************************************************/ 165 ******************************************************************************/
286 166
287acpi_status 167struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
288acpi_rs_fixed_io_stream(struct acpi_resource *linked_list, 168 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
289 u8 ** output_buffer, acpi_size * bytes_consumed) 169 ACPI_RS_SIZE_MIN,
290{ 170 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
291 u8 *buffer = *output_buffer; 171
292 u16 temp16 = 0; 172 /*
293 u8 temp8 = 0; 173 * Note: The checksum field is set to zero, meaning that the resource
294 174 * data is treated as if the checksum operation succeeded.
295 ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); 175 * (ACPI Spec 1.0b Section 6.4.2.8)
296 176 */
297 /* The descriptor field is static */ 177 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
298 178 sizeof(struct aml_resource_end_tag),
299 *buffer = 0x4B; 179 0}
300 180};
301 buffer += 1;
302
303 /* Set the Range base address */
304
305 temp16 = (u16) linked_list->data.fixed_io.base_address;
306
307 ACPI_MOVE_16_TO_16(buffer, &temp16);
308 buffer += 2;
309
310 /* Set the range length */
311
312 temp8 = (u8) linked_list->data.fixed_io.range_length;
313
314 *buffer = temp8;
315 buffer += 1;
316
317 /* Return the number of bytes consumed in this operation */
318
319 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
320 return_ACPI_STATUS(AE_OK);
321}
322 181
323/******************************************************************************* 182/*******************************************************************************
324 * 183 *
325 * FUNCTION: acpi_rs_dma_resource 184 * acpi_rs_get_start_dpf
326 *
327 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
328 * stream
329 * bytes_consumed - Pointer to where the number of bytes
330 * consumed the byte_stream_buffer is
331 * returned
332 * output_buffer - Pointer to the return data buffer
333 * structure_size - Pointer to where the number of bytes
334 * in the return data struct is returned
335 *
336 * RETURN: Status
337 *
338 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
339 * structure pointed to by the output_buffer. Return the
340 * number of bytes consumed from the byte stream.
341 * 185 *
342 ******************************************************************************/ 186 ******************************************************************************/
343 187
344acpi_status 188struct acpi_rsconvert_info acpi_rs_get_start_dpf[5] = {
345acpi_rs_dma_resource(u8 * byte_stream_buffer, 189 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
346 acpi_size * bytes_consumed, 190 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
347 u8 ** output_buffer, acpi_size * structure_size) 191 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
348{
349 u8 *buffer = byte_stream_buffer;
350 struct acpi_resource *output_struct = (void *)*output_buffer;
351 u8 temp8 = 0;
352 u8 index;
353 u8 i;
354 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
355
356 ACPI_FUNCTION_TRACE("rs_dma_resource");
357
358 /* The number of bytes consumed are Constant */
359 192
360 *bytes_consumed = 3; 193 /* Defaults for Compatibility and Performance priorities */
361 output_struct->id = ACPI_RSTYPE_DMA;
362 194
363 /* Point to the 8-bits of Byte 1 */ 195 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
196 ACPI_ACCEPTABLE_CONFIGURATION,
197 2},
364 198
365 buffer += 1; 199 /* All done if there is no flag byte present in the descriptor */
366 temp8 = *buffer;
367 200
368 /* Decode the DMA channel bits */ 201 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
369 202
370 for (i = 0, index = 0; index < 8; index++) { 203 /* Flag byte is present, get the flags */
371 if ((temp8 >> index) & 0x01) {
372 output_struct->data.dma.channels[i] = index;
373 i++;
374 }
375 }
376 204
377 /* Zero DMA channels is valid */ 205 {ACPI_RSC_2BITFLAG,
206 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
207 AML_OFFSET(start_dpf.flags),
208 0},
378 209
379 output_struct->data.dma.number_of_channels = i; 210 {ACPI_RSC_2BITFLAG,
380 if (i > 0) { 211 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
381 /* Calculate the structure size based upon the number of interrupts */ 212 AML_OFFSET(start_dpf.flags),
382 213 2}
383 struct_size += ((acpi_size) i - 1) * 4; 214};
384 }
385
386 /* Point to Byte 2 */
387
388 buffer += 1;
389 temp8 = *buffer;
390
391 /* Check for transfer preference (Bits[1:0]) */
392
393 output_struct->data.dma.transfer = temp8 & 0x03;
394
395 if (0x03 == output_struct->data.dma.transfer) {
396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
397 "Invalid DMA.Transfer preference (3)\n"));
398 return_ACPI_STATUS(AE_BAD_DATA);
399 }
400
401 /* Get bus master preference (Bit[2]) */
402
403 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
404
405 /* Get channel speed support (Bits[6:5]) */
406
407 output_struct->data.dma.type = (temp8 >> 5) & 0x03;
408
409 /* Set the Length parameter */
410
411 output_struct->length = (u32) struct_size;
412
413 /* Return the final size of the structure */
414
415 *structure_size = struct_size;
416 return_ACPI_STATUS(AE_OK);
417}
418 215
419/******************************************************************************* 216/*******************************************************************************
420 * 217 *
421 * FUNCTION: acpi_rs_dma_stream 218 * acpi_rs_set_start_dpf
422 *
423 * PARAMETERS: linked_list - Pointer to the resource linked list
424 * output_buffer - Pointer to the user's return buffer
425 * bytes_consumed - Pointer to where the number of bytes
426 * used in the output_buffer is returned
427 *
428 * RETURN: Status
429 *
430 * DESCRIPTION: Take the linked list resource structure and fills in the
431 * the appropriate bytes in a byte stream
432 * 219 *
433 ******************************************************************************/ 220 ******************************************************************************/
434 221
435acpi_status 222struct acpi_rsconvert_info acpi_rs_set_start_dpf[6] = {
436acpi_rs_dma_stream(struct acpi_resource *linked_list, 223 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
437 u8 ** output_buffer, acpi_size * bytes_consumed) 224 sizeof(struct aml_resource_start_dependent),
438{ 225 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
439 u8 *buffer = *output_buffer; 226
440 u16 temp16 = 0; 227 /* Set the default flag values */
441 u8 temp8 = 0; 228
442 u8 index; 229 {ACPI_RSC_2BITFLAG,
443 230 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
444 ACPI_FUNCTION_TRACE("rs_dma_stream"); 231 AML_OFFSET(start_dpf.flags),
445 232 0},
446 /* The descriptor field is static */ 233
447 234 {ACPI_RSC_2BITFLAG,
448 *buffer = 0x2A; 235 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
449 buffer += 1; 236 AML_OFFSET(start_dpf.flags),
450 temp8 = 0; 237 2},
451 238 /*
452 /* Loop through all of the Channels and set the mask bits */ 239 * All done if flags byte is necessary -- if either priority value
453 240 * is not ACPI_ACCEPTABLE_CONFIGURATION
454 for (index = 0; 241 */
455 index < linked_list->data.dma.number_of_channels; index++) { 242 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
456 temp16 = (u16) linked_list->data.dma.channels[index]; 243 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
457 temp8 |= 0x1 << temp16; 244 ACPI_ACCEPTABLE_CONFIGURATION},
458 } 245
459 246 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
460 *buffer = temp8; 247 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
461 buffer += 1; 248 ACPI_ACCEPTABLE_CONFIGURATION},
462 249
463 /* Set the DMA Info */ 250 /* Flag byte is not necessary */
464 251
465 temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5); 252 {ACPI_RSC_LENGTH, 0, 0,
466 temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2); 253 sizeof(struct aml_resource_start_dependent_noprio)}
467 temp8 |= (linked_list->data.dma.transfer & 0x03); 254};
468
469 *buffer = temp8;
470 buffer += 1;
471
472 /* Return the number of bytes consumed in this operation */
473
474 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
475 return_ACPI_STATUS(AE_OK);
476}
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index 56043fee96cb..1fa63bc2e36f 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,504 +49,182 @@ ACPI_MODULE_NAME("rsirq")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_irq_resource 52 * acpi_rs_get_irq
53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 53 *
69 ******************************************************************************/ 54 ******************************************************************************/
70acpi_status 55struct acpi_rsconvert_info acpi_rs_get_irq[7] = {
71acpi_rs_irq_resource(u8 * byte_stream_buffer, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
72 acpi_size * bytes_consumed, 57 ACPI_RS_SIZE(struct acpi_resource_irq),
73 u8 ** output_buffer, acpi_size * structure_size) 58 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 u8 index;
80 u8 i;
81 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
82
83 ACPI_FUNCTION_TRACE("rs_irq_resource");
84
85 /*
86 * The number of bytes consumed are contained in the descriptor
87 * (Bits:0-1)
88 */
89 temp8 = *buffer;
90 *bytes_consumed = (temp8 & 0x03) + 1;
91 output_struct->id = ACPI_RSTYPE_IRQ;
92
93 /* Point to the 16-bits of Bytes 1 and 2 */
94
95 buffer += 1;
96 ACPI_MOVE_16_TO_16(&temp16, buffer);
97
98 output_struct->data.irq.number_of_interrupts = 0;
99
100 /* Decode the IRQ bits */
101
102 for (i = 0, index = 0; index < 16; index++) {
103 if ((temp16 >> index) & 0x01) {
104 output_struct->data.irq.interrupts[i] = index;
105 i++;
106 }
107 }
108 59
109 /* Zero interrupts is valid */ 60 /* Get the IRQ mask (bytes 1:2) */
110 61
111 output_struct->data.irq.number_of_interrupts = i; 62 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
112 if (i > 0) { 63 AML_OFFSET(irq.irq_mask),
113 /* Calculate the structure size based upon the number of interrupts */ 64 ACPI_RS_OFFSET(data.irq.interrupt_count)},
114 65
115 struct_size += ((acpi_size) i - 1) * 4; 66 /* Set default flags (others are zero) */
116 }
117 67
118 /* Point to Byte 3 if it is used */ 68 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
69 ACPI_EDGE_SENSITIVE,
70 1},
119 71
120 if (4 == *bytes_consumed) { 72 /* All done if no flag byte present in descriptor */
121 buffer += 2;
122 temp8 = *buffer;
123 73
124 /* Check for HE, LL interrupts */ 74 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
125 75
126 switch (temp8 & 0x09) { 76 /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
127 case 0x01: /* HE */
128 output_struct->data.irq.edge_level =
129 ACPI_EDGE_SENSITIVE;
130 output_struct->data.irq.active_high_low =
131 ACPI_ACTIVE_HIGH;
132 break;
133 77
134 case 0x08: /* LL */ 78 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
135 output_struct->data.irq.edge_level = 79 AML_OFFSET(irq.flags),
136 ACPI_LEVEL_SENSITIVE; 80 0},
137 output_struct->data.irq.active_high_low =
138 ACPI_ACTIVE_LOW;
139 break;
140 81
141 default: 82 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
142 /* 83 AML_OFFSET(irq.flags),
143 * Only _LL and _HE polarity/trigger interrupts 84 3},
144 * are allowed (ACPI spec, section "IRQ Format")
145 * so 0x00 and 0x09 are illegal.
146 */
147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
148 "Invalid interrupt polarity/trigger in resource list, %X\n",
149 temp8));
150 return_ACPI_STATUS(AE_BAD_DATA);
151 }
152 85
153 /* Check for sharable */ 86 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
154 87 AML_OFFSET(irq.flags),
155 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 88 4}
156 } else { 89};
157 /*
158 * Assume Edge Sensitive, Active High, Non-Sharable
159 * per ACPI Specification
160 */
161 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
162 output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
163 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
164 }
165
166 /* Set the Length parameter */
167
168 output_struct->length = (u32) struct_size;
169
170 /* Return the final size of the structure */
171
172 *structure_size = struct_size;
173 return_ACPI_STATUS(AE_OK);
174}
175 90
176/******************************************************************************* 91/*******************************************************************************
177 * 92 *
178 * FUNCTION: acpi_rs_irq_stream 93 * acpi_rs_set_irq
179 *
180 * PARAMETERS: linked_list - Pointer to the resource linked list
181 * output_buffer - Pointer to the user's return buffer
182 * bytes_consumed - Pointer to where the number of bytes
183 * used in the output_buffer is returned
184 *
185 * RETURN: Status
186 *
187 * DESCRIPTION: Take the linked list resource structure and fills in the
188 * the appropriate bytes in a byte stream
189 * 94 *
190 ******************************************************************************/ 95 ******************************************************************************/
191 96
192acpi_status 97struct acpi_rsconvert_info acpi_rs_set_irq[9] = {
193acpi_rs_irq_stream(struct acpi_resource *linked_list, 98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
194 u8 ** output_buffer, acpi_size * bytes_consumed) 99 sizeof(struct aml_resource_irq),
195{ 100 ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)},
196 u8 *buffer = *output_buffer;
197 u16 temp16 = 0;
198 u8 temp8 = 0;
199 u8 index;
200 u8 IRqinfo_byte_needed;
201
202 ACPI_FUNCTION_TRACE("rs_irq_stream");
203
204 /*
205 * The descriptor field is set based upon whether a third byte is
206 * needed to contain the IRQ Information.
207 */
208 if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
209 ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
210 ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
211 *buffer = 0x22;
212 IRqinfo_byte_needed = FALSE;
213 } else {
214 *buffer = 0x23;
215 IRqinfo_byte_needed = TRUE;
216 }
217
218 buffer += 1;
219 temp16 = 0;
220
221 /* Loop through all of the interrupts and set the mask bits */
222
223 for (index = 0;
224 index < linked_list->data.irq.number_of_interrupts; index++) {
225 temp8 = (u8) linked_list->data.irq.interrupts[index];
226 temp16 |= 0x1 << temp8;
227 }
228
229 ACPI_MOVE_16_TO_16(buffer, &temp16);
230 buffer += 2;
231
232 /* Set the IRQ Info byte if needed. */
233
234 if (IRqinfo_byte_needed) {
235 temp8 = 0;
236 temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
237 0x01) << 4);
238
239 if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
240 ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) {
241 temp8 |= 0x08;
242 } else {
243 temp8 |= 0x01;
244 }
245
246 *buffer = temp8;
247 buffer += 1;
248 }
249
250 /* Return the number of bytes consumed in this operation */
251
252 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
253 return_ACPI_STATUS(AE_OK);
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_rs_extended_irq_resource
259 *
260 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
261 * stream
262 * bytes_consumed - Pointer to where the number of bytes
263 * consumed the byte_stream_buffer is
264 * returned
265 * output_buffer - Pointer to the return data buffer
266 * structure_size - Pointer to where the number of bytes
267 * in the return data struct is returned
268 *
269 * RETURN: Status
270 *
271 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
272 * structure pointed to by the output_buffer. Return the
273 * number of bytes consumed from the byte stream.
274 *
275 ******************************************************************************/
276
277acpi_status
278acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
279 acpi_size * bytes_consumed,
280 u8 ** output_buffer, acpi_size * structure_size)
281{
282 u8 *buffer = byte_stream_buffer;
283 struct acpi_resource *output_struct = (void *)*output_buffer;
284 u16 temp16 = 0;
285 u8 temp8 = 0;
286 u8 *temp_ptr;
287 u8 index;
288 acpi_size struct_size =
289 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq);
290
291 ACPI_FUNCTION_TRACE("rs_extended_irq_resource");
292
293 /* Get the Descriptor Length field */
294
295 buffer += 1;
296 ACPI_MOVE_16_TO_16(&temp16, buffer);
297
298 /* Validate minimum descriptor length */
299
300 if (temp16 < 6) {
301 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
302 }
303
304 *bytes_consumed = temp16 + 3;
305 output_struct->id = ACPI_RSTYPE_EXT_IRQ;
306
307 /* Point to the Byte3 */
308
309 buffer += 2;
310 temp8 = *buffer;
311
312 output_struct->data.extended_irq.producer_consumer = temp8 & 0x01;
313 101
314 /* 102 /* Convert interrupt list to 16-bit IRQ bitmask */
315 * Check for Interrupt Mode
316 *
317 * The definition of an Extended IRQ changed between ACPI spec v1.0b
318 * and ACPI spec 2.0 (section 6.4.3.6 in both).
319 *
320 * - Edge/Level are defined opposite in the table vs the headers
321 */
322 output_struct->data.extended_irq.edge_level =
323 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
324
325 /* Check Interrupt Polarity */
326
327 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
328
329 /* Check for sharable */
330
331 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
332 103
333 /* Point to Byte4 (IRQ Table length) */ 104 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
105 AML_OFFSET(irq.irq_mask),
106 ACPI_RS_OFFSET(data.irq.interrupt_count)},
334 107
335 buffer += 1; 108 /* Set the flags byte by default */
336 temp8 = *buffer;
337 109
338 /* Must have at least one IRQ */ 110 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
111 AML_OFFSET(irq.flags),
112 0},
339 113
340 if (temp8 < 1) { 114 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
341 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 115 AML_OFFSET(irq.flags),
342 } 116 3},
343
344 output_struct->data.extended_irq.number_of_interrupts = temp8;
345 117
118 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
119 AML_OFFSET(irq.flags),
120 4},
346 /* 121 /*
347 * Add any additional structure size to properly calculate 122 * Check if the flags byte is necessary. Not needed if the flags are:
348 * the next pointer at the end of this function 123 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
349 */ 124 */
350 struct_size += (temp8 - 1) * 4; 125 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
351 126 ACPI_RS_OFFSET(data.irq.triggering),
352 /* Point to Byte5 (First IRQ Number) */ 127 ACPI_EDGE_SENSITIVE},
353
354 buffer += 1;
355
356 /* Cycle through every IRQ in the table */
357
358 for (index = 0; index < temp8; index++) {
359 ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq.
360 interrupts[index], buffer);
361
362 /* Point to the next IRQ */
363
364 buffer += 4;
365 }
366
367 /*
368 * This will leave us pointing to the Resource Source Index
369 * If it is present, then save it off and calculate the
370 * pointer to where the null terminated string goes:
371 * Each Interrupt takes 32-bits + the 5 bytes of the
372 * stream that are default.
373 *
374 * Note: Some resource descriptors will have an additional null, so
375 * we add 1 to the length.
376 */
377 if (*bytes_consumed >
378 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts *
379 4) + (5 + 1)) {
380 /* Dereference the Index */
381
382 temp8 = *buffer;
383 output_struct->data.extended_irq.resource_source.index =
384 (u32) temp8;
385
386 /* Point to the String */
387
388 buffer += 1;
389
390 /* Point the String pointer to the end of this structure. */
391
392 output_struct->data.extended_irq.resource_source.string_ptr =
393 (char *)((char *)output_struct + struct_size);
394 128
395 temp_ptr = (u8 *) 129 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
396 output_struct->data.extended_irq.resource_source.string_ptr; 130 ACPI_RS_OFFSET(data.irq.polarity),
131 ACPI_ACTIVE_HIGH},
397 132
398 /* Copy the string into the buffer */ 133 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
134 ACPI_RS_OFFSET(data.irq.sharable),
135 ACPI_EXCLUSIVE},
399 136
400 index = 0; 137 /* irq_no_flags() descriptor can be used */
401 while (*buffer) {
402 *temp_ptr = *buffer;
403 138
404 temp_ptr += 1; 139 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
405 buffer += 1; 140};
406 index += 1;
407 }
408
409 /* Add the terminating null */
410
411 *temp_ptr = 0;
412 output_struct->data.extended_irq.resource_source.string_length =
413 index + 1;
414
415 /*
416 * In order for the struct_size to fall on a 32-bit boundary,
417 * calculate the length of the string and expand the
418 * struct_size to the next 32-bit boundary.
419 */
420 temp8 = (u8) (index + 1);
421 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
422 } else {
423 output_struct->data.extended_irq.resource_source.index = 0;
424 output_struct->data.extended_irq.resource_source.string_length =
425 0;
426 output_struct->data.extended_irq.resource_source.string_ptr =
427 NULL;
428 }
429
430 /* Set the Length parameter */
431
432 output_struct->length = (u32) struct_size;
433
434 /* Return the final size of the structure */
435
436 *structure_size = struct_size;
437 return_ACPI_STATUS(AE_OK);
438}
439 141
440/******************************************************************************* 142/*******************************************************************************
441 * 143 *
442 * FUNCTION: acpi_rs_extended_irq_stream 144 * acpi_rs_convert_ext_irq
443 *
444 * PARAMETERS: linked_list - Pointer to the resource linked list
445 * output_buffer - Pointer to the user's return buffer
446 * bytes_consumed - Pointer to where the number of bytes
447 * used in the output_buffer is returned
448 *
449 * RETURN: Status
450 *
451 * DESCRIPTION: Take the linked list resource structure and fills in the
452 * the appropriate bytes in a byte stream
453 * 145 *
454 ******************************************************************************/ 146 ******************************************************************************/
455 147
456acpi_status 148struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
457acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, 149 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
458 u8 ** output_buffer, acpi_size * bytes_consumed) 150 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
459{ 151 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
460 u8 *buffer = *output_buffer;
461 u16 *length_field;
462 u8 temp8 = 0;
463 u8 index;
464 152
465 ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); 153 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
154 sizeof(struct aml_resource_extended_irq),
155 0},
466 156
467 /* Set the Descriptor Type field */ 157 /* Flag bits */
468 158
469 *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT; 159 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
470 buffer += 1; 160 AML_OFFSET(extended_irq.flags),
161 0},
471 162
472 /* Save a pointer to the Length field - to be filled in later */ 163 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
164 AML_OFFSET(extended_irq.flags),
165 1},
473 166
474 length_field = ACPI_CAST_PTR(u16, buffer); 167 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
475 buffer += 2; 168 AML_OFFSET(extended_irq.flags),
169 2},
476 170
477 /* Set the Interrupt vector flags */ 171 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
172 AML_OFFSET(extended_irq.flags),
173 3},
478 174
479 temp8 = (u8) (linked_list->data.extended_irq.producer_consumer & 0x01); 175 /* IRQ Table length (Byte4) */
480 temp8 |=
481 ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
482 176
483 /* 177 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
484 * Set the Interrupt Mode 178 AML_OFFSET(extended_irq.interrupt_count),
485 * 179 sizeof(u32)}
486 * The definition of an Extended IRQ changed between ACPI spec v1.0b 180 ,
487 * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not
488 * implement the more restrictive definition of 1.0b
489 *
490 * - Edge/Level are defined opposite in the table vs the headers
491 */
492 if (ACPI_EDGE_SENSITIVE == linked_list->data.extended_irq.edge_level) {
493 temp8 |= 0x2;
494 }
495
496 /* Set the Interrupt Polarity */
497 181
498 temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2); 182 /* Copy every IRQ in the table, each is 32 bits */
499 183
500 *buffer = temp8; 184 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
501 buffer += 1; 185 AML_OFFSET(extended_irq.interrupts[0]),
186 0}
187 ,
502 188
503 /* Set the Interrupt table length */ 189 /* Optional resource_source (Index and String) */
504 190
505 temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts; 191 {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source),
192 ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
193 sizeof(struct aml_resource_extended_irq)}
194};
506 195
507 *buffer = temp8; 196/*******************************************************************************
508 buffer += 1; 197 *
509 198 * acpi_rs_convert_dma
510 for (index = 0; 199 *
511 index < linked_list->data.extended_irq.number_of_interrupts; 200 ******************************************************************************/
512 index++) {
513 ACPI_MOVE_32_TO_32(buffer,
514 &linked_list->data.extended_irq.
515 interrupts[index]);
516 buffer += 4;
517 }
518 201
519 /* Resource Source Index and Resource Source are optional */ 202struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
203 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
204 ACPI_RS_SIZE(struct acpi_resource_dma),
205 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)},
520 206
521 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 207 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
522 *buffer = 208 sizeof(struct aml_resource_dma),
523 (u8) linked_list->data.extended_irq.resource_source.index; 209 0},
524 buffer += 1;
525 210
526 /* Copy the string */ 211 /* Flags: transfer preference, bus mastering, channel speed */
527 212
528 ACPI_STRCPY((char *)buffer, 213 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
529 linked_list->data.extended_irq.resource_source. 214 AML_OFFSET(dma.flags),
530 string_ptr); 215 0},
531 216
532 /* 217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
533 * Buffer needs to be set to the length of the string + one for the 218 AML_OFFSET(dma.flags),
534 * terminating null 219 2},
535 */
536 buffer +=
537 (acpi_size) (ACPI_STRLEN
538 (linked_list->data.extended_irq.
539 resource_source.string_ptr) + 1);
540 }
541 220
542 /* Return the number of bytes consumed in this operation */ 221 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
222 AML_OFFSET(dma.flags),
223 5},
543 224
544 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 225 /* DMA channel mask bits */
545 226
546 /* 227 {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]),
547 * Set the length field to the number of bytes consumed 228 AML_OFFSET(dma.dma_channel_mask),
548 * minus the header size (3 bytes) 229 ACPI_RS_OFFSET(data.dma.channel_count)}
549 */ 230};
550 *length_field = (u16) (*bytes_consumed - 3);
551 return_ACPI_STATUS(AE_OK);
552}
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index 103eb31c284e..1434e786477e 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,52 +49,12 @@ ACPI_MODULE_NAME("rslist")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_get_resource_type 52 * FUNCTION: acpi_rs_convert_aml_to_resources
53 * 53 *
54 * PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor 54 * PARAMETERS: Aml - Pointer to the resource byte stream
55 * 55 * aml_length - Length of Aml
56 * RETURN: The Resource Type with no extraneous bits 56 * output_buffer - Pointer to the buffer that will
57 * 57 * contain the output structures
58 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
59 * a resource descriptor.
60 *
61 ******************************************************************************/
62u8 acpi_rs_get_resource_type(u8 resource_start_byte)
63{
64
65 ACPI_FUNCTION_ENTRY();
66
67 /* Determine if this is a small or large resource */
68
69 switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) {
70 case ACPI_RDESC_TYPE_SMALL:
71
72 /* Small Resource Type -- Only bits 6:3 are valid */
73
74 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
75
76 case ACPI_RDESC_TYPE_LARGE:
77
78 /* Large Resource Type -- All bits are valid */
79
80 return (resource_start_byte);
81
82 default:
83 /* Invalid type */
84 break;
85 }
86
87 return (0xFF);
88}
89
90/*******************************************************************************
91 *
92 * FUNCTION: acpi_rs_byte_stream_to_list
93 *
94 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream
95 * byte_stream_buffer_length - Length of byte_stream_buffer
96 * output_buffer - Pointer to the buffer that will
97 * contain the output structures
98 * 58 *
99 * RETURN: Status 59 * RETURN: Status
100 * 60 *
@@ -102,241 +62,78 @@ u8 acpi_rs_get_resource_type(u8 resource_start_byte)
102 * linked list of resources in the caller's output buffer 62 * linked list of resources in the caller's output buffer
103 * 63 *
104 ******************************************************************************/ 64 ******************************************************************************/
105
106acpi_status 65acpi_status
107acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, 66acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer)
108 u32 byte_stream_buffer_length, u8 * output_buffer)
109{ 67{
68 struct acpi_resource *resource = (void *)output_buffer;
110 acpi_status status; 69 acpi_status status;
111 acpi_size bytes_parsed = 0; 70 u8 resource_index;
112 u8 resource_type = 0; 71 u8 *end_aml;
113 acpi_size bytes_consumed = 0; 72
114 u8 *buffer = output_buffer; 73 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
115 acpi_size structure_size = 0;
116 u8 end_tag_processed = FALSE;
117 struct acpi_resource *resource;
118
119 ACPI_FUNCTION_TRACE("rs_byte_stream_to_list");
120
121 while (bytes_parsed < byte_stream_buffer_length && !end_tag_processed) {
122 /* The next byte in the stream is the resource type */
123
124 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer);
125
126 switch (resource_type) {
127 case ACPI_RDESC_TYPE_MEMORY_24:
128 /*
129 * 24-Bit Memory Resource
130 */
131 status = acpi_rs_memory24_resource(byte_stream_buffer,
132 &bytes_consumed,
133 &buffer,
134 &structure_size);
135 break;
136
137 case ACPI_RDESC_TYPE_LARGE_VENDOR:
138 /*
139 * Vendor Defined Resource
140 */
141 status = acpi_rs_vendor_resource(byte_stream_buffer,
142 &bytes_consumed,
143 &buffer,
144 &structure_size);
145 break;
146
147 case ACPI_RDESC_TYPE_MEMORY_32:
148 /*
149 * 32-Bit Memory Range Resource
150 */
151 status =
152 acpi_rs_memory32_range_resource(byte_stream_buffer,
153 &bytes_consumed,
154 &buffer,
155 &structure_size);
156 break;
157
158 case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
159 /*
160 * 32-Bit Fixed Memory Resource
161 */
162 status =
163 acpi_rs_fixed_memory32_resource(byte_stream_buffer,
164 &bytes_consumed,
165 &buffer,
166 &structure_size);
167 break;
168
169 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
170 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE:
171 /*
172 * 64-Bit Address Resource
173 */
174 status = acpi_rs_address64_resource(byte_stream_buffer,
175 &bytes_consumed,
176 &buffer,
177 &structure_size);
178 break;
179
180 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
181 /*
182 * 32-Bit Address Resource
183 */
184 status = acpi_rs_address32_resource(byte_stream_buffer,
185 &bytes_consumed,
186 &buffer,
187 &structure_size);
188 break;
189
190 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
191 /*
192 * 16-Bit Address Resource
193 */
194 status = acpi_rs_address16_resource(byte_stream_buffer,
195 &bytes_consumed,
196 &buffer,
197 &structure_size);
198 break;
199
200 case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
201 /*
202 * Extended IRQ
203 */
204 status =
205 acpi_rs_extended_irq_resource(byte_stream_buffer,
206 &bytes_consumed,
207 &buffer,
208 &structure_size);
209 break;
210
211 case ACPI_RDESC_TYPE_IRQ_FORMAT:
212 /*
213 * IRQ Resource
214 */
215 status = acpi_rs_irq_resource(byte_stream_buffer,
216 &bytes_consumed, &buffer,
217 &structure_size);
218 break;
219
220 case ACPI_RDESC_TYPE_DMA_FORMAT:
221 /*
222 * DMA Resource
223 */
224 status = acpi_rs_dma_resource(byte_stream_buffer,
225 &bytes_consumed, &buffer,
226 &structure_size);
227 break;
228
229 case ACPI_RDESC_TYPE_START_DEPENDENT:
230 /*
231 * Start Dependent Functions Resource
232 */
233 status =
234 acpi_rs_start_depend_fns_resource
235 (byte_stream_buffer, &bytes_consumed, &buffer,
236 &structure_size);
237 break;
238
239 case ACPI_RDESC_TYPE_END_DEPENDENT:
240 /*
241 * End Dependent Functions Resource
242 */
243 status =
244 acpi_rs_end_depend_fns_resource(byte_stream_buffer,
245 &bytes_consumed,
246 &buffer,
247 &structure_size);
248 break;
249
250 case ACPI_RDESC_TYPE_IO_PORT:
251 /*
252 * IO Port Resource
253 */
254 status = acpi_rs_io_resource(byte_stream_buffer,
255 &bytes_consumed, &buffer,
256 &structure_size);
257 break;
258
259 case ACPI_RDESC_TYPE_FIXED_IO_PORT:
260 /*
261 * Fixed IO Port Resource
262 */
263 status = acpi_rs_fixed_io_resource(byte_stream_buffer,
264 &bytes_consumed,
265 &buffer,
266 &structure_size);
267 break;
268
269 case ACPI_RDESC_TYPE_SMALL_VENDOR:
270 /*
271 * Vendor Specific Resource
272 */
273 status = acpi_rs_vendor_resource(byte_stream_buffer,
274 &bytes_consumed,
275 &buffer,
276 &structure_size);
277 break;
278
279 case ACPI_RDESC_TYPE_END_TAG:
280 /*
281 * End Tag
282 */
283 end_tag_processed = TRUE;
284 status = acpi_rs_end_tag_resource(byte_stream_buffer,
285 &bytes_consumed,
286 &buffer,
287 &structure_size);
288 break;
289
290 default:
291 /*
292 * Invalid/Unknown resource type
293 */
294 status = AE_AML_INVALID_RESOURCE_TYPE;
295 break;
296 }
297 74
75 end_aml = aml + aml_length;
76
77 /* Loop until end-of-buffer or an end_tag is found */
78
79 while (aml < end_aml) {
80 /* Validate the Resource Type and Resource Length */
81
82 status = acpi_ut_validate_resource(aml, &resource_index);
298 if (ACPI_FAILURE(status)) { 83 if (ACPI_FAILURE(status)) {
299 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
300 } 85 }
301 86
302 /* Update the return value and counter */ 87 /* Convert the AML byte stream resource to a local resource struct */
303 88
304 bytes_parsed += bytes_consumed; 89 status =
90 acpi_rs_convert_aml_to_resource(resource,
91 ACPI_CAST_PTR(union
92 aml_resource,
93 aml),
94 acpi_gbl_get_resource_dispatch
95 [resource_index]);
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "Could not convert AML resource (Type %X)",
99 *aml));
100 return_ACPI_STATUS(status);
101 }
305 102
306 /* Set the byte stream to point to the next resource */ 103 /* Normal exit on completion of an end_tag resource descriptor */
307 104
308 byte_stream_buffer += bytes_consumed; 105 if (acpi_ut_get_resource_type(aml) ==
106 ACPI_RESOURCE_NAME_END_TAG) {
107 return_ACPI_STATUS(AE_OK);
108 }
309 109
310 /* Set the Buffer to the next structure */ 110 /* Point to the next input AML resource */
311 111
312 resource = ACPI_CAST_PTR(struct acpi_resource, buffer); 112 aml += acpi_ut_get_descriptor_length(aml);
313 resource->length =
314 (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length);
315 buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
316 }
317 113
318 /* Check the reason for exiting the while loop */ 114 /* Point to the next structure in the output buffer */
319 115
320 if (!end_tag_processed) { 116 resource =
321 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 117 ACPI_ADD_PTR(struct acpi_resource, resource,
118 resource->length);
322 } 119 }
323 120
324 return_ACPI_STATUS(AE_OK); 121 /* Did not find an end_tag resource descriptor */
122
123 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
325} 124}
326 125
327/******************************************************************************* 126/*******************************************************************************
328 * 127 *
329 * FUNCTION: acpi_rs_list_to_byte_stream 128 * FUNCTION: acpi_rs_convert_resources_to_aml
330 * 129 *
331 * PARAMETERS: linked_list - Pointer to the resource linked list 130 * PARAMETERS: Resource - Pointer to the resource linked list
332 * byte_steam_size_needed - Calculated size of the byte stream 131 * aml_size_needed - Calculated size of the byte stream
333 * needed from calling 132 * needed from calling acpi_rs_get_aml_length()
334 * acpi_rs_get_byte_stream_length() 133 * The size of the output_buffer is
335 * The size of the output_buffer is 134 * guaranteed to be >= aml_size_needed
336 * guaranteed to be >= 135 * output_buffer - Pointer to the buffer that will
337 * byte_stream_size_needed 136 * contain the byte stream
338 * output_buffer - Pointer to the buffer that will
339 * contain the byte stream
340 * 137 *
341 * RETURN: Status 138 * RETURN: Status
342 * 139 *
@@ -346,180 +143,73 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
346 ******************************************************************************/ 143 ******************************************************************************/
347 144
348acpi_status 145acpi_status
349acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list, 146acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
350 acpi_size byte_stream_size_needed, 147 acpi_size aml_size_needed, u8 * output_buffer)
351 u8 * output_buffer)
352{ 148{
149 u8 *aml = output_buffer;
150 u8 *end_aml = output_buffer + aml_size_needed;
353 acpi_status status; 151 acpi_status status;
354 u8 *buffer = output_buffer; 152
355 acpi_size bytes_consumed = 0; 153 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
356 u8 done = FALSE; 154
357 155 /* Walk the resource descriptor list, convert each descriptor */
358 ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); 156
359 157 while (aml < end_aml) {
360 while (!done) { 158 /* Validate the (internal) Resource Type */
361 switch (linked_list->id) { 159
362 case ACPI_RSTYPE_IRQ: 160 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
363 /* 161 ACPI_ERROR((AE_INFO,
364 * IRQ Resource 162 "Invalid descriptor type (%X) in resource list",
365 */ 163 resource->type));
366 status = 164 return_ACPI_STATUS(AE_BAD_DATA);
367 acpi_rs_irq_stream(linked_list, &buffer,
368 &bytes_consumed);
369 break;
370
371 case ACPI_RSTYPE_DMA:
372 /*
373 * DMA Resource
374 */
375 status =
376 acpi_rs_dma_stream(linked_list, &buffer,
377 &bytes_consumed);
378 break;
379
380 case ACPI_RSTYPE_START_DPF:
381 /*
382 * Start Dependent Functions Resource
383 */
384 status = acpi_rs_start_depend_fns_stream(linked_list,
385 &buffer,
386 &bytes_consumed);
387 break;
388
389 case ACPI_RSTYPE_END_DPF:
390 /*
391 * End Dependent Functions Resource
392 */
393 status = acpi_rs_end_depend_fns_stream(linked_list,
394 &buffer,
395 &bytes_consumed);
396 break;
397
398 case ACPI_RSTYPE_IO:
399 /*
400 * IO Port Resource
401 */
402 status =
403 acpi_rs_io_stream(linked_list, &buffer,
404 &bytes_consumed);
405 break;
406
407 case ACPI_RSTYPE_FIXED_IO:
408 /*
409 * Fixed IO Port Resource
410 */
411 status =
412 acpi_rs_fixed_io_stream(linked_list, &buffer,
413 &bytes_consumed);
414 break;
415
416 case ACPI_RSTYPE_VENDOR:
417 /*
418 * Vendor Defined Resource
419 */
420 status =
421 acpi_rs_vendor_stream(linked_list, &buffer,
422 &bytes_consumed);
423 break;
424
425 case ACPI_RSTYPE_END_TAG:
426 /*
427 * End Tag
428 */
429 status =
430 acpi_rs_end_tag_stream(linked_list, &buffer,
431 &bytes_consumed);
432
433 /* An End Tag indicates the end of the Resource Template */
434
435 done = TRUE;
436 break;
437
438 case ACPI_RSTYPE_MEM24:
439 /*
440 * 24-Bit Memory Resource
441 */
442 status =
443 acpi_rs_memory24_stream(linked_list, &buffer,
444 &bytes_consumed);
445 break;
446
447 case ACPI_RSTYPE_MEM32:
448 /*
449 * 32-Bit Memory Range Resource
450 */
451 status =
452 acpi_rs_memory32_range_stream(linked_list, &buffer,
453 &bytes_consumed);
454 break;
455
456 case ACPI_RSTYPE_FIXED_MEM32:
457 /*
458 * 32-Bit Fixed Memory Resource
459 */
460 status =
461 acpi_rs_fixed_memory32_stream(linked_list, &buffer,
462 &bytes_consumed);
463 break;
464
465 case ACPI_RSTYPE_ADDRESS16:
466 /*
467 * 16-Bit Address Descriptor Resource
468 */
469 status = acpi_rs_address16_stream(linked_list, &buffer,
470 &bytes_consumed);
471 break;
472
473 case ACPI_RSTYPE_ADDRESS32:
474 /*
475 * 32-Bit Address Descriptor Resource
476 */
477 status = acpi_rs_address32_stream(linked_list, &buffer,
478 &bytes_consumed);
479 break;
480
481 case ACPI_RSTYPE_ADDRESS64:
482 /*
483 * 64-Bit Address Descriptor Resource
484 */
485 status = acpi_rs_address64_stream(linked_list, &buffer,
486 &bytes_consumed);
487 break;
488
489 case ACPI_RSTYPE_EXT_IRQ:
490 /*
491 * Extended IRQ Resource
492 */
493 status =
494 acpi_rs_extended_irq_stream(linked_list, &buffer,
495 &bytes_consumed);
496 break;
497
498 default:
499 /*
500 * If we get here, everything is out of sync,
501 * so exit with an error
502 */
503 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
504 "Invalid descriptor type (%X) in resource list\n",
505 linked_list->id));
506 status = AE_BAD_DATA;
507 break;
508 } 165 }
509 166
167 /* Perform the conversion */
168
169 status = acpi_rs_convert_resource_to_aml(resource,
170 ACPI_CAST_PTR(union
171 aml_resource,
172 aml),
173 acpi_gbl_set_resource_dispatch
174 [resource->type]);
510 if (ACPI_FAILURE(status)) { 175 if (ACPI_FAILURE(status)) {
176 ACPI_EXCEPTION((AE_INFO, status,
177 "Could not convert resource (type %X) to AML",
178 resource->type));
511 return_ACPI_STATUS(status); 179 return_ACPI_STATUS(status);
512 } 180 }
513 181
514 /* Set the Buffer to point to the open byte */ 182 /* Perform final sanity check on the new AML resource descriptor */
183
184 status =
185 acpi_ut_validate_resource(ACPI_CAST_PTR
186 (union aml_resource, aml), NULL);
187 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS(status);
189 }
515 190
516 buffer += bytes_consumed; 191 /* Check for end-of-list, normal exit */
517 192
518 /* Point to the next object */ 193 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
194 /* An End Tag indicates the end of the input Resource Template */
519 195
520 linked_list = ACPI_PTR_ADD(struct acpi_resource, 196 return_ACPI_STATUS(AE_OK);
521 linked_list, linked_list->length); 197 }
198
199 /*
200 * Extract the total length of the new descriptor and set the
201 * Aml to point to the next (output) resource descriptor
202 */
203 aml += acpi_ut_get_descriptor_length(aml);
204
205 /* Point to the next input resource descriptor */
206
207 resource =
208 ACPI_ADD_PTR(struct acpi_resource, resource,
209 resource->length);
522 } 210 }
523 211
524 return_ACPI_STATUS(AE_OK); 212 /* Completed buffer, but did not find an end_tag resource descriptor */
213
214 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
525} 215}
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index daba1a1ed46d..a5131936d690 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,454 +49,187 @@ ACPI_MODULE_NAME("rsmemory")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_memory24_resource 52 * acpi_rs_convert_memory24
53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 53 *
69 ******************************************************************************/ 54 ******************************************************************************/
70acpi_status 55struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = {
71acpi_rs_memory24_resource(u8 * byte_stream_buffer, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
72 acpi_size * bytes_consumed, 57 ACPI_RS_SIZE(struct acpi_resource_memory24),
73 u8 ** output_buffer, acpi_size * structure_size) 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)},
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size =
80 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
81
82 ACPI_FUNCTION_TRACE("rs_memory24_resource");
83
84 /* Point past the Descriptor to get the number of bytes consumed */
85
86 buffer += 1;
87
88 ACPI_MOVE_16_TO_16(&temp16, buffer);
89 buffer += 2;
90 *bytes_consumed = (acpi_size) temp16 + 3;
91 output_struct->id = ACPI_RSTYPE_MEM24;
92
93 /* Check Byte 3 the Read/Write bit */
94
95 temp8 = *buffer;
96 buffer += 1;
97 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
98
99 /* Get min_base_address (Bytes 4-5) */
100
101 ACPI_MOVE_16_TO_16(&temp16, buffer);
102 buffer += 2;
103 output_struct->data.memory24.min_base_address = temp16;
104
105 /* Get max_base_address (Bytes 6-7) */
106
107 ACPI_MOVE_16_TO_16(&temp16, buffer);
108 buffer += 2;
109 output_struct->data.memory24.max_base_address = temp16;
110 59
111 /* Get Alignment (Bytes 8-9) */ 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
61 sizeof(struct aml_resource_memory24),
62 0},
112 63
113 ACPI_MOVE_16_TO_16(&temp16, buffer); 64 /* Read/Write bit */
114 buffer += 2;
115 output_struct->data.memory24.alignment = temp16;
116 65
117 /* Get range_length (Bytes 10-11) */ 66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect),
118 67 AML_OFFSET(memory24.flags),
119 ACPI_MOVE_16_TO_16(&temp16, buffer); 68 0},
120 output_struct->data.memory24.range_length = temp16; 69 /*
121 70 * These fields are contiguous in both the source and destination:
122 /* Set the Length parameter */ 71 * Minimum Base Address
123 72 * Maximum Base Address
124 output_struct->length = (u32) struct_size; 73 * Address Base Alignment
125 74 * Range Length
126 /* Return the final size of the structure */ 75 */
127 76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum),
128 *structure_size = struct_size; 77 AML_OFFSET(memory24.minimum),
129 return_ACPI_STATUS(AE_OK); 78 4}
130} 79};
131 80
132/******************************************************************************* 81/*******************************************************************************
133 * 82 *
134 * FUNCTION: acpi_rs_memory24_stream 83 * acpi_rs_convert_memory32
135 *
136 * PARAMETERS: linked_list - Pointer to the resource linked list
137 * output_buffer - Pointer to the user's return buffer
138 * bytes_consumed - Pointer to where the number of bytes
139 * used in the output_buffer is returned
140 *
141 * RETURN: Status
142 *
143 * DESCRIPTION: Take the linked list resource structure and fills in the
144 * the appropriate bytes in a byte stream
145 * 84 *
146 ******************************************************************************/ 85 ******************************************************************************/
147 86
148acpi_status 87struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = {
149acpi_rs_memory24_stream(struct acpi_resource *linked_list, 88 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
150 u8 ** output_buffer, acpi_size * bytes_consumed) 89 ACPI_RS_SIZE(struct acpi_resource_memory32),
151{ 90 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)},
152 u8 *buffer = *output_buffer;
153 u16 temp16 = 0;
154 u8 temp8 = 0;
155
156 ACPI_FUNCTION_TRACE("rs_memory24_stream");
157
158 /* The descriptor field is static */
159
160 *buffer = 0x81;
161 buffer += 1;
162 91
163 /* The length field is static */ 92 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
93 sizeof(struct aml_resource_memory32),
94 0},
164 95
165 temp16 = 0x09; 96 /* Read/Write bit */
166 ACPI_MOVE_16_TO_16(buffer, &temp16);
167 buffer += 2;
168 97
169 /* Set the Information Byte */ 98 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect),
170 99 AML_OFFSET(memory32.flags),
171 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); 100 0},
172 *buffer = temp8; 101 /*
173 buffer += 1; 102 * These fields are contiguous in both the source and destination:
174 103 * Minimum Base Address
175 /* Set the Range minimum base address */ 104 * Maximum Base Address
176 105 * Address Base Alignment
177 ACPI_MOVE_32_TO_16(buffer, 106 * Range Length
178 &linked_list->data.memory24.min_base_address); 107 */
179 buffer += 2; 108 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum),
180 109 AML_OFFSET(memory32.minimum),
181 /* Set the Range maximum base address */ 110 4}
182 111};
183 ACPI_MOVE_32_TO_16(buffer,
184 &linked_list->data.memory24.max_base_address);
185 buffer += 2;
186
187 /* Set the base alignment */
188
189 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.alignment);
190 buffer += 2;
191
192 /* Set the range length */
193
194 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.range_length);
195 buffer += 2;
196
197 /* Return the number of bytes consumed in this operation */
198
199 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
200 return_ACPI_STATUS(AE_OK);
201}
202 112
203/******************************************************************************* 113/*******************************************************************************
204 * 114 *
205 * FUNCTION: acpi_rs_memory32_range_resource 115 * acpi_rs_convert_fixed_memory32
206 *
207 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
208 * stream
209 * bytes_consumed - Pointer to where the number of bytes
210 * consumed the byte_stream_buffer is
211 * returned
212 * output_buffer - Pointer to the return data buffer
213 * structure_size - Pointer to where the number of bytes
214 * in the return data struct is returned
215 *
216 * RETURN: Status
217 *
218 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
219 * structure pointed to by the output_buffer. Return the
220 * number of bytes consumed from the byte stream.
221 * 116 *
222 ******************************************************************************/ 117 ******************************************************************************/
223 118
224acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = {
225acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
226 acpi_size * bytes_consumed, 121 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
227 u8 ** output_buffer, acpi_size * structure_size) 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)},
228{
229 u8 *buffer = byte_stream_buffer;
230 struct acpi_resource *output_struct = (void *)*output_buffer;
231 u16 temp16 = 0;
232 u8 temp8 = 0;
233 acpi_size struct_size =
234 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
235
236 ACPI_FUNCTION_TRACE("rs_memory32_range_resource");
237
238 /* Point past the Descriptor to get the number of bytes consumed */
239
240 buffer += 1;
241 123
242 ACPI_MOVE_16_TO_16(&temp16, buffer); 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
243 buffer += 2; 125 sizeof(struct aml_resource_fixed_memory32),
244 *bytes_consumed = (acpi_size) temp16 + 3; 126 0},
245 127
246 output_struct->id = ACPI_RSTYPE_MEM32; 128 /* Read/Write bit */
247 129
130 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect),
131 AML_OFFSET(fixed_memory32.flags),
132 0},
248 /* 133 /*
249 * Point to the place in the output buffer where the data portion will 134 * These fields are contiguous in both the source and destination:
250 * begin. 135 * Base Address
251 * 1. Set the RESOURCE_DATA * Data to point to its own address, then 136 * Range Length
252 * 2. Set the pointer to the next address.
253 *
254 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
255 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
256 */ 137 */
257 138 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address),
258 /* Check Byte 3 the Read/Write bit */ 139 AML_OFFSET(fixed_memory32.address),
259 140 2}
260 temp8 = *buffer; 141};
261 buffer += 1;
262
263 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
264
265 /* Get min_base_address (Bytes 4-7) */
266
267 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address,
268 buffer);
269 buffer += 4;
270
271 /* Get max_base_address (Bytes 8-11) */
272
273 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address,
274 buffer);
275 buffer += 4;
276
277 /* Get Alignment (Bytes 12-15) */
278
279 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer);
280 buffer += 4;
281
282 /* Get range_length (Bytes 16-19) */
283
284 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer);
285
286 /* Set the Length parameter */
287
288 output_struct->length = (u32) struct_size;
289
290 /* Return the final size of the structure */
291
292 *structure_size = struct_size;
293 return_ACPI_STATUS(AE_OK);
294}
295 142
296/******************************************************************************* 143/*******************************************************************************
297 * 144 *
298 * FUNCTION: acpi_rs_fixed_memory32_resource 145 * acpi_rs_get_vendor_small
299 *
300 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
301 * stream
302 * bytes_consumed - Pointer to where the number of bytes
303 * consumed the byte_stream_buffer is
304 * returned
305 * output_buffer - Pointer to the return data buffer
306 * structure_size - Pointer to where the number of bytes
307 * in the return data struct is returned
308 *
309 * RETURN: Status
310 *
311 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
312 * structure pointed to by the output_buffer. Return the
313 * number of bytes consumed from the byte stream.
314 * 146 *
315 ******************************************************************************/ 147 ******************************************************************************/
316 148
317acpi_status 149struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
318acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, 150 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
319 acpi_size * bytes_consumed, 151 ACPI_RS_SIZE(struct acpi_resource_vendor),
320 u8 ** output_buffer, acpi_size * structure_size) 152 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)},
321{
322 u8 *buffer = byte_stream_buffer;
323 struct acpi_resource *output_struct = (void *)*output_buffer;
324 u16 temp16 = 0;
325 u8 temp8 = 0;
326 acpi_size struct_size =
327 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32);
328
329 ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource");
330 153
331 /* Point past the Descriptor to get the number of bytes consumed */ 154 /* Length of the vendor data (byte count) */
332 155
333 buffer += 1; 156 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
334 ACPI_MOVE_16_TO_16(&temp16, buffer); 157 0,
158 sizeof(u8)}
159 ,
335 160
336 buffer += 2; 161 /* Vendor data */
337 *bytes_consumed = (acpi_size) temp16 + 3;
338 162
339 output_struct->id = ACPI_RSTYPE_FIXED_MEM32; 163 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
340 164 sizeof(struct aml_resource_small_header),
341 /* Check Byte 3 the Read/Write bit */ 165 0}
342 166};
343 temp8 = *buffer;
344 buffer += 1;
345 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
346
347 /* Get range_base_address (Bytes 4-7) */
348
349 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.
350 range_base_address, buffer);
351 buffer += 4;
352
353 /* Get range_length (Bytes 8-11) */
354
355 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length,
356 buffer);
357
358 /* Set the Length parameter */
359
360 output_struct->length = (u32) struct_size;
361
362 /* Return the final size of the structure */
363
364 *structure_size = struct_size;
365 return_ACPI_STATUS(AE_OK);
366}
367 167
368/******************************************************************************* 168/*******************************************************************************
369 * 169 *
370 * FUNCTION: acpi_rs_memory32_range_stream 170 * acpi_rs_get_vendor_large
371 *
372 * PARAMETERS: linked_list - Pointer to the resource linked list
373 * output_buffer - Pointer to the user's return buffer
374 * bytes_consumed - Pointer to where the number of bytes
375 * used in the output_buffer is returned
376 *
377 * RETURN: Status
378 *
379 * DESCRIPTION: Take the linked list resource structure and fills in the
380 * the appropriate bytes in a byte stream
381 * 171 *
382 ******************************************************************************/ 172 ******************************************************************************/
383 173
384acpi_status 174struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
385acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, 175 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
386 u8 ** output_buffer, acpi_size * bytes_consumed) 176 ACPI_RS_SIZE(struct acpi_resource_vendor),
387{ 177 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)},
388 u8 *buffer = *output_buffer;
389 u16 temp16 = 0;
390 u8 temp8 = 0;
391
392 ACPI_FUNCTION_TRACE("rs_memory32_range_stream");
393
394 /* The descriptor field is static */
395
396 *buffer = 0x85;
397 buffer += 1;
398
399 /* The length field is static */
400
401 temp16 = 0x11;
402
403 ACPI_MOVE_16_TO_16(buffer, &temp16);
404 buffer += 2;
405
406 /* Set the Information Byte */
407
408 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
409 *buffer = temp8;
410 buffer += 1;
411
412 /* Set the Range minimum base address */
413
414 ACPI_MOVE_32_TO_32(buffer,
415 &linked_list->data.memory32.min_base_address);
416 buffer += 4;
417
418 /* Set the Range maximum base address */
419
420 ACPI_MOVE_32_TO_32(buffer,
421 &linked_list->data.memory32.max_base_address);
422 buffer += 4;
423 178
424 /* Set the base alignment */ 179 /* Length of the vendor data (byte count) */
425 180
426 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.alignment); 181 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
427 buffer += 4; 182 0,
183 sizeof(u8)}
184 ,
428 185
429 /* Set the range length */ 186 /* Vendor data */
430 187
431 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.range_length); 188 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
432 buffer += 4; 189 sizeof(struct aml_resource_large_header),
433 190 0}
434 /* Return the number of bytes consumed in this operation */ 191};
435
436 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
437 return_ACPI_STATUS(AE_OK);
438}
439 192
440/******************************************************************************* 193/*******************************************************************************
441 * 194 *
442 * FUNCTION: acpi_rs_fixed_memory32_stream 195 * acpi_rs_set_vendor
443 *
444 * PARAMETERS: linked_list - Pointer to the resource linked list
445 * output_buffer - Pointer to the user's return buffer
446 * bytes_consumed - Pointer to where the number of bytes
447 * used in the output_buffer is returned
448 *
449 * RETURN: Status
450 *
451 * DESCRIPTION: Take the linked list resource structure and fills in the
452 * the appropriate bytes in a byte stream
453 * 196 *
454 ******************************************************************************/ 197 ******************************************************************************/
455 198
456acpi_status 199struct acpi_rsconvert_info acpi_rs_set_vendor[7] = {
457acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, 200 /* Default is a small vendor descriptor */
458 u8 ** output_buffer, acpi_size * bytes_consumed)
459{
460 u8 *buffer = *output_buffer;
461 u16 temp16 = 0;
462 u8 temp8 = 0;
463
464 ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream");
465 201
466 /* The descriptor field is static */ 202 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
203 sizeof(struct aml_resource_small_header),
204 ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)},
467 205
468 *buffer = 0x86; 206 /* Get the length and copy the data */
469 buffer += 1;
470 207
471 /* The length field is static */ 208 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
209 0,
210 0},
472 211
473 temp16 = 0x09; 212 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
213 sizeof(struct aml_resource_small_header),
214 0},
474 215
475 ACPI_MOVE_16_TO_16(buffer, &temp16); 216 /*
476 buffer += 2; 217 * All done if the Vendor byte length is 7 or less, meaning that it will
477 218 * fit within a small descriptor
478 /* Set the Information Byte */ 219 */
479 220 {ACPI_RSC_EXIT_LE, 0, 0, 7},
480 temp8 =
481 (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
482 *buffer = temp8;
483 buffer += 1;
484
485 /* Set the Range base address */
486
487 ACPI_MOVE_32_TO_32(buffer,
488 &linked_list->data.fixed_memory32.
489 range_base_address);
490 buffer += 4;
491 221
492 /* Set the range length */ 222 /* Must create a large vendor descriptor */
493 223
494 ACPI_MOVE_32_TO_32(buffer, 224 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
495 &linked_list->data.fixed_memory32.range_length); 225 sizeof(struct aml_resource_large_header),
496 buffer += 4; 226 0},
497 227
498 /* Return the number of bytes consumed in this operation */ 228 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
229 0,
230 0},
499 231
500 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 232 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
501 return_ACPI_STATUS(AE_OK); 233 sizeof(struct aml_resource_large_header),
502} 234 0}
235};
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index 7a8a34e757f5..ed866cf1c6d2 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,481 +47,501 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmisc") 48ACPI_MODULE_NAME("rsmisc")
49 49
50#define INIT_RESOURCE_TYPE(i) i->resource_offset
51#define INIT_RESOURCE_LENGTH(i) i->aml_offset
52#define INIT_TABLE_LENGTH(i) i->value
53#define COMPARE_OPCODE(i) i->resource_offset
54#define COMPARE_TARGET(i) i->aml_offset
55#define COMPARE_VALUE(i) i->value
50/******************************************************************************* 56/*******************************************************************************
51 * 57 *
52 * FUNCTION: acpi_rs_end_tag_resource 58 * FUNCTION: acpi_rs_convert_aml_to_resource
53 * 59 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 60 * PARAMETERS: Resource - Pointer to the resource descriptor
55 * stream 61 * Aml - Where the AML descriptor is returned
56 * bytes_consumed - Pointer to where the number of bytes 62 * Info - Pointer to appropriate conversion table
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 * 63 *
63 * RETURN: Status 64 * RETURN: Status
64 * 65 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 66 * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
66 * structure pointed to by the output_buffer. Return the 67 * internal resource descriptor
67 * number of bytes consumed from the byte stream.
68 * 68 *
69 ******************************************************************************/ 69 ******************************************************************************/
70acpi_status 70acpi_status
71acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 71acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
72 acpi_size * bytes_consumed, 72 union aml_resource *aml,
73 u8 ** output_buffer, acpi_size * structure_size) 73 struct acpi_rsconvert_info *info)
74{ 74{
75 struct acpi_resource *output_struct = (void *)*output_buffer; 75 acpi_rs_length aml_resource_length;
76 acpi_size struct_size = ACPI_RESOURCE_LENGTH; 76 void *source;
77 77 void *destination;
78 ACPI_FUNCTION_TRACE("rs_end_tag_resource"); 78 char *target;
79 79 u8 count;
80 /* The number of bytes consumed is static */ 80 u8 flags_mode = FALSE;
81 81 u16 item_count = 0;
82 *bytes_consumed = 2;
83
84 /* Fill out the structure */
85
86 output_struct->id = ACPI_RSTYPE_END_TAG;
87
88 /* Set the Length parameter */
89
90 output_struct->length = 0;
91
92 /* Return the final size of the structure */
93
94 *structure_size = struct_size;
95 return_ACPI_STATUS(AE_OK);
96}
97
98/*******************************************************************************
99 *
100 * FUNCTION: acpi_rs_end_tag_stream
101 *
102 * PARAMETERS: linked_list - Pointer to the resource linked list
103 * output_buffer - Pointer to the user's return buffer
104 * bytes_consumed - Pointer to where the number of bytes
105 * used in the output_buffer is returned
106 *
107 * RETURN: Status
108 *
109 * DESCRIPTION: Take the linked list resource structure and fills in the
110 * the appropriate bytes in a byte stream
111 *
112 ******************************************************************************/
113
114acpi_status
115acpi_rs_end_tag_stream(struct acpi_resource *linked_list,
116 u8 ** output_buffer, acpi_size * bytes_consumed)
117{
118 u8 *buffer = *output_buffer;
119 u8 temp8 = 0;
120
121 ACPI_FUNCTION_TRACE("rs_end_tag_stream");
122
123 /* The descriptor field is static */
124
125 *buffer = 0x79;
126 buffer += 1;
127
128 /*
129 * Set the Checksum - zero means that the resource data is treated as if
130 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
131 */
132 temp8 = 0;
133
134 *buffer = temp8;
135 buffer += 1;
136
137 /* Return the number of bytes consumed in this operation */
138
139 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
140 return_ACPI_STATUS(AE_OK);
141}
142
143/*******************************************************************************
144 *
145 * FUNCTION: acpi_rs_vendor_resource
146 *
147 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
148 * stream
149 * bytes_consumed - Pointer to where the number of bytes
150 * consumed the byte_stream_buffer is
151 * returned
152 * output_buffer - Pointer to the return data buffer
153 * structure_size - Pointer to where the number of bytes
154 * in the return data struct is returned
155 *
156 * RETURN: Status
157 *
158 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
159 * structure pointed to by the output_buffer. Return the
160 * number of bytes consumed from the byte stream.
161 *
162 ******************************************************************************/
163
164acpi_status
165acpi_rs_vendor_resource(u8 * byte_stream_buffer,
166 acpi_size * bytes_consumed,
167 u8 ** output_buffer, acpi_size * structure_size)
168{
169 u8 *buffer = byte_stream_buffer;
170 struct acpi_resource *output_struct = (void *)*output_buffer;
171 u16 temp16 = 0; 82 u16 temp16 = 0;
172 u8 temp8 = 0;
173 u8 index;
174 acpi_size struct_size =
175 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor);
176
177 ACPI_FUNCTION_TRACE("rs_vendor_resource");
178
179 /* Dereference the Descriptor to find if this is a large or small item. */
180
181 temp8 = *buffer;
182
183 if (temp8 & 0x80) {
184 /* Large Item, point to the length field */
185
186 buffer += 1;
187 83
188 /* Dereference */ 84 ACPI_FUNCTION_TRACE("rs_get_resource");
189 85
190 ACPI_MOVE_16_TO_16(&temp16, buffer); 86 if (((acpi_native_uint) resource) & 0x3) {
87 /* Each internal resource struct is expected to be 32-bit aligned */
191 88
192 /* Calculate bytes consumed */ 89 ACPI_WARNING((AE_INFO,
193 90 "Misaligned resource pointer (get): %p Type %2.2X Len %X",
194 *bytes_consumed = (acpi_size) temp16 + 3; 91 resource, resource->type, resource->length));
195
196 /* Point to the first vendor byte */
197
198 buffer += 2;
199 } else {
200 /* Small Item, dereference the size */
201
202 temp16 = (u8) (*buffer & 0x07);
203
204 /* Calculate bytes consumed */
205
206 *bytes_consumed = (acpi_size) temp16 + 1;
207
208 /* Point to the first vendor byte */
209
210 buffer += 1;
211 } 92 }
212 93
213 output_struct->id = ACPI_RSTYPE_VENDOR; 94 /* Extract the resource Length field (does not include header length) */
214 output_struct->data.vendor_specific.length = temp16;
215 95
216 for (index = 0; index < temp16; index++) { 96 aml_resource_length = acpi_ut_get_resource_length(aml);
217 output_struct->data.vendor_specific.reserved[index] = *buffer;
218 buffer += 1;
219 }
220 97
221 /* 98 /*
222 * In order for the struct_size to fall on a 32-bit boundary, 99 * First table entry must be ACPI_RSC_INITxxx and must contain the
223 * calculate the length of the vendor string and expand the 100 * table length (# of table entries)
224 * struct_size to the next 32-bit boundary.
225 */ 101 */
226 struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); 102 count = INIT_TABLE_LENGTH(info);
227 103
228 /* Set the Length parameter */ 104 while (count) {
229 105 /*
230 output_struct->length = (u32) struct_size; 106 * Source is the external AML byte stream buffer,
231 107 * destination is the internal resource descriptor
232 /* Return the final size of the structure */ 108 */
233 109 source = ACPI_ADD_PTR(void, aml, info->aml_offset);
234 *structure_size = struct_size; 110 destination =
235 return_ACPI_STATUS(AE_OK); 111 ACPI_ADD_PTR(void, resource, info->resource_offset);
236} 112
237 113 switch (info->opcode) {
238/******************************************************************************* 114 case ACPI_RSC_INITGET:
239 * 115 /*
240 * FUNCTION: acpi_rs_vendor_stream 116 * Get the resource type and the initial (minimum) length
241 * 117 */
242 * PARAMETERS: linked_list - Pointer to the resource linked list 118 ACPI_MEMSET(resource, 0, INIT_RESOURCE_LENGTH(info));
243 * output_buffer - Pointer to the user's return buffer 119 resource->type = INIT_RESOURCE_TYPE(info);
244 * bytes_consumed - Pointer to where the number of bytes 120 resource->length = INIT_RESOURCE_LENGTH(info);
245 * used in the output_buffer is returned 121 break;
246 * 122
247 * RETURN: Status 123 case ACPI_RSC_INITSET:
248 * 124 break;
249 * DESCRIPTION: Take the linked list resource structure and fills in the 125
250 * the appropriate bytes in a byte stream 126 case ACPI_RSC_FLAGINIT:
251 * 127
252 ******************************************************************************/ 128 flags_mode = TRUE;
253 129 break;
254acpi_status 130
255acpi_rs_vendor_stream(struct acpi_resource *linked_list, 131 case ACPI_RSC_1BITFLAG:
256 u8 ** output_buffer, acpi_size * bytes_consumed) 132 /*
257{ 133 * Mask and shift the flag bit
258 u8 *buffer = *output_buffer; 134 */
259 u16 temp16 = 0; 135 ACPI_SET8(destination) = (u8)
260 u8 temp8 = 0; 136 ((ACPI_GET8(source) >> info->value) & 0x01);
261 u8 index; 137 break;
262 138
263 ACPI_FUNCTION_TRACE("rs_vendor_stream"); 139 case ACPI_RSC_2BITFLAG:
264 140 /*
265 /* Dereference the length to find if this is a large or small item. */ 141 * Mask and shift the flag bits
266 142 */
267 if (linked_list->data.vendor_specific.length > 7) { 143 ACPI_SET8(destination) = (u8)
268 /* Large Item, Set the descriptor field and length bytes */ 144 ((ACPI_GET8(source) >> info->value) & 0x03);
269 145 break;
270 *buffer = 0x84; 146
271 buffer += 1; 147 case ACPI_RSC_COUNT:
272 148
273 temp16 = (u16) linked_list->data.vendor_specific.length; 149 item_count = ACPI_GET8(source);
274 150 ACPI_SET8(destination) = (u8) item_count;
275 ACPI_MOVE_16_TO_16(buffer, &temp16); 151
276 buffer += 2; 152 resource->length = resource->length +
277 } else { 153 (info->value * (item_count - 1));
278 /* Small Item, Set the descriptor field */ 154 break;
279 155
280 temp8 = 0x70; 156 case ACPI_RSC_COUNT16:
281 temp8 |= (u8) linked_list->data.vendor_specific.length; 157
158 item_count = aml_resource_length;
159 ACPI_SET16(destination) = item_count;
160
161 resource->length = resource->length +
162 (info->value * (item_count - 1));
163 break;
164
165 case ACPI_RSC_LENGTH:
166
167 resource->length = resource->length + info->value;
168 break;
169
170 case ACPI_RSC_MOVE8:
171 case ACPI_RSC_MOVE16:
172 case ACPI_RSC_MOVE32:
173 case ACPI_RSC_MOVE64:
174 /*
175 * Raw data move. Use the Info value field unless item_count has
176 * been previously initialized via a COUNT opcode
177 */
178 if (info->value) {
179 item_count = info->value;
180 }
181 acpi_rs_move_data(destination, source, item_count,
182 info->opcode);
183 break;
184
185 case ACPI_RSC_SET8:
186
187 ACPI_MEMSET(destination, info->aml_offset, info->value);
188 break;
189
190 case ACPI_RSC_DATA8:
191
192 target = ACPI_ADD_PTR(char, resource, info->value);
193 ACPI_MEMCPY(destination, source, ACPI_GET16(target));
194 break;
195
196 case ACPI_RSC_ADDRESS:
197 /*
198 * Common handler for address descriptor flags
199 */
200 if (!acpi_rs_get_address_common(resource, aml)) {
201 return_ACPI_STATUS
202 (AE_AML_INVALID_RESOURCE_TYPE);
203 }
204 break;
205
206 case ACPI_RSC_SOURCE:
207 /*
208 * Optional resource_source (Index and String)
209 */
210 resource->length +=
211 acpi_rs_get_resource_source(aml_resource_length,
212 info->value,
213 destination, aml, NULL);
214 break;
215
216 case ACPI_RSC_SOURCEX:
217 /*
218 * Optional resource_source (Index and String). This is the more
219 * complicated case used by the Interrupt() macro
220 */
221 target =
222 ACPI_ADD_PTR(char, resource,
223 info->aml_offset + (item_count * 4));
224
225 resource->length +=
226 acpi_rs_get_resource_source(aml_resource_length,
227 (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target);
228 break;
229
230 case ACPI_RSC_BITMASK:
231 /*
232 * 8-bit encoded bitmask (DMA macro)
233 */
234 item_count =
235 acpi_rs_decode_bitmask(ACPI_GET8(source),
236 destination);
237 if (item_count) {
238 resource->length += (item_count - 1);
239 }
240
241 target = ACPI_ADD_PTR(char, resource, info->value);
242 ACPI_SET8(target) = (u8) item_count;
243 break;
244
245 case ACPI_RSC_BITMASK16:
246 /*
247 * 16-bit encoded bitmask (IRQ macro)
248 */
249 ACPI_MOVE_16_TO_16(&temp16, source);
250
251 item_count =
252 acpi_rs_decode_bitmask(temp16, destination);
253 if (item_count) {
254 resource->length += (item_count - 1);
255 }
256
257 target = ACPI_ADD_PTR(char, resource, info->value);
258 ACPI_SET8(target) = (u8) item_count;
259 break;
260
261 case ACPI_RSC_EXIT_NE:
262 /*
263 * Control - Exit conversion if not equal
264 */
265 switch (info->resource_offset) {
266 case ACPI_RSC_COMPARE_AML_LENGTH:
267 if (aml_resource_length != info->value) {
268 goto exit;
269 }
270 break;
271
272 case ACPI_RSC_COMPARE_VALUE:
273 if (ACPI_GET8(source) != info->value) {
274 goto exit;
275 }
276 break;
277
278 default:
279
280 ACPI_ERROR((AE_INFO,
281 "Invalid conversion sub-opcode"));
282 return_ACPI_STATUS(AE_BAD_PARAMETER);
283 }
284 break;
285
286 default:
287
288 ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
289 return_ACPI_STATUS(AE_BAD_PARAMETER);
290 }
282 291
283 *buffer = temp8; 292 count--;
284 buffer += 1; 293 info++;
285 } 294 }
286 295
287 /* Loop through all of the Vendor Specific fields */ 296 exit:
297 if (!flags_mode) {
298 /* Round the resource struct length up to the next 32-bit boundary */
288 299
289 for (index = 0; index < linked_list->data.vendor_specific.length; 300 resource->length = ACPI_ROUND_UP_to_32_bITS(resource->length);
290 index++) {
291 temp8 = linked_list->data.vendor_specific.reserved[index];
292
293 *buffer = temp8;
294 buffer += 1;
295 } 301 }
296
297 /* Return the number of bytes consumed in this operation */
298
299 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
300 return_ACPI_STATUS(AE_OK); 302 return_ACPI_STATUS(AE_OK);
301} 303}
302 304
303/******************************************************************************* 305/*******************************************************************************
304 * 306 *
305 * FUNCTION: acpi_rs_start_depend_fns_resource 307 * FUNCTION: acpi_rs_convert_resource_to_aml
306 * 308 *
307 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 309 * PARAMETERS: Resource - Pointer to the resource descriptor
308 * stream 310 * Aml - Where the AML descriptor is returned
309 * bytes_consumed - Pointer to where the number of bytes 311 * Info - Pointer to appropriate conversion table
310 * consumed the byte_stream_buffer is
311 * returned
312 * output_buffer - Pointer to the return data buffer
313 * structure_size - Pointer to where the number of bytes
314 * in the return data struct is returned
315 * 312 *
316 * RETURN: Status 313 * RETURN: Status
317 * 314 *
318 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 315 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
319 * structure pointed to by the output_buffer. Return the 316 * external AML resource descriptor.
320 * number of bytes consumed from the byte stream.
321 * 317 *
322 ******************************************************************************/ 318 ******************************************************************************/
323 319
324acpi_status 320acpi_status
325acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, 321acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
326 acpi_size * bytes_consumed, 322 union aml_resource *aml,
327 u8 ** output_buffer, 323 struct acpi_rsconvert_info *info)
328 acpi_size * structure_size)
329{ 324{
330 u8 *buffer = byte_stream_buffer; 325 void *source = NULL;
331 struct acpi_resource *output_struct = (void *)*output_buffer; 326 void *destination;
332 u8 temp8 = 0; 327 acpi_rsdesc_size aml_length = 0;
333 acpi_size struct_size = 328 u8 count;
334 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); 329 u16 temp16 = 0;
335 330 u16 item_count = 0;
336 ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
337
338 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
339
340 temp8 = *buffer;
341
342 *bytes_consumed = (temp8 & 0x01) + 1;
343
344 output_struct->id = ACPI_RSTYPE_START_DPF;
345
346 /* Point to Byte 1 if it is used */
347
348 if (2 == *bytes_consumed) {
349 buffer += 1;
350 temp8 = *buffer;
351
352 /* Check Compatibility priority */
353
354 output_struct->data.start_dpf.compatibility_priority =
355 temp8 & 0x03;
356
357 if (3 == output_struct->data.start_dpf.compatibility_priority) {
358 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
359 }
360
361 /* Check Performance/Robustness preference */
362 331
363 output_struct->data.start_dpf.performance_robustness = 332 ACPI_FUNCTION_TRACE("rs_convert_resource_to_aml");
364 (temp8 >> 2) & 0x03;
365 333
366 if (3 == output_struct->data.start_dpf.performance_robustness) { 334 /*
367 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); 335 * First table entry must be ACPI_RSC_INITxxx and must contain the
336 * table length (# of table entries)
337 */
338 count = INIT_TABLE_LENGTH(info);
339
340 while (count) {
341 /*
342 * Source is the internal resource descriptor,
343 * destination is the external AML byte stream buffer
344 */
345 source = ACPI_ADD_PTR(void, resource, info->resource_offset);
346 destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
347
348 switch (info->opcode) {
349 case ACPI_RSC_INITSET:
350
351 ACPI_MEMSET(aml, 0, INIT_RESOURCE_LENGTH(info));
352 aml_length = INIT_RESOURCE_LENGTH(info);
353 acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
354 aml_length, aml);
355 break;
356
357 case ACPI_RSC_INITGET:
358 break;
359
360 case ACPI_RSC_FLAGINIT:
361 /*
362 * Clear the flag byte
363 */
364 ACPI_SET8(destination) = 0;
365 break;
366
367 case ACPI_RSC_1BITFLAG:
368 /*
369 * Mask and shift the flag bit
370 */
371 ACPI_SET8(destination) |= (u8)
372 ((ACPI_GET8(source) & 0x01) << info->value);
373 break;
374
375 case ACPI_RSC_2BITFLAG:
376 /*
377 * Mask and shift the flag bits
378 */
379 ACPI_SET8(destination) |= (u8)
380 ((ACPI_GET8(source) & 0x03) << info->value);
381 break;
382
383 case ACPI_RSC_COUNT:
384
385 item_count = ACPI_GET8(source);
386 ACPI_SET8(destination) = (u8) item_count;
387
388 aml_length =
389 (u16) (aml_length +
390 (info->value * (item_count - 1)));
391 break;
392
393 case ACPI_RSC_COUNT16:
394
395 item_count = ACPI_GET16(source);
396 aml_length = (u16) (aml_length + item_count);
397 acpi_rs_set_resource_length(aml_length, aml);
398 break;
399
400 case ACPI_RSC_LENGTH:
401
402 acpi_rs_set_resource_length(info->value, aml);
403 break;
404
405 case ACPI_RSC_MOVE8:
406 case ACPI_RSC_MOVE16:
407 case ACPI_RSC_MOVE32:
408 case ACPI_RSC_MOVE64:
409
410 if (info->value) {
411 item_count = info->value;
412 }
413 acpi_rs_move_data(destination, source, item_count,
414 info->opcode);
415 break;
416
417 case ACPI_RSC_ADDRESS:
418
419 /* Set the Resource Type, General Flags, and Type-Specific Flags */
420
421 acpi_rs_set_address_common(aml, resource);
422 break;
423
424 case ACPI_RSC_SOURCEX:
425 /*
426 * Optional resource_source (Index and String)
427 */
428 aml_length =
429 acpi_rs_set_resource_source(aml,
430 (acpi_rs_length)
431 aml_length, source);
432 acpi_rs_set_resource_length(aml_length, aml);
433 break;
434
435 case ACPI_RSC_SOURCE:
436 /*
437 * Optional resource_source (Index and String). This is the more
438 * complicated case used by the Interrupt() macro
439 */
440 aml_length =
441 acpi_rs_set_resource_source(aml, info->value,
442 source);
443 acpi_rs_set_resource_length(aml_length, aml);
444 break;
445
446 case ACPI_RSC_BITMASK:
447 /*
448 * 8-bit encoded bitmask (DMA macro)
449 */
450 ACPI_SET8(destination) = (u8)
451 acpi_rs_encode_bitmask(source,
452 *ACPI_ADD_PTR(u8, resource,
453 info->value));
454 break;
455
456 case ACPI_RSC_BITMASK16:
457 /*
458 * 16-bit encoded bitmask (IRQ macro)
459 */
460 temp16 = acpi_rs_encode_bitmask(source,
461 *ACPI_ADD_PTR(u8,
462 resource,
463 info->
464 value));
465 ACPI_MOVE_16_TO_16(destination, &temp16);
466 break;
467
468 case ACPI_RSC_EXIT_LE:
469 /*
470 * Control - Exit conversion if less than or equal
471 */
472 if (item_count <= info->value) {
473 goto exit;
474 }
475 break;
476
477 case ACPI_RSC_EXIT_NE:
478 /*
479 * Control - Exit conversion if not equal
480 */
481 switch (COMPARE_OPCODE(info)) {
482 case ACPI_RSC_COMPARE_VALUE:
483
484 if (*ACPI_ADD_PTR(u8, resource,
485 COMPARE_TARGET(info)) !=
486 COMPARE_VALUE(info)) {
487 goto exit;
488 }
489 break;
490
491 default:
492
493 ACPI_ERROR((AE_INFO,
494 "Invalid conversion sub-opcode"));
495 return_ACPI_STATUS(AE_BAD_PARAMETER);
496 }
497 break;
498
499 default:
500
501 ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
502 return_ACPI_STATUS(AE_BAD_PARAMETER);
368 } 503 }
369 } else {
370 output_struct->data.start_dpf.compatibility_priority =
371 ACPI_ACCEPTABLE_CONFIGURATION;
372 504
373 output_struct->data.start_dpf.performance_robustness = 505 count--;
374 ACPI_ACCEPTABLE_CONFIGURATION; 506 info++;
375 } 507 }
376 508
377 /* Set the Length parameter */ 509 exit:
378
379 output_struct->length = (u32) struct_size;
380
381 /* Return the final size of the structure */
382
383 *structure_size = struct_size;
384 return_ACPI_STATUS(AE_OK); 510 return_ACPI_STATUS(AE_OK);
385} 511}
386 512
387/******************************************************************************* 513#if 0
388 * 514/* Previous resource validations */
389 * FUNCTION: acpi_rs_end_depend_fns_resource
390 *
391 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
392 * stream
393 * bytes_consumed - Pointer to where the number of bytes
394 * consumed the byte_stream_buffer is
395 * returned
396 * output_buffer - Pointer to the return data buffer
397 * structure_size - Pointer to where the number of bytes
398 * in the return data struct is returned
399 *
400 * RETURN: Status
401 *
402 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
403 * structure pointed to by the output_buffer. Return the
404 * number of bytes consumed from the byte stream.
405 *
406 ******************************************************************************/
407
408acpi_status
409acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
410 acpi_size * bytes_consumed,
411 u8 ** output_buffer, acpi_size * structure_size)
412{
413 struct acpi_resource *output_struct = (void *)*output_buffer;
414 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
415
416 ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
417
418 /* The number of bytes consumed is static */
419
420 *bytes_consumed = 1;
421 515
422 /* Fill out the structure */ 516if (aml->ext_address64.revision_iD != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
423 517 return_ACPI_STATUS(AE_SUPPORT);
424 output_struct->id = ACPI_RSTYPE_END_DPF;
425
426 /* Set the Length parameter */
427
428 output_struct->length = (u32) struct_size;
429
430 /* Return the final size of the structure */
431
432 *structure_size = struct_size;
433 return_ACPI_STATUS(AE_OK);
434} 518}
435 519
436/******************************************************************************* 520if (resource->data.start_dpf.performance_robustness >= 3) {
437 * 521 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
438 * FUNCTION: acpi_rs_start_depend_fns_stream 522}
439 *
440 * PARAMETERS: linked_list - Pointer to the resource linked list
441 * output_buffer - Pointer to the user's return buffer
442 * bytes_consumed - u32 pointer that is filled with
443 * the number of bytes of the
444 * output_buffer used
445 *
446 * RETURN: Status
447 *
448 * DESCRIPTION: Take the linked list resource structure and fills in the
449 * the appropriate bytes in a byte stream
450 *
451 ******************************************************************************/
452
453acpi_status
454acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
455 u8 ** output_buffer, acpi_size * bytes_consumed)
456{
457 u8 *buffer = *output_buffer;
458 u8 temp8 = 0;
459
460 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
461 523
524if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
462 /* 525 /*
463 * The descriptor field is set based upon whether a byte is needed 526 * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
464 * to contain Priority data. 527 * polarity/trigger interrupts are allowed (ACPI spec, section
528 * "IRQ Format"), so 0x00 and 0x09 are illegal.
465 */ 529 */
466 if (ACPI_ACCEPTABLE_CONFIGURATION == 530 ACPI_ERROR((AE_INFO,
467 linked_list->data.start_dpf.compatibility_priority && 531 "Invalid interrupt polarity/trigger in resource list, %X",
468 ACPI_ACCEPTABLE_CONFIGURATION == 532 aml->irq.flags));
469 linked_list->data.start_dpf.performance_robustness) { 533 return_ACPI_STATUS(AE_BAD_DATA);
470 *buffer = 0x30;
471 } else {
472 *buffer = 0x31;
473 buffer += 1;
474
475 /* Set the Priority Byte Definition */
476
477 temp8 = 0;
478 temp8 =
479 (u8) ((linked_list->data.start_dpf.
480 performance_robustness & 0x03) << 2);
481 temp8 |=
482 (linked_list->data.start_dpf.compatibility_priority & 0x03);
483 *buffer = temp8;
484 }
485
486 buffer += 1;
487
488 /* Return the number of bytes consumed in this operation */
489
490 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
491 return_ACPI_STATUS(AE_OK);
492} 534}
493 535
494/******************************************************************************* 536resource->data.extended_irq.interrupt_count = temp8;
495 * 537if (temp8 < 1) {
496 * FUNCTION: acpi_rs_end_depend_fns_stream 538 /* Must have at least one IRQ */
497 *
498 * PARAMETERS: linked_list - Pointer to the resource linked list
499 * output_buffer - Pointer to the user's return buffer
500 * bytes_consumed - Pointer to where the number of bytes
501 * used in the output_buffer is returned
502 *
503 * RETURN: Status
504 *
505 * DESCRIPTION: Take the linked list resource structure and fills in the
506 * the appropriate bytes in a byte stream
507 *
508 ******************************************************************************/
509
510acpi_status
511acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list,
512 u8 ** output_buffer, acpi_size * bytes_consumed)
513{
514 u8 *buffer = *output_buffer;
515
516 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
517
518 /* The descriptor field is static */
519
520 *buffer = 0x38;
521 buffer += 1;
522 539
523 /* Return the number of bytes consumed in this operation */ 540 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
541}
524 542
525 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 543if (resource->data.dma.transfer == 0x03) {
526 return_ACPI_STATUS(AE_OK); 544 ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
545 return_ACPI_STATUS(AE_BAD_DATA);
527} 546}
547#endif
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 4446778eaf79..25b5aedd6612 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,389 @@ ACPI_MODULE_NAME("rsutils")
50 50
51/******************************************************************************* 51/*******************************************************************************
52 * 52 *
53 * FUNCTION: acpi_rs_decode_bitmask
54 *
55 * PARAMETERS: Mask - Bitmask to decode
56 * List - Where the converted list is returned
57 *
58 * RETURN: Count of bits set (length of list)
59 *
60 * DESCRIPTION: Convert a bit mask into a list of values
61 *
62 ******************************************************************************/
63u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
64{
65 acpi_native_uint i;
66 u8 bit_count;
67
68 ACPI_FUNCTION_ENTRY();
69
70 /* Decode the mask bits */
71
72 for (i = 0, bit_count = 0; mask; i++) {
73 if (mask & 0x0001) {
74 list[bit_count] = (u8) i;
75 bit_count++;
76 }
77
78 mask >>= 1;
79 }
80
81 return (bit_count);
82}
83
84/*******************************************************************************
85 *
86 * FUNCTION: acpi_rs_encode_bitmask
87 *
88 * PARAMETERS: List - List of values to encode
89 * Count - Length of list
90 *
91 * RETURN: Encoded bitmask
92 *
93 * DESCRIPTION: Convert a list of values to an encoded bitmask
94 *
95 ******************************************************************************/
96
97u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
98{
99 acpi_native_uint i;
100 u16 mask;
101
102 ACPI_FUNCTION_ENTRY();
103
104 /* Encode the list into a single bitmask */
105
106 for (i = 0, mask = 0; i < count; i++) {
107 mask |= (0x0001 << list[i]);
108 }
109
110 return (mask);
111}
112
113/*******************************************************************************
114 *
115 * FUNCTION: acpi_rs_move_data
116 *
117 * PARAMETERS: Destination - Pointer to the destination descriptor
118 * Source - Pointer to the source descriptor
119 * item_count - How many items to move
120 * move_type - Byte width
121 *
122 * RETURN: None
123 *
124 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
125 * alignment issues and endian issues if necessary, as configured
126 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
127 *
128 ******************************************************************************/
129
130void
131acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
132{
133 acpi_native_uint i;
134
135 ACPI_FUNCTION_ENTRY();
136
137 /* One move per item */
138
139 for (i = 0; i < item_count; i++) {
140 switch (move_type) {
141 /*
142 * For the 8-bit case, we can perform the move all at once
143 * since there are no alignment or endian issues
144 */
145 case ACPI_RSC_MOVE8:
146 ACPI_MEMCPY(destination, source, item_count);
147 return;
148
149 /*
150 * 16-, 32-, and 64-bit cases must use the move macros that perform
151 * endian conversion and/or accomodate hardware that cannot perform
152 * misaligned memory transfers
153 */
154 case ACPI_RSC_MOVE16:
155 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
156 &ACPI_CAST_PTR(u16, source)[i]);
157 break;
158
159 case ACPI_RSC_MOVE32:
160 ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
161 &ACPI_CAST_PTR(u32, source)[i]);
162 break;
163
164 case ACPI_RSC_MOVE64:
165 ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
166 &ACPI_CAST_PTR(u64, source)[i]);
167 break;
168
169 default:
170 return;
171 }
172 }
173}
174
175/*******************************************************************************
176 *
177 * FUNCTION: acpi_rs_set_resource_length
178 *
179 * PARAMETERS: total_length - Length of the AML descriptor, including
180 * the header and length fields.
181 * Aml - Pointer to the raw AML descriptor
182 *
183 * RETURN: None
184 *
185 * DESCRIPTION: Set the resource_length field of an AML
186 * resource descriptor, both Large and Small descriptors are
187 * supported automatically. Note: Descriptor Type field must
188 * be valid.
189 *
190 ******************************************************************************/
191
192void
193acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
194 union aml_resource *aml)
195{
196 acpi_rs_length resource_length;
197
198 ACPI_FUNCTION_ENTRY();
199
200 /* Length is the total descriptor length minus the header length */
201
202 resource_length = (acpi_rs_length)
203 (total_length - acpi_ut_get_resource_header_length(aml));
204
205 /* Length is stored differently for large and small descriptors */
206
207 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
208 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
209
210 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
211 &resource_length);
212 } else {
213 /* Small descriptor -- bits 2:0 of byte 0 contain the length */
214
215 aml->small_header.descriptor_type = (u8)
216
217 /* Clear any existing length, preserving descriptor type bits */
218 ((aml->small_header.
219 descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
220
221 | resource_length);
222 }
223}
224
225/*******************************************************************************
226 *
227 * FUNCTION: acpi_rs_set_resource_header
228 *
229 * PARAMETERS: descriptor_type - Byte to be inserted as the type
230 * total_length - Length of the AML descriptor, including
231 * the header and length fields.
232 * Aml - Pointer to the raw AML descriptor
233 *
234 * RETURN: None
235 *
236 * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML
237 * resource descriptor, both Large and Small descriptors are
238 * supported automatically
239 *
240 ******************************************************************************/
241
242void
243acpi_rs_set_resource_header(u8 descriptor_type,
244 acpi_rsdesc_size total_length,
245 union aml_resource *aml)
246{
247 ACPI_FUNCTION_ENTRY();
248
249 /* Set the Resource Type */
250
251 aml->small_header.descriptor_type = descriptor_type;
252
253 /* Set the Resource Length */
254
255 acpi_rs_set_resource_length(total_length, aml);
256}
257
258/*******************************************************************************
259 *
260 * FUNCTION: acpi_rs_strcpy
261 *
262 * PARAMETERS: Destination - Pointer to the destination string
263 * Source - Pointer to the source string
264 *
265 * RETURN: String length, including NULL terminator
266 *
267 * DESCRIPTION: Local string copy that returns the string length, saving a
268 * strcpy followed by a strlen.
269 *
270 ******************************************************************************/
271
272static u16 acpi_rs_strcpy(char *destination, char *source)
273{
274 u16 i;
275
276 ACPI_FUNCTION_ENTRY();
277
278 for (i = 0; source[i]; i++) {
279 destination[i] = source[i];
280 }
281
282 destination[i] = 0;
283
284 /* Return string length including the NULL terminator */
285
286 return ((u16) (i + 1));
287}
288
289/*******************************************************************************
290 *
291 * FUNCTION: acpi_rs_get_resource_source
292 *
293 * PARAMETERS: resource_length - Length field of the descriptor
294 * minimum_length - Minimum length of the descriptor (minus
295 * any optional fields)
296 * resource_source - Where the resource_source is returned
297 * Aml - Pointer to the raw AML descriptor
298 * string_ptr - (optional) where to store the actual
299 * resource_source string
300 *
301 * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit
302 *
303 * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor
304 * to an internal resource descriptor
305 *
306 ******************************************************************************/
307
308acpi_rs_length
309acpi_rs_get_resource_source(acpi_rs_length resource_length,
310 acpi_rs_length minimum_length,
311 struct acpi_resource_source * resource_source,
312 union aml_resource * aml, char *string_ptr)
313{
314 acpi_rsdesc_size total_length;
315 u8 *aml_resource_source;
316
317 ACPI_FUNCTION_ENTRY();
318
319 total_length =
320 resource_length + sizeof(struct aml_resource_large_header);
321 aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
322
323 /*
324 * resource_source is present if the length of the descriptor is longer than
325 * the minimum length.
326 *
327 * Note: Some resource descriptors will have an additional null, so
328 * we add 1 to the minimum length.
329 */
330 if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) {
331 /* Get the resource_source_index */
332
333 resource_source->index = aml_resource_source[0];
334
335 resource_source->string_ptr = string_ptr;
336 if (!string_ptr) {
337 /*
338 * String destination pointer is not specified; Set the String
339 * pointer to the end of the current resource_source structure.
340 */
341 resource_source->string_ptr =
342 ACPI_ADD_PTR(char, resource_source,
343 sizeof(struct acpi_resource_source));
344 }
345
346 /*
347 * In order for the struct_size to fall on a 32-bit boundary, calculate
348 * the length of the string (+1 for the NULL terminator) and expand the
349 * struct_size to the next 32-bit boundary.
350 *
351 * Zero the entire area of the buffer.
352 */
353 total_length =
354 ACPI_ROUND_UP_to_32_bITS(ACPI_STRLEN
355 ((char *)&aml_resource_source[1]) +
356 1);
357 ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
358
359 /* Copy the resource_source string to the destination */
360
361 resource_source->string_length =
362 acpi_rs_strcpy(resource_source->string_ptr,
363 (char *)&aml_resource_source[1]);
364
365 return ((acpi_rs_length) total_length);
366 }
367
368 /* resource_source is not present */
369
370 resource_source->index = 0;
371 resource_source->string_length = 0;
372 resource_source->string_ptr = NULL;
373 return (0);
374}
375
376/*******************************************************************************
377 *
378 * FUNCTION: acpi_rs_set_resource_source
379 *
380 * PARAMETERS: Aml - Pointer to the raw AML descriptor
381 * minimum_length - Minimum length of the descriptor (minus
382 * any optional fields)
383 * resource_source - Internal resource_source
384
385 *
386 * RETURN: Total length of the AML descriptor
387 *
388 * DESCRIPTION: Convert an optional resource_source from internal format to a
389 * raw AML resource descriptor
390 *
391 ******************************************************************************/
392
393acpi_rsdesc_size
394acpi_rs_set_resource_source(union aml_resource * aml,
395 acpi_rs_length minimum_length,
396 struct acpi_resource_source * resource_source)
397{
398 u8 *aml_resource_source;
399 acpi_rsdesc_size descriptor_length;
400
401 ACPI_FUNCTION_ENTRY();
402
403 descriptor_length = minimum_length;
404
405 /* Non-zero string length indicates presence of a resource_source */
406
407 if (resource_source->string_length) {
408 /* Point to the end of the AML descriptor */
409
410 aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
411
412 /* Copy the resource_source_index */
413
414 aml_resource_source[0] = (u8) resource_source->index;
415
416 /* Copy the resource_source string */
417
418 ACPI_STRCPY((char *)&aml_resource_source[1],
419 resource_source->string_ptr);
420
421 /*
422 * Add the length of the string (+ 1 for null terminator) to the
423 * final descriptor length
424 */
425 descriptor_length +=
426 ((acpi_rsdesc_size) resource_source->string_length + 1);
427 }
428
429 /* Return the new total length of the AML descriptor */
430
431 return (descriptor_length);
432}
433
434/*******************************************************************************
435 *
53 * FUNCTION: acpi_rs_get_prt_method_data 436 * FUNCTION: acpi_rs_get_prt_method_data
54 * 437 *
55 * PARAMETERS: Handle - a handle to the containing object 438 * PARAMETERS: Handle - a handle to the containing object
@@ -65,8 +448,9 @@ ACPI_MODULE_NAME("rsutils")
65 * and the contents of the callers buffer is undefined. 448 * and the contents of the callers buffer is undefined.
66 * 449 *
67 ******************************************************************************/ 450 ******************************************************************************/
451
68acpi_status 452acpi_status
69acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) 453acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer)
70{ 454{
71 union acpi_operand_object *obj_desc; 455 union acpi_operand_object *obj_desc;
72 acpi_status status; 456 acpi_status status;
@@ -284,7 +668,7 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer)
284 * Convert the linked list into a byte stream 668 * Convert the linked list into a byte stream
285 */ 669 */
286 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 670 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
287 status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); 671 status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer);
288 if (ACPI_FAILURE(status)) { 672 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status); 673 return_ACPI_STATUS(status);
290 } 674 }
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index ee5a5c509199..88b67077aeeb 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -57,13 +57,17 @@ ACPI_MODULE_NAME("rsxface")
57 ACPI_COPY_FIELD(out, in, decode); \ 57 ACPI_COPY_FIELD(out, in, decode); \
58 ACPI_COPY_FIELD(out, in, min_address_fixed); \ 58 ACPI_COPY_FIELD(out, in, min_address_fixed); \
59 ACPI_COPY_FIELD(out, in, max_address_fixed); \ 59 ACPI_COPY_FIELD(out, in, max_address_fixed); \
60 ACPI_COPY_FIELD(out, in, attribute); \ 60 ACPI_COPY_FIELD(out, in, info); \
61 ACPI_COPY_FIELD(out, in, granularity); \ 61 ACPI_COPY_FIELD(out, in, granularity); \
62 ACPI_COPY_FIELD(out, in, min_address_range); \ 62 ACPI_COPY_FIELD(out, in, minimum); \
63 ACPI_COPY_FIELD(out, in, max_address_range); \ 63 ACPI_COPY_FIELD(out, in, maximum); \
64 ACPI_COPY_FIELD(out, in, address_translation_offset); \ 64 ACPI_COPY_FIELD(out, in, translation_offset); \
65 ACPI_COPY_FIELD(out, in, address_length); \ 65 ACPI_COPY_FIELD(out, in, address_length); \
66 ACPI_COPY_FIELD(out, in, resource_source); 66 ACPI_COPY_FIELD(out, in, resource_source);
67/* Local prototypes */
68static acpi_status
69acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context);
70
67/******************************************************************************* 71/*******************************************************************************
68 * 72 *
69 * FUNCTION: acpi_get_irq_routing_table 73 * FUNCTION: acpi_get_irq_routing_table
@@ -86,6 +90,7 @@ ACPI_MODULE_NAME("rsxface")
86 * the object indicated by the passed device_handle. 90 * the object indicated by the passed device_handle.
87 * 91 *
88 ******************************************************************************/ 92 ******************************************************************************/
93
89acpi_status 94acpi_status
90acpi_get_irq_routing_table(acpi_handle device_handle, 95acpi_get_irq_routing_table(acpi_handle device_handle,
91 struct acpi_buffer *ret_buffer) 96 struct acpi_buffer *ret_buffer)
@@ -222,12 +227,12 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
222 * 227 *
223 * FUNCTION: acpi_walk_resources 228 * FUNCTION: acpi_walk_resources
224 * 229 *
225 * PARAMETERS: device_handle - a handle to the device object for the 230 * PARAMETERS: device_handle - Handle to the device object for the
226 * device we are querying 231 * device we are querying
227 * Path - method name of the resources we want 232 * Name - Method name of the resources we want
228 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 233 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
229 * user_function - called for each resource 234 * user_function - Called for each resource
230 * Context - passed to user_function 235 * Context - Passed to user_function
231 * 236 *
232 * RETURN: Status 237 * RETURN: Status
233 * 238 *
@@ -239,79 +244,74 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
239 244
240acpi_status 245acpi_status
241acpi_walk_resources(acpi_handle device_handle, 246acpi_walk_resources(acpi_handle device_handle,
242 char *path, 247 char *name,
243 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) 248 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context)
244{ 249{
245 acpi_status status; 250 acpi_status status;
246 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 251 struct acpi_buffer buffer;
247 struct acpi_resource *resource; 252 struct acpi_resource *resource;
248 struct acpi_resource *buffer_end; 253 struct acpi_resource *resource_end;
249 254
250 ACPI_FUNCTION_TRACE("acpi_walk_resources"); 255 ACPI_FUNCTION_TRACE("acpi_walk_resources");
251 256
252 if (!device_handle || 257 /* Parameter validation */
253 (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && 258
254 ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { 259 if (!device_handle || !user_function || !name ||
260 (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
261 ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
255 return_ACPI_STATUS(AE_BAD_PARAMETER); 262 return_ACPI_STATUS(AE_BAD_PARAMETER);
256 } 263 }
257 264
258 status = acpi_rs_get_method_data(device_handle, path, &buffer); 265 /* Get the _CRS or _PRS resource list */
266
267 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
268 status = acpi_rs_get_method_data(device_handle, name, &buffer);
259 if (ACPI_FAILURE(status)) { 269 if (ACPI_FAILURE(status)) {
260 return_ACPI_STATUS(status); 270 return_ACPI_STATUS(status);
261 } 271 }
262 272
263 /* Setup pointers */ 273 /* Buffer now contains the resource list */
264 274
265 resource = (struct acpi_resource *)buffer.pointer; 275 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
266 buffer_end = ACPI_CAST_PTR(struct acpi_resource, 276 resource_end =
267 ((u8 *) buffer.pointer + buffer.length)); 277 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
268 278
269 /* Walk the resource list */ 279 /* Walk the resource list until the end_tag is found (or buffer end) */
270 280
271 for (;;) { 281 while (resource < resource_end) {
272 if (!resource || resource->id == ACPI_RSTYPE_END_TAG) { 282 /* Sanity check the resource */
283
284 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
285 status = AE_AML_INVALID_RESOURCE_TYPE;
273 break; 286 break;
274 } 287 }
275 288
276 status = user_function(resource, context); 289 /* Invoke the user function, abort on any error returned */
277
278 switch (status) {
279 case AE_OK:
280 case AE_CTRL_DEPTH:
281 290
282 /* Just keep going */ 291 status = user_function(resource, context);
292 if (ACPI_FAILURE(status)) {
293 if (status == AE_CTRL_TERMINATE) {
294 /* This is an OK termination by the user function */
283 295
284 status = AE_OK; 296 status = AE_OK;
297 }
285 break; 298 break;
299 }
286 300
287 case AE_CTRL_TERMINATE: 301 /* end_tag indicates end-of-list */
288
289 /* Exit now, with OK stats */
290
291 status = AE_OK;
292 goto cleanup;
293
294 default:
295
296 /* All others are valid exceptions */
297 302
298 goto cleanup; 303 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
304 break;
299 } 305 }
300 306
301 /* Get the next resource descriptor */ 307 /* Get the next resource descriptor */
302 308
303 resource = ACPI_NEXT_RESOURCE(resource); 309 resource =
304 310 ACPI_ADD_PTR(struct acpi_resource, resource,
305 /* Check for end-of-buffer */ 311 resource->length);
306
307 if (resource >= buffer_end) {
308 goto cleanup;
309 }
310 } 312 }
311 313
312 cleanup: 314 ACPI_MEM_FREE(buffer.pointer);
313
314 acpi_os_free(buffer.pointer);
315 return_ACPI_STATUS(status); 315 return_ACPI_STATUS(status);
316} 316}
317 317
@@ -360,8 +360,8 @@ EXPORT_SYMBOL(acpi_set_current_resources);
360 * 360 *
361 * FUNCTION: acpi_resource_to_address64 361 * FUNCTION: acpi_resource_to_address64
362 * 362 *
363 * PARAMETERS: resource - Pointer to a resource 363 * PARAMETERS: Resource - Pointer to a resource
364 * out - Pointer to the users's return 364 * Out - Pointer to the users's return
365 * buffer (a struct 365 * buffer (a struct
366 * struct acpi_resource_address64) 366 * struct acpi_resource_address64)
367 * 367 *
@@ -381,20 +381,26 @@ acpi_resource_to_address64(struct acpi_resource *resource,
381 struct acpi_resource_address16 *address16; 381 struct acpi_resource_address16 *address16;
382 struct acpi_resource_address32 *address32; 382 struct acpi_resource_address32 *address32;
383 383
384 switch (resource->id) { 384 if (!resource || !out) {
385 case ACPI_RSTYPE_ADDRESS16: 385 return (AE_BAD_PARAMETER);
386 }
387
388 /* Convert 16 or 32 address descriptor to 64 */
389
390 switch (resource->type) {
391 case ACPI_RESOURCE_TYPE_ADDRESS16:
386 392
387 address16 = (struct acpi_resource_address16 *)&resource->data; 393 address16 = (struct acpi_resource_address16 *)&resource->data;
388 ACPI_COPY_ADDRESS(out, address16); 394 ACPI_COPY_ADDRESS(out, address16);
389 break; 395 break;
390 396
391 case ACPI_RSTYPE_ADDRESS32: 397 case ACPI_RESOURCE_TYPE_ADDRESS32:
392 398
393 address32 = (struct acpi_resource_address32 *)&resource->data; 399 address32 = (struct acpi_resource_address32 *)&resource->data;
394 ACPI_COPY_ADDRESS(out, address32); 400 ACPI_COPY_ADDRESS(out, address32);
395 break; 401 break;
396 402
397 case ACPI_RSTYPE_ADDRESS64: 403 case ACPI_RESOURCE_TYPE_ADDRESS64:
398 404
399 /* Simple copy for 64 bit source */ 405 /* Simple copy for 64 bit source */
400 406
@@ -410,3 +416,113 @@ acpi_resource_to_address64(struct acpi_resource *resource,
410} 416}
411 417
412EXPORT_SYMBOL(acpi_resource_to_address64); 418EXPORT_SYMBOL(acpi_resource_to_address64);
419
420/*******************************************************************************
421 *
422 * FUNCTION: acpi_get_vendor_resource
423 *
424 * PARAMETERS: device_handle - Handle for the parent device object
425 * Name - Method name for the parent resource
426 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
427 * Uuid - Pointer to the UUID to be matched.
428 * includes both subtype and 16-byte UUID
429 * ret_buffer - Where the vendor resource is returned
430 *
431 * RETURN: Status
432 *
433 * DESCRIPTION: Walk a resource template for the specified evice to find a
434 * vendor-defined resource that matches the supplied UUID and
435 * UUID subtype. Returns a struct acpi_resource of type Vendor.
436 *
437 ******************************************************************************/
438
439acpi_status
440acpi_get_vendor_resource(acpi_handle device_handle,
441 char *name,
442 struct acpi_vendor_uuid * uuid,
443 struct acpi_buffer * ret_buffer)
444{
445 struct acpi_vendor_walk_info info;
446 acpi_status status;
447
448 /* Other parameters are validated by acpi_walk_resources */
449
450 if (!uuid || !ret_buffer) {
451 return (AE_BAD_PARAMETER);
452 }
453
454 info.uuid = uuid;
455 info.buffer = ret_buffer;
456 info.status = AE_NOT_EXIST;
457
458 /* Walk the _CRS or _PRS resource list for this device */
459
460 status =
461 acpi_walk_resources(device_handle, name,
462 acpi_rs_match_vendor_resource, &info);
463 if (ACPI_FAILURE(status)) {
464 return (status);
465 }
466
467 return (info.status);
468}
469
470/*******************************************************************************
471 *
472 * FUNCTION: acpi_rs_match_vendor_resource
473 *
474 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
475 *
476 * RETURN: Status
477 *
478 * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
479 *
480 ******************************************************************************/
481
482static acpi_status
483acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
484{
485 struct acpi_vendor_walk_info *info = context;
486 struct acpi_resource_vendor_typed *vendor;
487 struct acpi_buffer *buffer;
488 acpi_status status;
489
490 /* Ignore all descriptors except Vendor */
491
492 if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) {
493 return (AE_OK);
494 }
495
496 vendor = &resource->data.vendor_typed;
497
498 /*
499 * For a valid match, these conditions must hold:
500 *
501 * 1) Length of descriptor data must be at least as long as a UUID struct
502 * 2) The UUID subtypes must match
503 * 3) The UUID data must match
504 */
505 if ((vendor->byte_length < (ACPI_UUID_LENGTH + 1)) ||
506 (vendor->uuid_subtype != info->uuid->subtype) ||
507 (ACPI_MEMCMP(vendor->uuid, info->uuid->data, ACPI_UUID_LENGTH))) {
508 return (AE_OK);
509 }
510
511 /* Validate/Allocate/Clear caller buffer */
512
513 buffer = info->buffer;
514 status = acpi_ut_initialize_buffer(buffer, resource->length);
515 if (ACPI_FAILURE(status)) {
516 return (status);
517 }
518
519 /* Found the correct resource, copy and return it */
520
521 ACPI_MEMCPY(buffer->pointer, resource, resource->length);
522 buffer->length = resource->length;
523
524 /* Found the desired descriptor, terminate resource walk */
525
526 info->status = AE_OK;
527 return (AE_CTRL_TERMINATE);
528}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3b26a7104363..9271e5209ac1 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -851,7 +851,7 @@ static void acpi_device_set_id(struct acpi_device *device,
851 * ---- 851 * ----
852 * Fix for the system root bus device -- the only root-level device. 852 * Fix for the system root bus device -- the only root-level device.
853 */ 853 */
854 if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { 854 if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
855 hid = ACPI_BUS_HID; 855 hid = ACPI_BUS_HID;
856 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); 856 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
857 strcpy(device->pnp.device_class, ACPI_BUS_CLASS); 857 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index af7935a95bcc..47fb4b394eec 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -33,9 +33,7 @@ int acpi_sleep_prepare(u32 acpi_state)
33 ACPI_FLUSH_CPU_CACHE(); 33 ACPI_FLUSH_CPU_CACHE();
34 acpi_enable_wakeup_device_prep(acpi_state); 34 acpi_enable_wakeup_device_prep(acpi_state);
35#endif 35#endif
36 if (acpi_state == ACPI_STATE_S5) { 36 acpi_gpe_sleep_prepare(acpi_state);
37 acpi_wakeup_gpe_poweroff_prepare();
38 }
39 acpi_enter_sleep_state_prep(acpi_state); 37 acpi_enter_sleep_state_prep(acpi_state);
40 return 0; 38 return 0;
41} 39}
@@ -53,11 +51,16 @@ void acpi_power_off(void)
53 51
54static int acpi_shutdown(struct sys_device *x) 52static int acpi_shutdown(struct sys_device *x)
55{ 53{
56 if (system_state == SYSTEM_POWER_OFF) { 54 switch (system_state) {
57 /* Prepare if we are going to power off the system */ 55 case SYSTEM_POWER_OFF:
56 /* Prepare to power off the system */
58 return acpi_sleep_prepare(ACPI_STATE_S5); 57 return acpi_sleep_prepare(ACPI_STATE_S5);
58 case SYSTEM_SUSPEND_DISK:
59 /* Prepare to suspend the system to disk */
60 return acpi_sleep_prepare(ACPI_STATE_S4);
61 default:
62 return 0;
59 } 63 }
60 return 0;
61} 64}
62 65
63static struct sysdev_class acpi_sysclass = { 66static struct sysdev_class acpi_sysclass = {
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h
index efd0001c6f05..f3e70397a7d6 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep/sleep.h
@@ -5,4 +5,4 @@ extern int acpi_suspend (u32 state);
5extern void acpi_enable_wakeup_device_prep(u8 sleep_state); 5extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
6extern void acpi_enable_wakeup_device(u8 sleep_state); 6extern void acpi_enable_wakeup_device(u8 sleep_state);
7extern void acpi_disable_wakeup_device(u8 sleep_state); 7extern void acpi_disable_wakeup_device(u8 sleep_state);
8extern void acpi_wakeup_gpe_poweroff_prepare(void); 8extern void acpi_gpe_sleep_prepare(u32 sleep_state);
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
index 4134ed43d026..85df0ceda2a9 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/sleep/wakeup.c
@@ -192,7 +192,7 @@ late_initcall(acpi_wakeup_device_init);
192 * RUNTIME GPEs, we simply mark all GPES that 192 * RUNTIME GPEs, we simply mark all GPES that
193 * are not enabled for wakeup from S5 as RUNTIME. 193 * are not enabled for wakeup from S5 as RUNTIME.
194 */ 194 */
195void acpi_wakeup_gpe_poweroff_prepare(void) 195void acpi_gpe_sleep_prepare(u32 sleep_state)
196{ 196{
197 struct list_head *node, *next; 197 struct list_head *node, *next;
198 198
@@ -201,8 +201,8 @@ void acpi_wakeup_gpe_poweroff_prepare(void)
201 struct acpi_device, 201 struct acpi_device,
202 wakeup_list); 202 wakeup_list);
203 203
204 /* The GPE can wakeup system from S5, don't touch it */ 204 /* The GPE can wakeup system from this state, don't touch it */
205 if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5) 205 if ((u32) dev->wakeup.sleep_state >= sleep_state)
206 continue; 206 continue;
207 /* acpi_set_gpe_type will automatically disable GPE */ 207 /* acpi_set_gpe_type will automatically disable GPE */
208 acpi_set_gpe_type(dev->wakeup.gpe_device, 208 acpi_set_gpe_type(dev->wakeup.gpe_device,
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index a03939399fa9..03b37d2223bc 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -501,8 +501,8 @@ acpi_status acpi_tb_convert_table_fadt(void)
501 * at least as long as the version 1.0 FADT 501 * at least as long as the version 1.0 FADT
502 */ 502 */
503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) { 503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
504 ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n", 504 ACPI_ERROR((AE_INFO, "FADT is invalid, too short: 0x%X",
505 acpi_gbl_FADT->length)); 505 acpi_gbl_FADT->length));
506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
507 } 507 }
508 508
@@ -517,7 +517,10 @@ acpi_status acpi_tb_convert_table_fadt(void)
517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { 517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) {
518 /* Length is too short to be a V2.0 table */ 518 /* Length is too short to be a V2.0 table */
519 519
520 ACPI_REPORT_WARNING(("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); 520 ACPI_WARNING((AE_INFO,
521 "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table",
522 acpi_gbl_FADT->length,
523 acpi_gbl_FADT->revision));
521 524
522 acpi_tb_convert_fadt1(local_fadt, 525 acpi_tb_convert_fadt1(local_fadt,
523 (void *)acpi_gbl_FADT); 526 (void *)acpi_gbl_FADT);
@@ -554,7 +557,9 @@ acpi_status acpi_tb_convert_table_fadt(void)
554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 557 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
555 "Hex dump of common internal FADT, size %d (%X)\n", 558 "Hex dump of common internal FADT, size %d (%X)\n",
556 acpi_gbl_FADT->length, acpi_gbl_FADT->length)); 559 acpi_gbl_FADT->length, acpi_gbl_FADT->length));
557 ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); 560
561 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT),
562 acpi_gbl_FADT->length);
558 563
559 return_ACPI_STATUS(AE_OK); 564 return_ACPI_STATUS(AE_OK);
560} 565}
@@ -580,13 +585,15 @@ acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
580 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 585 /* Absolute minimum length is 24, but the ACPI spec says 64 */
581 586
582 if (acpi_gbl_FACS->length < 24) { 587 if (acpi_gbl_FACS->length < 24) {
583 ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n", 588 ACPI_ERROR((AE_INFO, "Invalid FACS table length: 0x%X",
584 acpi_gbl_FACS->length)); 589 acpi_gbl_FACS->length));
585 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 590 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
586 } 591 }
587 592
588 if (acpi_gbl_FACS->length < 64) { 593 if (acpi_gbl_FACS->length < 64) {
589 ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length)); 594 ACPI_WARNING((AE_INFO,
595 "FACS is shorter than the ACPI specification allows: 0x%X, using anyway",
596 acpi_gbl_FACS->length));
590 } 597 }
591 598
592 /* Copy fields to the new FACS */ 599 /* Copy fields to the new FACS */
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 6acd5aeb093e..09b4ee6dfd60 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -91,9 +91,9 @@ acpi_tb_get_table(struct acpi_pointer *address,
91 91
92 status = acpi_tb_get_table_body(address, &header, table_info); 92 status = acpi_tb_get_table_body(address, &header, table_info);
93 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
94 ACPI_REPORT_ERROR(("Could not get ACPI table (size %X), %s\n", 94 ACPI_EXCEPTION((AE_INFO, status,
95 header.length, 95 "Could not get ACPI table (size %X)",
96 acpi_format_exception(status))); 96 header.length));
97 return_ACPI_STATUS(status); 97 return_ACPI_STATUS(status);
98 } 98 }
99 99
@@ -148,7 +148,6 @@ acpi_tb_get_table_header(struct acpi_pointer *address,
148 sizeof(struct acpi_table_header), 148 sizeof(struct acpi_table_header),
149 (void *)&header); 149 (void *)&header);
150 if (ACPI_FAILURE(status)) { 150 if (ACPI_FAILURE(status)) {
151 ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64(address->pointer.physical), sizeof(struct acpi_table_header)));
152 return_ACPI_STATUS(status); 151 return_ACPI_STATUS(status);
153 } 152 }
154 153
@@ -161,8 +160,8 @@ acpi_tb_get_table_header(struct acpi_pointer *address,
161 160
162 default: 161 default:
163 162
164 ACPI_REPORT_ERROR(("Invalid address flags %X\n", 163 ACPI_ERROR((AE_INFO, "Invalid address flags %X",
165 address->pointer_type)); 164 address->pointer_type));
166 return_ACPI_STATUS(AE_BAD_PARAMETER); 165 return_ACPI_STATUS(AE_BAD_PARAMETER);
167 } 166 }
168 167
@@ -253,8 +252,8 @@ acpi_tb_table_override(struct acpi_table_header *header,
253 if (ACPI_FAILURE(status)) { 252 if (ACPI_FAILURE(status)) {
254 /* Some severe error from the OSL, but we basically ignore it */ 253 /* Some severe error from the OSL, but we basically ignore it */
255 254
256 ACPI_REPORT_ERROR(("Could not override ACPI table, %s\n", 255 ACPI_EXCEPTION((AE_INFO, status,
257 acpi_format_exception(status))); 256 "Could not override ACPI table"));
258 return_ACPI_STATUS(status); 257 return_ACPI_STATUS(status);
259 } 258 }
260 259
@@ -273,15 +272,14 @@ acpi_tb_table_override(struct acpi_table_header *header,
273 272
274 status = acpi_tb_get_this_table(&address, new_table, table_info); 273 status = acpi_tb_get_this_table(&address, new_table, table_info);
275 if (ACPI_FAILURE(status)) { 274 if (ACPI_FAILURE(status)) {
276 ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n", 275 ACPI_EXCEPTION((AE_INFO, status, "Could not copy ACPI table"));
277 acpi_format_exception(status)));
278 return_ACPI_STATUS(status); 276 return_ACPI_STATUS(status);
279 } 277 }
280 278
281 /* Copy the table info */ 279 /* Copy the table info */
282 280
283 ACPI_REPORT_INFO(("Table [%4.4s] replaced by host OS\n", 281 ACPI_INFO((AE_INFO, "Table [%4.4s] replaced by host OS",
284 table_info->pointer->signature)); 282 table_info->pointer->signature));
285 283
286 return_ACPI_STATUS(AE_OK); 284 return_ACPI_STATUS(AE_OK);
287} 285}
@@ -327,7 +325,9 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
327 325
328 full_table = ACPI_MEM_ALLOCATE(header->length); 326 full_table = ACPI_MEM_ALLOCATE(header->length);
329 if (!full_table) { 327 if (!full_table) {
330 ACPI_REPORT_ERROR(("Could not allocate table memory for [%4.4s] length %X\n", header->signature, header->length)); 328 ACPI_ERROR((AE_INFO,
329 "Could not allocate table memory for [%4.4s] length %X",
330 header->signature, header->length));
331 return_ACPI_STATUS(AE_NO_MEMORY); 331 return_ACPI_STATUS(AE_NO_MEMORY);
332 } 332 }
333 333
@@ -351,7 +351,12 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
351 (acpi_size) header->length, 351 (acpi_size) header->length,
352 (void *)&full_table); 352 (void *)&full_table);
353 if (ACPI_FAILURE(status)) { 353 if (ACPI_FAILURE(status)) {
354 ACPI_REPORT_ERROR(("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", header->signature, ACPI_FORMAT_UINT64(address->pointer.physical), header->length)); 354 ACPI_ERROR((AE_INFO,
355 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X",
356 header->signature,
357 ACPI_FORMAT_UINT64(address->pointer.
358 physical),
359 header->length));
355 return (status); 360 return (status);
356 } 361 }
357 362
@@ -362,8 +367,8 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
362 367
363 default: 368 default:
364 369
365 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid address flags %X\n", 370 ACPI_ERROR((AE_INFO, "Invalid address flags %X",
366 address->pointer_type)); 371 address->pointer_type));
367 return_ACPI_STATUS(AE_BAD_PARAMETER); 372 return_ACPI_STATUS(AE_BAD_PARAMETER);
368 } 373 }
369 374
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index 8d72343537e7..134e5dce0bc1 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -152,7 +152,9 @@ acpi_tb_get_secondary_table(struct acpi_pointer *address,
152 /* Signature must match request */ 152 /* Signature must match request */
153 153
154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) { 154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) {
155 ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature)); 155 ACPI_ERROR((AE_INFO,
156 "Incorrect table signature - wanted [%s] found [%4.4s]",
157 signature, header.signature));
156 return_ACPI_STATUS(AE_BAD_SIGNATURE); 158 return_ACPI_STATUS(AE_BAD_SIGNATURE);
157 } 159 }
158 160
@@ -231,14 +233,18 @@ acpi_status acpi_tb_get_required_tables(void)
231 */ 233 */
232 status = acpi_tb_get_primary_table(&address, &table_info); 234 status = acpi_tb_get_primary_table(&address, &table_info);
233 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { 235 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
234 ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value))); 236 ACPI_WARNING((AE_INFO,
237 "%s, while getting table at %8.8X%8.8X",
238 acpi_format_exception(status),
239 ACPI_FORMAT_UINT64(address.pointer.
240 value)));
235 } 241 }
236 } 242 }
237 243
238 /* We must have a FADT to continue */ 244 /* We must have a FADT to continue */
239 245
240 if (!acpi_gbl_FADT) { 246 if (!acpi_gbl_FADT) {
241 ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n")); 247 ACPI_ERROR((AE_INFO, "No FADT present in RSDT/XSDT"));
242 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 248 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
243 } 249 }
244 250
@@ -248,7 +254,8 @@ acpi_status acpi_tb_get_required_tables(void)
248 */ 254 */
249 status = acpi_tb_convert_table_fadt(); 255 status = acpi_tb_convert_table_fadt();
250 if (ACPI_FAILURE(status)) { 256 if (ACPI_FAILURE(status)) {
251 ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n")); 257 ACPI_ERROR((AE_INFO,
258 "Could not convert FADT to internal common format"));
252 return_ACPI_STATUS(status); 259 return_ACPI_STATUS(status);
253 } 260 }
254 261
@@ -258,8 +265,8 @@ acpi_status acpi_tb_get_required_tables(void)
258 265
259 status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info); 266 status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info);
260 if (ACPI_FAILURE(status)) { 267 if (ACPI_FAILURE(status)) {
261 ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n", 268 ACPI_EXCEPTION((AE_INFO, status,
262 acpi_format_exception(status))); 269 "Could not get/install the FACS"));
263 return_ACPI_STATUS(status); 270 return_ACPI_STATUS(status);
264 } 271 }
265 272
@@ -278,7 +285,7 @@ acpi_status acpi_tb_get_required_tables(void)
278 285
279 status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info); 286 status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info);
280 if (ACPI_FAILURE(status)) { 287 if (ACPI_FAILURE(status)) {
281 ACPI_REPORT_ERROR(("Could not get/install the DSDT\n")); 288 ACPI_ERROR((AE_INFO, "Could not get/install the DSDT"));
282 return_ACPI_STATUS(status); 289 return_ACPI_STATUS(status);
283 } 290 }
284 291
@@ -292,7 +299,9 @@ acpi_status acpi_tb_get_required_tables(void)
292 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", 299 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
293 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, 300 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
294 acpi_gbl_integer_bit_width)); 301 acpi_gbl_integer_bit_width));
295 ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); 302
303 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_DSDT),
304 acpi_gbl_DSDT->length);
296 305
297 /* Always delete the RSDP mapping, we are done with it */ 306 /* Always delete the RSDP mapping, we are done with it */
298 307
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 10db8484e462..7ffd0fddb4e5 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -128,8 +128,8 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
128 128
129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
130 if (ACPI_FAILURE(status)) { 130 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n", 131 ACPI_EXCEPTION((AE_INFO, status,
132 acpi_format_exception(status))); 132 "Could not acquire table mutex"));
133 return_ACPI_STATUS(status); 133 return_ACPI_STATUS(status);
134 } 134 }
135 135
@@ -146,9 +146,9 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
146 146
147 status = acpi_tb_init_table_descriptor(table_info->type, table_info); 147 status = acpi_tb_init_table_descriptor(table_info->type, table_info);
148 if (ACPI_FAILURE(status)) { 148 if (ACPI_FAILURE(status)) {
149 ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n", 149 ACPI_EXCEPTION((AE_INFO, status,
150 table_info->pointer->signature, 150 "Could not install table [%4.4s]",
151 acpi_format_exception(status))); 151 table_info->pointer->signature));
152 } 152 }
153 153
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n", 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n",
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index ad0252c2f7db..4d308220225d 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -176,7 +176,7 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
176{ 176{
177 int no_match; 177 int no_match;
178 178
179 ACPI_FUNCTION_NAME("tb_validate_rsdt"); 179 ACPI_FUNCTION_ENTRY();
180 180
181 /* 181 /*
182 * Search for appropriate signature, RSDT or XSDT 182 * Search for appropriate signature, RSDT or XSDT
@@ -192,24 +192,24 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
192 if (no_match) { 192 if (no_match) {
193 /* Invalid RSDT or XSDT signature */ 193 /* Invalid RSDT or XSDT signature */
194 194
195 ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); 195 ACPI_ERROR((AE_INFO,
196 "Invalid signature where RSDP indicates RSDT/XSDT should be located. RSDP:"));
196 197
197 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20); 198 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
198 199
199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, 200 ACPI_ERROR((AE_INFO,
200 "RSDT/XSDT signature at %X (%p) is invalid\n", 201 "RSDT/XSDT signature at %X (%p) is invalid",
201 acpi_gbl_RSDP->rsdt_physical_address, 202 acpi_gbl_RSDP->rsdt_physical_address,
202 (void *)(acpi_native_uint) acpi_gbl_RSDP-> 203 (void *)(acpi_native_uint) acpi_gbl_RSDP->
203 rsdt_physical_address)); 204 rsdt_physical_address));
204 205
205 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 206 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
206 ACPI_REPORT_ERROR(("Looking for RSDT\n")) 207 ACPI_ERROR((AE_INFO, "Looking for RSDT"));
207 } else { 208 } else {
208 ACPI_REPORT_ERROR(("Looking for XSDT\n")) 209 ACPI_ERROR((AE_INFO, "Looking for XSDT"));
209 } 210 }
210 211
211 ACPI_DUMP_BUFFER((char *)table_ptr, 48); 212 ACPI_DUMP_BUFFER((char *)table_ptr, 48);
212
213 return (AE_BAD_SIGNATURE); 213 return (AE_BAD_SIGNATURE);
214 } 214 }
215 215
@@ -243,15 +243,13 @@ acpi_status acpi_tb_get_table_rsdt(void)
243 table_info.type = ACPI_TABLE_XSDT; 243 table_info.type = ACPI_TABLE_XSDT;
244 status = acpi_tb_get_table(&address, &table_info); 244 status = acpi_tb_get_table(&address, &table_info);
245 if (ACPI_FAILURE(status)) { 245 if (ACPI_FAILURE(status)) {
246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 246 ACPI_EXCEPTION((AE_INFO, status,
247 "Could not get the RSDT/XSDT, %s\n", 247 "Could not get the RSDT/XSDT"));
248 acpi_format_exception(status)));
249
250 return_ACPI_STATUS(status); 248 return_ACPI_STATUS(status);
251 } 249 }
252 250
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 251 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 252 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n",
255 acpi_gbl_RSDP, 253 acpi_gbl_RSDP,
256 ACPI_FORMAT_UINT64(address.pointer.value))); 254 ACPI_FORMAT_UINT64(address.pointer.value)));
257 255
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 4b2fbb592f49..bc571592f087 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -94,9 +94,8 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
94 new_table_desc->pointer->length) 94 new_table_desc->pointer->length)
95 && 95 &&
96 (!ACPI_MEMCMP 96 (!ACPI_MEMCMP
97 ((const char *)table_desc->pointer, 97 (table_desc->pointer, new_table_desc->pointer,
98 (const char *)new_table_desc->pointer, 98 new_table_desc->pointer->length))) {
99 (acpi_size) new_table_desc->pointer->length))) {
100 /* Match: this table is already installed */ 99 /* Match: this table is already installed */
101 100
102 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 101 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
@@ -145,14 +144,13 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
145{ 144{
146 acpi_name signature; 145 acpi_name signature;
147 146
148 ACPI_FUNCTION_NAME("tb_validate_table_header"); 147 ACPI_FUNCTION_ENTRY();
149 148
150 /* Verify that this is a valid address */ 149 /* Verify that this is a valid address */
151 150
152 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) { 151 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) {
153 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 152 ACPI_ERROR((AE_INFO,
154 "Cannot read table header at %p\n", 153 "Cannot read table header at %p", table_header));
155 table_header));
156 154
157 return (AE_BAD_ADDRESS); 155 return (AE_BAD_ADDRESS);
158 } 156 }
@@ -161,12 +159,12 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
161 159
162 ACPI_MOVE_32_TO_32(&signature, table_header->signature); 160 ACPI_MOVE_32_TO_32(&signature, table_header->signature);
163 if (!acpi_ut_valid_acpi_name(signature)) { 161 if (!acpi_ut_valid_acpi_name(signature)) {
164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 162 ACPI_ERROR((AE_INFO,
165 "Table signature at %p [%p] has invalid characters\n", 163 "Table signature at %p [%p] has invalid characters",
166 table_header, &signature)); 164 table_header, &signature));
167 165
168 ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n", 166 ACPI_WARNING((AE_INFO, "Invalid table signature found: [%4.4s]",
169 (char *)&signature)); 167 ACPI_CAST_PTR(char, &signature)));
170 168
171 ACPI_DUMP_BUFFER(table_header, 169 ACPI_DUMP_BUFFER(table_header,
172 sizeof(struct acpi_table_header)); 170 sizeof(struct acpi_table_header));
@@ -176,11 +174,13 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
176 /* Validate the table length */ 174 /* Validate the table length */
177 175
178 if (table_header->length < sizeof(struct acpi_table_header)) { 176 if (table_header->length < sizeof(struct acpi_table_header)) {
179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 177 ACPI_ERROR((AE_INFO,
180 "Invalid length in table header %p name %4.4s\n", 178 "Invalid length in table header %p name %4.4s",
181 table_header, (char *)&signature)); 179 table_header, (char *)&signature));
182 180
183 ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length)); 181 ACPI_WARNING((AE_INFO,
182 "Invalid table header length (0x%X) found",
183 (u32) table_header->length));
184 184
185 ACPI_DUMP_BUFFER(table_header, 185 ACPI_DUMP_BUFFER(table_header,
186 sizeof(struct acpi_table_header)); 186 sizeof(struct acpi_table_header));
@@ -219,7 +219,10 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
219 /* Return the appropriate exception */ 219 /* Return the appropriate exception */
220 220
221 if (checksum) { 221 if (checksum) {
222 ACPI_REPORT_WARNING(("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", table_header->signature, (u32) table_header->checksum, (u32) checksum)); 222 ACPI_WARNING((AE_INFO,
223 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)",
224 table_header->signature,
225 (u32) table_header->checksum, (u32) checksum));
223 226
224 status = AE_BAD_CHECKSUM; 227 status = AE_BAD_CHECKSUM;
225 } 228 }
@@ -241,16 +244,16 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
241 244
242u8 acpi_tb_generate_checksum(void *buffer, u32 length) 245u8 acpi_tb_generate_checksum(void *buffer, u32 length)
243{ 246{
244 const u8 *limit; 247 u8 *end_buffer;
245 const u8 *rover; 248 u8 *rover;
246 u8 sum = 0; 249 u8 sum = 0;
247 250
248 if (buffer && length) { 251 if (buffer && length) {
249 /* Buffer and Length are valid */ 252 /* Buffer and Length are valid */
250 253
251 limit = (u8 *) buffer + length; 254 end_buffer = ACPI_ADD_PTR(u8, buffer, length);
252 255
253 for (rover = buffer; rover < limit; rover++) { 256 for (rover = buffer; rover < end_buffer; rover++) {
254 sum = (u8) (sum + *rover); 257 sum = (u8) (sum + *rover);
255 } 258 }
256 } 259 }
@@ -292,8 +295,7 @@ acpi_tb_handle_to_object(u16 table_id,
292 } 295 }
293 } 296 }
294 297
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n", 298 ACPI_ERROR((AE_INFO, "table_id=%X does not exist", table_id));
296 table_id));
297 return (AE_BAD_PARAMETER); 299 return (AE_BAD_PARAMETER);
298} 300}
299#endif 301#endif
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 3f96a4909aad..9fe53c9d5b9a 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -75,8 +75,7 @@ acpi_status acpi_load_tables(void)
75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING, 75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING,
76 &rsdp_address); 76 &rsdp_address);
77 if (ACPI_FAILURE(status)) { 77 if (ACPI_FAILURE(status)) {
78 ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n", 78 ACPI_EXCEPTION((AE_INFO, status, "Could not get the RSDP"));
79 acpi_format_exception(status)));
80 goto error_exit; 79 goto error_exit;
81 } 80 }
82 81
@@ -86,7 +85,7 @@ acpi_status acpi_load_tables(void)
86 85
87 status = acpi_tb_verify_rsdp(&rsdp_address); 86 status = acpi_tb_verify_rsdp(&rsdp_address);
88 if (ACPI_FAILURE(status)) { 87 if (ACPI_FAILURE(status)) {
89 ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status))); 88 ACPI_EXCEPTION((AE_INFO, status, "During RSDP validation"));
90 goto error_exit; 89 goto error_exit;
91 } 90 }
92 91
@@ -94,7 +93,7 @@ acpi_status acpi_load_tables(void)
94 93
95 status = acpi_tb_get_table_rsdt(); 94 status = acpi_tb_get_table_rsdt();
96 if (ACPI_FAILURE(status)) { 95 if (ACPI_FAILURE(status)) {
97 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status))); 96 ACPI_EXCEPTION((AE_INFO, status, "Could not load RSDT"));
98 goto error_exit; 97 goto error_exit;
99 } 98 }
100 99
@@ -102,7 +101,8 @@ acpi_status acpi_load_tables(void)
102 101
103 status = acpi_tb_get_required_tables(); 102 status = acpi_tb_get_required_tables();
104 if (ACPI_FAILURE(status)) { 103 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status))); 104 ACPI_EXCEPTION((AE_INFO, status,
105 "Could not get all required tables (DSDT/FADT/FACS)"));
106 goto error_exit; 106 goto error_exit;
107 } 107 }
108 108
@@ -112,16 +112,14 @@ acpi_status acpi_load_tables(void)
112 112
113 status = acpi_ns_load_namespace(); 113 status = acpi_ns_load_namespace();
114 if (ACPI_FAILURE(status)) { 114 if (ACPI_FAILURE(status)) {
115 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status))); 115 ACPI_EXCEPTION((AE_INFO, status, "Could not load namespace"));
116 goto error_exit; 116 goto error_exit;
117 } 117 }
118 118
119 return_ACPI_STATUS(AE_OK); 119 return_ACPI_STATUS(AE_OK);
120 120
121 error_exit: 121 error_exit:
122 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n", 122 ACPI_EXCEPTION((AE_INFO, status, "Could not load tables"));
123 acpi_format_exception(status)));
124
125 return_ACPI_STATUS(status); 123 return_ACPI_STATUS(status);
126} 124}
127 125
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 3b8a7e063e8a..a62db6af83c9 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -251,7 +251,7 @@ acpi_get_firmware_table(acpi_string signature,
251 251
252 acpi_tb_get_rsdt_address(&address); 252 acpi_tb_get_rsdt_address(&address);
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, RSDT physical=%8.8X%8.8X\n",
255 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
256 ACPI_FORMAT_UINT64(address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
257 257
@@ -396,9 +396,8 @@ acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
396 396
397 status = acpi_tb_find_rsdp(&table_info, flags); 397 status = acpi_tb_find_rsdp(&table_info, flags);
398 if (ACPI_FAILURE(status)) { 398 if (ACPI_FAILURE(status)) {
399 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 399 ACPI_EXCEPTION((AE_INFO, status,
400 "RSDP structure not found, %s Flags=%X\n", 400 "RSDP structure not found - Flags=%X", flags));
401 acpi_format_exception(status), flags));
402 401
403 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 402 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
404 } 403 }
@@ -503,10 +502,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
503 ACPI_EBDA_PTR_LENGTH, 502 ACPI_EBDA_PTR_LENGTH,
504 (void *)&table_ptr); 503 (void *)&table_ptr);
505 if (ACPI_FAILURE(status)) { 504 if (ACPI_FAILURE(status)) {
506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 505 ACPI_ERROR((AE_INFO,
507 "Could not map memory at %8.8X for length %X\n", 506 "Could not map memory at %8.8X for length %X",
508 ACPI_EBDA_PTR_LOCATION, 507 ACPI_EBDA_PTR_LOCATION,
509 ACPI_EBDA_PTR_LENGTH)); 508 ACPI_EBDA_PTR_LENGTH));
510 509
511 return_ACPI_STATUS(status); 510 return_ACPI_STATUS(status);
512 } 511 }
@@ -530,10 +529,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
530 ACPI_EBDA_WINDOW_SIZE, 529 ACPI_EBDA_WINDOW_SIZE,
531 (void *)&table_ptr); 530 (void *)&table_ptr);
532 if (ACPI_FAILURE(status)) { 531 if (ACPI_FAILURE(status)) {
533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 532 ACPI_ERROR((AE_INFO,
534 "Could not map memory at %8.8X for length %X\n", 533 "Could not map memory at %8.8X for length %X",
535 physical_address, 534 physical_address,
536 ACPI_EBDA_WINDOW_SIZE)); 535 ACPI_EBDA_WINDOW_SIZE));
537 536
538 return_ACPI_STATUS(status); 537 return_ACPI_STATUS(status);
539 } 538 }
@@ -563,10 +562,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
563 (void *)&table_ptr); 562 (void *)&table_ptr);
564 563
565 if (ACPI_FAILURE(status)) { 564 if (ACPI_FAILURE(status)) {
566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 565 ACPI_ERROR((AE_INFO,
567 "Could not map memory at %8.8X for length %X\n", 566 "Could not map memory at %8.8X for length %X",
568 ACPI_HI_RSDP_WINDOW_BASE, 567 ACPI_HI_RSDP_WINDOW_BASE,
569 ACPI_HI_RSDP_WINDOW_SIZE)); 568 ACPI_HI_RSDP_WINDOW_SIZE));
570 569
571 return_ACPI_STATUS(status); 570 return_ACPI_STATUS(status);
572 } 571 }
@@ -635,7 +634,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
635 634
636 /* A valid RSDP was not found */ 635 /* A valid RSDP was not found */
637 636
638 ACPI_REPORT_ERROR(("No valid RSDP was found\n")); 637 ACPI_ERROR((AE_INFO, "No valid RSDP was found"));
639 return_ACPI_STATUS(AE_NOT_FOUND); 638 return_ACPI_STATUS(AE_NOT_FOUND);
640} 639}
641 640
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
index e87108b7338a..88eff14c4894 100644
--- a/drivers/acpi/utilities/Makefile
+++ b/drivers/acpi/utilities/Makefile
@@ -2,7 +2,8 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o 6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
7 utstate.o utmutex.o utobject.o utcache.o utresrc.o
7 8
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 068450b36475..03b0044974c2 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@
47ACPI_MODULE_NAME("utalloc") 47ACPI_MODULE_NAME("utalloc")
48 48
49/* Local prototypes */ 49/* Local prototypes */
50#ifdef ACPI_DBG_TRACK_ALLOCATIONS 50#ifdef ACPI_DBG_TRACK_ALLOCATIONS
51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation); 51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation);
52 52
53static acpi_status 53static acpi_status
@@ -58,9 +58,7 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
58static acpi_status 58static acpi_status
59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, 59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
60 u32 component, char *module, u32 line); 60 u32 component, char *module, u32 line);
61#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
62 61
63#ifdef ACPI_DBG_TRACK_ALLOCATIONS
64static acpi_status 62static acpi_status
65acpi_ut_create_list(char *list_name, 63acpi_ut_create_list(char *list_name,
66 u16 object_size, struct acpi_memory_list **return_cache); 64 u16 object_size, struct acpi_memory_list **return_cache);
@@ -303,8 +301,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
303 /* Check for an inadvertent size of zero bytes */ 301 /* Check for an inadvertent size of zero bytes */
304 302
305 if (!size) { 303 if (!size) {
306 _ACPI_REPORT_ERROR(module, line, component, 304 ACPI_ERROR((module, line,
307 ("ut_allocate: Attempt to allocate zero bytes\n")); 305 "ut_allocate: Attempt to allocate zero bytes, allocating 1 byte"));
308 size = 1; 306 size = 1;
309 } 307 }
310 308
@@ -312,9 +310,9 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
312 if (!allocation) { 310 if (!allocation) {
313 /* Report allocation error */ 311 /* Report allocation error */
314 312
315 _ACPI_REPORT_ERROR(module, line, component, 313 ACPI_ERROR((module, line,
316 ("ut_allocate: Could not allocate size %X\n", 314 "ut_allocate: Could not allocate size %X",
317 (u32) size)); 315 (u32) size));
318 316
319 return_PTR(NULL); 317 return_PTR(NULL);
320 } 318 }
@@ -346,18 +344,17 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line)
346 /* Check for an inadvertent size of zero bytes */ 344 /* Check for an inadvertent size of zero bytes */
347 345
348 if (!size) { 346 if (!size) {
349 _ACPI_REPORT_ERROR(module, line, component, 347 ACPI_ERROR((module, line,
350 ("ut_callocate: Attempt to allocate zero bytes\n")); 348 "Attempt to allocate zero bytes, allocating 1 byte"));
351 return_PTR(NULL); 349 size = 1;
352 } 350 }
353 351
354 allocation = acpi_os_allocate(size); 352 allocation = acpi_os_allocate(size);
355 if (!allocation) { 353 if (!allocation) {
356 /* Report allocation error */ 354 /* Report allocation error */
357 355
358 _ACPI_REPORT_ERROR(module, line, component, 356 ACPI_ERROR((module, line,
359 ("ut_callocate: Could not allocate size %X\n", 357 "Could not allocate size %X", (u32) size));
360 (u32) size));
361 return_PTR(NULL); 358 return_PTR(NULL);
362 } 359 }
363 360
@@ -482,9 +479,8 @@ void *acpi_ut_callocate_and_track(acpi_size size,
482 if (!allocation) { 479 if (!allocation) {
483 /* Report allocation error */ 480 /* Report allocation error */
484 481
485 _ACPI_REPORT_ERROR(module, line, component, 482 ACPI_ERROR((module, line,
486 ("ut_callocate: Could not allocate size %X\n", 483 "Could not allocate size %X", (u32) size));
487 (u32) size));
488 return (NULL); 484 return (NULL);
489 } 485 }
490 486
@@ -526,8 +522,7 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
526 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation); 522 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
527 523
528 if (NULL == allocation) { 524 if (NULL == allocation) {
529 _ACPI_REPORT_ERROR(module, line, component, 525 ACPI_ERROR((module, line, "Attempt to delete a NULL address"));
530 ("acpi_ut_free: Attempt to delete a NULL address\n"));
531 526
532 return_VOID; 527 return_VOID;
533 } 528 }
@@ -542,14 +537,11 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
542 status = acpi_ut_remove_allocation(debug_block, 537 status = acpi_ut_remove_allocation(debug_block,
543 component, module, line); 538 component, module, line);
544 if (ACPI_FAILURE(status)) { 539 if (ACPI_FAILURE(status)) {
545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Could not free memory, %s\n", 540 ACPI_EXCEPTION((AE_INFO, status, "Could not free memory"));
546 acpi_format_exception(status)));
547 } 541 }
548 542
549 acpi_os_free(debug_block); 543 acpi_os_free(debug_block);
550
551 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); 544 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
552
553 return_VOID; 545 return_VOID;
554} 546}
555 547
@@ -626,10 +618,12 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
626 */ 618 */
627 element = acpi_ut_find_allocation(allocation); 619 element = acpi_ut_find_allocation(allocation);
628 if (element) { 620 if (element) {
629 ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation)); 621 ACPI_ERROR((AE_INFO,
622 "ut_track_allocation: Allocation already present in list! (%p)",
623 allocation));
630 624
631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n", 625 ACPI_ERROR((AE_INFO, "Element %p Address %p",
632 element, allocation)); 626 element, allocation));
633 627
634 goto unlock_and_exit; 628 goto unlock_and_exit;
635 } 629 }
@@ -689,8 +683,8 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
689 if (NULL == mem_list->list_head) { 683 if (NULL == mem_list->list_head) {
690 /* No allocations! */ 684 /* No allocations! */
691 685
692 _ACPI_REPORT_ERROR(module, line, component, 686 ACPI_ERROR((module, line,
693 ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); 687 "Empty allocation list, nothing to free!"));
694 688
695 return_ACPI_STATUS(AE_OK); 689 return_ACPI_STATUS(AE_OK);
696 } 690 }
@@ -865,12 +859,11 @@ void acpi_ut_dump_allocations(u32 component, char *module)
865 /* Print summary */ 859 /* Print summary */
866 860
867 if (!num_outstanding) { 861 if (!num_outstanding) {
868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 862 ACPI_INFO((AE_INFO, "No outstanding allocations"));
869 "No outstanding allocations.\n"));
870 } else { 863 } else {
871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 864 ACPI_ERROR((AE_INFO,
872 "%d(%X) Outstanding allocations\n", 865 "%d(%X) Outstanding allocations",
873 num_outstanding, num_outstanding)); 866 num_outstanding, num_outstanding));
874 } 867 }
875 868
876 return_VOID; 869 return_VOID;
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index 93d48681d276..2177cb1ef2c4 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 5442b32de611..df2d32096b72 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
398 * Build a simple object (no nested objects) 398 * Build a simple object (no nested objects)
399 */ 399 */
400 status = acpi_ut_copy_isimple_to_esimple(internal_object, 400 status = acpi_ut_copy_isimple_to_esimple(internal_object,
401 (union acpi_object *) 401 ACPI_CAST_PTR(union
402 ret_buffer->pointer, 402 acpi_object,
403 ((u8 *) ret_buffer-> 403 ret_buffer->
404 pointer + 404 pointer),
405 ACPI_ROUND_UP_TO_NATIVE_WORD 405 ACPI_ADD_PTR(u8,
406 (sizeof 406 ret_buffer->
407 (union 407 pointer,
408 acpi_object))), 408 ACPI_ROUND_UP_TO_NATIVE_WORD
409 (sizeof
410 (union
411 acpi_object))),
409 &ret_buffer->length); 412 &ret_buffer->length);
410 /* 413 /*
411 * build simple does not include the object size in the length 414 * build simple does not include the object size in the length
@@ -603,8 +606,8 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
603 /* 606 /*
604 * Packages as external input to control methods are not supported, 607 * Packages as external input to control methods are not supported,
605 */ 608 */
606 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 609 ACPI_ERROR((AE_INFO,
607 "Packages as parameters not implemented!\n")); 610 "Packages as parameters not implemented!"));
608 611
609 return_ACPI_STATUS(AE_NOT_IMPLEMENTED); 612 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
610 } 613 }
@@ -867,7 +870,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
867 count + 870 count +
868 1) * sizeof(void *)); 871 1) * sizeof(void *));
869 if (!dest_obj->package.elements) { 872 if (!dest_obj->package.elements) {
870 ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n")); 873 ACPI_ERROR((AE_INFO, "Package allocation failure"));
871 return_ACPI_STATUS(AE_NO_MEMORY); 874 return_ACPI_STATUS(AE_NO_MEMORY);
872 } 875 }
873 876
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index d80e92639932..35f3d581e034 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 2bc878f7a127..1db9695b0029 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -363,8 +363,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
363 363
364 default: 364 default:
365 365
366 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n", 366 ACPI_ERROR((AE_INFO, "Unknown action (%X)", action));
367 action));
368 break; 367 break;
369 } 368 }
370 369
@@ -374,9 +373,9 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
374 */ 373 */
375 if (count > ACPI_MAX_REFERENCE_COUNT) { 374 if (count > ACPI_MAX_REFERENCE_COUNT) {
376 375
377 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 376 ACPI_WARNING((AE_INFO,
378 "**** Warning **** Large Reference Count (%X) in object %p\n\n", 377 "Large Reference Count (%X) in object %p",
379 count, object)); 378 count, object));
380 } 379 }
381 380
382 return; 381 return;
@@ -535,8 +534,8 @@ acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action)
535 534
536 error_exit: 535 error_exit:
537 536
538 ACPI_REPORT_ERROR(("Could not update object reference count, %s\n", 537 ACPI_EXCEPTION((AE_INFO, status,
539 acpi_format_exception(status))); 538 "Could not update object reference count"));
540 539
541 return_ACPI_STATUS(status); 540 return_ACPI_STATUS(status);
542} 541}
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 7b81d5ef3c32..106cc97cb4af 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -95,7 +95,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
95 95
96 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { 96 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) {
97 if (!ACPI_STRCMP(string_desc->string.pointer, 97 if (!ACPI_STRCMP(string_desc->string.pointer,
98 (char *)acpi_gbl_valid_osi_strings[i])) { 98 ACPI_CAST_PTR(char,
99 acpi_gbl_valid_osi_strings[i])))
100 {
99 /* This string is supported */ 101 /* This string is supported */
100 102
101 return_desc->integer.value = 0xFFFFFFFF; 103 return_desc->integer.value = 0xFFFFFFFF;
@@ -152,8 +154,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
152 acpi_ut_get_node_name(prefix_node), 154 acpi_ut_get_node_name(prefix_node),
153 path)); 155 path));
154 } else { 156 } else {
155 ACPI_REPORT_METHOD_ERROR("Method execution failed", 157 ACPI_ERROR_METHOD("Method execution failed",
156 prefix_node, path, status); 158 prefix_node, path, status);
157 } 159 }
158 160
159 return_ACPI_STATUS(status); 161 return_ACPI_STATUS(status);
@@ -163,9 +165,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
163 165
164 if (!info.return_object) { 166 if (!info.return_object) {
165 if (expected_return_btypes) { 167 if (expected_return_btypes) {
166 ACPI_REPORT_METHOD_ERROR("No object was returned from", 168 ACPI_ERROR_METHOD("No object was returned from",
167 prefix_node, path, 169 prefix_node, path, AE_NOT_EXIST);
168 AE_NOT_EXIST);
169 170
170 return_ACPI_STATUS(AE_NOT_EXIST); 171 return_ACPI_STATUS(AE_NOT_EXIST);
171 } 172 }
@@ -210,15 +211,14 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
210 /* Is the return object one of the expected types? */ 211 /* Is the return object one of the expected types? */
211 212
212 if (!(expected_return_btypes & return_btype)) { 213 if (!(expected_return_btypes & return_btype)) {
213 ACPI_REPORT_METHOD_ERROR("Return object type is incorrect", 214 ACPI_ERROR_METHOD("Return object type is incorrect",
214 prefix_node, path, AE_TYPE); 215 prefix_node, path, AE_TYPE);
215 216
216 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 217 ACPI_ERROR((AE_INFO,
217 "Type returned from %s was incorrect: %s, expected Btypes: %X\n", 218 "Type returned from %s was incorrect: %s, expected Btypes: %X",
218 path, 219 path,
219 acpi_ut_get_object_type_name(info. 220 acpi_ut_get_object_type_name(info.return_object),
220 return_object), 221 expected_return_btypes));
221 expected_return_btypes));
222 222
223 /* On error exit, we must delete the return object */ 223 /* On error exit, we must delete the return object */
224 224
@@ -592,7 +592,7 @@ acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
592 "_STA on %4.4s was not found, assuming device is present\n", 592 "_STA on %4.4s was not found, assuming device is present\n",
593 acpi_ut_get_node_name(device_node))); 593 acpi_ut_get_node_name(device_node)));
594 594
595 *flags = 0x0F; 595 *flags = ACPI_UINT32_MAX;
596 status = AE_OK; 596 status = AE_OK;
597 } 597 }
598 598
@@ -637,17 +637,17 @@ acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest)
637 for (i = 0; i < 4; i++) { 637 for (i = 0; i < 4; i++) {
638 highest[i] = 0xFF; 638 highest[i] = 0xFF;
639 status = acpi_ut_evaluate_object(device_node, 639 status = acpi_ut_evaluate_object(device_node,
640 (char *) 640 ACPI_CAST_PTR(char,
641 acpi_gbl_highest_dstate_names 641 acpi_gbl_highest_dstate_names
642 [i], ACPI_BTYPE_INTEGER, 642 [i]),
643 &obj_desc); 643 ACPI_BTYPE_INTEGER, &obj_desc);
644 if (ACPI_FAILURE(status)) { 644 if (ACPI_FAILURE(status)) {
645 if (status != AE_NOT_FOUND) { 645 if (status != AE_NOT_FOUND) {
646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
647 "%s on Device %4.4s, %s\n", 647 "%s on Device %4.4s, %s\n",
648 (char *) 648 ACPI_CAST_PTR(char,
649 acpi_gbl_highest_dstate_names 649 acpi_gbl_highest_dstate_names
650 [i], 650 [i]),
651 acpi_ut_get_node_name 651 acpi_ut_get_node_name
652 (device_node), 652 (device_node),
653 acpi_format_exception 653 acpi_format_exception
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 399e64b51886..ffd13383a325 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -67,8 +67,11 @@ const char *acpi_format_exception(acpi_status status)
67 acpi_status sub_status; 67 acpi_status sub_status;
68 const char *exception = NULL; 68 const char *exception = NULL;
69 69
70 ACPI_FUNCTION_NAME("format_exception"); 70 ACPI_FUNCTION_ENTRY();
71 71
72 /*
73 * Status is composed of two parts, a "type" and an actual code
74 */
72 sub_status = (status & ~AE_CODE_MASK); 75 sub_status = (status & ~AE_CODE_MASK);
73 76
74 switch (status & AE_CODE_MASK) { 77 switch (status & AE_CODE_MASK) {
@@ -118,13 +121,13 @@ const char *acpi_format_exception(acpi_status status)
118 if (!exception) { 121 if (!exception) {
119 /* Exception code was not recognized */ 122 /* Exception code was not recognized */
120 123
121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 124 ACPI_ERROR((AE_INFO,
122 "Unknown exception code: 0x%8.8X\n", status)); 125 "Unknown exception code: 0x%8.8X", status));
123 126
124 return ((const char *)"UNKNOWN_STATUS_CODE"); 127 exception = "UNKNOWN_STATUS_CODE";
125 } 128 }
126 129
127 return ((const char *)exception); 130 return (ACPI_CAST_PTR(const char, exception));
128} 131}
129 132
130/******************************************************************************* 133/*******************************************************************************
@@ -217,23 +220,23 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
217 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 220 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
218 * perform a Notify() operation on it. 221 * perform a Notify() operation on it.
219 */ 222 */
220const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = 223const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
221 { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 224 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
222{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 225 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
223{"_SB_", ACPI_TYPE_DEVICE, NULL}, 226 {"_SB_", ACPI_TYPE_DEVICE, NULL},
224{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 227 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
225{"_TZ_", ACPI_TYPE_THERMAL, NULL}, 228 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
226{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, 229 {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
227{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 230 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
228{"_GL_", ACPI_TYPE_MUTEX, (char *)1}, 231 {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
229 232
230#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 233#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
231{"_OSI", ACPI_TYPE_METHOD, (char *)1}, 234 {"_OSI", ACPI_TYPE_METHOD, (char *)1},
232#endif 235#endif
233 236
234 /* Table terminator */ 237 /* Table terminator */
235 238
236{NULL, ACPI_TYPE_ANY, NULL} 239 {NULL, ACPI_TYPE_ANY, NULL}
237}; 240};
238 241
239/* 242/*
@@ -485,7 +488,7 @@ char *acpi_ut_get_region_name(u8 space_id)
485 return ("invalid_space_id"); 488 return ("invalid_space_id");
486 } 489 }
487 490
488 return ((char *)acpi_gbl_region_types[space_id]); 491 return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
489} 492}
490 493
491/******************************************************************************* 494/*******************************************************************************
@@ -503,11 +506,13 @@ char *acpi_ut_get_region_name(u8 space_id)
503/* Event type decoding */ 506/* Event type decoding */
504 507
505static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { 508static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
509/*! [Begin] no source code translation (keep these strings as-is) */
506 "PM_Timer", 510 "PM_Timer",
507 "global_lock", 511 "GlobalLock",
508 "power_button", 512 "PowerButton",
509 "sleep_button", 513 "SleepButton",
510 "real_time_clock", 514 "RealTimeClock",
515/*! [End] no source code translation !*/
511}; 516};
512 517
513char *acpi_ut_get_event_name(u32 event_id) 518char *acpi_ut_get_event_name(u32 event_id)
@@ -517,7 +522,7 @@ char *acpi_ut_get_event_name(u32 event_id)
517 return ("invalid_event_iD"); 522 return ("invalid_event_iD");
518 } 523 }
519 524
520 return ((char *)acpi_gbl_event_types[event_id]); 525 return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
521} 526}
522 527
523/******************************************************************************* 528/*******************************************************************************
@@ -545,12 +550,13 @@ static const char acpi_gbl_bad_type[] = "UNDEFINED";
545/* Printable names of the ACPI object types */ 550/* Printable names of the ACPI object types */
546 551
547static const char *acpi_gbl_ns_type_names[] = { 552static const char *acpi_gbl_ns_type_names[] = {
553/*! [Begin] no source code translation (keep these strings as-is) */
548 /* 00 */ "Untyped", 554 /* 00 */ "Untyped",
549 /* 01 */ "Integer", 555 /* 01 */ "Integer",
550 /* 02 */ "String", 556 /* 02 */ "String",
551 /* 03 */ "Buffer", 557 /* 03 */ "Buffer",
552 /* 04 */ "Package", 558 /* 04 */ "Package",
553 /* 05 */ "field_unit", 559 /* 05 */ "FieldUnit",
554 /* 06 */ "Device", 560 /* 06 */ "Device",
555 /* 07 */ "Event", 561 /* 07 */ "Event",
556 /* 08 */ "Method", 562 /* 08 */ "Method",
@@ -559,33 +565,34 @@ static const char *acpi_gbl_ns_type_names[] = {
559 /* 11 */ "Power", 565 /* 11 */ "Power",
560 /* 12 */ "Processor", 566 /* 12 */ "Processor",
561 /* 13 */ "Thermal", 567 /* 13 */ "Thermal",
562 /* 14 */ "buffer_field", 568 /* 14 */ "BufferField",
563 /* 15 */ "ddb_handle", 569 /* 15 */ "DdbHandle",
564 /* 16 */ "debug_object", 570 /* 16 */ "DebugObject",
565 /* 17 */ "region_field", 571 /* 17 */ "RegionField",
566 /* 18 */ "bank_field", 572 /* 18 */ "BankField",
567 /* 19 */ "index_field", 573 /* 19 */ "IndexField",
568 /* 20 */ "Reference", 574 /* 20 */ "Reference",
569 /* 21 */ "Alias", 575 /* 21 */ "Alias",
570 /* 22 */ "method_alias", 576 /* 22 */ "MethodAlias",
571 /* 23 */ "Notify", 577 /* 23 */ "Notify",
572 /* 24 */ "addr_handler", 578 /* 24 */ "AddrHandler",
573 /* 25 */ "resource_desc", 579 /* 25 */ "ResourceDesc",
574 /* 26 */ "resource_fld", 580 /* 26 */ "ResourceFld",
575 /* 27 */ "Scope", 581 /* 27 */ "Scope",
576 /* 28 */ "Extra", 582 /* 28 */ "Extra",
577 /* 29 */ "Data", 583 /* 29 */ "Data",
578 /* 30 */ "Invalid" 584 /* 30 */ "Invalid"
585/*! [End] no source code translation !*/
579}; 586};
580 587
581char *acpi_ut_get_type_name(acpi_object_type type) 588char *acpi_ut_get_type_name(acpi_object_type type)
582{ 589{
583 590
584 if (type > ACPI_TYPE_INVALID) { 591 if (type > ACPI_TYPE_INVALID) {
585 return ((char *)acpi_gbl_bad_type); 592 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
586 } 593 }
587 594
588 return ((char *)acpi_gbl_ns_type_names[type]); 595 return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
589} 596}
590 597
591char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) 598char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
@@ -634,7 +641,7 @@ char *acpi_ut_get_node_name(void *object)
634 641
635 /* Name must be a valid ACPI name */ 642 /* Name must be a valid ACPI name */
636 643
637 if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { 644 if (!acpi_ut_valid_acpi_name(node->name.integer)) {
638 return ("????"); 645 return ("????");
639 } 646 }
640 647
@@ -658,15 +665,16 @@ char *acpi_ut_get_node_name(void *object)
658/* Printable names of object descriptor types */ 665/* Printable names of object descriptor types */
659 666
660static const char *acpi_gbl_desc_type_names[] = { 667static const char *acpi_gbl_desc_type_names[] = {
668/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
661 /* 00 */ "Invalid", 669 /* 00 */ "Invalid",
662 /* 01 */ "Cached", 670 /* 01 */ "Cached",
663 /* 02 */ "State-Generic", 671 /* 02 */ "State-Generic",
664 /* 03 */ "State-Update", 672 /* 03 */ "State-Update",
665 /* 04 */ "State-Package", 673 /* 04 */ "State-Package",
666 /* 05 */ "State-Control", 674 /* 05 */ "State-Control",
667 /* 06 */ "State-root_parse_scope", 675 /* 06 */ "State-RootParseScope",
668 /* 07 */ "State-parse_scope", 676 /* 07 */ "State-ParseScope",
669 /* 08 */ "State-walk_scope", 677 /* 08 */ "State-WalkScope",
670 /* 09 */ "State-Result", 678 /* 09 */ "State-Result",
671 /* 10 */ "State-Notify", 679 /* 10 */ "State-Notify",
672 /* 11 */ "State-Thread", 680 /* 11 */ "State-Thread",
@@ -674,6 +682,7 @@ static const char *acpi_gbl_desc_type_names[] = {
674 /* 13 */ "Parser", 682 /* 13 */ "Parser",
675 /* 14 */ "Operand", 683 /* 14 */ "Operand",
676 /* 15 */ "Node" 684 /* 15 */ "Node"
685/*! [End] no source code translation !*/
677}; 686};
678 687
679char *acpi_ut_get_descriptor_name(void *object) 688char *acpi_ut_get_descriptor_name(void *object)
@@ -684,11 +693,12 @@ char *acpi_ut_get_descriptor_name(void *object)
684 } 693 }
685 694
686 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { 695 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
687 return ((char *)acpi_gbl_bad_type); 696 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
688 } 697 }
689 698
690 return ((char *) 699 return (ACPI_CAST_PTR(char,
691 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]); 700 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
701 (object)]));
692 702
693} 703}
694 704
@@ -787,6 +797,11 @@ void acpi_ut_init_globals(void)
787 acpi_gbl_mutex_info[i].use_count = 0; 797 acpi_gbl_mutex_info[i].use_count = 0;
788 } 798 }
789 799
800 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
801 acpi_gbl_owner_id_mask[i] = 0;
802 }
803 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
804
790 /* GPE support */ 805 /* GPE support */
791 806
792 acpi_gbl_gpe_xrupt_list_head = NULL; 807 acpi_gbl_gpe_xrupt_list_head = NULL;
@@ -824,7 +839,11 @@ void acpi_ut_init_globals(void)
824 acpi_gbl_ns_lookup_count = 0; 839 acpi_gbl_ns_lookup_count = 0;
825 acpi_gbl_ps_find_count = 0; 840 acpi_gbl_ps_find_count = 0;
826 acpi_gbl_acpi_hardware_present = TRUE; 841 acpi_gbl_acpi_hardware_present = TRUE;
827 acpi_gbl_owner_id_mask = 0; 842 acpi_gbl_last_owner_id_index = 0;
843 acpi_gbl_next_owner_id_offset = 0;
844 acpi_gbl_trace_method_name = 0;
845 acpi_gbl_trace_dbg_level = 0;
846 acpi_gbl_trace_dbg_layer = 0;
828 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 847 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
829 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 848 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
830 849
@@ -836,7 +855,6 @@ void acpi_ut_init_globals(void)
836 /* Namespace */ 855 /* Namespace */
837 856
838 acpi_gbl_root_node = NULL; 857 acpi_gbl_root_node = NULL;
839
840 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 858 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
841 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 859 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
842 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 860 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index 9dde82b0beaf..ba771b4f39bc 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -72,9 +72,9 @@ static void
72acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset) 72acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset)
73{ 73{
74 74
75 ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n", 75 ACPI_WARNING((AE_INFO,
76 register_name, value, (u32) offset, 76 "Invalid FADT value %s=%X at offset %X FADT=%p",
77 acpi_gbl_FADT)); 77 register_name, value, (u32) offset, acpi_gbl_FADT));
78} 78}
79 79
80/****************************************************************************** 80/******************************************************************************
@@ -221,15 +221,14 @@ void acpi_ut_subsystem_shutdown(void)
221 /* Just exit if subsystem is already shutdown */ 221 /* Just exit if subsystem is already shutdown */
222 222
223 if (acpi_gbl_shutdown) { 223 if (acpi_gbl_shutdown) {
224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 224 ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
225 "ACPI Subsystem is already terminated\n"));
226 return_VOID; 225 return_VOID;
227 } 226 }
228 227
229 /* Subsystem appears active, go ahead and shut it down */ 228 /* Subsystem appears active, go ahead and shut it down */
230 229
231 acpi_gbl_shutdown = TRUE; 230 acpi_gbl_shutdown = TRUE;
232 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); 231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
233 232
234 /* Close the acpi_event Handling */ 233 /* Close the acpi_event Handling */
235 234
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
index 68a0a6f94129..4a3360484e72 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/utilities/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -82,7 +82,7 @@ acpi_ut_short_divide(acpi_integer dividend,
82 /* Always check for a zero divisor */ 82 /* Always check for a zero divisor */
83 83
84 if (divisor == 0) { 84 if (divisor == 0) {
85 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); 85 ACPI_ERROR((AE_INFO, "Divide by zero"));
86 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 86 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
87 } 87 }
88 88
@@ -144,7 +144,7 @@ acpi_ut_divide(acpi_integer in_dividend,
144 /* Always check for a zero divisor */ 144 /* Always check for a zero divisor */
145 145
146 if (in_divisor == 0) { 146 if (in_divisor == 0) {
147 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); 147 ACPI_ERROR((AE_INFO, "Divide by zero"));
148 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 148 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
149 } 149 }
150 150
@@ -266,7 +266,7 @@ acpi_ut_short_divide(acpi_integer in_dividend,
266 /* Always check for a zero divisor */ 266 /* Always check for a zero divisor */
267 267
268 if (divisor == 0) { 268 if (divisor == 0) {
269 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); 269 ACPI_ERROR((AE_INFO, "Divide by zero"));
270 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 270 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
271 } 271 }
272 272
@@ -292,7 +292,7 @@ acpi_ut_divide(acpi_integer in_dividend,
292 /* Always check for a zero divisor */ 292 /* Always check for a zero divisor */
293 293
294 if (in_divisor == 0) { 294 if (in_divisor == 0) {
295 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); 295 ACPI_ERROR((AE_INFO, "Divide by zero"));
296 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 296 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
297 } 297 }
298 298
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 2ce872d75890..7364f5f8c9cd 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -63,6 +63,8 @@ ACPI_MODULE_NAME("utmisc")
63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) 63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
64{ 64{
65 acpi_native_uint i; 65 acpi_native_uint i;
66 acpi_native_uint j;
67 acpi_native_uint k;
66 acpi_status status; 68 acpi_status status;
67 69
68 ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); 70 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
@@ -70,8 +72,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
70 /* Guard against multiple allocations of ID to the same location */ 72 /* Guard against multiple allocations of ID to the same location */
71 73
72 if (*owner_id) { 74 if (*owner_id) {
73 ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n", 75 ACPI_ERROR((AE_INFO, "Owner ID [%2.2X] already exists",
74 *owner_id)); 76 *owner_id));
75 return_ACPI_STATUS(AE_ALREADY_EXISTS); 77 return_ACPI_STATUS(AE_ALREADY_EXISTS);
76 } 78 }
77 79
@@ -82,31 +84,67 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
82 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
83 } 85 }
84 86
85 /* Find a free owner ID */ 87 /*
88 * Find a free owner ID, cycle through all possible IDs on repeated
89 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
90 * to be scanned twice.
91 */
92 for (i = 0, j = acpi_gbl_last_owner_id_index;
93 i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) {
94 if (j >= ACPI_NUM_OWNERID_MASKS) {
95 j = 0; /* Wraparound to start of mask array */
96 }
97
98 for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) {
99 if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) {
100 /* There are no free IDs in this mask */
86 101
87 for (i = 0; i < 64; i++) { 102 break;
88 if (!(acpi_gbl_owner_id_mask & (1ULL << i))) { 103 }
89 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
90 "Current owner_id mask: %16.16LX New ID: %2.2X\n",
91 acpi_gbl_owner_id_mask,
92 (unsigned int)(i + 1)));
93 104
94 acpi_gbl_owner_id_mask |= (1ULL << i); 105 if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) {
95 *owner_id = (acpi_owner_id) (i + 1); 106 /*
96 goto exit; 107 * Found a free ID. The actual ID is the bit index plus one,
108 * making zero an invalid Owner ID. Save this as the last ID
109 * allocated and update the global ID mask.
110 */
111 acpi_gbl_owner_id_mask[j] |= (1 << k);
112
113 acpi_gbl_last_owner_id_index = (u8) j;
114 acpi_gbl_next_owner_id_offset = (u8) (k + 1);
115
116 /*
117 * Construct encoded ID from the index and bit position
118 *
119 * Note: Last [j].k (bit 255) is never used and is marked
120 * permanently allocated (prevents +1 overflow)
121 */
122 *owner_id =
123 (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j));
124
125 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
126 "Allocated owner_id: %2.2X\n",
127 (unsigned int)*owner_id));
128 goto exit;
129 }
97 } 130 }
131
132 acpi_gbl_next_owner_id_offset = 0;
98 } 133 }
99 134
100 /* 135 /*
101 * If we are here, all owner_ids have been allocated. This probably should 136 * All owner_ids have been allocated. This typically should
102 * not happen since the IDs are reused after deallocation. The IDs are 137 * not happen since the IDs are reused after deallocation. The IDs are
103 * allocated upon table load (one per table) and method execution, and 138 * allocated upon table load (one per table) and method execution, and
104 * they are released when a table is unloaded or a method completes 139 * they are released when a table is unloaded or a method completes
105 * execution. 140 * execution.
141 *
142 * If this error happens, there may be very deep nesting of invoked control
143 * methods, or there may be a bug where the IDs are not released.
106 */ 144 */
107 *owner_id = 0;
108 status = AE_OWNER_ID_LIMIT; 145 status = AE_OWNER_ID_LIMIT;
109 ACPI_REPORT_ERROR(("Could not allocate new owner_id (64 max), AE_OWNER_ID_LIMIT\n")); 146 ACPI_ERROR((AE_INFO,
147 "Could not allocate new owner_id (255 max), AE_OWNER_ID_LIMIT"));
110 148
111 exit: 149 exit:
112 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 150 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
@@ -123,7 +161,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
123 * control method or unloading a table. Either way, we would 161 * control method or unloading a table. Either way, we would
124 * ignore any error anyway. 162 * ignore any error anyway.
125 * 163 *
126 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 64 164 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
127 * 165 *
128 ******************************************************************************/ 166 ******************************************************************************/
129 167
@@ -131,6 +169,8 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
131{ 169{
132 acpi_owner_id owner_id = *owner_id_ptr; 170 acpi_owner_id owner_id = *owner_id_ptr;
133 acpi_status status; 171 acpi_status status;
172 acpi_native_uint index;
173 u32 bit;
134 174
135 ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id); 175 ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id);
136 176
@@ -140,8 +180,8 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
140 180
141 /* Zero is not a valid owner_iD */ 181 /* Zero is not a valid owner_iD */
142 182
143 if ((owner_id == 0) || (owner_id > 64)) { 183 if (owner_id == 0) {
144 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); 184 ACPI_ERROR((AE_INFO, "Invalid owner_id: %2.2X", owner_id));
145 return_VOID; 185 return_VOID;
146 } 186 }
147 187
@@ -156,10 +196,19 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
156 196
157 owner_id--; 197 owner_id--;
158 198
199 /* Decode ID to index/offset pair */
200
201 index = ACPI_DIV_32(owner_id);
202 bit = 1 << ACPI_MOD_32(owner_id);
203
159 /* Free the owner ID only if it is valid */ 204 /* Free the owner ID only if it is valid */
160 205
161 if (acpi_gbl_owner_id_mask & (1ULL << owner_id)) { 206 if (acpi_gbl_owner_id_mask[index] & bit) {
162 acpi_gbl_owner_id_mask ^= (1ULL << owner_id); 207 acpi_gbl_owner_id_mask[index] ^= bit;
208 } else {
209 ACPI_ERROR((AE_INFO,
210 "Release of non-allocated owner_id: %2.2X",
211 owner_id + 1));
163 } 212 }
164 213
165 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 214 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
@@ -790,109 +839,97 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
790 839
791/******************************************************************************* 840/*******************************************************************************
792 * 841 *
793 * FUNCTION: acpi_ut_get_resource_end_tag 842 * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info
794 * 843 *
795 * PARAMETERS: obj_desc - The resource template buffer object 844 * PARAMETERS: module_name - Caller's module name (for error output)
845 * line_number - Caller's line number (for error output)
846 * Format - Printf format string + additional args
796 * 847 *
797 * RETURN: Pointer to the end tag 848 * RETURN: None
798 * 849 *
799 * DESCRIPTION: Find the END_TAG resource descriptor in a resource template 850 * DESCRIPTION: Print message with module/line/version info
800 * 851 *
801 ******************************************************************************/ 852 ******************************************************************************/
802 853
803u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) 854void ACPI_INTERNAL_VAR_XFACE
855acpi_ut_error(char *module_name, u32 line_number, char *format, ...)
804{ 856{
805 u8 buffer_byte; 857 va_list args;
806 u8 *buffer;
807 u8 *end_buffer;
808 858
809 buffer = obj_desc->buffer.pointer; 859 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
810 end_buffer = buffer + obj_desc->buffer.length;
811 860
812 while (buffer < end_buffer) { 861 va_start(args, format);
813 buffer_byte = *buffer; 862 acpi_os_vprintf(format, args);
814 if (buffer_byte & ACPI_RDESC_TYPE_MASK) { 863 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
815 /* Large Descriptor - Length is next 2 bytes */ 864}
816 865
817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); 866void ACPI_INTERNAL_VAR_XFACE
818 } else { 867acpi_ut_exception(char *module_name,
819 /* Small Descriptor. End Tag will be found here */ 868 u32 line_number, acpi_status status, char *format, ...)
869{
870 va_list args;
820 871
821 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == 872 acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name,
822 ACPI_RDESC_TYPE_END_TAG) { 873 line_number, acpi_format_exception(status));
823 /* Found the end tag descriptor, all done. */
824 874
825 return (buffer); 875 va_start(args, format);
826 } 876 acpi_os_vprintf(format, args);
877 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
878}
827 879
828 /* Length is in the header */ 880void ACPI_INTERNAL_VAR_XFACE
881acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
882{
883 va_list args;
829 884
830 buffer += ((buffer_byte & 0x07) + 1); 885 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
831 } 886
832 } 887 va_start(args, format);
888 acpi_os_vprintf(format, args);
889 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
890}
891
892void ACPI_INTERNAL_VAR_XFACE
893acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
894{
895 va_list args;
833 896
834 /* End tag not found */ 897 acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
835 898
836 return (NULL); 899 va_start(args, format);
900 acpi_os_vprintf(format, args);
901 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
837} 902}
838 903
839/******************************************************************************* 904/*******************************************************************************
840 * 905 *
841 * FUNCTION: acpi_ut_report_error 906 * FUNCTION: acpi_ut_report_error, Warning, Info
842 * 907 *
843 * PARAMETERS: module_name - Caller's module name (for error output) 908 * PARAMETERS: module_name - Caller's module name (for error output)
844 * line_number - Caller's line number (for error output) 909 * line_number - Caller's line number (for error output)
845 * component_id - Caller's component ID (for error output)
846 * 910 *
847 * RETURN: None 911 * RETURN: None
848 * 912 *
849 * DESCRIPTION: Print error message 913 * DESCRIPTION: Print error message
850 * 914 *
915 * Note: Legacy only, should be removed when no longer used by drivers.
916 *
851 ******************************************************************************/ 917 ******************************************************************************/
852 918
853void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) 919void acpi_ut_report_error(char *module_name, u32 line_number)
854{ 920{
855 921
856 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); 922 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
857} 923}
858 924
859/******************************************************************************* 925void acpi_ut_report_warning(char *module_name, u32 line_number)
860 *
861 * FUNCTION: acpi_ut_report_warning
862 *
863 * PARAMETERS: module_name - Caller's module name (for error output)
864 * line_number - Caller's line number (for error output)
865 * component_id - Caller's component ID (for error output)
866 *
867 * RETURN: None
868 *
869 * DESCRIPTION: Print warning message
870 *
871 ******************************************************************************/
872
873void
874acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
875{ 926{
876 927
877 acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number); 928 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
878} 929}
879 930
880/******************************************************************************* 931void acpi_ut_report_info(char *module_name, u32 line_number)
881 *
882 * FUNCTION: acpi_ut_report_info
883 *
884 * PARAMETERS: module_name - Caller's module name (for error output)
885 * line_number - Caller's line number (for error output)
886 * component_id - Caller's component ID (for error output)
887 *
888 * RETURN: None
889 *
890 * DESCRIPTION: Print information message
891 *
892 ******************************************************************************/
893
894void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
895{ 932{
896 933
897 acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number); 934 acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
898} 935}
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 90134c56ece9..45a7244df924 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -214,23 +214,22 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
214 * the ACPI subsystem code. 214 * the ACPI subsystem code.
215 */ 215 */
216 for (i = mutex_id; i < MAX_MUTEX; i++) { 216 for (i = mutex_id; i < MAX_MUTEX; i++) {
217 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 217 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
218 if (i == mutex_id) { 218 if (i == mutex_id) {
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_ERROR((AE_INFO,
220 "Mutex [%s] already acquired by this thread [%X]\n", 220 "Mutex [%s] already acquired by this thread [%X]",
221 acpi_ut_get_mutex_name 221 acpi_ut_get_mutex_name
222 (mutex_id), 222 (mutex_id),
223 this_thread_id)); 223 this_thread_id));
224 224
225 return (AE_ALREADY_ACQUIRED); 225 return (AE_ALREADY_ACQUIRED);
226 } 226 }
227 227
228 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 228 ACPI_ERROR((AE_INFO,
229 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 229 "Invalid acquire order: Thread %X owns [%s], wants [%s]",
230 this_thread_id, 230 this_thread_id,
231 acpi_ut_get_mutex_name(i), 231 acpi_ut_get_mutex_name(i),
232 acpi_ut_get_mutex_name 232 acpi_ut_get_mutex_name(mutex_id)));
233 (mutex_id)));
234 233
235 return (AE_ACQUIRE_DEADLOCK); 234 return (AE_ACQUIRE_DEADLOCK);
236 } 235 }
@@ -253,11 +252,9 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
253 acpi_gbl_mutex_info[mutex_id].use_count++; 252 acpi_gbl_mutex_info[mutex_id].use_count++;
254 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; 253 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
255 } else { 254 } else {
256 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 255 ACPI_EXCEPTION((AE_INFO, status,
257 "Thread %X could not acquire Mutex [%s] %s\n", 256 "Thread %X could not acquire Mutex [%X]",
258 this_thread_id, 257 this_thread_id, mutex_id));
259 acpi_ut_get_mutex_name(mutex_id),
260 acpi_format_exception(status)));
261 } 258 }
262 259
263 return (status); 260 return (status);
@@ -295,9 +292,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
295 * Mutex must be acquired in order to release it! 292 * Mutex must be acquired in order to release it!
296 */ 293 */
297 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { 294 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 295 ACPI_ERROR((AE_INFO,
299 "Mutex [%s] is not acquired, cannot release\n", 296 "Mutex [%X] is not acquired, cannot release",
300 acpi_ut_get_mutex_name(mutex_id))); 297 mutex_id));
301 298
302 return (AE_NOT_ACQUIRED); 299 return (AE_NOT_ACQUIRED);
303 } 300 }
@@ -313,16 +310,15 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
313 * the ACPI subsystem code. 310 * the ACPI subsystem code.
314 */ 311 */
315 for (i = mutex_id; i < MAX_MUTEX; i++) { 312 for (i = mutex_id; i < MAX_MUTEX; i++) {
316 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 313 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
317 if (i == mutex_id) { 314 if (i == mutex_id) {
318 continue; 315 continue;
319 } 316 }
320 317
321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 318 ACPI_ERROR((AE_INFO,
322 "Invalid release order: owns [%s], releasing [%s]\n", 319 "Invalid release order: owns [%s], releasing [%s]",
323 acpi_ut_get_mutex_name(i), 320 acpi_ut_get_mutex_name(i),
324 acpi_ut_get_mutex_name 321 acpi_ut_get_mutex_name(mutex_id)));
325 (mutex_id)));
326 322
327 return (AE_RELEASE_DEADLOCK); 323 return (AE_RELEASE_DEADLOCK);
328 } 324 }
@@ -338,11 +334,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
338 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); 334 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
339 335
340 if (ACPI_FAILURE(status)) { 336 if (ACPI_FAILURE(status)) {
341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 337 ACPI_EXCEPTION((AE_INFO, status,
342 "Thread %X could not release Mutex [%s] %s\n", 338 "Thread %X could not release Mutex [%X]",
343 this_thread_id, 339 this_thread_id, mutex_id));
344 acpi_ut_get_mutex_name(mutex_id),
345 acpi_format_exception(status)));
346 } else { 340 } else {
347 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 341 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
348 "Thread %X released Mutex [%s]\n", 342 "Thread %X released Mutex [%s]\n",
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 3015e1540053..7ee2d1d98071 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -177,7 +177,8 @@ union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size)
177 177
178 buffer = ACPI_MEM_CALLOCATE(buffer_size); 178 buffer = ACPI_MEM_CALLOCATE(buffer_size);
179 if (!buffer) { 179 if (!buffer) {
180 ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size)); 180 ACPI_ERROR((AE_INFO, "Could not allocate size %X",
181 (u32) buffer_size));
181 acpi_ut_remove_reference(buffer_desc); 182 acpi_ut_remove_reference(buffer_desc);
182 return_PTR(NULL); 183 return_PTR(NULL);
183 } 184 }
@@ -228,7 +229,8 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
228 */ 229 */
229 string = ACPI_MEM_CALLOCATE(string_size + 1); 230 string = ACPI_MEM_CALLOCATE(string_size + 1);
230 if (!string) { 231 if (!string) {
231 ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size)); 232 ACPI_ERROR((AE_INFO, "Could not allocate size %X",
233 (u32) string_size));
232 acpi_ut_remove_reference(string_desc); 234 acpi_ut_remove_reference(string_desc);
233 return_PTR(NULL); 235 return_PTR(NULL);
234 } 236 }
@@ -310,8 +312,8 @@ void *acpi_ut_allocate_object_desc_dbg(char *module_name,
310 312
311 object = acpi_os_acquire_object(acpi_gbl_operand_cache); 313 object = acpi_os_acquire_object(acpi_gbl_operand_cache);
312 if (!object) { 314 if (!object) {
313 _ACPI_REPORT_ERROR(module_name, line_number, component_id, 315 ACPI_ERROR((module_name, line_number,
314 ("Could not allocate an object descriptor\n")); 316 "Could not allocate an object descriptor"));
315 317
316 return_PTR(NULL); 318 return_PTR(NULL);
317 } 319 }
@@ -345,9 +347,9 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
345 /* Object must be an union acpi_operand_object */ 347 /* Object must be an union acpi_operand_object */
346 348
347 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 349 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 350 ACPI_ERROR((AE_INFO,
349 "%p is not an ACPI Operand object [%s]\n", 351 "%p is not an ACPI Operand object [%s]", object,
350 object, acpi_ut_get_descriptor_name(object))); 352 acpi_ut_get_descriptor_name(object)));
351 return_VOID; 353 return_VOID;
352 } 354 }
353 355
@@ -449,10 +451,10 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
449 * Notably, Locals and Args are not supported, but this may be 451 * Notably, Locals and Args are not supported, but this may be
450 * required eventually. 452 * required eventually.
451 */ 453 */
452 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 454 ACPI_ERROR((AE_INFO,
453 "Unsupported Reference opcode=%X in object %p\n", 455 "Unsupported Reference opcode=%X in object %p",
454 internal_object->reference.opcode, 456 internal_object->reference.opcode,
455 internal_object)); 457 internal_object));
456 status = AE_TYPE; 458 status = AE_TYPE;
457 break; 459 break;
458 } 460 }
@@ -460,10 +462,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
460 462
461 default: 463 default:
462 464
463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 465 ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p",
464 "Unsupported type=%X in object %p\n", 466 ACPI_GET_OBJECT_TYPE(internal_object),
465 ACPI_GET_OBJECT_TYPE(internal_object), 467 internal_object));
466 internal_object));
467 status = AE_TYPE; 468 status = AE_TYPE;
468 break; 469 break;
469 } 470 }
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
new file mode 100644
index 000000000000..16461317113f
--- /dev/null
+++ b/drivers/acpi/utilities/utresrc.c
@@ -0,0 +1,554 @@
1/*******************************************************************************
2 *
3 * Module Name: utresrc - Resource managment utilities
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/amlresrc.h>
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utmisc")
49
50#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
51/*
52 * Strings used to decode resource descriptors.
53 * Used by both the disasssembler and the debugger resource dump routines
54 */
55const char *acpi_gbl_BMdecode[2] = {
56 "not_bus_master",
57 "bus_master"
58};
59
60const char *acpi_gbl_config_decode[4] = {
61 "0 - Good Configuration",
62 "1 - Acceptable Configuration",
63 "2 - Suboptimal Configuration",
64 "3 - ***Invalid Configuration***",
65};
66
67const char *acpi_gbl_consume_decode[2] = {
68 "resource_producer",
69 "resource_consumer"
70};
71
72const char *acpi_gbl_DECdecode[2] = {
73 "pos_decode",
74 "sub_decode"
75};
76
77const char *acpi_gbl_HEdecode[2] = {
78 "Level",
79 "Edge"
80};
81
82const char *acpi_gbl_io_decode[2] = {
83 "Decode10",
84 "Decode16"
85};
86
87const char *acpi_gbl_LLdecode[2] = {
88 "active_high",
89 "active_low"
90};
91
92const char *acpi_gbl_max_decode[2] = {
93 "max_not_fixed",
94 "max_fixed"
95};
96
97const char *acpi_gbl_MEMdecode[4] = {
98 "non_cacheable",
99 "Cacheable",
100 "write_combining",
101 "Prefetchable"
102};
103
104const char *acpi_gbl_min_decode[2] = {
105 "min_not_fixed",
106 "min_fixed"
107};
108
109const char *acpi_gbl_MTPdecode[4] = {
110 "address_range_memory",
111 "address_range_reserved",
112 "address_range_aCPI",
113 "address_range_nVS"
114};
115
116const char *acpi_gbl_RNGdecode[4] = {
117 "invalid_ranges",
118 "non_iSAonly_ranges",
119 "ISAonly_ranges",
120 "entire_range"
121};
122
123const char *acpi_gbl_RWdecode[2] = {
124 "read_only",
125 "read_write"
126};
127
128const char *acpi_gbl_SHRdecode[2] = {
129 "Exclusive",
130 "Shared"
131};
132
133const char *acpi_gbl_SIZdecode[4] = {
134 "Transfer8",
135 "Transfer8_16",
136 "Transfer16",
137 "invalid_size"
138};
139
140const char *acpi_gbl_TRSdecode[2] = {
141 "dense_translation",
142 "sparse_translation"
143};
144
145const char *acpi_gbl_TTPdecode[2] = {
146 "type_static",
147 "type_translation"
148};
149
150const char *acpi_gbl_TYPdecode[4] = {
151 "Compatibility",
152 "type_a",
153 "type_b",
154 "type_f"
155};
156
157#endif
158
159/*
160 * Base sizes of the raw AML resource descriptors, indexed by resource type.
161 * Zero indicates a reserved (and therefore invalid) resource type.
162 */
163const u8 acpi_gbl_resource_aml_sizes[] = {
164 /* Small descriptors */
165
166 0,
167 0,
168 0,
169 0,
170 ACPI_AML_SIZE_SMALL(struct aml_resource_irq),
171 ACPI_AML_SIZE_SMALL(struct aml_resource_dma),
172 ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent),
173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),
174 ACPI_AML_SIZE_SMALL(struct aml_resource_io),
175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),
176 0,
177 0,
178 0,
179 0,
180 ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small),
181 ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag),
182
183 /* Large descriptors */
184
185 0,
186 ACPI_AML_SIZE_LARGE(struct aml_resource_memory24),
187 ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register),
188 0,
189 ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large),
190 ACPI_AML_SIZE_LARGE(struct aml_resource_memory32),
191 ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32),
192 ACPI_AML_SIZE_LARGE(struct aml_resource_address32),
193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),
194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),
195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),
196 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)
197};
198
199/*
200 * Resource types, used to validate the resource length field.
201 * The length of fixed-length types must match exactly, variable
202 * lengths must meet the minimum required length, etc.
203 * Zero indicates a reserved (and therefore invalid) resource type.
204 */
205static const u8 acpi_gbl_resource_types[] = {
206 /* Small descriptors */
207
208 0,
209 0,
210 0,
211 0,
212 ACPI_SMALL_VARIABLE_LENGTH,
213 ACPI_FIXED_LENGTH,
214 ACPI_SMALL_VARIABLE_LENGTH,
215 ACPI_FIXED_LENGTH,
216 ACPI_FIXED_LENGTH,
217 ACPI_FIXED_LENGTH,
218 0,
219 0,
220 0,
221 0,
222 ACPI_VARIABLE_LENGTH,
223 ACPI_FIXED_LENGTH,
224
225 /* Large descriptors */
226
227 0,
228 ACPI_FIXED_LENGTH,
229 ACPI_FIXED_LENGTH,
230 0,
231 ACPI_VARIABLE_LENGTH,
232 ACPI_FIXED_LENGTH,
233 ACPI_FIXED_LENGTH,
234 ACPI_VARIABLE_LENGTH,
235 ACPI_VARIABLE_LENGTH,
236 ACPI_VARIABLE_LENGTH,
237 ACPI_VARIABLE_LENGTH,
238 ACPI_FIXED_LENGTH
239};
240
241/*******************************************************************************
242 *
243 * FUNCTION: acpi_ut_validate_resource
244 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
246 * return_index - Where the resource index is returned. NULL
247 * if the index is not required.
248 *
249 * RETURN: Status, and optionally the Index into the global resource tables
250 *
251 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
252 * Type and Resource Length. Returns an index into the global
253 * resource information/dispatch tables for later use.
254 *
255 ******************************************************************************/
256
257acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
258{
259 u8 resource_type;
260 u8 resource_index;
261 acpi_rs_length resource_length;
262 acpi_rs_length minimum_resource_length;
263
264 ACPI_FUNCTION_ENTRY();
265
266 /*
267 * 1) Validate the resource_type field (Byte 0)
268 */
269 resource_type = ACPI_GET8(aml);
270
271 /*
272 * Byte 0 contains the descriptor name (Resource Type)
273 * Examine the large/small bit in the resource header
274 */
275 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
276 /* Verify the large resource type (name) against the max */
277
278 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
279 return (AE_AML_INVALID_RESOURCE_TYPE);
280 }
281
282 /*
283 * Large Resource Type -- bits 6:0 contain the name
284 * Translate range 0x80-0x8B to index range 0x10-0x1B
285 */
286 resource_index = (u8) (resource_type - 0x70);
287 } else {
288 /*
289 * Small Resource Type -- bits 6:3 contain the name
290 * Shift range to index range 0x00-0x0F
291 */
292 resource_index = (u8)
293 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
294 }
295
296 /* Check validity of the resource type, zero indicates name is invalid */
297
298 if (!acpi_gbl_resource_types[resource_index]) {
299 return (AE_AML_INVALID_RESOURCE_TYPE);
300 }
301
302 /*
303 * 2) Validate the resource_length field. This ensures that the length
304 * is at least reasonable, and guarantees that it is non-zero.
305 */
306 resource_length = acpi_ut_get_resource_length(aml);
307 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];
308
309 /* Validate based upon the type of resource - fixed length or variable */
310
311 switch (acpi_gbl_resource_types[resource_index]) {
312 case ACPI_FIXED_LENGTH:
313
314 /* Fixed length resource, length must match exactly */
315
316 if (resource_length != minimum_resource_length) {
317 return (AE_AML_BAD_RESOURCE_LENGTH);
318 }
319 break;
320
321 case ACPI_VARIABLE_LENGTH:
322
323 /* Variable length resource, length must be at least the minimum */
324
325 if (resource_length < minimum_resource_length) {
326 return (AE_AML_BAD_RESOURCE_LENGTH);
327 }
328 break;
329
330 case ACPI_SMALL_VARIABLE_LENGTH:
331
332 /* Small variable length resource, length can be (Min) or (Min-1) */
333
334 if ((resource_length > minimum_resource_length) ||
335 (resource_length < (minimum_resource_length - 1))) {
336 return (AE_AML_BAD_RESOURCE_LENGTH);
337 }
338 break;
339
340 default:
341
342 /* Shouldn't happen (because of validation earlier), but be sure */
343
344 return (AE_AML_INVALID_RESOURCE_TYPE);
345 }
346
347 /* Optionally return the resource table index */
348
349 if (return_index) {
350 *return_index = resource_index;
351 }
352
353 return (AE_OK);
354}
355
356/*******************************************************************************
357 *
358 * FUNCTION: acpi_ut_get_resource_type
359 *
360 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
361 *
362 * RETURN: The Resource Type with no extraneous bits (except the
363 * Large/Small descriptor bit -- this is left alone)
364 *
365 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
366 * a resource descriptor.
367 *
368 ******************************************************************************/
369
370u8 acpi_ut_get_resource_type(void *aml)
371{
372 ACPI_FUNCTION_ENTRY();
373
374 /*
375 * Byte 0 contains the descriptor name (Resource Type)
376 * Examine the large/small bit in the resource header
377 */
378 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
379 /* Large Resource Type -- bits 6:0 contain the name */
380
381 return (ACPI_GET8(aml));
382 } else {
383 /* Small Resource Type -- bits 6:3 contain the name */
384
385 return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
386 }
387}
388
389/*******************************************************************************
390 *
391 * FUNCTION: acpi_ut_get_resource_length
392 *
393 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
394 *
395 * RETURN: Byte Length
396 *
397 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
398 * definition, this does not include the size of the descriptor
399 * header or the length field itself.
400 *
401 ******************************************************************************/
402
403u16 acpi_ut_get_resource_length(void *aml)
404{
405 acpi_rs_length resource_length;
406
407 ACPI_FUNCTION_ENTRY();
408
409 /*
410 * Byte 0 contains the descriptor name (Resource Type)
411 * Examine the large/small bit in the resource header
412 */
413 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
414 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
415
416 ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1));
417
418 } else {
419 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
420
421 resource_length = (u16) (ACPI_GET8(aml) &
422 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
423 }
424
425 return (resource_length);
426}
427
428/*******************************************************************************
429 *
430 * FUNCTION: acpi_ut_get_resource_header_length
431 *
432 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
433 *
434 * RETURN: Length of the AML header (depends on large/small descriptor)
435 *
436 * DESCRIPTION: Get the length of the header for this resource.
437 *
438 ******************************************************************************/
439
440u8 acpi_ut_get_resource_header_length(void *aml)
441{
442 ACPI_FUNCTION_ENTRY();
443
444 /* Examine the large/small bit in the resource header */
445
446 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
447 return (sizeof(struct aml_resource_large_header));
448 } else {
449 return (sizeof(struct aml_resource_small_header));
450 }
451}
452
453/*******************************************************************************
454 *
455 * FUNCTION: acpi_ut_get_descriptor_length
456 *
457 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
458 *
459 * RETURN: Byte length
460 *
461 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
462 * length of the descriptor header and the length field itself.
463 * Used to walk descriptor lists.
464 *
465 ******************************************************************************/
466
467u32 acpi_ut_get_descriptor_length(void *aml)
468{
469 ACPI_FUNCTION_ENTRY();
470
471 /*
472 * Get the Resource Length (does not include header length) and add
473 * the header length (depends on if this is a small or large resource)
474 */
475 return (acpi_ut_get_resource_length(aml) +
476 acpi_ut_get_resource_header_length(aml));
477}
478
479/*******************************************************************************
480 *
481 * FUNCTION: acpi_ut_get_resource_end_tag
482 *
483 * PARAMETERS: obj_desc - The resource template buffer object
484 * end_tag - Where the pointer to the end_tag is returned
485 *
486 * RETURN: Status, pointer to the end tag
487 *
488 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template
489 * Note: allows a buffer length of zero.
490 *
491 ******************************************************************************/
492
493acpi_status
494acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
495 u8 ** end_tag)
496{
497 acpi_status status;
498 u8 *aml;
499 u8 *end_aml;
500
501 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag");
502
503 /* Get start and end pointers */
504
505 aml = obj_desc->buffer.pointer;
506 end_aml = aml + obj_desc->buffer.length;
507
508 /* Allow a buffer length of zero */
509
510 if (!obj_desc->buffer.length) {
511 *end_tag = aml;
512 return_ACPI_STATUS(AE_OK);
513 }
514
515 /* Walk the resource template, one descriptor per iteration */
516
517 while (aml < end_aml) {
518 /* Validate the Resource Type and Resource Length */
519
520 status = acpi_ut_validate_resource(aml, NULL);
521 if (ACPI_FAILURE(status)) {
522 return_ACPI_STATUS(status);
523 }
524
525 /* end_tag resource indicates the end of the resource template */
526
527 if (acpi_ut_get_resource_type(aml) ==
528 ACPI_RESOURCE_NAME_END_TAG) {
529 /*
530 * There must be at least one more byte in the buffer for
531 * the 2nd byte of the end_tag
532 */
533 if ((aml + 1) >= end_aml) {
534 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
535 }
536
537 /* Return the pointer to the end_tag */
538
539 *end_tag = aml;
540 return_ACPI_STATUS(AE_OK);
541 }
542
543 /*
544 * Point to the next resource descriptor in the AML buffer. The
545 * descriptor length is guaranteed to be non-zero by resource
546 * validation above.
547 */
548 aml += acpi_ut_get_descriptor_length(aml);
549 }
550
551 /* Did not find an end_tag resource descriptor */
552
553 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
554}
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index c1cb27583be8..4b134a722907 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,7 @@ acpi_status
63acpi_ut_create_pkg_state_and_push(void *internal_object, 63acpi_ut_create_pkg_state_and_push(void *internal_object,
64 void *external_object, 64 void *external_object,
65 u16 index, 65 u16 index,
66 union acpi_generic_state ** state_list) 66 union acpi_generic_state **state_list)
67{ 67{
68 union acpi_generic_state *state; 68 union acpi_generic_state *state;
69 69
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index f06bd5e5e9d1..308a960871be 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -75,8 +75,7 @@ acpi_status acpi_initialize_subsystem(void)
75 75
76 status = acpi_os_initialize(); 76 status = acpi_os_initialize();
77 if (ACPI_FAILURE(status)) { 77 if (ACPI_FAILURE(status)) {
78 ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n", 78 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
79 acpi_format_exception(status)));
80 return_ACPI_STATUS(status); 79 return_ACPI_STATUS(status);
81 } 80 }
82 81
@@ -88,8 +87,8 @@ acpi_status acpi_initialize_subsystem(void)
88 87
89 status = acpi_ut_mutex_initialize(); 88 status = acpi_ut_mutex_initialize();
90 if (ACPI_FAILURE(status)) { 89 if (ACPI_FAILURE(status)) {
91 ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n", 90 ACPI_EXCEPTION((AE_INFO, status,
92 acpi_format_exception(status))); 91 "During Global Mutex creation"));
93 return_ACPI_STATUS(status); 92 return_ACPI_STATUS(status);
94 } 93 }
95 94
@@ -99,15 +98,14 @@ acpi_status acpi_initialize_subsystem(void)
99 */ 98 */
100 status = acpi_ns_root_initialize(); 99 status = acpi_ns_root_initialize();
101 if (ACPI_FAILURE(status)) { 100 if (ACPI_FAILURE(status)) {
102 ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n", 101 ACPI_EXCEPTION((AE_INFO, status,
103 acpi_format_exception(status))); 102 "During Namespace initialization"));
104 return_ACPI_STATUS(status); 103 return_ACPI_STATUS(status);
105 } 104 }
106 105
107 /* If configured, initialize the AML debugger */ 106 /* If configured, initialize the AML debugger */
108 107
109 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); 108 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
110
111 return_ACPI_STATUS(status); 109 return_ACPI_STATUS(status);
112} 110}
113 111
@@ -154,8 +152,7 @@ acpi_status acpi_enable_subsystem(u32 flags)
154 152
155 status = acpi_enable(); 153 status = acpi_enable();
156 if (ACPI_FAILURE(status)) { 154 if (ACPI_FAILURE(status)) {
157 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 155 ACPI_WARNING((AE_INFO, "acpi_enable failed"));
158 "acpi_enable failed.\n"));
159 return_ACPI_STATUS(status); 156 return_ACPI_STATUS(status);
160 } 157 }
161 } 158 }
@@ -178,10 +175,14 @@ acpi_status acpi_enable_subsystem(u32 flags)
178 /* 175 /*
179 * Initialize ACPI Event handling (Fixed and General Purpose) 176 * Initialize ACPI Event handling (Fixed and General Purpose)
180 * 177 *
181 * NOTE: We must have the hardware AND events initialized before we can 178 * Note1: We must have the hardware and events initialized before we can
182 * execute ANY control methods SAFELY. Any control method can require 179 * execute any control methods safely. Any control method can require
183 * ACPI hardware support, so the hardware MUST be initialized before 180 * ACPI hardware support, so the hardware must be fully initialized before
184 * execution! 181 * any method execution!
182 *
183 * Note2: Fixed events are initialized and enabled here. GPEs are
184 * initialized, but cannot be enabled until after the hardware is
185 * completely initialized (SCI and global_lock activated)
185 */ 186 */
186 if (!(flags & ACPI_NO_EVENT_INIT)) { 187 if (!(flags & ACPI_NO_EVENT_INIT)) {
187 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 188 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -193,8 +194,10 @@ acpi_status acpi_enable_subsystem(u32 flags)
193 } 194 }
194 } 195 }
195 196
196 /* Install the SCI handler and Global Lock handler */ 197 /*
197 198 * Install the SCI handler and Global Lock handler. This completes the
199 * hardware initialization.
200 */
198 if (!(flags & ACPI_NO_HANDLER_INIT)) { 201 if (!(flags & ACPI_NO_HANDLER_INIT)) {
199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 202 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
200 "[Init] Installing SCI/GL handlers\n")); 203 "[Init] Installing SCI/GL handlers\n"));
@@ -205,6 +208,24 @@ acpi_status acpi_enable_subsystem(u32 flags)
205 } 208 }
206 } 209 }
207 210
211 /*
212 * Complete the GPE initialization for the GPE blocks defined in the FADT
213 * (GPE block 0 and 1).
214 *
215 * Note1: This is where the _PRW methods are executed for the GPEs. These
216 * methods can only be executed after the SCI and Global Lock handlers are
217 * installed and initialized.
218 *
219 * Note2: Currently, there seems to be no need to run the _REG methods
220 * before execution of the _PRW methods and enabling of the GPEs.
221 */
222 if (!(flags & ACPI_NO_EVENT_INIT)) {
223 status = acpi_ev_install_fadt_gpes();
224 if (ACPI_FAILURE(status)) {
225 return (status);
226 }
227 }
228
208 return_ACPI_STATUS(status); 229 return_ACPI_STATUS(status);
209} 230}
210 231
@@ -230,9 +251,9 @@ acpi_status acpi_initialize_objects(u32 flags)
230 /* 251 /*
231 * Run all _REG methods 252 * Run all _REG methods
232 * 253 *
233 * NOTE: Any objects accessed 254 * Note: Any objects accessed by the _REG methods will be automatically
234 * by the _REG methods will be automatically initialized, even if they 255 * initialized, even if they contain executable AML (see the call to
235 * contain executable AML (see call to acpi_ns_initialize_objects below). 256 * acpi_ns_initialize_objects below).
236 */ 257 */
237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 258 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -245,9 +266,9 @@ acpi_status acpi_initialize_objects(u32 flags)
245 } 266 }
246 267
247 /* 268 /*
248 * Initialize the objects that remain uninitialized. This 269 * Initialize the objects that remain uninitialized. This runs the
249 * runs the executable AML that may be part of the declaration of these 270 * executable AML that may be part of the declaration of these objects:
250 * objects: operation_regions, buffer_fields, Buffers, and Packages. 271 * operation_regions, buffer_fields, Buffers, and Packages.
251 */ 272 */
252 if (!(flags & ACPI_NO_OBJECT_INIT)) { 273 if (!(flags & ACPI_NO_OBJECT_INIT)) {
253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 274 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -260,8 +281,8 @@ acpi_status acpi_initialize_objects(u32 flags)
260 } 281 }
261 282
262 /* 283 /*
263 * Initialize all device objects in the namespace 284 * Initialize all device objects in the namespace. This runs the device
264 * This runs the _STA and _INI methods. 285 * _STA and _INI methods.
265 */ 286 */
266 if (!(flags & ACPI_NO_DEVICE_INIT)) { 287 if (!(flags & ACPI_NO_DEVICE_INIT)) {
267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 288 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d10668f14699..bd4887518373 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -920,8 +920,8 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
921 "Unable to create 'state' fs entry\n")); 921 "Unable to create 'state' fs entry\n"));
922 else { 922 else {
923 acpi_video_device_state_fops.write = acpi_video_device_write_state;
923 entry->proc_fops = &acpi_video_device_state_fops; 924 entry->proc_fops = &acpi_video_device_state_fops;
924 entry->proc_fops->write = acpi_video_device_write_state;
925 entry->data = acpi_driver_data(device); 925 entry->data = acpi_driver_data(device);
926 entry->owner = THIS_MODULE; 926 entry->owner = THIS_MODULE;
927 } 927 }
@@ -934,8 +934,8 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
935 "Unable to create 'brightness' fs entry\n")); 935 "Unable to create 'brightness' fs entry\n"));
936 else { 936 else {
937 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
937 entry->proc_fops = &acpi_video_device_brightness_fops; 938 entry->proc_fops = &acpi_video_device_brightness_fops;
938 entry->proc_fops->write = acpi_video_device_write_brightness;
939 entry->data = acpi_driver_data(device); 939 entry->data = acpi_driver_data(device);
940 entry->owner = THIS_MODULE; 940 entry->owner = THIS_MODULE;
941 } 941 }
@@ -1239,8 +1239,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1240 "Unable to create 'POST' fs entry\n")); 1240 "Unable to create 'POST' fs entry\n"));
1241 else { 1241 else {
1242 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1242 entry->proc_fops = &acpi_video_bus_POST_fops; 1243 entry->proc_fops = &acpi_video_bus_POST_fops;
1243 entry->proc_fops->write = acpi_video_bus_write_POST;
1244 entry->data = acpi_driver_data(device); 1244 entry->data = acpi_driver_data(device);
1245 entry->owner = THIS_MODULE; 1245 entry->owner = THIS_MODULE;
1246 } 1246 }
@@ -1253,8 +1253,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1254 "Unable to create 'DOS' fs entry\n")); 1254 "Unable to create 'DOS' fs entry\n"));
1255 else { 1255 else {
1256 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1256 entry->proc_fops = &acpi_video_bus_DOS_fops; 1257 entry->proc_fops = &acpi_video_bus_DOS_fops;
1257 entry->proc_fops->write = acpi_video_bus_write_DOS;
1258 entry->data = acpi_driver_data(device); 1258 entry->data = acpi_driver_data(device);
1259 entry->owner = THIS_MODULE; 1259 entry->owner = THIS_MODULE;
1260 } 1260 }
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index f12898d53078..e99471d3232b 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -8,6 +8,7 @@ obj-y += power/
8obj-$(CONFIG_FW_LOADER) += firmware_class.o 8obj-$(CONFIG_FW_LOADER) += firmware_class.o
9obj-$(CONFIG_NUMA) += node.o 9obj-$(CONFIG_NUMA) += node.o
10obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o 10obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o
11obj-$(CONFIG_SMP) += topology.o
11 12
12ifeq ($(CONFIG_DEBUG_DRIVER),y) 13ifeq ($(CONFIG_DEBUG_DRIVER),y)
13EXTRA_CFLAGS += -DDEBUG 14EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
new file mode 100644
index 000000000000..915810f6237e
--- /dev/null
+++ b/drivers/base/topology.c
@@ -0,0 +1,148 @@
1/*
2 * driver/base/topology.c - Populate sysfs with cpu topology information
3 *
4 * Written by: Zhang Yanmin, Intel Corporation
5 *
6 * Copyright (C) 2006, Intel Corp.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 */
26#include <linux/sysdev.h>
27#include <linux/init.h>
28#include <linux/mm.h>
29#include <linux/cpu.h>
30#include <linux/module.h>
31#include <linux/topology.h>
32
33#define define_one_ro(_name) \
34static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
35
36#define define_id_show_func(name) \
37static ssize_t show_##name(struct sys_device *dev, char *buf) \
38{ \
39 unsigned int cpu = dev->id; \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \
41}
42
43#define define_siblings_show_func(name) \
44static ssize_t show_##name(struct sys_device *dev, char *buf) \
45{ \
46 ssize_t len = -1; \
47 unsigned int cpu = dev->id; \
48 len = cpumask_scnprintf(buf, NR_CPUS+1, topology_##name(cpu)); \
49 return (len + sprintf(buf + len, "\n")); \
50}
51
52#ifdef topology_physical_package_id
53define_id_show_func(physical_package_id);
54define_one_ro(physical_package_id);
55#define ref_physical_package_id_attr &attr_physical_package_id.attr,
56#else
57#define ref_physical_package_id_attr
58#endif
59
60#ifdef topology_core_id
61define_id_show_func(core_id);
62define_one_ro(core_id);
63#define ref_core_id_attr &attr_core_id.attr,
64#else
65#define ref_core_id_attr
66#endif
67
68#ifdef topology_thread_siblings
69define_siblings_show_func(thread_siblings);
70define_one_ro(thread_siblings);
71#define ref_thread_siblings_attr &attr_thread_siblings.attr,
72#else
73#define ref_thread_siblings_attr
74#endif
75
76#ifdef topology_core_siblings
77define_siblings_show_func(core_siblings);
78define_one_ro(core_siblings);
79#define ref_core_siblings_attr &attr_core_siblings.attr,
80#else
81#define ref_core_siblings_attr
82#endif
83
84static struct attribute *default_attrs[] = {
85 ref_physical_package_id_attr
86 ref_core_id_attr
87 ref_thread_siblings_attr
88 ref_core_siblings_attr
89 NULL
90};
91
92static struct attribute_group topology_attr_group = {
93 .attrs = default_attrs,
94 .name = "topology"
95};
96
97/* Add/Remove cpu_topology interface for CPU device */
98static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
99{
100 sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
101 return 0;
102}
103
104static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
105{
106 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group);
107 return 0;
108}
109
110static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
111 unsigned long action, void *hcpu)
112{
113 unsigned int cpu = (unsigned long)hcpu;
114 struct sys_device *sys_dev;
115
116 sys_dev = get_cpu_sysdev(cpu);
117 switch (action) {
118 case CPU_ONLINE:
119 topology_add_dev(sys_dev);
120 break;
121 case CPU_DEAD:
122 topology_remove_dev(sys_dev);
123 break;
124 }
125 return NOTIFY_OK;
126}
127
128static struct notifier_block topology_cpu_notifier =
129{
130 .notifier_call = topology_cpu_callback,
131};
132
133static int __cpuinit topology_sysfs_init(void)
134{
135 int i;
136
137 for_each_online_cpu(i) {
138 topology_cpu_callback(&topology_cpu_notifier, CPU_ONLINE,
139 (void *)(long)i);
140 }
141
142 register_cpu_notifier(&topology_cpu_notifier);
143
144 return 0;
145}
146
147device_initcall(topology_sysfs_init);
148
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index a3614e6a68d0..4ada1268b40d 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -882,7 +882,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
882 card->card_number, dev->bus->number, dev->devfn); 882 card->card_number, dev->bus->number, dev->devfn);
883 883
884 if (pci_set_dma_mask(dev, 0xffffffffffffffffLL) && 884 if (pci_set_dma_mask(dev, 0xffffffffffffffffLL) &&
885 !pci_set_dma_mask(dev, 0xffffffffLL)) { 885 pci_set_dma_mask(dev, 0xffffffffLL)) {
886 printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards); 886 printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards);
887 return -ENOMEM; 887 return -ENOMEM;
888 } 888 }
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 4135d8c5bcae..4c67727d75b1 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -992,7 +992,7 @@ config HPET_MMAP
992 992
993config HANGCHECK_TIMER 993config HANGCHECK_TIMER
994 tristate "Hangcheck timer" 994 tristate "Hangcheck timer"
995 depends on X86 || IA64 || PPC64 || S390 995 depends on X86 || IA64 || PPC64
996 help 996 help
997 The hangcheck-timer module detects when the system has gone 997 The hangcheck-timer module detects when the system has gone
998 out to lunch past a certain margin. It can reboot the system 998 out to lunch past a certain margin. It can reboot the system
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 39c61a71176e..cc7acf877dc0 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1233,7 +1233,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1233 } 1233 }
1234 info->idle_stats.recv_idle = jiffies; 1234 info->idle_stats.recv_idle = jiffies;
1235 } 1235 }
1236 schedule_delayed_work(&tty->buf.work, 1); 1236 tty_schedule_flip(tty);
1237 } 1237 }
1238 /* end of service */ 1238 /* end of service */
1239 cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f)); 1239 cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f));
@@ -1606,7 +1606,7 @@ cyz_handle_rx(struct cyclades_port *info,
1606 } 1606 }
1607#endif 1607#endif
1608 info->idle_stats.recv_idle = jiffies; 1608 info->idle_stats.recv_idle = jiffies;
1609 schedule_delayed_work(&tty->buf.work, 1); 1609 tty_schedule_flip(tty);
1610 } 1610 }
1611 /* Update rx_get */ 1611 /* Update rx_get */
1612 cy_writel(&buf_ctrl->rx_get, new_rx_get); 1612 cy_writel(&buf_ctrl->rx_get, new_rx_get);
@@ -1809,7 +1809,7 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
1809 if(delta_count) 1809 if(delta_count)
1810 cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); 1810 cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
1811 if(special_count) 1811 if(special_count)
1812 schedule_delayed_work(&tty->buf.work, 1); 1812 tty_schedule_flip(tty);
1813 } 1813 }
1814} 1814}
1815 1815
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index 5485382cadec..bd7be09ea53d 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -59,17 +59,16 @@ static void *drm_ati_alloc_pcigart_table(void)
59 int i; 59 int i;
60 DRM_DEBUG("%s\n", __FUNCTION__); 60 DRM_DEBUG("%s\n", __FUNCTION__);
61 61
62 address = __get_free_pages(GFP_KERNEL, ATI_PCIGART_TABLE_ORDER); 62 address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
63 ATI_PCIGART_TABLE_ORDER);
63 if (address == 0UL) { 64 if (address == 0UL) {
64 return 0; 65 return NULL;
65 } 66 }
66 67
67 page = virt_to_page(address); 68 page = virt_to_page(address);
68 69
69 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 70 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
70 get_page(page);
71 SetPageReserved(page); 71 SetPageReserved(page);
72 }
73 72
74 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); 73 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
75 return (void *)address; 74 return (void *)address;
@@ -83,10 +82,8 @@ static void drm_ati_free_pcigart_table(void *address)
83 82
84 page = virt_to_page((unsigned long)address); 83 page = virt_to_page((unsigned long)address);
85 84
86 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 85 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
87 __put_page(page);
88 ClearPageReserved(page); 86 ClearPageReserved(page);
89 }
90 87
91 free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER); 88 free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
92} 89}
@@ -127,7 +124,7 @@ int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
127 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN 124 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN
128 && gart_info->addr) { 125 && gart_info->addr) {
129 drm_ati_free_pcigart_table(gart_info->addr); 126 drm_ati_free_pcigart_table(gart_info->addr);
130 gart_info->addr = 0; 127 gart_info->addr = NULL;
131 } 128 }
132 129
133 return 1; 130 return 1;
@@ -168,7 +165,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
168 if (bus_address == 0) { 165 if (bus_address == 0) {
169 DRM_ERROR("unable to map PCIGART pages!\n"); 166 DRM_ERROR("unable to map PCIGART pages!\n");
170 drm_ati_free_pcigart_table(address); 167 drm_ati_free_pcigart_table(address);
171 address = 0; 168 address = NULL;
172 goto done; 169 goto done;
173 } 170 }
174 } else { 171 } else {
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 54b561e69486..71b8b32b075f 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -57,6 +57,7 @@
57#include <linux/smp_lock.h> /* For (un)lock_kernel */ 57#include <linux/smp_lock.h> /* For (un)lock_kernel */
58#include <linux/mm.h> 58#include <linux/mm.h>
59#include <linux/cdev.h> 59#include <linux/cdev.h>
60#include <linux/mutex.h>
60#if defined(__alpha__) || defined(__powerpc__) 61#if defined(__alpha__) || defined(__powerpc__)
61#include <asm/pgtable.h> /* For pte_wrprotect */ 62#include <asm/pgtable.h> /* For pte_wrprotect */
62#endif 63#endif
@@ -623,7 +624,7 @@ typedef struct drm_device {
623 /** \name Locks */ 624 /** \name Locks */
624 /*@{ */ 625 /*@{ */
625 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 626 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
626 struct semaphore struct_sem; /**< For others */ 627 struct mutex struct_mutex; /**< For others */
627 /*@} */ 628 /*@} */
628 629
629 /** \name Usage Counters */ 630 /** \name Usage Counters */
@@ -658,7 +659,7 @@ typedef struct drm_device {
658 /*@{ */ 659 /*@{ */
659 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ 660 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
660 int ctx_count; /**< Number of context handles */ 661 int ctx_count; /**< Number of context handles */
661 struct semaphore ctxlist_sem; /**< For ctxlist */ 662 struct mutex ctxlist_mutex; /**< For ctxlist */
662 663
663 drm_map_t **context_sareas; /**< per-context SAREA's */ 664 drm_map_t **context_sareas; /**< per-context SAREA's */
664 int max_context; 665 int max_context;
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c
index a47b502bc7cc..2a37586a7ee8 100644
--- a/drivers/char/drm/drm_auth.c
+++ b/drivers/char/drm/drm_auth.c
@@ -56,7 +56,7 @@ static int drm_hash_magic(drm_magic_t magic)
56 * \param magic magic number. 56 * \param magic magic number.
57 * 57 *
58 * Searches in drm_device::magiclist within all files with the same hash key 58 * Searches in drm_device::magiclist within all files with the same hash key
59 * the one with matching magic number, while holding the drm_device::struct_sem 59 * the one with matching magic number, while holding the drm_device::struct_mutex
60 * lock. 60 * lock.
61 */ 61 */
62static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) 62static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
@@ -65,14 +65,14 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
65 drm_magic_entry_t *pt; 65 drm_magic_entry_t *pt;
66 int hash = drm_hash_magic(magic); 66 int hash = drm_hash_magic(magic);
67 67
68 down(&dev->struct_sem); 68 mutex_lock(&dev->struct_mutex);
69 for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { 69 for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
70 if (pt->magic == magic) { 70 if (pt->magic == magic) {
71 retval = pt->priv; 71 retval = pt->priv;
72 break; 72 break;
73 } 73 }
74 } 74 }
75 up(&dev->struct_sem); 75 mutex_unlock(&dev->struct_mutex);
76 return retval; 76 return retval;
77} 77}
78 78
@@ -85,7 +85,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
85 * 85 *
86 * Creates a drm_magic_entry structure and appends to the linked list 86 * Creates a drm_magic_entry structure and appends to the linked list
87 * associated the magic number hash key in drm_device::magiclist, while holding 87 * associated the magic number hash key in drm_device::magiclist, while holding
88 * the drm_device::struct_sem lock. 88 * the drm_device::struct_mutex lock.
89 */ 89 */
90static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, 90static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
91 drm_magic_t magic) 91 drm_magic_t magic)
@@ -104,7 +104,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
104 entry->priv = priv; 104 entry->priv = priv;
105 entry->next = NULL; 105 entry->next = NULL;
106 106
107 down(&dev->struct_sem); 107 mutex_lock(&dev->struct_mutex);
108 if (dev->magiclist[hash].tail) { 108 if (dev->magiclist[hash].tail) {
109 dev->magiclist[hash].tail->next = entry; 109 dev->magiclist[hash].tail->next = entry;
110 dev->magiclist[hash].tail = entry; 110 dev->magiclist[hash].tail = entry;
@@ -112,7 +112,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
112 dev->magiclist[hash].head = entry; 112 dev->magiclist[hash].head = entry;
113 dev->magiclist[hash].tail = entry; 113 dev->magiclist[hash].tail = entry;
114 } 114 }
115 up(&dev->struct_sem); 115 mutex_unlock(&dev->struct_mutex);
116 116
117 return 0; 117 return 0;
118} 118}
@@ -124,7 +124,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
124 * \param magic magic number. 124 * \param magic magic number.
125 * 125 *
126 * Searches and unlinks the entry in drm_device::magiclist with the magic 126 * Searches and unlinks the entry in drm_device::magiclist with the magic
127 * number hash key, while holding the drm_device::struct_sem lock. 127 * number hash key, while holding the drm_device::struct_mutex lock.
128 */ 128 */
129static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) 129static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
130{ 130{
@@ -135,7 +135,7 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
135 DRM_DEBUG("%d\n", magic); 135 DRM_DEBUG("%d\n", magic);
136 hash = drm_hash_magic(magic); 136 hash = drm_hash_magic(magic);
137 137
138 down(&dev->struct_sem); 138 mutex_lock(&dev->struct_mutex);
139 for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { 139 for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
140 if (pt->magic == magic) { 140 if (pt->magic == magic) {
141 if (dev->magiclist[hash].head == pt) { 141 if (dev->magiclist[hash].head == pt) {
@@ -147,11 +147,11 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
147 if (prev) { 147 if (prev) {
148 prev->next = pt->next; 148 prev->next = pt->next;
149 } 149 }
150 up(&dev->struct_sem); 150 mutex_unlock(&dev->struct_mutex);
151 return 0; 151 return 0;
152 } 152 }
153 } 153 }
154 up(&dev->struct_sem); 154 mutex_unlock(&dev->struct_mutex);
155 155
156 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); 156 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
157 157
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 1db12dcb6802..e2637b4d51de 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -255,14 +255,14 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
255 memset(list, 0, sizeof(*list)); 255 memset(list, 0, sizeof(*list));
256 list->map = map; 256 list->map = map;
257 257
258 down(&dev->struct_sem); 258 mutex_lock(&dev->struct_mutex);
259 list_add(&list->head, &dev->maplist->head); 259 list_add(&list->head, &dev->maplist->head);
260 /* Assign a 32-bit handle */ 260 /* Assign a 32-bit handle */
261 /* We do it here so that dev->struct_sem protects the increment */ 261 /* We do it here so that dev->struct_mutex protects the increment */
262 list->user_token = HandleID(map->type == _DRM_SHM 262 list->user_token = HandleID(map->type == _DRM_SHM
263 ? (unsigned long)map->handle 263 ? (unsigned long)map->handle
264 : map->offset, dev); 264 : map->offset, dev);
265 up(&dev->struct_sem); 265 mutex_unlock(&dev->struct_mutex);
266 266
267 *maplist = list; 267 *maplist = list;
268 return 0; 268 return 0;
@@ -392,9 +392,9 @@ int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
392{ 392{
393 int ret; 393 int ret;
394 394
395 down(&dev->struct_sem); 395 mutex_lock(&dev->struct_mutex);
396 ret = drm_rmmap_locked(dev, map); 396 ret = drm_rmmap_locked(dev, map);
397 up(&dev->struct_sem); 397 mutex_unlock(&dev->struct_mutex);
398 398
399 return ret; 399 return ret;
400} 400}
@@ -423,7 +423,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
423 return -EFAULT; 423 return -EFAULT;
424 } 424 }
425 425
426 down(&dev->struct_sem); 426 mutex_lock(&dev->struct_mutex);
427 list_for_each(list, &dev->maplist->head) { 427 list_for_each(list, &dev->maplist->head) {
428 drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); 428 drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
429 429
@@ -439,7 +439,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
439 * find anything. 439 * find anything.
440 */ 440 */
441 if (list == (&dev->maplist->head)) { 441 if (list == (&dev->maplist->head)) {
442 up(&dev->struct_sem); 442 mutex_unlock(&dev->struct_mutex);
443 return -EINVAL; 443 return -EINVAL;
444 } 444 }
445 445
@@ -448,13 +448,13 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
448 448
449 /* Register and framebuffer maps are permanent */ 449 /* Register and framebuffer maps are permanent */
450 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) { 450 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) {
451 up(&dev->struct_sem); 451 mutex_unlock(&dev->struct_mutex);
452 return 0; 452 return 0;
453 } 453 }
454 454
455 ret = drm_rmmap_locked(dev, map); 455 ret = drm_rmmap_locked(dev, map);
456 456
457 up(&dev->struct_sem); 457 mutex_unlock(&dev->struct_mutex);
458 458
459 return ret; 459 return ret;
460} 460}
@@ -566,16 +566,16 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
566 atomic_inc(&dev->buf_alloc); 566 atomic_inc(&dev->buf_alloc);
567 spin_unlock(&dev->count_lock); 567 spin_unlock(&dev->count_lock);
568 568
569 down(&dev->struct_sem); 569 mutex_lock(&dev->struct_mutex);
570 entry = &dma->bufs[order]; 570 entry = &dma->bufs[order];
571 if (entry->buf_count) { 571 if (entry->buf_count) {
572 up(&dev->struct_sem); 572 mutex_unlock(&dev->struct_mutex);
573 atomic_dec(&dev->buf_alloc); 573 atomic_dec(&dev->buf_alloc);
574 return -ENOMEM; /* May only call once for each order */ 574 return -ENOMEM; /* May only call once for each order */
575 } 575 }
576 576
577 if (count < 0 || count > 4096) { 577 if (count < 0 || count > 4096) {
578 up(&dev->struct_sem); 578 mutex_unlock(&dev->struct_mutex);
579 atomic_dec(&dev->buf_alloc); 579 atomic_dec(&dev->buf_alloc);
580 return -EINVAL; 580 return -EINVAL;
581 } 581 }
@@ -583,7 +583,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
583 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 583 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
584 DRM_MEM_BUFS); 584 DRM_MEM_BUFS);
585 if (!entry->buflist) { 585 if (!entry->buflist) {
586 up(&dev->struct_sem); 586 mutex_unlock(&dev->struct_mutex);
587 atomic_dec(&dev->buf_alloc); 587 atomic_dec(&dev->buf_alloc);
588 return -ENOMEM; 588 return -ENOMEM;
589 } 589 }
@@ -616,7 +616,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
616 /* Set count correctly so we free the proper amount. */ 616 /* Set count correctly so we free the proper amount. */
617 entry->buf_count = count; 617 entry->buf_count = count;
618 drm_cleanup_buf_error(dev, entry); 618 drm_cleanup_buf_error(dev, entry);
619 up(&dev->struct_sem); 619 mutex_unlock(&dev->struct_mutex);
620 atomic_dec(&dev->buf_alloc); 620 atomic_dec(&dev->buf_alloc);
621 return -ENOMEM; 621 return -ENOMEM;
622 } 622 }
@@ -638,7 +638,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
638 if (!temp_buflist) { 638 if (!temp_buflist) {
639 /* Free the entry because it isn't valid */ 639 /* Free the entry because it isn't valid */
640 drm_cleanup_buf_error(dev, entry); 640 drm_cleanup_buf_error(dev, entry);
641 up(&dev->struct_sem); 641 mutex_unlock(&dev->struct_mutex);
642 atomic_dec(&dev->buf_alloc); 642 atomic_dec(&dev->buf_alloc);
643 return -ENOMEM; 643 return -ENOMEM;
644 } 644 }
@@ -656,7 +656,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
656 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 656 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
657 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 657 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
658 658
659 up(&dev->struct_sem); 659 mutex_unlock(&dev->struct_mutex);
660 660
661 request->count = entry->buf_count; 661 request->count = entry->buf_count;
662 request->size = size; 662 request->size = size;
@@ -722,16 +722,16 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
722 atomic_inc(&dev->buf_alloc); 722 atomic_inc(&dev->buf_alloc);
723 spin_unlock(&dev->count_lock); 723 spin_unlock(&dev->count_lock);
724 724
725 down(&dev->struct_sem); 725 mutex_lock(&dev->struct_mutex);
726 entry = &dma->bufs[order]; 726 entry = &dma->bufs[order];
727 if (entry->buf_count) { 727 if (entry->buf_count) {
728 up(&dev->struct_sem); 728 mutex_unlock(&dev->struct_mutex);
729 atomic_dec(&dev->buf_alloc); 729 atomic_dec(&dev->buf_alloc);
730 return -ENOMEM; /* May only call once for each order */ 730 return -ENOMEM; /* May only call once for each order */
731 } 731 }
732 732
733 if (count < 0 || count > 4096) { 733 if (count < 0 || count > 4096) {
734 up(&dev->struct_sem); 734 mutex_unlock(&dev->struct_mutex);
735 atomic_dec(&dev->buf_alloc); 735 atomic_dec(&dev->buf_alloc);
736 return -EINVAL; 736 return -EINVAL;
737 } 737 }
@@ -739,7 +739,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
739 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 739 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
740 DRM_MEM_BUFS); 740 DRM_MEM_BUFS);
741 if (!entry->buflist) { 741 if (!entry->buflist) {
742 up(&dev->struct_sem); 742 mutex_unlock(&dev->struct_mutex);
743 atomic_dec(&dev->buf_alloc); 743 atomic_dec(&dev->buf_alloc);
744 return -ENOMEM; 744 return -ENOMEM;
745 } 745 }
@@ -750,7 +750,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
750 if (!entry->seglist) { 750 if (!entry->seglist) {
751 drm_free(entry->buflist, 751 drm_free(entry->buflist,
752 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 752 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
753 up(&dev->struct_sem); 753 mutex_unlock(&dev->struct_mutex);
754 atomic_dec(&dev->buf_alloc); 754 atomic_dec(&dev->buf_alloc);
755 return -ENOMEM; 755 return -ENOMEM;
756 } 756 }
@@ -766,7 +766,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
766 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 766 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
767 drm_free(entry->seglist, 767 drm_free(entry->seglist,
768 count * sizeof(*entry->seglist), DRM_MEM_SEGS); 768 count * sizeof(*entry->seglist), DRM_MEM_SEGS);
769 up(&dev->struct_sem); 769 mutex_unlock(&dev->struct_mutex);
770 atomic_dec(&dev->buf_alloc); 770 atomic_dec(&dev->buf_alloc);
771 return -ENOMEM; 771 return -ENOMEM;
772 } 772 }
@@ -790,7 +790,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
790 drm_free(temp_pagelist, 790 drm_free(temp_pagelist,
791 (dma->page_count + (count << page_order)) 791 (dma->page_count + (count << page_order))
792 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 792 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
793 up(&dev->struct_sem); 793 mutex_unlock(&dev->struct_mutex);
794 atomic_dec(&dev->buf_alloc); 794 atomic_dec(&dev->buf_alloc);
795 return -ENOMEM; 795 return -ENOMEM;
796 } 796 }
@@ -831,7 +831,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
831 (count << page_order)) 831 (count << page_order))
832 * sizeof(*dma->pagelist), 832 * sizeof(*dma->pagelist),
833 DRM_MEM_PAGES); 833 DRM_MEM_PAGES);
834 up(&dev->struct_sem); 834 mutex_unlock(&dev->struct_mutex);
835 atomic_dec(&dev->buf_alloc); 835 atomic_dec(&dev->buf_alloc);
836 return -ENOMEM; 836 return -ENOMEM;
837 } 837 }
@@ -853,7 +853,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
853 drm_free(temp_pagelist, 853 drm_free(temp_pagelist,
854 (dma->page_count + (count << page_order)) 854 (dma->page_count + (count << page_order))
855 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 855 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
856 up(&dev->struct_sem); 856 mutex_unlock(&dev->struct_mutex);
857 atomic_dec(&dev->buf_alloc); 857 atomic_dec(&dev->buf_alloc);
858 return -ENOMEM; 858 return -ENOMEM;
859 } 859 }
@@ -878,7 +878,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
878 dma->page_count += entry->seg_count << page_order; 878 dma->page_count += entry->seg_count << page_order;
879 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order); 879 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
880 880
881 up(&dev->struct_sem); 881 mutex_unlock(&dev->struct_mutex);
882 882
883 request->count = entry->buf_count; 883 request->count = entry->buf_count;
884 request->size = size; 884 request->size = size;
@@ -948,16 +948,16 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
948 atomic_inc(&dev->buf_alloc); 948 atomic_inc(&dev->buf_alloc);
949 spin_unlock(&dev->count_lock); 949 spin_unlock(&dev->count_lock);
950 950
951 down(&dev->struct_sem); 951 mutex_lock(&dev->struct_mutex);
952 entry = &dma->bufs[order]; 952 entry = &dma->bufs[order];
953 if (entry->buf_count) { 953 if (entry->buf_count) {
954 up(&dev->struct_sem); 954 mutex_unlock(&dev->struct_mutex);
955 atomic_dec(&dev->buf_alloc); 955 atomic_dec(&dev->buf_alloc);
956 return -ENOMEM; /* May only call once for each order */ 956 return -ENOMEM; /* May only call once for each order */
957 } 957 }
958 958
959 if (count < 0 || count > 4096) { 959 if (count < 0 || count > 4096) {
960 up(&dev->struct_sem); 960 mutex_unlock(&dev->struct_mutex);
961 atomic_dec(&dev->buf_alloc); 961 atomic_dec(&dev->buf_alloc);
962 return -EINVAL; 962 return -EINVAL;
963 } 963 }
@@ -965,7 +965,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
965 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 965 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
966 DRM_MEM_BUFS); 966 DRM_MEM_BUFS);
967 if (!entry->buflist) { 967 if (!entry->buflist) {
968 up(&dev->struct_sem); 968 mutex_unlock(&dev->struct_mutex);
969 atomic_dec(&dev->buf_alloc); 969 atomic_dec(&dev->buf_alloc);
970 return -ENOMEM; 970 return -ENOMEM;
971 } 971 }
@@ -999,7 +999,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
999 /* Set count correctly so we free the proper amount. */ 999 /* Set count correctly so we free the proper amount. */
1000 entry->buf_count = count; 1000 entry->buf_count = count;
1001 drm_cleanup_buf_error(dev, entry); 1001 drm_cleanup_buf_error(dev, entry);
1002 up(&dev->struct_sem); 1002 mutex_unlock(&dev->struct_mutex);
1003 atomic_dec(&dev->buf_alloc); 1003 atomic_dec(&dev->buf_alloc);
1004 return -ENOMEM; 1004 return -ENOMEM;
1005 } 1005 }
@@ -1022,7 +1022,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
1022 if (!temp_buflist) { 1022 if (!temp_buflist) {
1023 /* Free the entry because it isn't valid */ 1023 /* Free the entry because it isn't valid */
1024 drm_cleanup_buf_error(dev, entry); 1024 drm_cleanup_buf_error(dev, entry);
1025 up(&dev->struct_sem); 1025 mutex_unlock(&dev->struct_mutex);
1026 atomic_dec(&dev->buf_alloc); 1026 atomic_dec(&dev->buf_alloc);
1027 return -ENOMEM; 1027 return -ENOMEM;
1028 } 1028 }
@@ -1040,7 +1040,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
1040 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 1040 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1041 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 1041 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1042 1042
1043 up(&dev->struct_sem); 1043 mutex_unlock(&dev->struct_mutex);
1044 1044
1045 request->count = entry->buf_count; 1045 request->count = entry->buf_count;
1046 request->size = size; 1046 request->size = size;
@@ -1110,16 +1110,16 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1110 atomic_inc(&dev->buf_alloc); 1110 atomic_inc(&dev->buf_alloc);
1111 spin_unlock(&dev->count_lock); 1111 spin_unlock(&dev->count_lock);
1112 1112
1113 down(&dev->struct_sem); 1113 mutex_lock(&dev->struct_mutex);
1114 entry = &dma->bufs[order]; 1114 entry = &dma->bufs[order];
1115 if (entry->buf_count) { 1115 if (entry->buf_count) {
1116 up(&dev->struct_sem); 1116 mutex_unlock(&dev->struct_mutex);
1117 atomic_dec(&dev->buf_alloc); 1117 atomic_dec(&dev->buf_alloc);
1118 return -ENOMEM; /* May only call once for each order */ 1118 return -ENOMEM; /* May only call once for each order */
1119 } 1119 }
1120 1120
1121 if (count < 0 || count > 4096) { 1121 if (count < 0 || count > 4096) {
1122 up(&dev->struct_sem); 1122 mutex_unlock(&dev->struct_mutex);
1123 atomic_dec(&dev->buf_alloc); 1123 atomic_dec(&dev->buf_alloc);
1124 return -EINVAL; 1124 return -EINVAL;
1125 } 1125 }
@@ -1127,7 +1127,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1127 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 1127 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
1128 DRM_MEM_BUFS); 1128 DRM_MEM_BUFS);
1129 if (!entry->buflist) { 1129 if (!entry->buflist) {
1130 up(&dev->struct_sem); 1130 mutex_unlock(&dev->struct_mutex);
1131 atomic_dec(&dev->buf_alloc); 1131 atomic_dec(&dev->buf_alloc);
1132 return -ENOMEM; 1132 return -ENOMEM;
1133 } 1133 }
@@ -1160,7 +1160,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1160 /* Set count correctly so we free the proper amount. */ 1160 /* Set count correctly so we free the proper amount. */
1161 entry->buf_count = count; 1161 entry->buf_count = count;
1162 drm_cleanup_buf_error(dev, entry); 1162 drm_cleanup_buf_error(dev, entry);
1163 up(&dev->struct_sem); 1163 mutex_unlock(&dev->struct_mutex);
1164 atomic_dec(&dev->buf_alloc); 1164 atomic_dec(&dev->buf_alloc);
1165 return -ENOMEM; 1165 return -ENOMEM;
1166 } 1166 }
@@ -1182,7 +1182,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1182 if (!temp_buflist) { 1182 if (!temp_buflist) {
1183 /* Free the entry because it isn't valid */ 1183 /* Free the entry because it isn't valid */
1184 drm_cleanup_buf_error(dev, entry); 1184 drm_cleanup_buf_error(dev, entry);
1185 up(&dev->struct_sem); 1185 mutex_unlock(&dev->struct_mutex);
1186 atomic_dec(&dev->buf_alloc); 1186 atomic_dec(&dev->buf_alloc);
1187 return -ENOMEM; 1187 return -ENOMEM;
1188 } 1188 }
@@ -1200,7 +1200,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1200 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 1200 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1201 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 1201 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1202 1202
1203 up(&dev->struct_sem); 1203 mutex_unlock(&dev->struct_mutex);
1204 1204
1205 request->count = entry->buf_count; 1205 request->count = entry->buf_count;
1206 request->size = size; 1206 request->size = size;
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index f84254526949..83094c73da67 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -53,7 +53,7 @@
53 * \param ctx_handle context handle. 53 * \param ctx_handle context handle.
54 * 54 *
55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry 55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
56 * in drm_device::context_sareas, while holding the drm_device::struct_sem 56 * in drm_device::context_sareas, while holding the drm_device::struct_mutex
57 * lock. 57 * lock.
58 */ 58 */
59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) 59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
64 goto failed; 64 goto failed;
65 65
66 if (ctx_handle < DRM_MAX_CTXBITMAP) { 66 if (ctx_handle < DRM_MAX_CTXBITMAP) {
67 down(&dev->struct_sem); 67 mutex_lock(&dev->struct_mutex);
68 clear_bit(ctx_handle, dev->ctx_bitmap); 68 clear_bit(ctx_handle, dev->ctx_bitmap);
69 dev->context_sareas[ctx_handle] = NULL; 69 dev->context_sareas[ctx_handle] = NULL;
70 up(&dev->struct_sem); 70 mutex_unlock(&dev->struct_mutex);
71 return; 71 return;
72 } 72 }
73 failed: 73 failed:
@@ -83,7 +83,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
83 * 83 *
84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates 84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates
85 * drm_device::context_sareas to accommodate the new entry while holding the 85 * drm_device::context_sareas to accommodate the new entry while holding the
86 * drm_device::struct_sem lock. 86 * drm_device::struct_mutex lock.
87 */ 87 */
88static int drm_ctxbitmap_next(drm_device_t * dev) 88static int drm_ctxbitmap_next(drm_device_t * dev)
89{ 89{
@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
92 if (!dev->ctx_bitmap) 92 if (!dev->ctx_bitmap)
93 return -1; 93 return -1;
94 94
95 down(&dev->struct_sem); 95 mutex_lock(&dev->struct_mutex);
96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); 96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
97 if (bit < DRM_MAX_CTXBITMAP) { 97 if (bit < DRM_MAX_CTXBITMAP) {
98 set_bit(bit, dev->ctx_bitmap); 98 set_bit(bit, dev->ctx_bitmap);
@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
113 DRM_MEM_MAPS); 113 DRM_MEM_MAPS);
114 if (!ctx_sareas) { 114 if (!ctx_sareas) {
115 clear_bit(bit, dev->ctx_bitmap); 115 clear_bit(bit, dev->ctx_bitmap);
116 up(&dev->struct_sem); 116 mutex_unlock(&dev->struct_mutex);
117 return -1; 117 return -1;
118 } 118 }
119 dev->context_sareas = ctx_sareas; 119 dev->context_sareas = ctx_sareas;
@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
126 DRM_MEM_MAPS); 126 DRM_MEM_MAPS);
127 if (!dev->context_sareas) { 127 if (!dev->context_sareas) {
128 clear_bit(bit, dev->ctx_bitmap); 128 clear_bit(bit, dev->ctx_bitmap);
129 up(&dev->struct_sem); 129 mutex_unlock(&dev->struct_mutex);
130 return -1; 130 return -1;
131 } 131 }
132 dev->context_sareas[bit] = NULL; 132 dev->context_sareas[bit] = NULL;
133 } 133 }
134 } 134 }
135 up(&dev->struct_sem); 135 mutex_unlock(&dev->struct_mutex);
136 return bit; 136 return bit;
137 } 137 }
138 up(&dev->struct_sem); 138 mutex_unlock(&dev->struct_mutex);
139 return -1; 139 return -1;
140} 140}
141 141
@@ -145,24 +145,24 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
145 * \param dev DRM device. 145 * \param dev DRM device.
146 * 146 *
147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding 147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
148 * the drm_device::struct_sem lock. 148 * the drm_device::struct_mutex lock.
149 */ 149 */
150int drm_ctxbitmap_init(drm_device_t * dev) 150int drm_ctxbitmap_init(drm_device_t * dev)
151{ 151{
152 int i; 152 int i;
153 int temp; 153 int temp;
154 154
155 down(&dev->struct_sem); 155 mutex_lock(&dev->struct_mutex);
156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE, 156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE,
157 DRM_MEM_CTXBITMAP); 157 DRM_MEM_CTXBITMAP);
158 if (dev->ctx_bitmap == NULL) { 158 if (dev->ctx_bitmap == NULL) {
159 up(&dev->struct_sem); 159 mutex_unlock(&dev->struct_mutex);
160 return -ENOMEM; 160 return -ENOMEM;
161 } 161 }
162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE); 162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE);
163 dev->context_sareas = NULL; 163 dev->context_sareas = NULL;
164 dev->max_context = -1; 164 dev->max_context = -1;
165 up(&dev->struct_sem); 165 mutex_unlock(&dev->struct_mutex);
166 166
167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { 167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
168 temp = drm_ctxbitmap_next(dev); 168 temp = drm_ctxbitmap_next(dev);
@@ -178,17 +178,17 @@ int drm_ctxbitmap_init(drm_device_t * dev)
178 * \param dev DRM device. 178 * \param dev DRM device.
179 * 179 *
180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding 180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
181 * the drm_device::struct_sem lock. 181 * the drm_device::struct_mutex lock.
182 */ 182 */
183void drm_ctxbitmap_cleanup(drm_device_t * dev) 183void drm_ctxbitmap_cleanup(drm_device_t * dev)
184{ 184{
185 down(&dev->struct_sem); 185 mutex_lock(&dev->struct_mutex);
186 if (dev->context_sareas) 186 if (dev->context_sareas)
187 drm_free(dev->context_sareas, 187 drm_free(dev->context_sareas,
188 sizeof(*dev->context_sareas) * 188 sizeof(*dev->context_sareas) *
189 dev->max_context, DRM_MEM_MAPS); 189 dev->max_context, DRM_MEM_MAPS);
190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); 190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
191 up(&dev->struct_sem); 191 mutex_unlock(&dev->struct_mutex);
192} 192}
193 193
194/*@}*/ 194/*@}*/
@@ -222,15 +222,15 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
222 if (copy_from_user(&request, argp, sizeof(request))) 222 if (copy_from_user(&request, argp, sizeof(request)))
223 return -EFAULT; 223 return -EFAULT;
224 224
225 down(&dev->struct_sem); 225 mutex_lock(&dev->struct_mutex);
226 if (dev->max_context < 0 226 if (dev->max_context < 0
227 || request.ctx_id >= (unsigned)dev->max_context) { 227 || request.ctx_id >= (unsigned)dev->max_context) {
228 up(&dev->struct_sem); 228 mutex_unlock(&dev->struct_mutex);
229 return -EINVAL; 229 return -EINVAL;
230 } 230 }
231 231
232 map = dev->context_sareas[request.ctx_id]; 232 map = dev->context_sareas[request.ctx_id];
233 up(&dev->struct_sem); 233 mutex_unlock(&dev->struct_mutex);
234 234
235 request.handle = NULL; 235 request.handle = NULL;
236 list_for_each_entry(_entry, &dev->maplist->head, head) { 236 list_for_each_entry(_entry, &dev->maplist->head, head) {
@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
274 (drm_ctx_priv_map_t __user *) arg, sizeof(request))) 274 (drm_ctx_priv_map_t __user *) arg, sizeof(request)))
275 return -EFAULT; 275 return -EFAULT;
276 276
277 down(&dev->struct_sem); 277 mutex_lock(&dev->struct_mutex);
278 list_for_each(list, &dev->maplist->head) { 278 list_for_each(list, &dev->maplist->head) {
279 r_list = list_entry(list, drm_map_list_t, head); 279 r_list = list_entry(list, drm_map_list_t, head);
280 if (r_list->map 280 if (r_list->map
@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
282 goto found; 282 goto found;
283 } 283 }
284 bad: 284 bad:
285 up(&dev->struct_sem); 285 mutex_unlock(&dev->struct_mutex);
286 return -EINVAL; 286 return -EINVAL;
287 287
288 found: 288 found:
@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
294 if (request.ctx_id >= (unsigned)dev->max_context) 294 if (request.ctx_id >= (unsigned)dev->max_context)
295 goto bad; 295 goto bad;
296 dev->context_sareas[request.ctx_id] = map; 296 dev->context_sareas[request.ctx_id] = map;
297 up(&dev->struct_sem); 297 mutex_unlock(&dev->struct_mutex);
298 return 0; 298 return 0;
299} 299}
300 300
@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
448 ctx_entry->handle = ctx.handle; 448 ctx_entry->handle = ctx.handle;
449 ctx_entry->tag = priv; 449 ctx_entry->tag = priv;
450 450
451 down(&dev->ctxlist_sem); 451 mutex_lock(&dev->ctxlist_mutex);
452 list_add(&ctx_entry->head, &dev->ctxlist->head); 452 list_add(&ctx_entry->head, &dev->ctxlist->head);
453 ++dev->ctx_count; 453 ++dev->ctx_count;
454 up(&dev->ctxlist_sem); 454 mutex_unlock(&dev->ctxlist_mutex);
455 455
456 if (copy_to_user(argp, &ctx, sizeof(ctx))) 456 if (copy_to_user(argp, &ctx, sizeof(ctx)))
457 return -EFAULT; 457 return -EFAULT;
@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
574 drm_ctxbitmap_free(dev, ctx.handle); 574 drm_ctxbitmap_free(dev, ctx.handle);
575 } 575 }
576 576
577 down(&dev->ctxlist_sem); 577 mutex_lock(&dev->ctxlist_mutex);
578 if (!list_empty(&dev->ctxlist->head)) { 578 if (!list_empty(&dev->ctxlist->head)) {
579 drm_ctx_list_t *pos, *n; 579 drm_ctx_list_t *pos, *n;
580 580
@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
586 } 586 }
587 } 587 }
588 } 588 }
589 up(&dev->ctxlist_sem); 589 mutex_unlock(&dev->ctxlist_mutex);
590 590
591 return 0; 591 return 0;
592} 592}
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index c4fa5a29582b..dc6bbe8a18dc 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -151,7 +151,7 @@ int drm_lastclose(drm_device_t * dev)
151 if (dev->irq_enabled) 151 if (dev->irq_enabled)
152 drm_irq_uninstall(dev); 152 drm_irq_uninstall(dev);
153 153
154 down(&dev->struct_sem); 154 mutex_lock(&dev->struct_mutex);
155 del_timer(&dev->timer); 155 del_timer(&dev->timer);
156 156
157 /* Clear pid list */ 157 /* Clear pid list */
@@ -231,7 +231,7 @@ int drm_lastclose(drm_device_t * dev)
231 dev->lock.filp = NULL; 231 dev->lock.filp = NULL;
232 wake_up_interruptible(&dev->lock.lock_queue); 232 wake_up_interruptible(&dev->lock.lock_queue);
233 } 233 }
234 up(&dev->struct_sem); 234 mutex_unlock(&dev->struct_mutex);
235 235
236 DRM_DEBUG("lastclose completed\n"); 236 DRM_DEBUG("lastclose completed\n");
237 return 0; 237 return 0;
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 403f44a1bf01..641f7633878c 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -262,7 +262,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
262 goto out_free; 262 goto out_free;
263 } 263 }
264 264
265 down(&dev->struct_sem); 265 mutex_lock(&dev->struct_mutex);
266 if (!dev->file_last) { 266 if (!dev->file_last) {
267 priv->next = NULL; 267 priv->next = NULL;
268 priv->prev = NULL; 268 priv->prev = NULL;
@@ -276,7 +276,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
276 dev->file_last->next = priv; 276 dev->file_last->next = priv;
277 dev->file_last = priv; 277 dev->file_last = priv;
278 } 278 }
279 up(&dev->struct_sem); 279 mutex_unlock(&dev->struct_mutex);
280 280
281#ifdef __alpha__ 281#ifdef __alpha__
282 /* 282 /*
@@ -413,7 +413,7 @@ int drm_release(struct inode *inode, struct file *filp)
413 413
414 drm_fasync(-1, filp, 0); 414 drm_fasync(-1, filp, 0);
415 415
416 down(&dev->ctxlist_sem); 416 mutex_lock(&dev->ctxlist_mutex);
417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { 417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
418 drm_ctx_list_t *pos, *n; 418 drm_ctx_list_t *pos, *n;
419 419
@@ -432,9 +432,9 @@ int drm_release(struct inode *inode, struct file *filp)
432 } 432 }
433 } 433 }
434 } 434 }
435 up(&dev->ctxlist_sem); 435 mutex_unlock(&dev->ctxlist_mutex);
436 436
437 down(&dev->struct_sem); 437 mutex_lock(&dev->struct_mutex);
438 if (priv->remove_auth_on_close == 1) { 438 if (priv->remove_auth_on_close == 1) {
439 drm_file_t *temp = dev->file_first; 439 drm_file_t *temp = dev->file_first;
440 while (temp) { 440 while (temp) {
@@ -452,7 +452,7 @@ int drm_release(struct inode *inode, struct file *filp)
452 } else { 452 } else {
453 dev->file_last = priv->prev; 453 dev->file_last = priv->prev;
454 } 454 }
455 up(&dev->struct_sem); 455 mutex_unlock(&dev->struct_mutex);
456 456
457 if (dev->driver->postclose) 457 if (dev->driver->postclose)
458 dev->driver->postclose(dev, priv); 458 dev->driver->postclose(dev, priv);
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index bcd4e604d3ec..555f323b8a32 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -194,9 +194,9 @@ int drm_getmap(struct inode *inode, struct file *filp,
194 return -EFAULT; 194 return -EFAULT;
195 idx = map.offset; 195 idx = map.offset;
196 196
197 down(&dev->struct_sem); 197 mutex_lock(&dev->struct_mutex);
198 if (idx < 0) { 198 if (idx < 0) {
199 up(&dev->struct_sem); 199 mutex_unlock(&dev->struct_mutex);
200 return -EINVAL; 200 return -EINVAL;
201 } 201 }
202 202
@@ -209,7 +209,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
209 i++; 209 i++;
210 } 210 }
211 if (!r_list || !r_list->map) { 211 if (!r_list || !r_list->map) {
212 up(&dev->struct_sem); 212 mutex_unlock(&dev->struct_mutex);
213 return -EINVAL; 213 return -EINVAL;
214 } 214 }
215 215
@@ -219,7 +219,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
219 map.flags = r_list->map->flags; 219 map.flags = r_list->map->flags;
220 map.handle = (void *)(unsigned long)r_list->user_token; 220 map.handle = (void *)(unsigned long)r_list->user_token;
221 map.mtrr = r_list->map->mtrr; 221 map.mtrr = r_list->map->mtrr;
222 up(&dev->struct_sem); 222 mutex_unlock(&dev->struct_mutex);
223 223
224 if (copy_to_user(argp, &map, sizeof(map))) 224 if (copy_to_user(argp, &map, sizeof(map)))
225 return -EFAULT; 225 return -EFAULT;
@@ -253,11 +253,11 @@ int drm_getclient(struct inode *inode, struct file *filp,
253 if (copy_from_user(&client, argp, sizeof(client))) 253 if (copy_from_user(&client, argp, sizeof(client)))
254 return -EFAULT; 254 return -EFAULT;
255 idx = client.idx; 255 idx = client.idx;
256 down(&dev->struct_sem); 256 mutex_lock(&dev->struct_mutex);
257 for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ; 257 for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ;
258 258
259 if (!pt) { 259 if (!pt) {
260 up(&dev->struct_sem); 260 mutex_unlock(&dev->struct_mutex);
261 return -EINVAL; 261 return -EINVAL;
262 } 262 }
263 client.auth = pt->authenticated; 263 client.auth = pt->authenticated;
@@ -265,7 +265,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
265 client.uid = pt->uid; 265 client.uid = pt->uid;
266 client.magic = pt->magic; 266 client.magic = pt->magic;
267 client.iocs = pt->ioctl_count; 267 client.iocs = pt->ioctl_count;
268 up(&dev->struct_sem); 268 mutex_unlock(&dev->struct_mutex);
269 269
270 if (copy_to_user(argp, &client, sizeof(client))) 270 if (copy_to_user(argp, &client, sizeof(client)))
271 return -EFAULT; 271 return -EFAULT;
@@ -292,7 +292,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
292 292
293 memset(&stats, 0, sizeof(stats)); 293 memset(&stats, 0, sizeof(stats));
294 294
295 down(&dev->struct_sem); 295 mutex_lock(&dev->struct_mutex);
296 296
297 for (i = 0; i < dev->counters; i++) { 297 for (i = 0; i < dev->counters; i++) {
298 if (dev->types[i] == _DRM_STAT_LOCK) 298 if (dev->types[i] == _DRM_STAT_LOCK)
@@ -305,7 +305,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
305 305
306 stats.count = dev->counters; 306 stats.count = dev->counters;
307 307
308 up(&dev->struct_sem); 308 mutex_unlock(&dev->struct_mutex);
309 309
310 if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats))) 310 if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats)))
311 return -EFAULT; 311 return -EFAULT;
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index b0d4b236e837..611a1173091d 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -98,20 +98,20 @@ static int drm_irq_install(drm_device_t * dev)
98 if (dev->irq == 0) 98 if (dev->irq == 0)
99 return -EINVAL; 99 return -EINVAL;
100 100
101 down(&dev->struct_sem); 101 mutex_lock(&dev->struct_mutex);
102 102
103 /* Driver must have been initialized */ 103 /* Driver must have been initialized */
104 if (!dev->dev_private) { 104 if (!dev->dev_private) {
105 up(&dev->struct_sem); 105 mutex_unlock(&dev->struct_mutex);
106 return -EINVAL; 106 return -EINVAL;
107 } 107 }
108 108
109 if (dev->irq_enabled) { 109 if (dev->irq_enabled) {
110 up(&dev->struct_sem); 110 mutex_unlock(&dev->struct_mutex);
111 return -EBUSY; 111 return -EBUSY;
112 } 112 }
113 dev->irq_enabled = 1; 113 dev->irq_enabled = 1;
114 up(&dev->struct_sem); 114 mutex_unlock(&dev->struct_mutex);
115 115
116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq); 116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
117 117
@@ -135,9 +135,9 @@ static int drm_irq_install(drm_device_t * dev)
135 ret = request_irq(dev->irq, dev->driver->irq_handler, 135 ret = request_irq(dev->irq, dev->driver->irq_handler,
136 sh_flags, dev->devname, dev); 136 sh_flags, dev->devname, dev);
137 if (ret < 0) { 137 if (ret < 0) {
138 down(&dev->struct_sem); 138 mutex_lock(&dev->struct_mutex);
139 dev->irq_enabled = 0; 139 dev->irq_enabled = 0;
140 up(&dev->struct_sem); 140 mutex_unlock(&dev->struct_mutex);
141 return ret; 141 return ret;
142 } 142 }
143 143
@@ -161,10 +161,10 @@ int drm_irq_uninstall(drm_device_t * dev)
161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
162 return -EINVAL; 162 return -EINVAL;
163 163
164 down(&dev->struct_sem); 164 mutex_lock(&dev->struct_mutex);
165 irq_enabled = dev->irq_enabled; 165 irq_enabled = dev->irq_enabled;
166 dev->irq_enabled = 0; 166 dev->irq_enabled = 0;
167 up(&dev->struct_sem); 167 mutex_unlock(&dev->struct_mutex);
168 168
169 if (!irq_enabled) 169 if (!irq_enabled)
170 return -EINVAL; 170 return -EINVAL;
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 5b1d3a04458d..8fd6357a48da 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -3,6 +3,7 @@
3 Please contact dri-devel@lists.sf.net to add new cards to this list 3 Please contact dri-devel@lists.sf.net to add new cards to this list
4*/ 4*/
5#define radeon_PCI_IDS \ 5#define radeon_PCI_IDS \
6 {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350},\
6 {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \ 7 {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \
7 {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \ 8 {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \
8 {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 9 {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
@@ -242,5 +243,6 @@
242 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 243 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
243 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 244 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
244 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 245 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
246 {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
245 {0, 0, 0} 247 {0, 0, 0}
246 248
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 6f943e3309ef..362a270af0f1 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -258,7 +258,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
258} 258}
259 259
260/** 260/**
261 * Simply calls _vm_info() while holding the drm_device::struct_sem lock. 261 * Simply calls _vm_info() while holding the drm_device::struct_mutex lock.
262 */ 262 */
263static int drm_vm_info(char *buf, char **start, off_t offset, int request, 263static int drm_vm_info(char *buf, char **start, off_t offset, int request,
264 int *eof, void *data) 264 int *eof, void *data)
@@ -266,9 +266,9 @@ static int drm_vm_info(char *buf, char **start, off_t offset, int request,
266 drm_device_t *dev = (drm_device_t *) data; 266 drm_device_t *dev = (drm_device_t *) data;
267 int ret; 267 int ret;
268 268
269 down(&dev->struct_sem); 269 mutex_lock(&dev->struct_mutex);
270 ret = drm__vm_info(buf, start, offset, request, eof, data); 270 ret = drm__vm_info(buf, start, offset, request, eof, data);
271 up(&dev->struct_sem); 271 mutex_unlock(&dev->struct_mutex);
272 return ret; 272 return ret;
273} 273}
274 274
@@ -331,7 +331,7 @@ static int drm__queues_info(char *buf, char **start, off_t offset,
331} 331}
332 332
333/** 333/**
334 * Simply calls _queues_info() while holding the drm_device::struct_sem lock. 334 * Simply calls _queues_info() while holding the drm_device::struct_mutex lock.
335 */ 335 */
336static int drm_queues_info(char *buf, char **start, off_t offset, int request, 336static int drm_queues_info(char *buf, char **start, off_t offset, int request,
337 int *eof, void *data) 337 int *eof, void *data)
@@ -339,9 +339,9 @@ static int drm_queues_info(char *buf, char **start, off_t offset, int request,
339 drm_device_t *dev = (drm_device_t *) data; 339 drm_device_t *dev = (drm_device_t *) data;
340 int ret; 340 int ret;
341 341
342 down(&dev->struct_sem); 342 mutex_lock(&dev->struct_mutex);
343 ret = drm__queues_info(buf, start, offset, request, eof, data); 343 ret = drm__queues_info(buf, start, offset, request, eof, data);
344 up(&dev->struct_sem); 344 mutex_unlock(&dev->struct_mutex);
345 return ret; 345 return ret;
346} 346}
347 347
@@ -403,7 +403,7 @@ static int drm__bufs_info(char *buf, char **start, off_t offset, int request,
403} 403}
404 404
405/** 405/**
406 * Simply calls _bufs_info() while holding the drm_device::struct_sem lock. 406 * Simply calls _bufs_info() while holding the drm_device::struct_mutex lock.
407 */ 407 */
408static int drm_bufs_info(char *buf, char **start, off_t offset, int request, 408static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
409 int *eof, void *data) 409 int *eof, void *data)
@@ -411,9 +411,9 @@ static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
411 drm_device_t *dev = (drm_device_t *) data; 411 drm_device_t *dev = (drm_device_t *) data;
412 int ret; 412 int ret;
413 413
414 down(&dev->struct_sem); 414 mutex_lock(&dev->struct_mutex);
415 ret = drm__bufs_info(buf, start, offset, request, eof, data); 415 ret = drm__bufs_info(buf, start, offset, request, eof, data);
416 up(&dev->struct_sem); 416 mutex_unlock(&dev->struct_mutex);
417 return ret; 417 return ret;
418} 418}
419 419
@@ -459,7 +459,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset,
459} 459}
460 460
461/** 461/**
462 * Simply calls _clients_info() while holding the drm_device::struct_sem lock. 462 * Simply calls _clients_info() while holding the drm_device::struct_mutex lock.
463 */ 463 */
464static int drm_clients_info(char *buf, char **start, off_t offset, 464static int drm_clients_info(char *buf, char **start, off_t offset,
465 int request, int *eof, void *data) 465 int request, int *eof, void *data)
@@ -467,9 +467,9 @@ static int drm_clients_info(char *buf, char **start, off_t offset,
467 drm_device_t *dev = (drm_device_t *) data; 467 drm_device_t *dev = (drm_device_t *) data;
468 int ret; 468 int ret;
469 469
470 down(&dev->struct_sem); 470 mutex_lock(&dev->struct_mutex);
471 ret = drm__clients_info(buf, start, offset, request, eof, data); 471 ret = drm__clients_info(buf, start, offset, request, eof, data);
472 up(&dev->struct_sem); 472 mutex_unlock(&dev->struct_mutex);
473 return ret; 473 return ret;
474} 474}
475 475
@@ -540,9 +540,9 @@ static int drm_vma_info(char *buf, char **start, off_t offset, int request,
540 drm_device_t *dev = (drm_device_t *) data; 540 drm_device_t *dev = (drm_device_t *) data;
541 int ret; 541 int ret;
542 542
543 down(&dev->struct_sem); 543 mutex_lock(&dev->struct_mutex);
544 ret = drm__vma_info(buf, start, offset, request, eof, data); 544 ret = drm__vma_info(buf, start, offset, request, eof, data);
545 up(&dev->struct_sem); 545 mutex_unlock(&dev->struct_mutex);
546 return ret; 546 return ret;
547} 547}
548#endif 548#endif
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 42d766359caa..7a9263ff3007 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -61,8 +61,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
61 61
62 spin_lock_init(&dev->count_lock); 62 spin_lock_init(&dev->count_lock);
63 init_timer(&dev->timer); 63 init_timer(&dev->timer);
64 sema_init(&dev->struct_sem, 1); 64 mutex_init(&dev->struct_mutex);
65 sema_init(&dev->ctxlist_sem, 1); 65 mutex_init(&dev->ctxlist_mutex);
66 66
67 dev->pdev = pdev; 67 dev->pdev = pdev;
68 68
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 3f73aa774c80..0291cd62c69f 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -188,7 +188,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
188 188
189 map = vma->vm_private_data; 189 map = vma->vm_private_data;
190 190
191 down(&dev->struct_sem); 191 mutex_lock(&dev->struct_mutex);
192 for (pt = dev->vmalist, prev = NULL; pt; pt = next) { 192 for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
193 next = pt->next; 193 next = pt->next;
194 if (pt->vma->vm_private_data == map) 194 if (pt->vma->vm_private_data == map)
@@ -248,7 +248,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
248 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 248 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
249 } 249 }
250 } 250 }
251 up(&dev->struct_sem); 251 mutex_unlock(&dev->struct_mutex);
252} 252}
253 253
254/** 254/**
@@ -404,12 +404,12 @@ static void drm_vm_open(struct vm_area_struct *vma)
404 404
405 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); 405 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
406 if (vma_entry) { 406 if (vma_entry) {
407 down(&dev->struct_sem); 407 mutex_lock(&dev->struct_mutex);
408 vma_entry->vma = vma; 408 vma_entry->vma = vma;
409 vma_entry->next = dev->vmalist; 409 vma_entry->next = dev->vmalist;
410 vma_entry->pid = current->pid; 410 vma_entry->pid = current->pid;
411 dev->vmalist = vma_entry; 411 dev->vmalist = vma_entry;
412 up(&dev->struct_sem); 412 mutex_unlock(&dev->struct_mutex);
413 } 413 }
414} 414}
415 415
@@ -431,7 +431,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
431 vma->vm_start, vma->vm_end - vma->vm_start); 431 vma->vm_start, vma->vm_end - vma->vm_start);
432 atomic_dec(&dev->vma_count); 432 atomic_dec(&dev->vma_count);
433 433
434 down(&dev->struct_sem); 434 mutex_lock(&dev->struct_mutex);
435 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { 435 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
436 if (pt->vma == vma) { 436 if (pt->vma == vma) {
437 if (prev) { 437 if (prev) {
@@ -443,7 +443,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
443 break; 443 break;
444 } 444 }
445 } 445 }
446 up(&dev->struct_sem); 446 mutex_unlock(&dev->struct_mutex);
447} 447}
448 448
449/** 449/**
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index cc1b89086876..ae0aa6d7e0bb 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -958,7 +958,7 @@ static int i810_flush_queue(drm_device_t * dev)
958} 958}
959 959
960/* Must be called with the lock held */ 960/* Must be called with the lock held */
961void i810_reclaim_buffers(drm_device_t * dev, struct file *filp) 961static void i810_reclaim_buffers(drm_device_t * dev, struct file *filp)
962{ 962{
963 drm_device_dma_t *dma = dev->dma; 963 drm_device_dma_t *dma = dev->dma;
964 int i; 964 int i;
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index a18b80d91920..e8cf3ff606f0 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -113,8 +113,6 @@ typedef struct drm_i810_private {
113} drm_i810_private_t; 113} drm_i810_private_t;
114 114
115 /* i810_dma.c */ 115 /* i810_dma.c */
116extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp);
117
118extern int i810_driver_dma_quiescent(drm_device_t * dev); 116extern int i810_driver_dma_quiescent(drm_device_t * dev);
119extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev, 117extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
120 struct file *filp); 118 struct file *filp);
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 4fea32aed6d2..163f2cbfe60d 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -1239,7 +1239,7 @@ static int i830_flush_queue(drm_device_t * dev)
1239} 1239}
1240 1240
1241/* Must be called with the lock held */ 1241/* Must be called with the lock held */
1242void i830_reclaim_buffers(drm_device_t * dev, struct file *filp) 1242static void i830_reclaim_buffers(drm_device_t * dev, struct file *filp)
1243{ 1243{
1244 drm_device_dma_t *dma = dev->dma; 1244 drm_device_dma_t *dma = dev->dma;
1245 int i; 1245 int i;
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index bf9075b576bd..85bc5be6f916 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -123,9 +123,6 @@ typedef struct drm_i830_private {
123extern drm_ioctl_desc_t i830_ioctls[]; 123extern drm_ioctl_desc_t i830_ioctls[];
124extern int i830_max_ioctl; 124extern int i830_max_ioctl;
125 125
126/* i830_dma.c */
127extern void i830_reclaim_buffers(drm_device_t * dev, struct file *filp);
128
129/* i830_irq.c */ 126/* i830_irq.c */
130extern int i830_irq_emit(struct inode *inode, struct file *filp, 127extern int i830_irq_emit(struct inode *inode, struct file *filp,
131 unsigned int cmd, unsigned long arg); 128 unsigned int cmd, unsigned long arg);
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index 9140703da1ba..1ff4c7ca0bff 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -344,18 +344,20 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
344 int i; 344 int i;
345 RING_LOCALS; 345 RING_LOCALS;
346 346
347 if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
348 return DRM_ERR(EINVAL);
349
350 BEGIN_LP_RING(((dwords+1)&~1));
351
347 for (i = 0; i < dwords;) { 352 for (i = 0; i < dwords;) {
348 int cmd, sz; 353 int cmd, sz;
349 354
350 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) 355 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd)))
351 return DRM_ERR(EINVAL); 356 return DRM_ERR(EINVAL);
352 357
353/* printk("%d/%d ", i, dwords); */
354
355 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords) 358 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
356 return DRM_ERR(EINVAL); 359 return DRM_ERR(EINVAL);
357 360
358 BEGIN_LP_RING(sz);
359 OUT_RING(cmd); 361 OUT_RING(cmd);
360 362
361 while (++i, --sz) { 363 while (++i, --sz) {
@@ -365,9 +367,13 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
365 } 367 }
366 OUT_RING(cmd); 368 OUT_RING(cmd);
367 } 369 }
368 ADVANCE_LP_RING();
369 } 370 }
370 371
372 if (dwords & 1)
373 OUT_RING(0);
374
375 ADVANCE_LP_RING();
376
371 return 0; 377 return 0;
372} 378}
373 379
@@ -401,6 +407,21 @@ static int i915_emit_box(drm_device_t * dev,
401 return 0; 407 return 0;
402} 408}
403 409
410static void i915_emit_breadcrumb(drm_device_t *dev)
411{
412 drm_i915_private_t *dev_priv = dev->dev_private;
413 RING_LOCALS;
414
415 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
416
417 BEGIN_LP_RING(4);
418 OUT_RING(CMD_STORE_DWORD_IDX);
419 OUT_RING(20);
420 OUT_RING(dev_priv->counter);
421 OUT_RING(0);
422 ADVANCE_LP_RING();
423}
424
404static int i915_dispatch_cmdbuffer(drm_device_t * dev, 425static int i915_dispatch_cmdbuffer(drm_device_t * dev,
405 drm_i915_cmdbuffer_t * cmd) 426 drm_i915_cmdbuffer_t * cmd)
406{ 427{
@@ -429,6 +450,7 @@ static int i915_dispatch_cmdbuffer(drm_device_t * dev,
429 return ret; 450 return ret;
430 } 451 }
431 452
453 i915_emit_breadcrumb(dev);
432 return 0; 454 return 0;
433} 455}
434 456
@@ -475,12 +497,7 @@ static int i915_dispatch_batchbuffer(drm_device_t * dev,
475 497
476 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; 498 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
477 499
478 BEGIN_LP_RING(4); 500 i915_emit_breadcrumb(dev);
479 OUT_RING(CMD_STORE_DWORD_IDX);
480 OUT_RING(20);
481 OUT_RING(dev_priv->counter);
482 OUT_RING(0);
483 ADVANCE_LP_RING();
484 501
485 return 0; 502 return 0;
486} 503}
@@ -657,7 +674,7 @@ static int i915_getparam(DRM_IOCTL_ARGS)
657 value = READ_BREADCRUMB(dev_priv); 674 value = READ_BREADCRUMB(dev_priv);
658 break; 675 break;
659 default: 676 default:
660 DRM_ERROR("Unkown parameter %d\n", param.param); 677 DRM_ERROR("Unknown parameter %d\n", param.param);
661 return DRM_ERR(EINVAL); 678 return DRM_ERR(EINVAL);
662 } 679 }
663 680
@@ -742,7 +759,8 @@ drm_ioctl_desc_t i915_ioctls[] = {
742 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, 759 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
743 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, 760 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
744 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 761 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
745 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH} 762 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
763 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }
746}; 764};
747 765
748int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 766int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h
index 77412ddac007..4cb3da578330 100644
--- a/drivers/char/drm/i915_drm.h
+++ b/drivers/char/drm/i915_drm.h
@@ -74,6 +74,30 @@ typedef struct _drm_i915_sarea {
74 int pf_active; 74 int pf_active;
75 int pf_current_page; /* which buffer is being displayed? */ 75 int pf_current_page; /* which buffer is being displayed? */
76 int perf_boxes; /* performance boxes to be displayed */ 76 int perf_boxes; /* performance boxes to be displayed */
77 int width, height; /* screen size in pixels */
78
79 drm_handle_t front_handle;
80 int front_offset;
81 int front_size;
82
83 drm_handle_t back_handle;
84 int back_offset;
85 int back_size;
86
87 drm_handle_t depth_handle;
88 int depth_offset;
89 int depth_size;
90
91 drm_handle_t tex_handle;
92 int tex_offset;
93 int tex_size;
94 int log_tex_granularity;
95 int pitch;
96 int rotation; /* 0, 90, 180 or 270 */
97 int rotated_offset;
98 int rotated_size;
99 int rotated_pitch;
100 int virtualX, virtualY;
77} drm_i915_sarea_t; 101} drm_i915_sarea_t;
78 102
79/* Flags for perf_boxes 103/* Flags for perf_boxes
@@ -99,6 +123,7 @@ typedef struct _drm_i915_sarea {
99#define DRM_I915_FREE 0x09 123#define DRM_I915_FREE 0x09
100#define DRM_I915_INIT_HEAP 0x0a 124#define DRM_I915_INIT_HEAP 0x0a
101#define DRM_I915_CMDBUFFER 0x0b 125#define DRM_I915_CMDBUFFER 0x0b
126#define DRM_I915_DESTROY_HEAP 0x0c
102 127
103#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 128#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
104#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 129#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -112,6 +137,7 @@ typedef struct _drm_i915_sarea {
112#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t) 137#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
113#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) 138#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
114#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) 139#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
140#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
115 141
116/* Allow drivers to submit batchbuffers directly to hardware, relying 142/* Allow drivers to submit batchbuffers directly to hardware, relying
117 * on the security mechanisms provided by hardware. 143 * on the security mechanisms provided by hardware.
@@ -191,4 +217,11 @@ typedef struct drm_i915_mem_init_heap {
191 int start; 217 int start;
192} drm_i915_mem_init_heap_t; 218} drm_i915_mem_init_heap_t;
193 219
220/* Allow memory manager to be torn down and re-initialized (eg on
221 * rotate):
222 */
223typedef struct drm_i915_mem_destroy_heap {
224 int region;
225} drm_i915_mem_destroy_heap_t;
226
194#endif /* _I915_DRM_H_ */ 227#endif /* _I915_DRM_H_ */
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index c6c71b45f101..7a65666899e4 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -37,16 +37,17 @@
37 37
38#define DRIVER_NAME "i915" 38#define DRIVER_NAME "i915"
39#define DRIVER_DESC "Intel Graphics" 39#define DRIVER_DESC "Intel Graphics"
40#define DRIVER_DATE "20051209" 40#define DRIVER_DATE "20060119"
41 41
42/* Interface history: 42/* Interface history:
43 * 43 *
44 * 1.1: Original. 44 * 1.1: Original.
45 * 1.2: Add Power Management 45 * 1.2: Add Power Management
46 * 1.3: Add vblank support 46 * 1.3: Add vblank support
47 * 1.4: Fix cmdbuffer path, add heap destroy
47 */ 48 */
48#define DRIVER_MAJOR 1 49#define DRIVER_MAJOR 1
49#define DRIVER_MINOR 3 50#define DRIVER_MINOR 4
50#define DRIVER_PATCHLEVEL 0 51#define DRIVER_PATCHLEVEL 0
51 52
52typedef struct _drm_i915_ring_buffer { 53typedef struct _drm_i915_ring_buffer {
@@ -123,6 +124,7 @@ extern void i915_driver_irq_uninstall(drm_device_t * dev);
123extern int i915_mem_alloc(DRM_IOCTL_ARGS); 124extern int i915_mem_alloc(DRM_IOCTL_ARGS);
124extern int i915_mem_free(DRM_IOCTL_ARGS); 125extern int i915_mem_free(DRM_IOCTL_ARGS);
125extern int i915_mem_init_heap(DRM_IOCTL_ARGS); 126extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
127extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
126extern void i915_mem_takedown(struct mem_block **heap); 128extern void i915_mem_takedown(struct mem_block **heap);
127extern void i915_mem_release(drm_device_t * dev, 129extern void i915_mem_release(drm_device_t * dev,
128 DRMFILE filp, struct mem_block *heap); 130 DRMFILE filp, struct mem_block *heap);
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c
index ba87ff17ff64..52c67324df58 100644
--- a/drivers/char/drm/i915_mem.c
+++ b/drivers/char/drm/i915_mem.c
@@ -365,3 +365,34 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS)
365 365
366 return init_heap(heap, initheap.start, initheap.size); 366 return init_heap(heap, initheap.start, initheap.size);
367} 367}
368
369int i915_mem_destroy_heap( DRM_IOCTL_ARGS )
370{
371 DRM_DEVICE;
372 drm_i915_private_t *dev_priv = dev->dev_private;
373 drm_i915_mem_destroy_heap_t destroyheap;
374 struct mem_block **heap;
375
376 if ( !dev_priv ) {
377 DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
378 return DRM_ERR(EINVAL);
379 }
380
381 DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data,
382 sizeof(destroyheap) );
383
384 heap = get_heap( dev_priv, destroyheap.region );
385 if (!heap) {
386 DRM_ERROR("get_heap failed");
387 return DRM_ERR(EFAULT);
388 }
389
390 if (!*heap) {
391 DRM_ERROR("heap not initialized?");
392 return DRM_ERR(EFAULT);
393 }
394
395 i915_mem_takedown( heap );
396 return 0;
397}
398
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 915665c7fe7c..9bb8ae0c1c27 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1640,7 +1640,7 @@ static int radeon_do_cleanup_cp(drm_device_t * dev)
1640 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) 1640 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB)
1641 { 1641 {
1642 drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); 1642 drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev);
1643 dev_priv->gart_info.addr = 0; 1643 dev_priv->gart_info.addr = NULL;
1644 } 1644 }
1645 } 1645 }
1646 /* only clear to the start of flags */ 1646 /* only clear to the start of flags */
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 0d426deeefec..59c7520bf9a2 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -32,6 +32,8 @@
32#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */ 32#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */
33#define SAVAGE_FREELIST_DEBUG 0 33#define SAVAGE_FREELIST_DEBUG 0
34 34
35static int savage_do_cleanup_bci(drm_device_t *dev);
36
35static int 37static int
36savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n) 38savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n)
37{ 39{
@@ -895,7 +897,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init)
895 return 0; 897 return 0;
896} 898}
897 899
898int savage_do_cleanup_bci(drm_device_t * dev) 900static int savage_do_cleanup_bci(drm_device_t * dev)
899{ 901{
900 drm_savage_private_t *dev_priv = dev->dev_private; 902 drm_savage_private_t *dev_priv = dev->dev_private;
901 903
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h
index dd46cb85439c..8f04b3d82292 100644
--- a/drivers/char/drm/savage_drv.h
+++ b/drivers/char/drm/savage_drv.h
@@ -212,7 +212,6 @@ extern int savage_driver_load(drm_device_t *dev, unsigned long chipset);
212extern int savage_driver_firstopen(drm_device_t *dev); 212extern int savage_driver_firstopen(drm_device_t *dev);
213extern void savage_driver_lastclose(drm_device_t *dev); 213extern void savage_driver_lastclose(drm_device_t *dev);
214extern int savage_driver_unload(drm_device_t *dev); 214extern int savage_driver_unload(drm_device_t *dev);
215extern int savage_do_cleanup_bci(drm_device_t * dev);
216extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp); 215extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp);
217 216
218/* state functions */ 217/* state functions */
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 593c0b8f650a..a691ae74129d 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -222,7 +222,7 @@ static int via_initialize(drm_device_t * dev,
222 return 0; 222 return 0;
223} 223}
224 224
225int via_dma_init(DRM_IOCTL_ARGS) 225static int via_dma_init(DRM_IOCTL_ARGS)
226{ 226{
227 DRM_DEVICE; 227 DRM_DEVICE;
228 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 228 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
@@ -321,7 +321,7 @@ int via_driver_dma_quiescent(drm_device_t * dev)
321 return 0; 321 return 0;
322} 322}
323 323
324int via_flush_ioctl(DRM_IOCTL_ARGS) 324static int via_flush_ioctl(DRM_IOCTL_ARGS)
325{ 325{
326 DRM_DEVICE; 326 DRM_DEVICE;
327 327
@@ -330,7 +330,7 @@ int via_flush_ioctl(DRM_IOCTL_ARGS)
330 return via_driver_dma_quiescent(dev); 330 return via_driver_dma_quiescent(dev);
331} 331}
332 332
333int via_cmdbuffer(DRM_IOCTL_ARGS) 333static int via_cmdbuffer(DRM_IOCTL_ARGS)
334{ 334{
335 DRM_DEVICE; 335 DRM_DEVICE;
336 drm_via_cmdbuffer_t cmdbuf; 336 drm_via_cmdbuffer_t cmdbuf;
@@ -375,7 +375,7 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t * dev,
375 return ret; 375 return ret;
376} 376}
377 377
378int via_pci_cmdbuffer(DRM_IOCTL_ARGS) 378static int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
379{ 379{
380 DRM_DEVICE; 380 DRM_DEVICE;
381 drm_via_cmdbuffer_t cmdbuf; 381 drm_via_cmdbuffer_t cmdbuf;
@@ -665,7 +665,7 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv)
665 * User interface to the space and lag functions. 665 * User interface to the space and lag functions.
666 */ 666 */
667 667
668int via_cmdbuf_size(DRM_IOCTL_ARGS) 668static int via_cmdbuf_size(DRM_IOCTL_ARGS)
669{ 669{
670 DRM_DEVICE; 670 DRM_DEVICE;
671 drm_via_cmdbuf_size_t d_siz; 671 drm_via_cmdbuf_size_t d_siz;
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 9d5e027dae0e..b7f17457b424 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -108,7 +108,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
108 int num_desc = 0; 108 int num_desc = 0;
109 int cur_line; 109 int cur_line;
110 dma_addr_t next = 0 | VIA_DMA_DPR_EC; 110 dma_addr_t next = 0 | VIA_DMA_DPR_EC;
111 drm_via_descriptor_t *desc_ptr = 0; 111 drm_via_descriptor_t *desc_ptr = NULL;
112 112
113 if (mode == 1) 113 if (mode == 1)
114 desc_ptr = vsg->desc_pages[cur_descriptor_page]; 114 desc_ptr = vsg->desc_pages[cur_descriptor_page];
@@ -167,7 +167,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
167 */ 167 */
168 168
169 169
170void 170static void
171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) 171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
172{ 172{
173 struct page *page; 173 struct page *page;
@@ -581,7 +581,7 @@ via_build_sg_info(drm_device_t *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *
581 int ret = 0; 581 int ret = 0;
582 582
583 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 583 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
584 vsg->bounce_buffer = 0; 584 vsg->bounce_buffer = NULL;
585 585
586 vsg->state = dr_via_sg_init; 586 vsg->state = dr_via_sg_init;
587 587
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h
index aad4f99f5405..52bcc7b1ba45 100644
--- a/drivers/char/drm/via_drv.h
+++ b/drivers/char/drm/via_drv.h
@@ -110,11 +110,6 @@ extern int via_mem_free(DRM_IOCTL_ARGS);
110extern int via_agp_init(DRM_IOCTL_ARGS); 110extern int via_agp_init(DRM_IOCTL_ARGS);
111extern int via_map_init(DRM_IOCTL_ARGS); 111extern int via_map_init(DRM_IOCTL_ARGS);
112extern int via_decoder_futex(DRM_IOCTL_ARGS); 112extern int via_decoder_futex(DRM_IOCTL_ARGS);
113extern int via_dma_init(DRM_IOCTL_ARGS);
114extern int via_cmdbuffer(DRM_IOCTL_ARGS);
115extern int via_flush_ioctl(DRM_IOCTL_ARGS);
116extern int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
117extern int via_cmdbuf_size(DRM_IOCTL_ARGS);
118extern int via_wait_irq(DRM_IOCTL_ARGS); 113extern int via_wait_irq(DRM_IOCTL_ARGS);
119extern int via_dma_blit_sync( DRM_IOCTL_ARGS ); 114extern int via_dma_blit_sync( DRM_IOCTL_ARGS );
120extern int via_dma_blit( DRM_IOCTL_ARGS ); 115extern int via_dma_blit( DRM_IOCTL_ARGS );
@@ -139,8 +134,6 @@ extern int via_driver_dma_quiescent(drm_device_t * dev);
139extern void via_init_futex(drm_via_private_t * dev_priv); 134extern void via_init_futex(drm_via_private_t * dev_priv);
140extern void via_cleanup_futex(drm_via_private_t * dev_priv); 135extern void via_cleanup_futex(drm_via_private_t * dev_priv);
141extern void via_release_futex(drm_via_private_t * dev_priv, int context); 136extern void via_release_futex(drm_via_private_t * dev_priv, int context);
142extern int via_driver_irq_wait(drm_device_t * dev, unsigned int irq,
143 int force_sequence, unsigned int *sequence);
144 137
145extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq); 138extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq);
146extern void via_init_dmablit(drm_device_t *dev); 139extern void via_init_dmablit(drm_device_t *dev);
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
index 56d7e3daea12..6152415644e9 100644
--- a/drivers/char/drm/via_irq.c
+++ b/drivers/char/drm/via_irq.c
@@ -190,7 +190,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
190 return ret; 190 return ret;
191} 191}
192 192
193int 193static int
194via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, 194via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
195 unsigned int *sequence) 195 unsigned int *sequence)
196{ 196{
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 3f3ac039f4d9..57539d8f9f7c 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -359,7 +359,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
359 } 359 }
360 } 360 }
361 361
362 schedule_delayed_work(&tty->buf.work, 1); 362 tty_schedule_flip(tty);
363 363
364 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; 364 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT;
365 release_pio_buffer(pio_buf); 365 release_pio_buffer(pio_buf);
@@ -426,7 +426,7 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
426 } 426 }
427 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); 427 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag);
428 } 428 }
429 schedule_delayed_work(&tty->buf.work, 1); 429 tty_schedule_flip(tty);
430 } 430 }
431 431
432 if (dma_bytes != num_bytes) { 432 if (dma_bytes != num_bytes) {
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index 40a67c86420c..ac626418b329 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -117,12 +117,9 @@ __setup("hcheck_reboot", hangcheck_parse_reboot);
117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); 117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118#endif /* not MODULE */ 118#endif /* not MODULE */
119 119
120#if defined(CONFIG_X86) 120#if defined(CONFIG_X86) || defined(CONFIG_S390)
121# define HAVE_MONOTONIC 121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL 122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_S390)
124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */
125# define TIMER_FREQ 0xFA240000ULL
126#elif defined(CONFIG_IA64) 123#elif defined(CONFIG_IA64)
127# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq) 124# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq)
128#elif defined(CONFIG_PPC64) 125#elif defined(CONFIG_PPC64)
@@ -134,12 +131,7 @@ extern unsigned long long monotonic_clock(void);
134#else 131#else
135static inline unsigned long long monotonic_clock(void) 132static inline unsigned long long monotonic_clock(void)
136{ 133{
137# ifdef __s390__
138 /* returns the TOD. see 4-38 Principles of Op of zSeries */
139 return get_clock();
140# else
141 return get_cycles(); 134 return get_cycles();
142# endif /* __s390__ */
143} 135}
144#endif /* HAVE_MONOTONIC */ 136#endif /* HAVE_MONOTONIC */
145 137
@@ -188,8 +180,6 @@ static int __init hangcheck_init(void)
188 VERSION_STR, hangcheck_tick, hangcheck_margin); 180 VERSION_STR, hangcheck_tick, hangcheck_margin);
189#if defined (HAVE_MONOTONIC) 181#if defined (HAVE_MONOTONIC)
190 printk("Hangcheck: Using monotonic_clock().\n"); 182 printk("Hangcheck: Using monotonic_clock().\n");
191#elif defined(__s390__)
192 printk("Hangcheck: Using TOD.\n");
193#else 183#else
194 printk("Hangcheck: Using get_cycles().\n"); 184 printk("Hangcheck: Using get_cycles().\n");
195#endif /* HAVE_MONOTONIC */ 185#endif /* HAVE_MONOTONIC */
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 3808d9572619..66a2fee06eb9 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -927,9 +927,9 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
927 if (ACPI_SUCCESS(status)) { 927 if (ACPI_SUCCESS(status)) {
928 unsigned long size; 928 unsigned long size;
929 929
930 size = addr.max_address_range - addr.min_address_range + 1; 930 size = addr.maximum - addr.minimum + 1;
931 hdp->hd_phys_address = addr.min_address_range; 931 hdp->hd_phys_address = addr.minimum;
932 hdp->hd_address = ioremap(addr.min_address_range, size); 932 hdp->hd_address = ioremap(addr.minimum, size);
933 933
934 if (hpet_is_known(hdp)) { 934 if (hpet_is_known(hdp)) {
935 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 935 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
@@ -937,15 +937,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
937 iounmap(hdp->hd_address); 937 iounmap(hdp->hd_address);
938 return -EBUSY; 938 return -EBUSY;
939 } 939 }
940 } else if (res->id == ACPI_RSTYPE_FIXED_MEM32) { 940 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) {
941 struct acpi_resource_fixed_mem32 *fixmem32; 941 struct acpi_resource_fixed_memory32 *fixmem32;
942 942
943 fixmem32 = &res->data.fixed_memory32; 943 fixmem32 = &res->data.fixed_memory32;
944 if (!fixmem32) 944 if (!fixmem32)
945 return -EINVAL; 945 return -EINVAL;
946 946
947 hdp->hd_phys_address = fixmem32->range_base_address; 947 hdp->hd_phys_address = fixmem32->address;
948 hdp->hd_address = ioremap(fixmem32->range_base_address, 948 hdp->hd_address = ioremap(fixmem32->address,
949 HPET_RANGE_SIZE); 949 HPET_RANGE_SIZE);
950 950
951 if (hpet_is_known(hdp)) { 951 if (hpet_is_known(hdp)) {
@@ -954,20 +954,20 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
954 iounmap(hdp->hd_address); 954 iounmap(hdp->hd_address);
955 return -EBUSY; 955 return -EBUSY;
956 } 956 }
957 } else if (res->id == ACPI_RSTYPE_EXT_IRQ) { 957 } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
958 struct acpi_resource_ext_irq *irqp; 958 struct acpi_resource_extended_irq *irqp;
959 int i; 959 int i;
960 960
961 irqp = &res->data.extended_irq; 961 irqp = &res->data.extended_irq;
962 962
963 if (irqp->number_of_interrupts > 0) { 963 if (irqp->interrupt_count > 0) {
964 hdp->hd_nirqs = irqp->number_of_interrupts; 964 hdp->hd_nirqs = irqp->interrupt_count;
965 965
966 for (i = 0; i < hdp->hd_nirqs; i++) { 966 for (i = 0; i < hdp->hd_nirqs; i++) {
967 int rc = 967 int rc =
968 acpi_register_gsi(irqp->interrupts[i], 968 acpi_register_gsi(irqp->interrupts[i],
969 irqp->edge_level, 969 irqp->triggering,
970 irqp->active_high_low); 970 irqp->polarity);
971 if (rc < 0) 971 if (rc < 0)
972 return AE_ERROR; 972 return AE_ERROR;
973 hdp->hd_irq[i] = rc; 973 hdp->hd_irq[i] = rc;
diff --git a/drivers/char/ip2/i2cmd.c b/drivers/char/ip2/i2cmd.c
index cb8f4198e9a3..e7af647800b6 100644
--- a/drivers/char/ip2/i2cmd.c
+++ b/drivers/char/ip2/i2cmd.c
@@ -139,7 +139,6 @@ static UCHAR ct79[] = { 2, BYP, 0x4F,0 }; // XMIT_NOW
139//static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE 139//static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE
140static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST 140static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST
141//static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD 141//static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD
142static UCHAR ct89[]={ 1, BYP, 0x59 }; // DSS_NOW
143//static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO 142//static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO
144//static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break 143//static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break
145 144
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c
index 56e93a5a1e24..48fcfba37bfa 100644
--- a/drivers/char/ip2main.c
+++ b/drivers/char/ip2main.c
@@ -2906,65 +2906,16 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
2906 rc = -EINVAL; 2906 rc = -EINVAL;
2907 break; 2907 break;
2908 case 3: // Trace device 2908 case 3: // Trace device
2909 if ( cmd == 1 ) { 2909 /*
2910 rc = put_user(iiSendPendingMail, pIndex++ ); 2910 * akpm: This used to write a whole bunch of function addresses
2911 rc = put_user(i2InitChannels, pIndex++ ); 2911 * to userspace, which generated lots of put_user() warnings.
2912 rc = put_user(i2QueueNeeds, pIndex++ ); 2912 * I killed it all. Just return "success" and don't do
2913 rc = put_user(i2QueueCommands, pIndex++ ); 2913 * anything.
2914 rc = put_user(i2GetStatus, pIndex++ ); 2914 */
2915 rc = put_user(i2Input, pIndex++ ); 2915 if (cmd == 1)
2916 rc = put_user(i2InputFlush, pIndex++ ); 2916 rc = 0;
2917 rc = put_user(i2Output, pIndex++ ); 2917 else
2918 rc = put_user(i2FlushOutput, pIndex++ );
2919 rc = put_user(i2DrainWakeup, pIndex++ );
2920 rc = put_user(i2DrainOutput, pIndex++ );
2921 rc = put_user(i2OutputFree, pIndex++ );
2922 rc = put_user(i2StripFifo, pIndex++ );
2923 rc = put_user(i2StuffFifoBypass, pIndex++ );
2924 rc = put_user(i2StuffFifoFlow, pIndex++ );
2925 rc = put_user(i2StuffFifoInline, pIndex++ );
2926 rc = put_user(i2ServiceBoard, pIndex++ );
2927 rc = put_user(serviceOutgoingFifo, pIndex++ );
2928 // rc = put_user(ip2_init, pIndex++ );
2929 rc = put_user(ip2_init_board, pIndex++ );
2930 rc = put_user(find_eisa_board, pIndex++ );
2931 rc = put_user(set_irq, pIndex++ );
2932 rc = put_user(ip2_interrupt, pIndex++ );
2933 rc = put_user(ip2_poll, pIndex++ );
2934 rc = put_user(service_all_boards, pIndex++ );
2935 rc = put_user(do_input, pIndex++ );
2936 rc = put_user(do_status, pIndex++ );
2937#ifndef IP2DEBUG_OPEN
2938 rc = put_user(0, pIndex++ );
2939#else
2940 rc = put_user(open_sanity_check, pIndex++ );
2941#endif
2942 rc = put_user(ip2_open, pIndex++ );
2943 rc = put_user(ip2_close, pIndex++ );
2944 rc = put_user(ip2_hangup, pIndex++ );
2945 rc = put_user(ip2_write, pIndex++ );
2946 rc = put_user(ip2_putchar, pIndex++ );
2947 rc = put_user(ip2_flush_chars, pIndex++ );
2948 rc = put_user(ip2_write_room, pIndex++ );
2949 rc = put_user(ip2_chars_in_buf, pIndex++ );
2950 rc = put_user(ip2_flush_buffer, pIndex++ );
2951
2952 //rc = put_user(ip2_wait_until_sent, pIndex++ );
2953 rc = put_user(0, pIndex++ );
2954
2955 rc = put_user(ip2_throttle, pIndex++ );
2956 rc = put_user(ip2_unthrottle, pIndex++ );
2957 rc = put_user(ip2_ioctl, pIndex++ );
2958 rc = put_user(0, pIndex++ );
2959 rc = put_user(get_serial_info, pIndex++ );
2960 rc = put_user(set_serial_info, pIndex++ );
2961 rc = put_user(ip2_set_termios, pIndex++ );
2962 rc = put_user(ip2_set_line_discipline, pIndex++ );
2963 rc = put_user(set_params, pIndex++ );
2964 } else {
2965 rc = -EINVAL; 2918 rc = -EINVAL;
2966 }
2967
2968 break; 2919 break;
2969 2920
2970 default: 2921 default:
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 0097f06fa67b..d745004281d0 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -481,7 +481,7 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len)
481 } 481 }
482 482
483 if ((addr->channel == IPMI_BMC_CHANNEL) 483 if ((addr->channel == IPMI_BMC_CHANNEL)
484 || (addr->channel >= IPMI_NUM_CHANNELS) 484 || (addr->channel >= IPMI_MAX_CHANNELS)
485 || (addr->channel < 0)) 485 || (addr->channel < 0))
486 return -EINVAL; 486 return -EINVAL;
487 487
@@ -1321,7 +1321,7 @@ static int i_ipmi_request(ipmi_user_t user,
1321 unsigned char ipmb_seq; 1321 unsigned char ipmb_seq;
1322 long seqid; 1322 long seqid;
1323 1323
1324 if (addr->channel >= IPMI_NUM_CHANNELS) { 1324 if (addr->channel >= IPMI_MAX_CHANNELS) {
1325 spin_lock_irqsave(&intf->counter_lock, flags); 1325 spin_lock_irqsave(&intf->counter_lock, flags);
1326 intf->sent_invalid_commands++; 1326 intf->sent_invalid_commands++;
1327 spin_unlock_irqrestore(&intf->counter_lock, flags); 1327 spin_unlock_irqrestore(&intf->counter_lock, flags);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index c67ef3e47ad5..e59b638766ef 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1270,36 +1270,36 @@ static int try_init_port(int intf_num, struct smi_info **new_info)
1270 return 0; 1270 return 0;
1271} 1271}
1272 1272
1273static unsigned char mem_inb(struct si_sm_io *io, unsigned int offset) 1273static unsigned char intf_mem_inb(struct si_sm_io *io, unsigned int offset)
1274{ 1274{
1275 return readb((io->addr)+(offset * io->regspacing)); 1275 return readb((io->addr)+(offset * io->regspacing));
1276} 1276}
1277 1277
1278static void mem_outb(struct si_sm_io *io, unsigned int offset, 1278static void intf_mem_outb(struct si_sm_io *io, unsigned int offset,
1279 unsigned char b) 1279 unsigned char b)
1280{ 1280{
1281 writeb(b, (io->addr)+(offset * io->regspacing)); 1281 writeb(b, (io->addr)+(offset * io->regspacing));
1282} 1282}
1283 1283
1284static unsigned char mem_inw(struct si_sm_io *io, unsigned int offset) 1284static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset)
1285{ 1285{
1286 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift) 1286 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
1287 && 0xff; 1287 && 0xff;
1288} 1288}
1289 1289
1290static void mem_outw(struct si_sm_io *io, unsigned int offset, 1290static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
1291 unsigned char b) 1291 unsigned char b)
1292{ 1292{
1293 writeb(b << io->regshift, (io->addr)+(offset * io->regspacing)); 1293 writeb(b << io->regshift, (io->addr)+(offset * io->regspacing));
1294} 1294}
1295 1295
1296static unsigned char mem_inl(struct si_sm_io *io, unsigned int offset) 1296static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset)
1297{ 1297{
1298 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift) 1298 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
1299 && 0xff; 1299 && 0xff;
1300} 1300}
1301 1301
1302static void mem_outl(struct si_sm_io *io, unsigned int offset, 1302static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
1303 unsigned char b) 1303 unsigned char b)
1304{ 1304{
1305 writel(b << io->regshift, (io->addr)+(offset * io->regspacing)); 1305 writel(b << io->regshift, (io->addr)+(offset * io->regspacing));
@@ -1349,16 +1349,16 @@ static int mem_setup(struct smi_info *info)
1349 upon the register size. */ 1349 upon the register size. */
1350 switch (info->io.regsize) { 1350 switch (info->io.regsize) {
1351 case 1: 1351 case 1:
1352 info->io.inputb = mem_inb; 1352 info->io.inputb = intf_mem_inb;
1353 info->io.outputb = mem_outb; 1353 info->io.outputb = intf_mem_outb;
1354 break; 1354 break;
1355 case 2: 1355 case 2:
1356 info->io.inputb = mem_inw; 1356 info->io.inputb = intf_mem_inw;
1357 info->io.outputb = mem_outw; 1357 info->io.outputb = intf_mem_outw;
1358 break; 1358 break;
1359 case 4: 1359 case 4:
1360 info->io.inputb = mem_inl; 1360 info->io.inputb = intf_mem_inl;
1361 info->io.outputb = mem_outl; 1361 info->io.outputb = intf_mem_outl;
1362 break; 1362 break;
1363#ifdef readq 1363#ifdef readq
1364 case 8: 1364 case 8:
@@ -1580,11 +1580,6 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1580 if (! is_new_interface(-1, addr_space, spmi->addr.address)) 1580 if (! is_new_interface(-1, addr_space, spmi->addr.address))
1581 return -ENODEV; 1581 return -ENODEV;
1582 1582
1583 if (! spmi->addr.register_bit_width) {
1584 acpi_failure = 1;
1585 return -ENODEV;
1586 }
1587
1588 /* Figure out the interface type. */ 1583 /* Figure out the interface type. */
1589 switch (spmi->InterfaceType) 1584 switch (spmi->InterfaceType)
1590 { 1585 {
@@ -1634,9 +1629,6 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1634 regspacings[intf_num] = spmi->addr.register_bit_width / 8; 1629 regspacings[intf_num] = spmi->addr.register_bit_width / 8;
1635 info->io.regspacing = spmi->addr.register_bit_width / 8; 1630 info->io.regspacing = spmi->addr.register_bit_width / 8;
1636 } else { 1631 } else {
1637 /* Some broken systems get this wrong and set the value
1638 * to zero. Assume it is the default spacing. If that
1639 * is wrong, too bad, the vendor should fix the tables. */
1640 regspacings[intf_num] = DEFAULT_REGSPACING; 1632 regspacings[intf_num] = DEFAULT_REGSPACING;
1641 info->io.regspacing = DEFAULT_REGSPACING; 1633 info->io.regspacing = DEFAULT_REGSPACING;
1642 } 1634 }
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 217ff09f2fa1..89bd94eb45be 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,148 +40,6 @@
40#endif 40#endif
41#define _cirrus_h 1 41#define _cirrus_h 1
42 42
43#ifdef RTA
44#define TO_UART RX
45#define TO_DRIVER TX
46#endif
47
48#ifdef HOST
49#define TO_UART TX
50#define TO_DRIVER RX
51#endif
52#ifdef RTA
53/* Miscellaneous defines for CIRRUS addresses and related logic for
54 interrupts etc.
55*/
56#define MAP(a) ((short *)(cirrus_base + (a)))
57#define outp(a,b) (*MAP (a) =(b))
58#define inp(a) ((*MAP (a)) & 0xff)
59#define CIRRUS_FIRST (short*)0x7300
60#define CIRRUS_SECOND (short*)0x7200
61#define CIRRUS_THIRD (short*)0x7100
62#define CIRRUS_FOURTH (short*)0x7000
63#define PORTS_ON_CIRRUS 4
64#define CIRRUS_FIFO_SIZE 12
65#define SPACE 0x20
66#define TAB 0x09
67#define LINE_FEED 0x0a
68#define CARRIAGE_RETURN 0x0d
69#define BACKSPACE 0x08
70#define SPACES_IN_TABS 8
71#define SEND_ESCAPE 0x00
72#define START_BREAK 0x81
73#define TIMER_TICK 0x82
74#define STOP_BREAK 0x83
75#define BASE(a) ((a) < 4 ? (short*)CIRRUS_FIRST : ((a) < 8 ? (short *)CIRRUS_SECOND : ((a) < 12 ? (short*)CIRRUS_THIRD : (short *)CIRRUS_FOURTH)))
76#define txack1 ((short *)0x7104)
77#define rxack1 ((short *)0x7102)
78#define mdack1 ((short *)0x7106)
79#define txack2 ((short *)0x7006)
80#define rxack2 ((short *)0x7004)
81#define mdack2 ((short *)0x7100)
82#define int_latch ((short *) 0x7800)
83#define int_status ((short *) 0x7c00)
84#define tx1_pending 0x20
85#define rx1_pending 0x10
86#define md1_pending 0x40
87#define tx2_pending 0x02
88#define rx2_pending 0x01
89#define md2_pending 0x40
90#define module1_bits 0x07
91#define module1_modern 0x08
92#define module2_bits 0x70
93#define module2_modern 0x80
94#define module_blank 0xf
95#define rs232_d25 0x0
96#define rs232_rj45 0x1
97#define rs422_d25 0x3
98#define parallel 0x5
99
100#define CLK0 0x00
101#define CLK1 0x01
102#define CLK2 0x02
103#define CLK3 0x03
104#define CLK4 0x04
105
106#define CIRRUS_REVC 0x42
107#define CIRRUS_REVE 0x44
108
109#define TURNON 1
110#define TURNOFF 0
111
112/* The list of CIRRUS registers.
113 NB. These registers are relative values on 8 bit boundaries whereas
114 on the RTA's the CIRRUS registers are on word boundaries. Use pointer
115 arithmetic (short *) to obtain the real addresses required */
116#define ccr 0x05 /* Channel Command Register */
117#define ier 0x06 /* Interrupt Enable Register */
118#define cor1 0x08 /* Channel Option Register 1 */
119#define cor2 0x09 /* Channel Option Register 2 */
120#define cor3 0x0a /* Channel Option Register 3 */
121#define cor4 0x1e /* Channel Option Register 4 */
122#define cor5 0x1f /* Channel Option Register 5 */
123
124#define ccsr 0x0b /* Channel Control Status Register */
125#define rdcr 0x0e /* Receive Data Count Register */
126#define tdcr 0x12 /* Transmit Data Count Register */
127#define mcor1 0x15 /* Modem Change Option Register 1 */
128#define mcor2 0x16 /* Modem Change Option Regsiter 2 */
129
130#define livr 0x18 /* Local Interrupt Vector Register */
131#define schr1 0x1a /* Special Character Register 1 */
132#define schr2 0x1b /* Special Character Register 2 */
133#define schr3 0x1c /* Special Character Register 3 */
134#define schr4 0x1d /* Special Character Register 4 */
135
136#define rtr 0x20 /* Receive Timer Register */
137#define rtpr 0x21 /* Receive Timeout Period Register */
138#define lnc 0x24 /* Lnext character */
139
140#define rivr 0x43 /* Receive Interrupt Vector Register */
141#define tivr 0x42 /* Transmit Interrupt Vector Register */
142#define mivr 0x41 /* Modem Interrupt Vector Register */
143#define gfrcr 0x40 /* Global Firmware Revision code Reg */
144#define ricr 0x44 /* Receive Interrupting Channel Reg */
145#define ticr 0x45 /* Transmit Interrupting Channel Reg */
146#define micr 0x46 /* Modem Interrupting Channel Register */
147
148#define gcr 0x4b /* Global configuration register */
149#define misr 0x4c /* Modem interrupt status register */
150
151#define rbusr 0x59
152#define tbusr 0x5a
153#define mbusr 0x5b
154
155#define eoir 0x60 /* End Of Interrupt Register */
156#define rdsr 0x62 /* Receive Data / Status Register */
157#define tdr 0x63 /* Transmit Data Register */
158#define svrr 0x67 /* Service Request Register */
159
160#define car 0x68 /* Channel Access Register */
161#define mir 0x69 /* Modem Interrupt Register */
162#define tir 0x6a /* Transmit Interrupt Register */
163#define rir 0x6b /* Receive Interrupt Register */
164#define msvr1 0x6c /* Modem Signal Value Register 1 */
165#define msvr2 0x6d /* Modem Signal Value Register 2 */
166#define psvr 0x6f /* Printer Signal Value Register */
167
168#define tbpr 0x72 /* Transmit Baud Rate Period Register */
169#define tcor 0x76 /* Transmit Clock Option Register */
170
171#define rbpr 0x78 /* Receive Baud Rate Period Register */
172#define rber 0x7a /* Receive Baud Rate Extension Register */
173#define rcor 0x7c /* Receive Clock Option Register */
174#define ppr 0x7e /* Prescalar Period Register */
175
176/* Misc registers used for forcing the 1400 out of its reset woes */
177#define airl 0x6d
178#define airm 0x6e
179#define airh 0x6f
180#define btcr 0x66
181#define mtcr 0x6c
182#define tber 0x74
183
184#endif /* #ifdef RTA */
185 43
186 44
187/* Bit fields for particular registers */ 45/* Bit fields for particular registers */
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
index 5b600c32ac02..d55c2f6a9877 100644
--- a/drivers/char/rio/defaults.h
+++ b/drivers/char/rio/defaults.h
@@ -45,13 +45,6 @@ static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */ 45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
46#define SECOND (int) 15625 /* Low priority ticks */ 46#define SECOND (int) 15625 /* Low priority ticks */
47 47
48#ifdef RTA
49#define RX_LIMIT (ushort) 3
50#endif
51#ifdef HOST
52#define RX_LIMIT (ushort) 1
53#endif
54
55#define LINK_TIMEOUT (int) (POLL_PERIOD / 2) 48#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
56 49
57 50
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index bfba5b0c033e..48d68ca7f825 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -102,30 +102,14 @@
102/* 102/*
103** LED stuff 103** LED stuff
104*/ 104*/
105#if defined(RTA)
106#define LED_OFF ((ushort) 0) /* LED off */
107#define LED_RED ((ushort) 1) /* LED Red */
108#define LED_GREEN ((ushort) 2) /* LED Green */
109#define LED_ORANGE ((ushort) 4) /* LED Orange */
110#define LED_1TO8_OPEN ((ushort) 1) /* Port 1->8 LED on */
111#define LED_9TO16_OPEN ((ushort) 2) /* Port 9->16 LED on */
112#define LED_SET_COLOUR(colour) (link->led = (colour))
113#define LED_OR_COLOUR(colour) (link->led |= (colour))
114#define LED_TIMEOUT(time) (link->led_timeout = RioTimePlus(RioTime(),(time)))
115#else
116#define LED_SET_COLOUR(colour) 105#define LED_SET_COLOUR(colour)
117#define LED_OR_COLOUR(colour) 106#define LED_OR_COLOUR(colour)
118#define LED_TIMEOUT(time) 107#define LED_TIMEOUT(time)
119#endif /* RTA */
120 108
121struct LPB { 109struct LPB {
122 WORD link_number; /* Link Number */ 110 WORD link_number; /* Link Number */
123 Channel_ptr in_ch; /* Link In Channel */ 111 Channel_ptr in_ch; /* Link In Channel */
124 Channel_ptr out_ch; /* Link Out Channel */ 112 Channel_ptr out_ch; /* Link Out Channel */
125#ifdef RTA
126 uchar stat_led; /* Port open leds */
127 uchar led; /* True, light led! */
128#endif
129 BYTE attached_serial[4]; /* Attached serial number */ 113 BYTE attached_serial[4]; /* Attached serial number */
130 BYTE attached_host_serial[4]; 114 BYTE attached_host_serial[4];
131 /* Serial number of Host who 115 /* Serial number of Host who
@@ -144,30 +128,12 @@ struct LPB {
144 WORD WaitNoBoot; /* Secs to hold off booting */ 128 WORD WaitNoBoot; /* Secs to hold off booting */
145 PKT_ptr add_packet_list; /* Add packets to here */ 129 PKT_ptr add_packet_list; /* Add packets to here */
146 PKT_ptr remove_packet_list; /* Send packets from here */ 130 PKT_ptr remove_packet_list; /* Send packets from here */
147#ifdef RTA
148#ifdef DCIRRUS
149#define QBUFS_PER_REDIRECT (4 / PKTS_PER_BUFFER + 1)
150#else
151#define QBUFS_PER_REDIRECT (8 / PKTS_PER_BUFFER + 1)
152#endif
153 PKT_ptr_ptr rd_add; /* Add a new Packet here */
154 Q_BUF_ptr rd_add_qb; /* Pointer to the add Q buf */
155 PKT_ptr_ptr rd_add_st_qbb; /* Pointer to start of the Q's buf */
156 PKT_ptr_ptr rd_add_end_qbb; /* Pointer to the end of the Q's buf */
157 PKT_ptr_ptr rd_remove; /* Remove a Packet here */
158 Q_BUF_ptr rd_remove_qb; /* Pointer to the remove Q buf */
159 PKT_ptr_ptr rd_remove_st_qbb; /* Pointer to the start of the Q buf */
160 PKT_ptr_ptr rd_remove_end_qbb; /* Pointer to the end of the Q buf */
161 ushort pkts_in_q; /* Packets in queue */
162#endif
163 131
164 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */ 132 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */
165 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */ 133 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */
166 134
167#if defined (HOST) || defined (INKERNEL)
168 /* RUP structure for HOST to driver communications */ 135 /* RUP structure for HOST to driver communications */
169 struct RUP rup; 136 struct RUP rup;
170#endif
171 struct RUP link_rup; /* RUP for the link (POLL, 137 struct RUP link_rup; /* RUP for the link (POLL,
172 topology etc.) */ 138 topology etc.) */
173 WORD attached_link; /* Number of attached link */ 139 WORD attached_link; /* Number of attached link */
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
index 36aad4c9cb3a..79b853140ae5 100644
--- a/drivers/char/rio/list.h
+++ b/drivers/char/rio/list.h
@@ -44,8 +44,6 @@ static char *_rio_list_h_sccs = "@(#)list.h 1.9";
44 44
45#define PKT_IN_USE 0x1 45#define PKT_IN_USE 0x1
46 46
47#ifdef INKERNEL
48
49#define ZERO_PTR (ushort) 0x8000 47#define ZERO_PTR (ushort) 0x8000
50#define CaD PortP->Caddr 48#define CaD PortP->Caddr
51 49
@@ -54,143 +52,5 @@ static char *_rio_list_h_sccs = "@(#)list.h 1.9";
54** to by the TxAdd pointer has PKT_IN_USE clear in its address. 52** to by the TxAdd pointer has PKT_IN_USE clear in its address.
55*/ 53*/
56 54
57#ifndef linux
58#if defined( MIPS ) && !defined( MIPSEISA )
59/* May the shoes of the Devil dance on your grave for creating this */
60#define can_add_transmit(PacketP,PortP) \
61 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
62 & (PKT_IN_USE<<2)))
63
64#elif defined(MIPSEISA) || defined(nx6000) || \
65 defined(drs6000) || defined(UWsparc)
66
67#define can_add_transmit(PacketP,PortP) \
68 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
69 & PKT_IN_USE))
70
71#else
72#define can_add_transmit(PacketP,PortP) \
73 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,*PortP->TxAdd)) \
74 & PKT_IN_USE))
75#endif
76
77/*
78** To add a packet to the queue, you set the PKT_IN_USE bit in the address,
79** and then move the TxAdd pointer along one position to point to the next
80** packet pointer. You must wrap the pointer from the end back to the start.
81*/
82#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
83# define add_transmit(PortP) \
84 WINDW(PortP->TxAdd,RINDW(PortP->TxAdd) | PKT_IN_USE);\
85 if (PortP->TxAdd == PortP->TxEnd)\
86 PortP->TxAdd = PortP->TxStart;\
87 else\
88 PortP->TxAdd++;\
89 WWORD(PortP->PhbP->tx_add , RIO_OFF(CaD,PortP->TxAdd));
90#elif defined(AIX)
91# define add_transmit(PortP) \
92 {\
93 register ushort *TxAddP = (ushort *)RIO_PTR(Cad,PortP->TxAddO);\
94 WINDW( TxAddP, RINDW( TxAddP ) | PKT_IN_USE );\
95 if (PortP->TxAddO == PortP->TxEndO )\
96 PortP->TxAddO = PortP->TxStartO;\
97 else\
98 PortP->TxAddO += sizeof(ushort);\
99 WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->tx_add , PortP->TxAddO );\
100 }
101#else
102# define add_transmit(PortP) \
103 *PortP->TxAdd |= PKT_IN_USE;\
104 if (PortP->TxAdd == PortP->TxEnd)\
105 PortP->TxAdd = PortP->TxStart;\
106 else\
107 PortP->TxAdd++;\
108 PortP->PhbP->tx_add = RIO_OFF(CaD,PortP->TxAdd);
109#endif
110
111/*
112** can_remove_receive( PacketP, PortP ) returns non-zero if PKT_IN_USE is set
113** for the next packet on the queue. It will also set PacketP to point to the
114** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
115** then can_remove_receive() returns 0.
116*/
117#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
118# define can_remove_receive(PacketP,PortP) \
119 ((RINDW(PortP->RxRemove) & PKT_IN_USE) ? \
120 (PacketP=(struct PKT *)RIO_PTR(CaD,(RINDW(PortP->RxRemove) & ~PKT_IN_USE))):0)
121#elif defined(AIX)
122# define can_remove_receive(PacketP,PortP) \
123 ((RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & PKT_IN_USE) ? \
124 (PacketP=(struct PKT *)RIO_PTR(Cad,RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & ~PKT_IN_USE)):0)
125#else
126# define can_remove_receive(PacketP,PortP) \
127 ((*PortP->RxRemove & PKT_IN_USE) ? \
128 (PacketP=(struct PKT *)RIO_PTR(CaD,(*PortP->RxRemove & ~PKT_IN_USE))):0)
129#endif
130
131
132/*
133** Will God see it within his heart to forgive us for this thing that
134** we have created? To remove a packet from the receive queue you clear
135** its PKT_IN_USE bit, and then bump the pointers. Once the pointers
136** get to the end, they must be wrapped back to the start.
137*/
138#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
139# define remove_receive(PortP) \
140 WINDW(PortP->RxRemove, (RINDW(PortP->RxRemove) & ~PKT_IN_USE));\
141 if (PortP->RxRemove == PortP->RxEnd)\
142 PortP->RxRemove = PortP->RxStart;\
143 else\
144 PortP->RxRemove++;\
145 WWORD(PortP->PhbP->rx_remove , RIO_OFF(CaD,PortP->RxRemove));
146#elif defined(AIX)
147# define remove_receive(PortP) \
148 {\
149 register ushort *RxRemoveP = (ushort *)RIO_PTR(Cad,PortP->RxRemoveO);\
150 WINDW( RxRemoveP, RINDW( RxRemoveP ) & ~PKT_IN_USE );\
151 if (PortP->RxRemoveO == PortP->RxEndO)\
152 PortP->RxRemoveO = PortP->RxStartO;\
153 else\
154 PortP->RxRemoveO += sizeof(ushort);\
155 WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->rx_remove, PortP->RxRemoveO );\
156 }
157#else
158# define remove_receive(PortP) \
159 *PortP->RxRemove &= ~PKT_IN_USE;\
160 if (PortP->RxRemove == PortP->RxEnd)\
161 PortP->RxRemove = PortP->RxStart;\
162 else\
163 PortP->RxRemove++;\
164 PortP->PhbP->rx_remove = RIO_OFF(CaD,PortP->RxRemove);
165#endif
166#endif
167
168
169#else /* !IN_KERNEL */
170
171#define ZERO_PTR NULL
172
173
174#ifdef HOST
175/* #define can_remove_transmit(pkt,phb) ((((char*)pkt = (*(char**)(phb->tx_remove))-1) || 1)) && (*phb->u3.s2.tx_remove_ptr & PKT_IN_USE)) */
176#define remove_transmit(phb) *phb->u3.s2.tx_remove_ptr &= ~(ushort)PKT_IN_USE;\
177 if (phb->tx_remove == phb->tx_end)\
178 phb->tx_remove = phb->tx_start;\
179 else\
180 phb->tx_remove++;
181#define can_add_receive(phb) !(*phb->u4.s2.rx_add_ptr & PKT_IN_USE)
182#define add_receive(pkt,phb) *phb->rx_add = pkt;\
183 *phb->u4.s2.rx_add_ptr |= PKT_IN_USE;\
184 if (phb->rx_add == phb->rx_end)\
185 phb->rx_add = phb->rx_start;\
186 else\
187 phb->rx_add++;
188#endif
189#endif
190
191#ifdef RTA
192#define splx(oldspl) if ((oldspl) == 0) spl0()
193#endif
194
195#endif /* ifndef _list.h */ 55#endif /* ifndef _list.h */
196/*********** end of file ***********/ 56/*********** end of file ***********/
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index fe4e00567065..e24acc1d1844 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -78,14 +78,9 @@ struct PARM_MAP {
78 WORD idle_count; /* Idle time counter */ 78 WORD idle_count; /* Idle time counter */
79 WORD busy_count; /* Busy counter */ 79 WORD busy_count; /* Busy counter */
80 WORD idle_control; /* Control Idle Process */ 80 WORD idle_control; /* Control Idle Process */
81#if defined(HOST) || defined(INKERNEL)
82 WORD tx_intr; /* TX interrupt pending */ 81 WORD tx_intr; /* TX interrupt pending */
83 WORD rx_intr; /* RX interrupt pending */ 82 WORD rx_intr; /* RX interrupt pending */
84 WORD rup_intr; /* RUP interrupt pending */ 83 WORD rup_intr; /* RUP interrupt pending */
85#endif
86#if defined(RTA)
87 WORD dying_count; /* Count of processes dead */
88#endif
89}; 84};
90 85
91#endif 86#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 3baebf8513af..2663ca0306e2 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -44,17 +44,6 @@
44#endif 44#endif
45 45
46 46
47 /*************************************************
48 * Set the LIMIT values.
49 ************************************************/
50#ifdef RTA
51#define RX_LIMIT (ushort) 3
52#endif
53#ifdef HOST
54#define RX_LIMIT (ushort) 1
55#endif
56
57
58/************************************************* 47/*************************************************
59 * Handshake asserted. Deasserted by the LTT(s) 48 * Handshake asserted. Deasserted by the LTT(s)
60 ************************************************/ 49 ************************************************/
@@ -69,11 +58,7 @@
69/************************************************* 58/*************************************************
70 * Maximum number of PHB's 59 * Maximum number of PHB's
71 ************************************************/ 60 ************************************************/
72#if defined (HOST) || defined (INKERNEL)
73#define MAX_PHB ((ushort) 128) /* range 0-127 */ 61#define MAX_PHB ((ushort) 128) /* range 0-127 */
74#else
75#define MAX_PHB ((ushort) 8) /* range 0-7 */
76#endif
77 62
78/************************************************* 63/*************************************************
79 * Defines for the mode fields 64 * Defines for the mode fields
@@ -139,141 +124,23 @@
139 * the start. The pointer tx_add points to a SPACE to put a Packet. 124 * the start. The pointer tx_add points to a SPACE to put a Packet.
140 * The pointer tx_remove points to the next Packet to remove 125 * The pointer tx_remove points to the next Packet to remove
141 *************************************************************************/ 126 *************************************************************************/
142#ifndef INKERNEL
143#define src_unit u2.s2.unit
144#define src_port u2.s2.port
145#define dest_unit u1.s1.unit
146#define dest_port u1.s1.port
147#endif
148#ifdef HOST
149#define tx_start u3.s1.tx_start_ptr_ptr
150#define tx_add u3.s1.tx_add_ptr_ptr
151#define tx_end u3.s1.tx_end_ptr_ptr
152#define tx_remove u3.s1.tx_remove_ptr_ptr
153#define rx_start u4.s1.rx_start_ptr_ptr
154#define rx_add u4.s1.rx_add_ptr_ptr
155#define rx_end u4.s1.rx_end_ptr_ptr
156#define rx_remove u4.s1.rx_remove_ptr_ptr
157#endif
158typedef struct PHB PHB; 127typedef struct PHB PHB;
159struct PHB { 128struct PHB {
160#ifdef RTA
161 ushort port;
162#endif
163#ifdef INKERNEL
164 WORD source; 129 WORD source;
165#else
166 union {
167 ushort source; /* Complete source */
168 struct {
169 unsigned char unit; /* Source unit */
170 unsigned char port; /* Source port */
171 } s2;
172 } u2;
173#endif
174 WORD handshake; 130 WORD handshake;
175 WORD status; 131 WORD status;
176 NUMBER timeout; /* Maximum of 1.9 seconds */ 132 NUMBER timeout; /* Maximum of 1.9 seconds */
177 WORD link; /* Send down this link */ 133 WORD link; /* Send down this link */
178#ifdef INKERNEL
179 WORD destination; 134 WORD destination;
180#else
181 union {
182 ushort destination; /* Complete destination */
183 struct {
184 unsigned char unit; /* Destination unit */
185 unsigned char port; /* Destination port */
186 } s1;
187 } u1;
188#endif
189#ifdef RTA
190 ushort tx_pkts_added;
191 ushort tx_pkts_removed;
192 Q_BUF_ptr tx_q_start; /* Start of the Q list chain */
193 short num_tx_q_bufs; /* Number of Q buffers in the chain */
194 PKT_ptr_ptr tx_add; /* Add a new Packet here */
195 Q_BUF_ptr tx_add_qb; /* Pointer to the add Q buf */
196 PKT_ptr_ptr tx_add_st_qbb; /* Pointer to start of the Q's buf */
197 PKT_ptr_ptr tx_add_end_qbb; /* Pointer to the end of the Q's buf */
198 PKT_ptr_ptr tx_remove; /* Remove a Packet here */
199 Q_BUF_ptr tx_remove_qb; /* Pointer to the remove Q buf */
200 PKT_ptr_ptr tx_remove_st_qbb; /* Pointer to the start of the Q buf */
201 PKT_ptr_ptr tx_remove_end_qbb; /* Pointer to the end of the Q buf */
202#endif
203#ifdef INKERNEL
204 PKT_ptr_ptr tx_start; 135 PKT_ptr_ptr tx_start;
205 PKT_ptr_ptr tx_end; 136 PKT_ptr_ptr tx_end;
206 PKT_ptr_ptr tx_add; 137 PKT_ptr_ptr tx_add;
207 PKT_ptr_ptr tx_remove; 138 PKT_ptr_ptr tx_remove;
208#endif
209#ifdef HOST
210 union {
211 struct {
212 PKT_ptr_ptr tx_start_ptr_ptr;
213 PKT_ptr_ptr tx_end_ptr_ptr;
214 PKT_ptr_ptr tx_add_ptr_ptr;
215 PKT_ptr_ptr tx_remove_ptr_ptr;
216 } s1;
217 struct {
218 ushort *tx_start_ptr;
219 ushort *tx_end_ptr;
220 ushort *tx_add_ptr;
221 ushort *tx_remove_ptr;
222 } s2;
223 } u3;
224#endif
225 139
226#ifdef RTA
227 ushort rx_pkts_added;
228 ushort rx_pkts_removed;
229 Q_BUF_ptr rx_q_start; /* Start of the Q list chain */
230 short num_rx_q_bufs; /* Number of Q buffers in the chain */
231 PKT_ptr_ptr rx_add; /* Add a new Packet here */
232 Q_BUF_ptr rx_add_qb; /* Pointer to the add Q buf */
233 PKT_ptr_ptr rx_add_st_qbb; /* Pointer to start of the Q's buf */
234 PKT_ptr_ptr rx_add_end_qbb; /* Pointer to the end of the Q's buf */
235 PKT_ptr_ptr rx_remove; /* Remove a Packet here */
236 Q_BUF_ptr rx_remove_qb; /* Pointer to the remove Q buf */
237 PKT_ptr_ptr rx_remove_st_qbb; /* Pointer to the start of the Q buf */
238 PKT_ptr_ptr rx_remove_end_qbb; /* Pointer to the end of the Q buf */
239#endif
240#ifdef INKERNEL
241 PKT_ptr_ptr rx_start; 140 PKT_ptr_ptr rx_start;
242 PKT_ptr_ptr rx_end; 141 PKT_ptr_ptr rx_end;
243 PKT_ptr_ptr rx_add; 142 PKT_ptr_ptr rx_add;
244 PKT_ptr_ptr rx_remove; 143 PKT_ptr_ptr rx_remove;
245#endif
246#ifdef HOST
247 union {
248 struct {
249 PKT_ptr_ptr rx_start_ptr_ptr;
250 PKT_ptr_ptr rx_end_ptr_ptr;
251 PKT_ptr_ptr rx_add_ptr_ptr;
252 PKT_ptr_ptr rx_remove_ptr_ptr;
253 } s1;
254 struct {
255 ushort *rx_start_ptr;
256 ushort *rx_end_ptr;
257 ushort *rx_add_ptr;
258 ushort *rx_remove_ptr;
259 } s2;
260 } u4;
261#endif
262
263#ifdef RTA /* some fields for the remotes */
264 ushort flush_count; /* Count of write flushes */
265 ushort txmode; /* Modes for tx */
266 ushort rxmode; /* Modes for rx */
267 ushort portmode; /* Generic modes */
268 ushort column; /* TAB3 column count */
269 ushort tx_subscript; /* (TX) Subscript into data field */
270 ushort rx_subscript; /* (RX) Subscript into data field */
271 PKT_ptr rx_incomplete; /* Hold an incomplete packet here */
272 ushort modem_bits; /* Modem bits to mask */
273 ushort lastModem; /* Modem control lines. */
274 ushort addr; /* Address for sub commands */
275 ushort MonitorTstate; /* TRUE if monitoring tstop */
276#endif
277 144
278}; 145};
279 146
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 882fd429ac2e..7011e52e82db 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -70,39 +70,12 @@
70#define CONTROL_DATA_WNDW (DATA_WNDW << 8) 70#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
71 71
72struct PKT { 72struct PKT {
73#ifdef INKERNEL
74 BYTE dest_unit; /* Destination Unit Id */ 73 BYTE dest_unit; /* Destination Unit Id */
75 BYTE dest_port; /* Destination POrt */ 74 BYTE dest_port; /* Destination POrt */
76 BYTE src_unit; /* Source Unit Id */ 75 BYTE src_unit; /* Source Unit Id */
77 BYTE src_port; /* Source POrt */ 76 BYTE src_port; /* Source POrt */
78#else
79 union {
80 ushort destination; /* Complete destination */
81 struct {
82 unsigned char unit; /* Destination unit */
83 unsigned char port; /* Destination port */
84 } s1;
85 } u1;
86 union {
87 ushort source; /* Complete source */
88 struct {
89 unsigned char unit; /* Source unit */
90 unsigned char port; /* Source port */
91 } s2;
92 } u2;
93#endif
94#ifdef INKERNEL
95 BYTE len; 77 BYTE len;
96 BYTE control; 78 BYTE control;
97#else
98 union {
99 ushort control;
100 struct {
101 unsigned char len;
102 unsigned char control;
103 } s3;
104 } u3;
105#endif
106 BYTE data[PKT_MAX_DATA_LEN]; 79 BYTE data[PKT_MAX_DATA_LEN];
107 /* Actual data :-) */ 80 /* Actual data :-) */
108 WORD csum; /* C-SUM */ 81 WORD csum; /* C-SUM */
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
index acd9e8e5307d..391ffc335535 100644
--- a/drivers/char/rio/qbuf.h
+++ b/drivers/char/rio/qbuf.h
@@ -46,11 +46,7 @@ static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
46 46
47 47
48 48
49#ifdef HOST
50#define PKTS_PER_BUFFER 1
51#else
52#define PKTS_PER_BUFFER (220 / PKT_LENGTH) 49#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
53#endif
54 50
55typedef struct Q_BUF Q_BUF; 51typedef struct Q_BUF Q_BUF;
56struct Q_BUF { 52struct Q_BUF {
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
index 9b67e2468bec..46084d5c7e98 100644
--- a/drivers/char/rio/riotypes.h
+++ b/drivers/char/rio/riotypes.h
@@ -43,9 +43,6 @@
43#endif 43#endif
44#endif 44#endif
45 45
46#ifdef INKERNEL
47
48#if !defined(MIPSAT)
49typedef unsigned short NUMBER_ptr; 46typedef unsigned short NUMBER_ptr;
50typedef unsigned short WORD_ptr; 47typedef unsigned short WORD_ptr;
51typedef unsigned short BYTE_ptr; 48typedef unsigned short BYTE_ptr;
@@ -65,69 +62,6 @@ typedef unsigned short RUP_ptr;
65typedef unsigned short short_ptr; 62typedef unsigned short short_ptr;
66typedef unsigned short u_short_ptr; 63typedef unsigned short u_short_ptr;
67typedef unsigned short ushort_ptr; 64typedef unsigned short ushort_ptr;
68#else
69/* MIPSAT types */
70typedef char RIO_POINTER[8];
71typedef RIO_POINTER NUMBER_ptr;
72typedef RIO_POINTER WORD_ptr;
73typedef RIO_POINTER BYTE_ptr;
74typedef RIO_POINTER char_ptr;
75typedef RIO_POINTER Channel_ptr;
76typedef RIO_POINTER FREE_LIST_ptr_ptr;
77typedef RIO_POINTER FREE_LIST_ptr;
78typedef RIO_POINTER LPB_ptr;
79typedef RIO_POINTER Process_ptr;
80typedef RIO_POINTER PHB_ptr;
81typedef RIO_POINTER PKT_ptr;
82typedef RIO_POINTER PKT_ptr_ptr;
83typedef RIO_POINTER Q_BUF_ptr;
84typedef RIO_POINTER Q_BUF_ptr_ptr;
85typedef RIO_POINTER ROUTE_STR_ptr;
86typedef RIO_POINTER RUP_ptr;
87typedef RIO_POINTER short_ptr;
88typedef RIO_POINTER u_short_ptr;
89typedef RIO_POINTER ushort_ptr;
90#endif
91
92#else /* not INKERNEL */
93typedef unsigned char BYTE;
94typedef unsigned short WORD;
95typedef unsigned long DWORD;
96typedef short NUMBER;
97typedef short *NUMBER_ptr;
98typedef unsigned short *WORD_ptr;
99typedef unsigned char *BYTE_ptr;
100typedef unsigned char uchar;
101typedef unsigned short ushort;
102typedef unsigned int uint;
103typedef unsigned long ulong;
104typedef unsigned char u_char;
105typedef unsigned short u_short;
106typedef unsigned int u_int;
107typedef unsigned long u_long;
108typedef unsigned short ERROR;
109typedef unsigned long ID;
110typedef char *char_ptr;
111typedef Channel *Channel_ptr;
112typedef struct FREE_LIST *FREE_LIST_ptr;
113typedef struct FREE_LIST **FREE_LIST_ptr_ptr;
114typedef struct LPB *LPB_ptr;
115typedef struct Process *Process_ptr;
116typedef struct PHB *PHB_ptr;
117typedef struct PKT *PKT_ptr;
118typedef struct PKT **PKT_ptr_ptr;
119typedef struct Q_BUF *Q_BUF_ptr;
120typedef struct Q_BUF **Q_BUF_ptr_ptr;
121typedef struct ROUTE_STR *ROUTE_STR_ptr;
122typedef struct RUP *RUP_ptr;
123typedef short *short_ptr;
124typedef u_short *u_short_ptr;
125typedef ushort *ushort_ptr;
126typedef struct PKT PKT;
127typedef struct LPB LPB;
128typedef struct RUP RUP;
129#endif
130
131 65
132#endif /* __riotypes__ */ 66#endif /* __riotypes__ */
133 67
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index 8d44fec91dd5..f74f67c6f702 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -43,12 +43,7 @@
43#endif 43#endif
44#endif 44#endif
45 45
46#if defined( HOST ) || defined( INKERNEL )
47#define MAX_RUP ((short) 16) 46#define MAX_RUP ((short) 16)
48#endif
49#ifdef RTA
50#define MAX_RUP ((short) 1)
51#endif
52 47
53#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */ 48#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
54 49
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
index 31494054b213..6f754e19015d 100644
--- a/drivers/char/rio/sam.h
+++ b/drivers/char/rio/sam.h
@@ -43,10 +43,6 @@
43#endif 43#endif
44 44
45 45
46#if !defined( HOST ) && !defined( INKERNEL )
47#define RTA 1
48#endif
49
50#define NUM_FREE_LIST_UNITS 500 46#define NUM_FREE_LIST_UNITS 500
51 47
52#ifndef FALSE 48#ifndef FALSE
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 0949dcef0697..7edc6a4dbdc4 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -433,7 +433,7 @@ static void rp_do_receive(struct r_port *info,
433 count += ToRecv; 433 count += ToRecv;
434 } 434 }
435 /* Push the data up to the tty layer */ 435 /* Push the data up to the tty layer */
436 ld->receive_buf(tty, cbuf, fbuf, count); 436 ld->receive_buf(tty, chead, fhead, count);
437done: 437done:
438 tty_ldisc_deref(ld); 438 tty_ldisc_deref(ld);
439} 439}
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 64bf89cb574f..c2490e270f1f 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -931,7 +931,7 @@ static int sx_set_real_termios (void *ptr)
931 case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break; 931 case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break;
932 case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break; 932 case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break;
933 default: 933 default:
934 printk (KERN_INFO "sx: Invalid wordsize: %d\n", CFLAG & CSIZE); 934 printk (KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
935 break; 935 break;
936 } 936 }
937 937
@@ -958,7 +958,7 @@ static int sx_set_real_termios (void *ptr)
958 } else { 958 } else {
959 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); 959 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
960 } 960 }
961 sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ", 961 sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
962 port->gs.tty->termios->c_iflag, 962 port->gs.tty->termios->c_iflag,
963 I_OTHER(port->gs.tty)); 963 I_OTHER(port->gs.tty));
964 964
@@ -973,7 +973,7 @@ static int sx_set_real_termios (void *ptr)
973 } else { 973 } else {
974 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); 974 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
975 } 975 }
976 sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", 976 sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
977 port->gs.tty->termios->c_oflag, 977 port->gs.tty->termios->c_oflag,
978 O_OTHER(port->gs.tty)); 978 O_OTHER(port->gs.tty));
979 /* port->c_dcd = sx_get_CD (port); */ 979 /* port->c_dcd = sx_get_CD (port); */
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index aedf7a8e6da7..537aa45d8c67 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -191,7 +191,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
191 const char *name = ""; 191 const char *name = "";
192 char data[40] = ""; 192 char data[40] = "";
193 int i, n_len = 0, d_len = 0; 193 int i, n_len = 0, d_len = 0;
194 u32 event_id, event_data_size; 194 u32 event_id;
195 195
196 switch(event->event_type) { 196 switch(event->event_type) {
197 case PREBOOT: 197 case PREBOOT:
@@ -220,8 +220,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
220 } 220 }
221 break; 221 break;
222 case EVENT_TAG: 222 case EVENT_TAG:
223 event_id = be32_to_cpu(event_entry); 223 event_id = be32_to_cpu(*((u32 *)event_entry));
224 event_data_size = be32_to_cpu(&event_entry[4]);
225 224
226 /* ToDo Row data -> Base64 */ 225 /* ToDo Row data -> Base64 */
227 226
@@ -376,7 +375,7 @@ static int read_log(struct tpm_bios_log *log)
376{ 375{
377 struct acpi_tcpa *buff; 376 struct acpi_tcpa *buff;
378 acpi_status status; 377 acpi_status status;
379 void *virt; 378 struct acpi_table_header *virt;
380 379
381 if (log->bios_event_log != NULL) { 380 if (log->bios_event_log != NULL) {
382 printk(KERN_ERR 381 printk(KERN_ERR
@@ -413,7 +412,7 @@ static int read_log(struct tpm_bios_log *log)
413 412
414 log->bios_event_log_end = log->bios_event_log + buff->log_max_len; 413 log->bios_event_log_end = log->bios_event_log + buff->log_max_len;
415 414
416 acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, &virt); 415 acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, (void *) &virt);
417 416
418 memcpy(log->bios_event_log, virt, buff->log_max_len); 417 memcpy(log->bios_event_log, virt, buff->log_max_len);
419 418
@@ -487,26 +486,35 @@ struct file_operations tpm_binary_bios_measurements_ops = {
487 .release = tpm_bios_measurements_release, 486 .release = tpm_bios_measurements_release,
488}; 487};
489 488
489static int is_bad(void *p)
490{
491 if (!p)
492 return 1;
493 if (IS_ERR(p) && (PTR_ERR(p) != -ENODEV))
494 return 1;
495 return 0;
496}
497
490struct dentry **tpm_bios_log_setup(char *name) 498struct dentry **tpm_bios_log_setup(char *name)
491{ 499{
492 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file; 500 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
493 501
494 tpm_dir = securityfs_create_dir(name, NULL); 502 tpm_dir = securityfs_create_dir(name, NULL);
495 if (!tpm_dir) 503 if (is_bad(tpm_dir))
496 goto out; 504 goto out;
497 505
498 bin_file = 506 bin_file =
499 securityfs_create_file("binary_bios_measurements", 507 securityfs_create_file("binary_bios_measurements",
500 S_IRUSR | S_IRGRP, tpm_dir, NULL, 508 S_IRUSR | S_IRGRP, tpm_dir, NULL,
501 &tpm_binary_bios_measurements_ops); 509 &tpm_binary_bios_measurements_ops);
502 if (!bin_file) 510 if (is_bad(bin_file))
503 goto out_tpm; 511 goto out_tpm;
504 512
505 ascii_file = 513 ascii_file =
506 securityfs_create_file("ascii_bios_measurements", 514 securityfs_create_file("ascii_bios_measurements",
507 S_IRUSR | S_IRGRP, tpm_dir, NULL, 515 S_IRUSR | S_IRGRP, tpm_dir, NULL,
508 &tpm_ascii_bios_measurements_ops); 516 &tpm_ascii_bios_measurements_ops);
509 if (!ascii_file) 517 if (is_bad(ascii_file))
510 goto out_bin; 518 goto out_bin;
511 519
512 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL); 520 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);
@@ -538,3 +546,4 @@ void tpm_bios_log_teardown(struct dentry **lst)
538 securityfs_remove(lst[i]); 546 securityfs_remove(lst[i]);
539} 547}
540EXPORT_SYMBOL_GPL(tpm_bios_log_teardown); 548EXPORT_SYMBOL_GPL(tpm_bios_log_teardown);
549MODULE_LICENSE("GPL");
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 8198dbb7370f..ec7590951af5 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -441,7 +441,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
441 441
442 if ((ioh << 8 | iol) != tpm_inf.base) { 442 if ((ioh << 8 | iol) != tpm_inf.base) {
443 dev_err(&dev->dev, 443 dev_err(&dev->dev,
444 "Could not set IO-ports to %04x\n", 444 "Could not set IO-ports to 0x%lx\n",
445 tpm_inf.base); 445 tpm_inf.base);
446 release_region(tpm_inf.base, TPM_INF_PORT_LEN); 446 release_region(tpm_inf.base, TPM_INF_PORT_LEN);
447 return -EIO; 447 return -EIO;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index eb8b5be4e249..076e07c1da38 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -253,6 +253,7 @@ static void tty_buffer_free_all(struct tty_struct *tty)
253 253
254static void tty_buffer_init(struct tty_struct *tty) 254static void tty_buffer_init(struct tty_struct *tty)
255{ 255{
256 spin_lock_init(&tty->buf.lock);
256 tty->buf.head = NULL; 257 tty->buf.head = NULL;
257 tty->buf.tail = NULL; 258 tty->buf.tail = NULL;
258 tty->buf.free = NULL; 259 tty->buf.free = NULL;
@@ -266,6 +267,7 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
266 p->used = 0; 267 p->used = 0;
267 p->size = size; 268 p->size = size;
268 p->next = NULL; 269 p->next = NULL;
270 p->active = 0;
269 p->char_buf_ptr = (char *)(p->data); 271 p->char_buf_ptr = (char *)(p->data);
270 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; 272 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size;
271/* printk("Flip create %p\n", p); */ 273/* printk("Flip create %p\n", p); */
@@ -312,25 +314,36 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)
312 314
313int tty_buffer_request_room(struct tty_struct *tty, size_t size) 315int tty_buffer_request_room(struct tty_struct *tty, size_t size)
314{ 316{
315 struct tty_buffer *b = tty->buf.tail, *n; 317 struct tty_buffer *b, *n;
316 int left = 0; 318 int left;
319 unsigned long flags;
320
321 spin_lock_irqsave(&tty->buf.lock, flags);
317 322
318 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 323 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
319 remove this conditional if its worth it. This would be invisible 324 remove this conditional if its worth it. This would be invisible
320 to the callers */ 325 to the callers */
321 if(b != NULL) 326 if ((b = tty->buf.tail) != NULL) {
322 left = b->size - b->used; 327 left = b->size - b->used;
323 if(left >= size) 328 b->active = 1;
324 return size; 329 } else
325 /* This is the slow path - looking for new buffers to use */ 330 left = 0;
326 n = tty_buffer_find(tty, size); 331
327 if(n == NULL) 332 if (left < size) {
328 return left; 333 /* This is the slow path - looking for new buffers to use */
329 if(b != NULL) 334 if ((n = tty_buffer_find(tty, size)) != NULL) {
330 b->next = n; 335 if (b != NULL) {
331 else 336 b->next = n;
332 tty->buf.head = n; 337 b->active = 0;
333 tty->buf.tail = n; 338 } else
339 tty->buf.head = n;
340 tty->buf.tail = n;
341 n->active = 1;
342 } else
343 size = left;
344 }
345
346 spin_unlock_irqrestore(&tty->buf.lock, flags);
334 return size; 347 return size;
335} 348}
336 349
@@ -396,10 +409,12 @@ EXPORT_SYMBOL_GPL(tty_insert_flip_string_flags);
396int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) 409int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size)
397{ 410{
398 int space = tty_buffer_request_room(tty, size); 411 int space = tty_buffer_request_room(tty, size);
399 struct tty_buffer *tb = tty->buf.tail; 412 if (likely(space)) {
400 *chars = tb->char_buf_ptr + tb->used; 413 struct tty_buffer *tb = tty->buf.tail;
401 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); 414 *chars = tb->char_buf_ptr + tb->used;
402 tb->used += space; 415 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);
416 tb->used += space;
417 }
403 return space; 418 return space;
404} 419}
405 420
@@ -416,10 +431,12 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
416int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) 431int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size)
417{ 432{
418 int space = tty_buffer_request_room(tty, size); 433 int space = tty_buffer_request_room(tty, size);
419 struct tty_buffer *tb = tty->buf.tail; 434 if (likely(space)) {
420 *chars = tb->char_buf_ptr + tb->used; 435 struct tty_buffer *tb = tty->buf.tail;
421 *flags = tb->flag_buf_ptr + tb->used; 436 *chars = tb->char_buf_ptr + tb->used;
422 tb->used += space; 437 *flags = tb->flag_buf_ptr + tb->used;
438 tb->used += space;
439 }
423 return space; 440 return space;
424} 441}
425 442
@@ -2747,20 +2764,20 @@ static void flush_to_ldisc(void *private_)
2747 schedule_delayed_work(&tty->buf.work, 1); 2764 schedule_delayed_work(&tty->buf.work, 1);
2748 goto out; 2765 goto out;
2749 } 2766 }
2750 spin_lock_irqsave(&tty->read_lock, flags); 2767 spin_lock_irqsave(&tty->buf.lock, flags);
2751 while((tbuf = tty->buf.head) != NULL) { 2768 while((tbuf = tty->buf.head) != NULL && !tbuf->active) {
2752 tty->buf.head = tbuf->next; 2769 tty->buf.head = tbuf->next;
2753 if (tty->buf.head == NULL) 2770 if (tty->buf.head == NULL)
2754 tty->buf.tail = NULL; 2771 tty->buf.tail = NULL;
2755 spin_unlock_irqrestore(&tty->read_lock, flags); 2772 spin_unlock_irqrestore(&tty->buf.lock, flags);
2756 /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */ 2773 /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */
2757 disc->receive_buf(tty, tbuf->char_buf_ptr, 2774 disc->receive_buf(tty, tbuf->char_buf_ptr,
2758 tbuf->flag_buf_ptr, 2775 tbuf->flag_buf_ptr,
2759 tbuf->used); 2776 tbuf->used);
2760 spin_lock_irqsave(&tty->read_lock, flags); 2777 spin_lock_irqsave(&tty->buf.lock, flags);
2761 tty_buffer_free(tty, tbuf); 2778 tty_buffer_free(tty, tbuf);
2762 } 2779 }
2763 spin_unlock_irqrestore(&tty->read_lock, flags); 2780 spin_unlock_irqrestore(&tty->buf.lock, flags);
2764out: 2781out:
2765 tty_ldisc_deref(disc); 2782 tty_ldisc_deref(disc);
2766} 2783}
@@ -2852,6 +2869,12 @@ EXPORT_SYMBOL(tty_get_baud_rate);
2852 2869
2853void tty_flip_buffer_push(struct tty_struct *tty) 2870void tty_flip_buffer_push(struct tty_struct *tty)
2854{ 2871{
2872 unsigned long flags;
2873 spin_lock_irqsave(&tty->buf.lock, flags);
2874 if (tty->buf.tail != NULL)
2875 tty->buf.tail->active = 0;
2876 spin_unlock_irqrestore(&tty->buf.lock, flags);
2877
2855 if (tty->low_latency) 2878 if (tty->low_latency)
2856 flush_to_ldisc((void *) tty); 2879 flush_to_ldisc((void *) tty);
2857 else 2880 else
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index f1d9cb7feae6..0900d1dbee59 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -3213,6 +3213,7 @@ void getconsxy(struct vc_data *vc, unsigned char *p)
3213 3213
3214void putconsxy(struct vc_data *vc, unsigned char *p) 3214void putconsxy(struct vc_data *vc, unsigned char *p)
3215{ 3215{
3216 hide_cursor(vc);
3216 gotoxy(vc, p[0], p[1]); 3217 gotoxy(vc, p[0], p[1]);
3217 set_cursor(vc); 3218 set_cursor(vc);
3218} 3219}
diff --git a/drivers/char/watchdog/sbc_epx_c3.c b/drivers/char/watchdog/sbc_epx_c3.c
index 951764614ebf..7a4dfb95d087 100644
--- a/drivers/char/watchdog/sbc_epx_c3.c
+++ b/drivers/char/watchdog/sbc_epx_c3.c
@@ -25,6 +25,7 @@
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/ioport.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/io.h> 30#include <asm/io.h>
30 31
@@ -181,11 +182,14 @@ static int __init watchdog_init(void)
181{ 182{
182 int ret; 183 int ret;
183 184
185 if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
186 return -EBUSY;
187
184 ret = register_reboot_notifier(&epx_c3_notifier); 188 ret = register_reboot_notifier(&epx_c3_notifier);
185 if (ret) { 189 if (ret) {
186 printk(KERN_ERR PFX "cannot register reboot notifier " 190 printk(KERN_ERR PFX "cannot register reboot notifier "
187 "(err=%d)\n", ret); 191 "(err=%d)\n", ret);
188 return ret; 192 goto out;
189 } 193 }
190 194
191 ret = misc_register(&epx_c3_miscdev); 195 ret = misc_register(&epx_c3_miscdev);
@@ -193,18 +197,23 @@ static int __init watchdog_init(void)
193 printk(KERN_ERR PFX "cannot register miscdev on minor=%d " 197 printk(KERN_ERR PFX "cannot register miscdev on minor=%d "
194 "(err=%d)\n", WATCHDOG_MINOR, ret); 198 "(err=%d)\n", WATCHDOG_MINOR, ret);
195 unregister_reboot_notifier(&epx_c3_notifier); 199 unregister_reboot_notifier(&epx_c3_notifier);
196 return ret; 200 goto out;
197 } 201 }
198 202
199 printk(banner); 203 printk(banner);
200 204
201 return 0; 205 return 0;
206
207out:
208 release_region(EPXC3_WATCHDOG_CTL_REG, 2);
209 return ret;
202} 210}
203 211
204static void __exit watchdog_exit(void) 212static void __exit watchdog_exit(void)
205{ 213{
206 misc_deregister(&epx_c3_miscdev); 214 misc_deregister(&epx_c3_miscdev);
207 unregister_reboot_notifier(&epx_c3_notifier); 215 unregister_reboot_notifier(&epx_c3_notifier);
216 release_region(EPXC3_WATCHDOG_CTL_REG, 2);
208} 217}
209 218
210module_init(watchdog_init); 219module_init(watchdog_init);
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 4819e7fc00dd..d94331c1e5b0 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -46,7 +46,7 @@ config EDAC_MM_EDAC
46 46
47config EDAC_AMD76X 47config EDAC_AMD76X
48 tristate "AMD 76x (760, 762, 768)" 48 tristate "AMD 76x (760, 762, 768)"
49 depends on EDAC_MM_EDAC && PCI 49 depends on EDAC_MM_EDAC && PCI && X86_32
50 help 50 help
51 Support for error detection and correction on the AMD 76x 51 Support for error detection and correction on the AMD 76x
52 series of chipsets used with the Athlon processor. 52 series of chipsets used with the Athlon processor.
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index 770a5a633079..c454ded2b060 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -1039,10 +1039,10 @@ MODULE_DEVICE_TABLE(pci, e752x_pci_tbl);
1039 1039
1040 1040
1041static struct pci_driver e752x_driver = { 1041static struct pci_driver e752x_driver = {
1042 name: BS_MOD_STR, 1042 .name = BS_MOD_STR,
1043 probe: e752x_init_one, 1043 .probe = e752x_init_one,
1044 remove: __devexit_p(e752x_remove_one), 1044 .remove = __devexit_p(e752x_remove_one),
1045 id_table: e752x_pci_tbl, 1045 .id_table = e752x_pci_tbl,
1046}; 1046};
1047 1047
1048 1048
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 4be9bd0a1267..b10ee4698b1d 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -14,7 +14,6 @@
14 14
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/version.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 1c81174595b3..d633081fa4c5 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -52,9 +52,9 @@ config IDE
52 52
53if IDE 53if IDE
54 54
55config IDE_MAX_HWIFS 55config IDE_MAX_HWIFS
56 int "Max IDE interfaces" 56 int "Max IDE interfaces"
57 depends on ALPHA || SUPERH 57 depends on ALPHA || SUPERH || IA64
58 default 4 58 default 4
59 help 59 help
60 This is the maximum number of IDE hardware interfaces that will 60 This is the maximum number of IDE hardware interfaces that will
@@ -162,8 +162,8 @@ config BLK_DEV_IDECS
162 tristate "PCMCIA IDE support" 162 tristate "PCMCIA IDE support"
163 depends on PCMCIA 163 depends on PCMCIA
164 help 164 help
165 Support for outboard IDE disks, tape drives, and CD-ROM drives 165 Support for Compact Flash cards, outboard IDE disks, tape drives,
166 connected through a PCMCIA card. 166 and CD-ROM drives connected through a PCMCIA card.
167 167
168config BLK_DEV_IDECD 168config BLK_DEV_IDECD
169 tristate "Include IDE/ATAPI CDROM support" 169 tristate "Include IDE/ATAPI CDROM support"
@@ -267,7 +267,7 @@ config IDE_TASK_IOCTL
267 help 267 help
268 This is a direct raw access to the media. It is a complex but 268 This is a direct raw access to the media. It is a complex but
269 elegant solution to test and validate the domain of the hardware and 269 elegant solution to test and validate the domain of the hardware and
270 perform below the driver data recover if needed. This is the most 270 perform below the driver data recovery if needed. This is the most
271 basic form of media-forensics. 271 basic form of media-forensics.
272 272
273 If you are unsure, say N here. 273 If you are unsure, say N here.
@@ -525,7 +525,7 @@ config BLK_DEV_CS5520
525 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)" 525 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)"
526 depends on EXPERIMENTAL 526 depends on EXPERIMENTAL
527 help 527 help
528 Include support for PIO tuning an virtual DMA on the Cyrix MediaGX 528 Include support for PIO tuning and virtual DMA on the Cyrix MediaGX
529 5510/5520 chipset. This will automatically be detected and 529 5510/5520 chipset. This will automatically be detected and
530 configured if found. 530 configured if found.
531 531
@@ -662,7 +662,7 @@ config PDC202XX_BURST
662 662
663 It was originally designed for the PDC20246/Ultra33, whose BIOS will 663 It was originally designed for the PDC20246/Ultra33, whose BIOS will
664 only setup UDMA on the first two PDC20246 cards. It has also been 664 only setup UDMA on the first two PDC20246 cards. It has also been
665 used succesfully on a PDC20265/Ultra100, allowing use of UDMA modes 665 used successfully on a PDC20265/Ultra100, allowing use of UDMA modes
666 when the PDC20265 BIOS has been disabled (for faster boot up). 666 when the PDC20265 BIOS has been disabled (for faster boot up).
667 667
668 Please read the comments at the top of 668 Please read the comments at the top of
@@ -673,13 +673,6 @@ config PDC202XX_BURST
673config BLK_DEV_PDC202XX_NEW 673config BLK_DEV_PDC202XX_NEW
674 tristate "PROMISE PDC202{68|69|70|71|75|76|77} support" 674 tristate "PROMISE PDC202{68|69|70|71|75|76|77} support"
675 675
676# FIXME - probably wants to be one for old and for new
677config PDC202XX_FORCE
678 bool "Enable controller even if disabled by BIOS"
679 depends on BLK_DEV_PDC202XX_NEW
680 help
681 Enable the PDC202xx controller even if it has been disabled in the BIOS setup.
682
683config BLK_DEV_SVWKS 676config BLK_DEV_SVWKS
684 tristate "ServerWorks OSB4/CSB5/CSB6 chipsets support" 677 tristate "ServerWorks OSB4/CSB5/CSB6 chipsets support"
685 help 678 help
@@ -722,7 +715,7 @@ config BLK_DEV_SIS5513
722config BLK_DEV_SLC90E66 715config BLK_DEV_SLC90E66
723 tristate "SLC90E66 chipset support" 716 tristate "SLC90E66 chipset support"
724 help 717 help
725 This driver ensures (U)DMA support for Victroy66 SouthBridges for 718 This driver ensures (U)DMA support for Victory66 SouthBridges for
726 SMsC with Intel NorthBridges. This is an Ultra66 based chipset. 719 SMsC with Intel NorthBridges. This is an Ultra66 based chipset.
727 The nice thing about it is that you can mix Ultra/DMA/PIO devices 720 The nice thing about it is that you can mix Ultra/DMA/PIO devices
728 and it will handle timing cycles. Since this is an improved 721 and it will handle timing cycles. Since this is an improved
@@ -1060,7 +1053,7 @@ config IDEDMA_IVB
1060 in that mode with an 80c ribbon. 1053 in that mode with an 80c ribbon.
1061 1054
1062 If you are experiencing compatibility or performance problems, you 1055 If you are experiencing compatibility or performance problems, you
1063 MAY try to answering Y here. However, it does not necessarily solve 1056 MAY try to answer Y here. However, it does not necessarily solve
1064 any of your problems, it could even cause more of them. 1057 any of your problems, it could even cause more of them.
1065 1058
1066 It is normally safe to answer Y; however, the default is N. 1059 It is normally safe to answer Y; however, the default is N.
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index ca25f9e3d0f4..6c60a9d2afd8 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -776,7 +776,7 @@ static void update_ordered(ide_drive_t *drive)
776 ide_id_has_flush_cache_ext(id)); 776 ide_id_has_flush_cache_ext(id));
777 777
778 printk(KERN_INFO "%s: cache flushes %ssupported\n", 778 printk(KERN_INFO "%s: cache flushes %ssupported\n",
779 drive->name, barrier ? "" : "not"); 779 drive->name, barrier ? "" : "not ");
780 780
781 if (barrier) { 781 if (barrier) {
782 ordered = QUEUE_ORDERED_DRAIN_FLUSH; 782 ordered = QUEUE_ORDERED_DRAIN_FLUSH;
@@ -889,11 +889,7 @@ static void idedisk_setup (ide_drive_t *drive)
889 if (drive->id_read == 0) 889 if (drive->id_read == 0)
890 return; 890 return;
891 891
892 /* 892 if (drive->removable) {
893 * CompactFlash cards and their brethern look just like hard drives
894 * to us, but they are removable and don't have a doorlock mechanism.
895 */
896 if (drive->removable && !(drive->is_flash)) {
897 /* 893 /*
898 * Removable disks (eg. SYQUEST); ignore 'WD' drives 894 * Removable disks (eg. SYQUEST); ignore 'WD' drives
899 */ 895 */
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 8d50df4526a4..c01615dec202 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -55,8 +55,8 @@
55#include <asm/io.h> 55#include <asm/io.h>
56#include <asm/bitops.h> 56#include <asm/bitops.h>
57 57
58int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate, 58static int __ide_end_request(ide_drive_t *drive, struct request *rq,
59 int nr_sectors) 59 int uptodate, int nr_sectors)
60{ 60{
61 int ret = 1; 61 int ret = 1;
62 62
@@ -91,7 +91,6 @@ int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate,
91 91
92 return ret; 92 return ret;
93} 93}
94EXPORT_SYMBOL(__ide_end_request);
95 94
96/** 95/**
97 * ide_end_request - complete an IDE I/O 96 * ide_end_request - complete an IDE I/O
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index af7af958ab3e..b72dde70840a 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1243,6 +1243,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1243 */ 1243 */
1244 if (stat == 0xff) 1244 if (stat == 0xff)
1245 return -ENODEV; 1245 return -ENODEV;
1246 touch_softlockup_watchdog();
1246 } 1247 }
1247 return -EBUSY; 1248 return -EBUSY;
1248} 1249}
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index e7425546b4b1..427d1c204174 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -125,45 +125,6 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
125} 125}
126 126
127/** 127/**
128 * drive_is_flashcard - check for compact flash
129 * @drive: drive to check
130 *
131 * CompactFlash cards and their brethern pretend to be removable
132 * hard disks, except:
133 * (1) they never have a slave unit, and
134 * (2) they don't have doorlock mechanisms.
135 * This test catches them, and is invoked elsewhere when setting
136 * appropriate config bits.
137 *
138 * FIXME: This treatment is probably applicable for *all* PCMCIA (PC CARD)
139 * devices, so in linux 2.3.x we should change this to just treat all
140 * PCMCIA drives this way, and get rid of the model-name tests below
141 * (too big of an interface change for 2.4.x).
142 * At that time, we might also consider parameterizing the timeouts and
143 * retries, since these are MUCH faster than mechanical drives. -M.Lord
144 */
145
146static inline int drive_is_flashcard (ide_drive_t *drive)
147{
148 struct hd_driveid *id = drive->id;
149
150 if (drive->removable) {
151 if (id->config == 0x848a) return 1; /* CompactFlash */
152 if (!strncmp(id->model, "KODAK ATA_FLASH", 15) /* Kodak */
153 || !strncmp(id->model, "Hitachi CV", 10) /* Hitachi */
154 || !strncmp(id->model, "SunDisk SDCFB", 13) /* old SanDisk */
155 || !strncmp(id->model, "SanDisk SDCFB", 13) /* SanDisk */
156 || !strncmp(id->model, "HAGIWARA HPC", 12) /* Hagiwara */
157 || !strncmp(id->model, "LEXAR ATA_FLASH", 15) /* Lexar */
158 || !strncmp(id->model, "ATA_FLASH", 9)) /* Simple Tech */
159 {
160 return 1; /* yes, it is a flash memory card */
161 }
162 }
163 return 0; /* no, it is not a flash memory card */
164}
165
166/**
167 * do_identify - identify a drive 128 * do_identify - identify a drive
168 * @drive: drive to identify 129 * @drive: drive to identify
169 * @cmd: command used 130 * @cmd: command used
@@ -278,13 +239,17 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
278 /* 239 /*
279 * Not an ATAPI device: looks like a "regular" hard disk 240 * Not an ATAPI device: looks like a "regular" hard disk
280 */ 241 */
281 if (id->config & (1<<7)) 242
243 /*
244 * 0x848a = CompactFlash device
245 * These are *not* removable in Linux definition of the term
246 */
247
248 if ((id->config != 0x848a) && (id->config & (1<<7)))
282 drive->removable = 1; 249 drive->removable = 1;
283 250
284 if (drive_is_flashcard(drive))
285 drive->is_flash = 1;
286 drive->media = ide_disk; 251 drive->media = ide_disk;
287 printk("%s DISK drive\n", (drive->is_flash) ? "CFA" : "ATA" ); 252 printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" );
288 QUIRK_LIST(drive); 253 QUIRK_LIST(drive);
289 return; 254 return;
290 255
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index afeb02bbb722..b2cc43702f65 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -242,7 +242,6 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
242 drive->name[2] = 'a' + (index * MAX_DRIVES) + unit; 242 drive->name[2] = 'a' + (index * MAX_DRIVES) + unit;
243 drive->max_failures = IDE_DEFAULT_MAX_FAILURES; 243 drive->max_failures = IDE_DEFAULT_MAX_FAILURES;
244 drive->using_dma = 0; 244 drive->using_dma = 0;
245 drive->is_flash = 0;
246 drive->vdma = 0; 245 drive->vdma = 0;
247 INIT_LIST_HEAD(&drive->list); 246 INIT_LIST_HEAD(&drive->list);
248 init_completion(&drive->gendev_rel_comp); 247 init_completion(&drive->gendev_rel_comp);
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index a21b1e11eef4..c743e68c33aa 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -262,6 +262,21 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
262 else 262 else
263 pci_set_drvdata(dev, (void *) aec6xxx_34_base); 263 pci_set_drvdata(dev, (void *) aec6xxx_34_base);
264 264
265 /* These are necessary to get AEC6280 Macintosh cards to work */
266 if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) ||
267 (dev->device == PCI_DEVICE_ID_ARTOP_ATP865R)) {
268 u8 reg49h = 0, reg4ah = 0;
269 /* Clear reset and test bits. */
270 pci_read_config_byte(dev, 0x49, &reg49h);
271 pci_write_config_byte(dev, 0x49, reg49h & ~0x30);
272 /* Enable chip interrupt output. */
273 pci_read_config_byte(dev, 0x4a, &reg4ah);
274 pci_write_config_byte(dev, 0x4a, reg4ah & ~0x01);
275 /* Enable burst mode. */
276 pci_read_config_byte(dev, 0x4a, &reg4ah);
277 pci_write_config_byte(dev, 0x4a, reg4ah | 0x80);
278 }
279
265 return dev->irq; 280 return dev->irq;
266} 281}
267 282
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 7b589d948bf9..940bdd4c5784 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1288,6 +1288,10 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1288 goto init_hpt37X_done; 1288 goto init_hpt37X_done;
1289 } 1289 }
1290 } 1290 }
1291 if (!pci_get_drvdata(dev)) {
1292 printk("No Clock Stabilization!!!\n");
1293 return;
1294 }
1291pll_recal: 1295pll_recal:
1292 if (adjust & 1) 1296 if (adjust & 1)
1293 pll -= (adjust >> 1); 1297 pll -= (adjust >> 1);
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 108fda83fea4..38f41b377ff6 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -733,7 +733,7 @@ static void __devinit it8212_disable_raid(struct pci_dev *dev)
733 733
734 pci_write_config_dword(dev,0x4C, 0x02040204); 734 pci_write_config_dword(dev,0x4C, 0x02040204);
735 pci_write_config_byte(dev, 0x42, 0x36); 735 pci_write_config_byte(dev, 0x42, 0x36);
736 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0); 736 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
737} 737}
738 738
739static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name) 739static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name)
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index fe06ebb0e5bf..acd63173199b 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -420,9 +420,6 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
420 .init_hwif = init_hwif_pdc202new, 420 .init_hwif = init_hwif_pdc202new,
421 .channels = 2, 421 .channels = 2,
422 .autodma = AUTODMA, 422 .autodma = AUTODMA,
423#ifndef CONFIG_PDC202XX_FORCE
424 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
425#endif
426 .bootable = OFF_BOARD, 423 .bootable = OFF_BOARD,
427 },{ /* 3 */ 424 },{ /* 3 */
428 .name = "PDC20271", 425 .name = "PDC20271",
@@ -447,9 +444,6 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
447 .init_hwif = init_hwif_pdc202new, 444 .init_hwif = init_hwif_pdc202new,
448 .channels = 2, 445 .channels = 2,
449 .autodma = AUTODMA, 446 .autodma = AUTODMA,
450#ifndef CONFIG_PDC202XX_FORCE
451 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
452#endif
453 .bootable = OFF_BOARD, 447 .bootable = OFF_BOARD,
454 },{ /* 6 */ 448 },{ /* 6 */
455 .name = "PDC20277", 449 .name = "PDC20277",
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index ad9d95817f95..6f8f8645b02c 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -786,9 +786,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
786 .init_dma = init_dma_pdc202xx, 786 .init_dma = init_dma_pdc202xx,
787 .channels = 2, 787 .channels = 2,
788 .autodma = AUTODMA, 788 .autodma = AUTODMA,
789#ifndef CONFIG_PDC202XX_FORCE
790 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
791#endif
792 .bootable = OFF_BOARD, 789 .bootable = OFF_BOARD,
793 .extra = 16, 790 .extra = 16,
794 },{ /* 1 */ 791 },{ /* 1 */
@@ -799,9 +796,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
799 .init_dma = init_dma_pdc202xx, 796 .init_dma = init_dma_pdc202xx,
800 .channels = 2, 797 .channels = 2,
801 .autodma = AUTODMA, 798 .autodma = AUTODMA,
802#ifndef CONFIG_PDC202XX_FORCE
803 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
804#endif
805 .bootable = OFF_BOARD, 799 .bootable = OFF_BOARD,
806 .extra = 48, 800 .extra = 48,
807 .flags = IDEPCI_FLAG_FORCE_PDC, 801 .flags = IDEPCI_FLAG_FORCE_PDC,
@@ -813,9 +807,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
813 .init_dma = init_dma_pdc202xx, 807 .init_dma = init_dma_pdc202xx,
814 .channels = 2, 808 .channels = 2,
815 .autodma = AUTODMA, 809 .autodma = AUTODMA,
816#ifndef CONFIG_PDC202XX_FORCE
817 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
818#endif
819 .bootable = OFF_BOARD, 810 .bootable = OFF_BOARD,
820 .extra = 48, 811 .extra = 48,
821 },{ /* 3 */ 812 },{ /* 3 */
@@ -826,9 +817,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
826 .init_dma = init_dma_pdc202xx, 817 .init_dma = init_dma_pdc202xx,
827 .channels = 2, 818 .channels = 2,
828 .autodma = AUTODMA, 819 .autodma = AUTODMA,
829#ifndef CONFIG_PDC202XX_FORCE
830 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
831#endif
832 .bootable = OFF_BOARD, 820 .bootable = OFF_BOARD,
833 .extra = 48, 821 .extra = 48,
834 .flags = IDEPCI_FLAG_FORCE_PDC, 822 .flags = IDEPCI_FLAG_FORCE_PDC,
@@ -840,9 +828,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
840 .init_dma = init_dma_pdc202xx, 828 .init_dma = init_dma_pdc202xx,
841 .channels = 2, 829 .channels = 2,
842 .autodma = AUTODMA, 830 .autodma = AUTODMA,
843#ifndef CONFIG_PDC202XX_FORCE
844 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
845#endif
846 .bootable = OFF_BOARD, 831 .bootable = OFF_BOARD,
847 .extra = 48, 832 .extra = 48,
848 } 833 }
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index b3e77df63cef..e9b83e1a3028 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -135,6 +135,7 @@ static u8 piix_ratemask (ide_drive_t *drive)
135 case PCI_DEVICE_ID_INTEL_ICH6_19: 135 case PCI_DEVICE_ID_INTEL_ICH6_19:
136 case PCI_DEVICE_ID_INTEL_ICH7_21: 136 case PCI_DEVICE_ID_INTEL_ICH7_21:
137 case PCI_DEVICE_ID_INTEL_ESB2_18: 137 case PCI_DEVICE_ID_INTEL_ESB2_18:
138 case PCI_DEVICE_ID_INTEL_ICH8_6:
138 mode = 3; 139 mode = 3;
139 break; 140 break;
140 /* UDMA 66 capable */ 141 /* UDMA 66 capable */
@@ -449,6 +450,7 @@ static unsigned int __devinit init_chipset_piix (struct pci_dev *dev, const char
449 case PCI_DEVICE_ID_INTEL_ICH6_19: 450 case PCI_DEVICE_ID_INTEL_ICH6_19:
450 case PCI_DEVICE_ID_INTEL_ICH7_21: 451 case PCI_DEVICE_ID_INTEL_ICH7_21:
451 case PCI_DEVICE_ID_INTEL_ESB2_18: 452 case PCI_DEVICE_ID_INTEL_ESB2_18:
453 case PCI_DEVICE_ID_INTEL_ICH8_6:
452 { 454 {
453 unsigned int extra = 0; 455 unsigned int extra = 0;
454 pci_read_config_dword(dev, 0x54, &extra); 456 pci_read_config_dword(dev, 0x54, &extra);
@@ -575,6 +577,7 @@ static ide_pci_device_t piix_pci_info[] __devinitdata = {
575 /* 21 */ DECLARE_PIIX_DEV("ICH7"), 577 /* 21 */ DECLARE_PIIX_DEV("ICH7"),
576 /* 22 */ DECLARE_PIIX_DEV("ICH4"), 578 /* 22 */ DECLARE_PIIX_DEV("ICH4"),
577 /* 23 */ DECLARE_PIIX_DEV("ESB2"), 579 /* 23 */ DECLARE_PIIX_DEV("ESB2"),
580 /* 24 */ DECLARE_PIIX_DEV("ICH8M"),
578}; 581};
579 582
580/** 583/**
@@ -651,6 +654,7 @@ static struct pci_device_id piix_pci_tbl[] = {
651 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21}, 654 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21},
652 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22}, 655 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22},
653 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 23}, 656 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 23},
657 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 24},
654 { 0, }, 658 { 0, },
655}; 659};
656MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 660MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 4ee597d08797..2b286e865163 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License 5 * under the terms of version 2 of the GNU General Public License
@@ -510,7 +510,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
510 drive->name); 510 drive->name);
511 goto use_pio_instead; 511 goto use_pio_instead;
512 } else { 512 } else {
513 u32 xcount, bcount = 513 u32 bcount =
514 0x10000 - (cur_addr & 0xffff); 514 0x10000 - (cur_addr & 0xffff);
515 515
516 if (bcount > cur_len) 516 if (bcount > cur_len)
@@ -525,8 +525,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
525 *table = 0x0; 525 *table = 0x0;
526 table++; 526 table++;
527 527
528 xcount = bcount & 0xffff; 528 *table = cpu_to_be32(bcount);
529 *table = cpu_to_be32(xcount);
530 table++; 529 table++;
531 530
532 cur_addr += bcount; 531 cur_addr += bcount;
@@ -680,7 +679,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
680 return -EIO; 679 return -EIO;
681 680
682 /* Create /proc/ide entries */ 681 /* Create /proc/ide entries */
683 create_proc_ide_interfaces(); 682 create_proc_ide_interfaces();
684 683
685 return 0; 684 return 0;
686} 685}
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
index 1b85ce166af8..11fe537e2f6f 100644
--- a/drivers/isdn/hisax/hisax.h
+++ b/drivers/isdn/hisax/hisax.h
@@ -216,7 +216,7 @@ struct Layer1 {
216#define GROUP_TEI 127 216#define GROUP_TEI 127
217#define TEI_SAPI 63 217#define TEI_SAPI 63
218#define CTRL_SAPI 0 218#define CTRL_SAPI 0
219#define PACKET_NOACK 250 219#define PACKET_NOACK 7
220 220
221/* Layer2 Flags */ 221/* Layer2 Flags */
222 222
diff --git a/drivers/isdn/sc/ioctl.c b/drivers/isdn/sc/ioctl.c
index 3314a5a19854..94c9afb7017c 100644
--- a/drivers/isdn/sc/ioctl.c
+++ b/drivers/isdn/sc/ioctl.c
@@ -71,14 +71,14 @@ int sc_ioctl(int card, scs_ioctl *data)
71 /* 71 /*
72 * Get the SRec from user space 72 * Get the SRec from user space
73 */ 73 */
74 if (copy_from_user(srec, data->dataptr, sizeof(srec))) { 74 if (copy_from_user(srec, data->dataptr, SCIOC_SRECSIZE)) {
75 kfree(rcvmsg); 75 kfree(rcvmsg);
76 kfree(srec); 76 kfree(srec);
77 return -EFAULT; 77 return -EFAULT;
78 } 78 }
79 79
80 status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc, 80 status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc,
81 0, sizeof(srec), srec, rcvmsg, SAR_TIMEOUT); 81 0, SCIOC_SRECSIZE, srec, rcvmsg, SAR_TIMEOUT);
82 kfree(rcvmsg); 82 kfree(rcvmsg);
83 kfree(srec); 83 kfree(srec);
84 84
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index ed6d3174d660..69596f6438e9 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -140,10 +140,9 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
140{ 140{
141 struct macio_dev * macio_dev; 141 struct macio_dev * macio_dev;
142 struct of_device * of; 142 struct of_device * of;
143 char *scratch, *compat; 143 char *scratch, *compat, *compat2;
144 int i = 0; 144 int i = 0;
145 int length = 0; 145 int length, cplen, cplen2, seen = 0;
146 int cplen, seen = 0;
147 146
148 if (!dev) 147 if (!dev)
149 return -ENODEV; 148 return -ENODEV;
@@ -153,23 +152,22 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
153 return -ENODEV; 152 return -ENODEV;
154 153
155 of = &macio_dev->ofdev; 154 of = &macio_dev->ofdev;
156 scratch = buffer;
157 155
158 /* stuff we want to pass to /sbin/hotplug */ 156 /* stuff we want to pass to /sbin/hotplug */
159 envp[i++] = scratch; 157 envp[i++] = scratch = buffer;
160 length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s", 158 length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
161 of->node->name);
162 if ((buffer_size - length <= 0) || (i >= num_envp))
163 return -ENOMEM;
164 ++length; 159 ++length;
160 buffer_size -= length;
161 if ((buffer_size <= 0) || (i >= num_envp))
162 return -ENOMEM;
165 scratch += length; 163 scratch += length;
166 164
167 envp[i++] = scratch; 165 envp[i++] = scratch;
168 length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s", 166 length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
169 of->node->type);
170 if ((buffer_size - length <= 0) || (i >= num_envp))
171 return -ENOMEM;
172 ++length; 167 ++length;
168 buffer_size -= length;
169 if ((buffer_size <= 0) || (i >= num_envp))
170 return -ENOMEM;
173 scratch += length; 171 scratch += length;
174 172
175 /* Since the compatible field can contain pretty much anything 173 /* Since the compatible field can contain pretty much anything
@@ -177,29 +175,55 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
177 * up using a number of environment variables instead. */ 175 * up using a number of environment variables instead. */
178 176
179 compat = (char *) get_property(of->node, "compatible", &cplen); 177 compat = (char *) get_property(of->node, "compatible", &cplen);
178 compat2 = compat;
179 cplen2= cplen;
180 while (compat && cplen > 0) { 180 while (compat && cplen > 0) {
181 int l;
182 envp[i++] = scratch; 181 envp[i++] = scratch;
183 length += scnprintf (scratch, buffer_size - length, 182 length = scnprintf (scratch, buffer_size,
184 "OF_COMPATIBLE_%d=%s", seen, compat); 183 "OF_COMPATIBLE_%d=%s", seen, compat);
185 if ((buffer_size - length <= 0) || (i >= num_envp)) 184 ++length;
185 buffer_size -= length;
186 if ((buffer_size <= 0) || (i >= num_envp))
186 return -ENOMEM; 187 return -ENOMEM;
187 length++;
188 scratch += length; 188 scratch += length;
189 l = strlen (compat) + 1; 189 length = strlen (compat) + 1;
190 compat += l; 190 compat += length;
191 cplen -= l; 191 cplen -= length;
192 seen++; 192 seen++;
193 } 193 }
194 194
195 envp[i++] = scratch; 195 envp[i++] = scratch;
196 length += scnprintf (scratch, buffer_size - length, 196 length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
197 "OF_COMPATIBLE_N=%d", seen);
198 if ((buffer_size - length <= 0) || (i >= num_envp))
199 return -ENOMEM;
200 ++length; 197 ++length;
198 buffer_size -= length;
199 if ((buffer_size <= 0) || (i >= num_envp))
200 return -ENOMEM;
201 scratch += length;
202
203 envp[i++] = scratch;
204 length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
205 of->node->name, of->node->type);
206 /* overwrite '\0' */
207 buffer_size -= length;
208 if ((buffer_size <= 0) || (i >= num_envp))
209 return -ENOMEM;
201 scratch += length; 210 scratch += length;
202 211
212 if (!compat2) {
213 compat2 = "";
214 cplen2 = 1;
215 }
216 while (cplen2 > 0) {
217 length = snprintf (scratch, buffer_size, "C%s", compat2);
218 buffer_size -= length;
219 if (buffer_size <= 0)
220 return -ENOMEM;
221 scratch += length;
222 length = strlen (compat2) + 1;
223 compat2 += length;
224 cplen2 -= length;
225 }
226
203 envp[i] = NULL; 227 envp[i] = NULL;
204 228
205 return 0; 229 return 0;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 1235135b384b..442e2be6052e 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1359,16 +1359,11 @@ static int ctl_ioctl(struct inode *inode, struct file *file,
1359 * Copy the parameters into kernel space. 1359 * Copy the parameters into kernel space.
1360 */ 1360 */
1361 r = copy_params(user, &param); 1361 r = copy_params(user, &param);
1362 if (r) {
1363 current->flags &= ~PF_MEMALLOC;
1364 return r;
1365 }
1366 1362
1367 /* 1363 current->flags &= ~PF_MEMALLOC;
1368 * FIXME: eventually we will remove the PF_MEMALLOC flag 1364
1369 * here. However the tools still do nasty things like 1365 if (r)
1370 * 'load' while a device is suspended. 1366 return r;
1371 */
1372 1367
1373 r = validate_params(cmd, param); 1368 r = validate_params(cmd, param);
1374 if (r) 1369 if (r)
@@ -1386,7 +1381,6 @@ static int ctl_ioctl(struct inode *inode, struct file *file,
1386 1381
1387 out: 1382 out:
1388 free_params(param); 1383 free_params(param);
1389 current->flags &= ~PF_MEMALLOC;
1390 return r; 1384 return r;
1391} 1385}
1392 1386
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index efe4adf78530..d73779a42417 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -112,7 +112,7 @@ void dm_destroy_dirty_log(struct dirty_log *log)
112/* 112/*
113 * The on-disk version of the metadata. 113 * The on-disk version of the metadata.
114 */ 114 */
115#define MIRROR_DISK_VERSION 1 115#define MIRROR_DISK_VERSION 2
116#define LOG_OFFSET 2 116#define LOG_OFFSET 2
117 117
118struct log_header { 118struct log_header {
@@ -157,7 +157,6 @@ struct log_c {
157 struct log_header *disk_header; 157 struct log_header *disk_header;
158 158
159 struct io_region bits_location; 159 struct io_region bits_location;
160 uint32_t *disk_bits;
161}; 160};
162 161
163/* 162/*
@@ -166,20 +165,20 @@ struct log_c {
166 */ 165 */
167static inline int log_test_bit(uint32_t *bs, unsigned bit) 166static inline int log_test_bit(uint32_t *bs, unsigned bit)
168{ 167{
169 return test_bit(bit, (unsigned long *) bs) ? 1 : 0; 168 return ext2_test_bit(bit, (unsigned long *) bs) ? 1 : 0;
170} 169}
171 170
172static inline void log_set_bit(struct log_c *l, 171static inline void log_set_bit(struct log_c *l,
173 uint32_t *bs, unsigned bit) 172 uint32_t *bs, unsigned bit)
174{ 173{
175 set_bit(bit, (unsigned long *) bs); 174 ext2_set_bit(bit, (unsigned long *) bs);
176 l->touched = 1; 175 l->touched = 1;
177} 176}
178 177
179static inline void log_clear_bit(struct log_c *l, 178static inline void log_clear_bit(struct log_c *l,
180 uint32_t *bs, unsigned bit) 179 uint32_t *bs, unsigned bit)
181{ 180{
182 clear_bit(bit, (unsigned long *) bs); 181 ext2_clear_bit(bit, (unsigned long *) bs);
183 l->touched = 1; 182 l->touched = 1;
184} 183}
185 184
@@ -219,6 +218,11 @@ static int read_header(struct log_c *log)
219 log->header.nr_regions = 0; 218 log->header.nr_regions = 0;
220 } 219 }
221 220
221#ifdef __LITTLE_ENDIAN
222 if (log->header.version == 1)
223 log->header.version = 2;
224#endif
225
222 if (log->header.version != MIRROR_DISK_VERSION) { 226 if (log->header.version != MIRROR_DISK_VERSION) {
223 DMWARN("incompatible disk log version"); 227 DMWARN("incompatible disk log version");
224 return -EINVAL; 228 return -EINVAL;
@@ -239,45 +243,24 @@ static inline int write_header(struct log_c *log)
239/*---------------------------------------------------------------- 243/*----------------------------------------------------------------
240 * Bits IO 244 * Bits IO
241 *--------------------------------------------------------------*/ 245 *--------------------------------------------------------------*/
242static inline void bits_to_core(uint32_t *core, uint32_t *disk, unsigned count)
243{
244 unsigned i;
245
246 for (i = 0; i < count; i++)
247 core[i] = le32_to_cpu(disk[i]);
248}
249
250static inline void bits_to_disk(uint32_t *core, uint32_t *disk, unsigned count)
251{
252 unsigned i;
253
254 /* copy across the clean/dirty bitset */
255 for (i = 0; i < count; i++)
256 disk[i] = cpu_to_le32(core[i]);
257}
258
259static int read_bits(struct log_c *log) 246static int read_bits(struct log_c *log)
260{ 247{
261 int r; 248 int r;
262 unsigned long ebits; 249 unsigned long ebits;
263 250
264 r = dm_io_sync_vm(1, &log->bits_location, READ, 251 r = dm_io_sync_vm(1, &log->bits_location, READ,
265 log->disk_bits, &ebits); 252 log->clean_bits, &ebits);
266 if (r) 253 if (r)
267 return r; 254 return r;
268 255
269 bits_to_core(log->clean_bits, log->disk_bits,
270 log->bitset_uint32_count);
271 return 0; 256 return 0;
272} 257}
273 258
274static int write_bits(struct log_c *log) 259static int write_bits(struct log_c *log)
275{ 260{
276 unsigned long ebits; 261 unsigned long ebits;
277 bits_to_disk(log->clean_bits, log->disk_bits,
278 log->bitset_uint32_count);
279 return dm_io_sync_vm(1, &log->bits_location, WRITE, 262 return dm_io_sync_vm(1, &log->bits_location, WRITE,
280 log->disk_bits, &ebits); 263 log->clean_bits, &ebits);
281} 264}
282 265
283/*---------------------------------------------------------------- 266/*----------------------------------------------------------------
@@ -433,11 +416,6 @@ static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
433 size = dm_round_up(lc->bitset_uint32_count * sizeof(uint32_t), 416 size = dm_round_up(lc->bitset_uint32_count * sizeof(uint32_t),
434 1 << SECTOR_SHIFT); 417 1 << SECTOR_SHIFT);
435 lc->bits_location.count = size >> SECTOR_SHIFT; 418 lc->bits_location.count = size >> SECTOR_SHIFT;
436 lc->disk_bits = vmalloc(size);
437 if (!lc->disk_bits) {
438 vfree(lc->disk_header);
439 goto bad;
440 }
441 return 0; 419 return 0;
442 420
443 bad: 421 bad:
@@ -451,7 +429,6 @@ static void disk_dtr(struct dirty_log *log)
451 struct log_c *lc = (struct log_c *) log->context; 429 struct log_c *lc = (struct log_c *) log->context;
452 dm_put_device(lc->ti, lc->log_dev); 430 dm_put_device(lc->ti, lc->log_dev);
453 vfree(lc->disk_header); 431 vfree(lc->disk_header);
454 vfree(lc->disk_bits);
455 core_dtr(log); 432 core_dtr(log);
456} 433}
457 434
@@ -568,7 +545,8 @@ static int core_get_resync_work(struct dirty_log *log, region_t *region)
568 return 0; 545 return 0;
569 546
570 do { 547 do {
571 *region = find_next_zero_bit((unsigned long *) lc->sync_bits, 548 *region = ext2_find_next_zero_bit(
549 (unsigned long *) lc->sync_bits,
572 lc->region_count, 550 lc->region_count,
573 lc->sync_search); 551 lc->sync_search);
574 lc->sync_search = *region + 1; 552 lc->sync_search = *region + 1;
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 87727d84dbba..f3759dd7828e 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -373,16 +373,11 @@ static inline ulong round_up(ulong n, ulong size)
373 373
374static void read_snapshot_metadata(struct dm_snapshot *s) 374static void read_snapshot_metadata(struct dm_snapshot *s)
375{ 375{
376 if (s->have_metadata)
377 return;
378
379 if (s->store.read_metadata(&s->store)) { 376 if (s->store.read_metadata(&s->store)) {
380 down_write(&s->lock); 377 down_write(&s->lock);
381 s->valid = 0; 378 s->valid = 0;
382 up_write(&s->lock); 379 up_write(&s->lock);
383 } 380 }
384
385 s->have_metadata = 1;
386} 381}
387 382
388/* 383/*
@@ -471,7 +466,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
471 s->chunk_shift = ffs(chunk_size) - 1; 466 s->chunk_shift = ffs(chunk_size) - 1;
472 467
473 s->valid = 1; 468 s->valid = 1;
474 s->have_metadata = 0; 469 s->active = 0;
475 s->last_percent = 0; 470 s->last_percent = 0;
476 init_rwsem(&s->lock); 471 init_rwsem(&s->lock);
477 s->table = ti->table; 472 s->table = ti->table;
@@ -506,7 +501,11 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
506 goto bad5; 501 goto bad5;
507 } 502 }
508 503
504 /* Metadata must only be loaded into one table at once */
505 read_snapshot_metadata(s);
506
509 /* Add snapshot to the list of snapshots for this origin */ 507 /* Add snapshot to the list of snapshots for this origin */
508 /* Exceptions aren't triggered till snapshot_resume() is called */
510 if (register_snapshot(s)) { 509 if (register_snapshot(s)) {
511 r = -EINVAL; 510 r = -EINVAL;
512 ti->error = "Cannot register snapshot origin"; 511 ti->error = "Cannot register snapshot origin";
@@ -793,6 +792,9 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
793 if (!s->valid) 792 if (!s->valid)
794 return -EIO; 793 return -EIO;
795 794
795 if (unlikely(bio_barrier(bio)))
796 return -EOPNOTSUPP;
797
796 /* 798 /*
797 * Write to snapshot - higher level takes care of RW/RO 799 * Write to snapshot - higher level takes care of RW/RO
798 * flags so we should only get this if we are 800 * flags so we should only get this if we are
@@ -862,7 +864,9 @@ static void snapshot_resume(struct dm_target *ti)
862{ 864{
863 struct dm_snapshot *s = (struct dm_snapshot *) ti->private; 865 struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
864 866
865 read_snapshot_metadata(s); 867 down_write(&s->lock);
868 s->active = 1;
869 up_write(&s->lock);
866} 870}
867 871
868static int snapshot_status(struct dm_target *ti, status_type_t type, 872static int snapshot_status(struct dm_target *ti, status_type_t type,
@@ -932,8 +936,8 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
932 /* Do all the snapshots on this origin */ 936 /* Do all the snapshots on this origin */
933 list_for_each_entry (snap, snapshots, list) { 937 list_for_each_entry (snap, snapshots, list) {
934 938
935 /* Only deal with valid snapshots */ 939 /* Only deal with valid and active snapshots */
936 if (!snap->valid) 940 if (!snap->valid || !snap->active)
937 continue; 941 continue;
938 942
939 /* Nothing to do if writing beyond end of snapshot */ 943 /* Nothing to do if writing beyond end of snapshot */
@@ -1057,6 +1061,9 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
1057 struct dm_dev *dev = (struct dm_dev *) ti->private; 1061 struct dm_dev *dev = (struct dm_dev *) ti->private;
1058 bio->bi_bdev = dev->bdev; 1062 bio->bi_bdev = dev->bdev;
1059 1063
1064 if (unlikely(bio_barrier(bio)))
1065 return -EOPNOTSUPP;
1066
1060 /* Only tell snapshots if this is a write */ 1067 /* Only tell snapshots if this is a write */
1061 return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1; 1068 return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1;
1062} 1069}
@@ -1104,7 +1111,7 @@ static int origin_status(struct dm_target *ti, status_type_t type, char *result,
1104 1111
1105static struct target_type origin_target = { 1112static struct target_type origin_target = {
1106 .name = "snapshot-origin", 1113 .name = "snapshot-origin",
1107 .version = {1, 0, 1}, 1114 .version = {1, 1, 0},
1108 .module = THIS_MODULE, 1115 .module = THIS_MODULE,
1109 .ctr = origin_ctr, 1116 .ctr = origin_ctr,
1110 .dtr = origin_dtr, 1117 .dtr = origin_dtr,
@@ -1115,7 +1122,7 @@ static struct target_type origin_target = {
1115 1122
1116static struct target_type snapshot_target = { 1123static struct target_type snapshot_target = {
1117 .name = "snapshot", 1124 .name = "snapshot",
1118 .version = {1, 0, 1}, 1125 .version = {1, 1, 0},
1119 .module = THIS_MODULE, 1126 .module = THIS_MODULE,
1120 .ctr = snapshot_ctr, 1127 .ctr = snapshot_ctr,
1121 .dtr = snapshot_dtr, 1128 .dtr = snapshot_dtr,
diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h
index 375aa24d4d7d..fdec1e2dc871 100644
--- a/drivers/md/dm-snap.h
+++ b/drivers/md/dm-snap.h
@@ -99,7 +99,9 @@ struct dm_snapshot {
99 99
100 /* You can't use a snapshot if this is 0 (e.g. if full) */ 100 /* You can't use a snapshot if this is 0 (e.g. if full) */
101 int valid; 101 int valid;
102 int have_metadata; 102
103 /* Origin writes don't trigger exceptions until this is set */
104 int active;
103 105
104 /* Used for display of table */ 106 /* Used for display of table */
105 char type; 107 char type;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a6f2dc66c3db..9b1e2f5ca630 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -508,7 +508,7 @@ int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
508 if (q->merge_bvec_fn) 508 if (q->merge_bvec_fn)
509 rs->max_sectors = 509 rs->max_sectors =
510 min_not_zero(rs->max_sectors, 510 min_not_zero(rs->max_sectors,
511 (unsigned short)(PAGE_SIZE >> 9)); 511 (unsigned int) (PAGE_SIZE >> 9));
512 512
513 rs->max_phys_segments = 513 rs->max_phys_segments =
514 min_not_zero(rs->max_phys_segments, 514 min_not_zero(rs->max_phys_segments,
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8c16359f8b01..e9adeb9d172f 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -31,6 +31,7 @@ struct dm_io {
31 int error; 31 int error;
32 struct bio *bio; 32 struct bio *bio;
33 atomic_t io_count; 33 atomic_t io_count;
34 unsigned long start_time;
34}; 35};
35 36
36/* 37/*
@@ -244,6 +245,36 @@ static inline void free_tio(struct mapped_device *md, struct target_io *tio)
244 mempool_free(tio, md->tio_pool); 245 mempool_free(tio, md->tio_pool);
245} 246}
246 247
248static void start_io_acct(struct dm_io *io)
249{
250 struct mapped_device *md = io->md;
251
252 io->start_time = jiffies;
253
254 preempt_disable();
255 disk_round_stats(dm_disk(md));
256 preempt_enable();
257 dm_disk(md)->in_flight = atomic_inc_return(&md->pending);
258}
259
260static int end_io_acct(struct dm_io *io)
261{
262 struct mapped_device *md = io->md;
263 struct bio *bio = io->bio;
264 unsigned long duration = jiffies - io->start_time;
265 int pending;
266 int rw = bio_data_dir(bio);
267
268 preempt_disable();
269 disk_round_stats(dm_disk(md));
270 preempt_enable();
271 dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending);
272
273 disk_stat_add(dm_disk(md), ticks[rw], duration);
274
275 return !pending;
276}
277
247/* 278/*
248 * Add the bio to the list of deferred io. 279 * Add the bio to the list of deferred io.
249 */ 280 */
@@ -299,7 +330,7 @@ static void dec_pending(struct dm_io *io, int error)
299 io->error = error; 330 io->error = error;
300 331
301 if (atomic_dec_and_test(&io->io_count)) { 332 if (atomic_dec_and_test(&io->io_count)) {
302 if (atomic_dec_and_test(&io->md->pending)) 333 if (end_io_acct(io))
303 /* nudge anyone waiting on suspend queue */ 334 /* nudge anyone waiting on suspend queue */
304 wake_up(&io->md->wait); 335 wake_up(&io->md->wait);
305 336
@@ -554,7 +585,7 @@ static void __split_bio(struct mapped_device *md, struct bio *bio)
554 ci.sector_count = bio_sectors(bio); 585 ci.sector_count = bio_sectors(bio);
555 ci.idx = bio->bi_idx; 586 ci.idx = bio->bi_idx;
556 587
557 atomic_inc(&md->pending); 588 start_io_acct(ci.io);
558 while (ci.sector_count) 589 while (ci.sector_count)
559 __clone_and_map(&ci); 590 __clone_and_map(&ci);
560 591
@@ -573,10 +604,14 @@ static void __split_bio(struct mapped_device *md, struct bio *bio)
573static int dm_request(request_queue_t *q, struct bio *bio) 604static int dm_request(request_queue_t *q, struct bio *bio)
574{ 605{
575 int r; 606 int r;
607 int rw = bio_data_dir(bio);
576 struct mapped_device *md = q->queuedata; 608 struct mapped_device *md = q->queuedata;
577 609
578 down_read(&md->io_lock); 610 down_read(&md->io_lock);
579 611
612 disk_stat_inc(dm_disk(md), ios[rw]);
613 disk_stat_add(dm_disk(md), sectors[rw], bio_sectors(bio));
614
580 /* 615 /*
581 * If we're suspended we have to queue 616 * If we're suspended we have to queue
582 * this io for later. 617 * this io for later.
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7145cd150f7b..d05e3125d298 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1024,7 +1024,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1024 rdev-> sb_size = (rdev->sb_size | bmask)+1; 1024 rdev-> sb_size = (rdev->sb_size | bmask)+1;
1025 1025
1026 if (refdev == 0) 1026 if (refdev == 0)
1027 return 1; 1027 ret = 1;
1028 else { 1028 else {
1029 __u64 ev1, ev2; 1029 __u64 ev1, ev2;
1030 struct mdp_superblock_1 *refsb = 1030 struct mdp_superblock_1 *refsb =
@@ -1044,7 +1044,9 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1044 ev2 = le64_to_cpu(refsb->events); 1044 ev2 = le64_to_cpu(refsb->events);
1045 1045
1046 if (ev1 > ev2) 1046 if (ev1 > ev2)
1047 return 1; 1047 ret = 1;
1048 else
1049 ret = 0;
1048 } 1050 }
1049 if (minor_version) 1051 if (minor_version)
1050 rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2; 1052 rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2;
@@ -1058,7 +1060,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1058 1060
1059 if (le32_to_cpu(sb->size) > rdev->size*2) 1061 if (le32_to_cpu(sb->size) > rdev->size*2)
1060 return -EINVAL; 1062 return -EINVAL;
1061 return 0; 1063 return ret;
1062} 1064}
1063 1065
1064static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) 1066static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
@@ -1081,7 +1083,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1081 mddev->size = le64_to_cpu(sb->size)/2; 1083 mddev->size = le64_to_cpu(sb->size)/2;
1082 mddev->events = le64_to_cpu(sb->events); 1084 mddev->events = le64_to_cpu(sb->events);
1083 mddev->bitmap_offset = 0; 1085 mddev->bitmap_offset = 0;
1084 mddev->default_bitmap_offset = 1024; 1086 mddev->default_bitmap_offset = 1024 >> 9;
1085 1087
1086 mddev->recovery_cp = le64_to_cpu(sb->resync_offset); 1088 mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
1087 memcpy(mddev->uuid, sb->set_uuid, 16); 1089 memcpy(mddev->uuid, sb->set_uuid, 16);
@@ -1161,6 +1163,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1161 1163
1162 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1164 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors);
1163 1165
1166 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1167 sb->size = cpu_to_le64(mddev->size<<1);
1168
1164 if (mddev->bitmap && mddev->bitmap_file == NULL) { 1169 if (mddev->bitmap && mddev->bitmap_file == NULL) {
1165 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); 1170 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
1166 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); 1171 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
@@ -2686,14 +2691,6 @@ static int do_md_stop(mddev_t * mddev, int ro)
2686 set_disk_ro(disk, 1); 2691 set_disk_ro(disk, 1);
2687 } 2692 }
2688 2693
2689 bitmap_destroy(mddev);
2690 if (mddev->bitmap_file) {
2691 atomic_set(&mddev->bitmap_file->f_dentry->d_inode->i_writecount, 1);
2692 fput(mddev->bitmap_file);
2693 mddev->bitmap_file = NULL;
2694 }
2695 mddev->bitmap_offset = 0;
2696
2697 /* 2694 /*
2698 * Free resources if final stop 2695 * Free resources if final stop
2699 */ 2696 */
@@ -2703,6 +2700,14 @@ static int do_md_stop(mddev_t * mddev, int ro)
2703 struct gendisk *disk; 2700 struct gendisk *disk;
2704 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 2701 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
2705 2702
2703 bitmap_destroy(mddev);
2704 if (mddev->bitmap_file) {
2705 atomic_set(&mddev->bitmap_file->f_dentry->d_inode->i_writecount, 1);
2706 fput(mddev->bitmap_file);
2707 mddev->bitmap_file = NULL;
2708 }
2709 mddev->bitmap_offset = 0;
2710
2706 ITERATE_RDEV(mddev,rdev,tmp) 2711 ITERATE_RDEV(mddev,rdev,tmp)
2707 if (rdev->raid_disk >= 0) { 2712 if (rdev->raid_disk >= 0) {
2708 char nm[20]; 2713 char nm[20];
@@ -2939,6 +2944,8 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
2939 info.ctime = mddev->ctime; 2944 info.ctime = mddev->ctime;
2940 info.level = mddev->level; 2945 info.level = mddev->level;
2941 info.size = mddev->size; 2946 info.size = mddev->size;
2947 if (info.size != mddev->size) /* overflow */
2948 info.size = -1;
2942 info.nr_disks = nr; 2949 info.nr_disks = nr;
2943 info.raid_disks = mddev->raid_disks; 2950 info.raid_disks = mddev->raid_disks;
2944 info.md_minor = mddev->md_minor; 2951 info.md_minor = mddev->md_minor;
@@ -3465,7 +3472,7 @@ static int update_size(mddev_t *mddev, unsigned long size)
3465 bdev = bdget_disk(mddev->gendisk, 0); 3472 bdev = bdget_disk(mddev->gendisk, 0);
3466 if (bdev) { 3473 if (bdev) {
3467 mutex_lock(&bdev->bd_inode->i_mutex); 3474 mutex_lock(&bdev->bd_inode->i_mutex);
3468 i_size_write(bdev->bd_inode, mddev->array_size << 10); 3475 i_size_write(bdev->bd_inode, (loff_t)mddev->array_size << 10);
3469 mutex_unlock(&bdev->bd_inode->i_mutex); 3476 mutex_unlock(&bdev->bd_inode->i_mutex);
3470 bdput(bdev); 3477 bdput(bdev);
3471 } 3478 }
@@ -3485,17 +3492,6 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks)
3485 if (mddev->sync_thread) 3492 if (mddev->sync_thread)
3486 return -EBUSY; 3493 return -EBUSY;
3487 rv = mddev->pers->reshape(mddev, raid_disks); 3494 rv = mddev->pers->reshape(mddev, raid_disks);
3488 if (!rv) {
3489 struct block_device *bdev;
3490
3491 bdev = bdget_disk(mddev->gendisk, 0);
3492 if (bdev) {
3493 mutex_lock(&bdev->bd_inode->i_mutex);
3494 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3495 mutex_unlock(&bdev->bd_inode->i_mutex);
3496 bdput(bdev);
3497 }
3498 }
3499 return rv; 3495 return rv;
3500} 3496}
3501 3497
@@ -3531,7 +3527,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
3531 ) 3527 )
3532 return -EINVAL; 3528 return -EINVAL;
3533 /* Check there is only one change */ 3529 /* Check there is only one change */
3534 if (mddev->size != info->size) cnt++; 3530 if (info->size >= 0 && mddev->size != info->size) cnt++;
3535 if (mddev->raid_disks != info->raid_disks) cnt++; 3531 if (mddev->raid_disks != info->raid_disks) cnt++;
3536 if (mddev->layout != info->layout) cnt++; 3532 if (mddev->layout != info->layout) cnt++;
3537 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++; 3533 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++;
@@ -3548,7 +3544,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
3548 else 3544 else
3549 return mddev->pers->reconfig(mddev, info->layout, -1); 3545 return mddev->pers->reconfig(mddev, info->layout, -1);
3550 } 3546 }
3551 if (mddev->size != info->size) 3547 if (info->size >= 0 && mddev->size != info->size)
3552 rv = update_size(mddev, info->size); 3548 rv = update_size(mddev, info->size);
3553 3549
3554 if (mddev->raid_disks != info->raid_disks) 3550 if (mddev->raid_disks != info->raid_disks)
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index d03f99cf4b7d..678f4dbbea1d 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -372,7 +372,7 @@ out_free_conf:
372 kfree(conf); 372 kfree(conf);
373 mddev->private = NULL; 373 mddev->private = NULL;
374out: 374out:
375 return 1; 375 return -ENOMEM;
376} 376}
377 377
378static int raid0_stop (mddev_t *mddev) 378static int raid0_stop (mddev_t *mddev)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 9130d051b474..ab90a6d12020 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -565,6 +565,8 @@ rb_out:
565 565
566 if (disk >= 0 && (rdev=rcu_dereference(conf->mirrors[disk].rdev))!= NULL) 566 if (disk >= 0 && (rdev=rcu_dereference(conf->mirrors[disk].rdev))!= NULL)
567 atomic_inc(&conf->mirrors[disk].rdev->nr_pending); 567 atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
568 else
569 disk = -1;
568 rcu_read_unlock(); 570 rcu_read_unlock();
569 571
570 return disk; 572 return disk;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 25976bfb6f9c..2dba305daf3c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -350,7 +350,8 @@ static void shrink_stripes(raid5_conf_t *conf)
350 while (drop_one_stripe(conf)) 350 while (drop_one_stripe(conf))
351 ; 351 ;
352 352
353 kmem_cache_destroy(conf->slab_cache); 353 if (conf->slab_cache)
354 kmem_cache_destroy(conf->slab_cache);
354 conf->slab_cache = NULL; 355 conf->slab_cache = NULL;
355} 356}
356 357
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index f618a53b98be..cd477ebf2ee4 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -115,7 +115,7 @@ static void __release_stripe(raid6_conf_t *conf, struct stripe_head *sh)
115 list_add_tail(&sh->lru, &conf->inactive_list); 115 list_add_tail(&sh->lru, &conf->inactive_list);
116 atomic_dec(&conf->active_stripes); 116 atomic_dec(&conf->active_stripes);
117 if (!conf->inactive_blocked || 117 if (!conf->inactive_blocked ||
118 atomic_read(&conf->active_stripes) < (NR_STRIPES*3/4)) 118 atomic_read(&conf->active_stripes) < (conf->max_nr_stripes*3/4))
119 wake_up(&conf->wait_for_stripe); 119 wake_up(&conf->wait_for_stripe);
120 } 120 }
121 } 121 }
@@ -273,7 +273,8 @@ static struct stripe_head *get_active_stripe(raid6_conf_t *conf, sector_t sector
273 conf->inactive_blocked = 1; 273 conf->inactive_blocked = 1;
274 wait_event_lock_irq(conf->wait_for_stripe, 274 wait_event_lock_irq(conf->wait_for_stripe,
275 !list_empty(&conf->inactive_list) && 275 !list_empty(&conf->inactive_list) &&
276 (atomic_read(&conf->active_stripes) < (NR_STRIPES *3/4) 276 (atomic_read(&conf->active_stripes)
277 < (conf->max_nr_stripes *3/4)
277 || !conf->inactive_blocked), 278 || !conf->inactive_blocked),
278 conf->device_lock, 279 conf->device_lock,
279 unplug_slaves(conf->mddev); 280 unplug_slaves(conf->mddev);
@@ -302,9 +303,31 @@ static struct stripe_head *get_active_stripe(raid6_conf_t *conf, sector_t sector
302 return sh; 303 return sh;
303} 304}
304 305
305static int grow_stripes(raid6_conf_t *conf, int num) 306static int grow_one_stripe(raid6_conf_t *conf)
306{ 307{
307 struct stripe_head *sh; 308 struct stripe_head *sh;
309 sh = kmem_cache_alloc(conf->slab_cache, GFP_KERNEL);
310 if (!sh)
311 return 0;
312 memset(sh, 0, sizeof(*sh) + (conf->raid_disks-1)*sizeof(struct r5dev));
313 sh->raid_conf = conf;
314 spin_lock_init(&sh->lock);
315
316 if (grow_buffers(sh, conf->raid_disks)) {
317 shrink_buffers(sh, conf->raid_disks);
318 kmem_cache_free(conf->slab_cache, sh);
319 return 0;
320 }
321 /* we just created an active stripe so... */
322 atomic_set(&sh->count, 1);
323 atomic_inc(&conf->active_stripes);
324 INIT_LIST_HEAD(&sh->lru);
325 release_stripe(sh);
326 return 1;
327}
328
329static int grow_stripes(raid6_conf_t *conf, int num)
330{
308 kmem_cache_t *sc; 331 kmem_cache_t *sc;
309 int devs = conf->raid_disks; 332 int devs = conf->raid_disks;
310 333
@@ -316,45 +339,35 @@ static int grow_stripes(raid6_conf_t *conf, int num)
316 if (!sc) 339 if (!sc)
317 return 1; 340 return 1;
318 conf->slab_cache = sc; 341 conf->slab_cache = sc;
319 while (num--) { 342 while (num--)
320 sh = kmem_cache_alloc(sc, GFP_KERNEL); 343 if (!grow_one_stripe(conf))
321 if (!sh)
322 return 1;
323 memset(sh, 0, sizeof(*sh) + (devs-1)*sizeof(struct r5dev));
324 sh->raid_conf = conf;
325 spin_lock_init(&sh->lock);
326
327 if (grow_buffers(sh, conf->raid_disks)) {
328 shrink_buffers(sh, conf->raid_disks);
329 kmem_cache_free(sc, sh);
330 return 1; 344 return 1;
331 }
332 /* we just created an active stripe so... */
333 atomic_set(&sh->count, 1);
334 atomic_inc(&conf->active_stripes);
335 INIT_LIST_HEAD(&sh->lru);
336 release_stripe(sh);
337 }
338 return 0; 345 return 0;
339} 346}
340 347
341static void shrink_stripes(raid6_conf_t *conf) 348static int drop_one_stripe(raid6_conf_t *conf)
342{ 349{
343 struct stripe_head *sh; 350 struct stripe_head *sh;
351 spin_lock_irq(&conf->device_lock);
352 sh = get_free_stripe(conf);
353 spin_unlock_irq(&conf->device_lock);
354 if (!sh)
355 return 0;
356 if (atomic_read(&sh->count))
357 BUG();
358 shrink_buffers(sh, conf->raid_disks);
359 kmem_cache_free(conf->slab_cache, sh);
360 atomic_dec(&conf->active_stripes);
361 return 1;
362}
344 363
345 while (1) { 364static void shrink_stripes(raid6_conf_t *conf)
346 spin_lock_irq(&conf->device_lock); 365{
347 sh = get_free_stripe(conf); 366 while (drop_one_stripe(conf))
348 spin_unlock_irq(&conf->device_lock); 367 ;
349 if (!sh) 368
350 break; 369 if (conf->slab_cache)
351 if (atomic_read(&sh->count)) 370 kmem_cache_destroy(conf->slab_cache);
352 BUG();
353 shrink_buffers(sh, conf->raid_disks);
354 kmem_cache_free(conf->slab_cache, sh);
355 atomic_dec(&conf->active_stripes);
356 }
357 kmem_cache_destroy(conf->slab_cache);
358 conf->slab_cache = NULL; 371 conf->slab_cache = NULL;
359} 372}
360 373
@@ -1912,6 +1925,74 @@ static void raid6d (mddev_t *mddev)
1912 PRINTK("--- raid6d inactive\n"); 1925 PRINTK("--- raid6d inactive\n");
1913} 1926}
1914 1927
1928static ssize_t
1929raid6_show_stripe_cache_size(mddev_t *mddev, char *page)
1930{
1931 raid6_conf_t *conf = mddev_to_conf(mddev);
1932 if (conf)
1933 return sprintf(page, "%d\n", conf->max_nr_stripes);
1934 else
1935 return 0;
1936}
1937
1938static ssize_t
1939raid6_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
1940{
1941 raid6_conf_t *conf = mddev_to_conf(mddev);
1942 char *end;
1943 int new;
1944 if (len >= PAGE_SIZE)
1945 return -EINVAL;
1946 if (!conf)
1947 return -ENODEV;
1948
1949 new = simple_strtoul(page, &end, 10);
1950 if (!*page || (*end && *end != '\n') )
1951 return -EINVAL;
1952 if (new <= 16 || new > 32768)
1953 return -EINVAL;
1954 while (new < conf->max_nr_stripes) {
1955 if (drop_one_stripe(conf))
1956 conf->max_nr_stripes--;
1957 else
1958 break;
1959 }
1960 while (new > conf->max_nr_stripes) {
1961 if (grow_one_stripe(conf))
1962 conf->max_nr_stripes++;
1963 else break;
1964 }
1965 return len;
1966}
1967
1968static struct md_sysfs_entry
1969raid6_stripecache_size = __ATTR(stripe_cache_size, S_IRUGO | S_IWUSR,
1970 raid6_show_stripe_cache_size,
1971 raid6_store_stripe_cache_size);
1972
1973static ssize_t
1974stripe_cache_active_show(mddev_t *mddev, char *page)
1975{
1976 raid6_conf_t *conf = mddev_to_conf(mddev);
1977 if (conf)
1978 return sprintf(page, "%d\n", atomic_read(&conf->active_stripes));
1979 else
1980 return 0;
1981}
1982
1983static struct md_sysfs_entry
1984raid6_stripecache_active = __ATTR_RO(stripe_cache_active);
1985
1986static struct attribute *raid6_attrs[] = {
1987 &raid6_stripecache_size.attr,
1988 &raid6_stripecache_active.attr,
1989 NULL,
1990};
1991static struct attribute_group raid6_attrs_group = {
1992 .name = NULL,
1993 .attrs = raid6_attrs,
1994};
1995
1915static int run(mddev_t *mddev) 1996static int run(mddev_t *mddev)
1916{ 1997{
1917 raid6_conf_t *conf; 1998 raid6_conf_t *conf;
@@ -2095,6 +2176,7 @@ static int stop (mddev_t *mddev)
2095 shrink_stripes(conf); 2176 shrink_stripes(conf);
2096 kfree(conf->stripe_hashtbl); 2177 kfree(conf->stripe_hashtbl);
2097 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 2178 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
2179 sysfs_remove_group(&mddev->kobj, &raid6_attrs_group);
2098 kfree(conf); 2180 kfree(conf);
2099 mddev->private = NULL; 2181 mddev->private = NULL;
2100 return 0; 2182 return 0;
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
index 0b6c2096ec66..aad4a18aafd6 100644
--- a/drivers/media/video/hexium_orion.c
+++ b/drivers/media/video/hexium_orion.c
@@ -484,7 +484,7 @@ static struct saa7146_ext_vv vv_data = {
484}; 484};
485 485
486static struct saa7146_extension extension = { 486static struct saa7146_extension extension = {
487 .name = "hexium HV-PCI6/Orion", 487 .name = "hexium HV-PCI6 Orion",
488 .flags = 0, // SAA7146_USE_I2C_IRQ, 488 .flags = 0, // SAA7146_USE_I2C_IRQ,
489 489
490 .pci_tbl = &pci_tbl[0], 490 .pci_tbl = &pci_tbl[0],
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index 90628562851e..184974cc734d 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -60,4 +60,7 @@ extern void i2o_iop_remove(struct i2o_controller *);
60#define I2O_IN_PORT 0x40 60#define I2O_IN_PORT 0x40
61#define I2O_OUT_PORT 0x44 61#define I2O_OUT_PORT 0x44
62 62
63/* Motorola/Freescale specific register offset */
64#define I2O_MOTOROLA_PORT_OFFSET 0x10400
65
63#define I2O_IRQ_OUTBOUND_POST 0x00000008 66#define I2O_IRQ_OUTBOUND_POST 0x00000008
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index d698d7709c31..4f1515cae5dc 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -88,6 +88,11 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
88 struct device *dev = &pdev->dev; 88 struct device *dev = &pdev->dev;
89 int i; 89 int i;
90 90
91 if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
92 printk(KERN_ERR "%s: device already claimed\n", c->name);
93 return -ENODEV;
94 }
95
91 for (i = 0; i < 6; i++) { 96 for (i = 0; i < 6; i++) {
92 /* Skip I/O spaces */ 97 /* Skip I/O spaces */
93 if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) { 98 if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
@@ -163,6 +168,24 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
163 c->in_port = c->base.virt + I2O_IN_PORT; 168 c->in_port = c->base.virt + I2O_IN_PORT;
164 c->out_port = c->base.virt + I2O_OUT_PORT; 169 c->out_port = c->base.virt + I2O_OUT_PORT;
165 170
171 /* Motorola/Freescale chip does not follow spec */
172 if (pdev->vendor == PCI_VENDOR_ID_MOTOROLA && pdev->device == 0x18c0) {
173 /* Check if CPU is enabled */
174 if (be32_to_cpu(readl(c->base.virt + 0x10000)) & 0x10000000) {
175 printk(KERN_INFO "%s: MPC82XX needs CPU running to "
176 "service I2O.\n", c->name);
177 i2o_pci_free(c);
178 return -ENODEV;
179 } else {
180 c->irq_status += I2O_MOTOROLA_PORT_OFFSET;
181 c->irq_mask += I2O_MOTOROLA_PORT_OFFSET;
182 c->in_port += I2O_MOTOROLA_PORT_OFFSET;
183 c->out_port += I2O_MOTOROLA_PORT_OFFSET;
184 printk(KERN_INFO "%s: MPC82XX workarounds activated.\n",
185 c->name);
186 }
187 }
188
166 if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) { 189 if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) {
167 i2o_pci_free(c); 190 i2o_pci_free(c);
168 return -ENOMEM; 191 return -ENOMEM;
@@ -298,7 +321,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
298 struct i2o_controller *c; 321 struct i2o_controller *c;
299 int rc; 322 int rc;
300 struct pci_dev *i960 = NULL; 323 struct pci_dev *i960 = NULL;
301 int pci_dev_busy = 0; 324 int enabled = pdev->is_enabled;
302 325
303 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); 326 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
304 327
@@ -308,16 +331,12 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
308 return -ENODEV; 331 return -ENODEV;
309 } 332 }
310 333
311 if ((rc = pci_enable_device(pdev))) { 334 if (!enabled)
312 printk(KERN_WARNING "i2o: couldn't enable device %s\n", 335 if ((rc = pci_enable_device(pdev))) {
313 pci_name(pdev)); 336 printk(KERN_WARNING "i2o: couldn't enable device %s\n",
314 return rc; 337 pci_name(pdev));
315 } 338 return rc;
316 339 }
317 if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
318 printk(KERN_ERR "i2o: device already claimed\n");
319 return -ENODEV;
320 }
321 340
322 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 341 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
323 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", 342 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
@@ -395,9 +414,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
395 414
396 if ((rc = i2o_pci_alloc(c))) { 415 if ((rc = i2o_pci_alloc(c))) {
397 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller " 416 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
398 " failed\n", c->name); 417 "failed\n", c->name);
399 if (rc == -ENODEV)
400 pci_dev_busy = 1;
401 goto free_controller; 418 goto free_controller;
402 } 419 }
403 420
@@ -425,7 +442,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
425 i2o_iop_free(c); 442 i2o_iop_free(c);
426 443
427 disable: 444 disable:
428 if (!pci_dev_busy) 445 if (!enabled)
429 pci_disable_device(pdev); 446 pci_disable_device(pdev);
430 447
431 return rc; 448 return rc;
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index 701620b6baed..8b3784e2de89 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -110,8 +110,9 @@ static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const voi
110{ 110{
111 while (len > 0) { 111 while (len > 0) {
112 map_word d; 112 map_word d;
113 d.x[0] = *((uint32_t*)from)++; 113 d.x[0] = *((uint32_t*)from);
114 dc21285_write32(map, d, to); 114 dc21285_write32(map, d, to);
115 from += 4;
115 to += 4; 116 to += 4;
116 len -= 4; 117 len -= 4;
117 } 118 }
@@ -121,8 +122,9 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
121{ 122{
122 while (len > 0) { 123 while (len > 0) {
123 map_word d; 124 map_word d;
124 d.x[0] = *((uint16_t*)from)++; 125 d.x[0] = *((uint16_t*)from);
125 dc21285_write16(map, d, to); 126 dc21285_write16(map, d, to);
127 from += 2;
126 to += 2; 128 to += 2;
127 len -= 2; 129 len -= 2;
128 } 130 }
@@ -131,8 +133,9 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
131static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len) 133static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
132{ 134{
133 map_word d; 135 map_word d;
134 d.x[0] = *((uint8_t*)from)++; 136 d.x[0] = *((uint8_t*)from);
135 dc21285_write8(map, d, to); 137 dc21285_write8(map, d, to);
138 from++;
136 to++; 139 to++;
137 len--; 140 len--;
138} 141}
diff --git a/drivers/mtd/maps/tsunami_flash.c b/drivers/mtd/maps/tsunami_flash.c
index 9e21e6c02f80..0f915ac3102e 100644
--- a/drivers/mtd/maps/tsunami_flash.c
+++ b/drivers/mtd/maps/tsunami_flash.c
@@ -62,7 +62,7 @@ static void tsunami_flash_copy_to(
62static struct map_info tsunami_flash_map = { 62static struct map_info tsunami_flash_map = {
63 .name = "flash chip on the Tsunami TIG bus", 63 .name = "flash chip on the Tsunami TIG bus",
64 .size = MAX_TIG_FLASH_SIZE, 64 .size = MAX_TIG_FLASH_SIZE,
65 .phys = NO_XIP; 65 .phys = NO_XIP,
66 .bankwidth = 1, 66 .bankwidth = 1,
67 .read = tsunami_flash_read8, 67 .read = tsunami_flash_read8,
68 .copy_from = tsunami_flash_copy_from, 68 .copy_from = tsunami_flash_copy_from,
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 7488ee7f7caf..7f47124f118d 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -753,9 +753,11 @@ enum tx_desc_status {
753enum ChipCaps { CapBusMaster=0x20, CapPwrMgmt=0x2000 }; 753enum ChipCaps { CapBusMaster=0x20, CapPwrMgmt=0x2000 };
754 754
755struct vortex_extra_stats { 755struct vortex_extra_stats {
756 unsigned long tx_deferred; 756 unsigned long tx_deferred;
757 unsigned long tx_multiple_collisions; 757 unsigned long tx_max_collisions;
758 unsigned long rx_bad_ssd; 758 unsigned long tx_multiple_collisions;
759 unsigned long tx_single_collisions;
760 unsigned long rx_bad_ssd;
759}; 761};
760 762
761struct vortex_private { 763struct vortex_private {
@@ -863,12 +865,14 @@ static struct {
863 const char str[ETH_GSTRING_LEN]; 865 const char str[ETH_GSTRING_LEN];
864} ethtool_stats_keys[] = { 866} ethtool_stats_keys[] = {
865 { "tx_deferred" }, 867 { "tx_deferred" },
868 { "tx_max_collisions" },
866 { "tx_multiple_collisions" }, 869 { "tx_multiple_collisions" },
870 { "tx_single_collisions" },
867 { "rx_bad_ssd" }, 871 { "rx_bad_ssd" },
868}; 872};
869 873
870/* number of ETHTOOL_GSTATS u64's */ 874/* number of ETHTOOL_GSTATS u64's */
871#define VORTEX_NUM_STATS 3 875#define VORTEX_NUM_STATS 5
872 876
873static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, 877static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
874 int chip_idx, int card_idx); 878 int chip_idx, int card_idx);
@@ -2108,9 +2112,12 @@ vortex_error(struct net_device *dev, int status)
2108 iowrite8(0, ioaddr + TxStatus); 2112 iowrite8(0, ioaddr + TxStatus);
2109 if (tx_status & 0x30) { /* txJabber or txUnderrun */ 2113 if (tx_status & 0x30) { /* txJabber or txUnderrun */
2110 do_tx_reset = 1; 2114 do_tx_reset = 1;
2111 } else if ((tx_status & 0x08) && (vp->drv_flags & MAX_COLLISION_RESET)) { /* maxCollisions */ 2115 } else if (tx_status & 0x08) { /* maxCollisions */
2112 do_tx_reset = 1; 2116 vp->xstats.tx_max_collisions++;
2113 reset_mask = 0x0108; /* Reset interface logic, but not download logic */ 2117 if (vp->drv_flags & MAX_COLLISION_RESET) {
2118 do_tx_reset = 1;
2119 reset_mask = 0x0108; /* Reset interface logic, but not download logic */
2120 }
2114 } else { /* Merely re-enable the transmitter. */ 2121 } else { /* Merely re-enable the transmitter. */
2115 iowrite16(TxEnable, ioaddr + EL3_CMD); 2122 iowrite16(TxEnable, ioaddr + EL3_CMD);
2116 } 2123 }
@@ -2926,7 +2933,6 @@ static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2926 EL3WINDOW(6); 2933 EL3WINDOW(6);
2927 vp->stats.tx_carrier_errors += ioread8(ioaddr + 0); 2934 vp->stats.tx_carrier_errors += ioread8(ioaddr + 0);
2928 vp->stats.tx_heartbeat_errors += ioread8(ioaddr + 1); 2935 vp->stats.tx_heartbeat_errors += ioread8(ioaddr + 1);
2929 vp->stats.collisions += ioread8(ioaddr + 3);
2930 vp->stats.tx_window_errors += ioread8(ioaddr + 4); 2936 vp->stats.tx_window_errors += ioread8(ioaddr + 4);
2931 vp->stats.rx_fifo_errors += ioread8(ioaddr + 5); 2937 vp->stats.rx_fifo_errors += ioread8(ioaddr + 5);
2932 vp->stats.tx_packets += ioread8(ioaddr + 6); 2938 vp->stats.tx_packets += ioread8(ioaddr + 6);
@@ -2939,10 +2945,15 @@ static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2939 vp->stats.tx_bytes += ioread16(ioaddr + 12); 2945 vp->stats.tx_bytes += ioread16(ioaddr + 12);
2940 /* Extra stats for get_ethtool_stats() */ 2946 /* Extra stats for get_ethtool_stats() */
2941 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2); 2947 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2);
2948 vp->xstats.tx_single_collisions += ioread8(ioaddr + 3);
2942 vp->xstats.tx_deferred += ioread8(ioaddr + 8); 2949 vp->xstats.tx_deferred += ioread8(ioaddr + 8);
2943 EL3WINDOW(4); 2950 EL3WINDOW(4);
2944 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12); 2951 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12);
2945 2952
2953 vp->stats.collisions = vp->xstats.tx_multiple_collisions
2954 + vp->xstats.tx_single_collisions
2955 + vp->xstats.tx_max_collisions;
2956
2946 { 2957 {
2947 u8 up = ioread8(ioaddr + 13); 2958 u8 up = ioread8(ioaddr + 13);
2948 vp->stats.rx_bytes += (up & 0x0f) << 16; 2959 vp->stats.rx_bytes += (up & 0x0f) << 16;
@@ -3036,8 +3047,10 @@ static void vortex_get_ethtool_stats(struct net_device *dev,
3036 spin_unlock_irqrestore(&vp->lock, flags); 3047 spin_unlock_irqrestore(&vp->lock, flags);
3037 3048
3038 data[0] = vp->xstats.tx_deferred; 3049 data[0] = vp->xstats.tx_deferred;
3039 data[1] = vp->xstats.tx_multiple_collisions; 3050 data[1] = vp->xstats.tx_max_collisions;
3040 data[2] = vp->xstats.rx_bad_ssd; 3051 data[2] = vp->xstats.tx_multiple_collisions;
3052 data[3] = vp->xstats.tx_single_collisions;
3053 data[4] = vp->xstats.rx_bad_ssd;
3041} 3054}
3042 3055
3043 3056
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index 6139f06d7d2b..94d5ea1ce8bd 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -56,8 +56,6 @@ PORT SIZE ACTION MEANING
56All other communication is through memory! 56All other communication is through memory!
57*/ 57*/
58 58
59#define SLOW_DOWN_IO udelay(5)
60
61#include <linux/module.h> 59#include <linux/module.h>
62#include <linux/init.h> 60#include <linux/init.h>
63#include <linux/delay.h> 61#include <linux/delay.h>
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index f2d1dafde087..e7dc653d5bd6 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -69,8 +69,8 @@
69 69
70#define DRV_MODULE_NAME "tg3" 70#define DRV_MODULE_NAME "tg3"
71#define PFX DRV_MODULE_NAME ": " 71#define PFX DRV_MODULE_NAME ": "
72#define DRV_MODULE_VERSION "3.48" 72#define DRV_MODULE_VERSION "3.49"
73#define DRV_MODULE_RELDATE "Jan 16, 2006" 73#define DRV_MODULE_RELDATE "Feb 2, 2006"
74 74
75#define TG3_DEF_MAC_MODE 0 75#define TG3_DEF_MAC_MODE 0
76#define TG3_DEF_RX_MODE 0 76#define TG3_DEF_RX_MODE 0
@@ -3482,6 +3482,17 @@ static void tg3_reset_task(void *_data)
3482 struct tg3 *tp = _data; 3482 struct tg3 *tp = _data;
3483 unsigned int restart_timer; 3483 unsigned int restart_timer;
3484 3484
3485 tg3_full_lock(tp, 0);
3486 tp->tg3_flags |= TG3_FLAG_IN_RESET_TASK;
3487
3488 if (!netif_running(tp->dev)) {
3489 tp->tg3_flags &= ~TG3_FLAG_IN_RESET_TASK;
3490 tg3_full_unlock(tp);
3491 return;
3492 }
3493
3494 tg3_full_unlock(tp);
3495
3485 tg3_netif_stop(tp); 3496 tg3_netif_stop(tp);
3486 3497
3487 tg3_full_lock(tp, 1); 3498 tg3_full_lock(tp, 1);
@@ -3494,10 +3505,12 @@ static void tg3_reset_task(void *_data)
3494 3505
3495 tg3_netif_start(tp); 3506 tg3_netif_start(tp);
3496 3507
3497 tg3_full_unlock(tp);
3498
3499 if (restart_timer) 3508 if (restart_timer)
3500 mod_timer(&tp->timer, jiffies + 1); 3509 mod_timer(&tp->timer, jiffies + 1);
3510
3511 tp->tg3_flags &= ~TG3_FLAG_IN_RESET_TASK;
3512
3513 tg3_full_unlock(tp);
3501} 3514}
3502 3515
3503static void tg3_tx_timeout(struct net_device *dev) 3516static void tg3_tx_timeout(struct net_device *dev)
@@ -6786,6 +6799,13 @@ static int tg3_close(struct net_device *dev)
6786{ 6799{
6787 struct tg3 *tp = netdev_priv(dev); 6800 struct tg3 *tp = netdev_priv(dev);
6788 6801
6802 /* Calling flush_scheduled_work() may deadlock because
6803 * linkwatch_event() may be on the workqueue and it will try to get
6804 * the rtnl_lock which we are holding.
6805 */
6806 while (tp->tg3_flags & TG3_FLAG_IN_RESET_TASK)
6807 msleep(1);
6808
6789 netif_stop_queue(dev); 6809 netif_stop_queue(dev);
6790 6810
6791 del_timer_sync(&tp->timer); 6811 del_timer_sync(&tp->timer);
@@ -10880,6 +10900,7 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
10880 if (dev) { 10900 if (dev) {
10881 struct tg3 *tp = netdev_priv(dev); 10901 struct tg3 *tp = netdev_priv(dev);
10882 10902
10903 flush_scheduled_work();
10883 unregister_netdev(dev); 10904 unregister_netdev(dev);
10884 if (tp->regs) { 10905 if (tp->regs) {
10885 iounmap(tp->regs); 10906 iounmap(tp->regs);
@@ -10901,6 +10922,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10901 if (!netif_running(dev)) 10922 if (!netif_running(dev))
10902 return 0; 10923 return 0;
10903 10924
10925 flush_scheduled_work();
10904 tg3_netif_stop(tp); 10926 tg3_netif_stop(tp);
10905 10927
10906 del_timer_sync(&tp->timer); 10928 del_timer_sync(&tp->timer);
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index e8243305f0e8..7f4b7f6ac40d 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2162,6 +2162,7 @@ struct tg3 {
2162#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000 2162#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000
2163#define TG3_FLAG_10_100_ONLY 0x01000000 2163#define TG3_FLAG_10_100_ONLY 0x01000000
2164#define TG3_FLAG_PAUSE_AUTONEG 0x02000000 2164#define TG3_FLAG_PAUSE_AUTONEG 0x02000000
2165#define TG3_FLAG_IN_RESET_TASK 0x04000000
2165#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 2166#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
2166#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000 2167#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000
2167#define TG3_FLAG_SPLIT_MODE 0x40000000 2168#define TG3_FLAG_SPLIT_MODE 0x40000000
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 916b24c544e2..14beab4bc91c 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -2456,7 +2456,7 @@ static void ipw_eeprom_init_sram(struct ipw_priv *priv)
2456 copy. Otherwise let the firmware know to perform the operation 2456 copy. Otherwise let the firmware know to perform the operation
2457 on it's own 2457 on it's own
2458 */ 2458 */
2459 if ((priv->eeprom + EEPROM_VERSION) != 0) { 2459 if (priv->eeprom[EEPROM_VERSION] != 0) {
2460 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n"); 2460 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n");
2461 2461
2462 /* write the eeprom data to sram */ 2462 /* write the eeprom data to sram */
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index f605dea57224..f63c387976cf 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -90,6 +90,15 @@ config PARPORT_ARC
90 depends on ARM && PARPORT 90 depends on ARM && PARPORT
91 select PARPORT_NOT_PC 91 select PARPORT_NOT_PC
92 92
93config PARPORT_IP32
94 tristate "SGI IP32 builtin port (EXPERIMENTAL)"
95 depends on SGI_IP32 && PARPORT && EXPERIMENTAL
96 select PARPORT_NOT_PC
97 help
98 Say Y here if you need support for the parallel port on
99 SGI O2 machines. This code is also available as a module (say M),
100 called parport_ip32. If in doubt, saying N is the safe plan.
101
93config PARPORT_AMIGA 102config PARPORT_AMIGA
94 tristate "Amiga builtin port" 103 tristate "Amiga builtin port"
95 depends on AMIGA && PARPORT 104 depends on AMIGA && PARPORT
diff --git a/drivers/parport/Makefile b/drivers/parport/Makefile
index 5372212bb9d9..a19de35f8de2 100644
--- a/drivers/parport/Makefile
+++ b/drivers/parport/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
17obj-$(CONFIG_PARPORT_ATARI) += parport_atari.o 17obj-$(CONFIG_PARPORT_ATARI) += parport_atari.o
18obj-$(CONFIG_PARPORT_SUNBPP) += parport_sunbpp.o 18obj-$(CONFIG_PARPORT_SUNBPP) += parport_sunbpp.o
19obj-$(CONFIG_PARPORT_GSC) += parport_gsc.o 19obj-$(CONFIG_PARPORT_GSC) += parport_gsc.o
20obj-$(CONFIG_PARPORT_IP32) += parport_ip32.o
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index 5b887ba5aaf9..690b239ad3a7 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -61,10 +61,10 @@ static void timeout_waiting_on_port (unsigned long cookie)
61 * set to zero, it returns immediately. 61 * set to zero, it returns immediately.
62 * 62 *
63 * If an interrupt occurs before the timeout period elapses, this 63 * If an interrupt occurs before the timeout period elapses, this
64 * function returns one immediately. If it times out, it returns 64 * function returns zero immediately. If it times out, it returns
65 * a value greater than zero. An error code less than zero 65 * one. An error code less than zero indicates an error (most
66 * indicates an error (most likely a pending signal), and the 66 * likely a pending signal), and the calling code should finish
67 * calling code should finish what it's doing as soon as it can. 67 * what it's doing as soon as it can.
68 */ 68 */
69 69
70int parport_wait_event (struct parport *port, signed long timeout) 70int parport_wait_event (struct parport *port, signed long timeout)
@@ -110,7 +110,7 @@ int parport_wait_event (struct parport *port, signed long timeout)
110 * 110 *
111 * If the status lines take on the desired values before the 111 * If the status lines take on the desired values before the
112 * timeout period elapses, parport_poll_peripheral() returns zero 112 * timeout period elapses, parport_poll_peripheral() returns zero
113 * immediately. A zero return value greater than zero indicates 113 * immediately. A return value greater than zero indicates
114 * a timeout. An error code (less than zero) indicates an error, 114 * a timeout. An error code (less than zero) indicates an error,
115 * most likely a signal that arrived, and the caller should 115 * most likely a signal that arrived, and the caller should
116 * finish what it is doing as soon as possible. 116 * finish what it is doing as soon as possible.
diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
new file mode 100644
index 000000000000..46e06e596d73
--- /dev/null
+++ b/drivers/parport/parport_ip32.c
@@ -0,0 +1,2253 @@
1/* Low-level parallel port routines for built-in port on SGI IP32
2 *
3 * Author: Arnaud Giersch <arnaud.giersch@free.fr>
4 *
5 * Based on parport_pc.c by
6 * Phil Blundell, Tim Waugh, Jose Renau, David Campbell,
7 * Andrea Arcangeli, et al.
8 *
9 * Thanks to Ilya A. Volynets-Evenbakh for his help.
10 *
11 * Copyright (C) 2005, 2006 Arnaud Giersch.
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc., 59
25 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 */
27
28/* Current status:
29 *
30 * Basic SPP and PS2 modes are supported.
31 * Support for parallel port IRQ is present.
32 * Hardware SPP (a.k.a. compatibility), EPP, and ECP modes are
33 * supported.
34 * SPP/ECP FIFO can be driven in PIO or DMA mode. PIO mode can work with
35 * or without interrupt support.
36 *
37 * Hardware ECP mode is not fully implemented (ecp_read_data and
38 * ecp_write_addr are actually missing).
39 *
40 * To do:
41 *
42 * Fully implement ECP mode.
43 * EPP and ECP mode need to be tested. I currently do not own any
44 * peripheral supporting these extended mode, and cannot test them.
45 * If DMA mode works well, decide if support for PIO FIFO modes should be
46 * dropped.
47 * Use the io{read,write} family functions when they become available in
48 * the linux-mips.org tree. Note: the MIPS specific functions readsb()
49 * and writesb() are to be translated by ioread8_rep() and iowrite8_rep()
50 * respectively.
51 */
52
53/* The built-in parallel port on the SGI 02 workstation (a.k.a. IP32) is an
54 * IEEE 1284 parallel port driven by a Texas Instrument TL16PIR552PH chip[1].
55 * This chip supports SPP, bidirectional, EPP and ECP modes. It has a 16 byte
56 * FIFO buffer and supports DMA transfers.
57 *
58 * [1] http://focus.ti.com/docs/prod/folders/print/tl16pir552.html
59 *
60 * Theoretically, we could simply use the parport_pc module. It is however
61 * not so simple. The parport_pc code assumes that the parallel port
62 * registers are port-mapped. On the O2, they are memory-mapped.
63 * Furthermore, each register is replicated on 256 consecutive addresses (as
64 * it is for the built-in serial ports on the same chip).
65 */
66
67/*--- Some configuration defines ---------------------------------------*/
68
69/* DEBUG_PARPORT_IP32
70 * 0 disable debug
71 * 1 standard level: pr_debug1 is enabled
72 * 2 parport_ip32_dump_state is enabled
73 * >=3 verbose level: pr_debug is enabled
74 */
75#if !defined(DEBUG_PARPORT_IP32)
76# define DEBUG_PARPORT_IP32 0 /* 0 (disabled) for production */
77#endif
78
79/*----------------------------------------------------------------------*/
80
81/* Setup DEBUG macros. This is done before any includes, just in case we
82 * activate pr_debug() with DEBUG_PARPORT_IP32 >= 3.
83 */
84#if DEBUG_PARPORT_IP32 == 1
85# warning DEBUG_PARPORT_IP32 == 1
86#elif DEBUG_PARPORT_IP32 == 2
87# warning DEBUG_PARPORT_IP32 == 2
88#elif DEBUG_PARPORT_IP32 >= 3
89# warning DEBUG_PARPORT_IP32 >= 3
90# if !defined(DEBUG)
91# define DEBUG /* enable pr_debug() in kernel.h */
92# endif
93#endif
94
95#include <linux/completion.h>
96#include <linux/delay.h>
97#include <linux/dma-mapping.h>
98#include <linux/err.h>
99#include <linux/init.h>
100#include <linux/interrupt.h>
101#include <linux/jiffies.h>
102#include <linux/kernel.h>
103#include <linux/module.h>
104#include <linux/parport.h>
105#include <linux/sched.h>
106#include <linux/spinlock.h>
107#include <linux/stddef.h>
108#include <linux/types.h>
109#include <asm/io.h>
110#include <asm/ip32/ip32_ints.h>
111#include <asm/ip32/mace.h>
112
113/*--- Global variables -------------------------------------------------*/
114
115/* Verbose probing on by default for debugging. */
116#if DEBUG_PARPORT_IP32 >= 1
117# define DEFAULT_VERBOSE_PROBING 1
118#else
119# define DEFAULT_VERBOSE_PROBING 0
120#endif
121
122/* Default prefix for printk */
123#define PPIP32 "parport_ip32: "
124
125/*
126 * These are the module parameters:
127 * @features: bit mask of features to enable/disable
128 * (all enabled by default)
129 * @verbose_probing: log chit-chat during initialization
130 */
131#define PARPORT_IP32_ENABLE_IRQ (1U << 0)
132#define PARPORT_IP32_ENABLE_DMA (1U << 1)
133#define PARPORT_IP32_ENABLE_SPP (1U << 2)
134#define PARPORT_IP32_ENABLE_EPP (1U << 3)
135#define PARPORT_IP32_ENABLE_ECP (1U << 4)
136static unsigned int features = ~0U;
137static int verbose_probing = DEFAULT_VERBOSE_PROBING;
138
139/* We do not support more than one port. */
140static struct parport *this_port = NULL;
141
142/* Timing constants for FIFO modes. */
143#define FIFO_NFAULT_TIMEOUT 100 /* milliseconds */
144#define FIFO_POLLING_INTERVAL 50 /* microseconds */
145
146/*--- I/O register definitions -----------------------------------------*/
147
148/**
149 * struct parport_ip32_regs - virtual addresses of parallel port registers
150 * @data: Data Register
151 * @dsr: Device Status Register
152 * @dcr: Device Control Register
153 * @eppAddr: EPP Address Register
154 * @eppData0: EPP Data Register 0
155 * @eppData1: EPP Data Register 1
156 * @eppData2: EPP Data Register 2
157 * @eppData3: EPP Data Register 3
158 * @ecpAFifo: ECP Address FIFO
159 * @fifo: General FIFO register. The same address is used for:
160 * - cFifo, the Parallel Port DATA FIFO
161 * - ecpDFifo, the ECP Data FIFO
162 * - tFifo, the ECP Test FIFO
163 * @cnfgA: Configuration Register A
164 * @cnfgB: Configuration Register B
165 * @ecr: Extended Control Register
166 */
167struct parport_ip32_regs {
168 void __iomem *data;
169 void __iomem *dsr;
170 void __iomem *dcr;
171 void __iomem *eppAddr;
172 void __iomem *eppData0;
173 void __iomem *eppData1;
174 void __iomem *eppData2;
175 void __iomem *eppData3;
176 void __iomem *ecpAFifo;
177 void __iomem *fifo;
178 void __iomem *cnfgA;
179 void __iomem *cnfgB;
180 void __iomem *ecr;
181};
182
183/* Device Status Register */
184#define DSR_nBUSY (1U << 7) /* PARPORT_STATUS_BUSY */
185#define DSR_nACK (1U << 6) /* PARPORT_STATUS_ACK */
186#define DSR_PERROR (1U << 5) /* PARPORT_STATUS_PAPEROUT */
187#define DSR_SELECT (1U << 4) /* PARPORT_STATUS_SELECT */
188#define DSR_nFAULT (1U << 3) /* PARPORT_STATUS_ERROR */
189#define DSR_nPRINT (1U << 2) /* specific to TL16PIR552 */
190/* #define DSR_reserved (1U << 1) */
191#define DSR_TIMEOUT (1U << 0) /* EPP timeout */
192
193/* Device Control Register */
194/* #define DCR_reserved (1U << 7) | (1U << 6) */
195#define DCR_DIR (1U << 5) /* direction */
196#define DCR_IRQ (1U << 4) /* interrupt on nAck */
197#define DCR_SELECT (1U << 3) /* PARPORT_CONTROL_SELECT */
198#define DCR_nINIT (1U << 2) /* PARPORT_CONTROL_INIT */
199#define DCR_AUTOFD (1U << 1) /* PARPORT_CONTROL_AUTOFD */
200#define DCR_STROBE (1U << 0) /* PARPORT_CONTROL_STROBE */
201
202/* ECP Configuration Register A */
203#define CNFGA_IRQ (1U << 7)
204#define CNFGA_ID_MASK ((1U << 6) | (1U << 5) | (1U << 4))
205#define CNFGA_ID_SHIFT 4
206#define CNFGA_ID_16 (00U << CNFGA_ID_SHIFT)
207#define CNFGA_ID_8 (01U << CNFGA_ID_SHIFT)
208#define CNFGA_ID_32 (02U << CNFGA_ID_SHIFT)
209/* #define CNFGA_reserved (1U << 3) */
210#define CNFGA_nBYTEINTRANS (1U << 2)
211#define CNFGA_PWORDLEFT ((1U << 1) | (1U << 0))
212
213/* ECP Configuration Register B */
214#define CNFGB_COMPRESS (1U << 7)
215#define CNFGB_INTRVAL (1U << 6)
216#define CNFGB_IRQ_MASK ((1U << 5) | (1U << 4) | (1U << 3))
217#define CNFGB_IRQ_SHIFT 3
218#define CNFGB_DMA_MASK ((1U << 2) | (1U << 1) | (1U << 0))
219#define CNFGB_DMA_SHIFT 0
220
221/* Extended Control Register */
222#define ECR_MODE_MASK ((1U << 7) | (1U << 6) | (1U << 5))
223#define ECR_MODE_SHIFT 5
224#define ECR_MODE_SPP (00U << ECR_MODE_SHIFT)
225#define ECR_MODE_PS2 (01U << ECR_MODE_SHIFT)
226#define ECR_MODE_PPF (02U << ECR_MODE_SHIFT)
227#define ECR_MODE_ECP (03U << ECR_MODE_SHIFT)
228#define ECR_MODE_EPP (04U << ECR_MODE_SHIFT)
229/* #define ECR_MODE_reserved (05U << ECR_MODE_SHIFT) */
230#define ECR_MODE_TST (06U << ECR_MODE_SHIFT)
231#define ECR_MODE_CFG (07U << ECR_MODE_SHIFT)
232#define ECR_nERRINTR (1U << 4)
233#define ECR_DMAEN (1U << 3)
234#define ECR_SERVINTR (1U << 2)
235#define ECR_F_FULL (1U << 1)
236#define ECR_F_EMPTY (1U << 0)
237
238/*--- Private data -----------------------------------------------------*/
239
240/**
241 * enum parport_ip32_irq_mode - operation mode of interrupt handler
242 * @PARPORT_IP32_IRQ_FWD: forward interrupt to the upper parport layer
243 * @PARPORT_IP32_IRQ_HERE: interrupt is handled locally
244 */
245enum parport_ip32_irq_mode { PARPORT_IP32_IRQ_FWD, PARPORT_IP32_IRQ_HERE };
246
247/**
248 * struct parport_ip32_private - private stuff for &struct parport
249 * @regs: register addresses
250 * @dcr_cache: cached contents of DCR
251 * @dcr_writable: bit mask of writable DCR bits
252 * @pword: number of bytes per PWord
253 * @fifo_depth: number of PWords that FIFO will hold
254 * @readIntrThreshold: minimum number of PWords we can read
255 * if we get an interrupt
256 * @writeIntrThreshold: minimum number of PWords we can write
257 * if we get an interrupt
258 * @irq_mode: operation mode of interrupt handler for this port
259 * @irq_complete: mutex used to wait for an interrupt to occur
260 */
261struct parport_ip32_private {
262 struct parport_ip32_regs regs;
263 unsigned int dcr_cache;
264 unsigned int dcr_writable;
265 unsigned int pword;
266 unsigned int fifo_depth;
267 unsigned int readIntrThreshold;
268 unsigned int writeIntrThreshold;
269 enum parport_ip32_irq_mode irq_mode;
270 struct completion irq_complete;
271};
272
273/*--- Debug code -------------------------------------------------------*/
274
275/*
276 * pr_debug1 - print debug messages
277 *
278 * This is like pr_debug(), but is defined for %DEBUG_PARPORT_IP32 >= 1
279 */
280#if DEBUG_PARPORT_IP32 >= 1
281# define pr_debug1(...) printk(KERN_DEBUG __VA_ARGS__)
282#else /* DEBUG_PARPORT_IP32 < 1 */
283# define pr_debug1(...) do { } while (0)
284#endif
285
286/*
287 * pr_trace, pr_trace1 - trace function calls
288 * @p: pointer to &struct parport
289 * @fmt: printk format string
290 * @...: parameters for format string
291 *
292 * Macros used to trace function calls. The given string is formatted after
293 * function name. pr_trace() uses pr_debug(), and pr_trace1() uses
294 * pr_debug1(). __pr_trace() is the low-level macro and is not to be used
295 * directly.
296 */
297#define __pr_trace(pr, p, fmt, ...) \
298 pr("%s: %s" fmt "\n", \
299 ({ const struct parport *__p = (p); \
300 __p ? __p->name : "parport_ip32"; }), \
301 __func__ , ##__VA_ARGS__)
302#define pr_trace(p, fmt, ...) __pr_trace(pr_debug, p, fmt , ##__VA_ARGS__)
303#define pr_trace1(p, fmt, ...) __pr_trace(pr_debug1, p, fmt , ##__VA_ARGS__)
304
305/*
306 * __pr_probe, pr_probe - print message if @verbose_probing is true
307 * @p: pointer to &struct parport
308 * @fmt: printk format string
309 * @...: parameters for format string
310 *
311 * For new lines, use pr_probe(). Use __pr_probe() for continued lines.
312 */
313#define __pr_probe(...) \
314 do { if (verbose_probing) printk(__VA_ARGS__); } while (0)
315#define pr_probe(p, fmt, ...) \
316 __pr_probe(KERN_INFO PPIP32 "0x%lx: " fmt, (p)->base , ##__VA_ARGS__)
317
318/*
319 * parport_ip32_dump_state - print register status of parport
320 * @p: pointer to &struct parport
321 * @str: string to add in message
322 * @show_ecp_config: shall we dump ECP configuration registers too?
323 *
324 * This function is only here for debugging purpose, and should be used with
325 * care. Reading the parallel port registers may have undesired side effects.
326 * Especially if @show_ecp_config is true, the parallel port is resetted.
327 * This function is only defined if %DEBUG_PARPORT_IP32 >= 2.
328 */
329#if DEBUG_PARPORT_IP32 >= 2
330static void parport_ip32_dump_state(struct parport *p, char *str,
331 unsigned int show_ecp_config)
332{
333 struct parport_ip32_private * const priv = p->physport->private_data;
334 unsigned int i;
335
336 printk(KERN_DEBUG PPIP32 "%s: state (%s):\n", p->name, str);
337 {
338 static const char ecr_modes[8][4] = {"SPP", "PS2", "PPF",
339 "ECP", "EPP", "???",
340 "TST", "CFG"};
341 unsigned int ecr = readb(priv->regs.ecr);
342 printk(KERN_DEBUG PPIP32 " ecr=0x%02x", ecr);
343 printk(" %s",
344 ecr_modes[(ecr & ECR_MODE_MASK) >> ECR_MODE_SHIFT]);
345 if (ecr & ECR_nERRINTR)
346 printk(",nErrIntrEn");
347 if (ecr & ECR_DMAEN)
348 printk(",dmaEn");
349 if (ecr & ECR_SERVINTR)
350 printk(",serviceIntr");
351 if (ecr & ECR_F_FULL)
352 printk(",f_full");
353 if (ecr & ECR_F_EMPTY)
354 printk(",f_empty");
355 printk("\n");
356 }
357 if (show_ecp_config) {
358 unsigned int oecr, cnfgA, cnfgB;
359 oecr = readb(priv->regs.ecr);
360 writeb(ECR_MODE_PS2, priv->regs.ecr);
361 writeb(ECR_MODE_CFG, priv->regs.ecr);
362 cnfgA = readb(priv->regs.cnfgA);
363 cnfgB = readb(priv->regs.cnfgB);
364 writeb(ECR_MODE_PS2, priv->regs.ecr);
365 writeb(oecr, priv->regs.ecr);
366 printk(KERN_DEBUG PPIP32 " cnfgA=0x%02x", cnfgA);
367 printk(" ISA-%s", (cnfgA & CNFGA_IRQ) ? "Level" : "Pulses");
368 switch (cnfgA & CNFGA_ID_MASK) {
369 case CNFGA_ID_8:
370 printk(",8 bits");
371 break;
372 case CNFGA_ID_16:
373 printk(",16 bits");
374 break;
375 case CNFGA_ID_32:
376 printk(",32 bits");
377 break;
378 default:
379 printk(",unknown ID");
380 break;
381 }
382 if (!(cnfgA & CNFGA_nBYTEINTRANS))
383 printk(",ByteInTrans");
384 if ((cnfgA & CNFGA_ID_MASK) != CNFGA_ID_8)
385 printk(",%d byte%s left", cnfgA & CNFGA_PWORDLEFT,
386 ((cnfgA & CNFGA_PWORDLEFT) > 1) ? "s" : "");
387 printk("\n");
388 printk(KERN_DEBUG PPIP32 " cnfgB=0x%02x", cnfgB);
389 printk(" irq=%u,dma=%u",
390 (cnfgB & CNFGB_IRQ_MASK) >> CNFGB_IRQ_SHIFT,
391 (cnfgB & CNFGB_DMA_MASK) >> CNFGB_DMA_SHIFT);
392 printk(",intrValue=%d", !!(cnfgB & CNFGB_INTRVAL));
393 if (cnfgB & CNFGB_COMPRESS)
394 printk(",compress");
395 printk("\n");
396 }
397 for (i = 0; i < 2; i++) {
398 unsigned int dcr = i ? priv->dcr_cache : readb(priv->regs.dcr);
399 printk(KERN_DEBUG PPIP32 " dcr(%s)=0x%02x",
400 i ? "soft" : "hard", dcr);
401 printk(" %s", (dcr & DCR_DIR) ? "rev" : "fwd");
402 if (dcr & DCR_IRQ)
403 printk(",ackIntEn");
404 if (!(dcr & DCR_SELECT))
405 printk(",nSelectIn");
406 if (dcr & DCR_nINIT)
407 printk(",nInit");
408 if (!(dcr & DCR_AUTOFD))
409 printk(",nAutoFD");
410 if (!(dcr & DCR_STROBE))
411 printk(",nStrobe");
412 printk("\n");
413 }
414#define sep (f++ ? ',' : ' ')
415 {
416 unsigned int f = 0;
417 unsigned int dsr = readb(priv->regs.dsr);
418 printk(KERN_DEBUG PPIP32 " dsr=0x%02x", dsr);
419 if (!(dsr & DSR_nBUSY))
420 printk("%cBusy", sep);
421 if (dsr & DSR_nACK)
422 printk("%cnAck", sep);
423 if (dsr & DSR_PERROR)
424 printk("%cPError", sep);
425 if (dsr & DSR_SELECT)
426 printk("%cSelect", sep);
427 if (dsr & DSR_nFAULT)
428 printk("%cnFault", sep);
429 if (!(dsr & DSR_nPRINT))
430 printk("%c(Print)", sep);
431 if (dsr & DSR_TIMEOUT)
432 printk("%cTimeout", sep);
433 printk("\n");
434 }
435#undef sep
436}
437#else /* DEBUG_PARPORT_IP32 < 2 */
438#define parport_ip32_dump_state(...) do { } while (0)
439#endif
440
441/*
442 * CHECK_EXTRA_BITS - track and log extra bits
443 * @p: pointer to &struct parport
444 * @b: byte to inspect
445 * @m: bit mask of authorized bits
446 *
447 * This is used to track and log extra bits that should not be there in
448 * parport_ip32_write_control() and parport_ip32_frob_control(). It is only
449 * defined if %DEBUG_PARPORT_IP32 >= 1.
450 */
451#if DEBUG_PARPORT_IP32 >= 1
452#define CHECK_EXTRA_BITS(p, b, m) \
453 do { \
454 unsigned int __b = (b), __m = (m); \
455 if (__b & ~__m) \
456 pr_debug1(PPIP32 "%s: extra bits in %s(%s): " \
457 "0x%02x/0x%02x\n", \
458 (p)->name, __func__, #b, __b, __m); \
459 } while (0)
460#else /* DEBUG_PARPORT_IP32 < 1 */
461#define CHECK_EXTRA_BITS(...) do { } while (0)
462#endif
463
464/*--- IP32 parallel port DMA operations --------------------------------*/
465
466/**
467 * struct parport_ip32_dma_data - private data needed for DMA operation
468 * @dir: DMA direction (from or to device)
469 * @buf: buffer physical address
470 * @len: buffer length
471 * @next: address of next bytes to DMA transfer
472 * @left: number of bytes remaining
473 * @ctx: next context to write (0: context_a; 1: context_b)
474 * @irq_on: are the DMA IRQs currently enabled?
475 * @lock: spinlock to protect access to the structure
476 */
477struct parport_ip32_dma_data {
478 enum dma_data_direction dir;
479 dma_addr_t buf;
480 dma_addr_t next;
481 size_t len;
482 size_t left;
483 unsigned int ctx;
484 unsigned int irq_on;
485 spinlock_t lock;
486};
487static struct parport_ip32_dma_data parport_ip32_dma;
488
489/**
490 * parport_ip32_dma_setup_context - setup next DMA context
491 * @limit: maximum data size for the context
492 *
493 * The alignment constraints must be verified in caller function, and the
494 * parameter @limit must be set accordingly.
495 */
496static void parport_ip32_dma_setup_context(unsigned int limit)
497{
498 unsigned long flags;
499
500 spin_lock_irqsave(&parport_ip32_dma.lock, flags);
501 if (parport_ip32_dma.left > 0) {
502 /* Note: ctxreg is "volatile" here only because
503 * mace->perif.ctrl.parport.context_a and context_b are
504 * "volatile". */
505 volatile u64 __iomem *ctxreg = (parport_ip32_dma.ctx == 0) ?
506 &mace->perif.ctrl.parport.context_a :
507 &mace->perif.ctrl.parport.context_b;
508 u64 count;
509 u64 ctxval;
510 if (parport_ip32_dma.left <= limit) {
511 count = parport_ip32_dma.left;
512 ctxval = MACEPAR_CONTEXT_LASTFLAG;
513 } else {
514 count = limit;
515 ctxval = 0;
516 }
517
518 pr_trace(NULL,
519 "(%u): 0x%04x:0x%04x, %u -> %u%s",
520 limit,
521 (unsigned int)parport_ip32_dma.buf,
522 (unsigned int)parport_ip32_dma.next,
523 (unsigned int)count,
524 parport_ip32_dma.ctx, ctxval ? "*" : "");
525
526 ctxval |= parport_ip32_dma.next &
527 MACEPAR_CONTEXT_BASEADDR_MASK;
528 ctxval |= ((count - 1) << MACEPAR_CONTEXT_DATALEN_SHIFT) &
529 MACEPAR_CONTEXT_DATALEN_MASK;
530 writeq(ctxval, ctxreg);
531 parport_ip32_dma.next += count;
532 parport_ip32_dma.left -= count;
533 parport_ip32_dma.ctx ^= 1U;
534 }
535 /* If there is nothing more to send, disable IRQs to avoid to
536 * face an IRQ storm which can lock the machine. Disable them
537 * only once. */
538 if (parport_ip32_dma.left == 0 && parport_ip32_dma.irq_on) {
539 pr_debug(PPIP32 "IRQ off (ctx)\n");
540 disable_irq_nosync(MACEISA_PAR_CTXA_IRQ);
541 disable_irq_nosync(MACEISA_PAR_CTXB_IRQ);
542 parport_ip32_dma.irq_on = 0;
543 }
544 spin_unlock_irqrestore(&parport_ip32_dma.lock, flags);
545}
546
547/**
548 * parport_ip32_dma_interrupt - DMA interrupt handler
549 * @irq: interrupt number
550 * @dev_id: unused
551 * @regs: pointer to &struct pt_regs
552 */
553static irqreturn_t parport_ip32_dma_interrupt(int irq, void *dev_id,
554 struct pt_regs *regs)
555{
556 if (parport_ip32_dma.left)
557 pr_trace(NULL, "(%d): ctx=%d", irq, parport_ip32_dma.ctx);
558 parport_ip32_dma_setup_context(MACEPAR_CONTEXT_DATA_BOUND);
559 return IRQ_HANDLED;
560}
561
562#if DEBUG_PARPORT_IP32
563static irqreturn_t parport_ip32_merr_interrupt(int irq, void *dev_id,
564 struct pt_regs *regs)
565{
566 pr_trace1(NULL, "(%d)", irq);
567 return IRQ_HANDLED;
568}
569#endif
570
571/**
572 * parport_ip32_dma_start - begins a DMA transfer
573 * @dir: DMA direction: DMA_TO_DEVICE or DMA_FROM_DEVICE
574 * @addr: pointer to data buffer
575 * @count: buffer size
576 *
577 * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be
578 * correctly balanced.
579 */
580static int parport_ip32_dma_start(enum dma_data_direction dir,
581 void *addr, size_t count)
582{
583 unsigned int limit;
584 u64 ctrl;
585
586 pr_trace(NULL, "(%d, %lu)", dir, (unsigned long)count);
587
588 /* FIXME - add support for DMA_FROM_DEVICE. In this case, buffer must
589 * be 64 bytes aligned. */
590 BUG_ON(dir != DMA_TO_DEVICE);
591
592 /* Reset DMA controller */
593 ctrl = MACEPAR_CTLSTAT_RESET;
594 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
595
596 /* DMA IRQs should normally be enabled */
597 if (!parport_ip32_dma.irq_on) {
598 WARN_ON(1);
599 enable_irq(MACEISA_PAR_CTXA_IRQ);
600 enable_irq(MACEISA_PAR_CTXB_IRQ);
601 parport_ip32_dma.irq_on = 1;
602 }
603
604 /* Prepare DMA pointers */
605 parport_ip32_dma.dir = dir;
606 parport_ip32_dma.buf = dma_map_single(NULL, addr, count, dir);
607 parport_ip32_dma.len = count;
608 parport_ip32_dma.next = parport_ip32_dma.buf;
609 parport_ip32_dma.left = parport_ip32_dma.len;
610 parport_ip32_dma.ctx = 0;
611
612 /* Setup DMA direction and first two contexts */
613 ctrl = (dir == DMA_TO_DEVICE) ? 0 : MACEPAR_CTLSTAT_DIRECTION;
614 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
615 /* Single transfer should not cross a 4K page boundary */
616 limit = MACEPAR_CONTEXT_DATA_BOUND -
617 (parport_ip32_dma.next & (MACEPAR_CONTEXT_DATA_BOUND - 1));
618 parport_ip32_dma_setup_context(limit);
619 parport_ip32_dma_setup_context(MACEPAR_CONTEXT_DATA_BOUND);
620
621 /* Real start of DMA transfer */
622 ctrl |= MACEPAR_CTLSTAT_ENABLE;
623 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
624
625 return 0;
626}
627
628/**
629 * parport_ip32_dma_stop - ends a running DMA transfer
630 *
631 * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be
632 * correctly balanced.
633 */
634static void parport_ip32_dma_stop(void)
635{
636 u64 ctx_a;
637 u64 ctx_b;
638 u64 ctrl;
639 u64 diag;
640 size_t res[2]; /* {[0] = res_a, [1] = res_b} */
641
642 pr_trace(NULL, "()");
643
644 /* Disable IRQs */
645 spin_lock_irq(&parport_ip32_dma.lock);
646 if (parport_ip32_dma.irq_on) {
647 pr_debug(PPIP32 "IRQ off (stop)\n");
648 disable_irq_nosync(MACEISA_PAR_CTXA_IRQ);
649 disable_irq_nosync(MACEISA_PAR_CTXB_IRQ);
650 parport_ip32_dma.irq_on = 0;
651 }
652 spin_unlock_irq(&parport_ip32_dma.lock);
653 /* Force IRQ synchronization, even if the IRQs were disabled
654 * elsewhere. */
655 synchronize_irq(MACEISA_PAR_CTXA_IRQ);
656 synchronize_irq(MACEISA_PAR_CTXB_IRQ);
657
658 /* Stop DMA transfer */
659 ctrl = readq(&mace->perif.ctrl.parport.cntlstat);
660 ctrl &= ~MACEPAR_CTLSTAT_ENABLE;
661 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
662
663 /* Adjust residue (parport_ip32_dma.left) */
664 ctx_a = readq(&mace->perif.ctrl.parport.context_a);
665 ctx_b = readq(&mace->perif.ctrl.parport.context_b);
666 ctrl = readq(&mace->perif.ctrl.parport.cntlstat);
667 diag = readq(&mace->perif.ctrl.parport.diagnostic);
668 res[0] = (ctrl & MACEPAR_CTLSTAT_CTXA_VALID) ?
669 1 + ((ctx_a & MACEPAR_CONTEXT_DATALEN_MASK) >>
670 MACEPAR_CONTEXT_DATALEN_SHIFT) :
671 0;
672 res[1] = (ctrl & MACEPAR_CTLSTAT_CTXB_VALID) ?
673 1 + ((ctx_b & MACEPAR_CONTEXT_DATALEN_MASK) >>
674 MACEPAR_CONTEXT_DATALEN_SHIFT) :
675 0;
676 if (diag & MACEPAR_DIAG_DMACTIVE)
677 res[(diag & MACEPAR_DIAG_CTXINUSE) != 0] =
678 1 + ((diag & MACEPAR_DIAG_CTRMASK) >>
679 MACEPAR_DIAG_CTRSHIFT);
680 parport_ip32_dma.left += res[0] + res[1];
681
682 /* Reset DMA controller, and re-enable IRQs */
683 ctrl = MACEPAR_CTLSTAT_RESET;
684 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
685 pr_debug(PPIP32 "IRQ on (stop)\n");
686 enable_irq(MACEISA_PAR_CTXA_IRQ);
687 enable_irq(MACEISA_PAR_CTXB_IRQ);
688 parport_ip32_dma.irq_on = 1;
689
690 dma_unmap_single(NULL, parport_ip32_dma.buf, parport_ip32_dma.len,
691 parport_ip32_dma.dir);
692}
693
694/**
695 * parport_ip32_dma_get_residue - get residue from last DMA transfer
696 *
697 * Returns the number of bytes remaining from last DMA transfer.
698 */
699static inline size_t parport_ip32_dma_get_residue(void)
700{
701 return parport_ip32_dma.left;
702}
703
704/**
705 * parport_ip32_dma_register - initialize DMA engine
706 *
707 * Returns zero for success.
708 */
709static int parport_ip32_dma_register(void)
710{
711 int err;
712
713 spin_lock_init(&parport_ip32_dma.lock);
714 parport_ip32_dma.irq_on = 1;
715
716 /* Reset DMA controller */
717 writeq(MACEPAR_CTLSTAT_RESET, &mace->perif.ctrl.parport.cntlstat);
718
719 /* Request IRQs */
720 err = request_irq(MACEISA_PAR_CTXA_IRQ, parport_ip32_dma_interrupt,
721 0, "parport_ip32", NULL);
722 if (err)
723 goto fail_a;
724 err = request_irq(MACEISA_PAR_CTXB_IRQ, parport_ip32_dma_interrupt,
725 0, "parport_ip32", NULL);
726 if (err)
727 goto fail_b;
728#if DEBUG_PARPORT_IP32
729 /* FIXME - what is this IRQ for? */
730 err = request_irq(MACEISA_PAR_MERR_IRQ, parport_ip32_merr_interrupt,
731 0, "parport_ip32", NULL);
732 if (err)
733 goto fail_merr;
734#endif
735 return 0;
736
737#if DEBUG_PARPORT_IP32
738fail_merr:
739 free_irq(MACEISA_PAR_CTXB_IRQ, NULL);
740#endif
741fail_b:
742 free_irq(MACEISA_PAR_CTXA_IRQ, NULL);
743fail_a:
744 return err;
745}
746
747/**
748 * parport_ip32_dma_unregister - release and free resources for DMA engine
749 */
750static void parport_ip32_dma_unregister(void)
751{
752#if DEBUG_PARPORT_IP32
753 free_irq(MACEISA_PAR_MERR_IRQ, NULL);
754#endif
755 free_irq(MACEISA_PAR_CTXB_IRQ, NULL);
756 free_irq(MACEISA_PAR_CTXA_IRQ, NULL);
757}
758
759/*--- Interrupt handlers and associates --------------------------------*/
760
761/**
762 * parport_ip32_wakeup - wakes up code waiting for an interrupt
763 * @p: pointer to &struct parport
764 */
765static inline void parport_ip32_wakeup(struct parport *p)
766{
767 struct parport_ip32_private * const priv = p->physport->private_data;
768 complete(&priv->irq_complete);
769}
770
771/**
772 * parport_ip32_interrupt - interrupt handler
773 * @irq: interrupt number
774 * @dev_id: pointer to &struct parport
775 * @regs: pointer to &struct pt_regs
776 *
777 * Caught interrupts are forwarded to the upper parport layer if IRQ_mode is
778 * %PARPORT_IP32_IRQ_FWD.
779 */
780static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id,
781 struct pt_regs *regs)
782{
783 struct parport * const p = dev_id;
784 struct parport_ip32_private * const priv = p->physport->private_data;
785 enum parport_ip32_irq_mode irq_mode = priv->irq_mode;
786 switch (irq_mode) {
787 case PARPORT_IP32_IRQ_FWD:
788 parport_generic_irq(irq, p, regs);
789 break;
790 case PARPORT_IP32_IRQ_HERE:
791 parport_ip32_wakeup(p);
792 break;
793 }
794 return IRQ_HANDLED;
795}
796
797/*--- Some utility function to manipulate ECR register -----------------*/
798
799/**
800 * parport_ip32_read_econtrol - read contents of the ECR register
801 * @p: pointer to &struct parport
802 */
803static inline unsigned int parport_ip32_read_econtrol(struct parport *p)
804{
805 struct parport_ip32_private * const priv = p->physport->private_data;
806 return readb(priv->regs.ecr);
807}
808
809/**
810 * parport_ip32_write_econtrol - write new contents to the ECR register
811 * @p: pointer to &struct parport
812 * @c: new value to write
813 */
814static inline void parport_ip32_write_econtrol(struct parport *p,
815 unsigned int c)
816{
817 struct parport_ip32_private * const priv = p->physport->private_data;
818 writeb(c, priv->regs.ecr);
819}
820
821/**
822 * parport_ip32_frob_econtrol - change bits from the ECR register
823 * @p: pointer to &struct parport
824 * @mask: bit mask of bits to change
825 * @val: new value for changed bits
826 *
827 * Read from the ECR, mask out the bits in @mask, exclusive-or with the bits
828 * in @val, and write the result to the ECR.
829 */
830static inline void parport_ip32_frob_econtrol(struct parport *p,
831 unsigned int mask,
832 unsigned int val)
833{
834 unsigned int c;
835 c = (parport_ip32_read_econtrol(p) & ~mask) ^ val;
836 parport_ip32_write_econtrol(p, c);
837}
838
839/**
840 * parport_ip32_set_mode - change mode of ECP port
841 * @p: pointer to &struct parport
842 * @mode: new mode to write in ECR
843 *
844 * ECR is reset in a sane state (interrupts and DMA disabled), and placed in
845 * mode @mode. Go through PS2 mode if needed.
846 */
847static void parport_ip32_set_mode(struct parport *p, unsigned int mode)
848{
849 unsigned int omode;
850
851 mode &= ECR_MODE_MASK;
852 omode = parport_ip32_read_econtrol(p) & ECR_MODE_MASK;
853
854 if (!(mode == ECR_MODE_SPP || mode == ECR_MODE_PS2
855 || omode == ECR_MODE_SPP || omode == ECR_MODE_PS2)) {
856 /* We have to go through PS2 mode */
857 unsigned int ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR;
858 parport_ip32_write_econtrol(p, ecr);
859 }
860 parport_ip32_write_econtrol(p, mode | ECR_nERRINTR | ECR_SERVINTR);
861}
862
863/*--- Basic functions needed for parport -------------------------------*/
864
865/**
866 * parport_ip32_read_data - return current contents of the DATA register
867 * @p: pointer to &struct parport
868 */
869static inline unsigned char parport_ip32_read_data(struct parport *p)
870{
871 struct parport_ip32_private * const priv = p->physport->private_data;
872 return readb(priv->regs.data);
873}
874
875/**
876 * parport_ip32_write_data - set new contents for the DATA register
877 * @p: pointer to &struct parport
878 * @d: new value to write
879 */
880static inline void parport_ip32_write_data(struct parport *p, unsigned char d)
881{
882 struct parport_ip32_private * const priv = p->physport->private_data;
883 writeb(d, priv->regs.data);
884}
885
886/**
887 * parport_ip32_read_status - return current contents of the DSR register
888 * @p: pointer to &struct parport
889 */
890static inline unsigned char parport_ip32_read_status(struct parport *p)
891{
892 struct parport_ip32_private * const priv = p->physport->private_data;
893 return readb(priv->regs.dsr);
894}
895
896/**
897 * __parport_ip32_read_control - return cached contents of the DCR register
898 * @p: pointer to &struct parport
899 */
900static inline unsigned int __parport_ip32_read_control(struct parport *p)
901{
902 struct parport_ip32_private * const priv = p->physport->private_data;
903 return priv->dcr_cache; /* use soft copy */
904}
905
906/**
907 * __parport_ip32_write_control - set new contents for the DCR register
908 * @p: pointer to &struct parport
909 * @c: new value to write
910 */
911static inline void __parport_ip32_write_control(struct parport *p,
912 unsigned int c)
913{
914 struct parport_ip32_private * const priv = p->physport->private_data;
915 CHECK_EXTRA_BITS(p, c, priv->dcr_writable);
916 c &= priv->dcr_writable; /* only writable bits */
917 writeb(c, priv->regs.dcr);
918 priv->dcr_cache = c; /* update soft copy */
919}
920
921/**
922 * __parport_ip32_frob_control - change bits from the DCR register
923 * @p: pointer to &struct parport
924 * @mask: bit mask of bits to change
925 * @val: new value for changed bits
926 *
927 * This is equivalent to read from the DCR, mask out the bits in @mask,
928 * exclusive-or with the bits in @val, and write the result to the DCR.
929 * Actually, the cached contents of the DCR is used.
930 */
931static inline void __parport_ip32_frob_control(struct parport *p,
932 unsigned int mask,
933 unsigned int val)
934{
935 unsigned int c;
936 c = (__parport_ip32_read_control(p) & ~mask) ^ val;
937 __parport_ip32_write_control(p, c);
938}
939
940/**
941 * parport_ip32_read_control - return cached contents of the DCR register
942 * @p: pointer to &struct parport
943 *
944 * The return value is masked so as to only return the value of %DCR_STROBE,
945 * %DCR_AUTOFD, %DCR_nINIT, and %DCR_SELECT.
946 */
947static inline unsigned char parport_ip32_read_control(struct parport *p)
948{
949 const unsigned int rm =
950 DCR_STROBE | DCR_AUTOFD | DCR_nINIT | DCR_SELECT;
951 return __parport_ip32_read_control(p) & rm;
952}
953
954/**
955 * parport_ip32_write_control - set new contents for the DCR register
956 * @p: pointer to &struct parport
957 * @c: new value to write
958 *
959 * The value is masked so as to only change the value of %DCR_STROBE,
960 * %DCR_AUTOFD, %DCR_nINIT, and %DCR_SELECT.
961 */
962static inline void parport_ip32_write_control(struct parport *p,
963 unsigned char c)
964{
965 const unsigned int wm =
966 DCR_STROBE | DCR_AUTOFD | DCR_nINIT | DCR_SELECT;
967 CHECK_EXTRA_BITS(p, c, wm);
968 __parport_ip32_frob_control(p, wm, c & wm);
969}
970
971/**
972 * parport_ip32_frob_control - change bits from the DCR register
973 * @p: pointer to &struct parport
974 * @mask: bit mask of bits to change
975 * @val: new value for changed bits
976 *
977 * This differs from __parport_ip32_frob_control() in that it only allows to
978 * change the value of %DCR_STROBE, %DCR_AUTOFD, %DCR_nINIT, and %DCR_SELECT.
979 */
980static inline unsigned char parport_ip32_frob_control(struct parport *p,
981 unsigned char mask,
982 unsigned char val)
983{
984 const unsigned int wm =
985 DCR_STROBE | DCR_AUTOFD | DCR_nINIT | DCR_SELECT;
986 CHECK_EXTRA_BITS(p, mask, wm);
987 CHECK_EXTRA_BITS(p, val, wm);
988 __parport_ip32_frob_control(p, mask & wm, val & wm);
989 return parport_ip32_read_control(p);
990}
991
992/**
993 * parport_ip32_disable_irq - disable interrupts on the rising edge of nACK
994 * @p: pointer to &struct parport
995 */
996static inline void parport_ip32_disable_irq(struct parport *p)
997{
998 __parport_ip32_frob_control(p, DCR_IRQ, 0);
999}
1000
1001/**
1002 * parport_ip32_enable_irq - enable interrupts on the rising edge of nACK
1003 * @p: pointer to &struct parport
1004 */
1005static inline void parport_ip32_enable_irq(struct parport *p)
1006{
1007 __parport_ip32_frob_control(p, DCR_IRQ, DCR_IRQ);
1008}
1009
1010/**
1011 * parport_ip32_data_forward - enable host-to-peripheral communications
1012 * @p: pointer to &struct parport
1013 *
1014 * Enable the data line drivers, for 8-bit host-to-peripheral communications.
1015 */
1016static inline void parport_ip32_data_forward(struct parport *p)
1017{
1018 __parport_ip32_frob_control(p, DCR_DIR, 0);
1019}
1020
1021/**
1022 * parport_ip32_data_reverse - enable peripheral-to-host communications
1023 * @p: pointer to &struct parport
1024 *
1025 * Place the data bus in a high impedance state, if @p->modes has the
1026 * PARPORT_MODE_TRISTATE bit set.
1027 */
1028static inline void parport_ip32_data_reverse(struct parport *p)
1029{
1030 __parport_ip32_frob_control(p, DCR_DIR, DCR_DIR);
1031}
1032
1033/**
1034 * parport_ip32_init_state - for core parport code
1035 * @dev: pointer to &struct pardevice
1036 * @s: pointer to &struct parport_state to initialize
1037 */
1038static void parport_ip32_init_state(struct pardevice *dev,
1039 struct parport_state *s)
1040{
1041 s->u.ip32.dcr = DCR_SELECT | DCR_nINIT;
1042 s->u.ip32.ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR;
1043}
1044
1045/**
1046 * parport_ip32_save_state - for core parport code
1047 * @p: pointer to &struct parport
1048 * @s: pointer to &struct parport_state to save state to
1049 */
1050static void parport_ip32_save_state(struct parport *p,
1051 struct parport_state *s)
1052{
1053 s->u.ip32.dcr = __parport_ip32_read_control(p);
1054 s->u.ip32.ecr = parport_ip32_read_econtrol(p);
1055}
1056
1057/**
1058 * parport_ip32_restore_state - for core parport code
1059 * @p: pointer to &struct parport
1060 * @s: pointer to &struct parport_state to restore state from
1061 */
1062static void parport_ip32_restore_state(struct parport *p,
1063 struct parport_state *s)
1064{
1065 parport_ip32_set_mode(p, s->u.ip32.ecr & ECR_MODE_MASK);
1066 parport_ip32_write_econtrol(p, s->u.ip32.ecr);
1067 __parport_ip32_write_control(p, s->u.ip32.dcr);
1068}
1069
1070/*--- EPP mode functions -----------------------------------------------*/
1071
1072/**
1073 * parport_ip32_clear_epp_timeout - clear Timeout bit in EPP mode
1074 * @p: pointer to &struct parport
1075 *
1076 * Returns 1 if the Timeout bit is clear, and 0 otherwise.
1077 */
1078static unsigned int parport_ip32_clear_epp_timeout(struct parport *p)
1079{
1080 struct parport_ip32_private * const priv = p->physport->private_data;
1081 unsigned int cleared;
1082
1083 if (!(parport_ip32_read_status(p) & DSR_TIMEOUT))
1084 cleared = 1;
1085 else {
1086 unsigned int r;
1087 /* To clear timeout some chips require double read */
1088 parport_ip32_read_status(p);
1089 r = parport_ip32_read_status(p);
1090 /* Some reset by writing 1 */
1091 writeb(r | DSR_TIMEOUT, priv->regs.dsr);
1092 /* Others by writing 0 */
1093 writeb(r & ~DSR_TIMEOUT, priv->regs.dsr);
1094
1095 r = parport_ip32_read_status(p);
1096 cleared = !(r & DSR_TIMEOUT);
1097 }
1098
1099 pr_trace(p, "(): %s", cleared ? "cleared" : "failed");
1100 return cleared;
1101}
1102
1103/**
1104 * parport_ip32_epp_read - generic EPP read function
1105 * @eppreg: I/O register to read from
1106 * @p: pointer to &struct parport
1107 * @buf: buffer to store read data
1108 * @len: length of buffer @buf
1109 * @flags: may be PARPORT_EPP_FAST
1110 */
1111static size_t parport_ip32_epp_read(void __iomem *eppreg,
1112 struct parport *p, void *buf,
1113 size_t len, int flags)
1114{
1115 struct parport_ip32_private * const priv = p->physport->private_data;
1116 size_t got;
1117 parport_ip32_set_mode(p, ECR_MODE_EPP);
1118 parport_ip32_data_reverse(p);
1119 parport_ip32_write_control(p, DCR_nINIT);
1120 if ((flags & PARPORT_EPP_FAST) && (len > 1)) {
1121 readsb(eppreg, buf, len);
1122 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1123 parport_ip32_clear_epp_timeout(p);
1124 return -EIO;
1125 }
1126 got = len;
1127 } else {
1128 u8 *bufp = buf;
1129 for (got = 0; got < len; got++) {
1130 *bufp++ = readb(eppreg);
1131 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1132 parport_ip32_clear_epp_timeout(p);
1133 break;
1134 }
1135 }
1136 }
1137 parport_ip32_data_forward(p);
1138 parport_ip32_set_mode(p, ECR_MODE_PS2);
1139 return got;
1140}
1141
1142/**
1143 * parport_ip32_epp_write - generic EPP write function
1144 * @eppreg: I/O register to write to
1145 * @p: pointer to &struct parport
1146 * @buf: buffer of data to write
1147 * @len: length of buffer @buf
1148 * @flags: may be PARPORT_EPP_FAST
1149 */
1150static size_t parport_ip32_epp_write(void __iomem *eppreg,
1151 struct parport *p, const void *buf,
1152 size_t len, int flags)
1153{
1154 struct parport_ip32_private * const priv = p->physport->private_data;
1155 size_t written;
1156 parport_ip32_set_mode(p, ECR_MODE_EPP);
1157 parport_ip32_data_forward(p);
1158 parport_ip32_write_control(p, DCR_nINIT);
1159 if ((flags & PARPORT_EPP_FAST) && (len > 1)) {
1160 writesb(eppreg, buf, len);
1161 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1162 parport_ip32_clear_epp_timeout(p);
1163 return -EIO;
1164 }
1165 written = len;
1166 } else {
1167 const u8 *bufp = buf;
1168 for (written = 0; written < len; written++) {
1169 writeb(*bufp++, eppreg);
1170 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1171 parport_ip32_clear_epp_timeout(p);
1172 break;
1173 }
1174 }
1175 }
1176 parport_ip32_set_mode(p, ECR_MODE_PS2);
1177 return written;
1178}
1179
1180/**
1181 * parport_ip32_epp_read_data - read a block of data in EPP mode
1182 * @p: pointer to &struct parport
1183 * @buf: buffer to store read data
1184 * @len: length of buffer @buf
1185 * @flags: may be PARPORT_EPP_FAST
1186 */
1187static size_t parport_ip32_epp_read_data(struct parport *p, void *buf,
1188 size_t len, int flags)
1189{
1190 struct parport_ip32_private * const priv = p->physport->private_data;
1191 return parport_ip32_epp_read(priv->regs.eppData0, p, buf, len, flags);
1192}
1193
1194/**
1195 * parport_ip32_epp_write_data - write a block of data in EPP mode
1196 * @p: pointer to &struct parport
1197 * @buf: buffer of data to write
1198 * @len: length of buffer @buf
1199 * @flags: may be PARPORT_EPP_FAST
1200 */
1201static size_t parport_ip32_epp_write_data(struct parport *p, const void *buf,
1202 size_t len, int flags)
1203{
1204 struct parport_ip32_private * const priv = p->physport->private_data;
1205 return parport_ip32_epp_write(priv->regs.eppData0, p, buf, len, flags);
1206}
1207
1208/**
1209 * parport_ip32_epp_read_addr - read a block of addresses in EPP mode
1210 * @p: pointer to &struct parport
1211 * @buf: buffer to store read data
1212 * @len: length of buffer @buf
1213 * @flags: may be PARPORT_EPP_FAST
1214 */
1215static size_t parport_ip32_epp_read_addr(struct parport *p, void *buf,
1216 size_t len, int flags)
1217{
1218 struct parport_ip32_private * const priv = p->physport->private_data;
1219 return parport_ip32_epp_read(priv->regs.eppAddr, p, buf, len, flags);
1220}
1221
1222/**
1223 * parport_ip32_epp_write_addr - write a block of addresses in EPP mode
1224 * @p: pointer to &struct parport
1225 * @buf: buffer of data to write
1226 * @len: length of buffer @buf
1227 * @flags: may be PARPORT_EPP_FAST
1228 */
1229static size_t parport_ip32_epp_write_addr(struct parport *p, const void *buf,
1230 size_t len, int flags)
1231{
1232 struct parport_ip32_private * const priv = p->physport->private_data;
1233 return parport_ip32_epp_write(priv->regs.eppAddr, p, buf, len, flags);
1234}
1235
1236/*--- ECP mode functions (FIFO) ----------------------------------------*/
1237
1238/**
1239 * parport_ip32_fifo_wait_break - check if the waiting function should return
1240 * @p: pointer to &struct parport
1241 * @expire: timeout expiring date, in jiffies
1242 *
1243 * parport_ip32_fifo_wait_break() checks if the waiting function should return
1244 * immediately or not. The break conditions are:
1245 * - expired timeout;
1246 * - a pending signal;
1247 * - nFault asserted low.
1248 * This function also calls cond_resched().
1249 */
1250static unsigned int parport_ip32_fifo_wait_break(struct parport *p,
1251 unsigned long expire)
1252{
1253 cond_resched();
1254 if (time_after(jiffies, expire)) {
1255 pr_debug1(PPIP32 "%s: FIFO write timed out\n", p->name);
1256 return 1;
1257 }
1258 if (signal_pending(current)) {
1259 pr_debug1(PPIP32 "%s: Signal pending\n", p->name);
1260 return 1;
1261 }
1262 if (!(parport_ip32_read_status(p) & DSR_nFAULT)) {
1263 pr_debug1(PPIP32 "%s: nFault asserted low\n", p->name);
1264 return 1;
1265 }
1266 return 0;
1267}
1268
1269/**
1270 * parport_ip32_fwp_wait_polling - wait for FIFO to empty (polling)
1271 * @p: pointer to &struct parport
1272 *
1273 * Returns the number of bytes that can safely be written in the FIFO. A
1274 * return value of zero means that the calling function should terminate as
1275 * fast as possible.
1276 */
1277static unsigned int parport_ip32_fwp_wait_polling(struct parport *p)
1278{
1279 struct parport_ip32_private * const priv = p->physport->private_data;
1280 struct parport * const physport = p->physport;
1281 unsigned long expire;
1282 unsigned int count;
1283 unsigned int ecr;
1284
1285 expire = jiffies + physport->cad->timeout;
1286 count = 0;
1287 while (1) {
1288 if (parport_ip32_fifo_wait_break(p, expire))
1289 break;
1290
1291 /* Check FIFO state. We do nothing when the FIFO is nor full,
1292 * nor empty. It appears that the FIFO full bit is not always
1293 * reliable, the FIFO state is sometimes wrongly reported, and
1294 * the chip gets confused if we give it another byte. */
1295 ecr = parport_ip32_read_econtrol(p);
1296 if (ecr & ECR_F_EMPTY) {
1297 /* FIFO is empty, fill it up */
1298 count = priv->fifo_depth;
1299 break;
1300 }
1301
1302 /* Wait a moment... */
1303 udelay(FIFO_POLLING_INTERVAL);
1304 } /* while (1) */
1305
1306 return count;
1307}
1308
1309/**
1310 * parport_ip32_fwp_wait_interrupt - wait for FIFO to empty (interrupt-driven)
1311 * @p: pointer to &struct parport
1312 *
1313 * Returns the number of bytes that can safely be written in the FIFO. A
1314 * return value of zero means that the calling function should terminate as
1315 * fast as possible.
1316 */
1317static unsigned int parport_ip32_fwp_wait_interrupt(struct parport *p)
1318{
1319 static unsigned int lost_interrupt = 0;
1320 struct parport_ip32_private * const priv = p->physport->private_data;
1321 struct parport * const physport = p->physport;
1322 unsigned long nfault_timeout;
1323 unsigned long expire;
1324 unsigned int count;
1325 unsigned int ecr;
1326
1327 nfault_timeout = min((unsigned long)physport->cad->timeout,
1328 msecs_to_jiffies(FIFO_NFAULT_TIMEOUT));
1329 expire = jiffies + physport->cad->timeout;
1330 count = 0;
1331 while (1) {
1332 if (parport_ip32_fifo_wait_break(p, expire))
1333 break;
1334
1335 /* Initialize mutex used to take interrupts into account */
1336 INIT_COMPLETION(priv->irq_complete);
1337
1338 /* Enable serviceIntr */
1339 parport_ip32_frob_econtrol(p, ECR_SERVINTR, 0);
1340
1341 /* Enabling serviceIntr while the FIFO is empty does not
1342 * always generate an interrupt, so check for emptiness
1343 * now. */
1344 ecr = parport_ip32_read_econtrol(p);
1345 if (!(ecr & ECR_F_EMPTY)) {
1346 /* FIFO is not empty: wait for an interrupt or a
1347 * timeout to occur */
1348 wait_for_completion_interruptible_timeout(
1349 &priv->irq_complete, nfault_timeout);
1350 ecr = parport_ip32_read_econtrol(p);
1351 if ((ecr & ECR_F_EMPTY) && !(ecr & ECR_SERVINTR)
1352 && !lost_interrupt) {
1353 printk(KERN_WARNING PPIP32
1354 "%s: lost interrupt in %s\n",
1355 p->name, __func__);
1356 lost_interrupt = 1;
1357 }
1358 }
1359
1360 /* Disable serviceIntr */
1361 parport_ip32_frob_econtrol(p, ECR_SERVINTR, ECR_SERVINTR);
1362
1363 /* Check FIFO state */
1364 if (ecr & ECR_F_EMPTY) {
1365 /* FIFO is empty, fill it up */
1366 count = priv->fifo_depth;
1367 break;
1368 } else if (ecr & ECR_SERVINTR) {
1369 /* FIFO is not empty, but we know that can safely push
1370 * writeIntrThreshold bytes into it */
1371 count = priv->writeIntrThreshold;
1372 break;
1373 }
1374 /* FIFO is not empty, and we did not get any interrupt.
1375 * Either it's time to check for nFault, or a signal is
1376 * pending. This is verified in
1377 * parport_ip32_fifo_wait_break(), so we continue the loop. */
1378 } /* while (1) */
1379
1380 return count;
1381}
1382
1383/**
1384 * parport_ip32_fifo_write_block_pio - write a block of data (PIO mode)
1385 * @p: pointer to &struct parport
1386 * @buf: buffer of data to write
1387 * @len: length of buffer @buf
1388 *
1389 * Uses PIO to write the contents of the buffer @buf into the parallel port
1390 * FIFO. Returns the number of bytes that were actually written. It can work
1391 * with or without the help of interrupts. The parallel port must be
1392 * correctly initialized before calling parport_ip32_fifo_write_block_pio().
1393 */
1394static size_t parport_ip32_fifo_write_block_pio(struct parport *p,
1395 const void *buf, size_t len)
1396{
1397 struct parport_ip32_private * const priv = p->physport->private_data;
1398 const u8 *bufp = buf;
1399 size_t left = len;
1400
1401 priv->irq_mode = PARPORT_IP32_IRQ_HERE;
1402
1403 while (left > 0) {
1404 unsigned int count;
1405
1406 count = (p->irq == PARPORT_IRQ_NONE) ?
1407 parport_ip32_fwp_wait_polling(p) :
1408 parport_ip32_fwp_wait_interrupt(p);
1409 if (count == 0)
1410 break; /* Transmission should be stopped */
1411 if (count > left)
1412 count = left;
1413 if (count == 1) {
1414 writeb(*bufp, priv->regs.fifo);
1415 bufp++, left--;
1416 } else {
1417 writesb(priv->regs.fifo, bufp, count);
1418 bufp += count, left -= count;
1419 }
1420 }
1421
1422 priv->irq_mode = PARPORT_IP32_IRQ_FWD;
1423
1424 return len - left;
1425}
1426
1427/**
1428 * parport_ip32_fifo_write_block_dma - write a block of data (DMA mode)
1429 * @p: pointer to &struct parport
1430 * @buf: buffer of data to write
1431 * @len: length of buffer @buf
1432 *
1433 * Uses DMA to write the contents of the buffer @buf into the parallel port
1434 * FIFO. Returns the number of bytes that were actually written. The
1435 * parallel port must be correctly initialized before calling
1436 * parport_ip32_fifo_write_block_dma().
1437 */
1438static size_t parport_ip32_fifo_write_block_dma(struct parport *p,
1439 const void *buf, size_t len)
1440{
1441 struct parport_ip32_private * const priv = p->physport->private_data;
1442 struct parport * const physport = p->physport;
1443 unsigned long nfault_timeout;
1444 unsigned long expire;
1445 size_t written;
1446 unsigned int ecr;
1447
1448 priv->irq_mode = PARPORT_IP32_IRQ_HERE;
1449
1450 parport_ip32_dma_start(DMA_TO_DEVICE, (void *)buf, len);
1451 INIT_COMPLETION(priv->irq_complete);
1452 parport_ip32_frob_econtrol(p, ECR_DMAEN | ECR_SERVINTR, ECR_DMAEN);
1453
1454 nfault_timeout = min((unsigned long)physport->cad->timeout,
1455 msecs_to_jiffies(FIFO_NFAULT_TIMEOUT));
1456 expire = jiffies + physport->cad->timeout;
1457 while (1) {
1458 if (parport_ip32_fifo_wait_break(p, expire))
1459 break;
1460 wait_for_completion_interruptible_timeout(&priv->irq_complete,
1461 nfault_timeout);
1462 ecr = parport_ip32_read_econtrol(p);
1463 if (ecr & ECR_SERVINTR)
1464 break; /* DMA transfer just finished */
1465 }
1466 parport_ip32_dma_stop();
1467 written = len - parport_ip32_dma_get_residue();
1468
1469 priv->irq_mode = PARPORT_IP32_IRQ_FWD;
1470
1471 return written;
1472}
1473
1474/**
1475 * parport_ip32_fifo_write_block - write a block of data
1476 * @p: pointer to &struct parport
1477 * @buf: buffer of data to write
1478 * @len: length of buffer @buf
1479 *
1480 * Uses PIO or DMA to write the contents of the buffer @buf into the parallel
1481 * p FIFO. Returns the number of bytes that were actually written.
1482 */
1483static size_t parport_ip32_fifo_write_block(struct parport *p,
1484 const void *buf, size_t len)
1485{
1486 size_t written = 0;
1487 if (len)
1488 /* FIXME - Maybe some threshold value should be set for @len
1489 * under which we revert to PIO mode? */
1490 written = (p->modes & PARPORT_MODE_DMA) ?
1491 parport_ip32_fifo_write_block_dma(p, buf, len) :
1492 parport_ip32_fifo_write_block_pio(p, buf, len);
1493 return written;
1494}
1495
1496/**
1497 * parport_ip32_drain_fifo - wait for FIFO to empty
1498 * @p: pointer to &struct parport
1499 * @timeout: timeout, in jiffies
1500 *
1501 * This function waits for FIFO to empty. It returns 1 when FIFO is empty, or
1502 * 0 if the timeout @timeout is reached before, or if a signal is pending.
1503 */
1504static unsigned int parport_ip32_drain_fifo(struct parport *p,
1505 unsigned long timeout)
1506{
1507 unsigned long expire = jiffies + timeout;
1508 unsigned int polling_interval;
1509 unsigned int counter;
1510
1511 /* Busy wait for approx. 200us */
1512 for (counter = 0; counter < 40; counter++) {
1513 if (parport_ip32_read_econtrol(p) & ECR_F_EMPTY)
1514 break;
1515 if (time_after(jiffies, expire))
1516 break;
1517 if (signal_pending(current))
1518 break;
1519 udelay(5);
1520 }
1521 /* Poll slowly. Polling interval starts with 1 millisecond, and is
1522 * increased exponentially until 128. */
1523 polling_interval = 1; /* msecs */
1524 while (!(parport_ip32_read_econtrol(p) & ECR_F_EMPTY)) {
1525 if (time_after_eq(jiffies, expire))
1526 break;
1527 msleep_interruptible(polling_interval);
1528 if (signal_pending(current))
1529 break;
1530 if (polling_interval < 128)
1531 polling_interval *= 2;
1532 }
1533
1534 return !!(parport_ip32_read_econtrol(p) & ECR_F_EMPTY);
1535}
1536
1537/**
1538 * parport_ip32_get_fifo_residue - reset FIFO
1539 * @p: pointer to &struct parport
1540 * @mode: current operation mode (ECR_MODE_PPF or ECR_MODE_ECP)
1541 *
1542 * This function resets FIFO, and returns the number of bytes remaining in it.
1543 */
1544static unsigned int parport_ip32_get_fifo_residue(struct parport *p,
1545 unsigned int mode)
1546{
1547 struct parport_ip32_private * const priv = p->physport->private_data;
1548 unsigned int residue;
1549 unsigned int cnfga;
1550
1551 /* FIXME - We are missing one byte if the printer is off-line. I
1552 * don't know how to detect this. It looks that the full bit is not
1553 * always reliable. For the moment, the problem is avoided in most
1554 * cases by testing for BUSY in parport_ip32_compat_write_data().
1555 */
1556 if (parport_ip32_read_econtrol(p) & ECR_F_EMPTY)
1557 residue = 0;
1558 else {
1559 pr_debug1(PPIP32 "%s: FIFO is stuck\n", p->name);
1560
1561 /* Stop all transfers.
1562 *
1563 * Microsoft's document instructs to drive DCR_STROBE to 0,
1564 * but it doesn't work (at least in Compatibility mode, not
1565 * tested in ECP mode). Switching directly to Test mode (as
1566 * in parport_pc) is not an option: it does confuse the port,
1567 * ECP service interrupts are no more working after that. A
1568 * hard reset is then needed to revert to a sane state.
1569 *
1570 * Let's hope that the FIFO is really stuck and that the
1571 * peripheral doesn't wake up now.
1572 */
1573 parport_ip32_frob_control(p, DCR_STROBE, 0);
1574
1575 /* Fill up FIFO */
1576 for (residue = priv->fifo_depth; residue > 0; residue--) {
1577 if (parport_ip32_read_econtrol(p) & ECR_F_FULL)
1578 break;
1579 writeb(0x00, priv->regs.fifo);
1580 }
1581 }
1582 if (residue)
1583 pr_debug1(PPIP32 "%s: %d PWord%s left in FIFO\n",
1584 p->name, residue,
1585 (residue == 1) ? " was" : "s were");
1586
1587 /* Now reset the FIFO */
1588 parport_ip32_set_mode(p, ECR_MODE_PS2);
1589
1590 /* Host recovery for ECP mode */
1591 if (mode == ECR_MODE_ECP) {
1592 parport_ip32_data_reverse(p);
1593 parport_ip32_frob_control(p, DCR_nINIT, 0);
1594 if (parport_wait_peripheral(p, DSR_PERROR, 0))
1595 pr_debug1(PPIP32 "%s: PEerror timeout 1 in %s\n",
1596 p->name, __func__);
1597 parport_ip32_frob_control(p, DCR_STROBE, DCR_STROBE);
1598 parport_ip32_frob_control(p, DCR_nINIT, DCR_nINIT);
1599 if (parport_wait_peripheral(p, DSR_PERROR, DSR_PERROR))
1600 pr_debug1(PPIP32 "%s: PEerror timeout 2 in %s\n",
1601 p->name, __func__);
1602 }
1603
1604 /* Adjust residue if needed */
1605 parport_ip32_set_mode(p, ECR_MODE_CFG);
1606 cnfga = readb(priv->regs.cnfgA);
1607 if (!(cnfga & CNFGA_nBYTEINTRANS)) {
1608 pr_debug1(PPIP32 "%s: cnfgA contains 0x%02x\n",
1609 p->name, cnfga);
1610 pr_debug1(PPIP32 "%s: Accounting for extra byte\n",
1611 p->name);
1612 residue++;
1613 }
1614
1615 /* Don't care about partial PWords since we do not support
1616 * PWord != 1 byte. */
1617
1618 /* Back to forward PS2 mode. */
1619 parport_ip32_set_mode(p, ECR_MODE_PS2);
1620 parport_ip32_data_forward(p);
1621
1622 return residue;
1623}
1624
1625/**
1626 * parport_ip32_compat_write_data - write a block of data in SPP mode
1627 * @p: pointer to &struct parport
1628 * @buf: buffer of data to write
1629 * @len: length of buffer @buf
1630 * @flags: ignored
1631 */
1632static size_t parport_ip32_compat_write_data(struct parport *p,
1633 const void *buf, size_t len,
1634 int flags)
1635{
1636 static unsigned int ready_before = 1;
1637 struct parport_ip32_private * const priv = p->physport->private_data;
1638 struct parport * const physport = p->physport;
1639 size_t written = 0;
1640
1641 /* Special case: a timeout of zero means we cannot call schedule().
1642 * Also if O_NONBLOCK is set then use the default implementation. */
1643 if (physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
1644 return parport_ieee1284_write_compat(p, buf, len, flags);
1645
1646 /* Reset FIFO, go in forward mode, and disable ackIntEn */
1647 parport_ip32_set_mode(p, ECR_MODE_PS2);
1648 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
1649 parport_ip32_data_forward(p);
1650 parport_ip32_disable_irq(p);
1651 parport_ip32_set_mode(p, ECR_MODE_PPF);
1652 physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
1653
1654 /* Wait for peripheral to become ready */
1655 if (parport_wait_peripheral(p, DSR_nBUSY | DSR_nFAULT,
1656 DSR_nBUSY | DSR_nFAULT)) {
1657 /* Avoid to flood the logs */
1658 if (ready_before)
1659 printk(KERN_INFO PPIP32 "%s: not ready in %s\n",
1660 p->name, __func__);
1661 ready_before = 0;
1662 goto stop;
1663 }
1664 ready_before = 1;
1665
1666 written = parport_ip32_fifo_write_block(p, buf, len);
1667
1668 /* Wait FIFO to empty. Timeout is proportional to FIFO_depth. */
1669 parport_ip32_drain_fifo(p, physport->cad->timeout * priv->fifo_depth);
1670
1671 /* Check for a potential residue */
1672 written -= parport_ip32_get_fifo_residue(p, ECR_MODE_PPF);
1673
1674 /* Then, wait for BUSY to get low. */
1675 if (parport_wait_peripheral(p, DSR_nBUSY, DSR_nBUSY))
1676 printk(KERN_DEBUG PPIP32 "%s: BUSY timeout in %s\n",
1677 p->name, __func__);
1678
1679stop:
1680 /* Reset FIFO */
1681 parport_ip32_set_mode(p, ECR_MODE_PS2);
1682 physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
1683
1684 return written;
1685}
1686
1687/*
1688 * FIXME - Insert here parport_ip32_ecp_read_data().
1689 */
1690
1691/**
1692 * parport_ip32_ecp_write_data - write a block of data in ECP mode
1693 * @p: pointer to &struct parport
1694 * @buf: buffer of data to write
1695 * @len: length of buffer @buf
1696 * @flags: ignored
1697 */
1698static size_t parport_ip32_ecp_write_data(struct parport *p,
1699 const void *buf, size_t len,
1700 int flags)
1701{
1702 static unsigned int ready_before = 1;
1703 struct parport_ip32_private * const priv = p->physport->private_data;
1704 struct parport * const physport = p->physport;
1705 size_t written = 0;
1706
1707 /* Special case: a timeout of zero means we cannot call schedule().
1708 * Also if O_NONBLOCK is set then use the default implementation. */
1709 if (physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
1710 return parport_ieee1284_ecp_write_data(p, buf, len, flags);
1711
1712 /* Negotiate to forward mode if necessary. */
1713 if (physport->ieee1284.phase != IEEE1284_PH_FWD_IDLE) {
1714 /* Event 47: Set nInit high. */
1715 parport_ip32_frob_control(p, DCR_nINIT | DCR_AUTOFD,
1716 DCR_nINIT | DCR_AUTOFD);
1717
1718 /* Event 49: PError goes high. */
1719 if (parport_wait_peripheral(p, DSR_PERROR, DSR_PERROR)) {
1720 printk(KERN_DEBUG PPIP32 "%s: PError timeout in %s",
1721 p->name, __func__);
1722 physport->ieee1284.phase = IEEE1284_PH_ECP_DIR_UNKNOWN;
1723 return 0;
1724 }
1725 }
1726
1727 /* Reset FIFO, go in forward mode, and disable ackIntEn */
1728 parport_ip32_set_mode(p, ECR_MODE_PS2);
1729 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
1730 parport_ip32_data_forward(p);
1731 parport_ip32_disable_irq(p);
1732 parport_ip32_set_mode(p, ECR_MODE_ECP);
1733 physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
1734
1735 /* Wait for peripheral to become ready */
1736 if (parport_wait_peripheral(p, DSR_nBUSY | DSR_nFAULT,
1737 DSR_nBUSY | DSR_nFAULT)) {
1738 /* Avoid to flood the logs */
1739 if (ready_before)
1740 printk(KERN_INFO PPIP32 "%s: not ready in %s\n",
1741 p->name, __func__);
1742 ready_before = 0;
1743 goto stop;
1744 }
1745 ready_before = 1;
1746
1747 written = parport_ip32_fifo_write_block(p, buf, len);
1748
1749 /* Wait FIFO to empty. Timeout is proportional to FIFO_depth. */
1750 parport_ip32_drain_fifo(p, physport->cad->timeout * priv->fifo_depth);
1751
1752 /* Check for a potential residue */
1753 written -= parport_ip32_get_fifo_residue(p, ECR_MODE_ECP);
1754
1755 /* Then, wait for BUSY to get low. */
1756 if (parport_wait_peripheral(p, DSR_nBUSY, DSR_nBUSY))
1757 printk(KERN_DEBUG PPIP32 "%s: BUSY timeout in %s\n",
1758 p->name, __func__);
1759
1760stop:
1761 /* Reset FIFO */
1762 parport_ip32_set_mode(p, ECR_MODE_PS2);
1763 physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
1764
1765 return written;
1766}
1767
1768/*
1769 * FIXME - Insert here parport_ip32_ecp_write_addr().
1770 */
1771
1772/*--- Default parport operations ---------------------------------------*/
1773
1774static __initdata struct parport_operations parport_ip32_ops = {
1775 .write_data = parport_ip32_write_data,
1776 .read_data = parport_ip32_read_data,
1777
1778 .write_control = parport_ip32_write_control,
1779 .read_control = parport_ip32_read_control,
1780 .frob_control = parport_ip32_frob_control,
1781
1782 .read_status = parport_ip32_read_status,
1783
1784 .enable_irq = parport_ip32_enable_irq,
1785 .disable_irq = parport_ip32_disable_irq,
1786
1787 .data_forward = parport_ip32_data_forward,
1788 .data_reverse = parport_ip32_data_reverse,
1789
1790 .init_state = parport_ip32_init_state,
1791 .save_state = parport_ip32_save_state,
1792 .restore_state = parport_ip32_restore_state,
1793
1794 .epp_write_data = parport_ieee1284_epp_write_data,
1795 .epp_read_data = parport_ieee1284_epp_read_data,
1796 .epp_write_addr = parport_ieee1284_epp_write_addr,
1797 .epp_read_addr = parport_ieee1284_epp_read_addr,
1798
1799 .ecp_write_data = parport_ieee1284_ecp_write_data,
1800 .ecp_read_data = parport_ieee1284_ecp_read_data,
1801 .ecp_write_addr = parport_ieee1284_ecp_write_addr,
1802
1803 .compat_write_data = parport_ieee1284_write_compat,
1804 .nibble_read_data = parport_ieee1284_read_nibble,
1805 .byte_read_data = parport_ieee1284_read_byte,
1806
1807 .owner = THIS_MODULE,
1808};
1809
1810/*--- Device detection -------------------------------------------------*/
1811
1812/**
1813 * parport_ip32_ecp_supported - check for an ECP port
1814 * @p: pointer to the &parport structure
1815 *
1816 * Returns 1 if an ECP port is found, and 0 otherwise. This function actually
1817 * checks if an Extended Control Register seems to be present. On successful
1818 * return, the port is placed in SPP mode.
1819 */
1820static __init unsigned int parport_ip32_ecp_supported(struct parport *p)
1821{
1822 struct parport_ip32_private * const priv = p->physport->private_data;
1823 unsigned int ecr;
1824
1825 ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR;
1826 writeb(ecr, priv->regs.ecr);
1827 if (readb(priv->regs.ecr) != (ecr | ECR_F_EMPTY))
1828 goto fail;
1829
1830 pr_probe(p, "Found working ECR register\n");
1831 parport_ip32_set_mode(p, ECR_MODE_SPP);
1832 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
1833 return 1;
1834
1835fail:
1836 pr_probe(p, "ECR register not found\n");
1837 return 0;
1838}
1839
1840/**
1841 * parport_ip32_fifo_supported - check for FIFO parameters
1842 * @p: pointer to the &parport structure
1843 *
1844 * Check for FIFO parameters of an Extended Capabilities Port. Returns 1 on
1845 * success, and 0 otherwise. Adjust FIFO parameters in the parport structure.
1846 * On return, the port is placed in SPP mode.
1847 */
1848static __init unsigned int parport_ip32_fifo_supported(struct parport *p)
1849{
1850 struct parport_ip32_private * const priv = p->physport->private_data;
1851 unsigned int configa, configb;
1852 unsigned int pword;
1853 unsigned int i;
1854
1855 /* Configuration mode */
1856 parport_ip32_set_mode(p, ECR_MODE_CFG);
1857 configa = readb(priv->regs.cnfgA);
1858 configb = readb(priv->regs.cnfgB);
1859
1860 /* Find out PWord size */
1861 switch (configa & CNFGA_ID_MASK) {
1862 case CNFGA_ID_8:
1863 pword = 1;
1864 break;
1865 case CNFGA_ID_16:
1866 pword = 2;
1867 break;
1868 case CNFGA_ID_32:
1869 pword = 4;
1870 break;
1871 default:
1872 pr_probe(p, "Unknown implementation ID: 0x%0x\n",
1873 (configa & CNFGA_ID_MASK) >> CNFGA_ID_SHIFT);
1874 goto fail;
1875 break;
1876 }
1877 if (pword != 1) {
1878 pr_probe(p, "Unsupported PWord size: %u\n", pword);
1879 goto fail;
1880 }
1881 priv->pword = pword;
1882 pr_probe(p, "PWord is %u bits\n", 8 * priv->pword);
1883
1884 /* Check for compression support */
1885 writeb(configb | CNFGB_COMPRESS, priv->regs.cnfgB);
1886 if (readb(priv->regs.cnfgB) & CNFGB_COMPRESS)
1887 pr_probe(p, "Hardware compression detected (unsupported)\n");
1888 writeb(configb & ~CNFGB_COMPRESS, priv->regs.cnfgB);
1889
1890 /* Reset FIFO and go in test mode (no interrupt, no DMA) */
1891 parport_ip32_set_mode(p, ECR_MODE_TST);
1892
1893 /* FIFO must be empty now */
1894 if (!(readb(priv->regs.ecr) & ECR_F_EMPTY)) {
1895 pr_probe(p, "FIFO not reset\n");
1896 goto fail;
1897 }
1898
1899 /* Find out FIFO depth. */
1900 priv->fifo_depth = 0;
1901 for (i = 0; i < 1024; i++) {
1902 if (readb(priv->regs.ecr) & ECR_F_FULL) {
1903 /* FIFO full */
1904 priv->fifo_depth = i;
1905 break;
1906 }
1907 writeb((u8)i, priv->regs.fifo);
1908 }
1909 if (i >= 1024) {
1910 pr_probe(p, "Can't fill FIFO\n");
1911 goto fail;
1912 }
1913 if (!priv->fifo_depth) {
1914 pr_probe(p, "Can't get FIFO depth\n");
1915 goto fail;
1916 }
1917 pr_probe(p, "FIFO is %u PWords deep\n", priv->fifo_depth);
1918
1919 /* Enable interrupts */
1920 parport_ip32_frob_econtrol(p, ECR_SERVINTR, 0);
1921
1922 /* Find out writeIntrThreshold: number of PWords we know we can write
1923 * if we get an interrupt. */
1924 priv->writeIntrThreshold = 0;
1925 for (i = 0; i < priv->fifo_depth; i++) {
1926 if (readb(priv->regs.fifo) != (u8)i) {
1927 pr_probe(p, "Invalid data in FIFO\n");
1928 goto fail;
1929 }
1930 if (!priv->writeIntrThreshold
1931 && readb(priv->regs.ecr) & ECR_SERVINTR)
1932 /* writeIntrThreshold reached */
1933 priv->writeIntrThreshold = i + 1;
1934 if (i + 1 < priv->fifo_depth
1935 && readb(priv->regs.ecr) & ECR_F_EMPTY) {
1936 /* FIFO empty before the last byte? */
1937 pr_probe(p, "Data lost in FIFO\n");
1938 goto fail;
1939 }
1940 }
1941 if (!priv->writeIntrThreshold) {
1942 pr_probe(p, "Can't get writeIntrThreshold\n");
1943 goto fail;
1944 }
1945 pr_probe(p, "writeIntrThreshold is %u\n", priv->writeIntrThreshold);
1946
1947 /* FIFO must be empty now */
1948 if (!(readb(priv->regs.ecr) & ECR_F_EMPTY)) {
1949 pr_probe(p, "Can't empty FIFO\n");
1950 goto fail;
1951 }
1952
1953 /* Reset FIFO */
1954 parport_ip32_set_mode(p, ECR_MODE_PS2);
1955 /* Set reverse direction (must be in PS2 mode) */
1956 parport_ip32_data_reverse(p);
1957 /* Test FIFO, no interrupt, no DMA */
1958 parport_ip32_set_mode(p, ECR_MODE_TST);
1959 /* Enable interrupts */
1960 parport_ip32_frob_econtrol(p, ECR_SERVINTR, 0);
1961
1962 /* Find out readIntrThreshold: number of PWords we can read if we get
1963 * an interrupt. */
1964 priv->readIntrThreshold = 0;
1965 for (i = 0; i < priv->fifo_depth; i++) {
1966 writeb(0xaa, priv->regs.fifo);
1967 if (readb(priv->regs.ecr) & ECR_SERVINTR) {
1968 /* readIntrThreshold reached */
1969 priv->readIntrThreshold = i + 1;
1970 break;
1971 }
1972 }
1973 if (!priv->readIntrThreshold) {
1974 pr_probe(p, "Can't get readIntrThreshold\n");
1975 goto fail;
1976 }
1977 pr_probe(p, "readIntrThreshold is %u\n", priv->readIntrThreshold);
1978
1979 /* Reset ECR */
1980 parport_ip32_set_mode(p, ECR_MODE_PS2);
1981 parport_ip32_data_forward(p);
1982 parport_ip32_set_mode(p, ECR_MODE_SPP);
1983 return 1;
1984
1985fail:
1986 priv->fifo_depth = 0;
1987 parport_ip32_set_mode(p, ECR_MODE_SPP);
1988 return 0;
1989}
1990
1991/*--- Initialization code ----------------------------------------------*/
1992
1993/**
1994 * parport_ip32_make_isa_registers - compute (ISA) register addresses
1995 * @regs: pointer to &struct parport_ip32_regs to fill
1996 * @base: base address of standard and EPP registers
1997 * @base_hi: base address of ECP registers
1998 * @regshift: how much to shift register offset by
1999 *
2000 * Compute register addresses, according to the ISA standard. The addresses
2001 * of the standard and EPP registers are computed from address @base. The
2002 * addresses of the ECP registers are computed from address @base_hi.
2003 */
2004static void __init
2005parport_ip32_make_isa_registers(struct parport_ip32_regs *regs,
2006 void __iomem *base, void __iomem *base_hi,
2007 unsigned int regshift)
2008{
2009#define r_base(offset) ((u8 __iomem *)base + ((offset) << regshift))
2010#define r_base_hi(offset) ((u8 __iomem *)base_hi + ((offset) << regshift))
2011 *regs = (struct parport_ip32_regs){
2012 .data = r_base(0),
2013 .dsr = r_base(1),
2014 .dcr = r_base(2),
2015 .eppAddr = r_base(3),
2016 .eppData0 = r_base(4),
2017 .eppData1 = r_base(5),
2018 .eppData2 = r_base(6),
2019 .eppData3 = r_base(7),
2020 .ecpAFifo = r_base(0),
2021 .fifo = r_base_hi(0),
2022 .cnfgA = r_base_hi(0),
2023 .cnfgB = r_base_hi(1),
2024 .ecr = r_base_hi(2)
2025 };
2026#undef r_base_hi
2027#undef r_base
2028}
2029
2030/**
2031 * parport_ip32_probe_port - probe and register IP32 built-in parallel port
2032 *
2033 * Returns the new allocated &parport structure. On error, an error code is
2034 * encoded in return value with the ERR_PTR function.
2035 */
2036static __init struct parport *parport_ip32_probe_port(void)
2037{
2038 struct parport_ip32_regs regs;
2039 struct parport_ip32_private *priv = NULL;
2040 struct parport_operations *ops = NULL;
2041 struct parport *p = NULL;
2042 int err;
2043
2044 parport_ip32_make_isa_registers(&regs, &mace->isa.parallel,
2045 &mace->isa.ecp1284, 8 /* regshift */);
2046
2047 ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
2048 priv = kmalloc(sizeof(struct parport_ip32_private), GFP_KERNEL);
2049 p = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, ops);
2050 if (ops == NULL || priv == NULL || p == NULL) {
2051 err = -ENOMEM;
2052 goto fail;
2053 }
2054 p->base = MACE_BASE + offsetof(struct sgi_mace, isa.parallel);
2055 p->base_hi = MACE_BASE + offsetof(struct sgi_mace, isa.ecp1284);
2056 p->private_data = priv;
2057
2058 *ops = parport_ip32_ops;
2059 *priv = (struct parport_ip32_private){
2060 .regs = regs,
2061 .dcr_writable = DCR_DIR | DCR_SELECT | DCR_nINIT |
2062 DCR_AUTOFD | DCR_STROBE,
2063 .irq_mode = PARPORT_IP32_IRQ_FWD,
2064 };
2065 init_completion(&priv->irq_complete);
2066
2067 /* Probe port. */
2068 if (!parport_ip32_ecp_supported(p)) {
2069 err = -ENODEV;
2070 goto fail;
2071 }
2072 parport_ip32_dump_state(p, "begin init", 0);
2073
2074 /* We found what looks like a working ECR register. Simply assume
2075 * that all modes are correctly supported. Enable basic modes. */
2076 p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
2077 p->modes |= PARPORT_MODE_TRISTATE;
2078
2079 if (!parport_ip32_fifo_supported(p)) {
2080 printk(KERN_WARNING PPIP32
2081 "%s: error: FIFO disabled\n", p->name);
2082 /* Disable hardware modes depending on a working FIFO. */
2083 features &= ~PARPORT_IP32_ENABLE_SPP;
2084 features &= ~PARPORT_IP32_ENABLE_ECP;
2085 /* DMA is not needed if FIFO is not supported. */
2086 features &= ~PARPORT_IP32_ENABLE_DMA;
2087 }
2088
2089 /* Request IRQ */
2090 if (features & PARPORT_IP32_ENABLE_IRQ) {
2091 int irq = MACEISA_PARALLEL_IRQ;
2092 if (request_irq(irq, parport_ip32_interrupt, 0, p->name, p)) {
2093 printk(KERN_WARNING PPIP32
2094 "%s: error: IRQ disabled\n", p->name);
2095 /* DMA cannot work without interrupts. */
2096 features &= ~PARPORT_IP32_ENABLE_DMA;
2097 } else {
2098 pr_probe(p, "Interrupt support enabled\n");
2099 p->irq = irq;
2100 priv->dcr_writable |= DCR_IRQ;
2101 }
2102 }
2103
2104 /* Allocate DMA resources */
2105 if (features & PARPORT_IP32_ENABLE_DMA) {
2106 if (parport_ip32_dma_register())
2107 printk(KERN_WARNING PPIP32
2108 "%s: error: DMA disabled\n", p->name);
2109 else {
2110 pr_probe(p, "DMA support enabled\n");
2111 p->dma = 0; /* arbitrary value != PARPORT_DMA_NONE */
2112 p->modes |= PARPORT_MODE_DMA;
2113 }
2114 }
2115
2116 if (features & PARPORT_IP32_ENABLE_SPP) {
2117 /* Enable compatibility FIFO mode */
2118 p->ops->compat_write_data = parport_ip32_compat_write_data;
2119 p->modes |= PARPORT_MODE_COMPAT;
2120 pr_probe(p, "Hardware support for SPP mode enabled\n");
2121 }
2122 if (features & PARPORT_IP32_ENABLE_EPP) {
2123 /* Set up access functions to use EPP hardware. */
2124 p->ops->epp_read_data = parport_ip32_epp_read_data;
2125 p->ops->epp_write_data = parport_ip32_epp_write_data;
2126 p->ops->epp_read_addr = parport_ip32_epp_read_addr;
2127 p->ops->epp_write_addr = parport_ip32_epp_write_addr;
2128 p->modes |= PARPORT_MODE_EPP;
2129 pr_probe(p, "Hardware support for EPP mode enabled\n");
2130 }
2131 if (features & PARPORT_IP32_ENABLE_ECP) {
2132 /* Enable ECP FIFO mode */
2133 p->ops->ecp_write_data = parport_ip32_ecp_write_data;
2134 /* FIXME - not implemented */
2135/* p->ops->ecp_read_data = parport_ip32_ecp_read_data; */
2136/* p->ops->ecp_write_addr = parport_ip32_ecp_write_addr; */
2137 p->modes |= PARPORT_MODE_ECP;
2138 pr_probe(p, "Hardware support for ECP mode enabled\n");
2139 }
2140
2141 /* Initialize the port with sensible values */
2142 parport_ip32_set_mode(p, ECR_MODE_PS2);
2143 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
2144 parport_ip32_data_forward(p);
2145 parport_ip32_disable_irq(p);
2146 parport_ip32_write_data(p, 0x00);
2147 parport_ip32_dump_state(p, "end init", 0);
2148
2149 /* Print out what we found */
2150 printk(KERN_INFO "%s: SGI IP32 at 0x%lx (0x%lx)",
2151 p->name, p->base, p->base_hi);
2152 if (p->irq != PARPORT_IRQ_NONE)
2153 printk(", irq %d", p->irq);
2154 printk(" [");
2155#define printmode(x) if (p->modes & PARPORT_MODE_##x) \
2156 printk("%s%s", f++ ? "," : "", #x)
2157 {
2158 unsigned int f = 0;
2159 printmode(PCSPP);
2160 printmode(TRISTATE);
2161 printmode(COMPAT);
2162 printmode(EPP);
2163 printmode(ECP);
2164 printmode(DMA);
2165 }
2166#undef printmode
2167 printk("]\n");
2168
2169 parport_announce_port(p);
2170 return p;
2171
2172fail:
2173 if (p)
2174 parport_put_port(p);
2175 kfree(priv);
2176 kfree(ops);
2177 return ERR_PTR(err);
2178}
2179
2180/**
2181 * parport_ip32_unregister_port - unregister a parallel port
2182 * @p: pointer to the &struct parport
2183 *
2184 * Unregisters a parallel port and free previously allocated resources
2185 * (memory, IRQ, ...).
2186 */
2187static __exit void parport_ip32_unregister_port(struct parport *p)
2188{
2189 struct parport_ip32_private * const priv = p->physport->private_data;
2190 struct parport_operations *ops = p->ops;
2191
2192 parport_remove_port(p);
2193 if (p->modes & PARPORT_MODE_DMA)
2194 parport_ip32_dma_unregister();
2195 if (p->irq != PARPORT_IRQ_NONE)
2196 free_irq(p->irq, p);
2197 parport_put_port(p);
2198 kfree(priv);
2199 kfree(ops);
2200}
2201
2202/**
2203 * parport_ip32_init - module initialization function
2204 */
2205static int __init parport_ip32_init(void)
2206{
2207 pr_info(PPIP32 "SGI IP32 built-in parallel port driver v0.6\n");
2208 pr_debug1(PPIP32 "Compiled on %s, %s\n", __DATE__, __TIME__);
2209 this_port = parport_ip32_probe_port();
2210 return IS_ERR(this_port) ? PTR_ERR(this_port) : 0;
2211}
2212
2213/**
2214 * parport_ip32_exit - module termination function
2215 */
2216static void __exit parport_ip32_exit(void)
2217{
2218 parport_ip32_unregister_port(this_port);
2219}
2220
2221/*--- Module stuff -----------------------------------------------------*/
2222
2223MODULE_AUTHOR("Arnaud Giersch <arnaud.giersch@free.fr>");
2224MODULE_DESCRIPTION("SGI IP32 built-in parallel port driver");
2225MODULE_LICENSE("GPL");
2226MODULE_VERSION("0.6"); /* update in parport_ip32_init() too */
2227
2228module_init(parport_ip32_init);
2229module_exit(parport_ip32_exit);
2230
2231module_param(verbose_probing, bool, S_IRUGO);
2232MODULE_PARM_DESC(verbose_probing, "Log chit-chat during initialization");
2233
2234module_param(features, uint, S_IRUGO);
2235MODULE_PARM_DESC(features,
2236 "Bit mask of features to enable"
2237 ", bit 0: IRQ support"
2238 ", bit 1: DMA support"
2239 ", bit 2: hardware SPP mode"
2240 ", bit 3: hardware EPP mode"
2241 ", bit 4: hardware ECP mode");
2242
2243/*--- Inform (X)Emacs about preferred coding style ---------------------*/
2244/*
2245 * Local Variables:
2246 * mode: c
2247 * c-file-style: "linux"
2248 * indent-tabs-mode: t
2249 * tab-width: 8
2250 * fill-column: 78
2251 * ispell-local-dictionary: "american"
2252 * End:
2253 */
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 76dd077e3184..166de3507780 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -329,9 +329,9 @@ static int __devinit parport_register (struct pci_dev *dev,
329 329
330 if (priv->num_par == ARRAY_SIZE (priv->port)) { 330 if (priv->num_par == ARRAY_SIZE (priv->port)) {
331 printk (KERN_WARNING 331 printk (KERN_WARNING
332 "parport_serial: %s: only %u parallel ports " 332 "parport_serial: %s: only %zu parallel ports "
333 "supported (%d reported)\n", pci_name (dev), 333 "supported (%d reported)\n", pci_name (dev),
334 ARRAY_SIZE (priv->port), card->numports); 334 ARRAY_SIZE(priv->port), card->numports);
335 break; 335 break;
336 } 336 }
337 337
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index b62aee8de3cb..ea83b70e0de2 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -199,7 +199,7 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer,
199 199
200 if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) { 200 if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) {
201 if (belen != len) { 201 if (belen != len) {
202 printk (KERN_DEBUG "%s: Device ID was %d bytes" 202 printk (KERN_DEBUG "%s: Device ID was %zd bytes"
203 " while device told it would be %d" 203 " while device told it would be %d"
204 " bytes\n", 204 " bytes\n",
205 port->name, len, belen); 205 port->name, len, belen);
@@ -214,7 +214,7 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer,
214 if (buffer[len-1] == ';') { 214 if (buffer[len-1] == ';') {
215 printk (KERN_DEBUG "%s: Device ID reading stopped" 215 printk (KERN_DEBUG "%s: Device ID reading stopped"
216 " before device told data not available. " 216 " before device told data not available. "
217 "Current idlen %d of %d, len bytes %02X %02X\n", 217 "Current idlen %u of %u, len bytes %02X %02X\n",
218 port->name, current_idlen, numidlens, 218 port->name, current_idlen, numidlens,
219 length[0], length[1]); 219 length[0], length[1]);
220 goto done; 220 goto done;
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 04cc1e7275ce..78943e064b59 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -159,6 +159,7 @@ int rpaphp_deregister_slot(struct slot *slot)
159 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 159 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
160 return retval; 160 return retval;
161} 161}
162EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
162 163
163int rpaphp_register_slot(struct slot *slot) 164int rpaphp_register_slot(struct slot *slot)
164{ 165{
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 0ecbe4edbec1..aaa568a3806e 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -363,7 +363,7 @@ static int card_resume(struct pnp_dev *dev)
363 363
364int pnp_register_card_driver(struct pnp_card_driver * drv) 364int pnp_register_card_driver(struct pnp_card_driver * drv)
365{ 365{
366 int count = 0; 366 int count;
367 struct list_head *pos, *temp; 367 struct list_head *pos, *temp;
368 368
369 drv->link.name = drv->name; 369 drv->link.name = drv->name;
@@ -374,10 +374,15 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
374 drv->link.suspend = drv->suspend ? card_suspend : NULL; 374 drv->link.suspend = drv->suspend ? card_suspend : NULL;
375 drv->link.resume = drv->resume ? card_resume : NULL; 375 drv->link.resume = drv->resume ? card_resume : NULL;
376 376
377 count = pnp_register_driver(&drv->link);
378 if (count < 0)
379 return count;
380
377 spin_lock(&pnp_lock); 381 spin_lock(&pnp_lock);
378 list_add_tail(&drv->global_list, &pnp_card_drivers); 382 list_add_tail(&drv->global_list, &pnp_card_drivers);
379 spin_unlock(&pnp_lock); 383 spin_unlock(&pnp_lock);
380 pnp_register_driver(&drv->link); 384
385 count = 0;
381 386
382 list_for_each_safe(pos,temp,&pnp_cards){ 387 list_for_each_safe(pos,temp,&pnp_cards){
383 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); 388 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 816479ad217b..f104577f73e0 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -27,12 +27,15 @@
27 27
28static int num = 0; 28static int num = 0;
29 29
30/* We need only to blacklist devices that have already an acpi driver that
31 * can't use pnp layer. We don't need to blacklist device that are directly
32 * used by the kernel (PCI root, ...), as it is harmless and there were
33 * already present in pnpbios. But there is an exception for devices that
34 * have irqs (PIC, Timer) because we call acpi_register_gsi.
35 * Finaly only devices that have a CRS method need to be in this list.
36 */
30static char __initdata excluded_id_list[] = 37static char __initdata excluded_id_list[] =
31 "PNP0C0A," /* Battery */
32 "PNP0C0C,PNP0C0E,PNP0C0D," /* Button */
33 "PNP0C09," /* EC */ 38 "PNP0C09," /* EC */
34 "PNP0C0B," /* Fan */
35 "PNP0A03," /* PCI root */
36 "PNP0C0F," /* Link device */ 39 "PNP0C0F," /* Link device */
37 "PNP0000," /* PIC */ 40 "PNP0000," /* PIC */
38 "PNP0100," /* Timer */ 41 "PNP0100," /* Timer */
@@ -131,7 +134,8 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
131 struct pnp_id *dev_id; 134 struct pnp_id *dev_id;
132 struct pnp_dev *dev; 135 struct pnp_dev *dev;
133 136
134 if (!ispnpidacpi(acpi_device_hid(device)) || 137 status = acpi_get_handle(device->handle, "_CRS", &temp);
138 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
135 is_exclusive_device(device)) 139 is_exclusive_device(device))
136 return 0; 140 return 0;
137 141
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 416d30debe6c..407b4eaddcbf 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr> 4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com> 5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any 9 * Free Software Foundation; either version 2, or (at your option) any
@@ -32,17 +32,17 @@
32/* 32/*
33 * Allocated Resources 33 * Allocated Resources
34 */ 34 */
35static int irq_flags(int edge_level, int active_high_low) 35static int irq_flags(int triggering, int polarity)
36{ 36{
37 int flag; 37 int flag;
38 if (edge_level == ACPI_LEVEL_SENSITIVE) { 38 if (triggering == ACPI_LEVEL_SENSITIVE) {
39 if(active_high_low == ACPI_ACTIVE_LOW) 39 if(polarity == ACPI_ACTIVE_LOW)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 40 flag = IORESOURCE_IRQ_LOWLEVEL;
41 else 41 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 42 flag = IORESOURCE_IRQ_HIGHLEVEL;
43 } 43 }
44 else { 44 else {
45 if(active_high_low == ACPI_ACTIVE_LOW) 45 if(polarity == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE; 46 flag = IORESOURCE_IRQ_LOWEDGE;
47 else 47 else
48 flag = IORESOURCE_IRQ_HIGHEDGE; 48 flag = IORESOURCE_IRQ_HIGHEDGE;
@@ -50,31 +50,31 @@ static int irq_flags(int edge_level, int active_high_low)
50 return flag; 50 return flag;
51} 51}
52 52
53static void decode_irq_flags(int flag, int *edge_level, int *active_high_low) 53static void decode_irq_flags(int flag, int *triggering, int *polarity)
54{ 54{
55 switch (flag) { 55 switch (flag) {
56 case IORESOURCE_IRQ_LOWLEVEL: 56 case IORESOURCE_IRQ_LOWLEVEL:
57 *edge_level = ACPI_LEVEL_SENSITIVE; 57 *triggering = ACPI_LEVEL_SENSITIVE;
58 *active_high_low = ACPI_ACTIVE_LOW; 58 *polarity = ACPI_ACTIVE_LOW;
59 break; 59 break;
60 case IORESOURCE_IRQ_HIGHLEVEL: 60 case IORESOURCE_IRQ_HIGHLEVEL:
61 *edge_level = ACPI_LEVEL_SENSITIVE; 61 *triggering = ACPI_LEVEL_SENSITIVE;
62 *active_high_low = ACPI_ACTIVE_HIGH; 62 *polarity = ACPI_ACTIVE_HIGH;
63 break; 63 break;
64 case IORESOURCE_IRQ_LOWEDGE: 64 case IORESOURCE_IRQ_LOWEDGE:
65 *edge_level = ACPI_EDGE_SENSITIVE; 65 *triggering = ACPI_EDGE_SENSITIVE;
66 *active_high_low = ACPI_ACTIVE_LOW; 66 *polarity = ACPI_ACTIVE_LOW;
67 break; 67 break;
68 case IORESOURCE_IRQ_HIGHEDGE: 68 case IORESOURCE_IRQ_HIGHEDGE:
69 *edge_level = ACPI_EDGE_SENSITIVE; 69 *triggering = ACPI_EDGE_SENSITIVE;
70 *active_high_low = ACPI_ACTIVE_HIGH; 70 *polarity = ACPI_ACTIVE_HIGH;
71 break; 71 break;
72 } 72 }
73} 73}
74 74
75static void 75static void
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, 76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
77 int edge_level, int active_high_low) 77 int triggering, int polarity)
78{ 78{
79 int i = 0; 79 int i = 0;
80 int irq; 80 int irq;
@@ -89,7 +89,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
89 return; 89 return;
90 90
91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
92 irq = acpi_register_gsi(gsi, edge_level, active_high_low); 92 irq = acpi_register_gsi(gsi, triggering, polarity);
93 if (irq < 0) { 93 if (irq < 0) {
94 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 94 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
95 return; 95 return;
@@ -163,77 +163,96 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
163 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; 163 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data;
164 int i; 164 int i;
165 165
166 switch (res->id) { 166 switch (res->type) {
167 case ACPI_RSTYPE_IRQ: 167 case ACPI_RESOURCE_TYPE_IRQ:
168 /* 168 /*
169 * Per spec, only one interrupt per descriptor is allowed in 169 * Per spec, only one interrupt per descriptor is allowed in
170 * _CRS, but some firmware violates this, so parse them all. 170 * _CRS, but some firmware violates this, so parse them all.
171 */ 171 */
172 for (i = 0; i < res->data.irq.number_of_interrupts; i++) { 172 for (i = 0; i < res->data.irq.interrupt_count; i++) {
173 pnpacpi_parse_allocated_irqresource(res_table, 173 pnpacpi_parse_allocated_irqresource(res_table,
174 res->data.irq.interrupts[i], 174 res->data.irq.interrupts[i],
175 res->data.irq.edge_level, 175 res->data.irq.triggering,
176 res->data.irq.active_high_low); 176 res->data.irq.polarity);
177 } 177 }
178 break; 178 break;
179 179
180 case ACPI_RSTYPE_EXT_IRQ: 180 case ACPI_RESOURCE_TYPE_DMA:
181 for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) { 181 if (res->data.dma.channel_count > 0)
182 pnpacpi_parse_allocated_irqresource(res_table, 182 pnpacpi_parse_allocated_dmaresource(res_table,
183 res->data.extended_irq.interrupts[i],
184 res->data.extended_irq.edge_level,
185 res->data.extended_irq.active_high_low);
186 }
187 break;
188 case ACPI_RSTYPE_DMA:
189 if (res->data.dma.number_of_channels > 0)
190 pnpacpi_parse_allocated_dmaresource(res_table,
191 res->data.dma.channels[0]); 183 res->data.dma.channels[0]);
192 break; 184 break;
193 case ACPI_RSTYPE_IO: 185
194 pnpacpi_parse_allocated_ioresource(res_table, 186 case ACPI_RESOURCE_TYPE_IO:
195 res->data.io.min_base_address, 187 pnpacpi_parse_allocated_ioresource(res_table,
196 res->data.io.range_length); 188 res->data.io.minimum,
189 res->data.io.address_length);
197 break; 190 break;
198 case ACPI_RSTYPE_FIXED_IO: 191
199 pnpacpi_parse_allocated_ioresource(res_table, 192 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
200 res->data.fixed_io.base_address, 193 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
201 res->data.fixed_io.range_length);
202 break; 194 break;
203 case ACPI_RSTYPE_MEM24: 195
204 pnpacpi_parse_allocated_memresource(res_table, 196 case ACPI_RESOURCE_TYPE_FIXED_IO:
205 res->data.memory24.min_base_address, 197 pnpacpi_parse_allocated_ioresource(res_table,
206 res->data.memory24.range_length); 198 res->data.fixed_io.address,
199 res->data.fixed_io.address_length);
200 break;
201
202 case ACPI_RESOURCE_TYPE_VENDOR:
207 break; 203 break;
208 case ACPI_RSTYPE_MEM32: 204
209 pnpacpi_parse_allocated_memresource(res_table, 205 case ACPI_RESOURCE_TYPE_END_TAG:
210 res->data.memory32.min_base_address, 206 break;
211 res->data.memory32.range_length); 207
208 case ACPI_RESOURCE_TYPE_MEMORY24:
209 pnpacpi_parse_allocated_memresource(res_table,
210 res->data.memory24.minimum,
211 res->data.memory24.address_length);
212 break; 212 break;
213 case ACPI_RSTYPE_FIXED_MEM32: 213 case ACPI_RESOURCE_TYPE_MEMORY32:
214 pnpacpi_parse_allocated_memresource(res_table, 214 pnpacpi_parse_allocated_memresource(res_table,
215 res->data.fixed_memory32.range_base_address, 215 res->data.memory32.minimum,
216 res->data.fixed_memory32.range_length); 216 res->data.memory32.address_length);
217 break; 217 break;
218 case ACPI_RSTYPE_ADDRESS16: 218 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
219 pnpacpi_parse_allocated_memresource(res_table, 219 pnpacpi_parse_allocated_memresource(res_table,
220 res->data.address16.min_address_range, 220 res->data.fixed_memory32.address,
221 res->data.fixed_memory32.address_length);
222 break;
223 case ACPI_RESOURCE_TYPE_ADDRESS16:
224 pnpacpi_parse_allocated_memresource(res_table,
225 res->data.address16.minimum,
221 res->data.address16.address_length); 226 res->data.address16.address_length);
222 break; 227 break;
223 case ACPI_RSTYPE_ADDRESS32: 228 case ACPI_RESOURCE_TYPE_ADDRESS32:
224 pnpacpi_parse_allocated_memresource(res_table, 229 pnpacpi_parse_allocated_memresource(res_table,
225 res->data.address32.min_address_range, 230 res->data.address32.minimum,
226 res->data.address32.address_length); 231 res->data.address32.address_length);
227 break; 232 break;
228 case ACPI_RSTYPE_ADDRESS64: 233 case ACPI_RESOURCE_TYPE_ADDRESS64:
229 pnpacpi_parse_allocated_memresource(res_table, 234 pnpacpi_parse_allocated_memresource(res_table,
230 res->data.address64.min_address_range, 235 res->data.address64.minimum,
231 res->data.address64.address_length); 236 res->data.address64.address_length);
232 break; 237 break;
233 case ACPI_RSTYPE_VENDOR: 238
239 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
240 break;
241
242 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
243 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
244 pnpacpi_parse_allocated_irqresource(res_table,
245 res->data.extended_irq.interrupts[i],
246 res->data.extended_irq.triggering,
247 res->data.extended_irq.polarity);
248 }
249 break;
250
251 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
234 break; 252 break;
253
235 default: 254 default:
236 pnp_warn("PnPACPI: unknown resource type %d", res->id); 255 pnp_warn("PnPACPI: unknown resource type %d", res->type);
237 return AE_ERROR; 256 return AE_ERROR;
238 } 257 }
239 258
@@ -253,13 +272,13 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
253 int i; 272 int i;
254 struct pnp_dma * dma; 273 struct pnp_dma * dma;
255 274
256 if (p->number_of_channels == 0) 275 if (p->channel_count == 0)
257 return; 276 return;
258 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 277 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
259 if (!dma) 278 if (!dma)
260 return; 279 return;
261 280
262 for(i = 0; i < p->number_of_channels; i++) 281 for(i = 0; i < p->channel_count; i++)
263 dma->map |= 1 << p->channels[i]; 282 dma->map |= 1 << p->channels[i];
264 dma->flags = 0; 283 dma->flags = 0;
265 if (p->bus_master) 284 if (p->bus_master)
@@ -309,37 +328,37 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
309 int i; 328 int i;
310 struct pnp_irq * irq; 329 struct pnp_irq * irq;
311 330
312 if (p->number_of_interrupts == 0) 331 if (p->interrupt_count == 0)
313 return; 332 return;
314 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 333 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
315 if (!irq) 334 if (!irq)
316 return; 335 return;
317 336
318 for(i = 0; i < p->number_of_interrupts; i++) 337 for(i = 0; i < p->interrupt_count; i++)
319 if (p->interrupts[i]) 338 if (p->interrupts[i])
320 __set_bit(p->interrupts[i], irq->map); 339 __set_bit(p->interrupts[i], irq->map);
321 irq->flags = irq_flags(p->edge_level, p->active_high_low); 340 irq->flags = irq_flags(p->triggering, p->polarity);
322 341
323 pnp_register_irq_resource(option, irq); 342 pnp_register_irq_resource(option, irq);
324 return; 343 return;
325} 344}
326 345
327static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 346static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
328 struct acpi_resource_ext_irq *p) 347 struct acpi_resource_extended_irq *p)
329{ 348{
330 int i; 349 int i;
331 struct pnp_irq * irq; 350 struct pnp_irq * irq;
332 351
333 if (p->number_of_interrupts == 0) 352 if (p->interrupt_count == 0)
334 return; 353 return;
335 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 354 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
336 if (!irq) 355 if (!irq)
337 return; 356 return;
338 357
339 for(i = 0; i < p->number_of_interrupts; i++) 358 for(i = 0; i < p->interrupt_count; i++)
340 if (p->interrupts[i]) 359 if (p->interrupts[i])
341 __set_bit(p->interrupts[i], irq->map); 360 __set_bit(p->interrupts[i], irq->map);
342 irq->flags = irq_flags(p->edge_level, p->active_high_low); 361 irq->flags = irq_flags(p->triggering, p->polarity);
343 362
344 pnp_register_irq_resource(option, irq); 363 pnp_register_irq_resource(option, irq);
345 return; 364 return;
@@ -351,16 +370,16 @@ pnpacpi_parse_port_option(struct pnp_option *option,
351{ 370{
352 struct pnp_port * port; 371 struct pnp_port * port;
353 372
354 if (io->range_length == 0) 373 if (io->address_length == 0)
355 return; 374 return;
356 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 375 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
357 if (!port) 376 if (!port)
358 return; 377 return;
359 port->min = io->min_base_address; 378 port->min = io->minimum;
360 port->max = io->max_base_address; 379 port->max = io->maximum;
361 port->align = io->alignment; 380 port->align = io->alignment;
362 port->size = io->range_length; 381 port->size = io->address_length;
363 port->flags = ACPI_DECODE_16 == io->io_decode ? 382 port->flags = ACPI_DECODE_16 == io->io_decode ?
364 PNP_PORT_FLAG_16BITADDR : 0; 383 PNP_PORT_FLAG_16BITADDR : 0;
365 pnp_register_port_resource(option,port); 384 pnp_register_port_resource(option,port);
366 return; 385 return;
@@ -372,13 +391,13 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
372{ 391{
373 struct pnp_port * port; 392 struct pnp_port * port;
374 393
375 if (io->range_length == 0) 394 if (io->address_length == 0)
376 return; 395 return;
377 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 396 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
378 if (!port) 397 if (!port)
379 return; 398 return;
380 port->min = port->max = io->base_address; 399 port->min = port->max = io->address;
381 port->size = io->range_length; 400 port->size = io->address_length;
382 port->align = 0; 401 port->align = 0;
383 port->flags = PNP_PORT_FLAG_FIXED; 402 port->flags = PNP_PORT_FLAG_FIXED;
384 pnp_register_port_resource(option,port); 403 pnp_register_port_resource(option,port);
@@ -387,21 +406,21 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
387 406
388static void 407static void
389pnpacpi_parse_mem24_option(struct pnp_option *option, 408pnpacpi_parse_mem24_option(struct pnp_option *option,
390 struct acpi_resource_mem24 *p) 409 struct acpi_resource_memory24 *p)
391{ 410{
392 struct pnp_mem * mem; 411 struct pnp_mem * mem;
393 412
394 if (p->range_length == 0) 413 if (p->address_length == 0)
395 return; 414 return;
396 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 415 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
397 if (!mem) 416 if (!mem)
398 return; 417 return;
399 mem->min = p->min_base_address; 418 mem->min = p->minimum;
400 mem->max = p->max_base_address; 419 mem->max = p->maximum;
401 mem->align = p->alignment; 420 mem->align = p->alignment;
402 mem->size = p->range_length; 421 mem->size = p->address_length;
403 422
404 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 423 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
405 IORESOURCE_MEM_WRITEABLE : 0; 424 IORESOURCE_MEM_WRITEABLE : 0;
406 425
407 pnp_register_mem_resource(option,mem); 426 pnp_register_mem_resource(option,mem);
@@ -410,21 +429,21 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
410 429
411static void 430static void
412pnpacpi_parse_mem32_option(struct pnp_option *option, 431pnpacpi_parse_mem32_option(struct pnp_option *option,
413 struct acpi_resource_mem32 *p) 432 struct acpi_resource_memory32 *p)
414{ 433{
415 struct pnp_mem * mem; 434 struct pnp_mem * mem;
416 435
417 if (p->range_length == 0) 436 if (p->address_length == 0)
418 return; 437 return;
419 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 438 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
420 if (!mem) 439 if (!mem)
421 return; 440 return;
422 mem->min = p->min_base_address; 441 mem->min = p->minimum;
423 mem->max = p->max_base_address; 442 mem->max = p->maximum;
424 mem->align = p->alignment; 443 mem->align = p->alignment;
425 mem->size = p->range_length; 444 mem->size = p->address_length;
426 445
427 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 446 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
428 IORESOURCE_MEM_WRITEABLE : 0; 447 IORESOURCE_MEM_WRITEABLE : 0;
429 448
430 pnp_register_mem_resource(option,mem); 449 pnp_register_mem_resource(option,mem);
@@ -433,33 +452,72 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
433 452
434static void 453static void
435pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 454pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
436 struct acpi_resource_fixed_mem32 *p) 455 struct acpi_resource_fixed_memory32 *p)
437{ 456{
438 struct pnp_mem * mem; 457 struct pnp_mem * mem;
439 458
440 if (p->range_length == 0) 459 if (p->address_length == 0)
441 return; 460 return;
442 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 461 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
443 if (!mem) 462 if (!mem)
444 return; 463 return;
445 mem->min = mem->max = p->range_base_address; 464 mem->min = mem->max = p->address;
446 mem->size = p->range_length; 465 mem->size = p->address_length;
447 mem->align = 0; 466 mem->align = 0;
448 467
449 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 468 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
450 IORESOURCE_MEM_WRITEABLE : 0; 469 IORESOURCE_MEM_WRITEABLE : 0;
451 470
452 pnp_register_mem_resource(option,mem); 471 pnp_register_mem_resource(option,mem);
453 return; 472 return;
454} 473}
455 474
475static void
476pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
477{
478 struct acpi_resource_address64 addr, *p = &addr;
479 acpi_status status;
480 struct pnp_mem * mem;
481 struct pnp_port * port;
482
483 status = acpi_resource_to_address64(r, p);
484 if (!ACPI_SUCCESS(status)) {
485 pnp_warn("PnPACPI: failed to convert resource type %d", r->type);
486 return;
487 }
488
489 if (p->address_length == 0)
490 return;
491
492 if (p->resource_type == ACPI_MEMORY_RANGE) {
493 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
494 if (!mem)
495 return;
496 mem->min = mem->max = p->minimum;
497 mem->size = p->address_length;
498 mem->align = 0;
499 mem->flags = (p->info.mem.write_protect ==
500 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
501 pnp_register_mem_resource(option,mem);
502 } else if (p->resource_type == ACPI_IO_RANGE) {
503 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
504 if (!port)
505 return;
506 port->min = port->max = p->minimum;
507 port->size = p->address_length;
508 port->align = 0;
509 port->flags = PNP_PORT_FLAG_FIXED;
510 pnp_register_port_resource(option,port);
511 }
512}
513
456struct acpipnp_parse_option_s { 514struct acpipnp_parse_option_s {
457 struct pnp_option *option; 515 struct pnp_option *option;
458 struct pnp_option *option_independent; 516 struct pnp_option *option_independent;
459 struct pnp_dev *dev; 517 struct pnp_dev *dev;
460}; 518};
461 519
462static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 520static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
463 void *data) 521 void *data)
464{ 522{
465 int priority = 0; 523 int priority = 0;
@@ -467,35 +525,16 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
467 struct pnp_dev *dev = parse_data->dev; 525 struct pnp_dev *dev = parse_data->dev;
468 struct pnp_option *option = parse_data->option; 526 struct pnp_option *option = parse_data->option;
469 527
470 switch (res->id) { 528 switch (res->type) {
471 case ACPI_RSTYPE_IRQ: 529 case ACPI_RESOURCE_TYPE_IRQ:
472 pnpacpi_parse_irq_option(option, &res->data.irq); 530 pnpacpi_parse_irq_option(option, &res->data.irq);
473 break; 531 break;
474 case ACPI_RSTYPE_EXT_IRQ: 532
475 pnpacpi_parse_ext_irq_option(option, 533 case ACPI_RESOURCE_TYPE_DMA:
476 &res->data.extended_irq);
477 break;
478 case ACPI_RSTYPE_DMA:
479 pnpacpi_parse_dma_option(option, &res->data.dma); 534 pnpacpi_parse_dma_option(option, &res->data.dma);
480 break; 535 break;
481 case ACPI_RSTYPE_IO: 536
482 pnpacpi_parse_port_option(option, &res->data.io); 537 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
483 break;
484 case ACPI_RSTYPE_FIXED_IO:
485 pnpacpi_parse_fixed_port_option(option,
486 &res->data.fixed_io);
487 break;
488 case ACPI_RSTYPE_MEM24:
489 pnpacpi_parse_mem24_option(option, &res->data.memory24);
490 break;
491 case ACPI_RSTYPE_MEM32:
492 pnpacpi_parse_mem32_option(option, &res->data.memory32);
493 break;
494 case ACPI_RSTYPE_FIXED_MEM32:
495 pnpacpi_parse_fixed_mem32_option(option,
496 &res->data.fixed_memory32);
497 break;
498 case ACPI_RSTYPE_START_DPF:
499 switch (res->data.start_dpf.compatibility_priority) { 538 switch (res->data.start_dpf.compatibility_priority) {
500 case ACPI_GOOD_CONFIGURATION: 539 case ACPI_GOOD_CONFIGURATION:
501 priority = PNP_RES_PRIORITY_PREFERRED; 540 priority = PNP_RES_PRIORITY_PREFERRED;
@@ -518,7 +557,8 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
518 return AE_ERROR; 557 return AE_ERROR;
519 parse_data->option = option; 558 parse_data->option = option;
520 break; 559 break;
521 case ACPI_RSTYPE_END_DPF: 560
561 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
522 /*only one EndDependentFn is allowed*/ 562 /*only one EndDependentFn is allowed*/
523 if (!parse_data->option_independent) { 563 if (!parse_data->option_independent) {
524 pnp_warn("PnPACPI: more than one EndDependentFn"); 564 pnp_warn("PnPACPI: more than one EndDependentFn");
@@ -527,15 +567,59 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
527 parse_data->option = parse_data->option_independent; 567 parse_data->option = parse_data->option_independent;
528 parse_data->option_independent = NULL; 568 parse_data->option_independent = NULL;
529 break; 569 break;
570
571 case ACPI_RESOURCE_TYPE_IO:
572 pnpacpi_parse_port_option(option, &res->data.io);
573 break;
574
575 case ACPI_RESOURCE_TYPE_FIXED_IO:
576 pnpacpi_parse_fixed_port_option(option,
577 &res->data.fixed_io);
578 break;
579
580 case ACPI_RESOURCE_TYPE_VENDOR:
581 case ACPI_RESOURCE_TYPE_END_TAG:
582 break;
583
584 case ACPI_RESOURCE_TYPE_MEMORY24:
585 pnpacpi_parse_mem24_option(option, &res->data.memory24);
586 break;
587
588 case ACPI_RESOURCE_TYPE_MEMORY32:
589 pnpacpi_parse_mem32_option(option, &res->data.memory32);
590 break;
591
592 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
593 pnpacpi_parse_fixed_mem32_option(option,
594 &res->data.fixed_memory32);
595 break;
596
597 case ACPI_RESOURCE_TYPE_ADDRESS16:
598 case ACPI_RESOURCE_TYPE_ADDRESS32:
599 case ACPI_RESOURCE_TYPE_ADDRESS64:
600 pnpacpi_parse_address_option(option, res);
601 break;
602
603 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
604 break;
605
606 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
607 pnpacpi_parse_ext_irq_option(option,
608 &res->data.extended_irq);
609 break;
610
611 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
612 break;
613
530 default: 614 default:
531 pnp_warn("PnPACPI: unknown resource type %d", res->id); 615 pnp_warn("PnPACPI: unknown resource type %d", res->type);
532 return AE_ERROR; 616 return AE_ERROR;
533 } 617 }
534 618
535 return AE_OK; 619 return AE_OK;
536} 620}
537 621
538acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 622acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
539 struct pnp_dev *dev) 623 struct pnp_dev *dev)
540{ 624{
541 acpi_status status; 625 acpi_status status;
@@ -546,7 +630,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
546 return AE_ERROR; 630 return AE_ERROR;
547 parse_data.option_independent = parse_data.option; 631 parse_data.option_independent = parse_data.option;
548 parse_data.dev = dev; 632 parse_data.dev = dev;
549 status = acpi_walk_resources(handle, METHOD_NAME__PRS, 633 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
550 pnpacpi_option_resource, &parse_data); 634 pnpacpi_option_resource, &parse_data);
551 635
552 return status; 636 return status;
@@ -559,21 +643,24 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
559 void *data) 643 void *data)
560{ 644{
561 int *res_cnt = (int *)data; 645 int *res_cnt = (int *)data;
562 switch (res->id) { 646 switch (res->type) {
563 case ACPI_RSTYPE_IRQ: 647 case ACPI_RESOURCE_TYPE_IRQ:
564 case ACPI_RSTYPE_EXT_IRQ: 648 case ACPI_RESOURCE_TYPE_DMA:
565 case ACPI_RSTYPE_DMA: 649 case ACPI_RESOURCE_TYPE_IO:
566 case ACPI_RSTYPE_IO: 650 case ACPI_RESOURCE_TYPE_FIXED_IO:
567 case ACPI_RSTYPE_FIXED_IO: 651 case ACPI_RESOURCE_TYPE_MEMORY24:
568 case ACPI_RSTYPE_MEM24: 652 case ACPI_RESOURCE_TYPE_MEMORY32:
569 case ACPI_RSTYPE_MEM32: 653 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
570 case ACPI_RSTYPE_FIXED_MEM32: 654 case ACPI_RESOURCE_TYPE_ADDRESS16:
571#if 0 655 case ACPI_RESOURCE_TYPE_ADDRESS32:
572 case ACPI_RSTYPE_ADDRESS16: 656 case ACPI_RESOURCE_TYPE_ADDRESS64:
573 case ACPI_RSTYPE_ADDRESS32: 657 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
574 case ACPI_RSTYPE_ADDRESS64:
575#endif
576 (*res_cnt) ++; 658 (*res_cnt) ++;
659 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
660 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
661 case ACPI_RESOURCE_TYPE_VENDOR:
662 case ACPI_RESOURCE_TYPE_END_TAG:
663 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
577 default: 664 default:
578 return AE_OK; 665 return AE_OK;
579 } 666 }
@@ -584,22 +671,25 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
584 void *data) 671 void *data)
585{ 672{
586 struct acpi_resource **resource = (struct acpi_resource **)data; 673 struct acpi_resource **resource = (struct acpi_resource **)data;
587 switch (res->id) { 674 switch (res->type) {
588 case ACPI_RSTYPE_IRQ: 675 case ACPI_RESOURCE_TYPE_IRQ:
589 case ACPI_RSTYPE_EXT_IRQ: 676 case ACPI_RESOURCE_TYPE_DMA:
590 case ACPI_RSTYPE_DMA: 677 case ACPI_RESOURCE_TYPE_IO:
591 case ACPI_RSTYPE_IO: 678 case ACPI_RESOURCE_TYPE_FIXED_IO:
592 case ACPI_RSTYPE_FIXED_IO: 679 case ACPI_RESOURCE_TYPE_MEMORY24:
593 case ACPI_RSTYPE_MEM24: 680 case ACPI_RESOURCE_TYPE_MEMORY32:
594 case ACPI_RSTYPE_MEM32: 681 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
595 case ACPI_RSTYPE_FIXED_MEM32: 682 case ACPI_RESOURCE_TYPE_ADDRESS16:
596#if 0 683 case ACPI_RESOURCE_TYPE_ADDRESS32:
597 case ACPI_RSTYPE_ADDRESS16: 684 case ACPI_RESOURCE_TYPE_ADDRESS64:
598 case ACPI_RSTYPE_ADDRESS32: 685 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
599 case ACPI_RSTYPE_ADDRESS64: 686 (*resource)->type = res->type;
600#endif
601 (*resource)->id = res->id;
602 (*resource)++; 687 (*resource)++;
688 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
689 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
690 case ACPI_RESOURCE_TYPE_VENDOR:
691 case ACPI_RESOURCE_TYPE_END_TAG:
692 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
603 default: 693 default:
604 return AE_OK; 694 return AE_OK;
605 } 695 }
@@ -607,14 +697,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
607 return AE_OK; 697 return AE_OK;
608} 698}
609 699
610int pnpacpi_build_resource_template(acpi_handle handle, 700int pnpacpi_build_resource_template(acpi_handle handle,
611 struct acpi_buffer *buffer) 701 struct acpi_buffer *buffer)
612{ 702{
613 struct acpi_resource *resource; 703 struct acpi_resource *resource;
614 int res_cnt = 0; 704 int res_cnt = 0;
615 acpi_status status; 705 acpi_status status;
616 706
617 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 707 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
618 pnpacpi_count_resources, &res_cnt); 708 pnpacpi_count_resources, &res_cnt);
619 if (ACPI_FAILURE(status)) { 709 if (ACPI_FAILURE(status)) {
620 pnp_err("Evaluate _CRS failed"); 710 pnp_err("Evaluate _CRS failed");
@@ -628,7 +718,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
628 return -ENOMEM; 718 return -ENOMEM;
629 pnp_dbg("Res cnt %d", res_cnt); 719 pnp_dbg("Res cnt %d", res_cnt);
630 resource = (struct acpi_resource *)buffer->pointer; 720 resource = (struct acpi_resource *)buffer->pointer;
631 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 721 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
632 pnpacpi_type_resources, &resource); 722 pnpacpi_type_resources, &resource);
633 if (ACPI_FAILURE(status)) { 723 if (ACPI_FAILURE(status)) {
634 kfree(buffer->pointer); 724 kfree(buffer->pointer);
@@ -636,54 +726,54 @@ int pnpacpi_build_resource_template(acpi_handle handle,
636 return -EINVAL; 726 return -EINVAL;
637 } 727 }
638 /* resource will pointer the end resource now */ 728 /* resource will pointer the end resource now */
639 resource->id = ACPI_RSTYPE_END_TAG; 729 resource->type = ACPI_RESOURCE_TYPE_END_TAG;
640 730
641 return 0; 731 return 0;
642} 732}
643 733
644static void pnpacpi_encode_irq(struct acpi_resource *resource, 734static void pnpacpi_encode_irq(struct acpi_resource *resource,
645 struct resource *p) 735 struct resource *p)
646{ 736{
647 int edge_level, active_high_low; 737 int triggering, polarity;
648 738
649 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 739 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
650 &active_high_low); 740 &polarity);
651 resource->id = ACPI_RSTYPE_IRQ; 741 resource->type = ACPI_RESOURCE_TYPE_IRQ;
652 resource->length = sizeof(struct acpi_resource); 742 resource->length = sizeof(struct acpi_resource);
653 resource->data.irq.edge_level = edge_level; 743 resource->data.irq.triggering = triggering;
654 resource->data.irq.active_high_low = active_high_low; 744 resource->data.irq.polarity = polarity;
655 if (edge_level == ACPI_EDGE_SENSITIVE) 745 if (triggering == ACPI_EDGE_SENSITIVE)
656 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 746 resource->data.irq.sharable = ACPI_EXCLUSIVE;
657 else 747 else
658 resource->data.irq.shared_exclusive = ACPI_SHARED; 748 resource->data.irq.sharable = ACPI_SHARED;
659 resource->data.irq.number_of_interrupts = 1; 749 resource->data.irq.interrupt_count = 1;
660 resource->data.irq.interrupts[0] = p->start; 750 resource->data.irq.interrupts[0] = p->start;
661} 751}
662 752
663static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 753static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
664 struct resource *p) 754 struct resource *p)
665{ 755{
666 int edge_level, active_high_low; 756 int triggering, polarity;
667 757
668 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 758 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
669 &active_high_low); 759 &polarity);
670 resource->id = ACPI_RSTYPE_EXT_IRQ; 760 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
671 resource->length = sizeof(struct acpi_resource); 761 resource->length = sizeof(struct acpi_resource);
672 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; 762 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
673 resource->data.extended_irq.edge_level = edge_level; 763 resource->data.extended_irq.triggering = triggering;
674 resource->data.extended_irq.active_high_low = active_high_low; 764 resource->data.extended_irq.polarity = polarity;
675 if (edge_level == ACPI_EDGE_SENSITIVE) 765 if (triggering == ACPI_EDGE_SENSITIVE)
676 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 766 resource->data.irq.sharable = ACPI_EXCLUSIVE;
677 else 767 else
678 resource->data.irq.shared_exclusive = ACPI_SHARED; 768 resource->data.irq.sharable = ACPI_SHARED;
679 resource->data.extended_irq.number_of_interrupts = 1; 769 resource->data.extended_irq.interrupt_count = 1;
680 resource->data.extended_irq.interrupts[0] = p->start; 770 resource->data.extended_irq.interrupts[0] = p->start;
681} 771}
682 772
683static void pnpacpi_encode_dma(struct acpi_resource *resource, 773static void pnpacpi_encode_dma(struct acpi_resource *resource,
684 struct resource *p) 774 struct resource *p)
685{ 775{
686 resource->id = ACPI_RSTYPE_DMA; 776 resource->type = ACPI_RESOURCE_TYPE_DMA;
687 resource->length = sizeof(struct acpi_resource); 777 resource->length = sizeof(struct acpi_resource);
688 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 778 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
689 if (p->flags & IORESOURCE_DMA_COMPATIBLE) 779 if (p->flags & IORESOURCE_DMA_COMPATIBLE)
@@ -701,75 +791,75 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
701 else if (p->flags & IORESOURCE_DMA_16BIT) 791 else if (p->flags & IORESOURCE_DMA_16BIT)
702 resource->data.dma.transfer = ACPI_TRANSFER_16; 792 resource->data.dma.transfer = ACPI_TRANSFER_16;
703 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; 793 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER;
704 resource->data.dma.number_of_channels = 1; 794 resource->data.dma.channel_count = 1;
705 resource->data.dma.channels[0] = p->start; 795 resource->data.dma.channels[0] = p->start;
706} 796}
707 797
708static void pnpacpi_encode_io(struct acpi_resource *resource, 798static void pnpacpi_encode_io(struct acpi_resource *resource,
709 struct resource *p) 799 struct resource *p)
710{ 800{
711 resource->id = ACPI_RSTYPE_IO; 801 resource->type = ACPI_RESOURCE_TYPE_IO;
712 resource->length = sizeof(struct acpi_resource); 802 resource->length = sizeof(struct acpi_resource);
713 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 803 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
714 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? 804 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)?
715 ACPI_DECODE_16 : ACPI_DECODE_10; 805 ACPI_DECODE_16 : ACPI_DECODE_10;
716 resource->data.io.min_base_address = p->start; 806 resource->data.io.minimum = p->start;
717 resource->data.io.max_base_address = p->end; 807 resource->data.io.maximum = p->end;
718 resource->data.io.alignment = 0; /* Correct? */ 808 resource->data.io.alignment = 0; /* Correct? */
719 resource->data.io.range_length = p->end - p->start + 1; 809 resource->data.io.address_length = p->end - p->start + 1;
720} 810}
721 811
722static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 812static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
723 struct resource *p) 813 struct resource *p)
724{ 814{
725 resource->id = ACPI_RSTYPE_FIXED_IO; 815 resource->type = ACPI_RESOURCE_TYPE_FIXED_IO;
726 resource->length = sizeof(struct acpi_resource); 816 resource->length = sizeof(struct acpi_resource);
727 resource->data.fixed_io.base_address = p->start; 817 resource->data.fixed_io.address = p->start;
728 resource->data.fixed_io.range_length = p->end - p->start + 1; 818 resource->data.fixed_io.address_length = p->end - p->start + 1;
729} 819}
730 820
731static void pnpacpi_encode_mem24(struct acpi_resource *resource, 821static void pnpacpi_encode_mem24(struct acpi_resource *resource,
732 struct resource *p) 822 struct resource *p)
733{ 823{
734 resource->id = ACPI_RSTYPE_MEM24; 824 resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
735 resource->length = sizeof(struct acpi_resource); 825 resource->length = sizeof(struct acpi_resource);
736 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 826 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
737 resource->data.memory24.read_write_attribute = 827 resource->data.memory24.write_protect =
738 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 828 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
739 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 829 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
740 resource->data.memory24.min_base_address = p->start; 830 resource->data.memory24.minimum = p->start;
741 resource->data.memory24.max_base_address = p->end; 831 resource->data.memory24.maximum = p->end;
742 resource->data.memory24.alignment = 0; 832 resource->data.memory24.alignment = 0;
743 resource->data.memory24.range_length = p->end - p->start + 1; 833 resource->data.memory24.address_length = p->end - p->start + 1;
744} 834}
745 835
746static void pnpacpi_encode_mem32(struct acpi_resource *resource, 836static void pnpacpi_encode_mem32(struct acpi_resource *resource,
747 struct resource *p) 837 struct resource *p)
748{ 838{
749 resource->id = ACPI_RSTYPE_MEM32; 839 resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
750 resource->length = sizeof(struct acpi_resource); 840 resource->length = sizeof(struct acpi_resource);
751 resource->data.memory32.read_write_attribute = 841 resource->data.memory32.write_protect =
752 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 842 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
753 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 843 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
754 resource->data.memory32.min_base_address = p->start; 844 resource->data.memory32.minimum = p->start;
755 resource->data.memory32.max_base_address = p->end; 845 resource->data.memory32.maximum = p->end;
756 resource->data.memory32.alignment = 0; 846 resource->data.memory32.alignment = 0;
757 resource->data.memory32.range_length = p->end - p->start + 1; 847 resource->data.memory32.address_length = p->end - p->start + 1;
758} 848}
759 849
760static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 850static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
761 struct resource *p) 851 struct resource *p)
762{ 852{
763 resource->id = ACPI_RSTYPE_FIXED_MEM32; 853 resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
764 resource->length = sizeof(struct acpi_resource); 854 resource->length = sizeof(struct acpi_resource);
765 resource->data.fixed_memory32.read_write_attribute = 855 resource->data.fixed_memory32.write_protect =
766 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 856 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
767 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 857 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
768 resource->data.fixed_memory32.range_base_address = p->start; 858 resource->data.fixed_memory32.address = p->start;
769 resource->data.fixed_memory32.range_length = p->end - p->start + 1; 859 resource->data.fixed_memory32.address_length = p->end - p->start + 1;
770} 860}
771 861
772int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 862int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
773 struct acpi_buffer *buffer) 863 struct acpi_buffer *buffer)
774{ 864{
775 int i = 0; 865 int i = 0;
@@ -780,58 +870,67 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
780 870
781 pnp_dbg("res cnt %d", res_cnt); 871 pnp_dbg("res cnt %d", res_cnt);
782 while (i < res_cnt) { 872 while (i < res_cnt) {
783 switch(resource->id) { 873 switch(resource->type) {
784 case ACPI_RSTYPE_IRQ: 874 case ACPI_RESOURCE_TYPE_IRQ:
785 pnp_dbg("Encode irq"); 875 pnp_dbg("Encode irq");
786 pnpacpi_encode_irq(resource, 876 pnpacpi_encode_irq(resource,
787 &res_table->irq_resource[irq]); 877 &res_table->irq_resource[irq]);
788 irq++; 878 irq++;
789 break; 879 break;
790 880
791 case ACPI_RSTYPE_EXT_IRQ: 881 case ACPI_RESOURCE_TYPE_DMA:
792 pnp_dbg("Encode ext irq");
793 pnpacpi_encode_ext_irq(resource,
794 &res_table->irq_resource[irq]);
795 irq++;
796 break;
797 case ACPI_RSTYPE_DMA:
798 pnp_dbg("Encode dma"); 882 pnp_dbg("Encode dma");
799 pnpacpi_encode_dma(resource, 883 pnpacpi_encode_dma(resource,
800 &res_table->dma_resource[dma]); 884 &res_table->dma_resource[dma]);
801 dma ++; 885 dma ++;
802 break; 886 break;
803 case ACPI_RSTYPE_IO: 887 case ACPI_RESOURCE_TYPE_IO:
804 pnp_dbg("Encode io"); 888 pnp_dbg("Encode io");
805 pnpacpi_encode_io(resource, 889 pnpacpi_encode_io(resource,
806 &res_table->port_resource[port]); 890 &res_table->port_resource[port]);
807 port ++; 891 port ++;
808 break; 892 break;
809 case ACPI_RSTYPE_FIXED_IO: 893 case ACPI_RESOURCE_TYPE_FIXED_IO:
810 pnp_dbg("Encode fixed io"); 894 pnp_dbg("Encode fixed io");
811 pnpacpi_encode_fixed_io(resource, 895 pnpacpi_encode_fixed_io(resource,
812 &res_table->port_resource[port]); 896 &res_table->port_resource[port]);
813 port ++; 897 port ++;
814 break; 898 break;
815 case ACPI_RSTYPE_MEM24: 899 case ACPI_RESOURCE_TYPE_MEMORY24:
816 pnp_dbg("Encode mem24"); 900 pnp_dbg("Encode mem24");
817 pnpacpi_encode_mem24(resource, 901 pnpacpi_encode_mem24(resource,
818 &res_table->mem_resource[mem]); 902 &res_table->mem_resource[mem]);
819 mem ++; 903 mem ++;
820 break; 904 break;
821 case ACPI_RSTYPE_MEM32: 905 case ACPI_RESOURCE_TYPE_MEMORY32:
822 pnp_dbg("Encode mem32"); 906 pnp_dbg("Encode mem32");
823 pnpacpi_encode_mem32(resource, 907 pnpacpi_encode_mem32(resource,
824 &res_table->mem_resource[mem]); 908 &res_table->mem_resource[mem]);
825 mem ++; 909 mem ++;
826 break; 910 break;
827 case ACPI_RSTYPE_FIXED_MEM32: 911 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
828 pnp_dbg("Encode fixed mem32"); 912 pnp_dbg("Encode fixed mem32");
829 pnpacpi_encode_fixed_mem32(resource, 913 pnpacpi_encode_fixed_mem32(resource,
830 &res_table->mem_resource[mem]); 914 &res_table->mem_resource[mem]);
831 mem ++; 915 mem ++;
832 break; 916 break;
917 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
918 pnp_dbg("Encode ext irq");
919 pnpacpi_encode_ext_irq(resource,
920 &res_table->irq_resource[irq]);
921 irq++;
922 break;
923 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
924 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
925 case ACPI_RESOURCE_TYPE_VENDOR:
926 case ACPI_RESOURCE_TYPE_END_TAG:
927 case ACPI_RESOURCE_TYPE_ADDRESS16:
928 case ACPI_RESOURCE_TYPE_ADDRESS32:
929 case ACPI_RESOURCE_TYPE_ADDRESS64:
930 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
931 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
833 default: /* other type */ 932 default: /* other type */
834 pnp_warn("unknown resource type %d", resource->id); 933 pnp_warn("unknown resource type %d", resource->type);
835 return -EINVAL; 934 return -EINVAL;
836 } 935 }
837 resource ++; 936 resource ++;
diff --git a/drivers/s390/Kconfig b/drivers/s390/Kconfig
index a86a650f3d6d..721787cc5a1c 100644
--- a/drivers/s390/Kconfig
+++ b/drivers/s390/Kconfig
@@ -51,6 +51,13 @@ config UNIX98_PTY_COUNT
51 When not in use, each additional set of 256 PTYs occupy 51 When not in use, each additional set of 256 PTYs occupy
52 approximately 8 KB of kernel memory on 32-bit architectures. 52 approximately 8 KB of kernel memory on 32-bit architectures.
53 53
54config HANGCHECK_TIMER
55 tristate "Hangcheck timer"
56 help
57 The hangcheck-timer module detects when the system has gone
58 out to lunch past a certain margin. It can reboot the system
59 or merely print a warning.
60
54source "drivers/char/watchdog/Kconfig" 61source "drivers/char/watchdog/Kconfig"
55 62
56comment "S/390 character device drivers" 63comment "S/390 character device drivers"
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig
index 6f50cc9323d9..6912399d0937 100644
--- a/drivers/s390/block/Kconfig
+++ b/drivers/s390/block/Kconfig
@@ -55,13 +55,21 @@ config DASD_DIAG
55 Disks under VM. If you are not running under VM or unsure what it is, 55 Disks under VM. If you are not running under VM or unsure what it is,
56 say "N". 56 say "N".
57 57
58config DASD_EER
59 tristate "Extended error reporting (EER)"
60 depends on DASD
61 help
62 This driver provides a character device interface to the
63 DASD extended error reporting. This is only needed if you want to
64 use applications written for the EER facility.
65
58config DASD_CMB 66config DASD_CMB
59 tristate "Compatibility interface for DASD channel measurement blocks" 67 tristate "Compatibility interface for DASD channel measurement blocks"
60 depends on DASD 68 depends on DASD
61 help 69 help
62 This driver provides an additional interface to the channel measurement 70 This driver provides an additional interface to the channel
63 facility, which is normally accessed though sysfs, with a set of 71 measurement facility, which is normally accessed though sysfs, with
64 ioctl functions specific to the dasd driver. 72 a set of ioctl functions specific to the dasd driver.
65 This is only needed if you want to use applications written for 73 This is only needed if you want to use applications written for
66 linux-2.4 dasd channel measurement facility interface. 74 linux-2.4 dasd channel measurement facility interface.
67 75
diff --git a/drivers/s390/block/Makefile b/drivers/s390/block/Makefile
index 58c6780134f7..0c0d871e8f51 100644
--- a/drivers/s390/block/Makefile
+++ b/drivers/s390/block/Makefile
@@ -5,6 +5,7 @@
5dasd_eckd_mod-objs := dasd_eckd.o dasd_3990_erp.o dasd_9343_erp.o 5dasd_eckd_mod-objs := dasd_eckd.o dasd_3990_erp.o dasd_9343_erp.o
6dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o 6dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o
7dasd_diag_mod-objs := dasd_diag.o 7dasd_diag_mod-objs := dasd_diag.o
8dasd_eer_mod-objs := dasd_eer.o
8dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \ 9dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \
9 dasd_genhd.o dasd_erp.o 10 dasd_genhd.o dasd_erp.o
10 11
@@ -13,5 +14,6 @@ obj-$(CONFIG_DASD_DIAG) += dasd_diag_mod.o
13obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o 14obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o
14obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o 15obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o
15obj-$(CONFIG_DASD_CMB) += dasd_cmb.o 16obj-$(CONFIG_DASD_CMB) += dasd_cmb.o
17obj-$(CONFIG_DASD_EER) += dasd_eer.o
16obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o 18obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o
17obj-$(CONFIG_DCSSBLK) += dcssblk.o 19obj-$(CONFIG_DCSSBLK) += dcssblk.o
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index ef4c687e7c01..08c88fcd8963 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -7,7 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.172 $
11 */ 10 */
12 11
13#include <linux/config.h> 12#include <linux/config.h>
@@ -19,6 +18,7 @@
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/buffer_head.h> 19#include <linux/buffer_head.h>
21#include <linux/hdreg.h> 20#include <linux/hdreg.h>
21#include <linux/notifier.h>
22 22
23#include <asm/ccwdev.h> 23#include <asm/ccwdev.h>
24#include <asm/ebcdic.h> 24#include <asm/ebcdic.h>
@@ -58,6 +58,7 @@ static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
58static void dasd_flush_ccw_queue(struct dasd_device *, int); 58static void dasd_flush_ccw_queue(struct dasd_device *, int);
59static void dasd_tasklet(struct dasd_device *); 59static void dasd_tasklet(struct dasd_device *);
60static void do_kick_device(void *data); 60static void do_kick_device(void *data);
61static void dasd_disable_eer(struct dasd_device *device);
61 62
62/* 63/*
63 * SECTION: Operations on the device structure. 64 * SECTION: Operations on the device structure.
@@ -152,6 +153,8 @@ dasd_state_new_to_known(struct dasd_device *device)
152static inline void 153static inline void
153dasd_state_known_to_new(struct dasd_device * device) 154dasd_state_known_to_new(struct dasd_device * device)
154{ 155{
156 /* disable extended error reporting for this device */
157 dasd_disable_eer(device);
155 /* Forget the discipline information. */ 158 /* Forget the discipline information. */
156 device->discipline = NULL; 159 device->discipline = NULL;
157 device->state = DASD_STATE_NEW; 160 device->state = DASD_STATE_NEW;
@@ -675,11 +678,8 @@ dasd_term_IO(struct dasd_ccw_req * cqr)
675 rc = ccw_device_clear(device->cdev, (long) cqr); 678 rc = ccw_device_clear(device->cdev, (long) cqr);
676 switch (rc) { 679 switch (rc) {
677 case 0: /* termination successful */ 680 case 0: /* termination successful */
678 if (cqr->retries > 0) { 681 cqr->retries--;
679 cqr->retries--; 682 cqr->status = DASD_CQR_CLEAR;
680 cqr->status = DASD_CQR_CLEAR;
681 } else
682 cqr->status = DASD_CQR_FAILED;
683 cqr->stopclk = get_clock(); 683 cqr->stopclk = get_clock();
684 DBF_DEV_EVENT(DBF_DEBUG, device, 684 DBF_DEV_EVENT(DBF_DEBUG, device,
685 "terminate cqr %p successful", 685 "terminate cqr %p successful",
@@ -871,6 +871,9 @@ dasd_handle_state_change_pending(struct dasd_device *device)
871 struct dasd_ccw_req *cqr; 871 struct dasd_ccw_req *cqr;
872 struct list_head *l, *n; 872 struct list_head *l, *n;
873 873
874 /* first of all call extended error reporting */
875 dasd_write_eer_trigger(DASD_EER_STATECHANGE, device, NULL);
876
874 device->stopped &= ~DASD_STOPPED_PENDING; 877 device->stopped &= ~DASD_STOPPED_PENDING;
875 878
876 /* restart all 'running' IO on queue */ 879 /* restart all 'running' IO on queue */
@@ -1090,6 +1093,19 @@ restart:
1090 } 1093 }
1091 goto restart; 1094 goto restart;
1092 } 1095 }
1096
1097 /* first of all call extended error reporting */
1098 if (device->eer && cqr->status == DASD_CQR_FAILED) {
1099 dasd_write_eer_trigger(DASD_EER_FATALERROR,
1100 device, cqr);
1101
1102 /* restart request */
1103 cqr->status = DASD_CQR_QUEUED;
1104 cqr->retries = 255;
1105 device->stopped |= DASD_STOPPED_QUIESCE;
1106 goto restart;
1107 }
1108
1093 /* Process finished ERP request. */ 1109 /* Process finished ERP request. */
1094 if (cqr->refers) { 1110 if (cqr->refers) {
1095 __dasd_process_erp(device, cqr); 1111 __dasd_process_erp(device, cqr);
@@ -1227,7 +1243,8 @@ __dasd_start_head(struct dasd_device * device)
1227 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); 1243 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1228 /* check FAILFAST */ 1244 /* check FAILFAST */
1229 if (device->stopped & ~DASD_STOPPED_PENDING && 1245 if (device->stopped & ~DASD_STOPPED_PENDING &&
1230 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) { 1246 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
1247 (!device->eer)) {
1231 cqr->status = DASD_CQR_FAILED; 1248 cqr->status = DASD_CQR_FAILED;
1232 dasd_schedule_bh(device); 1249 dasd_schedule_bh(device);
1233 } 1250 }
@@ -1308,7 +1325,7 @@ dasd_tasklet(struct dasd_device * device)
1308 /* Now call the callback function of requests with final status */ 1325 /* Now call the callback function of requests with final status */
1309 list_for_each_safe(l, n, &final_queue) { 1326 list_for_each_safe(l, n, &final_queue) {
1310 cqr = list_entry(l, struct dasd_ccw_req, list); 1327 cqr = list_entry(l, struct dasd_ccw_req, list);
1311 list_del(&cqr->list); 1328 list_del_init(&cqr->list);
1312 if (cqr->callback != NULL) 1329 if (cqr->callback != NULL)
1313 (cqr->callback)(cqr, cqr->callback_data); 1330 (cqr->callback)(cqr, cqr->callback_data);
1314 } 1331 }
@@ -1393,7 +1410,9 @@ _wait_for_wakeup(struct dasd_ccw_req *cqr)
1393 1410
1394 device = cqr->device; 1411 device = cqr->device;
1395 spin_lock_irq(get_ccwdev_lock(device->cdev)); 1412 spin_lock_irq(get_ccwdev_lock(device->cdev));
1396 rc = cqr->status == DASD_CQR_DONE || cqr->status == DASD_CQR_FAILED; 1413 rc = ((cqr->status == DASD_CQR_DONE ||
1414 cqr->status == DASD_CQR_FAILED) &&
1415 list_empty(&cqr->list));
1397 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1416 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1398 return rc; 1417 return rc;
1399} 1418}
@@ -1457,15 +1476,37 @@ dasd_sleep_on_interruptible(struct dasd_ccw_req * cqr)
1457 while (!finished) { 1476 while (!finished) {
1458 rc = wait_event_interruptible(wait_q, _wait_for_wakeup(cqr)); 1477 rc = wait_event_interruptible(wait_q, _wait_for_wakeup(cqr));
1459 if (rc != -ERESTARTSYS) { 1478 if (rc != -ERESTARTSYS) {
1460 /* Request status is either done or failed. */ 1479 /* Request is final (done or failed) */
1461 rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0; 1480 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1462 break; 1481 break;
1463 } 1482 }
1464 spin_lock_irq(get_ccwdev_lock(device->cdev)); 1483 spin_lock_irq(get_ccwdev_lock(device->cdev));
1465 if (cqr->status == DASD_CQR_IN_IO && 1484 switch (cqr->status) {
1466 device->discipline->term_IO(cqr) == 0) { 1485 case DASD_CQR_IN_IO:
1467 list_del(&cqr->list); 1486 /* terminate runnig cqr */
1487 if (device->discipline->term_IO) {
1488 cqr->retries = -1;
1489 device->discipline->term_IO(cqr);
1490 /*nished =
1491 * wait (non-interruptible) for final status
1492 * because signal ist still pending
1493 */
1494 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1495 wait_event(wait_q, _wait_for_wakeup(cqr));
1496 spin_lock_irq(get_ccwdev_lock(device->cdev));
1497 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1498 finished = 1;
1499 }
1500 break;
1501 case DASD_CQR_QUEUED:
1502 /* request */
1503 list_del_init(&cqr->list);
1504 rc = -EIO;
1468 finished = 1; 1505 finished = 1;
1506 break;
1507 default:
1508 /* cqr with 'non-interruptable' status - just wait */
1509 break;
1469 } 1510 }
1470 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1511 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1471 } 1512 }
@@ -1945,6 +1986,9 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
1945 switch (event) { 1986 switch (event) {
1946 case CIO_GONE: 1987 case CIO_GONE:
1947 case CIO_NO_PATH: 1988 case CIO_NO_PATH:
1989 /* first of all call extended error reporting */
1990 dasd_write_eer_trigger(DASD_EER_NOPATH, device, NULL);
1991
1948 if (device->state < DASD_STATE_BASIC) 1992 if (device->state < DASD_STATE_BASIC)
1949 break; 1993 break;
1950 /* Device is active. We want to keep it. */ 1994 /* Device is active. We want to keep it. */
@@ -2002,6 +2046,51 @@ dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
2002 put_driver(drv); 2046 put_driver(drv);
2003} 2047}
2004 2048
2049/*
2050 * notifications for extended error reports
2051 */
2052static struct notifier_block *dasd_eer_chain;
2053
2054int
2055dasd_register_eer_notifier(struct notifier_block *nb)
2056{
2057 return notifier_chain_register(&dasd_eer_chain, nb);
2058}
2059
2060int
2061dasd_unregister_eer_notifier(struct notifier_block *nb)
2062{
2063 return notifier_chain_unregister(&dasd_eer_chain, nb);
2064}
2065
2066/*
2067 * Notify the registered error reporting module of a problem
2068 */
2069void
2070dasd_write_eer_trigger(unsigned int id, struct dasd_device *device,
2071 struct dasd_ccw_req *cqr)
2072{
2073 if (device->eer) {
2074 struct dasd_eer_trigger temp;
2075 temp.id = id;
2076 temp.device = device;
2077 temp.cqr = cqr;
2078 notifier_call_chain(&dasd_eer_chain, DASD_EER_TRIGGER,
2079 (void *)&temp);
2080 }
2081}
2082
2083/*
2084 * Tell the registered error reporting module to disable error reporting for
2085 * a given device and to cleanup any private data structures on that device.
2086 */
2087static void
2088dasd_disable_eer(struct dasd_device *device)
2089{
2090 notifier_call_chain(&dasd_eer_chain, DASD_EER_DISABLE, (void *)device);
2091}
2092
2093
2005static int __init 2094static int __init
2006dasd_init(void) 2095dasd_init(void)
2007{ 2096{
@@ -2083,6 +2172,11 @@ EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2083EXPORT_SYMBOL_GPL(dasd_generic_set_offline); 2172EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2084EXPORT_SYMBOL_GPL(dasd_generic_auto_online); 2173EXPORT_SYMBOL_GPL(dasd_generic_auto_online);
2085 2174
2175EXPORT_SYMBOL(dasd_register_eer_notifier);
2176EXPORT_SYMBOL(dasd_unregister_eer_notifier);
2177EXPORT_SYMBOL(dasd_write_eer_trigger);
2178
2179
2086/* 2180/*
2087 * Overrides for Emacs so that we follow Linus's tabbing style. 2181 * Overrides for Emacs so that we follow Linus's tabbing style.
2088 * Emacs will notice this stuff at the end of the file and automatically 2182 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/drivers/s390/block/dasd_3370_erp.c b/drivers/s390/block/dasd_3370_erp.c
index 84565c8f584e..1d11c2a9525d 100644
--- a/drivers/s390/block/dasd_3370_erp.c
+++ b/drivers/s390/block/dasd_3370_erp.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 * 6 *
7 * $Revision: 1.9 $
8 */ 7 */
9 8
10#define PRINTK_HEADER "dasd_erp(3370)" 9#define PRINTK_HEADER "dasd_erp(3370)"
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index c143ecb53d9d..c811380b9079 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -5,7 +5,6 @@
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
7 * 7 *
8 * $Revision: 1.36 $
9 */ 8 */
10 9
11#include <linux/timer.h> 10#include <linux/timer.h>
@@ -1109,6 +1108,9 @@ dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
1109 case 0x0B: 1108 case 0x0B:
1110 DEV_MESSAGE(KERN_WARNING, device, "%s", 1109 DEV_MESSAGE(KERN_WARNING, device, "%s",
1111 "FORMAT F - Volume is suspended duplex"); 1110 "FORMAT F - Volume is suspended duplex");
1111 /* call extended error reporting (EER) */
1112 dasd_write_eer_trigger(DASD_EER_PPRCSUSPEND, device,
1113 erp->refers);
1112 break; 1114 break;
1113 case 0x0C: 1115 case 0x0C:
1114 DEV_MESSAGE(KERN_WARNING, device, "%s", 1116 DEV_MESSAGE(KERN_WARNING, device, "%s",
diff --git a/drivers/s390/block/dasd_9336_erp.c b/drivers/s390/block/dasd_9336_erp.c
index 01e87170a3a2..dc861446d056 100644
--- a/drivers/s390/block/dasd_9336_erp.c
+++ b/drivers/s390/block/dasd_9336_erp.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 * 6 *
7 * $Revision: 1.8 $
8 */ 7 */
9 8
10#define PRINTK_HEADER "dasd_erp(9336)" 9#define PRINTK_HEADER "dasd_erp(9336)"
diff --git a/drivers/s390/block/dasd_9343_erp.c b/drivers/s390/block/dasd_9343_erp.c
index 2a23b74faf3f..4a5b79569aaa 100644
--- a/drivers/s390/block/dasd_9343_erp.c
+++ b/drivers/s390/block/dasd_9343_erp.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 * 6 *
7 * $Revision: 1.13 $
8 */ 7 */
9 8
10#define PRINTK_HEADER "dasd_erp(9343)" 9#define PRINTK_HEADER "dasd_erp(9343)"
diff --git a/drivers/s390/block/dasd_cmb.c b/drivers/s390/block/dasd_cmb.c
index 4f365bff275c..e88f73ee72ce 100644
--- a/drivers/s390/block/dasd_cmb.c
+++ b/drivers/s390/block/dasd_cmb.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.9 $)
3 *
4 * Linux on zSeries Channel Measurement Facility support 2 * Linux on zSeries Channel Measurement Facility support
5 * (dasd device driver interface) 3 * (dasd device driver interface)
6 * 4 *
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index caee16a3dc62..1629b27c48ab 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -11,7 +11,6 @@
11 * functions may not be called from interrupt context. In particular 11 * functions may not be called from interrupt context. In particular
12 * dasd_get_device is a no-no from interrupt context. 12 * dasd_get_device is a no-no from interrupt context.
13 * 13 *
14 * $Revision: 1.43 $
15 */ 14 */
16 15
17#include <linux/config.h> 16#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index ba80fdea7ebf..3f9d704d2657 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -6,7 +6,6 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.53 $
10 */ 9 */
11 10
12#include <linux/config.h> 11#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h
index a4f80bd735f1..38a4e55f8953 100644
--- a/drivers/s390/block/dasd_diag.h
+++ b/drivers/s390/block/dasd_diag.h
@@ -6,7 +6,6 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.9 $
10 */ 9 */
11 10
12#define MDSK_WRITE_REQ 0x01 11#define MDSK_WRITE_REQ 0x01
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 96eb48258580..822e2a265578 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -7,7 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
9 * 9 *
10 * $Revision: 1.74 $
11 */ 10 */
12 11
13#include <linux/config.h> 12#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h
index b6888c68b224..e15dd7978050 100644
--- a/drivers/s390/block/dasd_eckd.h
+++ b/drivers/s390/block/dasd_eckd.h
@@ -5,7 +5,6 @@
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
7 * 7 *
8 * $Revision: 1.10 $
9 */ 8 */
10 9
11#ifndef DASD_ECKD_H 10#ifndef DASD_ECKD_H
@@ -30,6 +29,7 @@
30#define DASD_ECKD_CCW_PSF 0x27 29#define DASD_ECKD_CCW_PSF 0x27
31#define DASD_ECKD_CCW_RSSD 0x3e 30#define DASD_ECKD_CCW_RSSD 0x3e
32#define DASD_ECKD_CCW_LOCATE_RECORD 0x47 31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47
32#define DASD_ECKD_CCW_SNSS 0x54
33#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63 33#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63
34#define DASD_ECKD_CCW_WRITE_MT 0x85 34#define DASD_ECKD_CCW_WRITE_MT 0x85
35#define DASD_ECKD_CCW_READ_MT 0x86 35#define DASD_ECKD_CCW_READ_MT 0x86
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
new file mode 100644
index 000000000000..f70cd7716b24
--- /dev/null
+++ b/drivers/s390/block/dasd_eer.c
@@ -0,0 +1,1090 @@
1/*
2 * character device driver for extended error reporting
3 *
4 *
5 * Copyright (C) 2005 IBM Corporation
6 * extended error reporting for DASD ECKD devices
7 * Author(s): Stefan Weinhuber <wein@de.ibm.com>
8 *
9 */
10
11#include <linux/init.h>
12#include <linux/fs.h>
13#include <linux/kernel.h>
14#include <linux/miscdevice.h>
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/device.h>
18#include <linux/workqueue.h>
19#include <linux/poll.h>
20#include <linux/notifier.h>
21
22#include <asm/uaccess.h>
23#include <asm/semaphore.h>
24#include <asm/atomic.h>
25#include <asm/ebcdic.h>
26
27#include "dasd_int.h"
28#include "dasd_eckd.h"
29
30
31MODULE_LICENSE("GPL");
32
33MODULE_AUTHOR("Stefan Weinhuber <wein@de.ibm.com>");
34MODULE_DESCRIPTION("DASD extended error reporting module");
35
36
37#ifdef PRINTK_HEADER
38#undef PRINTK_HEADER
39#endif /* PRINTK_HEADER */
40#define PRINTK_HEADER "dasd(eer):"
41
42
43
44
45
46/*****************************************************************************/
47/* the internal buffer */
48/*****************************************************************************/
49
50/*
51 * The internal buffer is meant to store obaque blobs of data, so it doesn't
52 * know of higher level concepts like triggers.
53 * It consists of a number of pages that are used as a ringbuffer. Each data
54 * blob is stored in a simple record that consists of an integer, which
55 * contains the size of the following data, and the data bytes themselfes.
56 *
57 * To allow for multiple independent readers we create one internal buffer
58 * each time the device is opened and destroy the buffer when the file is
59 * closed again.
60 *
61 * One record can be written to a buffer by using the functions
62 * - dasd_eer_start_record (one time per record to write the size to the buffer
63 * and reserve the space for the data)
64 * - dasd_eer_write_buffer (one or more times per record to write the data)
65 * The data can be written in several steps but you will have to compute
66 * the total size up front for the invocation of dasd_eer_start_record.
67 * If the ringbuffer is full, dasd_eer_start_record will remove the required
68 * number of old records.
69 *
70 * A record is typically read in two steps, first read the integer that
71 * specifies the size of the following data, then read the data.
72 * Both can be done by
73 * - dasd_eer_read_buffer
74 *
75 * For all mentioned functions you need to get the bufferlock first and keep it
76 * until a complete record is written or read.
77 */
78
79
80/*
81 * Alle information necessary to keep track of an internal buffer is kept in
82 * a struct eerbuffer. The buffer specific to a file pointer is strored in
83 * the private_data field of that file. To be able to write data to all
84 * existing buffers, each buffer is also added to the bufferlist.
85 * If the user doesn't want to read a complete record in one go, we have to
86 * keep track of the rest of the record. residual stores the number of bytes
87 * that are still to deliver. If the rest of the record is invalidated between
88 * two reads then residual will be set to -1 so that the next read will fail.
89 * All entries in the eerbuffer structure are protected with the bufferlock.
90 * To avoid races between writing to a buffer on the one side and creating
91 * and destroying buffers on the other side, the bufferlock must also be used
92 * to protect the bufferlist.
93 */
94
95struct eerbuffer {
96 struct list_head list;
97 char **buffer;
98 int buffersize;
99 int buffer_page_count;
100 int head;
101 int tail;
102 int residual;
103};
104
105LIST_HEAD(bufferlist);
106
107static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED;
108
109DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue);
110
111/*
112 * How many free bytes are available on the buffer.
113 * needs to be called with bufferlock held
114 */
115static int
116dasd_eer_get_free_bytes(struct eerbuffer *eerb)
117{
118 if (eerb->head < eerb->tail) {
119 return eerb->tail - eerb->head - 1;
120 } else
121 return eerb->buffersize - eerb->head + eerb->tail -1;
122}
123
124/*
125 * How many bytes of buffer space are used.
126 * needs to be called with bufferlock held
127 */
128static int
129dasd_eer_get_filled_bytes(struct eerbuffer *eerb)
130{
131
132 if (eerb->head >= eerb->tail) {
133 return eerb->head - eerb->tail;
134 } else
135 return eerb->buffersize - eerb->tail + eerb->head;
136}
137
138/*
139 * The dasd_eer_write_buffer function just copies count bytes of data
140 * to the buffer. Make sure to call dasd_eer_start_record first, to
141 * make sure that enough free space is available.
142 * needs to be called with bufferlock held
143 */
144static void
145dasd_eer_write_buffer(struct eerbuffer *eerb, int count, char *data)
146{
147
148 unsigned long headindex,localhead;
149 unsigned long rest, len;
150 char *nextdata;
151
152 nextdata = data;
153 rest = count;
154 while (rest > 0) {
155 headindex = eerb->head / PAGE_SIZE;
156 localhead = eerb->head % PAGE_SIZE;
157 len = min(rest, (PAGE_SIZE - localhead));
158 memcpy(eerb->buffer[headindex]+localhead, nextdata, len);
159 nextdata += len;
160 rest -= len;
161 eerb->head += len;
162 if ( eerb->head == eerb->buffersize )
163 eerb->head = 0; /* wrap around */
164 if (eerb->head > eerb->buffersize) {
165 MESSAGE(KERN_ERR, "%s", "runaway buffer head.");
166 BUG();
167 }
168 }
169}
170
171/*
172 * needs to be called with bufferlock held
173 */
174static int
175dasd_eer_read_buffer(struct eerbuffer *eerb, int count, char *data)
176{
177
178 unsigned long tailindex,localtail;
179 unsigned long rest, len, finalcount;
180 char *nextdata;
181
182 finalcount = min(count, dasd_eer_get_filled_bytes(eerb));
183 nextdata = data;
184 rest = finalcount;
185 while (rest > 0) {
186 tailindex = eerb->tail / PAGE_SIZE;
187 localtail = eerb->tail % PAGE_SIZE;
188 len = min(rest, (PAGE_SIZE - localtail));
189 memcpy(nextdata, eerb->buffer[tailindex]+localtail, len);
190 nextdata += len;
191 rest -= len;
192 eerb->tail += len;
193 if ( eerb->tail == eerb->buffersize )
194 eerb->tail = 0; /* wrap around */
195 if (eerb->tail > eerb->buffersize) {
196 MESSAGE(KERN_ERR, "%s", "runaway buffer tail.");
197 BUG();
198 }
199 }
200 return finalcount;
201}
202
203/*
204 * Whenever you want to write a blob of data to the internal buffer you
205 * have to start by using this function first. It will write the number
206 * of bytes that will be written to the buffer. If necessary it will remove
207 * old records to make room for the new one.
208 * needs to be called with bufferlock held
209 */
210static int
211dasd_eer_start_record(struct eerbuffer *eerb, int count)
212{
213 int tailcount;
214 if (count + sizeof(count) > eerb->buffersize)
215 return -ENOMEM;
216 while (dasd_eer_get_free_bytes(eerb) < count + sizeof(count)) {
217 if (eerb->residual > 0) {
218 eerb->tail += eerb->residual;
219 if (eerb->tail >= eerb->buffersize)
220 eerb->tail -= eerb->buffersize;
221 eerb->residual = -1;
222 }
223 dasd_eer_read_buffer(eerb, sizeof(tailcount),
224 (char*)(&tailcount));
225 eerb->tail += tailcount;
226 if (eerb->tail >= eerb->buffersize)
227 eerb->tail -= eerb->buffersize;
228 }
229 dasd_eer_write_buffer(eerb, sizeof(count), (char*)(&count));
230
231 return 0;
232};
233
234/*
235 * release pages that are not used anymore
236 */
237static void
238dasd_eer_free_buffer_pages(char **buf, int no_pages)
239{
240 int i;
241
242 for (i = 0; i < no_pages; ++i) {
243 free_page((unsigned long)buf[i]);
244 }
245}
246
247/*
248 * allocate a new set of memory pages
249 */
250static int
251dasd_eer_allocate_buffer_pages(char **buf, int no_pages)
252{
253 int i;
254
255 for (i = 0; i < no_pages; ++i) {
256 buf[i] = (char *) get_zeroed_page(GFP_KERNEL);
257 if (!buf[i]) {
258 dasd_eer_free_buffer_pages(buf, i);
259 return -ENOMEM;
260 }
261 }
262 return 0;
263}
264
265/*
266 * empty the buffer by resetting head and tail
267 * In case there is a half read data blob in the buffer, we set residual
268 * to -1 to indicate that the remainder of the blob is lost.
269 */
270static void
271dasd_eer_purge_buffer(struct eerbuffer *eerb)
272{
273 unsigned long flags;
274
275 spin_lock_irqsave(&bufferlock, flags);
276 if (eerb->residual > 0)
277 eerb->residual = -1;
278 eerb->tail=0;
279 eerb->head=0;
280 spin_unlock_irqrestore(&bufferlock, flags);
281}
282
283/*
284 * set the size of the buffer, newsize is the new number of pages to be used
285 * we don't try to copy any data back an forth, so any resize will also purge
286 * the buffer
287 */
288static int
289dasd_eer_resize_buffer(struct eerbuffer *eerb, int newsize)
290{
291 int i, oldcount, reuse;
292 char **new;
293 char **old;
294 unsigned long flags;
295
296 if (newsize < 1)
297 return -EINVAL;
298 if (eerb->buffer_page_count == newsize) {
299 /* documented behaviour is that any successfull invocation
300 * will purge all records */
301 dasd_eer_purge_buffer(eerb);
302 return 0;
303 }
304 new = kmalloc(newsize*sizeof(char*), GFP_KERNEL);
305 if (!new)
306 return -ENOMEM;
307
308 reuse=min(eerb->buffer_page_count, newsize);
309 for (i = 0; i < reuse; ++i) {
310 new[i] = eerb->buffer[i];
311 }
312 if (eerb->buffer_page_count < newsize) {
313 if (dasd_eer_allocate_buffer_pages(
314 &new[eerb->buffer_page_count],
315 newsize - eerb->buffer_page_count)) {
316 kfree(new);
317 return -ENOMEM;
318 }
319 }
320
321 spin_lock_irqsave(&bufferlock, flags);
322 old = eerb->buffer;
323 eerb->buffer = new;
324 if (eerb->residual > 0)
325 eerb->residual = -1;
326 eerb->tail = 0;
327 eerb->head = 0;
328 oldcount = eerb->buffer_page_count;
329 eerb->buffer_page_count = newsize;
330 spin_unlock_irqrestore(&bufferlock, flags);
331
332 if (oldcount > newsize) {
333 for (i = newsize; i < oldcount; ++i) {
334 free_page((unsigned long)old[i]);
335 }
336 }
337 kfree(old);
338
339 return 0;
340}
341
342
343/*****************************************************************************/
344/* The extended error reporting functionality */
345/*****************************************************************************/
346
347/*
348 * When a DASD device driver wants to report an error, it calls the
349 * function dasd_eer_write_trigger (via a notifier mechanism) and gives the
350 * respective trigger ID as parameter.
351 * Currently there are four kinds of triggers:
352 *
353 * DASD_EER_FATALERROR: all kinds of unrecoverable I/O problems
354 * DASD_EER_PPRCSUSPEND: PPRC was suspended
355 * DASD_EER_NOPATH: There is no path to the device left.
356 * DASD_EER_STATECHANGE: The state of the device has changed.
357 *
358 * For the first three triggers all required information can be supplied by
359 * the caller. For these triggers a record is written by the function
360 * dasd_eer_write_standard_trigger.
361 *
362 * When dasd_eer_write_trigger is called to write a DASD_EER_STATECHANGE
363 * trigger, we have to gather the necessary sense data first. We cannot queue
364 * the necessary SNSS (sense subsystem status) request immediatly, since we
365 * are likely to run in a deadlock situation. Instead, we schedule a
366 * work_struct that calls the function dasd_eer_sense_subsystem_status to
367 * create and start an SNSS request asynchronously.
368 *
369 * To avoid memory allocations at runtime, the necessary memory is allocated
370 * when the extended error reporting is enabled for a device (by
371 * dasd_eer_probe). There is one private eer data structure for each eer
372 * enabled DASD device. It contains memory for the work_struct, one SNSS cqr
373 * and a flags field that is used to coordinate the use of the cqr. The call
374 * to write a state change trigger can come in at any time, so we have one flag
375 * CQR_IN_USE that protects the cqr itself. When this flag indicates that the
376 * cqr is currently in use, dasd_eer_sense_subsystem_status cannot start a
377 * second request but sets the SNSS_REQUESTED flag instead.
378 *
379 * When the request is finished, the callback function dasd_eer_SNSS_cb
380 * is called. This function will invoke the function
381 * dasd_eer_write_SNSS_trigger to finally write the trigger. It will also
382 * check the SNSS_REQUESTED flag and if it is set it will call
383 * dasd_eer_sense_subsystem_status again.
384 *
385 * To avoid race conditions during the handling of the lock, the flags must
386 * be protected by the snsslock.
387 */
388
389struct dasd_eer_private {
390 struct dasd_ccw_req *cqr;
391 unsigned long flags;
392 struct work_struct worker;
393};
394
395static void dasd_eer_destroy(struct dasd_device *device,
396 struct dasd_eer_private *eer);
397static int
398dasd_eer_write_trigger(struct dasd_eer_trigger *trigger);
399static void dasd_eer_sense_subsystem_status(void *data);
400static int dasd_eer_notify(struct notifier_block *self,
401 unsigned long action, void *data);
402
403struct workqueue_struct *dasd_eer_workqueue;
404
405#define SNSS_DATA_SIZE 44
406static spinlock_t snsslock = SPIN_LOCK_UNLOCKED;
407
408#define DASD_EER_BUSID_SIZE 10
409struct dasd_eer_header {
410 __u32 total_size;
411 __u32 trigger;
412 __u64 tv_sec;
413 __u64 tv_usec;
414 char busid[DASD_EER_BUSID_SIZE];
415} __attribute__ ((packed));
416
417static struct notifier_block dasd_eer_nb = {
418 .notifier_call = dasd_eer_notify,
419};
420
421/*
422 * flags for use with dasd_eer_private
423 */
424#define CQR_IN_USE 0
425#define SNSS_REQUESTED 1
426
427/*
428 * This function checks if extended error reporting is available for a given
429 * dasd_device. If yes, then it creates and returns a struct dasd_eer,
430 * otherwise it returns an -EPERM error pointer.
431 */
432struct dasd_eer_private *
433dasd_eer_probe(struct dasd_device *device)
434{
435 struct dasd_eer_private *private;
436
437 if (!(device && device->discipline
438 && !strcmp(device->discipline->name, "ECKD"))) {
439 return ERR_PTR(-EPERM);
440 }
441 /* allocate the private data structure */
442 private = (struct dasd_eer_private *)kmalloc(
443 sizeof(struct dasd_eer_private), GFP_KERNEL);
444 if (!private) {
445 return ERR_PTR(-ENOMEM);
446 }
447 INIT_WORK(&private->worker, dasd_eer_sense_subsystem_status,
448 (void *)device);
449 private->cqr = dasd_kmalloc_request("ECKD",
450 1 /* SNSS */ ,
451 SNSS_DATA_SIZE ,
452 device);
453 if (!private->cqr) {
454 kfree(private);
455 return ERR_PTR(-ENOMEM);
456 }
457 private->flags = 0;
458 return private;
459};
460
461/*
462 * If our private SNSS request is queued, remove it from the
463 * dasd ccw queue so we can free the requests memory.
464 */
465static void
466dasd_eer_dequeue_SNSS_request(struct dasd_device *device,
467 struct dasd_eer_private *eer)
468{
469 struct list_head *lst, *nxt;
470 struct dasd_ccw_req *cqr, *erpcqr;
471 dasd_erp_fn_t erp_fn;
472
473 spin_lock_irq(get_ccwdev_lock(device->cdev));
474 list_for_each_safe(lst, nxt, &device->ccw_queue) {
475 cqr = list_entry(lst, struct dasd_ccw_req, list);
476 /* we are looking for two kinds or requests */
477 /* first kind: our SNSS request: */
478 if (cqr == eer->cqr) {
479 if (cqr->status == DASD_CQR_IN_IO)
480 device->discipline->term_IO(cqr);
481 list_del(&cqr->list);
482 break;
483 }
484 /* second kind: ERP requests for our SNSS request */
485 if (cqr->refers) {
486 /* If this erp request chain ends in our cqr, then */
487 /* cal the erp_postaction to clean it up */
488 erpcqr = cqr;
489 while (erpcqr->refers) {
490 erpcqr = erpcqr->refers;
491 }
492 if (erpcqr == eer->cqr) {
493 erp_fn = device->discipline->erp_postaction(
494 cqr);
495 erp_fn(cqr);
496 }
497 continue;
498 }
499 }
500 spin_unlock_irq(get_ccwdev_lock(device->cdev));
501}
502
503/*
504 * This function dismantles a struct dasd_eer that was created by
505 * dasd_eer_probe. Since we want to free our private data structure,
506 * we must make sure that the memory is not in use anymore.
507 * We have to flush the work queue and remove a possible SNSS request
508 * from the dasd queue.
509 */
510static void
511dasd_eer_destroy(struct dasd_device *device, struct dasd_eer_private *eer)
512{
513 flush_workqueue(dasd_eer_workqueue);
514 dasd_eer_dequeue_SNSS_request(device, eer);
515 dasd_kfree_request(eer->cqr, device);
516 kfree(eer);
517};
518
519/*
520 * enable the extended error reporting for a particular device
521 */
522static int
523dasd_eer_enable_on_device(struct dasd_device *device)
524{
525 void *eer;
526 if (!device)
527 return -ENODEV;
528 if (device->eer)
529 return 0;
530 if (!try_module_get(THIS_MODULE)) {
531 return -EINVAL;
532 }
533 eer = (void *)dasd_eer_probe(device);
534 if (IS_ERR(eer)) {
535 module_put(THIS_MODULE);
536 return PTR_ERR(eer);
537 }
538 device->eer = eer;
539 return 0;
540}
541
542/*
543 * enable the extended error reporting for a particular device
544 */
545static int
546dasd_eer_disable_on_device(struct dasd_device *device)
547{
548 struct dasd_eer_private *eer = device->eer;
549
550 if (!device)
551 return -ENODEV;
552 if (!device->eer)
553 return 0;
554 device->eer = NULL;
555 dasd_eer_destroy(device,eer);
556 module_put(THIS_MODULE);
557
558 return 0;
559}
560
561/*
562 * Set extended error reporting (eer)
563 * Note: This will be registered as a DASD ioctl, to be called on DASD devices.
564 */
565static int
566dasd_ioctl_set_eer(struct block_device *bdev, int no, long args)
567{
568 struct dasd_device *device;
569 int intval;
570
571 if (!capable(CAP_SYS_ADMIN))
572 return -EACCES;
573 if (bdev != bdev->bd_contains)
574 /* Error-reporting is not allowed for partitions */
575 return -EINVAL;
576 if (get_user(intval, (int __user *) args))
577 return -EFAULT;
578 device = bdev->bd_disk->private_data;
579 if (device == NULL)
580 return -ENODEV;
581
582 intval = (intval != 0);
583 DEV_MESSAGE (KERN_DEBUG, device,
584 "set eer on device to %d", intval);
585 if (intval)
586 return dasd_eer_enable_on_device(device);
587 else
588 return dasd_eer_disable_on_device(device);
589}
590
591/*
592 * Get value of extended error reporting.
593 * Note: This will be registered as a DASD ioctl, to be called on DASD devices.
594 */
595static int
596dasd_ioctl_get_eer(struct block_device *bdev, int no, long args)
597{
598 struct dasd_device *device;
599
600 device = bdev->bd_disk->private_data;
601 if (device == NULL)
602 return -ENODEV;
603 return put_user((device->eer != NULL), (int __user *) args);
604}
605
606/*
607 * The following function can be used for those triggers that have
608 * all necessary data available when the function is called.
609 * If the parameter cqr is not NULL, the chain of requests will be searched
610 * for valid sense data, and all valid sense data sets will be added to
611 * the triggers data.
612 */
613static int
614dasd_eer_write_standard_trigger(int trigger, struct dasd_device *device,
615 struct dasd_ccw_req *cqr)
616{
617 struct dasd_ccw_req *temp_cqr;
618 int data_size;
619 struct timeval tv;
620 struct dasd_eer_header header;
621 unsigned long flags;
622 struct eerbuffer *eerb;
623
624 /* go through cqr chain and count the valid sense data sets */
625 temp_cqr = cqr;
626 data_size = 0;
627 while (temp_cqr) {
628 if (temp_cqr->irb.esw.esw0.erw.cons)
629 data_size += 32;
630 temp_cqr = temp_cqr->refers;
631 }
632
633 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
634 header.trigger = trigger;
635 do_gettimeofday(&tv);
636 header.tv_sec = tv.tv_sec;
637 header.tv_usec = tv.tv_usec;
638 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
639
640 spin_lock_irqsave(&bufferlock, flags);
641 list_for_each_entry(eerb, &bufferlist, list) {
642 dasd_eer_start_record(eerb, header.total_size);
643 dasd_eer_write_buffer(eerb, sizeof(header), (char*)(&header));
644 temp_cqr = cqr;
645 while (temp_cqr) {
646 if (temp_cqr->irb.esw.esw0.erw.cons)
647 dasd_eer_write_buffer(eerb, 32, cqr->irb.ecw);
648 temp_cqr = temp_cqr->refers;
649 }
650 dasd_eer_write_buffer(eerb, 4,"EOR");
651 }
652 spin_unlock_irqrestore(&bufferlock, flags);
653
654 wake_up_interruptible(&dasd_eer_read_wait_queue);
655
656 return 0;
657}
658
659/*
660 * This function writes a DASD_EER_STATECHANGE trigger.
661 */
662static void
663dasd_eer_write_SNSS_trigger(struct dasd_device *device,
664 struct dasd_ccw_req *cqr)
665{
666 int data_size;
667 int snss_rc;
668 struct timeval tv;
669 struct dasd_eer_header header;
670 unsigned long flags;
671 struct eerbuffer *eerb;
672
673 snss_rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
674 if (snss_rc)
675 data_size = 0;
676 else
677 data_size = SNSS_DATA_SIZE;
678
679 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
680 header.trigger = DASD_EER_STATECHANGE;
681 do_gettimeofday(&tv);
682 header.tv_sec = tv.tv_sec;
683 header.tv_usec = tv.tv_usec;
684 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
685
686 spin_lock_irqsave(&bufferlock, flags);
687 list_for_each_entry(eerb, &bufferlist, list) {
688 dasd_eer_start_record(eerb, header.total_size);
689 dasd_eer_write_buffer(eerb, sizeof(header),(char*)(&header));
690 if (!snss_rc)
691 dasd_eer_write_buffer(eerb, SNSS_DATA_SIZE, cqr->data);
692 dasd_eer_write_buffer(eerb, 4,"EOR");
693 }
694 spin_unlock_irqrestore(&bufferlock, flags);
695
696 wake_up_interruptible(&dasd_eer_read_wait_queue);
697}
698
699/*
700 * callback function for use with SNSS request
701 */
702static void
703dasd_eer_SNSS_cb(struct dasd_ccw_req *cqr, void *data)
704{
705 struct dasd_device *device;
706 struct dasd_eer_private *private;
707 unsigned long irqflags;
708
709 device = (struct dasd_device *)data;
710 private = (struct dasd_eer_private *)device->eer;
711 dasd_eer_write_SNSS_trigger(device, cqr);
712 spin_lock_irqsave(&snsslock, irqflags);
713 if(!test_and_clear_bit(SNSS_REQUESTED, &private->flags)) {
714 clear_bit(CQR_IN_USE, &private->flags);
715 spin_unlock_irqrestore(&snsslock, irqflags);
716 return;
717 };
718 clear_bit(CQR_IN_USE, &private->flags);
719 spin_unlock_irqrestore(&snsslock, irqflags);
720 dasd_eer_sense_subsystem_status(device);
721 return;
722}
723
724/*
725 * clean a used cqr before using it again
726 */
727static void
728dasd_eer_clean_SNSS_request(struct dasd_ccw_req *cqr)
729{
730 struct ccw1 *cpaddr = cqr->cpaddr;
731 void *data = cqr->data;
732
733 memset(cqr, 0, sizeof(struct dasd_ccw_req));
734 memset(cpaddr, 0, sizeof(struct ccw1));
735 memset(data, 0, SNSS_DATA_SIZE);
736 cqr->cpaddr = cpaddr;
737 cqr->data = data;
738 strncpy((char *) &cqr->magic, "ECKD", 4);
739 ASCEBC((char *) &cqr->magic, 4);
740 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
741}
742
743/*
744 * build and start an SNSS request
745 * This function is called from a work queue so we have to
746 * pass the dasd_device pointer as a void pointer.
747 */
748static void
749dasd_eer_sense_subsystem_status(void *data)
750{
751 struct dasd_device *device;
752 struct dasd_eer_private *private;
753 struct dasd_ccw_req *cqr;
754 struct ccw1 *ccw;
755 unsigned long irqflags;
756
757 device = (struct dasd_device *)data;
758 private = (struct dasd_eer_private *)device->eer;
759 if (!private) /* device not eer enabled any more */
760 return;
761 cqr = private->cqr;
762 spin_lock_irqsave(&snsslock, irqflags);
763 if(test_and_set_bit(CQR_IN_USE, &private->flags)) {
764 set_bit(SNSS_REQUESTED, &private->flags);
765 spin_unlock_irqrestore(&snsslock, irqflags);
766 return;
767 };
768 spin_unlock_irqrestore(&snsslock, irqflags);
769 dasd_eer_clean_SNSS_request(cqr);
770 cqr->device = device;
771 cqr->retries = 255;
772 cqr->expires = 10 * HZ;
773
774 ccw = cqr->cpaddr;
775 ccw->cmd_code = DASD_ECKD_CCW_SNSS;
776 ccw->count = SNSS_DATA_SIZE;
777 ccw->flags = 0;
778 ccw->cda = (__u32)(addr_t)cqr->data;
779
780 cqr->buildclk = get_clock();
781 cqr->status = DASD_CQR_FILLED;
782 cqr->callback = dasd_eer_SNSS_cb;
783 cqr->callback_data = (void *)device;
784 dasd_add_request_head(cqr);
785
786 return;
787}
788
789/*
790 * This function is called for all triggers. It calls the appropriate
791 * function that writes the actual trigger records.
792 */
793static int
794dasd_eer_write_trigger(struct dasd_eer_trigger *trigger)
795{
796 int rc;
797 struct dasd_eer_private *private = trigger->device->eer;
798
799 switch (trigger->id) {
800 case DASD_EER_FATALERROR:
801 case DASD_EER_PPRCSUSPEND:
802 rc = dasd_eer_write_standard_trigger(
803 trigger->id, trigger->device, trigger->cqr);
804 break;
805 case DASD_EER_NOPATH:
806 rc = dasd_eer_write_standard_trigger(
807 trigger->id, trigger->device, NULL);
808 break;
809 case DASD_EER_STATECHANGE:
810 if (queue_work(dasd_eer_workqueue, &private->worker)) {
811 rc=0;
812 } else {
813 /* If the work_struct was already queued, it can't
814 * be queued again. But this is OK since we don't
815 * need to have it queued twice.
816 */
817 rc = -EBUSY;
818 }
819 break;
820 default: /* unknown trigger, so we write it without any sense data */
821 rc = dasd_eer_write_standard_trigger(
822 trigger->id, trigger->device, NULL);
823 break;
824 }
825 return rc;
826}
827
828/*
829 * This function is registered with the dasd device driver and gets called
830 * for all dasd eer notifications.
831 */
832static int dasd_eer_notify(struct notifier_block *self,
833 unsigned long action, void *data)
834{
835 switch (action) {
836 case DASD_EER_DISABLE:
837 dasd_eer_disable_on_device((struct dasd_device *)data);
838 break;
839 case DASD_EER_TRIGGER:
840 dasd_eer_write_trigger((struct dasd_eer_trigger *)data);
841 break;
842 }
843 return NOTIFY_OK;
844}
845
846
847/*****************************************************************************/
848/* the device operations */
849/*****************************************************************************/
850
851/*
852 * On the one side we need a lock to access our internal buffer, on the
853 * other side a copy_to_user can sleep. So we need to copy the data we have
854 * to transfer in a readbuffer, which is protected by the readbuffer_mutex.
855 */
856static char readbuffer[PAGE_SIZE];
857DECLARE_MUTEX(readbuffer_mutex);
858
859
860static int
861dasd_eer_open(struct inode *inp, struct file *filp)
862{
863 struct eerbuffer *eerb;
864 unsigned long flags;
865
866 eerb = kmalloc(sizeof(struct eerbuffer), GFP_KERNEL);
867 eerb->head = 0;
868 eerb->tail = 0;
869 eerb->residual = 0;
870 eerb->buffer_page_count = 1;
871 eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
872 eerb->buffer = kmalloc(eerb->buffer_page_count*sizeof(char*),
873 GFP_KERNEL);
874 if (!eerb->buffer)
875 return -ENOMEM;
876 if (dasd_eer_allocate_buffer_pages(eerb->buffer,
877 eerb->buffer_page_count)) {
878 kfree(eerb->buffer);
879 return -ENOMEM;
880 }
881 filp->private_data = eerb;
882 spin_lock_irqsave(&bufferlock, flags);
883 list_add(&eerb->list, &bufferlist);
884 spin_unlock_irqrestore(&bufferlock, flags);
885
886 return nonseekable_open(inp,filp);
887}
888
889static int
890dasd_eer_close(struct inode *inp, struct file *filp)
891{
892 struct eerbuffer *eerb;
893 unsigned long flags;
894
895 eerb = (struct eerbuffer *)filp->private_data;
896 spin_lock_irqsave(&bufferlock, flags);
897 list_del(&eerb->list);
898 spin_unlock_irqrestore(&bufferlock, flags);
899 dasd_eer_free_buffer_pages(eerb->buffer, eerb->buffer_page_count);
900 kfree(eerb->buffer);
901 kfree(eerb);
902
903 return 0;
904}
905
906static long
907dasd_eer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
908{
909 int intval;
910 struct eerbuffer *eerb;
911
912 eerb = (struct eerbuffer *)filp->private_data;
913 switch (cmd) {
914 case DASD_EER_PURGE:
915 dasd_eer_purge_buffer(eerb);
916 return 0;
917 case DASD_EER_SETBUFSIZE:
918 if (get_user(intval, (int __user *)arg))
919 return -EFAULT;
920 return dasd_eer_resize_buffer(eerb, intval);
921 default:
922 return -ENOIOCTLCMD;
923 }
924}
925
926static ssize_t
927dasd_eer_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
928{
929 int tc,rc;
930 int tailcount,effective_count;
931 unsigned long flags;
932 struct eerbuffer *eerb;
933
934 eerb = (struct eerbuffer *)filp->private_data;
935 if(down_interruptible(&readbuffer_mutex))
936 return -ERESTARTSYS;
937
938 spin_lock_irqsave(&bufferlock, flags);
939
940 if (eerb->residual < 0) { /* the remainder of this record */
941 /* has been deleted */
942 eerb->residual = 0;
943 spin_unlock_irqrestore(&bufferlock, flags);
944 up(&readbuffer_mutex);
945 return -EIO;
946 } else if (eerb->residual > 0) {
947 /* OK we still have a second half of a record to deliver */
948 effective_count = min(eerb->residual, (int)count);
949 eerb->residual -= effective_count;
950 } else {
951 tc = 0;
952 while (!tc) {
953 tc = dasd_eer_read_buffer(eerb,
954 sizeof(tailcount), (char*)(&tailcount));
955 if (!tc) {
956 /* no data available */
957 spin_unlock_irqrestore(&bufferlock, flags);
958 up(&readbuffer_mutex);
959 if (filp->f_flags & O_NONBLOCK)
960 return -EAGAIN;
961 rc = wait_event_interruptible(
962 dasd_eer_read_wait_queue,
963 eerb->head != eerb->tail);
964 if (rc) {
965 return rc;
966 }
967 if(down_interruptible(&readbuffer_mutex))
968 return -ERESTARTSYS;
969 spin_lock_irqsave(&bufferlock, flags);
970 }
971 }
972 WARN_ON(tc != sizeof(tailcount));
973 effective_count = min(tailcount,(int)count);
974 eerb->residual = tailcount - effective_count;
975 }
976
977 tc = dasd_eer_read_buffer(eerb, effective_count, readbuffer);
978 WARN_ON(tc != effective_count);
979
980 spin_unlock_irqrestore(&bufferlock, flags);
981
982 if (copy_to_user(buf, readbuffer, effective_count)) {
983 up(&readbuffer_mutex);
984 return -EFAULT;
985 }
986
987 up(&readbuffer_mutex);
988 return effective_count;
989}
990
991static unsigned int
992dasd_eer_poll (struct file *filp, poll_table *ptable)
993{
994 unsigned int mask;
995 unsigned long flags;
996 struct eerbuffer *eerb;
997
998 eerb = (struct eerbuffer *)filp->private_data;
999 poll_wait(filp, &dasd_eer_read_wait_queue, ptable);
1000 spin_lock_irqsave(&bufferlock, flags);
1001 if (eerb->head != eerb->tail)
1002 mask = POLLIN | POLLRDNORM ;
1003 else
1004 mask = 0;
1005 spin_unlock_irqrestore(&bufferlock, flags);
1006 return mask;
1007}
1008
1009static struct file_operations dasd_eer_fops = {
1010 .open = &dasd_eer_open,
1011 .release = &dasd_eer_close,
1012 .unlocked_ioctl = &dasd_eer_ioctl,
1013 .compat_ioctl = &dasd_eer_ioctl,
1014 .read = &dasd_eer_read,
1015 .poll = &dasd_eer_poll,
1016 .owner = THIS_MODULE,
1017};
1018
1019static struct miscdevice dasd_eer_dev = {
1020 .minor = MISC_DYNAMIC_MINOR,
1021 .name = "dasd_eer",
1022 .fops = &dasd_eer_fops,
1023};
1024
1025
1026/*****************************************************************************/
1027/* Init and exit */
1028/*****************************************************************************/
1029
1030static int
1031__init dasd_eer_init(void)
1032{
1033 int rc;
1034
1035 dasd_eer_workqueue = create_singlethread_workqueue("dasd_eer");
1036 if (!dasd_eer_workqueue) {
1037 MESSAGE(KERN_ERR , "%s", "dasd_eer_init could not "
1038 "create workqueue \n");
1039 rc = -ENOMEM;
1040 goto out;
1041 }
1042
1043 rc = dasd_register_eer_notifier(&dasd_eer_nb);
1044 if (rc) {
1045 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
1046 "register error reporting");
1047 goto queue;
1048 }
1049
1050 dasd_ioctl_no_register(THIS_MODULE, BIODASDEERSET, dasd_ioctl_set_eer);
1051 dasd_ioctl_no_register(THIS_MODULE, BIODASDEERGET, dasd_ioctl_get_eer);
1052
1053 /* we don't need our own character device,
1054 * so we just register as misc device */
1055 rc = misc_register(&dasd_eer_dev);
1056 if (rc) {
1057 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
1058 "register misc device");
1059 goto unregister;
1060 }
1061
1062 return 0;
1063
1064unregister:
1065 dasd_unregister_eer_notifier(&dasd_eer_nb);
1066 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERSET,
1067 dasd_ioctl_set_eer);
1068 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERGET,
1069 dasd_ioctl_get_eer);
1070queue:
1071 destroy_workqueue(dasd_eer_workqueue);
1072out:
1073 return rc;
1074
1075}
1076module_init(dasd_eer_init);
1077
1078static void
1079__exit dasd_eer_exit(void)
1080{
1081 dasd_unregister_eer_notifier(&dasd_eer_nb);
1082 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERSET,
1083 dasd_ioctl_set_eer);
1084 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERGET,
1085 dasd_ioctl_get_eer);
1086 destroy_workqueue(dasd_eer_workqueue);
1087
1088 WARN_ON(misc_deregister(&dasd_eer_dev) != 0);
1089}
1090module_exit(dasd_eer_exit);
diff --git a/drivers/s390/block/dasd_erp.c b/drivers/s390/block/dasd_erp.c
index 7cb98d25f341..8fd71ab02ef0 100644
--- a/drivers/s390/block/dasd_erp.c
+++ b/drivers/s390/block/dasd_erp.c
@@ -7,7 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.14 $
11 */ 10 */
12 11
13#include <linux/config.h> 12#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 8ec75dc08e2c..91145698f8e9 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6 * 6 *
7 * $Revision: 1.41 $
8 */ 7 */
9 8
10#include <linux/config.h> 9#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_fba.h b/drivers/s390/block/dasd_fba.h
index 624f0402ee22..da1fa91fc01d 100644
--- a/drivers/s390/block/dasd_fba.h
+++ b/drivers/s390/block/dasd_fba.h
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6 * 6 *
7 * $Revision: 1.6 $
8 */ 7 */
9 8
10#ifndef DASD_FBA_H 9#ifndef DASD_FBA_H
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index a601c9a33541..65dc844b975c 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * gendisk related functions for the dasd driver. 10 * gendisk related functions for the dasd driver.
11 * 11 *
12 * $Revision: 1.51 $
13 */ 12 */
14 13
15#include <linux/config.h> 14#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index e4b401500b01..d1b08fa13fd2 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -6,7 +6,6 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.68 $
10 */ 9 */
11 10
12#ifndef DASD_INT_H 11#ifndef DASD_INT_H
@@ -276,6 +275,34 @@ struct dasd_discipline {
276 275
277extern struct dasd_discipline *dasd_diag_discipline_pointer; 276extern struct dasd_discipline *dasd_diag_discipline_pointer;
278 277
278
279/*
280 * Notification numbers for extended error reporting notifications:
281 * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
282 * eer pointer) is freed. The error reporting module needs to do all necessary
283 * cleanup steps.
284 * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
285 */
286#define DASD_EER_DISABLE 0
287#define DASD_EER_TRIGGER 1
288
289/* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
290#define DASD_EER_FATALERROR 1
291#define DASD_EER_NOPATH 2
292#define DASD_EER_STATECHANGE 3
293#define DASD_EER_PPRCSUSPEND 4
294
295/*
296 * The dasd_eer_trigger structure contains all data that we need to send
297 * along with an DASD_EER_TRIGGER notification.
298 */
299struct dasd_eer_trigger {
300 unsigned int id;
301 struct dasd_device *device;
302 struct dasd_ccw_req *cqr;
303};
304
305
279struct dasd_device { 306struct dasd_device {
280 /* Block device stuff. */ 307 /* Block device stuff. */
281 struct gendisk *gdp; 308 struct gendisk *gdp;
@@ -289,6 +316,9 @@ struct dasd_device {
289 unsigned long flags; /* per device flags */ 316 unsigned long flags; /* per device flags */
290 unsigned short features; /* copy of devmap-features (read-only!) */ 317 unsigned short features; /* copy of devmap-features (read-only!) */
291 318
319 /* extended error reporting stuff (eer) */
320 void *eer;
321
292 /* Device discipline stuff. */ 322 /* Device discipline stuff. */
293 struct dasd_discipline *discipline; 323 struct dasd_discipline *discipline;
294 char *private; 324 char *private;
@@ -489,6 +519,12 @@ int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
489int dasd_generic_set_offline (struct ccw_device *cdev); 519int dasd_generic_set_offline (struct ccw_device *cdev);
490int dasd_generic_notify(struct ccw_device *, int); 520int dasd_generic_notify(struct ccw_device *, int);
491void dasd_generic_auto_online (struct ccw_driver *); 521void dasd_generic_auto_online (struct ccw_driver *);
522int dasd_register_eer_notifier(struct notifier_block *);
523int dasd_unregister_eer_notifier(struct notifier_block *);
524void dasd_write_eer_trigger(unsigned int , struct dasd_device *,
525 struct dasd_ccw_req *);
526
527
492 528
493/* externals in dasd_devmap.c */ 529/* externals in dasd_devmap.c */
494extern int dasd_max_devindex; 530extern int dasd_max_devindex;
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 9396fcacb8f8..fafeeae52675 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -7,8 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.50 $
11 *
12 * i/o controls for the dasd driver. 10 * i/o controls for the dasd driver.
13 */ 11 */
14#include <linux/config.h> 12#include <linux/config.h>
@@ -423,8 +421,15 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
423 dasd_info->cu_model = cdev->id.cu_model; 421 dasd_info->cu_model = cdev->id.cu_model;
424 dasd_info->dev_type = cdev->id.dev_type; 422 dasd_info->dev_type = cdev->id.dev_type;
425 dasd_info->dev_model = cdev->id.dev_model; 423 dasd_info->dev_model = cdev->id.dev_model;
426 dasd_info->open_count = atomic_read(&device->open_count);
427 dasd_info->status = device->state; 424 dasd_info->status = device->state;
425 /*
426 * The open_count is increased for every opener, that includes
427 * the blkdev_get in dasd_scan_partitions.
428 * This must be hidden from user-space.
429 */
430 dasd_info->open_count = atomic_read(&device->open_count);
431 if (!device->bdev)
432 dasd_info->open_count++;
428 433
429 /* 434 /*
430 * check if device is really formatted 435 * check if device is really formatted
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index fff9020d4886..2d5da3c75ca7 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * /proc interface for the dasd driver. 10 * /proc interface for the dasd driver.
11 * 11 *
12 * $Revision: 1.33 $
13 */ 12 */
14 13
15#include <linux/config.h> 14#include <linux/config.h>
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 1f060914cfa4..606f6ad285a0 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/console.h> 22#include <linux/console.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/err.h>
24 25
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/bootmem.h> 27#include <linux/bootmem.h>
@@ -864,7 +865,7 @@ con3215_init(void)
864 } 865 }
865 866
866 cdev = ccw_device_probe_console(); 867 cdev = ccw_device_probe_console();
867 if (!cdev) 868 if (IS_ERR(cdev))
868 return -ENODEV; 869 return -ENODEV;
869 870
870 raw3215[0] = raw = (struct raw3215_info *) 871 raw3215[0] = raw = (struct raw3215_info *)
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index c570a9f6ce9c..ef607a1de55a 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -15,6 +15,7 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/err.h>
18 19
19#include <asm/ccwdev.h> 20#include <asm/ccwdev.h>
20#include <asm/cio.h> 21#include <asm/cio.h>
@@ -597,7 +598,7 @@ con3270_init(void)
597 } 598 }
598 599
599 cdev = ccw_device_probe_console(); 600 cdev = ccw_device_probe_console();
600 if (!cdev) 601 if (IS_ERR(cdev))
601 return -ENODEV; 602 return -ENODEV;
602 rp = raw3270_setup_console(cdev); 603 rp = raw3270_setup_console(cdev);
603 if (IS_ERR(rp)) 604 if (IS_ERR(rp))
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index 5bda2340a39d..a317a123daba 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -440,7 +440,11 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
440 return -EPERM; 440 return -EPERM;
441 len = strnlen_user(u_kbs->kb_string, 441 len = strnlen_user(u_kbs->kb_string,
442 sizeof(u_kbs->kb_string) - 1); 442 sizeof(u_kbs->kb_string) - 1);
443 p = kmalloc(len, GFP_KERNEL); 443 if (!len)
444 return -EFAULT;
445 if (len > sizeof(u_kbs->kb_string) - 1)
446 return -EINVAL;
447 p = kmalloc(len + 1, GFP_KERNEL);
444 if (!p) 448 if (!p)
445 return -ENOMEM; 449 return -ENOMEM;
446 if (copy_from_user(p, u_kbs->kb_string, len)) { 450 if (copy_from_user(p, u_kbs->kb_string, len)) {
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index 20be88e91fa1..682039cac15b 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -1357,7 +1357,7 @@ tape_34xx_init (void)
1357 debug_set_level(TAPE_DBF_AREA, 6); 1357 debug_set_level(TAPE_DBF_AREA, 6);
1358#endif 1358#endif
1359 1359
1360 DBF_EVENT(3, "34xx init: $Revision: 1.23 $\n"); 1360 DBF_EVENT(3, "34xx init\n");
1361 /* Register driver for 3480/3490 tapes. */ 1361 /* Register driver for 3480/3490 tapes. */
1362 rc = ccw_driver_register(&tape_34xx_driver); 1362 rc = ccw_driver_register(&tape_34xx_driver);
1363 if (rc) 1363 if (rc)
@@ -1377,8 +1377,7 @@ tape_34xx_exit(void)
1377 1377
1378MODULE_DEVICE_TABLE(ccw, tape_34xx_ids); 1378MODULE_DEVICE_TABLE(ccw, tape_34xx_ids);
1379MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH"); 1379MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH");
1380MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape " 1380MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape device driver");
1381 "device driver ($Revision: 1.23 $)");
1382MODULE_LICENSE("GPL"); 1381MODULE_LICENSE("GPL");
1383 1382
1384module_init(tape_34xx_init); 1383module_init(tape_34xx_init);
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index fcaee447d6fe..b3569c82bb16 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * (C) Copyright IBM Corp. 2004 2 * (C) Copyright IBM Corp. 2004
3 * tape_class.c ($Revision: 1.8 $) 3 * tape_class.c
4 * 4 *
5 * Tape class device support 5 * Tape class device support
6 * 6 *
@@ -12,7 +12,7 @@
12MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>"); 12MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>");
13MODULE_DESCRIPTION( 13MODULE_DESCRIPTION(
14 "(C) Copyright IBM Corp. 2004 All Rights Reserved.\n" 14 "(C) Copyright IBM Corp. 2004 All Rights Reserved.\n"
15 "tape_class.c ($Revision: 1.8 $)" 15 "tape_class.c"
16); 16);
17MODULE_LICENSE("GPL"); 17MODULE_LICENSE("GPL");
18 18
diff --git a/drivers/s390/char/tape_class.h b/drivers/s390/char/tape_class.h
index 33133ad00ba2..3d0ca054cdee 100644
--- a/drivers/s390/char/tape_class.h
+++ b/drivers/s390/char/tape_class.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * (C) Copyright IBM Corp. 2004 All Rights Reserved. 2 * (C) Copyright IBM Corp. 2004 All Rights Reserved.
3 * tape_class.h ($Revision: 1.4 $) 3 * tape_class.h
4 * 4 *
5 * Tape class device support 5 * Tape class device support
6 * 6 *
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 8f486e1a8507..4ea438c749c9 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -1239,7 +1239,7 @@ tape_init (void)
1239#ifdef DBF_LIKE_HELL 1239#ifdef DBF_LIKE_HELL
1240 debug_set_level(TAPE_DBF_AREA, 6); 1240 debug_set_level(TAPE_DBF_AREA, 6);
1241#endif 1241#endif
1242 DBF_EVENT(3, "tape init: ($Revision: 1.54 $)\n"); 1242 DBF_EVENT(3, "tape init\n");
1243 tape_proc_init(); 1243 tape_proc_init();
1244 tapechar_init (); 1244 tapechar_init ();
1245 tapeblock_init (); 1245 tapeblock_init ();
@@ -1263,8 +1263,7 @@ tape_exit(void)
1263 1263
1264MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and " 1264MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and "
1265 "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)"); 1265 "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)");
1266MODULE_DESCRIPTION("Linux on zSeries channel attached " 1266MODULE_DESCRIPTION("Linux on zSeries channel attached tape device driver");
1267 "tape device driver ($Revision: 1.54 $)");
1268MODULE_LICENSE("GPL"); 1267MODULE_LICENSE("GPL");
1269 1268
1270module_init(tape_init); 1269module_init(tape_init);
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c
index cd2cc28e16a7..5287631fbfc8 100644
--- a/drivers/s390/cio/airq.c
+++ b/drivers/s390/cio/airq.c
@@ -2,8 +2,6 @@
2 * drivers/s390/cio/airq.c 2 * drivers/s390/cio/airq.c
3 * S/390 common I/O routines -- support for adapter interruptions 3 * S/390 common I/O routines -- support for adapter interruptions
4 * 4 *
5 * $Revision: 1.15 $
6 *
7 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
8 * IBM Corporation 6 * IBM Corporation
9 * Author(s): Ingo Adlung (adlung@de.ibm.com) 7 * Author(s): Ingo Adlung (adlung@de.ibm.com)
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 72f27c151c09..cb8e2e672b68 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/blacklist.c 2 * drivers/s390/cio/blacklist.c
3 * S/390 common I/O routines -- blacklisting of specific devices 3 * S/390 common I/O routines -- blacklisting of specific devices
4 * $Revision: 1.42 $
5 * 4 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 6c077ad71edc..8013c8eb76fe 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/ccwgroup.c 2 * drivers/s390/cio/ccwgroup.c
3 * bus driver for ccwgroup 3 * bus driver for ccwgroup
4 * $Revision: 1.35 $
5 * 4 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 2cbb724791a8..92be75d99a56 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/chsc.c 2 * drivers/s390/cio/chsc.c
3 * S/390 common I/O routines -- channel subsystem call 3 * S/390 common I/O routines -- channel subsystem call
4 * $Revision: 1.128 $
5 * 4 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index 44e4b4bb1c5a..3e75095f35d0 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -68,6 +68,6 @@ extern void *chsc_get_chp_desc(struct subchannel*, int);
68 68
69extern int chsc_enable_facility(int); 69extern int chsc_enable_facility(int);
70 70
71#define to_channelpath(dev) container_of(dev, struct channel_path, dev) 71#define to_channelpath(device) container_of(device, struct channel_path, dev)
72 72
73#endif 73#endif
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 6223b06d27d5..cbb86fa5f293 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/cio.c 2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls 3 * S/390 common I/O routines -- low level i/o calls
4 * $Revision: 1.140 $
5 * 4 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 0b03714e696a..07ef3f640f4a 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.19 $) 2 * linux/drivers/s390/cio/cmf.c
3 * 3 *
4 * Linux on zSeries Channel Measurement Facility support 4 * Linux on zSeries Channel Measurement Facility support
5 * 5 *
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 516108779f60..1bbf231f8aaf 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/css.c 2 * drivers/s390/cio/css.c
3 * driver for channel subsystem 3 * driver for channel subsystem
4 * $Revision: 1.96 $
5 * 4 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index a67e7e60e330..062fb100d94c 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/device.c 2 * drivers/s390/cio/device.c
3 * bus driver for ccw devices 3 * bus driver for ccw devices
4 * $Revision: 1.140 $
5 * 4 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
@@ -255,7 +254,7 @@ modalias_show (struct device *dev, struct device_attribute *attr, char *buf)
255 struct ccw_device_id *id = &(cdev->id); 254 struct ccw_device_id *id = &(cdev->id);
256 int ret; 255 int ret;
257 256
258 ret = sprintf(buf, "ccw:t%04Xm%02x", 257 ret = sprintf(buf, "ccw:t%04Xm%02X",
259 id->cu_type, id->cu_model); 258 id->cu_type, id->cu_model);
260 if (id->dev_type != 0) 259 if (id->dev_type != 0)
261 ret += sprintf(buf + ret, "dt%04Xdm%02X\n", 260 ret += sprintf(buf + ret, "dt%04Xdm%02X\n",
@@ -1013,7 +1012,7 @@ ccw_device_probe_console(void)
1013 int ret; 1012 int ret;
1014 1013
1015 if (xchg(&console_cdev_in_use, 1) != 0) 1014 if (xchg(&console_cdev_in_use, 1) != 0)
1016 return NULL; 1015 return ERR_PTR(-EBUSY);
1017 sch = cio_probe_console(); 1016 sch = cio_probe_console();
1018 if (IS_ERR(sch)) { 1017 if (IS_ERR(sch)) {
1019 console_cdev_in_use = 0; 1018 console_cdev_in_use = 0;
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 8b0218949b62..3a50b1903287 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/device_ops.c 2 * drivers/s390/cio/device_ops.c
3 * 3 *
4 * $Revision: 1.61 $
5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 4 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 5 * IBM Corporation
8 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 77be2c39bfe4..45ce032772f4 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -56,8 +56,6 @@
56#include "ioasm.h" 56#include "ioasm.h"
57#include "chsc.h" 57#include "chsc.h"
58 58
59#define VERSION_QDIO_C "$Revision: 1.117 $"
60
61/****************** MODULE PARAMETER VARIABLES ********************/ 59/****************** MODULE PARAMETER VARIABLES ********************/
62MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>"); 60MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
63MODULE_DESCRIPTION("QDIO base support version 2, " \ 61MODULE_DESCRIPTION("QDIO base support version 2, " \
@@ -66,8 +64,7 @@ MODULE_LICENSE("GPL");
66 64
67/******************** HERE WE GO ***********************************/ 65/******************** HERE WE GO ***********************************/
68 66
69static const char version[] = "QDIO base support version 2 (" 67static const char version[] = "QDIO base support version 2";
70 VERSION_QDIO_C "/" VERSION_QDIO_H "/" VERSION_CIO_QDIO_H ")";
71 68
72#ifdef QDIO_PERFORMANCE_STATS 69#ifdef QDIO_PERFORMANCE_STATS
73static int proc_perf_file_registration; 70static int proc_perf_file_registration;
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index fa385e761fe1..ceb3ab31ee08 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -5,8 +5,6 @@
5 5
6#include "schid.h" 6#include "schid.h"
7 7
8#define VERSION_CIO_QDIO_H "$Revision: 1.40 $"
9
10#ifdef CONFIG_QDIO_DEBUG 8#ifdef CONFIG_QDIO_DEBUG
11#define QDIO_VERBOSE_LEVEL 9 9#define QDIO_VERBOSE_LEVEL 9
12#else /* CONFIG_QDIO_DEBUG */ 10#else /* CONFIG_QDIO_DEBUG */
diff --git a/drivers/s390/crypto/z90common.h b/drivers/s390/crypto/z90common.h
index f87c785f2039..dbbcda3c846a 100644
--- a/drivers/s390/crypto/z90common.h
+++ b/drivers/s390/crypto/z90common.h
@@ -27,8 +27,6 @@
27#ifndef _Z90COMMON_H_ 27#ifndef _Z90COMMON_H_
28#define _Z90COMMON_H_ 28#define _Z90COMMON_H_
29 29
30#define VERSION_Z90COMMON_H "$Revision: 1.17 $"
31
32 30
33#define RESPBUFFSIZE 256 31#define RESPBUFFSIZE 256
34#define PCI_FUNC_KEY_DECRYPT 0x5044 32#define PCI_FUNC_KEY_DECRYPT 0x5044
diff --git a/drivers/s390/crypto/z90crypt.h b/drivers/s390/crypto/z90crypt.h
index 3a18443fdfa7..5e6b1f535f62 100644
--- a/drivers/s390/crypto/z90crypt.h
+++ b/drivers/s390/crypto/z90crypt.h
@@ -29,8 +29,6 @@
29 29
30#include <linux/ioctl.h> 30#include <linux/ioctl.h>
31 31
32#define VERSION_Z90CRYPT_H "$Revision: 1.2.2.4 $"
33
34#define z90crypt_VERSION 1 32#define z90crypt_VERSION 1
35#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards 33#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
36#define z90crypt_VARIANT 3 // 3 = CEX2A support 34#define z90crypt_VARIANT 3 // 3 = CEX2A support
diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c
index d7f7494a0cbe..4141919da805 100644
--- a/drivers/s390/crypto/z90hardware.c
+++ b/drivers/s390/crypto/z90hardware.c
@@ -32,12 +32,6 @@
32#include "z90crypt.h" 32#include "z90crypt.h"
33#include "z90common.h" 33#include "z90common.h"
34 34
35#define VERSION_Z90HARDWARE_C "$Revision: 1.34 $"
36
37char z90hardware_version[] __initdata =
38 "z90hardware.o (" VERSION_Z90HARDWARE_C "/"
39 VERSION_Z90COMMON_H "/" VERSION_Z90CRYPT_H ")";
40
41struct cca_token_hdr { 35struct cca_token_hdr {
42 unsigned char token_identifier; 36 unsigned char token_identifier;
43 unsigned char version; 37 unsigned char version;
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 2f54d033d7cf..7d6f19030ef9 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -38,14 +38,6 @@
38#include "z90crypt.h" 38#include "z90crypt.h"
39#include "z90common.h" 39#include "z90common.h"
40 40
41#define VERSION_Z90MAIN_C "$Revision: 1.62 $"
42
43static char z90main_version[] __initdata =
44 "z90main.o (" VERSION_Z90MAIN_C "/"
45 VERSION_Z90COMMON_H "/" VERSION_Z90CRYPT_H ")";
46
47extern char z90hardware_version[];
48
49/** 41/**
50 * Defaults that may be modified. 42 * Defaults that may be modified.
51 */ 43 */
@@ -594,8 +586,6 @@ z90crypt_init_module(void)
594 PRINTKN("Version %d.%d.%d loaded, built on %s %s\n", 586 PRINTKN("Version %d.%d.%d loaded, built on %s %s\n",
595 z90crypt_VERSION, z90crypt_RELEASE, z90crypt_VARIANT, 587 z90crypt_VERSION, z90crypt_RELEASE, z90crypt_VARIANT,
596 __DATE__, __TIME__); 588 __DATE__, __TIME__);
597 PRINTKN("%s\n", z90main_version);
598 PRINTKN("%s\n", z90hardware_version);
599 PDEBUG("create_z90crypt (domain index %d) successful.\n", 589 PDEBUG("create_z90crypt (domain index %d) successful.\n",
600 domain); 590 domain);
601 } else 591 } else
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index e70af7f39946..a86436a7a606 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -2,8 +2,6 @@
2 * drivers/s390/net/claw.c 2 * drivers/s390/net/claw.c
3 * ESCON CLAW network driver 3 * ESCON CLAW network driver
4 * 4 *
5 * $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $
6 *
7 * Linux for zSeries version 5 * Linux for zSeries version
8 * Copyright (C) 2002,2005 IBM Corporation 6 * Copyright (C) 2002,2005 IBM Corporation
9 * Author(s) Original code written by: 7 * Author(s) Original code written by:
@@ -4391,14 +4389,7 @@ static int __init
4391claw_init(void) 4389claw_init(void)
4392{ 4390{
4393 int ret = 0; 4391 int ret = 0;
4394 printk(KERN_INFO "claw: starting driver " 4392 printk(KERN_INFO "claw: starting driver\n");
4395#ifdef MODULE
4396 "module "
4397#else
4398 "compiled into kernel "
4399#endif
4400 " $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $ \n");
4401
4402 4393
4403#ifdef FUNCTRACE 4394#ifdef FUNCTRACE
4404 printk(KERN_INFO "claw: %s() enter \n",__FUNCTION__); 4395 printk(KERN_INFO "claw: %s() enter \n",__FUNCTION__);
diff --git a/drivers/s390/net/claw.h b/drivers/s390/net/claw.h
index 3df71970f601..969be465309c 100644
--- a/drivers/s390/net/claw.h
+++ b/drivers/s390/net/claw.h
@@ -2,7 +2,7 @@
2* Define constants * 2* Define constants *
3* * 3* *
4********************************************************/ 4********************************************************/
5#define VERSION_CLAW_H "$Revision: 1.6 $" 5
6/*-----------------------------------------------------* 6/*-----------------------------------------------------*
7* CCW command codes for CLAW protocol * 7* CCW command codes for CLAW protocol *
8*------------------------------------------------------*/ 8*------------------------------------------------------*/
diff --git a/drivers/s390/net/ctcdbug.c b/drivers/s390/net/ctcdbug.c
index 0e2a8bb93032..e6e72deb36b5 100644
--- a/drivers/s390/net/ctcdbug.c
+++ b/drivers/s390/net/ctcdbug.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/ctcdbug.c ($Revision: 1.6 $) 3 * linux/drivers/s390/net/ctcdbug.c
4 * 4 *
5 * CTC / ESCON network driver - s390 dbf exploit. 5 * CTC / ESCON network driver - s390 dbf exploit.
6 * 6 *
@@ -9,8 +9,6 @@
9 * Author(s): Original Code written by 9 * Author(s): Original Code written by
10 * Peter Tiedemann (ptiedem@de.ibm.com) 10 * Peter Tiedemann (ptiedem@de.ibm.com)
11 * 11 *
12 * $Revision: 1.6 $ $Date: 2005/05/11 08:10:17 $
13 *
14 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option) 14 * the Free Software Foundation; either version 2, or (at your option)
@@ -80,4 +78,3 @@ ctc_register_dbf_views(void)
80 return 0; 78 return 0;
81} 79}
82 80
83
diff --git a/drivers/s390/net/ctcdbug.h b/drivers/s390/net/ctcdbug.h
index 7d6afa1627c3..413925ee23d1 100644
--- a/drivers/s390/net/ctcdbug.h
+++ b/drivers/s390/net/ctcdbug.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.6 $) 3 * linux/drivers/s390/net/ctcdbug.h
4 * 4 *
5 * CTC / ESCON network driver - s390 dbf exploit. 5 * CTC / ESCON network driver - s390 dbf exploit.
6 * 6 *
@@ -9,8 +9,6 @@
9 * Author(s): Original Code written by 9 * Author(s): Original Code written by
10 * Peter Tiedemann (ptiedem@de.ibm.com) 10 * Peter Tiedemann (ptiedem@de.ibm.com)
11 * 11 *
12 * $Revision: 1.6 $ $Date: 2005/05/11 08:10:17 $
13 *
14 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option) 14 * the Free Software Foundation; either version 2, or (at your option)
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index 1901feef07d9..af9f212314b3 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctcmain.c,v 1.79 2006/01/11 11:32:18 cohuck Exp $
3 *
4 * CTC / ESCON network driver 2 * CTC / ESCON network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -37,8 +35,6 @@
37 * along with this program; if not, write to the Free Software 35 * along with this program; if not, write to the Free Software
38 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 36 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 * 37 *
40 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.79 $
41 *
42 */ 38 */
43#undef DEBUG 39#undef DEBUG
44#include <linux/module.h> 40#include <linux/module.h>
@@ -248,22 +244,11 @@ static void
248print_banner(void) 244print_banner(void)
249{ 245{
250 static int printed = 0; 246 static int printed = 0;
251 char vbuf[] = "$Revision: 1.79 $";
252 char *version = vbuf;
253 247
254 if (printed) 248 if (printed)
255 return; 249 return;
256 if ((version = strchr(version, ':'))) { 250
257 char *p = strchr(version + 1, '$'); 251 printk(KERN_INFO "CTC driver initialized\n");
258 if (p)
259 *p = '\0';
260 } else
261 version = " ??? ";
262 printk(KERN_INFO "CTC driver Version%s"
263#ifdef DEBUG
264 " (DEBUG-VERSION, " __DATE__ __TIME__ ")"
265#endif
266 " initialized\n", version);
267 printed = 1; 252 printed = 1;
268} 253}
269 254
diff --git a/drivers/s390/net/ctcmain.h b/drivers/s390/net/ctcmain.h
index ba3605f16335..d2e835c0c134 100644
--- a/drivers/s390/net/ctcmain.h
+++ b/drivers/s390/net/ctcmain.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctcmain.h,v 1.4 2005/03/24 09:04:17 mschwide Exp $
3 *
4 * CTC / ESCON network driver 2 * CTC / ESCON network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -29,8 +27,6 @@
29 * along with this program; if not, write to the Free Software 27 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 29 *
32 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.4 $
33 *
34 */ 30 */
35 31
36#ifndef _CTCMAIN_H_ 32#ifndef _CTCMAIN_H_
diff --git a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
index 93d1725eb79b..5cdcdbf92962 100644
--- a/drivers/s390/net/ctctty.c
+++ b/drivers/s390/net/ctctty.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctctty.c,v 1.29 2005/04/05 08:50:44 mschwide Exp $
3 *
4 * CTC / ESCON network driver, tty interface. 2 * CTC / ESCON network driver, tty interface.
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
diff --git a/drivers/s390/net/ctctty.h b/drivers/s390/net/ctctty.h
index 84b2f8f23ab3..7254dc006311 100644
--- a/drivers/s390/net/ctctty.h
+++ b/drivers/s390/net/ctctty.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctctty.h,v 1.4 2003/09/18 08:01:10 mschwide Exp $
3 *
4 * CTC / ESCON network driver, tty interface. 2 * CTC / ESCON network driver, tty interface.
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
index 2014fb7a4881..b12533104c1f 100644
--- a/drivers/s390/net/cu3088.c
+++ b/drivers/s390/net/cu3088.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: cu3088.c,v 1.38 2006/01/12 14:33:09 cohuck Exp $
3 *
4 * CTC / LCS ccw_device driver 2 * CTC / LCS ccw_device driver
5 * 3 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index 24029bd9c7d0..6caf5fa6a3b5 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -1,6 +1,4 @@
1/** 1/**
2 * $Id: fsm.c,v 1.6 2003/10/15 11:37:29 mschwide Exp $
3 *
4 * A generic FSM based on fsm used in isdn4linux 2 * A generic FSM based on fsm used in isdn4linux
5 * 3 *
6 */ 4 */
diff --git a/drivers/s390/net/fsm.h b/drivers/s390/net/fsm.h
index 5b98253be7aa..af679c10f1bd 100644
--- a/drivers/s390/net/fsm.h
+++ b/drivers/s390/net/fsm.h
@@ -1,5 +1,3 @@
1/* $Id: fsm.h,v 1.1.1.1 2002/03/13 19:33:09 mschwide Exp $
2 */
3#ifndef _FSM_H_ 1#ifndef _FSM_H_
4#define _FSM_H_ 2#define _FSM_H_
5 3
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index ea8177392564..760e77ec5a11 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: iucv.c,v 1.47 2005/11/21 11:35:22 mschwide Exp $
3 *
4 * IUCV network driver 2 * IUCV network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -29,8 +27,6 @@
29 * along with this program; if not, write to the Free Software 27 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 29 *
32 * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.47 $
33 *
34 */ 30 */
35 31
36/* #define DEBUG */ 32/* #define DEBUG */
@@ -355,17 +351,7 @@ do { \
355static void 351static void
356iucv_banner(void) 352iucv_banner(void)
357{ 353{
358 char vbuf[] = "$Revision: 1.47 $"; 354 printk(KERN_INFO "IUCV lowlevel driver initialized\n");
359 char *version = vbuf;
360
361 if ((version = strchr(version, ':'))) {
362 char *p = strchr(version + 1, '$');
363 if (p)
364 *p = '\0';
365 } else
366 version = " ??? ";
367 printk(KERN_INFO
368 "IUCV lowlevel driver Version%s initialized\n", version);
369} 355}
370 356
371/** 357/**
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index da8c515743e8..6229ba4995ad 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -11,8 +11,6 @@
11 * Frank Pavlic (fpavlic@de.ibm.com) and 11 * Frank Pavlic (fpavlic@de.ibm.com) and
12 * Martin Schwidefsky <schwidefsky@de.ibm.com> 12 * Martin Schwidefsky <schwidefsky@de.ibm.com>
13 * 13 *
14 * $Revision: 1.99 $ $Date: 2005/05/11 08:10:17 $
15 *
16 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option) 16 * the Free Software Foundation; either version 2, or (at your option)
@@ -59,9 +57,8 @@
59/** 57/**
60 * initialization string for output 58 * initialization string for output
61 */ 59 */
62#define VERSION_LCS_C "$Revision: 1.99 $"
63 60
64static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")"; 61static char version[] __initdata = "LCS driver";
65static char debug_buffer[255]; 62static char debug_buffer[255];
66 63
67/** 64/**
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index a7f348ef1b08..08e60ad43916 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -6,8 +6,6 @@
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7#include <asm/ccwdev.h> 7#include <asm/ccwdev.h>
8 8
9#define VERSION_LCS_H "$Revision: 1.19 $"
10
11#define LCS_DBF_TEXT(level, name, text) \ 9#define LCS_DBF_TEXT(level, name, text) \
12 do { \ 10 do { \
13 debug_text_event(lcs_dbf_##name, level, text); \ 11 debug_text_event(lcs_dbf_##name, level, text); \
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index ac4c4b83fe17..71d3853e8682 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: netiucv.c,v 1.69 2006/01/12 14:33:09 cohuck Exp $
3 *
4 * IUCV network driver 2 * IUCV network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -31,8 +29,6 @@
31 * along with this program; if not, write to the Free Software 29 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 * 31 *
34 * RELEASE-TAG: IUCV network driver $Revision: 1.69 $
35 *
36 */ 32 */
37 33
38#undef DEBUG 34#undef DEBUG
@@ -2077,16 +2073,7 @@ DRIVER_ATTR(remove, 0200, NULL, remove_write);
2077static void 2073static void
2078netiucv_banner(void) 2074netiucv_banner(void)
2079{ 2075{
2080 char vbuf[] = "$Revision: 1.69 $"; 2076 PRINT_INFO("NETIUCV driver initialized\n");
2081 char *version = vbuf;
2082
2083 if ((version = strchr(version, ':'))) {
2084 char *p = strchr(version + 1, '$');
2085 if (p)
2086 *p = '\0';
2087 } else
2088 version = " ??? ";
2089 PRINT_INFO("NETIUCV driver Version%s initialized\n", version);
2090} 2077}
2091 2078
2092static void __exit 2079static void __exit
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index d238c7ed103b..9a064d4727ad 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -25,8 +25,6 @@
25 25
26#include "qeth_mpc.h" 26#include "qeth_mpc.h"
27 27
28#define VERSION_QETH_H "$Revision: 1.152 $"
29
30#ifdef CONFIG_QETH_IPV6 28#ifdef CONFIG_QETH_IPV6
31#define QETH_VERSION_IPV6 ":IPv6" 29#define QETH_VERSION_IPV6 ":IPv6"
32#else 30#else
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index f94f1f25eec6..b02313127780 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 * linux/drivers/s390/net/qeth_eddp.c
3 * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.13 $)
4 * 3 *
5 * Enhanced Device Driver Packing (EDDP) support for the qeth driver. 4 * Enhanced Device Driver Packing (EDDP) support for the qeth driver.
6 * 5 *
@@ -8,8 +7,6 @@
8 * 7 *
9 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 8 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
10 * 9 *
11 * $Revision: 1.13 $ $Date: 2005/05/04 20:19:18 $
12 *
13 */ 10 */
14#include <linux/config.h> 11#include <linux/config.h>
15#include <linux/errno.h> 12#include <linux/errno.h>
diff --git a/drivers/s390/net/qeth_eddp.h b/drivers/s390/net/qeth_eddp.h
index e1b51860bc57..cae9ba265056 100644
--- a/drivers/s390/net/qeth_eddp.h
+++ b/drivers/s390/net/qeth_eddp.h
@@ -1,14 +1,12 @@
1/* 1/*
2 * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.5 $) 2 * linux/drivers/s390/net/qeth_eddp.h
3 * 3 *
4 * Header file for qeth enhanced device driver pakcing. 4 * Header file for qeth enhanced device driver packing.
5 * 5 *
6 * Copyright 2004 IBM Corporation 6 * Copyright 2004 IBM Corporation
7 * 7 *
8 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 8 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
9 * 9 *
10 * $Revision: 1.5 $ $Date: 2005/03/24 09:04:18 $
11 *
12 */ 10 */
13#ifndef __QETH_EDDP_H__ 11#ifndef __QETH_EDDP_H__
14#define __QETH_EDDP_H__ 12#define __QETH_EDDP_H__
diff --git a/drivers/s390/net/qeth_fs.h b/drivers/s390/net/qeth_fs.h
index c0b4c8d82c45..e422b41c656e 100644
--- a/drivers/s390/net/qeth_fs.h
+++ b/drivers/s390/net/qeth_fs.h
@@ -12,11 +12,6 @@
12#ifndef __QETH_FS_H__ 12#ifndef __QETH_FS_H__
13#define __QETH_FS_H__ 13#define __QETH_FS_H__
14 14
15#define VERSION_QETH_FS_H "$Revision: 1.10 $"
16
17extern const char *VERSION_QETH_PROC_C;
18extern const char *VERSION_QETH_SYS_C;
19
20#ifdef CONFIG_PROC_FS 15#ifdef CONFIG_PROC_FS
21extern int 16extern int
22qeth_create_procfs_entries(void); 17qeth_create_procfs_entries(void);
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 97f927c01a82..410abeada6c4 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 * linux/drivers/s390/net/qeth_main.c
3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.251 $)
4 * 3 *
5 * Linux on zSeries OSA Express and HiperSockets support 4 * Linux on zSeries OSA Express and HiperSockets support
6 * 5 *
@@ -12,8 +11,6 @@
12 * Frank Pavlic (fpavlic@de.ibm.com) and 11 * Frank Pavlic (fpavlic@de.ibm.com) and
13 * Thomas Spatzier <tspat@de.ibm.com> 12 * Thomas Spatzier <tspat@de.ibm.com>
14 * 13 *
15 * $Revision: 1.251 $ $Date: 2005/05/04 20:19:18 $
16 *
17 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2, or (at your option) 16 * the Free Software Foundation; either version 2, or (at your option)
@@ -73,7 +70,6 @@
73#include "qeth_eddp.h" 70#include "qeth_eddp.h"
74#include "qeth_tso.h" 71#include "qeth_tso.h"
75 72
76#define VERSION_QETH_C "$Revision: 1.251 $"
77static const char *version = "qeth S/390 OSA-Express driver"; 73static const char *version = "qeth S/390 OSA-Express driver";
78 74
79/** 75/**
@@ -8626,12 +8622,7 @@ qeth_init(void)
8626{ 8622{
8627 int rc=0; 8623 int rc=0;
8628 8624
8629 PRINT_INFO("loading %s (%s/%s/%s/%s/%s/%s/%s %s %s)\n", 8625 PRINT_INFO("loading %s\n", version);
8630 version, VERSION_QETH_C, VERSION_QETH_H,
8631 VERSION_QETH_MPC_H, VERSION_QETH_MPC_C,
8632 VERSION_QETH_FS_H, VERSION_QETH_PROC_C,
8633 VERSION_QETH_SYS_C, QETH_VERSION_IPV6,
8634 QETH_VERSION_VLAN);
8635 8626
8636 INIT_LIST_HEAD(&qeth_card_list.list); 8627 INIT_LIST_HEAD(&qeth_card_list.list);
8637 INIT_LIST_HEAD(&qeth_notify_list); 8628 INIT_LIST_HEAD(&qeth_notify_list);
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c
index 5f8754addc14..77c83209d70e 100644
--- a/drivers/s390/net/qeth_mpc.c
+++ b/drivers/s390/net/qeth_mpc.c
@@ -11,8 +11,6 @@
11#include <asm/cio.h> 11#include <asm/cio.h>
12#include "qeth_mpc.h" 12#include "qeth_mpc.h"
13 13
14const char *VERSION_QETH_MPC_C = "$Revision: 1.13 $";
15
16unsigned char IDX_ACTIVATE_READ[]={ 14unsigned char IDX_ACTIVATE_READ[]={
17 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00, 15 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00,
18 0x19,0x01,0x01,0x80, 0x00,0x00,0x00,0x00, 16 0x19,0x01,0x01,0x80, 0x00,0x00,0x00,0x00,
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
index 864cec5f6c62..011c41041029 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -14,10 +14,6 @@
14 14
15#include <asm/qeth.h> 15#include <asm/qeth.h>
16 16
17#define VERSION_QETH_MPC_H "$Revision: 1.46 $"
18
19extern const char *VERSION_QETH_MPC_C;
20
21#define IPA_PDU_HEADER_SIZE 0x40 17#define IPA_PDU_HEADER_SIZE 0x40
22#define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e) 18#define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e)
23#define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26) 19#define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26)
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index 7bf35098831e..3c6339df879d 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_fs.c ($Revision: 1.16 $) 3 * linux/drivers/s390/net/qeth_fs.c
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to procfs. 6 * This file contains code related to procfs.
@@ -21,8 +21,6 @@
21#include "qeth_mpc.h" 21#include "qeth_mpc.h"
22#include "qeth_fs.h" 22#include "qeth_fs.h"
23 23
24const char *VERSION_QETH_PROC_C = "$Revision: 1.16 $";
25
26/***** /proc/qeth *****/ 24/***** /proc/qeth *****/
27#define QETH_PROCFILE_NAME "qeth" 25#define QETH_PROCFILE_NAME "qeth"
28static struct proc_dir_entry *qeth_procfile; 26static struct proc_dir_entry *qeth_procfile;
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index 0ea185f70f75..c1831f572585 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.60 $) 3 * linux/drivers/s390/net/qeth_sys.c
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to sysfs. 6 * This file contains code related to sysfs.
@@ -20,8 +20,6 @@
20#include "qeth_mpc.h" 20#include "qeth_mpc.h"
21#include "qeth_fs.h" 21#include "qeth_fs.h"
22 22
23const char *VERSION_QETH_SYS_C = "$Revision: 1.60 $";
24
25/*****************************************************************************/ 23/*****************************************************************************/
26/* */ 24/* */
27/* /sys-fs stuff UNDER DEVELOPMENT !!! */ 25/* /sys-fs stuff UNDER DEVELOPMENT !!! */
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
index 3c50b6f24f51..1286ddea450b 100644
--- a/drivers/s390/net/qeth_tso.h
+++ b/drivers/s390/net/qeth_tso.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.8 $) 2 * linux/drivers/s390/net/qeth_tso.h
3 * 3 *
4 * Header file for qeth TCP Segmentation Offload support. 4 * Header file for qeth TCP Segmentation Offload support.
5 * 5 *
@@ -7,8 +7,6 @@
7 * 7 *
8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com> 8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com>
9 * 9 *
10 * $Revision: 1.8 $ $Date: 2005/05/04 20:19:18 $
11 *
12 */ 10 */
13#ifndef __QETH_TSO_H__ 11#ifndef __QETH_TSO_H__
14#define __QETH_TSO_H__ 12#define __QETH_TSO_H__
diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c
index 206518c7d332..e3f647169827 100644
--- a/drivers/s390/s390_rdev.c
+++ b/drivers/s390/s390_rdev.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/s390_rdev.c 2 * drivers/s390/s390_rdev.c
3 * s390 root device 3 * s390 root device
4 * $Revision: 1.4 $
5 * 4 *
6 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/s390mach.h b/drivers/s390/s390mach.h
index d9ea7ed2e46e..7abb42a09ae2 100644
--- a/drivers/s390/s390mach.h
+++ b/drivers/s390/s390mach.h
@@ -90,15 +90,16 @@ struct crw {
90 90
91static inline int stcrw(struct crw *pcrw ) 91static inline int stcrw(struct crw *pcrw )
92{ 92{
93 int ccode; 93 int ccode;
94 94
95 __asm__ __volatile__( 95 __asm__ __volatile__(
96 "STCRW 0(%1)\n\t" 96 "stcrw 0(%2)\n\t"
97 "IPM %0\n\t" 97 "ipm %0\n\t"
98 "SRL %0,28\n\t" 98 "srl %0,28\n\t"
99 : "=d" (ccode) : "a" (pcrw) 99 : "=d" (ccode), "=m" (*pcrw)
100 : "cc", "1" ); 100 : "a" (pcrw)
101 return ccode; 101 : "cc" );
102 return ccode;
102} 103}
103 104
104#endif /* __s390mach */ 105#endif /* __s390mach */
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 167fef39d8a7..95b92f317b6f 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -29,8 +29,6 @@
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 30 */
31 31
32#define ZFCP_AUX_REVISION "$Revision: 1.145 $"
33
34#include "zfcp_ext.h" 32#include "zfcp_ext.h"
35 33
36/* accumulated log level (module parameter) */ 34/* accumulated log level (module parameter) */
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index 0fc46381fc22..241136d0c6eb 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -27,8 +27,6 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#define ZFCP_CCW_C_REVISION "$Revision: 1.58 $"
31
32#include "zfcp_ext.h" 30#include "zfcp_ext.h"
33 31
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 95599719f8ab..4d7d47cf2394 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -23,8 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#define ZFCP_DBF_REVISION "$Revision$"
27
28#include <asm/debug.h> 26#include <asm/debug.h>
29#include <linux/ctype.h> 27#include <linux/ctype.h>
30#include "zfcp_ext.h" 28#include "zfcp_ext.h"
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 9bb511083a26..e260d19fa717 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -34,8 +34,6 @@
34#ifndef ZFCP_DEF_H 34#ifndef ZFCP_DEF_H
35#define ZFCP_DEF_H 35#define ZFCP_DEF_H
36 36
37#define ZFCP_DEF_REVISION "$Revision: 1.111 $"
38
39/*************************** INCLUDES *****************************************/ 37/*************************** INCLUDES *****************************************/
40 38
41#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index c065cb836c97..da947e662031 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -31,8 +31,6 @@
31 31
32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_ERP 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_ERP
33 33
34#define ZFCP_ERP_REVISION "$Revision: 1.86 $"
35
36#include "zfcp_ext.h" 34#include "zfcp_ext.h"
37 35
38static int zfcp_erp_adisc(struct zfcp_port *); 36static int zfcp_erp_adisc(struct zfcp_port *);
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index c3782261cb5c..c1ba7cf1b496 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -32,8 +32,6 @@
32#ifndef ZFCP_EXT_H 32#ifndef ZFCP_EXT_H
33#define ZFCP_EXT_H 33#define ZFCP_EXT_H
34 34
35#define ZFCP_EXT_REVISION "$Revision: 1.62 $"
36
37#include "zfcp_def.h" 35#include "zfcp_def.h"
38 36
39extern struct zfcp_data zfcp_data; 37extern struct zfcp_data zfcp_data;
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index cbfab09899c8..9f0cb3d820c0 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -30,8 +30,6 @@
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */ 31 */
32 32
33#define ZFCP_FSF_C_REVISION "$Revision: 1.92 $"
34
35#include "zfcp_ext.h" 33#include "zfcp_ext.h"
36 34
37static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *); 35static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *);
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index d719f66a29a4..1c3275163c91 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -29,8 +29,6 @@
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 30 */
31 31
32#define ZFCP_QDIO_C_REVISION "$Revision: 1.20 $"
33
34#include "zfcp_ext.h" 32#include "zfcp_ext.h"
35 33
36static inline void zfcp_qdio_sbal_limit(struct zfcp_fsf_req *, int); 34static inline void zfcp_qdio_sbal_limit(struct zfcp_fsf_req *, int);
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 3c2cbcccbf54..e0803757c0fa 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -31,8 +31,6 @@
31 31
32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_SCSI 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_SCSI
33 33
34#define ZFCP_SCSI_REVISION "$Revision: 1.74 $"
35
36#include "zfcp_ext.h" 34#include "zfcp_ext.h"
37 35
38static void zfcp_scsi_slave_destroy(struct scsi_device *sdp); 36static void zfcp_scsi_slave_destroy(struct scsi_device *sdp);
diff --git a/drivers/s390/scsi/zfcp_sysfs_adapter.c b/drivers/s390/scsi/zfcp_sysfs_adapter.c
index 9f262250043a..dfc07370f412 100644
--- a/drivers/s390/scsi/zfcp_sysfs_adapter.c
+++ b/drivers/s390/scsi/zfcp_sysfs_adapter.c
@@ -27,8 +27,6 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#define ZFCP_SYSFS_ADAPTER_C_REVISION "$Revision: 1.38 $"
31
32#include "zfcp_ext.h" 30#include "zfcp_ext.h"
33 31
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_sysfs_driver.c b/drivers/s390/scsi/zfcp_sysfs_driver.c
index 77a5e2dcc0ff..6622d55e0a45 100644
--- a/drivers/s390/scsi/zfcp_sysfs_driver.c
+++ b/drivers/s390/scsi/zfcp_sysfs_driver.c
@@ -27,8 +27,6 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#define ZFCP_SYSFS_DRIVER_C_REVISION "$Revision: 1.17 $"
31
32#include "zfcp_ext.h" 30#include "zfcp_ext.h"
33 31
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_sysfs_port.c b/drivers/s390/scsi/zfcp_sysfs_port.c
index 3924eb38805c..f401d42db21c 100644
--- a/drivers/s390/scsi/zfcp_sysfs_port.c
+++ b/drivers/s390/scsi/zfcp_sysfs_port.c
@@ -28,8 +28,6 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.47 $"
32
33#include "zfcp_ext.h" 31#include "zfcp_ext.h"
34 32
35#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 33#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_sysfs_unit.c b/drivers/s390/scsi/zfcp_sysfs_unit.c
index 2f50815f65c7..ad5dfb889bee 100644
--- a/drivers/s390/scsi/zfcp_sysfs_unit.c
+++ b/drivers/s390/scsi/zfcp_sysfs_unit.c
@@ -28,8 +28,6 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.30 $"
32
33#include "zfcp_ext.h" 31#include "zfcp_ext.h"
34 32
35#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 33#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 3c688ef54660..0cf0e4c7ac0c 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -751,9 +751,8 @@ static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
751 idescsi_add_settings(drive); 751 idescsi_add_settings(drive);
752} 752}
753 753
754static int ide_scsi_remove(struct device *dev) 754static void ide_scsi_remove(ide_drive_t *drive)
755{ 755{
756 ide_drive_t *drive = to_ide_device(dev);
757 struct Scsi_Host *scsihost = drive->driver_data; 756 struct Scsi_Host *scsihost = drive->driver_data;
758 struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost); 757 struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost);
759 struct gendisk *g = scsi->disk; 758 struct gendisk *g = scsi->disk;
@@ -768,11 +767,9 @@ static int ide_scsi_remove(struct device *dev)
768 767
769 scsi_remove_host(scsihost); 768 scsi_remove_host(scsihost);
770 ide_scsi_put(scsi); 769 ide_scsi_put(scsi);
771
772 return 0;
773} 770}
774 771
775static int ide_scsi_probe(struct device *); 772static int ide_scsi_probe(ide_drive_t *);
776 773
777#ifdef CONFIG_PROC_FS 774#ifdef CONFIG_PROC_FS
778static ide_proc_entry_t idescsi_proc[] = { 775static ide_proc_entry_t idescsi_proc[] = {
@@ -788,9 +785,9 @@ static ide_driver_t idescsi_driver = {
788 .owner = THIS_MODULE, 785 .owner = THIS_MODULE,
789 .name = "ide-scsi", 786 .name = "ide-scsi",
790 .bus = &ide_bus_type, 787 .bus = &ide_bus_type,
791 .probe = ide_scsi_probe,
792 .remove = ide_scsi_remove,
793 }, 788 },
789 .probe = ide_scsi_probe,
790 .remove = ide_scsi_remove,
794 .version = IDESCSI_VERSION, 791 .version = IDESCSI_VERSION,
795 .media = ide_scsi, 792 .media = ide_scsi,
796 .supports_dsc_overlap = 0, 793 .supports_dsc_overlap = 0,
@@ -1119,9 +1116,8 @@ static struct scsi_host_template idescsi_template = {
1119 .proc_name = "ide-scsi", 1116 .proc_name = "ide-scsi",
1120}; 1117};
1121 1118
1122static int ide_scsi_probe(struct device *dev) 1119static int ide_scsi_probe(ide_drive_t *drive)
1123{ 1120{
1124 ide_drive_t *drive = to_ide_device(dev);
1125 idescsi_scsi_t *idescsi; 1121 idescsi_scsi_t *idescsi;
1126 struct Scsi_Host *host; 1122 struct Scsi_Host *host;
1127 struct gendisk *g; 1123 struct gendisk *g;
diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c
index a802bdce6e5d..809f89ab965c 100644
--- a/drivers/serial/8250_acpi.c
+++ b/drivers/serial/8250_acpi.c
@@ -27,7 +27,7 @@ struct serial_private {
27static acpi_status acpi_serial_mmio(struct uart_port *port, 27static acpi_status acpi_serial_mmio(struct uart_port *port,
28 struct acpi_resource_address64 *addr) 28 struct acpi_resource_address64 *addr)
29{ 29{
30 port->mapbase = addr->min_address_range; 30 port->mapbase = addr->minimum;
31 port->iotype = UPIO_MEM; 31 port->iotype = UPIO_MEM;
32 port->flags |= UPF_IOREMAP; 32 port->flags |= UPF_IOREMAP;
33 return AE_OK; 33 return AE_OK;
@@ -36,8 +36,8 @@ static acpi_status acpi_serial_mmio(struct uart_port *port,
36static acpi_status acpi_serial_port(struct uart_port *port, 36static acpi_status acpi_serial_port(struct uart_port *port,
37 struct acpi_resource_io *io) 37 struct acpi_resource_io *io)
38{ 38{
39 if (io->range_length) { 39 if (io->address_length) {
40 port->iobase = io->min_base_address; 40 port->iobase = io->minimum;
41 port->iotype = UPIO_PORT; 41 port->iotype = UPIO_PORT;
42 } else 42 } else
43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); 43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__);
@@ -45,13 +45,13 @@ static acpi_status acpi_serial_port(struct uart_port *port,
45} 45}
46 46
47static acpi_status acpi_serial_ext_irq(struct uart_port *port, 47static acpi_status acpi_serial_ext_irq(struct uart_port *port,
48 struct acpi_resource_ext_irq *ext_irq) 48 struct acpi_resource_extended_irq *ext_irq)
49{ 49{
50 int rc; 50 int rc;
51 51
52 if (ext_irq->number_of_interrupts > 0) { 52 if (ext_irq->interrupt_count > 0) {
53 rc = acpi_register_gsi(ext_irq->interrupts[0], 53 rc = acpi_register_gsi(ext_irq->interrupts[0],
54 ext_irq->edge_level, ext_irq->active_high_low); 54 ext_irq->triggering, ext_irq->polarity);
55 if (rc < 0) 55 if (rc < 0)
56 return AE_ERROR; 56 return AE_ERROR;
57 port->irq = rc; 57 port->irq = rc;
@@ -64,9 +64,9 @@ static acpi_status acpi_serial_irq(struct uart_port *port,
64{ 64{
65 int rc; 65 int rc;
66 66
67 if (irq->number_of_interrupts > 0) { 67 if (irq->interrupt_count > 0) {
68 rc = acpi_register_gsi(irq->interrupts[0], 68 rc = acpi_register_gsi(irq->interrupts[0],
69 irq->edge_level, irq->active_high_low); 69 irq->triggering, irq->polarity);
70 if (rc < 0) 70 if (rc < 0)
71 return AE_ERROR; 71 return AE_ERROR;
72 port->irq = rc; 72 port->irq = rc;
@@ -83,11 +83,11 @@ static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data)
83 status = acpi_resource_to_address64(res, &addr); 83 status = acpi_resource_to_address64(res, &addr);
84 if (ACPI_SUCCESS(status)) 84 if (ACPI_SUCCESS(status))
85 return acpi_serial_mmio(port, &addr); 85 return acpi_serial_mmio(port, &addr);
86 else if (res->id == ACPI_RSTYPE_IO) 86 else if (res->type == ACPI_RESOURCE_TYPE_IO)
87 return acpi_serial_port(port, &res->data.io); 87 return acpi_serial_port(port, &res->data.io);
88 else if (res->id == ACPI_RSTYPE_EXT_IRQ) 88 else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
89 return acpi_serial_ext_irq(port, &res->data.extended_irq); 89 return acpi_serial_ext_irq(port, &res->data.extended_irq);
90 else if (res->id == ACPI_RSTYPE_IRQ) 90 else if (res->type == ACPI_RESOURCE_TYPE_IRQ)
91 return acpi_serial_irq(port, &res->data.irq); 91 return acpi_serial_irq(port, &res->data.irq);
92 return AE_OK; 92 return AE_OK;
93} 93}
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 0d38f0f2ae29..ee4265d7a8c9 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -892,20 +892,20 @@ config SERIAL_VR41XX_CONSOLE
892 a console on a serial port, say Y. Otherwise, say N. 892 a console on a serial port, say Y. Otherwise, say N.
893 893
894config SERIAL_JSM 894config SERIAL_JSM
895 tristate "Digi International NEO PCI Support" 895 tristate "Digi International NEO PCI Support"
896 depends on PCI && BROKEN 896 depends on PCI
897 select SERIAL_CORE 897 select SERIAL_CORE
898 help 898 help
899 This is a driver for Digi International's Neo series 899 This is a driver for Digi International's Neo series
900 of cards which provide multiple serial ports. You would need 900 of cards which provide multiple serial ports. You would need
901 something like this to connect more than two modems to your Linux 901 something like this to connect more than two modems to your Linux
902 box, for instance in order to become a dial-in server. This driver 902 box, for instance in order to become a dial-in server. This driver
903 supports PCI boards only. 903 supports PCI boards only.
904 If you have a card like this, say Y here and read the file 904 If you have a card like this, say Y here and read the file
905 <file:Documentation/jsm.txt>. 905 <file:Documentation/jsm.txt>.
906 906
907 To compile this driver as a module, choose M here: the 907 To compile this driver as a module, choose M here: the
908 module will be called jsm. 908 module will be called jsm.
909 909
910config SERIAL_SGI_IOC4 910config SERIAL_SGI_IOC4
911 tristate "SGI IOC4 controller serial support" 911 tristate "SGI IOC4 controller serial support"
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index 18753193f59b..dfc1e86d3aa1 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -380,7 +380,6 @@ struct neo_uart_struct {
380extern struct uart_driver jsm_uart_driver; 380extern struct uart_driver jsm_uart_driver;
381extern struct board_ops jsm_neo_ops; 381extern struct board_ops jsm_neo_ops;
382extern int jsm_debug; 382extern int jsm_debug;
383extern int jsm_rawreadok;
384 383
385/************************************************************************* 384/*************************************************************************
386 * 385 *
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 7e56c7824194..b1b66e71d281 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -49,11 +49,8 @@ struct uart_driver jsm_uart_driver = {
49}; 49};
50 50
51int jsm_debug; 51int jsm_debug;
52int jsm_rawreadok;
53module_param(jsm_debug, int, 0); 52module_param(jsm_debug, int, 0);
54module_param(jsm_rawreadok, int, 0);
55MODULE_PARM_DESC(jsm_debug, "Driver debugging level"); 53MODULE_PARM_DESC(jsm_debug, "Driver debugging level");
56MODULE_PARM_DESC(jsm_rawreadok, "Bypass flip buffers on input");
57 54
58static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) 55static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
59{ 56{
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index 6f22b42d9337..87e4e2cf8ce7 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -965,56 +965,47 @@ static void neo_param(struct jsm_channel *ch)
965 baud = ch->ch_custom_speed; 965 baud = ch->ch_custom_speed;
966 if (ch->ch_flags & CH_BAUD0) 966 if (ch->ch_flags & CH_BAUD0)
967 ch->ch_flags &= ~(CH_BAUD0); 967 ch->ch_flags &= ~(CH_BAUD0);
968 } else { 968 } else {
969 int iindex = 0; 969 int i;
970 int jindex = 0; 970 unsigned int cflag;
971 971 static struct {
972 const u64 bauds[4][16] = { 972 unsigned int rate;
973 { 973 unsigned int cflag;
974 0, 50, 75, 110, 974 } baud_rates[] = {
975 134, 150, 200, 300, 975 { 921600, B921600 },
976 600, 1200, 1800, 2400, 976 { 460800, B460800 },
977 4800, 9600, 19200, 38400 }, 977 { 230400, B230400 },
978 { 978 { 115200, B115200 },
979 0, 57600, 115200, 230400, 979 { 57600, B57600 },
980 460800, 150, 200, 921600, 980 { 38400, B38400 },
981 600, 1200, 1800, 2400, 981 { 19200, B19200 },
982 4800, 9600, 19200, 38400 }, 982 { 9600, B9600 },
983 { 983 { 4800, B4800 },
984 0, 57600, 76800, 115200, 984 { 2400, B2400 },
985 131657, 153600, 230400, 460800, 985 { 1200, B1200 },
986 921600, 1200, 1800, 2400, 986 { 600, B600 },
987 4800, 9600, 19200, 38400 }, 987 { 300, B300 },
988 { 988 { 200, B200 },
989 0, 57600, 115200, 230400, 989 { 150, B150 },
990 460800, 150, 200, 921600, 990 { 134, B134 },
991 600, 1200, 1800, 2400, 991 { 110, B110 },
992 4800, 9600, 19200, 38400 } 992 { 75, B75 },
993 }; 993 { 50, B50 },
994 994 };
995 baud = C_BAUD(ch->uart_port.info->tty) & 0xff; 995
996 996 cflag = C_BAUD(ch->uart_port.info->tty);
997 if (ch->ch_c_cflag & CBAUDEX) 997 baud = 9600;
998 iindex = 1; 998 for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
999 999 if (baud_rates[i].cflag == cflag) {
1000 jindex = baud; 1000 baud = baud_rates[i].rate;
1001 1001 break;
1002 if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16))
1003 baud = bauds[iindex][jindex];
1004 else {
1005 jsm_printk(IOCTL, DEBUG, &ch->ch_bd->pci_dev,
1006 "baud indices were out of range (%d)(%d)",
1007 iindex, jindex);
1008 baud = 0;
1009 } 1002 }
1010
1011 if (baud == 0)
1012 baud = 9600;
1013
1014 if (ch->ch_flags & CH_BAUD0)
1015 ch->ch_flags &= ~(CH_BAUD0);
1016 } 1003 }
1017 1004
1005 if (ch->ch_flags & CH_BAUD0)
1006 ch->ch_flags &= ~(CH_BAUD0);
1007 }
1008
1018 if (ch->ch_c_cflag & PARENB) 1009 if (ch->ch_c_cflag & PARENB)
1019 lcr |= UART_LCR_PARITY; 1010 lcr |= UART_LCR_PARITY;
1020 1011
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 6fa0d62d6f68..4d48b625cd3d 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -20,8 +20,10 @@
20 * 20 *
21 * Contact Information: 21 * Contact Information:
22 * Scott H Kilau <Scott_Kilau@digi.com> 22 * Scott H Kilau <Scott_Kilau@digi.com>
23 * Wendy Xiong <wendyx@us.ltcfwd.linux.ibm.com> 23 * Ananda Venkatarman <mansarov@us.ibm.com>
24 * 24 * Modifications:
25 * 01/19/06: changed jsm_input routine to use the dynamically allocated
26 * tty_buffer changes. Contributors: Scott Kilau and Ananda V.
25 ***********************************************************************/ 27 ***********************************************************************/
26#include <linux/tty.h> 28#include <linux/tty.h>
27#include <linux/tty_flip.h> 29#include <linux/tty_flip.h>
@@ -497,16 +499,15 @@ void jsm_input(struct jsm_channel *ch)
497{ 499{
498 struct jsm_board *bd; 500 struct jsm_board *bd;
499 struct tty_struct *tp; 501 struct tty_struct *tp;
502 struct tty_ldisc *ld;
500 u32 rmask; 503 u32 rmask;
501 u16 head; 504 u16 head;
502 u16 tail; 505 u16 tail;
503 int data_len; 506 int data_len;
504 unsigned long lock_flags; 507 unsigned long lock_flags;
505 int flip_len; 508 int flip_len = 0;
506 int len = 0; 509 int len = 0;
507 int n = 0; 510 int n = 0;
508 char *buf = NULL;
509 char *buf2 = NULL;
510 int s = 0; 511 int s = 0;
511 int i = 0; 512 int i = 0;
512 513
@@ -574,56 +575,50 @@ void jsm_input(struct jsm_channel *ch)
574 575
575 /* 576 /*
576 * If the rxbuf is empty and we are not throttled, put as much 577 * If the rxbuf is empty and we are not throttled, put as much
577 * as we can directly into the linux TTY flip buffer. 578 * as we can directly into the linux TTY buffer.
578 * The jsm_rawreadok case takes advantage of carnal knowledge that
579 * the char_buf and the flag_buf are next to each other and
580 * are each of (2 * TTY_FLIPBUF_SIZE) size.
581 * 579 *
582 * NOTE: if(!tty->real_raw), the call to ldisc.receive_buf
583 *actually still uses the flag buffer, so you can't
584 *use it for input data
585 */ 580 */
586 if (jsm_rawreadok) { 581 flip_len = TTY_FLIPBUF_SIZE;
587 if (tp->real_raw)
588 flip_len = MYFLIPLEN;
589 else
590 flip_len = 2 * TTY_FLIPBUF_SIZE;
591 } else
592 flip_len = TTY_FLIPBUF_SIZE - tp->flip.count;
593 582
594 len = min(data_len, flip_len); 583 len = min(data_len, flip_len);
595 len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); 584 len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt);
585 ld = tty_ldisc_ref(tp);
596 586
597 if (len <= 0) { 587 /*
598 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 588 * If the DONT_FLIP flag is on, don't flush our buffer, and act
599 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "jsm_input 1\n"); 589 * like the ld doesn't have any space to put the data right now.
600 return; 590 */
601 } 591 if (test_bit(TTY_DONT_FLIP, &tp->flags))
592 len = 0;
602 593
603 /* 594 /*
604 * If we're bypassing flip buffers on rx, we can blast it 595 * If we were unable to get a reference to the ld,
605 * right into the beginning of the buffer. 596 * don't flush our buffer, and act like the ld doesn't
597 * have any space to put the data right now.
606 */ 598 */
607 if (jsm_rawreadok) { 599 if (!ld) {
608 if (tp->real_raw) { 600 len = 0;
609 if (ch->ch_flags & CH_FLIPBUF_IN_USE) {
610 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
611 "JSM - FLIPBUF in use. delaying input\n");
612 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
613 return;
614 }
615 ch->ch_flags |= CH_FLIPBUF_IN_USE;
616 buf = ch->ch_bd->flipbuf;
617 buf2 = NULL;
618 } else {
619 buf = tp->flip.char_buf;
620 buf2 = tp->flip.flag_buf;
621 }
622 } else { 601 } else {
623 buf = tp->flip.char_buf_ptr; 602 /*
624 buf2 = tp->flip.flag_buf_ptr; 603 * If ld doesn't have a pointer to a receive_buf function,
604 * flush the data, then act like the ld doesn't have any
605 * space to put the data right now.
606 */
607 if (!ld->receive_buf) {
608 ch->ch_r_head = ch->ch_r_tail;
609 len = 0;
610 }
625 } 611 }
626 612
613 if (len <= 0) {
614 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
615 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "jsm_input 1\n");
616 if (ld)
617 tty_ldisc_deref(ld);
618 return;
619 }
620
621 len = tty_buffer_request_room(tp, len);
627 n = len; 622 n = len;
628 623
629 /* 624 /*
@@ -638,121 +633,47 @@ void jsm_input(struct jsm_channel *ch)
638 if (s <= 0) 633 if (s <= 0)
639 break; 634 break;
640 635
641 memcpy(buf, ch->ch_rqueue + tail, s); 636 /*
642 637 * If conditions are such that ld needs to see all
643 /* buf2 is only set when port isn't raw */ 638 * UART errors, we will have to walk each character
644 if (buf2) 639 * and error byte and send them to the buffer one at
645 memcpy(buf2, ch->ch_equeue + tail, s); 640 * a time.
646 641 */
647 tail += s;
648 buf += s;
649 if (buf2)
650 buf2 += s;
651 n -= s;
652 /* Flip queue if needed */
653 tail &= rmask;
654 }
655 642
656 /*
657 * In high performance mode, we don't have to update
658 * flag_buf or any of the counts or pointers into flip buf.
659 */
660 if (!jsm_rawreadok) {
661 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { 643 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
662 for (i = 0; i < len; i++) { 644 for (i = 0; i < s; i++) {
663 /* 645 /*
664 * Give the Linux ld the flags in the 646 * Give the Linux ld the flags in the
665 * format it likes. 647 * format it likes.
666 */ 648 */
667 if (tp->flip.flag_buf_ptr[i] & UART_LSR_BI) 649 if (*(ch->ch_equeue +tail +i) & UART_LSR_BI)
668 tp->flip.flag_buf_ptr[i] = TTY_BREAK; 650 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_BREAK);
669 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_PE) 651 else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE)
670 tp->flip.flag_buf_ptr[i] = TTY_PARITY; 652 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_PARITY);
671 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_FE) 653 else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE)
672 tp->flip.flag_buf_ptr[i] = TTY_FRAME; 654 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_FRAME);
673 else 655 else
674 tp->flip.flag_buf_ptr[i] = TTY_NORMAL; 656 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
675 } 657 }
676 } else { 658 } else {
677 memset(tp->flip.flag_buf_ptr, 0, len); 659 tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ;
678 } 660 }
679 661 tail += s;
680 tp->flip.char_buf_ptr += len; 662 n -= s;
681 tp->flip.flag_buf_ptr += len; 663 /* Flip queue if needed */
682 tp->flip.count += len; 664 tail &= rmask;
683 }
684 else if (!tp->real_raw) {
685 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
686 for (i = 0; i < len; i++) {
687 /*
688 * Give the Linux ld the flags in the
689 * format it likes.
690 */
691 if (tp->flip.flag_buf_ptr[i] & UART_LSR_BI)
692 tp->flip.flag_buf_ptr[i] = TTY_BREAK;
693 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_PE)
694 tp->flip.flag_buf_ptr[i] = TTY_PARITY;
695 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_FE)
696 tp->flip.flag_buf_ptr[i] = TTY_FRAME;
697 else
698 tp->flip.flag_buf_ptr[i] = TTY_NORMAL;
699 }
700 } else
701 memset(tp->flip.flag_buf, 0, len);
702 } 665 }
703 666
704 /* 667 ch->ch_r_tail = tail & rmask;
705 * If we're doing raw reads, jam it right into the 668 ch->ch_e_tail = tail & rmask;
706 * line disc bypassing the flip buffers. 669 jsm_check_queue_flow_control(ch);
707 */ 670 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
708 if (jsm_rawreadok) {
709 if (tp->real_raw) {
710 ch->ch_r_tail = tail & rmask;
711 ch->ch_e_tail = tail & rmask;
712
713 jsm_check_queue_flow_control(ch);
714
715 /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */
716 671
717 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 672 /* Tell the tty layer its okay to "eat" the data now */
673 tty_flip_buffer_push(tp);
718 674
719 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 675 if (ld)
720 "jsm_input. %d real_raw len:%d calling receive_buf for board %d\n", 676 tty_ldisc_deref(ld);
721 __LINE__, len, ch->ch_bd->boardnum);
722 tp->ldisc.receive_buf(tp, ch->ch_bd->flipbuf, NULL, len);
723
724 /* Allow use of channel flip buffer again */
725 spin_lock_irqsave(&ch->ch_lock, lock_flags);
726 ch->ch_flags &= ~CH_FLIPBUF_IN_USE;
727 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
728
729 } else {
730 ch->ch_r_tail = tail & rmask;
731 ch->ch_e_tail = tail & rmask;
732
733 jsm_check_queue_flow_control(ch);
734
735 /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */
736 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
737
738 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
739 "jsm_input. %d not real_raw len:%d calling receive_buf for board %d\n",
740 __LINE__, len, ch->ch_bd->boardnum);
741
742 tp->ldisc.receive_buf(tp, tp->flip.char_buf, tp->flip.flag_buf, len);
743 }
744 } else {
745 ch->ch_r_tail = tail & rmask;
746 ch->ch_e_tail = tail & rmask;
747
748 jsm_check_queue_flow_control(ch);
749
750 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
751
752 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
753 "jsm_input. %d not jsm_read raw okay scheduling flip\n", __LINE__);
754 tty_schedule_flip(tp);
755 }
756 677
757 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 678 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n");
758} 679}
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index d957a3a9edf1..0ef648fa4b2d 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -350,8 +350,7 @@ static inline void receive_chars(struct mcf_serial *info)
350 } 350 }
351 tty_insert_flip_char(tty, ch, flag); 351 tty_insert_flip_char(tty, ch, flag);
352 } 352 }
353 353 tty_flip_buffer_push(tty);
354 schedule_work(&tty->flip.work);
355 return; 354 return;
356} 355}
357 356
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 0111206327ca..80737c131ce7 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -42,6 +42,7 @@
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/console.h> 43#include <linux/console.h>
44#include <linux/bitops.h> 44#include <linux/bitops.h>
45#include <linux/generic_serial.h>
45 46
46#ifdef CONFIG_CPU_FREQ 47#ifdef CONFIG_CPU_FREQ
47#include <linux/notifier.h> 48#include <linux/notifier.h>
@@ -53,7 +54,9 @@
53#include <asm/irq.h> 54#include <asm/irq.h>
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
55 56
56#include <linux/generic_serial.h> 57#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
58#include <asm/clock.h>
59#endif
57 60
58#ifdef CONFIG_SH_STANDARD_BIOS 61#ifdef CONFIG_SH_STANDARD_BIOS
59#include <asm/sh_bios.h> 62#include <asm/sh_bios.h>
@@ -86,9 +89,11 @@ static void sci_stop_rx(struct uart_port *port);
86static int sci_request_irq(struct sci_port *port); 89static int sci_request_irq(struct sci_port *port);
87static void sci_free_irq(struct sci_port *port); 90static void sci_free_irq(struct sci_port *port);
88 91
89static struct sci_port sci_ports[SCI_NPORTS]; 92static struct sci_port sci_ports[];
90static struct uart_driver sci_uart_driver; 93static struct uart_driver sci_uart_driver;
91 94
95#define SCI_NPORTS sci_uart_driver.nr
96
92#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB) 97#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
93 98
94static void handle_error(struct uart_port *port) 99static void handle_error(struct uart_port *port)
@@ -168,7 +173,7 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
168 int usegdb=0; 173 int usegdb=0;
169 174
170#ifdef CONFIG_SH_STANDARD_BIOS 175#ifdef CONFIG_SH_STANDARD_BIOS
171 /* This call only does a trap the first time it is 176 /* This call only does a trap the first time it is
172 * called, and so is safe to do here unconditionally 177 * called, and so is safe to do here unconditionally
173 */ 178 */
174 usegdb |= sh_bios_in_gdb_mode(); 179 usegdb |= sh_bios_in_gdb_mode();
@@ -324,47 +329,46 @@ static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag)
324 /* tx mark output*/ 329 /* tx mark output*/
325 H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx; 330 H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx;
326} 331}
327#else
328static void sci_init_pins_sci(struct uart_port *port, unsigned int cflag)
329{
330}
331#endif 332#endif
332#endif 333#endif
333 334
334#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF) 335#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
335#if defined(CONFIG_CPU_SH3) 336#if defined(CONFIG_CPU_SUBTYPE_SH7300)
336/* For SH7705, SH7707, SH7709, SH7709A, SH7729, SH7300*/ 337/* SH7300 doesn't use RTS/CTS */
338static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
339{
340 sci_out(port, SCFCR, 0);
341}
342#elif defined(CONFIG_CPU_SH3)
343/* For SH7705, SH7707, SH7709, SH7709A, SH7729 */
337static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 344static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
338{ 345{
339 unsigned int fcr_val = 0; 346 unsigned int fcr_val = 0;
340#if !defined(CONFIG_CPU_SUBTYPE_SH7300) /* SH7300 doesn't use RTS/CTS */ 347 unsigned short data;
341 { 348
342 unsigned short data; 349 /* We need to set SCPCR to enable RTS/CTS */
350 data = ctrl_inw(SCPCR);
351 /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
352 ctrl_outw(data & 0x0fcf, SCPCR);
343 353
344 /* We need to set SCPCR to enable RTS/CTS */
345 data = ctrl_inw(SCPCR);
346 /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
347 ctrl_outw(data&0x0fcf, SCPCR);
348 }
349 if (cflag & CRTSCTS) 354 if (cflag & CRTSCTS)
350 fcr_val |= SCFCR_MCE; 355 fcr_val |= SCFCR_MCE;
351 else { 356 else {
352 unsigned short data;
353
354 /* We need to set SCPCR to enable RTS/CTS */ 357 /* We need to set SCPCR to enable RTS/CTS */
355 data = ctrl_inw(SCPCR); 358 data = ctrl_inw(SCPCR);
356 /* Clear out SCP7MD1,0, SCP4MD1,0, 359 /* Clear out SCP7MD1,0, SCP4MD1,0,
357 Set SCP6MD1,0 = {01} (output) */ 360 Set SCP6MD1,0 = {01} (output) */
358 ctrl_outw((data&0x0fcf)|0x1000, SCPCR); 361 ctrl_outw((data & 0x0fcf) | 0x1000, SCPCR);
359 362
360 data = ctrl_inb(SCPDR); 363 data = ctrl_inb(SCPDR);
361 /* Set /RTS2 (bit6) = 0 */ 364 /* Set /RTS2 (bit6) = 0 */
362 ctrl_outb(data&0xbf, SCPDR); 365 ctrl_outb(data & 0xbf, SCPDR);
363 } 366 }
364#endif 367
365 sci_out(port, SCFCR, fcr_val); 368 sci_out(port, SCFCR, fcr_val);
366} 369}
367 370
371#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
368static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag) 372static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
369{ 373{
370 unsigned int fcr_val = 0; 374 unsigned int fcr_val = 0;
@@ -374,7 +378,7 @@ static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
374 378
375 sci_out(port, SCFCR, fcr_val); 379 sci_out(port, SCFCR, fcr_val);
376} 380}
377 381#endif
378#else 382#else
379 383
380/* For SH7750 */ 384/* For SH7750 */
@@ -385,7 +389,11 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
385 if (cflag & CRTSCTS) { 389 if (cflag & CRTSCTS) {
386 fcr_val |= SCFCR_MCE; 390 fcr_val |= SCFCR_MCE;
387 } else { 391 } else {
392#ifdef CONFIG_CPU_SUBTYPE_SH7780
393 ctrl_outw(0x0080, SCSPTR0); /* Set RTS = 1 */
394#else
388 ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */ 395 ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */
396#endif
389 } 397 }
390 sci_out(port, SCFCR, fcr_val); 398 sci_out(port, SCFCR, fcr_val);
391} 399}
@@ -422,7 +430,11 @@ static void sci_transmit_chars(struct uart_port *port)
422 430
423#if !defined(SCI_ONLY) 431#if !defined(SCI_ONLY)
424 if (port->type == PORT_SCIF) { 432 if (port->type == PORT_SCIF) {
433#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
434 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f);
435#else
425 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8); 436 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8);
437#endif
426 } else { 438 } else {
427 txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0; 439 txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
428 } 440 }
@@ -491,7 +503,11 @@ static inline void sci_receive_chars(struct uart_port *port,
491 while (1) { 503 while (1) {
492#if !defined(SCI_ONLY) 504#if !defined(SCI_ONLY)
493 if (port->type == PORT_SCIF) { 505 if (port->type == PORT_SCIF) {
506#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
507 count = sci_in(port, SCRFDR) & 0x7f;
508#else
494 count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ; 509 count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ;
510#endif
495 } else { 511 } else {
496 count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0; 512 count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
497 } 513 }
@@ -652,7 +668,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
652 struct tty_struct *tty = port->info->tty; 668 struct tty_struct *tty = port->info->tty;
653 struct sci_port *s = &sci_ports[port->line]; 669 struct sci_port *s = &sci_ports[port->line];
654 670
655 if (!s->break_flag && status & SCxSR_BRK(port)) 671 if (!s->break_flag && status & SCxSR_BRK(port)) {
656#if defined(CONFIG_CPU_SH3) 672#if defined(CONFIG_CPU_SH3)
657 /* Debounce break */ 673 /* Debounce break */
658 s->break_flag = 1; 674 s->break_flag = 1;
@@ -783,6 +799,7 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void *
783 (phase == CPUFREQ_RESUMECHANGE)){ 799 (phase == CPUFREQ_RESUMECHANGE)){
784 for (i = 0; i < SCI_NPORTS; i++) { 800 for (i = 0; i < SCI_NPORTS; i++) {
785 struct uart_port *port = &sci_ports[i].port; 801 struct uart_port *port = &sci_ports[i].port;
802 struct clk *clk;
786 803
787 /* 804 /*
788 * Update the uartclk per-port if frequency has 805 * Update the uartclk per-port if frequency has
@@ -795,7 +812,9 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void *
795 * 812 *
796 * Clean this up later.. 813 * Clean this up later..
797 */ 814 */
798 port->uartclk = current_cpu_data.module_clock * 16; 815 clk = clk_get("module_clk");
816 port->uartclk = clk_get_rate(clk) * 16;
817 clk_put(clk);
799 } 818 }
800 819
801 printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n", 820 printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n",
@@ -1008,15 +1027,20 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
1008 sci_out(port, SCSMR, smr_val); 1027 sci_out(port, SCSMR, smr_val);
1009 1028
1010 switch (baud) { 1029 switch (baud) {
1011 case 0: t = -1; break; 1030 case 0:
1012 case 2400: t = BPS_2400; break; 1031 t = -1;
1013 case 4800: t = BPS_4800; break; 1032 break;
1014 case 9600: t = BPS_9600; break; 1033 default:
1015 case 19200: t = BPS_19200; break; 1034 {
1016 case 38400: t = BPS_38400; break; 1035#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
1017 case 57600: t = BPS_57600; break; 1036 struct clk *clk = clk_get("module_clk");
1018 case 115200: t = BPS_115200; break; 1037 t = SCBRR_VALUE(baud, clk_get_rate(clk));
1019 default: t = SCBRR_VALUE(baud); break; 1038 clk_put(clk);
1039#else
1040 t = SCBRR_VALUE(baud);
1041#endif
1042 }
1043 break;
1020 } 1044 }
1021 1045
1022 if (t > 0) { 1046 if (t > 0) {
@@ -1030,7 +1054,9 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
1030 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ 1054 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
1031 } 1055 }
1032 1056
1033 s->init_pins(port, termios->c_cflag); 1057 if (likely(s->init_pins))
1058 s->init_pins(port, termios->c_cflag);
1059
1034 sci_out(port, SCSCR, SCSCR_INIT(port)); 1060 sci_out(port, SCSCR, SCSCR_INIT(port));
1035 1061
1036 if ((termios->c_cflag & CREAD) != 0) 1062 if ((termios->c_cflag & CREAD) != 0)
@@ -1107,7 +1133,7 @@ static struct uart_ops sci_uart_ops = {
1107 .verify_port = sci_verify_port, 1133 .verify_port = sci_verify_port,
1108}; 1134};
1109 1135
1110static struct sci_port sci_ports[SCI_NPORTS] = { 1136static struct sci_port sci_ports[] = {
1111#if defined(CONFIG_CPU_SUBTYPE_SH7708) 1137#if defined(CONFIG_CPU_SUBTYPE_SH7708)
1112 { 1138 {
1113 .port = { 1139 .port = {
@@ -1121,7 +1147,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1121 }, 1147 },
1122 .type = PORT_SCI, 1148 .type = PORT_SCI,
1123 .irqs = SCI_IRQS, 1149 .irqs = SCI_IRQS,
1124 .init_pins = sci_init_pins_sci,
1125 }, 1150 },
1126#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 1151#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
1127 { 1152 {
@@ -1165,7 +1190,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1165 }, 1190 },
1166 .type = PORT_SCI, 1191 .type = PORT_SCI,
1167 .irqs = SCI_IRQS, 1192 .irqs = SCI_IRQS,
1168 .init_pins = sci_init_pins_sci,
1169 }, 1193 },
1170 { 1194 {
1171 .port = { 1195 .port = {
@@ -1225,7 +1249,7 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1225 .irqs = SH73180_SCIF_IRQS, 1249 .irqs = SH73180_SCIF_IRQS,
1226 .init_pins = sci_init_pins_scif, 1250 .init_pins = sci_init_pins_scif,
1227 }, 1251 },
1228#elif defined(CONFIG_SH_RTS7751R2D) 1252#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
1229 { 1253 {
1230 .port = { 1254 .port = {
1231 .membase = (void *)0xffe80000, 1255 .membase = (void *)0xffe80000,
@@ -1253,7 +1277,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1253 }, 1277 },
1254 .type = PORT_SCI, 1278 .type = PORT_SCI,
1255 .irqs = SCI_IRQS, 1279 .irqs = SCI_IRQS,
1256 .init_pins = sci_init_pins_sci,
1257 }, 1280 },
1258 { 1281 {
1259 .port = { 1282 .port = {
@@ -1312,21 +1335,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1312 .irqs = SH7760_SCIF2_IRQS, 1335 .irqs = SH7760_SCIF2_IRQS,
1313 .init_pins = sci_init_pins_scif, 1336 .init_pins = sci_init_pins_scif,
1314 }, 1337 },
1315#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
1316 {
1317 .port = {
1318 .membase = (void *)0xffe80000,
1319 .mapbase = 0xffe80000,
1320 .iotype = UPIO_MEM,
1321 .irq = 43,
1322 .ops = &sci_uart_ops,
1323 .flags = UPF_BOOT_AUTOCONF,
1324 .line = 0,
1325 },
1326 .type = PORT_SCIF,
1327 .irqs = SH4_SCIF_IRQS,
1328 .init_pins = sci_init_pins_scif,
1329 },
1330#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 1338#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
1331 { 1339 {
1332 .port = { 1340 .port = {
@@ -1455,6 +1463,78 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1455 .irqs = H8S_SCI_IRQS2, 1463 .irqs = H8S_SCI_IRQS2,
1456 .init_pins = sci_init_pins_sci, 1464 .init_pins = sci_init_pins_sci,
1457 }, 1465 },
1466#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
1467 {
1468 .port = {
1469 .membase = (void *)0xff923000,
1470 .mapbase = 0xff923000,
1471 .iotype = SERIAL_IO_MEM,
1472 .irq = 61,
1473 .ops = &sci_uart_ops,
1474 .flags = ASYNC_BOOT_AUTOCONF,
1475 .line = 0,
1476 },
1477 .type = PORT_SCIF,
1478 .irqs = SH7770_SCIF0_IRQS,
1479 .init_pins = sci_init_pins_scif,
1480 },
1481 {
1482 .port = {
1483 .membase = (void *)0xff924000,
1484 .mapbase = 0xff924000,
1485 .iotype = SERIAL_IO_MEM,
1486 .irq = 62,
1487 .ops = &sci_uart_ops,
1488 .flags = ASYNC_BOOT_AUTOCONF,
1489 .line = 1,
1490 },
1491 .type = PORT_SCIF,
1492 .irqs = SH7770_SCIF1_IRQS,
1493 .init_pins = sci_init_pins_scif,
1494 },
1495 {
1496 .port = {
1497 .membase = (void *)0xff925000,
1498 .mapbase = 0xff925000,
1499 .iotype = SERIAL_IO_MEM,
1500 .irq = 63,
1501 .ops = &sci_uart_ops,
1502 .flags = ASYNC_BOOT_AUTOCONF,
1503 .line = 2,
1504 },
1505 .type = PORT_SCIF,
1506 .irqs = SH7770_SCIF2_IRQS,
1507 .init_pins = sci_init_pins_scif,
1508 },
1509#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
1510 {
1511 .port = {
1512 .membase = (void *)0xffe00000,
1513 .mapbase = 0xffe00000,
1514 .iotype = SERIAL_IO_MEM,
1515 .irq = 43,
1516 .ops = &sci_uart_ops,
1517 .flags = ASYNC_BOOT_AUTOCONF,
1518 .line = 0,
1519 },
1520 .type = PORT_SCIF,
1521 .irqs = SH7780_SCIF0_IRQS,
1522 .init_pins = sci_init_pins_scif,
1523 },
1524 {
1525 .port = {
1526 .membase = (void *)0xffe10000,
1527 .mapbase = 0xffe10000,
1528 .iotype = SERIAL_IO_MEM,
1529 .irq = 79,
1530 .ops = &sci_uart_ops,
1531 .flags = ASYNC_BOOT_AUTOCONF,
1532 .line = 1,
1533 },
1534 .type = PORT_SCIF,
1535 .irqs = SH7780_SCIF1_IRQS,
1536 .init_pins = sci_init_pins_scif,
1537 },
1458#else 1538#else
1459#error "CPU subtype not defined" 1539#error "CPU subtype not defined"
1460#endif 1540#endif
@@ -1480,9 +1560,6 @@ static int __init serial_console_setup(struct console *co, char *options)
1480 int flow = 'n'; 1560 int flow = 'n';
1481 int ret; 1561 int ret;
1482 1562
1483 if (co->index >= SCI_NPORTS)
1484 co->index = 0;
1485
1486 serial_console_port = &sci_ports[co->index]; 1563 serial_console_port = &sci_ports[co->index];
1487 port = &serial_console_port->port; 1564 port = &serial_console_port->port;
1488 port->type = serial_console_port->type; 1565 port->type = serial_console_port->type;
@@ -1496,14 +1573,21 @@ static int __init serial_console_setup(struct console *co, char *options)
1496 * We need to set the initial uartclk here, since otherwise it will 1573 * We need to set the initial uartclk here, since otherwise it will
1497 * only ever be setup at sci_init() time. 1574 * only ever be setup at sci_init() time.
1498 */ 1575 */
1499#if !defined(__H8300H__) && !defined(__H8300S__) 1576#if defined(__H8300H__) || defined(__H8300S__)
1500 port->uartclk = current_cpu_data.module_clock * 16;
1501#else
1502 port->uartclk = CONFIG_CPU_CLOCK; 1577 port->uartclk = CONFIG_CPU_CLOCK;
1503#endif 1578
1504#if defined(__H8300S__) 1579#if defined(__H8300S__)
1505 h8300_sci_enable(port, sci_enable); 1580 h8300_sci_enable(port, sci_enable);
1506#endif 1581#endif
1582#elif defined(CONFIG_SUPERH64)
1583 port->uartclk = current_cpu_info.module_clock * 16;
1584#else
1585 {
1586 struct clk *clk = clk_get("module_clk");
1587 port->uartclk = clk_get_rate(clk) * 16;
1588 clk_put(clk);
1589 }
1590#endif
1507 if (options) 1591 if (options)
1508 uart_parse_options(options, &baud, &parity, &bits, &flow); 1592 uart_parse_options(options, &baud, &parity, &bits, &flow);
1509 1593
@@ -1566,7 +1650,7 @@ int __init kgdb_console_setup(struct console *co, char *options)
1566 int parity = 'n'; 1650 int parity = 'n';
1567 int flow = 'n'; 1651 int flow = 'n';
1568 1652
1569 if (co->index >= SCI_NPORTS || co->index != kgdb_portnum) 1653 if (co->index != kgdb_portnum)
1570 co->index = kgdb_portnum; 1654 co->index = kgdb_portnum;
1571 1655
1572 if (options) 1656 if (options)
@@ -1606,7 +1690,7 @@ console_initcall(kgdb_console_init);
1606#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE) 1690#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
1607#define SCI_CONSOLE &serial_console 1691#define SCI_CONSOLE &serial_console
1608#else 1692#else
1609#define SCI_CONSOLE 0 1693#define SCI_CONSOLE 0
1610#endif 1694#endif
1611 1695
1612static char banner[] __initdata = 1696static char banner[] __initdata =
@@ -1621,7 +1705,6 @@ static struct uart_driver sci_uart_driver = {
1621 .dev_name = "ttySC", 1705 .dev_name = "ttySC",
1622 .major = SCI_MAJOR, 1706 .major = SCI_MAJOR,
1623 .minor = SCI_MINOR_START, 1707 .minor = SCI_MINOR_START,
1624 .nr = SCI_NPORTS,
1625 .cons = SCI_CONSOLE, 1708 .cons = SCI_CONSOLE,
1626}; 1709};
1627 1710
@@ -1631,15 +1714,21 @@ static int __init sci_init(void)
1631 1714
1632 printk("%s", banner); 1715 printk("%s", banner);
1633 1716
1717 sci_uart_driver.nr = ARRAY_SIZE(sci_ports);
1718
1634 ret = uart_register_driver(&sci_uart_driver); 1719 ret = uart_register_driver(&sci_uart_driver);
1635 if (ret == 0) { 1720 if (ret == 0) {
1636 for (chan = 0; chan < SCI_NPORTS; chan++) { 1721 for (chan = 0; chan < SCI_NPORTS; chan++) {
1637 struct sci_port *sciport = &sci_ports[chan]; 1722 struct sci_port *sciport = &sci_ports[chan];
1638 1723
1639#if !defined(__H8300H__) && !defined(__H8300S__) 1724#if defined(__H8300H__) || defined(__H8300S__)
1640 sciport->port.uartclk = (current_cpu_data.module_clock * 16);
1641#else
1642 sciport->port.uartclk = CONFIG_CPU_CLOCK; 1725 sciport->port.uartclk = CONFIG_CPU_CLOCK;
1726#elif defined(CONFIG_SUPERH64)
1727 sciport->port.uartclk = current_cpu_info.module_clock * 16;
1728#else
1729 struct clk *clk = clk_get("module_clk");
1730 sciport->port.uartclk = clk_get_rate(clk) * 16;
1731 clk_put(clk);
1643#endif 1732#endif
1644 uart_add_one_port(&sci_uart_driver, &sciport->port); 1733 uart_add_one_port(&sci_uart_driver, &sciport->port);
1645 sciport->break_timer.data = (unsigned long)sciport; 1734 sciport->break_timer.data = (unsigned long)sciport;
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 2892169eff05..1f14bb4382f6 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -46,14 +46,17 @@
46#define H8S_SCI_IRQS1 {92, 93, 94, 0 } 46#define H8S_SCI_IRQS1 {92, 93, 94, 0 }
47#define H8S_SCI_IRQS2 {96, 97, 98, 0 } 47#define H8S_SCI_IRQS2 {96, 97, 98, 0 }
48#define SH5_SCIF_IRQS {39, 40, 42, 0 } 48#define SH5_SCIF_IRQS {39, 40, 42, 0 }
49#define SH7770_SCIF0_IRQS {61, 61, 61, 61 }
50#define SH7770_SCIF1_IRQS {62, 62, 62, 62 }
51#define SH7770_SCIF2_IRQS {63, 63, 63, 63 }
52#define SH7780_SCIF0_IRQS {40, 41, 43, 42 }
53#define SH7780_SCIF1_IRQS {76, 77, 79, 78 }
49 54
50#if defined(CONFIG_CPU_SUBTYPE_SH7708) 55#if defined(CONFIG_CPU_SUBTYPE_SH7708)
51# define SCI_NPORTS 1
52# define SCSPTR 0xffffff7c /* 8 bit */ 56# define SCSPTR 0xffffff7c /* 8 bit */
53# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 57# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
54# define SCI_ONLY 58# define SCI_ONLY
55#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) 59#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
56# define SCI_NPORTS 3
57# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ 60# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
58# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ 61# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
59# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 62# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
@@ -61,9 +64,8 @@
61#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 64#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
62# define SCIF0 0xA4400000 65# define SCIF0 0xA4400000
63# define SCIF2 0xA4410000 66# define SCIF2 0xA4410000
64# define SCSMR_Ir 0xA44A0000 67# define SCSMR_Ir 0xA44A0000
65# define IRDA_SCIF SCIF0 68# define IRDA_SCIF SCIF0
66# define SCI_NPORTS 2
67# define SCPCR 0xA4000116 69# define SCPCR 0xA4000116
68# define SCPDR 0xA4000136 70# define SCPDR 0xA4000136
69 71
@@ -74,14 +76,11 @@
74# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 76# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
75# define SCIF_ONLY 77# define SCIF_ONLY
76#elif defined(CONFIG_SH_RTS7751R2D) 78#elif defined(CONFIG_SH_RTS7751R2D)
77# define SCI_NPORTS 1
78# define SCSPTR1 0xffe0001c /* 8 bit SCI */
79# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ 79# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
80# define SCIF_ORER 0x0001 /* overrun error bit */ 80# define SCIF_ORER 0x0001 /* overrun error bit */
81# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 81# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
82# define SCIF_ONLY 82# define SCIF_ONLY
83#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) 83#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
84# define SCI_NPORTS 2
85# define SCSPTR1 0xffe0001c /* 8 bit SCI */ 84# define SCSPTR1 0xffe0001c /* 8 bit SCI */
86# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ 85# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
87# define SCIF_ORER 0x0001 /* overrun error bit */ 86# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -90,34 +89,29 @@
90 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) 89 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
91# define SCI_AND_SCIF 90# define SCI_AND_SCIF
92#elif defined(CONFIG_CPU_SUBTYPE_SH7760) 91#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
93# define SCI_NPORTS 3 92# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
94# define SCSPTR0 0xfe600000 /* 16 bit SCIF */ 93# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
95# define SCSPTR1 0xfe610000 /* 16 bit SCIF */ 94# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
96# define SCSPTR2 0xfe620000 /* 16 bit SCIF */
97# define SCIF_ORER 0x0001 /* overrun error bit */ 95# define SCIF_ORER 0x0001 /* overrun error bit */
98# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 96# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
99# define SCIF_ONLY 97# define SCIF_ONLY
100#elif defined(CONFIG_CPU_SUBTYPE_SH7300) 98#elif defined(CONFIG_CPU_SUBTYPE_SH7300)
101# define SCI_NPORTS 1
102# define SCPCR 0xA4050116 /* 16 bit SCIF */ 99# define SCPCR 0xA4050116 /* 16 bit SCIF */
103# define SCPDR 0xA4050136 /* 16 bit SCIF */ 100# define SCPDR 0xA4050136 /* 16 bit SCIF */
104# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ 101# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
105# define SCIF_ONLY 102# define SCIF_ONLY
106#elif defined(CONFIG_CPU_SUBTYPE_SH73180) 103#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
107# define SCI_NPORTS 1
108# define SCPDR 0xA4050138 /* 16 bit SCIF */ 104# define SCPDR 0xA4050138 /* 16 bit SCIF */
109# define SCSPTR2 SCPDR 105# define SCSPTR2 SCPDR
110# define SCIF_ORER 0x0001 /* overrun error bit */ 106# define SCIF_ORER 0x0001 /* overrun error bit */
111# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */ 107# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */
112# define SCIF_ONLY 108# define SCIF_ONLY
113#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 109#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
114# define SCI_NPORTS 1
115# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 110# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
116# define SCIF_ORER 0x0001 /* overrun error bit */ 111# define SCIF_ORER 0x0001 /* overrun error bit */
117# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 112# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
118# define SCIF_ONLY 113# define SCIF_ONLY
119#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 114#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
120# define SCI_NPORTS 2
121# define SCSPTR1 0xffe00020 /* 16 bit SCIF */ 115# define SCSPTR1 0xffe00020 /* 16 bit SCIF */
122# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 116# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
123# define SCIF_ORER 0x0001 /* overrun error bit */ 117# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -129,26 +123,32 @@
129# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR 123# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
130# define SCIF_PTR2_OFFS 0x0000020 124# define SCIF_PTR2_OFFS 0x0000020
131# define SCIF_LSR2_OFFS 0x0000024 125# define SCIF_LSR2_OFFS 0x0000024
132# define SCI_NPORTS 1
133# define SCI_INIT { \
134 { {}, PORT_SCIF, 0, \
135 SH5_SCIF_IRQS, sci_init_pins_scif } \
136}
137# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ 126# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */
138# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ 127# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */
139# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, 128# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,
140 TE=1,RE=1,REIE=1 */ 129 TE=1,RE=1,REIE=1 */
141# define SCIF_ONLY 130# define SCIF_ONLY
142#elif defined(CONFIG_H83007) || defined(CONFIG_H83068) 131#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
143# define SCI_NPORTS 3
144# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 132# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
145# define SCI_ONLY 133# define SCI_ONLY
146# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) 134# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
147#elif defined(CONFIG_H8S2678) 135#elif defined(CONFIG_H8S2678)
148# define SCI_NPORTS 3
149# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 136# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
150# define SCI_ONLY 137# define SCI_ONLY
151# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) 138# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
139#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
140# define SCSPTR0 0xff923020 /* 16 bit SCIF */
141# define SCSPTR1 0xff924020 /* 16 bit SCIF */
142# define SCSPTR2 0xff925020 /* 16 bit SCIF */
143# define SCIF_ORER 0x0001 /* overrun error bit */
144# define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */
145# define SCIF_ONLY
146#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
147# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
148# define SCSPTR1 0xffe10024 /* 16 bit SCIF */
149# define SCIF_OPER 0x0001 /* Overrun error bit */
150# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
151# define SCIF_ONLY
152#else 152#else
153# error CPU subtype not defined 153# error CPU subtype not defined
154#endif 154#endif
@@ -158,7 +158,7 @@
158#define SCI_CTRL_FLAGS_RIE 0x40 /* all */ 158#define SCI_CTRL_FLAGS_RIE 0x40 /* all */
159#define SCI_CTRL_FLAGS_TE 0x20 /* all */ 159#define SCI_CTRL_FLAGS_TE 0x20 /* all */
160#define SCI_CTRL_FLAGS_RE 0x10 /* all */ 160#define SCI_CTRL_FLAGS_RE 0x10 /* all */
161#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) 161#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7780)
162#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ 162#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
163#else 163#else
164#define SCI_CTRL_FLAGS_REIE 0 164#define SCI_CTRL_FLAGS_REIE 0
@@ -213,7 +213,7 @@
213# define SCxSR_RDxF_CLEAR(port) 0xbc 213# define SCxSR_RDxF_CLEAR(port) 0xbc
214# define SCxSR_ERROR_CLEAR(port) 0xc4 214# define SCxSR_ERROR_CLEAR(port) 0xc4
215# define SCxSR_TDxE_CLEAR(port) 0x78 215# define SCxSR_TDxE_CLEAR(port) 0x78
216# define SCxSR_BREAK_CLEAR(port) 0xc4 216# define SCxSR_BREAK_CLEAR(port) 0xc4
217#elif defined(SCIF_ONLY) 217#elif defined(SCIF_ONLY)
218# define SCxSR_TEND(port) SCIF_TEND 218# define SCxSR_TEND(port) SCIF_TEND
219# define SCxSR_ERRORS(port) SCIF_ERRORS 219# define SCxSR_ERRORS(port) SCIF_ERRORS
@@ -237,7 +237,7 @@
237# define SCxSR_RDxF_CLEAR(port) 0x00fc 237# define SCxSR_RDxF_CLEAR(port) 0x00fc
238# define SCxSR_ERROR_CLEAR(port) 0x0073 238# define SCxSR_ERROR_CLEAR(port) 0x0073
239# define SCxSR_TDxE_CLEAR(port) 0x00df 239# define SCxSR_TDxE_CLEAR(port) 0x00df
240# define SCxSR_BREAK_CLEAR(port) 0x00e3 240# define SCxSR_BREAK_CLEAR(port) 0x00e3
241#endif 241#endif
242#else 242#else
243# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) 243# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
@@ -285,14 +285,14 @@ struct sci_port {
285 285
286#define SCI_IN(size, offset) \ 286#define SCI_IN(size, offset) \
287 unsigned int addr = port->mapbase + (offset); \ 287 unsigned int addr = port->mapbase + (offset); \
288 if ((size) == 8) { \ 288 if ((size) == 8) { \
289 return ctrl_inb(addr); \ 289 return ctrl_inb(addr); \
290 } else { \ 290 } else { \
291 return ctrl_inw(addr); \ 291 return ctrl_inw(addr); \
292 } 292 }
293#define SCI_OUT(size, offset, value) \ 293#define SCI_OUT(size, offset, value) \
294 unsigned int addr = port->mapbase + (offset); \ 294 unsigned int addr = port->mapbase + (offset); \
295 if ((size) == 8) { \ 295 if ((size) == 8) { \
296 ctrl_outb(value, addr); \ 296 ctrl_outb(value, addr); \
297 } else { \ 297 } else { \
298 ctrl_outw(value, addr); \ 298 ctrl_outw(value, addr); \
@@ -301,10 +301,10 @@ struct sci_port {
301#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ 301#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
302 static inline unsigned int sci_##name##_in(struct uart_port *port) \ 302 static inline unsigned int sci_##name##_in(struct uart_port *port) \
303 { \ 303 { \
304 if (port->type == PORT_SCI) { \ 304 if (port->type == PORT_SCI) { \
305 SCI_IN(sci_size, sci_offset) \ 305 SCI_IN(sci_size, sci_offset) \
306 } else { \ 306 } else { \
307 SCI_IN(scif_size, scif_offset); \ 307 SCI_IN(scif_size, scif_offset); \
308 } \ 308 } \
309 } \ 309 } \
310 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ 310 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
@@ -319,7 +319,7 @@ struct sci_port {
319#define CPU_SCIF_FNS(name, scif_offset, scif_size) \ 319#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
320 static inline unsigned int sci_##name##_in(struct uart_port *port) \ 320 static inline unsigned int sci_##name##_in(struct uart_port *port) \
321 { \ 321 { \
322 SCI_IN(scif_size, scif_offset); \ 322 SCI_IN(scif_size, scif_offset); \
323 } \ 323 } \
324 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ 324 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
325 { \ 325 { \
@@ -329,7 +329,7 @@ struct sci_port {
329#define CPU_SCI_FNS(name, sci_offset, sci_size) \ 329#define CPU_SCI_FNS(name, sci_offset, sci_size) \
330 static inline unsigned int sci_##name##_in(struct uart_port* port) \ 330 static inline unsigned int sci_##name##_in(struct uart_port* port) \
331 { \ 331 { \
332 SCI_IN(sci_size, sci_offset); \ 332 SCI_IN(sci_size, sci_offset); \
333 } \ 333 } \
334 static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ 334 static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \
335 { \ 335 { \
@@ -385,10 +385,17 @@ SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
385SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) 385SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
386SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 386SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
387SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 387SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
388#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
389SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
390SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
391SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
392SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
393#else
388SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 394SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
389SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) 395SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
390SCIF_FNS(SCLSR, 0, 0, 0x24, 16) 396SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
391#endif 397#endif
398#endif
392#define sci_in(port, reg) sci_##reg##_in(port) 399#define sci_in(port, reg) sci_##reg##_in(port)
393#define sci_out(port, reg, value) sci_##reg##_out(port, value) 400#define sci_out(port, reg, value) sci_##reg##_out(port, value)
394 401
@@ -518,6 +525,24 @@ static inline int sci_rxd_in(struct uart_port *port)
518 int ch = (port->mapbase - SMR0) >> 3; 525 int ch = (port->mapbase - SMR0) >> 3;
519 return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; 526 return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
520} 527}
528#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
529static inline int sci_rxd_in(struct uart_port *port)
530{
531 if (port->mapbase == 0xff923000)
532 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
533 if (port->mapbase == 0xff924000)
534 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
535 if (port->mapbase == 0xff925000)
536 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
537}
538#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
539static inline int sci_rxd_in(struct uart_port *port)
540{
541 if (port->mapbase == 0xffe00000)
542 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
543 if (port->mapbase == 0xffe10000)
544 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
545}
521#endif 546#endif
522 547
523/* 548/*
@@ -552,22 +577,15 @@ static inline int sci_rxd_in(struct uart_port *port)
552 * -- Mitch Davis - 15 Jul 2000 577 * -- Mitch Davis - 15 Jul 2000
553 */ 578 */
554 579
555#define PCLK (current_cpu_data.module_clock) 580#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7780)
556 581#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
557#if defined(CONFIG_CPU_SUBTYPE_SH7300)
558#define SCBRR_VALUE(bps) ((PCLK+16*bps)/(16*bps)-1)
559#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 582#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
560#define SCBRR_VALUE(bps) (((PCLK*2)+16*bps)/(32*bps)-1) 583#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
561#elif !defined(__H8300H__) && !defined(__H8300S__) 584#elif defined(__H8300H__) || defined(__H8300S__)
562#define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1)
563#else
564#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) 585#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
586#elif defined(CONFIG_SUPERH64)
587#define SCBRR_VALUE(bps) ((current_cpu_data.module_clock+16*bps)/(32*bps)-1)
588#else /* Generic SH */
589#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
565#endif 590#endif
566#define BPS_2400 SCBRR_VALUE(2400)
567#define BPS_4800 SCBRR_VALUE(4800)
568#define BPS_9600 SCBRR_VALUE(9600)
569#define BPS_19200 SCBRR_VALUE(19200)
570#define BPS_38400 SCBRR_VALUE(38400)
571#define BPS_57600 SCBRR_VALUE(57600)
572#define BPS_115200 SCBRR_VALUE(115200)
573 591
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c
index aaa009f4a7bf..c70ae81b5d98 100644
--- a/drivers/sn/ioc3.c
+++ b/drivers/sn/ioc3.c
@@ -843,9 +843,9 @@ MODULE_AUTHOR("Stanislaw Skowronek <skylark@linux-mips.org>");
843MODULE_DESCRIPTION("PCI driver for SGI IOC3"); 843MODULE_DESCRIPTION("PCI driver for SGI IOC3");
844MODULE_LICENSE("GPL"); 844MODULE_LICENSE("GPL");
845 845
846EXPORT_SYMBOL(ioc3_register_submodule); 846EXPORT_SYMBOL_GPL(ioc3_register_submodule);
847EXPORT_SYMBOL(ioc3_unregister_submodule); 847EXPORT_SYMBOL_GPL(ioc3_unregister_submodule);
848EXPORT_SYMBOL(ioc3_ack); 848EXPORT_SYMBOL_GPL(ioc3_ack);
849EXPORT_SYMBOL(ioc3_gpcr_set); 849EXPORT_SYMBOL_GPL(ioc3_gpcr_set);
850EXPORT_SYMBOL(ioc3_disable); 850EXPORT_SYMBOL_GPL(ioc3_disable);
851EXPORT_SYMBOL(ioc3_enable); 851EXPORT_SYMBOL_GPL(ioc3_enable);
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index f6704688ee8c..5578a9dd04e8 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -3558,10 +3558,16 @@ static void ixj_write_frame(IXJ *j)
3558 } 3558 }
3559 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */ 3559 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
3560 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) { 3560 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3561 if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 && 3561 if (j->write_buffer_rp[cnt] == 0 &&
3562 j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 && 3562 j->write_buffer_rp[cnt + 1] == 0 &&
3563 j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 && 3563 j->write_buffer_rp[cnt + 2] == 0 &&
3564 j->write_buffer_rp + cnt + 9 == 0) { 3564 j->write_buffer_rp[cnt + 3] == 0 &&
3565 j->write_buffer_rp[cnt + 4] == 0 &&
3566 j->write_buffer_rp[cnt + 5] == 0 &&
3567 j->write_buffer_rp[cnt + 6] == 0 &&
3568 j->write_buffer_rp[cnt + 7] == 0 &&
3569 j->write_buffer_rp[cnt + 8] == 0 &&
3570 j->write_buffer_rp[cnt + 9] == 0) {
3565 /* someone is trying to write silence lets make this a type 0 frame. */ 3571 /* someone is trying to write silence lets make this a type 0 frame. */
3566 outb_p(0x00, j->DSPbase + 0x0C); 3572 outb_p(0x00, j->DSPbase + 0x0C);
3567 outb_p(0x00, j->DSPbase + 0x0D); 3573 outb_p(0x00, j->DSPbase + 0x0D);
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 996d543d6609..9d996f2c10d5 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -50,3 +50,11 @@ config BACKLIGHT_CORGI
50 If you have a Sharp Zaurus SL-C7xx, say y to enable the 50 If you have a Sharp Zaurus SL-C7xx, say y to enable the
51 backlight driver. 51 backlight driver.
52 52
53config BACKLIGHT_HP680
54 tristate "HP Jornada 680 Backlight Driver"
55 depends on BACKLIGHT_DEVICE && SH_HP6XX
56 default y
57 help
58 If you have a HP Jornada 680, say y to enable the
59 backlight driver.
60
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 4af321fae390..744210c38e74 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -3,4 +3,5 @@
3obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o 3obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o
4obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o 4obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
5obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o 5obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
6obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
6obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o 7obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
new file mode 100644
index 000000000000..95da4c9ed1f1
--- /dev/null
+++ b/drivers/video/backlight/hp680_bl.c
@@ -0,0 +1,189 @@
1/*
2 * Backlight Driver for HP Jornada 680
3 *
4 * Copyright (c) 2005 Andriy Skulysh
5 *
6 * Based on Sharp's Corgi Backlight Driver
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/spinlock.h>
18#include <linux/fb.h>
19#include <linux/backlight.h>
20
21#include <asm/cpu/dac.h>
22#include <asm/hp6xx/hp6xx.h>
23#include <asm/hd64461/hd64461.h>
24
25#define HP680_MAX_INTENSITY 255
26#define HP680_DEFAULT_INTENSITY 10
27
28static int hp680bl_powermode = FB_BLANK_UNBLANK;
29static int current_intensity = 0;
30static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED;
31
32static void hp680bl_send_intensity(int intensity)
33{
34 unsigned long flags;
35
36 if (hp680bl_powermode != FB_BLANK_UNBLANK)
37 intensity = 0;
38
39 spin_lock_irqsave(&bl_lock, flags);
40 sh_dac_output(255-(u8)intensity, DAC_LCD_BRIGHTNESS);
41 spin_unlock_irqrestore(&bl_lock, flags);
42}
43
44static void hp680bl_blank(int blank)
45{
46 u16 v;
47
48 switch(blank) {
49
50 case FB_BLANK_NORMAL:
51 case FB_BLANK_VSYNC_SUSPEND:
52 case FB_BLANK_HSYNC_SUSPEND:
53 case FB_BLANK_POWERDOWN:
54 if (hp680bl_powermode == FB_BLANK_UNBLANK) {
55 hp680bl_send_intensity(0);
56 hp680bl_powermode = blank;
57 sh_dac_disable(DAC_LCD_BRIGHTNESS);
58 v = inw(HD64461_GPBDR);
59 v |= HD64461_GPBDR_LCDOFF;
60 outw(v, HD64461_GPBDR);
61 }
62 break;
63 case FB_BLANK_UNBLANK:
64 if (hp680bl_powermode != FB_BLANK_UNBLANK) {
65 sh_dac_enable(DAC_LCD_BRIGHTNESS);
66 v = inw(HD64461_GPBDR);
67 v &= ~HD64461_GPBDR_LCDOFF;
68 outw(v, HD64461_GPBDR);
69 hp680bl_powermode = blank;
70 hp680bl_send_intensity(current_intensity);
71 }
72 break;
73 }
74}
75
76#ifdef CONFIG_PM
77static int hp680bl_suspend(struct device *dev, pm_message_t state, u32 level)
78{
79 if (level == SUSPEND_POWER_DOWN)
80 hp680bl_blank(FB_BLANK_POWERDOWN);
81 return 0;
82}
83
84static int hp680bl_resume(struct device *dev, u32 level)
85{
86 if (level == RESUME_POWER_ON)
87 hp680bl_blank(FB_BLANK_UNBLANK);
88 return 0;
89}
90#else
91#define hp680bl_suspend NULL
92#define hp680bl_resume NULL
93#endif
94
95
96static int hp680bl_set_power(struct backlight_device *bd, int state)
97{
98 hp680bl_blank(state);
99 return 0;
100}
101
102static int hp680bl_get_power(struct backlight_device *bd)
103{
104 return hp680bl_powermode;
105}
106
107static int hp680bl_set_intensity(struct backlight_device *bd, int intensity)
108{
109 if (intensity > HP680_MAX_INTENSITY)
110 intensity = HP680_MAX_INTENSITY;
111 hp680bl_send_intensity(intensity);
112 current_intensity = intensity;
113 return 0;
114}
115
116static int hp680bl_get_intensity(struct backlight_device *bd)
117{
118 return current_intensity;
119}
120
121static struct backlight_properties hp680bl_data = {
122 .owner = THIS_MODULE,
123 .get_power = hp680bl_get_power,
124 .set_power = hp680bl_set_power,
125 .max_brightness = HP680_MAX_INTENSITY,
126 .get_brightness = hp680bl_get_intensity,
127 .set_brightness = hp680bl_set_intensity,
128};
129
130static struct backlight_device *hp680_backlight_device;
131
132static int __init hp680bl_probe(struct device *dev)
133{
134 hp680_backlight_device = backlight_device_register ("hp680-bl",
135 NULL, &hp680bl_data);
136 if (IS_ERR (hp680_backlight_device))
137 return PTR_ERR (hp680_backlight_device);
138
139 hp680bl_set_intensity(NULL, HP680_DEFAULT_INTENSITY);
140
141 return 0;
142}
143
144static int hp680bl_remove(struct device *dev)
145{
146 backlight_device_unregister(hp680_backlight_device);
147
148 return 0;
149}
150
151static struct device_driver hp680bl_driver = {
152 .name = "hp680-bl",
153 .bus = &platform_bus_type,
154 .probe = hp680bl_probe,
155 .remove = hp680bl_remove,
156 .suspend = hp680bl_suspend,
157 .resume = hp680bl_resume,
158};
159
160static struct platform_device hp680bl_device = {
161 .name = "hp680-bl",
162 .id = -1,
163};
164
165static int __init hp680bl_init(void)
166{
167 int ret;
168
169 ret=driver_register(&hp680bl_driver);
170 if (!ret) {
171 ret = platform_device_register(&hp680bl_device);
172 if (ret)
173 driver_unregister(&hp680bl_driver);
174 }
175 return ret;
176}
177
178static void __exit hp680bl_exit(void)
179{
180 platform_device_unregister(&hp680bl_device);
181 driver_unregister(&hp680bl_driver);
182}
183
184module_init(hp680bl_init);
185module_exit(hp680bl_exit);
186
187MODULE_AUTHOR("Andriy Skulysh <askulysh@image.kiev.ua>");
188MODULE_DESCRIPTION("HP Jornada 680 Backlight Driver");
189MODULE_LICENSE("GPL");
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index bd410e06db73..e3c8b5f1ca76 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -191,11 +191,11 @@ int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn)
191 u8 *edid = NULL; 191 u8 *edid = NULL;
192 int i; 192 int i;
193 193
194 DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn); 194 DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn+1);
195 if (conn < 4) { 195 if (conn < par->ddc_num) {
196 for (i = 0; i < 3; i++) { 196 for (i = 0; i < 3; i++) {
197 /* Do the real work */ 197 /* Do the real work */
198 edid = i810_do_probe_i2c_edid(&par->chan[conn-1]); 198 edid = i810_do_probe_i2c_edid(&par->chan[conn]);
199 if (edid) 199 if (edid)
200 break; 200 break;
201 } 201 }
diff --git a/drivers/video/i810/i810.h b/drivers/video/i810/i810.h
index 6c187d5fe951..579195c2bea3 100644
--- a/drivers/video/i810/i810.h
+++ b/drivers/video/i810/i810.h
@@ -280,6 +280,7 @@ struct i810fb_par {
280 u32 blit_bpp; 280 u32 blit_bpp;
281 u32 ovract; 281 u32 ovract;
282 u32 cur_state; 282 u32 cur_state;
283 u32 ddc_num;
283 int mtrr_reg; 284 int mtrr_reg;
284 u16 bltcntl; 285 u16 bltcntl;
285 u8 interlace; 286 u8 interlace;
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 266d0ab92663..d8467c03b49f 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -149,6 +149,7 @@ static int vyres __devinitdata;
149static int sync __devinitdata; 149static int sync __devinitdata;
150static int extvga __devinitdata; 150static int extvga __devinitdata;
151static int dcolor __devinitdata; 151static int dcolor __devinitdata;
152static int ddc3 __devinitdata = 2;
152 153
153/*------------------------------------------------------------*/ 154/*------------------------------------------------------------*/
154 155
@@ -1763,6 +1764,8 @@ static void __devinit i810_init_defaults(struct i810fb_par *par,
1763 if (sync) 1764 if (sync)
1764 par->dev_flags |= ALWAYS_SYNC; 1765 par->dev_flags |= ALWAYS_SYNC;
1765 1766
1767 par->ddc_num = ddc3;
1768
1766 if (bpp < 8) 1769 if (bpp < 8)
1767 bpp = 8; 1770 bpp = 8;
1768 1771
@@ -1885,7 +1888,7 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info)
1885 int found = 0; 1888 int found = 0;
1886#ifdef CONFIG_FB_I810_I2C 1889#ifdef CONFIG_FB_I810_I2C
1887 int i; 1890 int i;
1888 int err; 1891 int err = 1;
1889 struct i810fb_par *par = info->par; 1892 struct i810fb_par *par = info->par;
1890#endif 1893#endif
1891 1894
@@ -1895,8 +1898,8 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info)
1895#ifdef CONFIG_FB_I810_I2C 1898#ifdef CONFIG_FB_I810_I2C
1896 i810_create_i2c_busses(par); 1899 i810_create_i2c_busses(par);
1897 1900
1898 for (i = 0; i < 4; i++) { 1901 for (i = 0; i < par->ddc_num + 1; i++) {
1899 err = i810_probe_i2c_connector(info, &par->edid, i+1); 1902 err = i810_probe_i2c_connector(info, &par->edid, i);
1900 if (!err) 1903 if (!err)
1901 break; 1904 break;
1902 } 1905 }
@@ -1983,6 +1986,8 @@ static int __devinit i810fb_setup(char *options)
1983 vsync2 = simple_strtoul(this_opt+7, NULL, 0); 1986 vsync2 = simple_strtoul(this_opt+7, NULL, 0);
1984 else if (!strncmp(this_opt, "dcolor", 6)) 1987 else if (!strncmp(this_opt, "dcolor", 6))
1985 dcolor = 1; 1988 dcolor = 1;
1989 else if (!strncmp(this_opt, "ddc3", 4))
1990 ddc3 = 3;
1986 else 1991 else
1987 mode_option = this_opt; 1992 mode_option = this_opt;
1988 } 1993 }
@@ -2190,6 +2195,8 @@ MODULE_PARM_DESC(sync, "wait for accel engine to finish drawing"
2190module_param(dcolor, bool, 0); 2195module_param(dcolor, bool, 0);
2191MODULE_PARM_DESC(dcolor, "use DirectColor visuals" 2196MODULE_PARM_DESC(dcolor, "use DirectColor visuals"
2192 " (default = 0 = TrueColor)"); 2197 " (default = 0 = TrueColor)");
2198module_param(ddc3, bool, 0);
2199MODULE_PARM_DESC(ddc3, "Probe DDC bus 3 (default = 0 = no)");
2193module_param(mode_option, charp, 0); 2200module_param(mode_option, charp, 0);
2194MODULE_PARM_DESC(mode_option, "Specify initial video mode"); 2201MODULE_PARM_DESC(mode_option, "Specify initial video mode");
2195 2202