Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e83ee07 authored by Dominik Brodowski's avatar Dominik Brodowski
Browse files

pcmcia: CodingStyle fixes



Fix most of the remaining CodingStyle issues in drivers/pcmcia , which
related to wrong indent -- PCMCIA historically used 4 spaces. Also, remove
a custom min() implementation with the generic one.

Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent f25e188c
Loading
Loading
Loading
Loading
+940 −968
Original line number Diff line number Diff line
@@ -54,10 +54,6 @@ static const u_int exponent[] = {
/* Upper limit on reasonable # of tuples */
#define MAX_TUPLES		200

/*====================================================================*/

/* Parameters that can be set with 'insmod' */

/* 16-bit CIS? */
static int cis_width;
module_param(cis_width, int, 0444);
@@ -79,21 +75,23 @@ void release_cis_mem(struct pcmcia_socket *s)
	mutex_unlock(&s->ops_mutex);
}

/*
 * Map the card memory at "card_offset" into virtual space.
/**
 * set_cis_map() - map the card memory at "card_offset" into virtual space.
 *
 * If flags & MAP_ATTRIB, map the attribute space, otherwise
 * map the memory space.
 *
 * Must be called with ops_mutex held.
 */
static void __iomem *
set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flags)
static void __iomem *set_cis_map(struct pcmcia_socket *s,
				unsigned int card_offset, unsigned int flags)
{
	pccard_mem_map *mem = &s->cis_mem;
	int ret;

	if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) {
		mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s);
		mem->res = pcmcia_find_mem_region(0, s->map_size,
						s->map_size, 0, s);
		if (mem->res == NULL) {
			dev_printk(KERN_NOTICE, &s->dev,
				   "cs: unable to map card memory!\n");
@@ -124,17 +122,14 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag
	return s->cis_virt;
}

/*======================================================================

    Low-level functions to read and write CIS memory.  I think the
    write routine is only useful for writing one-byte registers.

======================================================================*/

/* Bits in attr field */
#define IS_ATTR		1
#define IS_INDIRECT	8

/**
 * pcmcia_read_cis_mem() - low-level function to read CIS memory
 */
int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
		 u_int len, void *ptr)
{
@@ -153,7 +148,8 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
			flags = ICTRL0_AUTOINC;
		}

	sys = set_cis_map(s, 0, MAP_ACTIVE | ((cis_width) ? MAP_16BIT : 0));
		sys = set_cis_map(s, 0, MAP_ACTIVE |
				((cis_width) ? MAP_16BIT : 0));
		if (!sys) {
			dev_dbg(&s->dev, "could not map memory\n");
			memset(ptr, 0xff, len);
@@ -172,7 +168,8 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
		u_int inc = 1, card_offset, flags;

		if (addr > CISTPL_MAX_CIS_SIZE)
		dev_dbg(&s->dev, "attempt to read CIS mem at addr %#x", addr);
			dev_dbg(&s->dev,
				"attempt to read CIS mem at addr %#x", addr);

		flags = MAP_ACTIVE | ((cis_width) ? MAP_16BIT : 0);
		if (attr) {
@@ -209,13 +206,19 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
}


/**
 * pcmcia_write_cis_mem() - low-level function to write CIS memory
 *
 * Probably only useful for writing one-byte registers.
 */
void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
		   u_int len, void *ptr)
{
	void __iomem *sys, *end;
	unsigned char *buf = ptr;

    dev_dbg(&s->dev, "pcmcia_write_cis_mem(%d, %#x, %u)\n", attr, addr, len);
	dev_dbg(&s->dev,
		"pcmcia_write_cis_mem(%d, %#x, %u)\n", attr, addr, len);

	mutex_lock(&s->ops_mutex);
	if (attr & IS_INDIRECT) {
@@ -227,7 +230,8 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
			flags = ICTRL0_AUTOINC;
		}

	sys = set_cis_map(s, 0, MAP_ACTIVE | ((cis_width) ? MAP_16BIT : 0));
		sys = set_cis_map(s, 0, MAP_ACTIVE |
				((cis_width) ? MAP_16BIT : 0));
		if (!sys) {
			dev_dbg(&s->dev, "could not map memory\n");
			mutex_unlock(&s->ops_mutex);
@@ -275,14 +279,13 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
}


/*======================================================================

    This is a wrapper around read_cis_mem, with the same interface,
    but which caches information, for cards whose CIS may not be
    readable all the time.

======================================================================*/

/**
 * read_cis_cache() - read CIS memory or its associated cache
 *
 * This is a wrapper around read_cis_mem, with the same interface,
 * but which caches information, for cards whose CIS may not be
 * readable all the time.
 */
static int read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
			size_t len, void *ptr)
{
@@ -353,7 +356,6 @@ remove_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, u_int len)
 * This destroys the CIS cache but keeps any fake CIS alive. Must be
 * called with ops_mutex held.
 */

