aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/isapnp
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-04-28 18:34:32 -0400
committerLen Brown <len.brown@intel.com>2008-04-29 03:22:28 -0400
commit21855d69d1e3ace3efdb8159a4a7ab1ab98a6f19 (patch)
treebfa5bc70ab7dabe5e4117fde96199df6c05cd261 /drivers/pnp/isapnp
parent0a977f15469457d9a19eed992caf71995c674064 (diff)
PNP: add pnp_resource index for ISAPNP
Save the ISAPNP config register index in the struct pnp_resource. We need this because it is important to write ISAPNP configuration back to the same registers we read it from. For example, if we read valid regions from memory descriptors 0, 1, and 3, we'd better write them back to the same registers, without compressing them to descriptors 0, 1, and 2. This was previously guaranteed by using the index into the pnp_resource_table array as the ISAPNP config register index. However, I am removing those fixed-size arrays, so we need to save the ISAPNP register index elsewhere. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/isapnp')
-rw-r--r--drivers/pnp/isapnp/core.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index a62ecc6f13bd..f949a538ccde 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -931,6 +931,7 @@ EXPORT_SYMBOL(isapnp_write_byte);
931 931
932static int isapnp_read_resources(struct pnp_dev *dev) 932static int isapnp_read_resources(struct pnp_dev *dev)
933{ 933{
934 struct pnp_resource *pnp_res;
934 struct resource *res; 935 struct resource *res;
935 int tmp, ret; 936 int tmp, ret;
936 937
@@ -940,7 +941,9 @@ static int isapnp_read_resources(struct pnp_dev *dev)
940 ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); 941 ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1));
941 if (!ret) 942 if (!ret)
942 continue; 943 continue;
943 res = pnp_get_resource(dev, IORESOURCE_IO, tmp); 944 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp);
945 pnp_res->index = tmp;
946 res = &pnp_res->res;
944 res->start = ret; 947 res->start = ret;
945 res->flags = IORESOURCE_IO; 948 res->flags = IORESOURCE_IO;
946 } 949 }
@@ -949,7 +952,10 @@ static int isapnp_read_resources(struct pnp_dev *dev)
949 isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; 952 isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
950 if (!ret) 953 if (!ret)
951 continue; 954 continue;
952 res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); 955 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM,
956 tmp);
957 pnp_res->index = tmp;
958 res = &pnp_res->res;
953 res->start = ret; 959 res->start = ret;
954 res->flags = IORESOURCE_MEM; 960 res->flags = IORESOURCE_MEM;
955 } 961 }
@@ -959,7 +965,10 @@ static int isapnp_read_resources(struct pnp_dev *dev)
959 8); 965 8);
960 if (!ret) 966 if (!ret)
961 continue; 967 continue;
962 res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); 968 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ,
969 tmp);
970 pnp_res->index = tmp;
971 res = &pnp_res->res;
963 res->start = res->end = ret; 972 res->start = res->end = ret;
964 res->flags = IORESOURCE_IRQ; 973 res->flags = IORESOURCE_IRQ;
965 } 974 }
@@ -967,7 +976,10 @@ static int isapnp_read_resources(struct pnp_dev *dev)
967 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); 976 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
968 if (ret == 4) 977 if (ret == 4)
969 continue; 978 continue;
970 res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); 979 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA,
980 tmp);
981 pnp_res->index = tmp;
982 res = &pnp_res->res;
971 res->start = res->end = ret; 983 res->start = res->end = ret;
972 res->flags = IORESOURCE_DMA; 984 res->flags = IORESOURCE_DMA;
973 } 985 }
@@ -989,45 +1001,62 @@ static int isapnp_get_resources(struct pnp_dev *dev)
989 1001
990static int isapnp_set_resources(struct pnp_dev *dev) 1002static int isapnp_set_resources(struct pnp_dev *dev)
991{ 1003{
1004 struct pnp_resource *pnp_res;
992 struct resource *res; 1005 struct resource *res;
993 int tmp; 1006 int tmp, index;
994 1007
995 dev_dbg(&dev->dev, "set resources\n"); 1008 dev_dbg(&dev->dev, "set resources\n");
996 isapnp_cfg_begin(dev->card->number, dev->number); 1009 isapnp_cfg_begin(dev->card->number, dev->number);
997 dev->active = 1; 1010 dev->active = 1;
998 for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { 1011 for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
999 res = pnp_get_resource(dev, IORESOURCE_IO, tmp); 1012 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp);
1013 if (!pnp_res)
1014 continue;
1015 res = &pnp_res->res;
1000 if (pnp_resource_valid(res)) { 1016 if (pnp_resource_valid(res)) {
1017 index = pnp_res->index;
1001 dev_dbg(&dev->dev, " set io %d to %#llx\n", 1018 dev_dbg(&dev->dev, " set io %d to %#llx\n",
1002 tmp, (unsigned long long) res->start); 1019 index, (unsigned long long) res->start);
1003 isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), 1020 isapnp_write_word(ISAPNP_CFG_PORT + (index << 1),
1004 res->start); 1021 res->start);
1005 } 1022 }
1006 } 1023 }
1007 for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { 1024 for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
1008 res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); 1025 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, tmp);
1026 if (!pnp_res)
1027 continue;
1028 res = &pnp_res->res;
1009 if (pnp_resource_valid(res)) { 1029 if (pnp_resource_valid(res)) {
1010 int irq = res->start; 1030 int irq = res->start;
1011 if (irq == 2) 1031 if (irq == 2)
1012 irq = 9; 1032 irq = 9;
1013 dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq); 1033 index = pnp_res->index;
1014 isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq); 1034 dev_dbg(&dev->dev, " set irq %d to %d\n", index, irq);
1035 isapnp_write_byte(ISAPNP_CFG_IRQ + (index << 1), irq);
1015 } 1036 }
1016 } 1037 }
1017 for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { 1038 for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
1018 res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); 1039 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, tmp);
1040 if (!pnp_res)
1041 continue;
1042 res = &pnp_res->res;
1019 if (pnp_resource_valid(res)) { 1043 if (pnp_resource_valid(res)) {
1044 index = pnp_res->index;
1020 dev_dbg(&dev->dev, " set dma %d to %lld\n", 1045 dev_dbg(&dev->dev, " set dma %d to %lld\n",
1021 tmp, (unsigned long long) res->start); 1046 index, (unsigned long long) res->start);
1022 isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start); 1047 isapnp_write_byte(ISAPNP_CFG_DMA + index, res->start);
1023 } 1048 }
1024 } 1049 }
1025 for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { 1050 for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
1026 res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); 1051 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, tmp);
1052 if (!pnp_res)
1053 continue;
1054 res = &pnp_res->res;
1027 if (pnp_resource_valid(res)) { 1055 if (pnp_resource_valid(res)) {
1056 index = pnp_res->index;
1028 dev_dbg(&dev->dev, " set mem %d to %#llx\n", 1057 dev_dbg(&dev->dev, " set mem %d to %#llx\n",
1029 tmp, (unsigned long long) res->start); 1058 index, (unsigned long long) res->start);
1030 isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), 1059 isapnp_write_word(ISAPNP_CFG_MEM + (index << 3),
1031 (res->start >> 8) & 0xffff); 1060 (res->start >> 8) & 0xffff);
1032 } 1061 }
1033 } 1062 }