pcmcia: CodingStyle fixes

Fix several CodingStyle issues in drivers/pcmcia/ . checkpatch.pl no longer
reports errors in the PCMCIA core. The remaining warnings mostly relate to
wrong indent -- PCMCIA historically used 4 spaces --, to lines over 80
characters and to hundreds of typedefs. The cleanup of those will follow
in the future.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
Dominik Brodowski 2009-12-07 22:11:45 +01:00
parent e15c1c1f3f
commit 9fea84f46a
14 changed files with 481 additions and 383 deletions

View file

@ -27,8 +27,8 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/io.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/ss.h> #include <pcmcia/ss.h>
@ -127,7 +127,8 @@ static int cb_setup_cis_mem(struct pcmcia_socket * s, struct resource *res)
=====================================================================*/ =====================================================================*/
int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void *ptr) int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len,
void *ptr)
{ {
struct pci_dev *dev; struct pci_dev *dev;
struct resource *res; struct resource *res;
@ -214,7 +215,7 @@ int __ref cb_alloc(struct pcmcia_socket * s)
unsigned int max, pass; unsigned int max, pass;
s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0)); s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0));
// pcibios_fixup_bus(bus); /* pcibios_fixup_bus(bus); */
max = bus->secondary; max = bus->secondary;
for (pass = 0; pass < 2; pass++) for (pass = 0; pass < 2; pass++)

View file