void destroy_cis_cache(struct pcmcia_socket *s)
{
	struct list_head *l, *n;
@@ -366,13 +368,9 @@ void destroy_cis_cache(struct pcmcia_socket *s)
	}
}

/*======================================================================

    This verifies if the CIS of a card matches what is in the CIS
    cache.

======================================================================*/

/**
 * verify_cis_cache() - does the CIS match what is in the CIS cache?
 */
int verify_cis_cache(struct pcmcia_socket *s)
{
	struct cis_cache_entry *cis;
@@ -404,13 +402,12 @@ int verify_cis_cache(struct pcmcia_socket *s)
	return 0;
}

/*======================================================================

    For really bad cards, we provide a facility for uploading a
    replacement CIS.

======================================================================*/

/**
 * pcmcia_replace_cis() - use a replacement CIS instead of the card's CIS
 *
 * For really bad cards, we provide a facility for uploading a
 * replacement CIS.
 */
int pcmcia_replace_cis(struct pcmcia_socket *s,
		       const u8 *data, const size_t len)
{
@@ -433,11 +430,7 @@ int pcmcia_replace_cis(struct pcmcia_socket *s,
	return 0;
}

/*======================================================================

    The high-level CIS tuple services

======================================================================*/
/* The high-level CIS tuple services */

typedef struct tuple_flags {
	u_int		link_space:4;
@@ -451,7 +444,8 @@ typedef struct tuple_flags {
#define MFC_FN(f)	(((tuple_flags *)(&(f)))->mfc_fn)
#define SPACE(f)	(((tuple_flags *)(&(f)))->space)

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)
		return -EINVAL;
@@ -499,9 +493,9 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
		ofs = tuple->LinkOffset;
		SPACE(tuple->Flags) = LINK_SPACE(tuple->Flags);
		HAS_LINK(tuple->Flags) = 0;
    } else {
	} else
		return -1;
    }

	if (SPACE(tuple->Flags)) {
		/* This is ugly, but a common CIS error is to code the long
		   link offset incorrectly, so we check the right spot... */
@@ -525,7 +519,8 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
	return -1;
}

