aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/isapnp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/isapnp')
-rw-r--r--drivers/pnp/isapnp/core.c84
1 files changed, 29 insertions, 55 deletions
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index f1bccdbdeb08..752b51fbaa6c 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -928,7 +928,6 @@ EXPORT_SYMBOL(isapnp_write_byte);
928 928
929static int isapnp_get_resources(struct pnp_dev *dev) 929static int isapnp_get_resources(struct pnp_dev *dev)
930{ 930{
931 struct pnp_resource *pnp_res;
932 int i, ret; 931 int i, ret;
933 932
934 dev_dbg(&dev->dev, "get resources\n"); 933 dev_dbg(&dev->dev, "get resources\n");
@@ -940,35 +939,23 @@ static int isapnp_get_resources(struct pnp_dev *dev)
940 939
941 for (i = 0; i < ISAPNP_MAX_PORT; i++) { 940 for (i = 0; i < ISAPNP_MAX_PORT; i++) {
942 ret = isapnp_read_word(ISAPNP_CFG_PORT + (i << 1)); 941 ret = isapnp_read_word(ISAPNP_CFG_PORT + (i << 1));
943 if (ret) { 942 pnp_add_io_resource(dev, ret, ret,
944 pnp_res = pnp_add_io_resource(dev, ret, ret, 0); 943 ret == 0 ? IORESOURCE_DISABLED : 0);
945 if (pnp_res)
946 pnp_res->index = i;
947 }
948 } 944 }
949 for (i = 0; i < ISAPNP_MAX_MEM; i++) { 945 for (i = 0; i < ISAPNP_MAX_MEM; i++) {
950 ret = isapnp_read_word(ISAPNP_CFG_MEM + (i << 3)) << 8; 946 ret = isapnp_read_word(ISAPNP_CFG_MEM + (i << 3)) << 8;
951 if (ret) { 947 pnp_add_mem_resource(dev, ret, ret,
952 pnp_res = pnp_add_mem_resource(dev, ret, ret, 0); 948 ret == 0 ? IORESOURCE_DISABLED : 0);
953 if (pnp_res)
954 pnp_res->index = i;
955 }
956 } 949 }
957 for (i = 0; i < ISAPNP_MAX_IRQ; i++) { 950 for (i = 0; i < ISAPNP_MAX_IRQ; i++) {
958 ret = isapnp_read_word(ISAPNP_CFG_IRQ + (i << 1)) >> 8; 951 ret = isapnp_read_word(ISAPNP_CFG_IRQ + (i << 1)) >> 8;
959 if (ret) { 952 pnp_add_irq_resource(dev, ret,
960 pnp_res = pnp_add_irq_resource(dev, ret, 0); 953 ret == 0 ? IORESOURCE_DISABLED : 0);
961 if (pnp_res)
962 pnp_res->index = i;
963 }
964 } 954 }
965 for (i = 0; i < ISAPNP_MAX_DMA; i++) { 955 for (i = 0; i < ISAPNP_MAX_DMA; i++) {
966 ret = isapnp_read_byte(ISAPNP_CFG_DMA + i); 956 ret = isapnp_read_byte(ISAPNP_CFG_DMA + i);
967 if (ret != 4) { 957 pnp_add_dma_resource(dev, ret,
968 pnp_res = pnp_add_dma_resource(dev, ret, 0); 958 ret == 4 ? IORESOURCE_DISABLED : 0);
969 if (pnp_res)
970 pnp_res->index = i;
971 }
972 } 959 }
973 960
974__end: 961__end:
@@ -978,62 +965,49 @@ __end:
978 965
979static int isapnp_set_resources(struct pnp_dev *dev) 966static int isapnp_set_resources(struct pnp_dev *dev)
980{ 967{
981 struct pnp_resource *pnp_res;
982 struct resource *res; 968 struct resource *res;
983 int tmp, index; 969 int tmp;
984 970
985 dev_dbg(&dev->dev, "set resources\n"); 971 dev_dbg(&dev->dev, "set resources\n");
986 isapnp_cfg_begin(dev->card->number, dev->number); 972 isapnp_cfg_begin(dev->card->number, dev->number);
987 dev->active = 1; 973 dev->active = 1;
988 for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { 974 for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
989 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp); 975 res = pnp_get_resource(dev, IORESOURCE_IO, tmp);
990 if (!pnp_res) 976 if (res && pnp_resource_valid(res) &&
991 continue; 977 !(res->flags & IORESOURCE_DISABLED)) {
992 res = &pnp_res->res;
993 if (pnp_resource_valid(res)) {
994 index = pnp_res->index;
995 dev_dbg(&dev->dev, " set io %d to %#llx\n", 978 dev_dbg(&dev->dev, " set io %d to %#llx\n",
996 index, (unsigned long long) res->start); 979 tmp, (unsigned long long) res->start);
997 isapnp_write_word(ISAPNP_CFG_PORT + (index << 1), 980 isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
998 res->start); 981 res->start);
999 } 982 }
1000 } 983 }
1001 for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { 984 for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
1002 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, tmp); 985 res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp);
1003 if (!pnp_res) 986 if (res && pnp_resource_valid(res) &&
1004 continue; 987 !(res->flags & IORESOURCE_DISABLED)) {
1005 res = &pnp_res->res;
1006 if (pnp_resource_valid(res)) {
1007 int irq = res->start; 988 int irq = res->start;
1008 if (irq == 2) 989 if (irq == 2)
1009 irq = 9; 990 irq = 9;
1010 index = pnp_res->index; 991 dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq);
1011 dev_dbg(&dev->dev, " set irq %d to %d\n", index, irq); 992 isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
1012 isapnp_write_byte(ISAPNP_CFG_IRQ + (index << 1), irq);
1013 } 993 }
1014 } 994 }
1015 for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { 995 for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
1016 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, tmp); 996 res = pnp_get_resource(dev, IORESOURCE_DMA, tmp);
1017 if (!pnp_res) 997 if (res && pnp_resource_valid(res) &&
1018 continue; 998 !(res->flags & IORESOURCE_DISABLED)) {
1019 res = &pnp_res->res;
1020 if (pnp_resource_valid(res)) {
1021 index = pnp_res->index;
1022 dev_dbg(&dev->dev, " set dma %d to %lld\n", 999 dev_dbg(&dev->dev, " set dma %d to %lld\n",
1023 index, (unsigned long long) res->start); 1000 tmp, (unsigned long long) res->start);
1024 isapnp_write_byte(ISAPNP_CFG_DMA + index, res->start); 1001 isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start);
1025 } 1002 }
1026 } 1003 }
1027 for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { 1004 for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
1028 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, tmp); 1005 res = pnp_get_resource(dev, IORESOURCE_MEM, tmp);
1029 if (!pnp_res) 1006 if (res && pnp_resource_valid(res) &&
1030 continue; 1007 !(res->flags & IORESOURCE_DISABLED)) {
1031 res = &pnp_res->res;
1032 if (pnp_resource_valid(res)) {
1033 index = pnp_res->index;
1034 dev_dbg(&dev->dev, " set mem %d to %#llx\n", 1008 dev_dbg(&dev->dev, " set mem %d to %#llx\n",
1035 index, (unsigned long long) res->start); 1009 tmp, (unsigned long long) res->start);
1036 isapnp_write_word(ISAPNP_CFG_MEM + (index << 3), 1010 isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
1037 (res->start >> 8) & 0xffff); 1011 (res->start >> 8) & 0xffff);
1038 } 1012 }
1039 } 1013 }