@ -23,7 +23,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <asm/io.h> #include <linux/io.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
@ -421,8 +421,6 @@ typedef struct tuple_flags {
#define MFC_FN(f) (((tuple_flags *)(&(f)))->mfc_fn) #define MFC_FN(f) (((tuple_flags *)(&(f)))->mfc_fn)
#define SPACE(f) (((tuple_flags *)(&(f)))->space) #define SPACE(f) (((tuple_flags *)(&(f)))->space)
int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple);
int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
{ {
if (!s) if (!s)
@ -526,7 +524,8 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
/* End of chain? Follow long link if possible */ /* End of chain? Follow long link if possible */
if (link[0] == CISTPL_END) { if (link[0] == CISTPL_END) {
if ((ofs = follow_link(s, tuple)) < 0) ofs = follow_link(s, tuple);
if (ofs < 0)
return -ENOSPC; return -ENOSPC;
attr = SPACE(tuple->Flags); attr = SPACE(tuple->Flags);
read_cis_cache(s, attr, ofs, 2, link); read_cis_cache(s, attr, ofs, 2, link);
@ -638,15 +637,26 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device)
device->ndev = 0; device->ndev = 0;
for (i = 0; i < CISTPL_MAX_DEVICES; i++) { for (i = 0; i < CISTPL_MAX_DEVICES; i++) {
if (*p == 0xff) break; if (*p == 0xff)
break;
device->dev[i].type = (*p >> 4); device->dev[i].type = (*p >> 4);
device->dev[i].wp = (*p & 0x08) ? 1 : 0; device->dev[i].wp = (*p & 0x08) ? 1 : 0;
switch (*p & 0x07) { switch (*p & 0x07) {
case 0: device->dev[i].speed = 0; break; case 0:
case 1: device->dev[i].speed = 250; break; device->dev[i].speed = 0;
case 2: device->dev[i].speed = 200; break; break;
case 3: device->dev[i].speed = 150; break; case 1:
case 4: device->dev[i].speed = 100; break; device->dev[i].speed = 250;
break;
case 2:
device->dev[i].speed = 200;
break;
case 3:
device->dev[i].speed = 150;
break;
case 4:
device->dev[i].speed = 100;
break;
case 7: case 7:
if (++p == q) if (++p == q)
return -EINVAL; return -EINVAL;
@ -737,11 +747,13 @@ static int parse_strings(u_char *p, u_char *q, int max,
ns++; ns++;
for (;;) { for (;;) {
s[j++] = (*p == 0xff) ? '\0' : *p; s[j++] = (*p == 0xff) ? '\0' : *p;
if ((*p == '\0') || (*p == 0xff)) break; if ((*p == '\0') || (*p == 0xff))
break;
if (++p == q) if (++p == q)
return -EINVAL; return -EINVAL;
} }
if ((*p == 0xff) || (++p == q)) break; if ((*p == 0xff) || (++p == q))
break;
} }
if (found) { if (found) {
*found = ns; *found = ns;
@ -793,7 +805,8 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
q = p + tuple->TupleDataLen; q = p + tuple->TupleDataLen;
for (nid = 0; nid < CISTPL_MAX_DEVICES; nid++) { for (nid = 0; nid < CISTPL_MAX_DEVICES; nid++) {
if (p > q-2) break; if (p > q-2)
break;
jedec->id[nid].mfr = p[0]; jedec->id[nid].mfr = p[0];
jedec->id[nid].info = p[1]; jedec->id[nid].info = p[1];
p += 2; p += 2;
@ -880,17 +893,20 @@ static u_char *parse_power(u_char *p, u_char *q,
int i; int i;
u_int scale; u_int scale;
if (p == q) return NULL; if (p == q)
return NULL;
pwr->present = *p; pwr->present = *p;
pwr->flags = 0; pwr->flags = 0;
p++; p++;
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
if (pwr->present & (1<<i)) { if (pwr->present & (1<<i)) {
if (p == q) return NULL; if (p == q)
return NULL;
pwr->param[i] = POWER_CVT(*p); pwr->param[i] = POWER_CVT(*p);
scale = POWER_SCALE(*p); scale = POWER_SCALE(*p);
while (*p & 0x80) { while (*p & 0x80) {
if (++p == q) return NULL; if (++p == q)
return NULL;
if ((*p & 0x7f) < 100) if ((*p & 0x7f) < 100)
pwr->param[i] += (*p & 0x7f) * scale / 100; pwr->param[i] += (*p & 0x7f) * scale / 100;
else if (*p == 0x7d) else if (*p == 0x7d)
@ -914,24 +930,28 @@ static u_char *parse_timing(u_char *p, u_char *q,
{ {
u_char scale; u_char scale;
if (p == q) return NULL; if (p == q)
return NULL;
scale = *p; scale = *p;
if ((scale & 3) != 3) { if ((scale & 3) != 3) {
if (++p == q) return NULL; if (++p == q)
return NULL;
timing->wait = SPEED_CVT(*p); timing->wait = SPEED_CVT(*p);
timing->waitscale = exponent[scale & 3]; timing->waitscale = exponent[scale & 3];
} else } else
timing->wait = 0; timing->wait = 0;
scale >>= 2; scale >>= 2;
if ((scale & 7) != 7) { if ((scale & 7) != 7) {
if (++p == q) return NULL; if (++p == q)
return NULL;
timing->ready = SPEED_CVT(*p); timing->ready = SPEED_CVT(*p);
timing->rdyscale = exponent[scale & 7]; timing->rdyscale = exponent[scale & 7];
} else } else
timing->ready = 0; timing->ready = 0;
scale >>= 3; scale >>= 3;
if (scale != 7) { if (scale != 7) {
if (++p == q) return NULL; if (++p == q)
return NULL;
timing->reserved = SPEED_CVT(*p); timing->reserved = SPEED_CVT(*p);
timing->rsvscale = exponent[scale]; timing->rsvscale = exponent[scale];
} else } else
@ -946,7 +966,8 @@ static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
{ {
int i, j, bsz, lsz; int i, j, bsz, lsz;
if (p == q) return NULL; if (p == q)
return NULL;
io->flags = *p; io->flags = *p;
if (!(*p & 0x80)) { if (!(*p & 0x80)) {
@ -956,23 +977,28 @@ static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
return p+1; return p+1;
} }
if (++p == q) return NULL; if (++p == q)
return NULL;
io->nwin = (*p & 0x0f) + 1; io->nwin = (*p & 0x0f) + 1;
bsz = (*p & 0x30) >> 4; bsz = (*p & 0x30) >> 4;
if (bsz == 3) bsz++; if (bsz == 3)
bsz++;
lsz = (*p & 0xc0) >> 6; lsz = (*p & 0xc0) >> 6;
if (lsz == 3) lsz++; if (lsz == 3)
lsz++;
p++; p++;
for (i = 0; i < io->nwin; i++) { for (i = 0; i < io->nwin; i++) {
io->win[i].base = 0; io->win[i].base = 0;
io->win[i].len = 1; io->win[i].len = 1;
for (j = 0; j < bsz; j++, p++) { for (j = 0; j < bsz; j++, p++) {
if (p == q) return NULL; if (p == q)
return NULL;
io->win[i].base += *p << (j*8); io->win[i].base += *p << (j*8);
} }
for (j = 0; j < lsz; j++, p++) { for (j = 0; j < lsz; j++, p++) {
if (p == q) return NULL; if (p == q)
return NULL;
io->win[i].len += *p << (j*8); io->win[i].len += *p << (j*8);
} }
} }
@ -986,27 +1012,32 @@ static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem)
int i, j, asz, lsz, has_ha; int i, j, asz, lsz, has_ha;
u_int len, ca, ha; u_int len, ca, ha;
if (p == q) return NULL; if (p == q)
return NULL;
mem->nwin = (*p & 0x07) + 1; mem->nwin = (*p & 0x07) + 1;
lsz = (*p & 0x18) >> 3; lsz = (*p & 0x18) >> 3;
asz = (*p & 0x60) >> 5; asz = (*p & 0x60) >> 5;
has_ha = (*p & 0x80); has_ha = (*p & 0x80);
if (++p == q) return NULL; if (++p == q)
return NULL;
for (i = 0; i < mem->nwin; i++) { for (i = 0; i < mem->nwin; i++) {
len = ca = ha = 0; len = ca = ha = 0;
for (j = 0; j < lsz; j++, p++) { for (j = 0; j < lsz; j++, p++) {
if (p == q) return NULL; if (p == q)
return NULL;
len += *p << (j*8); len += *p << (j*8);
} }
for (j = 0; j < asz; j++, p++) { for (j = 0; j < asz; j++, p++) {
if (p == q) return NULL; if (p == q)
return NULL;
ca += *p << (j*8); ca += *p << (j*8);
} }
if (has_ha) if (has_ha)
for (j = 0; j < asz; j++, p++) { for (j = 0; j < asz; j++, p++) {
if (p == q) return NULL; if (p == q)
return NULL;
ha += *p << (j*8); ha += *p << (j*8);
} }
mem->win[i].len = len << 8; mem->win[i].len = len << 8;
@ -1281,7 +1312,8 @@ static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo)
q = p + tuple->TupleDataLen; q = p + tuple->TupleDataLen;
for (n = 0; n < CISTPL_MAX_DEVICES; n++) { for (n = 0; n < CISTPL_MAX_DEVICES; n++) {
if (p > q-6) break; if (p > q-6)
break;
geo->geo[n].buswidth = p[0]; geo->geo[n].buswidth = p[0];
geo->geo[n].erase_block = 1 << (p[1]-1); geo->geo[n].erase_block = 1 << (p[1]-1);
geo->geo[n].read_block = 1 << (p[2]-1); geo->geo[n].read_block = 1 << (p[2]-1);
@ -1332,7 +1364,8 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org)
return -EINVAL; return -EINVAL;
for (i = 0; i < 30; i++) { for (i = 0; i < 30; i++) {
org->desc[i] = *p; org->desc[i] = *p;
if (*p == '\0') break; if (*p == '\0')
break;
if (++p == q) if (++p == q)
return -EINVAL; return -EINVAL;
} }

View file

@ -145,7 +145,7 @@ struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt)
put_device(&skt->dev); put_device(&skt->dev);
return NULL; return NULL;
} }
return (skt); return skt;
} }
EXPORT_SYMBOL(pcmcia_get_socket); EXPORT_SYMBOL(pcmcia_get_socket);

View file

@ -325,7 +325,7 @@ put_module:
put_dev: put_dev:
if (ret) if (ret)
put_device(dev); put_device(dev);
return (ret); return ret;
} }
@ -630,7 +630,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
for (i = 0; i < no_funcs; i++) for (i = 0; i < no_funcs; i++)
pcmcia_device_add(s, i); pcmcia_device_add(s, i);
return (ret); return ret;
} }
@ -756,7 +756,7 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
release: release:
release_firmware(fw); release_firmware(fw);
return (ret); return ret;
} }
#else /* !CONFIG_PCMCIA_LOAD_CIS */ #else /* !CONFIG_PCMCIA_LOAD_CIS */
@ -865,7 +865,8 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
} }
static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { static int pcmcia_bus_match(struct device *dev, struct device_driver *drv)
{
struct pcmcia_device *p_dev = to_pcmcia_dev(dev); struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
struct pcmcia_driver *p_drv = to_pcmcia_drv(drv); struct pcmcia_driver *p_drv = to_pcmcia_drv(drv);
struct pcmcia_device_id *did = p_drv->id_table; struct pcmcia_device_id *did = p_drv->id_table;
@ -1042,7 +1043,8 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (!p_dev->prod_id[i]) if (!p_dev->prod_id[i])
continue; continue;
hash[i] = crc32(0,p_dev->prod_id[i],strlen(p_dev->prod_id[i])); hash[i] = crc32(0, p_dev->prod_id[i],
strlen(p_dev->prod_id[i]));
} }
return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
"pa%08Xpb%08Xpc%08Xpd%08X\n", "pa%08Xpb%08Xpc%08Xpd%08X\n",
@ -1329,7 +1331,7 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
if (ret) { if (ret) {
dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n"); dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n");
pcmcia_put_socket(socket); pcmcia_put_socket(socket);
return (ret); return ret;
} }
return 0; return 0;

View file

@ -88,12 +88,12 @@ static struct pcmcia_driver *get_pcmcia_driver(dev_info_t *dev_info)
p_drv = container_of(drv, struct pcmcia_driver, drv); p_drv = container_of(drv, struct pcmcia_driver, drv);
return (p_drv); return p_drv;
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static struct proc_dir_entry *proc_pccard = NULL; static struct proc_dir_entry *proc_pccard;
static int proc_read_drivers_callback(struct device_driver *driver, void *_m) static int proc_read_drivers_callback(struct device_driver *driver, void *_m)
{ {
@ -158,7 +158,8 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
#else #else
static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
{
return 0; return 0;
} }
@ -215,7 +216,7 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
} }
up_read(&pcmcia_socket_list_rwsem); up_read(&pcmcia_socket_list_rwsem);
return (ret); return ret;
} }
@ -558,7 +559,7 @@ rescan:
err_put: err_put:
pcmcia_put_socket(s); pcmcia_put_socket(s);
return (ret); return ret;
} /* bind_request */ } /* bind_request */
#ifdef CONFIG_CARDBUS #ifdef CONFIG_CARDBUS
@ -655,7 +656,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
err_put: err_put:
pcmcia_put_dev(p_dev); pcmcia_put_dev(p_dev);
return (ret); return ret;
} /* get_device_info */ } /* get_device_info */
@ -664,7 +665,7 @@ static int ds_open(struct inode *inode, struct file *file)
socket_t i = iminor(inode); socket_t i = iminor(inode);
struct pcmcia_socket *s; struct pcmcia_socket *s;
user_info_t *user; user_info_t *user;
static int warning_printed = 0; static int warning_printed;
int ret = 0; int ret = 0;
pr_debug("ds_open(socket %d)\n", i); pr_debug("ds_open(socket %d)\n", i);
@ -738,12 +739,13 @@ static int ds_release(struct inode *inode, struct file *file)
s = user->socket; s = user->socket;
/* Unlink user data structure */ /* Unlink user data structure */
if ((file->f_flags & O_ACCMODE) != O_RDONLY) { if ((file->f_flags & O_ACCMODE) != O_RDONLY)
s->pcmcia_state.busy = 0; s->pcmcia_state.busy = 0;
}
file->private_data = NULL; file->private_data = NULL;
for (link = &s->user; *link; link = &(*link)->next) for (link = &s->user; *link; link = &(*link)->next)
if (*link == user) break; if (*link == user)
break;
if (link == NULL) if (link == NULL)
goto out; goto out;
*link = user->next; *link = user->next;
@ -845,7 +847,8 @@ static int ds_ioctl(struct inode * inode, struct file * file,
return -EIO; return -EIO;
size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
if (size > sizeof(ds_ioctl_arg_t)) return -EINVAL; if (size > sizeof(ds_ioctl_arg_t))
return -EINVAL;
/* Permission check */ /* Permission check */
if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN)) if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN))
@ -1045,7 +1048,8 @@ static const struct file_operations ds_fops = {
.poll = ds_poll, .poll = ds_poll,
}; };
void __init pcmcia_setup_ioctl(void) { void __init pcmcia_setup_ioctl(void)
{
int i; int i;
/* Set up character device for user mode clients */ /* Set up character device for user mode clients */
@ -1064,7 +1068,8 @@ void __init pcmcia_setup_ioctl(void) {
} }
void __exit pcmcia_cleanup_ioctl(void) { void __exit pcmcia_cleanup_ioctl(void)
{
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
if (proc_pccard) { if (proc_pccard) {
remove_proc_entry("drivers", proc_pccard); remove_proc_entry("drivers", proc_pccard);

View file

@ -33,7 +33,7 @@
/* Access speed for IO windows */ /* Access speed for IO windows */
static int io_speed = 0; static int io_speed;
module_param(io_speed, int, 0444); module_param(io_speed, int, 0444);
@ -62,7 +62,8 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr,
num, align); num, align);
align = 0; align = 0;
} else } else
while (align && (align < num)) align <<= 1; while (align && (align < num))
align <<= 1;
} }
if (*base & ~(align-1)) { if (*base & ~(align-1)) {
dev_dbg(&s->dev, "odd IO request: base %#x align %#x\n", dev_dbg(&s->dev, "odd IO request: base %#x align %#x\n",
@ -383,9 +384,8 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
s->irq.AssignedIRQ = 0; s->irq.AssignedIRQ = 0;
} }
if (req->Handler) { if (req->Handler)
free_irq(req->AssignedIRQ, p_dev->priv); free_irq(req->AssignedIRQ, p_dev->priv);
}
#ifdef CONFIG_PCMCIA_PROBE #ifdef CONFIG_PCMCIA_PROBE
pcmcia_used_irq[req->AssignedIRQ]--; pcmcia_used_irq[req->AssignedIRQ]--;
@ -656,7 +656,8 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
type = IRQF_SHARED; type = IRQF_SHARED;
else if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) else if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)
type = IRQF_SHARED; type = IRQF_SHARED;
else printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n"); else
printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n");
#ifdef CONFIG_PCMCIA_PROBE #ifdef CONFIG_PCMCIA_PROBE
@ -788,7 +789,8 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
/* Allocate system memory window */ /* Allocate system memory window */
for (w = 0; w < MAX_WIN; w++) for (w = 0; w < MAX_WIN; w++)
if (!(s->state & SOCKET_WIN_REQ(w))) break; if (!(s->state & SOCKET_WIN_REQ(w)))
break;
if (w == MAX_WIN) { if (w == MAX_WIN) {
dev_dbg(&s->dev, "all windows are used already\n"); dev_dbg(&s->dev, "all windows are used already\n");
return -EINVAL; return -EINVAL;
@ -826,18 +828,19 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
s->state |= SOCKET_WIN_REQ(w); s->state |= SOCKET_WIN_REQ(w);
/* Return window handle */ /* Return window handle */
if (s->features & SS_CAP_STATIC_MAP) { if (s->features & SS_CAP_STATIC_MAP)
req->Base = win->static_start; req->Base = win->static_start;
} else { else
req->Base = win->res->start; req->Base = win->res->start;
}
*wh = w + 1; *wh = w + 1;
return 0; return 0;
} /* pcmcia_request_window */ } /* pcmcia_request_window */
EXPORT_SYMBOL(pcmcia_request_window); EXPORT_SYMBOL(pcmcia_request_window);
void pcmcia_disable_device(struct pcmcia_device *p_dev) { void pcmcia_disable_device(struct pcmcia_device *p_dev)
{
pcmcia_release_configuration(p_dev); pcmcia_release_configuration(p_dev);
pcmcia_release_io(p_dev, &p_dev->io); pcmcia_release_io(p_dev, &p_dev->io);
pcmcia_release_irq(p_dev, &p_dev->irq); pcmcia_release_irq(p_dev, &p_dev->irq);
@ -970,7 +973,7 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL, return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL,
&loop, pcmcia_do_loop_tuple); &loop, pcmcia_do_loop_tuple);
}; }
EXPORT_SYMBOL(pcmcia_loop_tuple); EXPORT_SYMBOL(pcmcia_loop_tuple);
@ -1000,7 +1003,7 @@ static int pcmcia_do_get_tuple(struct pcmcia_device *p_dev, tuple_t *tuple,
} else } else
dev_dbg(&p_dev->dev, "do_get_tuple: out of memory\n"); dev_dbg(&p_dev->dev, "do_get_tuple: out of memory\n");
return 0; return 0;
}; }
/** /**
* pcmcia_get_tuple() - get first tuple from CIS * pcmcia_get_tuple() - get first tuple from CIS
@ -1024,7 +1027,7 @@ size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
pcmcia_loop_tuple(p_dev, code, pcmcia_do_get_tuple, &get); pcmcia_loop_tuple(p_dev, code, pcmcia_do_get_tuple, &get);
return get.len; return get.len;
}; }
EXPORT_SYMBOL(pcmcia_get_tuple); EXPORT_SYMBOL(pcmcia_get_tuple);
@ -1057,7 +1060,7 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
dev->dev_addr[i] = tuple->TupleData[i+2]; dev->dev_addr[i] = tuple->TupleData[i+2];
return 0; return 0;
}; }
/** /**
* pcmcia_get_mac_from_cis() - read out MAC address from CISTPL_FUNCE * pcmcia_get_mac_from_cis() - read out MAC address from CISTPL_FUNCE
@ -1071,6 +1074,6 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, struct net_device *dev) int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, struct net_device *dev)
{ {
return pcmcia_loop_tuple(p_dev, CISTPL_FUNCE, pcmcia_do_get_mac, dev); return pcmcia_loop_tuple(p_dev, CISTPL_FUNCE, pcmcia_do_get_mac, dev);
}; }
EXPORT_SYMBOL(pcmcia_get_mac_from_cis); EXPORT_SYMBOL(pcmcia_get_mac_from_cis);

View file

@ -24,9 +24,9 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/io.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/ss.h> #include <pcmcia/ss.h>
@ -168,7 +168,8 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
q->num = base - q->base; q->num = base - q->base;
} else { } else {
/* Split the block into two pieces */ /* Split the block into two pieces */
p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); p = kmalloc(sizeof(struct resource_map),
GFP_KERNEL);
if (!p) { if (!p) {
printk(KERN_WARNING "out of memory to update resources\n"); printk(KERN_WARNING "out of memory to update resources\n");
return -ENOMEM; return -ENOMEM;
@ -212,26 +213,29 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
return; return;
} }
for (i = base, most = 0; i < base+num; i += 8) { for (i = base, most = 0; i < base+num; i += 8) {
res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe"); res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
if (!res) if (!res)
continue; continue;
hole = inb(i); hole = inb(i);
for (j = 1; j < 8; j++) for (j = 1; j < 8; j++)
if (inb(i+j) != hole) break; if (inb(i+j) != hole)
break;
free_region(res); free_region(res);
if ((j == 8) && (++b[hole] > b[most])) if ((j == 8) && (++b[hole] > b[most]))
most = hole; most = hole;
if (b[most] == 127) break; if (b[most] == 127)
break;
} }
kfree(b); kfree(b);
bad = any = 0; bad = any = 0;
for (i = base; i < base+num; i += 8) { for (i = base; i < base+num; i += 8) {
res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe"); res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
if (!res) if (!res)
continue; continue;
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
if (inb(i+j) != most) break; if (inb(i+j) != most)
break;
free_region(res); free_region(res);
if (j < 8) { if (j < 8) {
if (!any) if (!any)
@ -327,8 +331,9 @@ cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size)
unsigned int info1, info2; unsigned int info1, info2;
int ret = 0; int ret = 0;
res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe"); res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "PCMCIA memprobe");
res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe"); res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM,
"PCMCIA memprobe");
if (res1 && res2) { if (res1 && res2) {
ret = readable(s, res1, &info1); ret = readable(s, res1, &info1);
@ -347,8 +352,9 @@ checksum_match(struct pcmcia_socket *s, unsigned long base, unsigned long size)
struct resource *res1, *res2; struct resource *res1, *res2;
int a = -1, b = -1; int a = -1, b = -1;
res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe"); res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "PCMCIA memprobe");
res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe"); res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM,
"PCMCIA memprobe");
if (res1 && res2) { if (res1 && res2) {
a = checksum(s, res1); a = checksum(s, res1);
@ -399,14 +405,15 @@ static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s)
break; break;
} }
if (i != j) { if (i != j) {
if (!bad) printk(" excluding"); if (!bad)
printk(" excluding");
printk(" %#05lx-%#05lx", i, j-1); printk(" %#05lx-%#05lx", i, j-1);
sub_interval(&s_data->mem_db, i, j-i); sub_interval(&s_data->mem_db, i, j-i);
bad += j-i; bad += j-i;
} }
} }
printk(bad ? "\n" : " clean.\n"); printk(bad ? "\n" : " clean.\n");
return (num - bad); return num - bad;
} }
#ifdef CONFIG_PCMCIA_PROBE #ifdef CONFIG_PCMCIA_PROBE
@ -915,7 +922,7 @@ static ssize_t show_io_db(struct device *dev,
} }
mutex_unlock(&rsrc_mutex); mutex_unlock(&rsrc_mutex);
return (ret); return ret;
} }
static ssize_t store_io_db(struct device *dev, static ssize_t store_io_db(struct device *dev,
@ -932,7 +939,8 @@ static ssize_t store_io_db(struct device *dev,
ret = sscanf(buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); ret = sscanf(buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
add = REMOVE_MANAGED_RESOURCE; add = REMOVE_MANAGED_RESOURCE;
if (ret != 2) { if (ret != 2) {
ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); ret = sscanf(buf, "0x%lx - 0x%lx", &start_addr,
&end_addr);
add = ADD_MANAGED_RESOURCE; add = ADD_MANAGED_RESOURCE;
if (ret != 2) if (ret != 2)
return -EINVAL; return -EINVAL;
@ -970,7 +978,7 @@ static ssize_t show_mem_db(struct device *dev,
} }
mutex_unlock(&rsrc_mutex); mutex_unlock(&rsrc_mutex);
return (ret); return ret;
} }
static ssize_t store_mem_db(struct device *dev, static ssize_t store_mem_db(struct device *dev,
@ -987,7 +995,8 @@ static ssize_t store_mem_db(struct device *dev,
ret = sscanf(buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); ret = sscanf(buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
add = REMOVE_MANAGED_RESOURCE; add = REMOVE_MANAGED_RESOURCE;
if (ret != 2) { if (ret != 2) {
ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); ret = sscanf(buf, "0x%lx - 0x%lx", &start_addr,
&end_addr);
add = ADD_MANAGED_RESOURCE; add = ADD_MANAGED_RESOURCE;
if (ret != 2) if (ret != 2)
return -EINVAL; return -EINVAL;

View file

@ -278,7 +278,7 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off
free_tuple: free_tuple:
kfree(tuplebuffer); kfree(tuplebuffer);
return (ret); return ret;
} }
static ssize_t pccard_show_cis(struct kobject *kobj, static ssize_t pccard_show_cis(struct kobject *kobj,
@ -308,7 +308,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
count = pccard_extract_cis(s, buf, off, count); count = pccard_extract_cis(s, buf, off, count);
} }
return (count); return count;
} }
static ssize_t pccard_store_cis(struct kobject *kobj, static ssize_t pccard_store_cis(struct kobject *kobj,

View file

@ -16,13 +16,12 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/io.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/ss.h> #include <pcmcia/ss.h>
#include <pcmcia/cs.h> #include <pcmcia/cs.h>
#include <asm/io.h>
#include "yenta_socket.h" #include "yenta_socket.h"
#include "i82365.h" #include "i82365.h"
@ -237,24 +236,42 @@ static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
/* i82365SL-DF style */ /* i82365SL-DF style */
if (socket->flags & YENTA_16BIT_POWER_DF) { if (socket->flags & YENTA_16BIT_POWER_DF) {
switch (state->Vcc) { switch (state->Vcc) {
case 33: reg |= I365_VCC_3V; break; case 33:
case 50: reg |= I365_VCC_5V; break; reg |= I365_VCC_3V;
default: reg = 0; break; break;
case 50:
reg |= I365_VCC_5V;
break;
default:
reg = 0;
break;
} }
switch (state->Vpp) { switch (state->Vpp) {
case 33: case 33:
case 50: reg |= I365_VPP1_5V; break; case 50:
case 120: reg |= I365_VPP1_12V; break; reg |= I365_VPP1_5V;
break;
case 120:
reg |= I365_VPP1_12V;
break;
} }
} else { } else {
/* i82365SL-B style */ /* i82365SL-B style */
switch (state->Vcc) { switch (state->Vcc) {
case 50: reg |= I365_VCC_5V; break; case 50:
default: reg = 0; break; reg |= I365_VCC_5V;
break;
default:
reg = 0;
break;
} }
switch (state->Vpp) { switch (state->Vpp) {
case 50: reg |= I365_VPP1_5V | I365_VPP2_5V; break; case 50:
case 120: reg |= I365_VPP1_12V | I365_VPP2_12V; break; reg |= I365_VPP1_5V | I365_VPP2_5V;
break;
case 120:
reg |= I365_VPP1_12V | I365_VPP2_12V;
break;
} }
} }
@ -263,14 +280,26 @@ static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
} else { } else {
u32 reg = 0; /* CB_SC_STPCLK? */ u32 reg = 0; /* CB_SC_STPCLK? */
switch (state->Vcc) { switch (state->Vcc) {
case 33: reg = CB_SC_VCC_3V; break; case 33:
case 50: reg = CB_SC_VCC_5V; break; reg = CB_SC_VCC_3V;
default: reg = 0; break; break;
case 50:
reg = CB_SC_VCC_5V;
break;
default:
reg = 0;
break;
} }
switch (state->Vpp) { switch (state->Vpp) {
case 33: reg |= CB_SC_VPP_3V; break; case 33:
case 50: reg |= CB_SC_VPP_5V; break; reg |= CB_SC_VPP_3V;
case 120: reg |= CB_SC_VPP_12V; break; break;
case 50:
reg |= CB_SC_VPP_5V;
break;
case 120:
reg |= CB_SC_VPP_12V;
break;
} }
if (reg != cb_readl(socket, CB_SOCKET_CONTROL)) if (reg != cb_readl(socket, CB_SOCKET_CONTROL))
cb_writel(socket, CB_SOCKET_CONTROL, reg); cb_writel(socket, CB_SOCKET_CONTROL, reg);
@ -314,19 +343,25 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK); reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK);
reg |= I365_PWR_NORESET; reg |= I365_PWR_NORESET;
if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO; if (state->flags & SS_PWR_AUTO)
if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT; reg |= I365_PWR_AUTO;
if (state->flags & SS_OUTPUT_ENA)
reg |= I365_PWR_OUT;
if (exca_readb(socket, I365_POWER) != reg) if (exca_readb(socket, I365_POWER) != reg)
exca_writeb(socket, I365_POWER, reg); exca_writeb(socket, I365_POWER, reg);
/* CSC interrupt: no ISA irq for CSC */ /* CSC interrupt: no ISA irq for CSC */
reg = I365_CSC_DETECT; reg = I365_CSC_DETECT;
if (state->flags & SS_IOCARD) { if (state->flags & SS_IOCARD) {
if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG; if (state->csc_mask & SS_STSCHG)
reg |= I365_CSC_STSCHG;
} else { } else {
if (state->csc_mask & SS_BATDEAD) reg |= I365_CSC_BVD1; if (state->csc_mask & SS_BATDEAD)
if (state->csc_mask & SS_BATWARN) reg |= I365_CSC_BVD2; reg |= I365_CSC_BVD1;
if (state->csc_mask & SS_READY) reg |= I365_CSC_READY; if (state->csc_mask & SS_BATWARN)
reg |= I365_CSC_BVD2;
if (state->csc_mask & SS_READY)
reg |= I365_CSC_READY;
} }
exca_writeb(socket, I365_CSCINT, reg); exca_writeb(socket, I365_CSCINT, reg);
exca_readb(socket, I365_CSC); exca_readb(socket, I365_CSC);
@ -368,9 +403,12 @@ static int yenta_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io
exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop); exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop);
ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map); ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map); if (io->flags & MAP_0WS)
if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map); ioctl |= I365_IOCTL_0WS(map);
if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map); if (io->flags & MAP_16BIT)
ioctl |= I365_IOCTL_16BIT(map);
if (io->flags & MAP_AUTOSZ)
ioctl |= I365_IOCTL_IOCS16(map);
exca_writeb(socket, I365_IOCTL, ioctl); exca_writeb(socket, I365_IOCTL, ioctl);
if (io->flags & MAP_ACTIVE) if (io->flags & MAP_ACTIVE)
@ -416,10 +454,17 @@ static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *
word = (stop >> 12) & 0x0fff; word = (stop >> 12) & 0x0fff;
switch (to_cycles(mem->speed)) { switch (to_cycles(mem->speed)) {
case 0: break; case 0:
case 1: word |= I365_MEM_WS0; break; break;
case 2: word |= I365_MEM_WS1; break; case 1:
default: word |= I365_MEM_WS1 | I365_MEM_WS0; break; word |= I365_MEM_WS0;
break;
case 2:
word |= I365_MEM_WS1;
break;
default:
word |= I365_MEM_WS1 | I365_MEM_WS0;
break;
} }
exca_writew(socket, I365_MEM(map) + I365_W_STOP, word); exca_writew(socket, I365_MEM(map) + I365_W_STOP, word);
@ -547,9 +592,9 @@ static int yenta_sock_suspend(struct pcmcia_socket *sock)
* max 4 MB, min 16 kB. We try very hard to not get below * max 4 MB, min 16 kB. We try very hard to not get below
* the "ACC" values, though. * the "ACC" values, though.
*/ */
#define BRIDGE_MEM_MAX 4*1024*1024 #define BRIDGE_MEM_MAX (4*1024*1024)
#define BRIDGE_MEM_ACC 128*1024 #define BRIDGE_MEM_ACC (128*1024)
#define BRIDGE_MEM_MIN 16*1024 #define BRIDGE_MEM_MIN (16*1024)
#define BRIDGE_IO_MAX 512 #define BRIDGE_IO_MAX 512
#define BRIDGE_IO_ACC 256 #define BRIDGE_IO_ACC 256

View file

@ -15,8 +15,8 @@
#ifndef _LINUX_MEM_OP_H #ifndef _LINUX_MEM_OP_H
#define _LINUX_MEM_OP_H #define _LINUX_MEM_OP_H
#include <linux/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h>
/* /*
If UNSAFE_MEMCPY is defined, we use the (optimized) system routines If UNSAFE_MEMCPY is defined, we use the (optimized) system routines