int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
			tuple_t *tuple)
{
	u_char link[2], tmp;
	int ofs, i, attr;
@@ -541,14 +536,15 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
	attr = SPACE(tuple->Flags);

	for (i = 0; i < MAX_TUPLES; i++) {
	if (link[1] == 0xff) {
		if (link[1] == 0xff)
			link[0] = CISTPL_END;
	} else {
		else {
			ret = read_cis_cache(s, attr, ofs, 2, link);
			if (ret)
				return -1;
			if (link[0] == CISTPL_NULL) {
		ofs++; continue;
				ofs++;
				continue;
			}
		}

@@ -574,20 +570,23 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
			case CISTPL_LONGLINK_A:
				HAS_LINK(tuple->Flags) = 1;
				LINK_SPACE(tuple->Flags) = attr | IS_ATTR;
		ret = read_cis_cache(s, attr, ofs+2, 4, &tuple->LinkOffset);
				ret = read_cis_cache(s, attr, ofs+2, 4,
						&tuple->LinkOffset);
				if (ret)
					return -1;
				break;
			case CISTPL_LONGLINK_C:
				HAS_LINK(tuple->Flags) = 1;
				LINK_SPACE(tuple->Flags) = attr & ~IS_ATTR;
		ret = read_cis_cache(s, attr, ofs+2, 4, &tuple->LinkOffset);
				ret = read_cis_cache(s, attr, ofs+2, 4,
						&tuple->LinkOffset);
				if (ret)
					return -1;
				break;
			case CISTPL_INDIRECT:
				HAS_LINK(tuple->Flags) = 1;
		LINK_SPACE(tuple->Flags) = IS_ATTR | IS_INDIRECT;
				LINK_SPACE(tuple->Flags) = IS_ATTR |
					IS_INDIRECT;
				tuple->LinkOffset = 0;
				break;
			case CISTPL_LONGLINK_MFC:
@@ -595,7 +594,8 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
				LINK_SPACE(tuple->Flags) = attr;
				if (function == BIND_FN_ALL) {
					/* Follow all the MFC links */
		    ret = read_cis_cache(s, attr, ofs+2, 1, &tmp);
					ret = read_cis_cache(s, attr, ofs+2,
							1, &tmp);
					if (ret)
						return -1;
					MFC_FN(tuple->Flags) = tmp;
@@ -631,10 +631,6 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
	return 0;
}

/*====================================================================*/

#define _MIN(a, b)		(((a) < (b)) ? (a) : (b))

int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
{
	u_int len;
@@ -651,18 +647,15 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
		return 0;
	ret = read_cis_cache(s, SPACE(tuple->Flags),
			tuple->CISOffset + tuple->TupleOffset,
		   _MIN(len, tuple->TupleDataMax), tuple->TupleData);
			min(len, (u_int) tuple->TupleDataMax),
			tuple->TupleData);
	if (ret)
		return -1;
	return 0;
}


/*======================================================================

    Parsing routines for individual tuples

======================================================================*/
/* Parsing routines for individual tuples */

static int parse_device(tuple_t *tuple, cistpl_device_t *device)
{
@@ -724,7 +717,6 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device)
	return 0;
}

/*====================================================================*/

static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
{
@@ -738,7 +730,6 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
	return 0;
}

/*====================================================================*/

static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link)
{
@@ -748,10 +739,8 @@ static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link)
	return 0;
}

/*====================================================================*/

static int parse_longlink_mfc(tuple_t *tuple,
			      cistpl_longlink_mfc_t *link)
static int parse_longlink_mfc(tuple_t *tuple, cistpl_longlink_mfc_t *link)
{
	u_char *p;
	int i;
@@ -769,7 +758,6 @@ static int parse_longlink_mfc(tuple_t *tuple,
	return 0;
}

/*====================================================================*/

static int parse_strings(u_char *p, u_char *q, int max,
			 char *s, u_char *ofs, u_char *found)
@@ -797,12 +785,11 @@ static int parse_strings(u_char *p, u_char *q, int max,
	if (found) {
		*found = ns;
		return 0;
    } else {
	return (ns == max) ? 0 : -EINVAL;
	}

	return (ns == max) ? 0 : -EINVAL;
}

/*====================================================================*/

static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1)
{
@@ -820,7 +807,6 @@ static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1)
			vers_1->str, vers_1->ofs, &vers_1->ns);
}

/*====================================================================*/

static int parse_altstr(tuple_t *tuple, cistpl_altstr_t *altstr)
{
@@ -833,7 +819,6 @@ static int parse_altstr(tuple_t *tuple, cistpl_altstr_t *altstr)
			altstr->str, altstr->ofs, &altstr->ns);
}

/*====================================================================*/

static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
{
@@ -854,7 +839,6 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
	return 0;
}

/*====================================================================*/

static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m)
{
@@ -865,7 +849,6 @@ static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m)
	return 0;
}

/*====================================================================*/

static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f)
{
@@ -878,7 +861,6 @@ static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f)
	return 0;
}

/*====================================================================*/

