aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi/rsparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpacpi/rsparser.c')
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c131
1 files changed, 88 insertions, 43 deletions
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 46c791adb894..9a45c25b46d2 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -806,6 +806,13 @@ static void pnpacpi_encode_irq(struct pnp_dev *dev,
806 struct acpi_resource_irq *irq = &resource->data.irq; 806 struct acpi_resource_irq *irq = &resource->data.irq;
807 int triggering, polarity, shareable; 807 int triggering, polarity, shareable;
808 808
809 if (!pnp_resource_enabled(p)) {
810 irq->interrupt_count = 0;
811 dev_dbg(&dev->dev, " encode irq (%s)\n",
812 p ? "disabled" : "missing");
813 return;
814 }
815
809 decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); 816 decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable);
810 irq->triggering = triggering; 817 irq->triggering = triggering;
811 irq->polarity = polarity; 818 irq->polarity = polarity;
@@ -828,6 +835,13 @@ static void pnpacpi_encode_ext_irq(struct pnp_dev *dev,
828 struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq; 835 struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq;
829 int triggering, polarity, shareable; 836 int triggering, polarity, shareable;
830 837
838 if (!pnp_resource_enabled(p)) {
839 extended_irq->interrupt_count = 0;
840 dev_dbg(&dev->dev, " encode extended irq (%s)\n",
841 p ? "disabled" : "missing");
842 return;
843 }
844
831 decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable); 845 decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable);
832 extended_irq->producer_consumer = ACPI_CONSUMER; 846 extended_irq->producer_consumer = ACPI_CONSUMER;
833 extended_irq->triggering = triggering; 847 extended_irq->triggering = triggering;
@@ -848,6 +862,13 @@ static void pnpacpi_encode_dma(struct pnp_dev *dev,
848{ 862{
849 struct acpi_resource_dma *dma = &resource->data.dma; 863 struct acpi_resource_dma *dma = &resource->data.dma;
850 864
865 if (!pnp_resource_enabled(p)) {
866 dma->channel_count = 0;
867 dev_dbg(&dev->dev, " encode dma (%s)\n",
868 p ? "disabled" : "missing");
869 return;
870 }
871
851 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 872 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
852 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { 873 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
853 case IORESOURCE_DMA_TYPEA: 874 case IORESOURCE_DMA_TYPEA:
@@ -889,17 +910,21 @@ static void pnpacpi_encode_io(struct pnp_dev *dev,
889{ 910{
890 struct acpi_resource_io *io = &resource->data.io; 911 struct acpi_resource_io *io = &resource->data.io;
891 912
892 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 913 if (pnp_resource_enabled(p)) {
893 io->io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ? 914 /* Note: pnp_assign_port copies pnp_port->flags into p->flags */
894 ACPI_DECODE_16 : ACPI_DECODE_10; 915 io->io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ?
895 io->minimum = p->start; 916 ACPI_DECODE_16 : ACPI_DECODE_10;
896 io->maximum = p->end; 917 io->minimum = p->start;
897 io->alignment = 0; /* Correct? */ 918 io->maximum = p->end;
898 io->address_length = p->end - p->start + 1; 919 io->alignment = 0; /* Correct? */
899 920 io->address_length = p->end - p->start + 1;
900 dev_dbg(&dev->dev, " encode io %#llx-%#llx decode %#x\n", 921 } else {
901 (unsigned long long) p->start, (unsigned long long) p->end, 922 io->minimum = 0;
902 io->io_decode); 923 io->address_length = 0;
924 }
925
926 dev_dbg(&dev->dev, " encode io %#x-%#x decode %#x\n", io->minimum,
927 io->minimum + io->address_length - 1, io->io_decode);
903} 928}
904 929
905static void pnpacpi_encode_fixed_io(struct pnp_dev *dev, 930static void pnpacpi_encode_fixed_io(struct pnp_dev *dev,
@@ -908,11 +933,16 @@ static void pnpacpi_encode_fixed_io(struct pnp_dev *dev,
908{ 933{
909 struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io; 934 struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io;
910 935
911 fixed_io->address = p->start; 936 if (pnp_resource_enabled(p)) {
912 fixed_io->address_length = p->end - p->start + 1; 937 fixed_io->address = p->start;
938 fixed_io->address_length = p->end - p->start + 1;
939 } else {
940 fixed_io->address = 0;
941 fixed_io->address_length = 0;
942 }
913 943
914 dev_dbg(&dev->dev, " encode fixed_io %#llx-%#llx\n", 944 dev_dbg(&dev->dev, " encode fixed_io %#x-%#x\n", fixed_io->address,
915 (unsigned long long) p->start, (unsigned long long) p->end); 945 fixed_io->address + fixed_io->address_length - 1);
916} 946}
917 947
918static void pnpacpi_encode_mem24(struct pnp_dev *dev, 948static void pnpacpi_encode_mem24(struct pnp_dev *dev,
@@ -921,17 +951,22 @@ static void pnpacpi_encode_mem24(struct pnp_dev *dev,
921{ 951{
922 struct acpi_resource_memory24 *memory24 = &resource->data.memory24; 952 struct acpi_resource_memory24 *memory24 = &resource->data.memory24;
923 953
924 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 954 if (pnp_resource_enabled(p)) {
925 memory24->write_protect = 955 /* Note: pnp_assign_mem copies pnp_mem->flags into p->flags */
926 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 956 memory24->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ?
927 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 957 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
928 memory24->minimum = p->start; 958 memory24->minimum = p->start;
929 memory24->maximum = p->end; 959 memory24->maximum = p->end;
930 memory24->alignment = 0; 960 memory24->alignment = 0;
931 memory24->address_length = p->end - p->start + 1; 961 memory24->address_length = p->end - p->start + 1;
932 962 } else {
933 dev_dbg(&dev->dev, " encode mem24 %#llx-%#llx write_protect %#x\n", 963 memory24->minimum = 0;
934 (unsigned long long) p->start, (unsigned long long) p->end, 964 memory24->address_length = 0;
965 }
966
967 dev_dbg(&dev->dev, " encode mem24 %#x-%#x write_protect %#x\n",
968 memory24->minimum,
969 memory24->minimum + memory24->address_length - 1,
935 memory24->write_protect); 970 memory24->write_protect);
936} 971}
937 972
@@ -941,16 +976,21 @@ static void pnpacpi_encode_mem32(struct pnp_dev *dev,
941{ 976{
942 struct acpi_resource_memory32 *memory32 = &resource->data.memory32; 977 struct acpi_resource_memory32 *memory32 = &resource->data.memory32;
943 978
944 memory32->write_protect = 979 if (pnp_resource_enabled(p)) {
945 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 980 memory32->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ?
946 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 981 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
947 memory32->minimum = p->start; 982 memory32->minimum = p->start;
948 memory32->maximum = p->end; 983 memory32->maximum = p->end;
949 memory32->alignment = 0; 984 memory32->alignment = 0;
950 memory32->address_length = p->end - p->start + 1; 985 memory32->address_length = p->end - p->start + 1;
986 } else {
987 memory32->minimum = 0;
988 memory32->alignment = 0;
989 }
951 990
952 dev_dbg(&dev->dev, " encode mem32 %#llx-%#llx write_protect %#x\n", 991 dev_dbg(&dev->dev, " encode mem32 %#x-%#x write_protect %#x\n",
953 (unsigned long long) p->start, (unsigned long long) p->end, 992 memory32->minimum,
993 memory32->minimum + memory32->address_length - 1,
954 memory32->write_protect); 994 memory32->write_protect);
955} 995}
956 996
@@ -960,15 +1000,20 @@ static void pnpacpi_encode_fixed_mem32(struct pnp_dev *dev,
960{ 1000{
961 struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32; 1001 struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32;
962 1002
963 fixed_memory32->write_protect = 1003 if (pnp_resource_enabled(p)) {
964 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 1004 fixed_memory32->write_protect =
965 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 1005 p->flags & IORESOURCE_MEM_WRITEABLE ?
966 fixed_memory32->address = p->start; 1006 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
967 fixed_memory32->address_length = p->end - p->start + 1; 1007 fixed_memory32->address = p->start;
1008 fixed_memory32->address_length = p->end - p->start + 1;
1009 } else {
1010 fixed_memory32->address = 0;
1011 fixed_memory32->address_length = 0;
1012 }
968 1013
969 dev_dbg(&dev->dev, " encode fixed_mem32 %#llx-%#llx " 1014 dev_dbg(&dev->dev, " encode fixed_mem32 %#x-%#x write_protect %#x\n",
970 "write_protect %#x\n", 1015 fixed_memory32->address,
971 (unsigned long long) p->start, (unsigned long long) p->end, 1016 fixed_memory32->address + fixed_memory32->address_length - 1,
972 fixed_memory32->write_protect); 1017 fixed_memory32->write_protect);
973} 1018}
974 1019