PCMCIA/i82092: add/remove spaces to improve readability
Improve the readability by adding whitespaces after commas and around comparative operations. Also change indentation of one comment block. While at it, remove trailing whitespaces and spaces before tabs. Co-developed-by: Lukas Panzer <lukas.panzer@fau.de> Signed-off-by: Lukas Panzer <lukas.panzer@fau.de> Signed-off-by: Simon Geis <simon.geis@fau.de> [linux@dominikbrodowski.net: fixup one additional definition] Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
parent
26a0a10419
commit
4839879f8a
@ -33,16 +33,16 @@ static const struct pci_device_id i82092aa_pci_ids[] = {
|
||||
MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);
|
||||
|
||||
static struct pci_driver i82092aa_pci_driver = {
|
||||
.name = "i82092aa",
|
||||
.id_table = i82092aa_pci_ids,
|
||||
.probe = i82092aa_pci_probe,
|
||||
.remove = i82092aa_pci_remove,
|
||||
.name = "i82092aa",
|
||||
.id_table = i82092aa_pci_ids,
|
||||
.probe = i82092aa_pci_probe,
|
||||
.remove = i82092aa_pci_remove,
|
||||
};
|
||||
|
||||
|
||||
/* the pccard structure and its functions */
|
||||
static struct pccard_operations i82092aa_operations = {
|
||||
.init = i82092aa_init,
|
||||
.init = i82092aa_init,
|
||||
.get_status = i82092aa_get_status,
|
||||
.set_socket = i82092aa_set_socket,
|
||||
.set_io_map = i82092aa_set_io_map,
|
||||
@ -53,11 +53,13 @@ static struct pccard_operations i82092aa_operations = {
|
||||
|
||||
struct socket_info {
|
||||
int number;
|
||||
int card_state; /* 0 = no socket,
|
||||
1 = empty socket,
|
||||
2 = card but not initialized,
|
||||
3 = operational card */
|
||||
unsigned int io_base; /* base io address of the socket */
|
||||
int card_state;
|
||||
/* 0 = no socket,
|
||||
* 1 = empty socket,
|
||||
* 2 = card but not initialized,
|
||||
* 3 = operational card
|
||||
*/
|
||||
unsigned int io_base; /* base io address of the socket */
|
||||
|
||||
struct pcmcia_socket socket;
|
||||
struct pci_dev *dev; /* The PCI device for the socket */
|
||||
@ -65,7 +67,7 @@ struct socket_info {
|
||||
|
||||
#define MAX_SOCKETS 4
|
||||
static struct socket_info sockets[MAX_SOCKETS];
|
||||
static int socket_count; /* shortcut */
|
||||
static int socket_count; /* shortcut */
|
||||
|
||||
|
||||
static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
@ -79,7 +81,7 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
|
||||
return ret;
|
||||
|
||||
pci_read_config_byte(dev, 0x40, &configbyte); /* PCI Configuration Control */
|
||||
switch(configbyte&6) {
|
||||
switch (configbyte&6) {
|
||||
case 0:
|
||||
socket_count = 2;
|
||||
break;
|
||||
@ -105,7 +107,7 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
|
||||
goto err_out_disable;
|
||||
}
|
||||
|
||||
for (i = 0;i<socket_count;i++) {
|
||||
for (i = 0; i < socket_count; i++) {
|
||||
sockets[i].card_state = 1; /* 1 = present but empty */
|
||||
sockets[i].io_base = pci_resource_start(dev, 0);
|
||||
sockets[i].socket.features |= SS_CAP_PCCARD;
|
||||
@ -137,7 +139,7 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
|
||||
goto err_out_free_res;
|
||||
}
|
||||
|
||||
for (i = 0; i<socket_count; i++) {
|
||||
for (i = 0; i < socket_count; i++) {
|
||||
sockets[i].socket.dev.parent = &dev->dev;
|
||||
sockets[i].socket.ops = &i82092aa_operations;
|
||||
sockets[i].socket.resource_ops = &pccard_nonstatic_ops;
|
||||
@ -152,7 +154,7 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
|
||||
|
||||
err_out_free_sockets:
|
||||
if (i) {
|
||||
for (i--;i>=0;i--) {
|
||||
for (i--; i >= 0; i--) {
|
||||
pcmcia_unregister_socket(&sockets[i].socket);
|
||||
}
|
||||
}
|
||||
@ -187,12 +189,12 @@ static unsigned char indirect_read(int socket, unsigned short reg)
|
||||
unsigned short int port;
|
||||
unsigned char val;
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&port_lock,flags);
|
||||
spin_lock_irqsave(&port_lock, flags);
|
||||
reg += socket * 0x40;
|
||||
port = sockets[socket].io_base;
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
val = inb(port+1);
|
||||
spin_unlock_irqrestore(&port_lock,flags);
|
||||
spin_unlock_irqrestore(&port_lock, flags);
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -202,15 +204,15 @@ static unsigned short indirect_read16(int socket, unsigned short reg)
|
||||
unsigned short int port;
|
||||
unsigned short tmp;
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&port_lock,flags);
|
||||
spin_lock_irqsave(&port_lock, flags);
|
||||
reg = reg + socket * 0x40;
|
||||
port = sockets[socket].io_base;
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
tmp = inb(port+1);
|
||||
reg++;
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
tmp = tmp | (inb(port+1)<<8);
|
||||
spin_unlock_irqrestore(&port_lock,flags);
|
||||
spin_unlock_irqrestore(&port_lock, flags);
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
@ -219,12 +221,12 @@ static void indirect_write(int socket, unsigned short reg, unsigned char value)
|
||||
{
|
||||
unsigned short int port;
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&port_lock,flags);
|
||||
spin_lock_irqsave(&port_lock, flags);
|
||||
reg = reg + socket * 0x40;
|
||||
port = sockets[socket].io_base;
|
||||
outb(reg,port);
|
||||
outb(value,port+1);
|
||||
spin_unlock_irqrestore(&port_lock,flags);
|
||||
outb(reg, port);
|
||||
outb(value, port+1);
|
||||
spin_unlock_irqrestore(&port_lock, flags);
|
||||
}
|
||||
|
||||
static void indirect_setbit(int socket, unsigned short reg, unsigned char mask)
|
||||
@ -232,15 +234,15 @@ static void indirect_setbit(int socket, unsigned short reg, unsigned char mask)
|
||||
unsigned short int port;
|
||||
unsigned char val;
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&port_lock,flags);
|
||||
spin_lock_irqsave(&port_lock, flags);
|
||||
reg = reg + socket * 0x40;
|
||||
port = sockets[socket].io_base;
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
val = inb(port+1);
|
||||
val |= mask;
|
||||
outb(reg,port);
|
||||
outb(val,port+1);
|
||||
spin_unlock_irqrestore(&port_lock,flags);
|
||||
outb(reg, port);
|
||||
outb(val, port+1);
|
||||
spin_unlock_irqrestore(&port_lock, flags);
|
||||
}
|
||||
|
||||
|
||||
@ -249,15 +251,15 @@ static void indirect_resetbit(int socket, unsigned short reg, unsigned char mask
|
||||
unsigned short int port;
|
||||
unsigned char val;
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&port_lock,flags);
|
||||
spin_lock_irqsave(&port_lock, flags);
|
||||
reg = reg + socket * 0x40;
|
||||
port = sockets[socket].io_base;
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
val = inb(port+1);
|
||||
val &= ~mask;
|
||||
outb(reg,port);
|
||||
outb(val,port+1);
|
||||
spin_unlock_irqrestore(&port_lock,flags);
|
||||
outb(reg, port);
|
||||
outb(val, port+1);
|
||||
spin_unlock_irqrestore(&port_lock, flags);
|
||||
}
|
||||
|
||||
static void indirect_write16(int socket, unsigned short reg, unsigned short value)
|
||||
@ -265,20 +267,20 @@ static void indirect_write16(int socket, unsigned short reg, unsigned short valu
|
||||
unsigned short int port;
|
||||
unsigned char val;
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&port_lock,flags);
|
||||
spin_lock_irqsave(&port_lock, flags);
|
||||
reg = reg + socket * 0x40;
|
||||
port = sockets[socket].io_base;
|
||||
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
val = value & 255;
|
||||
outb(val,port+1);
|
||||
outb(val, port+1);
|
||||
|
||||
reg++;
|
||||
|
||||
outb(reg,port);
|
||||
outb(reg, port);
|
||||
val = value>>8;
|
||||
outb(val,port+1);
|
||||
spin_unlock_irqrestore(&port_lock,flags);
|
||||
outb(val, port+1);
|
||||
spin_unlock_irqrestore(&port_lock, flags);
|
||||
}
|
||||
|
||||
/* simple helper functions */
|
||||
@ -287,7 +289,7 @@ static int cycle_time = 120;
|
||||
|
||||
static int to_cycles(int ns)
|
||||
{
|
||||
if (cycle_time!=0)
|
||||
if (cycle_time != 0)
|
||||
return ns/cycle_time;
|
||||
else
|
||||
return 0;
|
||||
@ -302,28 +304,28 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev)
|
||||
int loopcount = 0;
|
||||
int handled = 0;
|
||||
|
||||
unsigned int events, active=0;
|
||||
unsigned int events, active = 0;
|
||||
|
||||
/* enter("i82092aa_interrupt");*/
|
||||
|
||||
while (1) {
|
||||
loopcount++;
|
||||
if (loopcount>20) {
|
||||
if (loopcount > 20) {
|
||||
pr_err("i82092aa: infinite eventloop in interrupt\n");
|
||||
break;
|
||||
}
|
||||
|
||||
active = 0;
|
||||
|
||||
for (i=0;i<socket_count;i++) {
|
||||
for (i = 0; i < socket_count; i++) {
|
||||
int csc;
|
||||
if (sockets[i].card_state==0) /* Inactive socket, should not happen */
|
||||
if (sockets[i].card_state == 0) /* Inactive socket, should not happen */
|
||||
continue;
|
||||
|
||||
csc = indirect_read(i,I365_CSC); /* card status change register */
|
||||
csc = indirect_read(i, I365_CSC); /* card status change register */
|
||||
|
||||
if (csc==0) /* no events on this socket */
|
||||
continue;
|
||||
if (csc == 0) /* no events on this socket */
|
||||
continue;
|
||||
handled = 1;
|
||||
events = 0;
|
||||
|
||||
@ -331,9 +333,9 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev)
|
||||
events |= SS_DETECT;
|
||||
dev_info(&sockets[i].dev->dev,
|
||||
"Card detected in socket %i!\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
if (indirect_read(i,I365_INTCTL) & I365_PC_IOCARD) {
|
||||
if (indirect_read(i, I365_INTCTL) & I365_PC_IOCARD) {
|
||||
/* For IO/CARDS, bit 0 means "read the card" */
|
||||
events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0;
|
||||
} else {
|
||||
@ -349,9 +351,8 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev)
|
||||
active |= events;
|
||||
}
|
||||
|
||||
if (active==0) /* no more events to handle */
|
||||
if (active == 0) /* no more events to handle */
|
||||
break;
|
||||
|
||||
}
|
||||
return IRQ_RETVAL(handled);
|
||||
/* leave("i82092aa_interrupt");*/
|
||||
@ -366,14 +367,14 @@ static int card_present(int socketno)
|
||||
unsigned int val;
|
||||
enter("card_present");
|
||||
|
||||
if ((socketno<0) || (socketno >= MAX_SOCKETS))
|
||||
if ((socketno < 0) || (socketno >= MAX_SOCKETS))
|
||||
return 0;
|
||||
if (sockets[socketno].io_base == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
val = indirect_read(socketno, 1); /* Interface status register */
|
||||
if ((val&12)==12) {
|
||||
if ((val&12) == 12) {
|
||||
leave("card_present 1");
|
||||
return 1;
|
||||
}
|
||||
@ -385,34 +386,30 @@ static int card_present(int socketno)
|
||||
static void set_bridge_state(int sock)
|
||||
{
|
||||
enter("set_bridge_state");
|
||||
indirect_write(sock, I365_GBLCTL,0x00);
|
||||
indirect_write(sock, I365_GENCTL,0x00);
|
||||
indirect_write(sock, I365_GBLCTL, 0x00);
|
||||
indirect_write(sock, I365_GENCTL, 0x00);
|
||||
|
||||
indirect_setbit(sock, I365_INTCTL,0x08);
|
||||
indirect_setbit(sock, I365_INTCTL, 0x08);
|
||||
leave("set_bridge_state");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int i82092aa_init(struct pcmcia_socket *sock)
|
||||
{
|
||||
int i;
|
||||
struct resource res = { .start = 0, .end = 0x0fff };
|
||||
pccard_io_map io = { 0, 0, 0, 0, 1 };
|
||||
pccard_io_map io = { 0, 0, 0, 0, 1 };
|
||||
pccard_mem_map mem = { .res = &res, };
|
||||
|
||||
enter("i82092aa_init");
|
||||
enter("i82092aa_init");
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
io.map = i;
|
||||
i82092aa_set_io_map(sock, &io);
|
||||
for (i = 0; i < 2; i++) {
|
||||
io.map = i;
|
||||
i82092aa_set_io_map(sock, &io);
|
||||
}
|
||||
for (i = 0; i < 5; i++) {
|
||||
mem.map = i;
|
||||
i82092aa_set_mem_map(sock, &mem);
|
||||
for (i = 0; i < 5; i++) {
|
||||
mem.map = i;
|
||||
i82092aa_set_mem_map(sock, &mem);
|
||||
}
|
||||
|
||||
leave("i82092aa_init");
|
||||
@ -426,7 +423,7 @@ static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
|
||||
|
||||
enter("i82092aa_get_status");
|
||||
|
||||
status = indirect_read(sock,I365_STATUS); /* Interface Status Register */
|
||||
status = indirect_read(sock, I365_STATUS); /* Interface Status Register */
|
||||
*value = 0;
|
||||
|
||||
if ((status & I365_CS_DETECT) == I365_CS_DETECT) {
|
||||
@ -435,7 +432,7 @@ static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
|
||||
|
||||
/* IO cards have a different meaning of bits 0,1 */
|
||||
/* Also notice the inverse-logic on the bits */
|
||||
if (indirect_read(sock, I365_INTCTL) & I365_PC_IOCARD) {
|
||||
if (indirect_read(sock, I365_INTCTL) & I365_PC_IOCARD) {
|
||||
/* IO card */
|
||||
if (!(status & I365_CS_STSCHG))
|
||||
*value |= SS_STSCHG;
|
||||
@ -476,12 +473,12 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
|
||||
/* Values for the IGENC register */
|
||||
|
||||
reg = 0;
|
||||
if (!(state->flags & SS_RESET)) /* The reset bit has "inverse" logic */
|
||||
if (!(state->flags & SS_RESET)) /* The reset bit has "inverse" logic */
|
||||
reg = reg | I365_PC_RESET;
|
||||
if (state->flags & SS_IOCARD)
|
||||
reg = reg | I365_PC_IOCARD;
|
||||
|
||||
indirect_write(sock,I365_INTCTL,reg); /* IGENC, Interrupt and General Control Register */
|
||||
indirect_write(sock, I365_INTCTL, reg); /* IGENC, Interrupt and General Control Register */
|
||||
|
||||
/* Power registers */
|
||||
|
||||
@ -513,7 +510,6 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
switch (state->Vpp) {
|
||||
case 0:
|
||||
dev_info(&sock_info->dev->dev,
|
||||
@ -536,8 +532,8 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (reg != indirect_read(sock,I365_POWER)) /* only write if changed */
|
||||
indirect_write(sock,I365_POWER,reg);
|
||||
if (reg != indirect_read(sock, I365_POWER)) /* only write if changed */
|
||||
indirect_write(sock, I365_POWER, reg);
|
||||
|
||||
/* Enable specific interrupt events */
|
||||
|
||||
@ -560,8 +556,8 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
|
||||
|
||||
/* now write the value and clear the (probably bogus) pending stuff by doing a dummy read*/
|
||||
|
||||
indirect_write(sock,I365_CSCINT,reg);
|
||||
(void)indirect_read(sock,I365_CSC);
|
||||
indirect_write(sock, I365_CSCINT, reg);
|
||||
(void)indirect_read(sock, I365_CSC);
|
||||
|
||||
leave("i82092aa_set_socket");
|
||||
return 0;
|
||||
@ -583,7 +579,7 @@ static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_ma
|
||||
leave("i82092aa_set_io_map with invalid map");
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((io->start > 0xffff) || (io->stop > 0xffff) || (io->stop < io->start)){
|
||||
if ((io->start > 0xffff) || (io->stop > 0xffff) || (io->stop < io->start)) {
|
||||
leave("i82092aa_set_io_map with invalid io");
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -593,19 +589,19 @@ static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_ma
|
||||
indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_IO(map));
|
||||
|
||||
/* write the new values */
|
||||
indirect_write16(sock,I365_IO(map)+I365_W_START,io->start);
|
||||
indirect_write16(sock,I365_IO(map)+I365_W_STOP,io->stop);
|
||||
indirect_write16(sock, I365_IO(map)+I365_W_START, io->start);
|
||||
indirect_write16(sock, I365_IO(map)+I365_W_STOP, io->stop);
|
||||
|
||||
ioctl = indirect_read(sock,I365_IOCTL) & ~I365_IOCTL_MASK(map);
|
||||
ioctl = indirect_read(sock, I365_IOCTL) & ~I365_IOCTL_MASK(map);
|
||||
|
||||
if (io->flags & (MAP_16BIT|MAP_AUTOSZ))
|
||||
ioctl |= I365_IOCTL_16BIT(map);
|
||||
|
||||
indirect_write(sock,I365_IOCTL,ioctl);
|
||||
indirect_write(sock, I365_IOCTL, ioctl);
|
||||
|
||||
/* Turn the window back on if needed */
|
||||
if (io->flags & MAP_ACTIVE)
|
||||
indirect_setbit(sock,I365_ADDRWIN,I365_ENA_IO(map));
|
||||
indirect_setbit(sock, I365_ADDRWIN, I365_ENA_IO(map));
|
||||
|
||||
leave("i82092aa_set_io_map");
|
||||
return 0;
|
||||
@ -630,8 +626,8 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
|
||||
}
|
||||
|
||||
|
||||
if ( (mem->card_start > 0x3ffffff) || (region.start > region.end) ||
|
||||
(mem->speed > 1000) ) {
|
||||
if ((mem->card_start > 0x3ffffff) || (region.start > region.end) ||
|
||||
(mem->speed > 1000)) {
|
||||
leave("i82092aa_set_mem_map: invalid address / speed");
|
||||
dev_err(&sock_info->dev->dev,
|
||||
"invalid mem map for socket %i: %llx to %llx with a "
|
||||
@ -645,8 +641,7 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
|
||||
|
||||
/* Turn off the window before changing anything */
|
||||
if (indirect_read(sock, I365_ADDRWIN) & I365_ENA_MEM(map))
|
||||
indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_MEM(map));
|
||||
|
||||
indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_MEM(map));
|
||||
|
||||
/* write the start address */
|
||||
base = I365_MEM(map);
|
||||
@ -655,11 +650,11 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
|
||||
i |= I365_MEM_16BIT;
|
||||
if (mem->flags & MAP_0WS)
|
||||
i |= I365_MEM_0WS;
|
||||
indirect_write16(sock,base+I365_W_START,i);
|
||||
indirect_write16(sock, base+I365_W_START, i);
|
||||
|
||||
/* write the stop address */
|
||||
|
||||
i= (region.end >> 12) & 0x0fff;
|
||||
i = (region.end >> 12) & 0x0fff;
|
||||
switch (to_cycles(mem->speed)) {
|
||||
case 0:
|
||||
break;
|
||||
@ -674,7 +669,7 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
|
||||
break;
|
||||
}
|
||||
|
||||
indirect_write16(sock,base+I365_W_STOP,i);
|
||||
indirect_write16(sock, base+I365_W_STOP, i);
|
||||
|
||||
/* card start */
|
||||
|
||||
@ -683,7 +678,7 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
|
||||
i |= I365_MEM_WRPROT;
|
||||
if (mem->flags & MAP_ATTRIB)
|
||||
i |= I365_MEM_REG;
|
||||
indirect_write16(sock,base+I365_W_OFF,i);
|
||||
indirect_write16(sock, base+I365_W_OFF, i);
|
||||
|
||||
/* Enable the window if necessary */
|
||||
if (mem->flags & MAP_ACTIVE)
|
||||
@ -702,7 +697,7 @@ static void i82092aa_module_exit(void)
|
||||
{
|
||||
enter("i82092aa_module_exit");
|
||||
pci_unregister_driver(&i82092aa_pci_driver);
|
||||
if (sockets[0].io_base>0)
|
||||
if (sockets[0].io_base > 0)
|
||||
release_region(sockets[0].io_base, 2);
|
||||
leave("i82092aa_module_exit");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user