static int parse_funce(tuple_t *tuple, cistpl_funce_t *f)
{
@@ -893,7 +875,6 @@ static int parse_funce(tuple_t *tuple, cistpl_funce_t *f)
	return 0;
}

/*====================================================================*/

static int parse_config(tuple_t *tuple, cistpl_config_t *config)
{
@@ -919,15 +900,11 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config)
	return 0;
}

/*======================================================================

    The following routines are all used to parse the nightmarish
    config table entries.

======================================================================*/
/* The following routines are all used to parse the nightmarish
 * config table entries.
 */

static u_char *parse_power(u_char *p, u_char *q,
			   cistpl_power_t *pwr)
static u_char *parse_power(u_char *p, u_char *q, cistpl_power_t *pwr)
{
	int i;
	u_int scale;
@@ -947,7 +924,8 @@ static u_char *parse_power(u_char *p, u_char *q,
				if (++p == q)
					return NULL;
				if ((*p & 0x7f) < 100)
		    pwr->param[i] += (*p & 0x7f) * scale / 100;
					pwr->param[i] +=
						(*p & 0x7f) * scale / 100;
				else if (*p == 0x7d)
					pwr->flags |= CISTPL_POWER_HIGHZ_OK;
				else if (*p == 0x7e)
@@ -962,10 +940,8 @@ static u_char *parse_power(u_char *p, u_char *q,
	return p;
}

/*====================================================================*/

static u_char *parse_timing(u_char *p, u_char *q,
			    cistpl_timing_t *timing)
static u_char *parse_timing(u_char *p, u_char *q, cistpl_timing_t *timing)
{
	u_char scale;

@@ -999,7 +975,6 @@ static u_char *parse_timing(u_char *p, u_char *q,
	return p;
}

/*====================================================================*/

static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
{
@@ -1044,7 +1019,6 @@ static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
	return p;
}

/*====================================================================*/

static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem)
{
@@ -1086,7 +1060,6 @@ static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem)
	return p;
}

/*====================================================================*/

static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq)
{
@@ -1102,7 +1075,6 @@ static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq)
	return p;
}

/*====================================================================*/

static int parse_cftable_entry(tuple_t *tuple,
			       cistpl_cftable_entry_t *entry)
@@ -1227,7 +1199,6 @@ static int parse_cftable_entry(tuple_t *tuple,
	return 0;
}

/*====================================================================*/

static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo)
{
@@ -1252,7 +1223,6 @@ static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo)
	return 0;
}

/*====================================================================*/

static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
{
@@ -1274,7 +1244,6 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
	return parse_strings(p, q, 2, v2->str, &v2->vendor, NULL);
}

/*====================================================================*/

static int parse_org(tuple_t *tuple, cistpl_org_t *org)
{
@@ -1298,7 +1267,6 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org)
	return 0;
}

/*====================================================================*/

static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
{
@@ -1317,7 +1285,6 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
	return 0;
}

/*====================================================================*/

int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse)
{
@@ -1393,13 +1360,18 @@ int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse)
}
EXPORT_SYMBOL(pcmcia_parse_tuple);

/*======================================================================

    This is used internally by Card Services to look up CIS stuff.

======================================================================*/

int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse)
/**
 * pccard_read_tuple() - internal CIS tuple access
 * @s:		the struct pcmcia_socket where the card is inserted
 * @function:	the device function we loop for
 * @code:	which CIS code shall we look for?
 * @parse:	buffer where the tuple shall be parsed (or NULL, if no parse)
 *
 * pccard_read_tuple() reads out one tuple and attempts to parse it
 */
int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
		cisdata_t code, void *parse)
{
	tuple_t tuple;
	cisdata_t *buf;
+1 −2
Original line number Diff line number Diff line
@@ -79,10 +79,9 @@ static resource_size_t pcmcia_align(void *align_data,

#ifdef CONFIG_X86
	if (res->flags & IORESOURCE_IO) {
		if (start & 0x300) {
		if (start & 0x300)
			start = (start + 0x3ff) & ~0x3ff;
	}
	}
#endif

#ifdef CONFIG_M68K
+1 −1

File changed.

Contains only whitespace changes.