@@ -88,46 +88,44 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
8888 }
8989 if ((s -> features & SS_CAP_STATIC_MAP ) && s -> io_offset ) {
9090 * base = s -> io_offset | (* base & 0x0fff );
91- s -> io [0 ].Attributes = attr ;
91+ s -> io [0 ].res -> flags = ( s -> io [ 0 ]. res -> flags & ~ IORESOURCE_BITS ) | ( attr & IORESOURCE_BITS ) ;
9292 return 0 ;
9393 }
9494 /* Check for an already-allocated window that must conflict with
9595 * what was asked for. It is a hack because it does not catch all
9696 * potential conflicts, just the most obvious ones.
9797 */
9898 for (i = 0 ; i < MAX_IO_WIN ; i ++ )
99- if ((s -> io [i ].NumPorts != 0 ) &&
100- ((s -> io [i ].BasePort & (align - 1 )) == * base ))
99+ if ((s -> io [i ].res ) &&
100+ ((s -> io [i ].res -> start & (align - 1 )) == * base ))
101101 return 1 ;
102102 for (i = 0 ; i < MAX_IO_WIN ; i ++ ) {
103- if (s -> io [i ].NumPorts == 0 ) {
103+ if (! s -> io [i ].res ) {
104104 s -> io [i ].res = pcmcia_find_io_region (* base , num , align , s );
105105 if (s -> io [i ].res ) {
106- s -> io [i ].Attributes = attr ;
107- s -> io [i ].BasePort = * base = s -> io [i ].res -> start ;
108- s -> io [i ].NumPorts = s -> io [ i ]. InUse = num ;
106+ * base = s -> io [i ].res -> start ;
107+ s -> io [i ].res -> flags = ( s -> io [i ].res -> flags & ~ IORESOURCE_BITS ) | ( attr & IORESOURCE_BITS ) ;
108+ s -> io [i ].InUse = num ;
109109 break ;
110110 } else
111111 return 1 ;
112- } else if (s -> io [i ].Attributes != attr )
112+ } else if (( s -> io [i ].res -> flags & IORESOURCE_BITS ) != ( attr & IORESOURCE_BITS ) )
113113 continue ;
114114 /* Try to extend top of window */
115- try = s -> io [i ].BasePort + s -> io [ i ]. NumPorts ;
115+ try = s -> io [i ].res -> end + 1 ;
116116 if ((* base == 0 ) || (* base == try ))
117117 if (pcmcia_adjust_io_region (s -> io [i ].res , s -> io [i ].res -> start ,
118118 s -> io [i ].res -> end + num , s ) == 0 ) {
119119 * base = try ;
120- s -> io [i ].NumPorts += num ;
121120 s -> io [i ].InUse += num ;
122121 break ;
123122 }
124123 /* Try to extend bottom of window */
125- try = s -> io [i ].BasePort - num ;
124+ try = s -> io [i ].res -> start - num ;
126125 if ((* base == 0 ) || (* base == try ))
127126 if (pcmcia_adjust_io_region (s -> io [i ].res , s -> io [i ].res -> start - num ,
128127 s -> io [i ].res -> end , s ) == 0 ) {
129- s -> io [i ].BasePort = * base = try ;
130- s -> io [i ].NumPorts += num ;
128+ * base = try ;
131129 s -> io [i ].InUse += num ;
132130 break ;
133131 }
@@ -142,12 +140,13 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
142140 int i ;
143141
144142 for (i = 0 ; i < MAX_IO_WIN ; i ++ ) {
145- if ((s -> io [i ].BasePort <= base ) &&
146- (s -> io [i ].BasePort + s -> io [i ].NumPorts >= base + num )) {
143+ if (!s -> io [i ].res )
144+ continue ;
145+ if ((s -> io [i ].res -> start <= base ) &&
146+ (s -> io [i ].res -> end >= base + num - 1 )) {
147147 s -> io [i ].InUse -= num ;
148148 /* Free the window if no one else is using it */
149149 if (s -> io [i ].InUse == 0 ) {
150- s -> io [i ].NumPorts = 0 ;
151150 release_resource (s -> io [i ].res );
152151 kfree (s -> io [i ].res );
153152 s -> io [i ].res = NULL ;
@@ -224,8 +223,8 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
224223 config -> AssignedIRQ = s -> irq .AssignedIRQ ;
225224 if (config -> AssignedIRQ )
226225 config -> Attributes |= CONF_ENABLE_IRQ ;
227- config -> BasePort1 = s -> io [0 ].BasePort ;
228- config -> NumPorts1 = s -> io [0 ].NumPorts ;
226+ config -> BasePort1 = s -> io [0 ].res -> start ;
227+ config -> NumPorts1 = s -> io [0 ].res -> end - config -> BasePort1 + 1 ;
229228 }
230229 return CS_SUCCESS ;
231230 }
@@ -468,7 +467,7 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
468467 }
469468 if (c -> state & CONFIG_IO_REQ )
470469 for (i = 0 ; i < MAX_IO_WIN ; i ++ ) {
471- if (s -> io [i ].NumPorts == 0 )
470+ if (! s -> io [i ].res )
472471 continue ;
473472 s -> io [i ].Config -- ;
474473 if (s -> io [i ].Config != 0 )
@@ -679,19 +678,19 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
679678 if (c -> state & CONFIG_IO_REQ ) {
680679 iomap .speed = io_speed ;
681680 for (i = 0 ; i < MAX_IO_WIN ; i ++ )
682- if (s -> io [i ].NumPorts != 0 ) {
681+ if (s -> io [i ].res ) {
683682 iomap .map = i ;
684683 iomap .flags = MAP_ACTIVE ;
685- switch (s -> io [i ].Attributes & IO_DATA_PATH_WIDTH ) {
684+ switch (s -> io [i ].res -> flags & IO_DATA_PATH_WIDTH ) {
686685 case IO_DATA_PATH_WIDTH_16 :
687686 iomap .flags |= MAP_16BIT ; break ;
688687 case IO_DATA_PATH_WIDTH_AUTO :
689688 iomap .flags |= MAP_AUTOSZ ; break ;
690689 default :
691690 break ;
692691 }
693- iomap .start = s -> io [i ].BasePort ;
694- iomap .stop = iomap . start + s -> io [i ].NumPorts - 1 ;
692+ iomap .start = s -> io [i ].res -> start ;
693+ iomap .stop = s -> io [i ].res -> end ;
695694 s -> ops -> set_io_map (s , & iomap );
696695 s -> io [i ].Config ++ ;
697696 }
0 commit comments