Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * PCMCIA high-level CIS access functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * The initial developer of the original code is David A. Hinds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Copyright (C) 1999	     David A. Hinds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Copyright (C) 2004-2010   Dominik Brodowski
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <pcmcia/cisreg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <pcmcia/cistpl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <pcmcia/ss.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <pcmcia/ds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "cs_internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * pccard_read_tuple() - internal CIS tuple access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * @s:		the struct pcmcia_socket where the card is inserted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * @function:	the device function we loop for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * @code:	which CIS code shall we look for?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * @parse:	buffer where the tuple shall be parsed (or NULL, if no parse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * pccard_read_tuple() reads out one tuple and attempts to parse it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		cisdata_t code, void *parse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	tuple_t tuple;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	cisdata_t *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	buf = kmalloc(256, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	if (buf == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		dev_warn(&s->dev, "no memory to read tuple\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	tuple.DesiredTuple = code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	tuple.Attributes = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if (function == BIND_FN_ALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		tuple.Attributes = TUPLE_RETURN_COMMON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	ret = pccard_get_first_tuple(s, function, &tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	tuple.TupleData = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	tuple.TupleOffset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	tuple.TupleDataMax = 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	ret = pccard_get_tuple_data(s, &tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	ret = pcmcia_parse_tuple(&tuple, parse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * pccard_loop_tuple() - loop over tuples in the CIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * @s:		the struct pcmcia_socket where the card is inserted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * @function:	the device function we loop for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @code:	which CIS code shall we look for?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * @parse:	buffer where the tuple shall be parsed (or NULL, if no parse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @priv_data:	private data to be passed to the loop_tuple function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @loop_tuple:	function to call for each CIS entry of type @function. IT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *		gets passed the raw tuple, the paresed tuple (if @parse is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *		set) and @priv_data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * pccard_loop_tuple() loops over all CIS entries of type @function, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * calls the @loop_tuple function for each entry. If the call to @loop_tuple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * returns 0, the loop exits. Returns 0 on success or errorcode otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			     cisdata_t code, cisparse_t *parse, void *priv_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			     int (*loop_tuple) (tuple_t *tuple,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 					 cisparse_t *parse,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 					 void *priv_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	tuple_t tuple;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	cisdata_t *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	buf = kzalloc(256, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (buf == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		dev_warn(&s->dev, "no memory to read tuple\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	tuple.TupleData = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	tuple.TupleDataMax = 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	tuple.TupleOffset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	tuple.DesiredTuple = code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	tuple.Attributes = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	ret = pccard_get_first_tuple(s, function, &tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	while (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		if (pccard_get_tuple_data(s, &tuple))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			goto next_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		if (parse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			if (pcmcia_parse_tuple(&tuple, parse))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 				goto next_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		ret = loop_tuple(&tuple, parse, priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) next_entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		ret = pccard_get_next_tuple(s, function, &tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * pcmcia_io_cfg_data_width() - convert cfgtable to data path width parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static int pcmcia_io_cfg_data_width(unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (!(flags & CISTPL_IO_8BIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return IO_DATA_PATH_WIDTH_16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (!(flags & CISTPL_IO_16BIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return IO_DATA_PATH_WIDTH_8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return IO_DATA_PATH_WIDTH_AUTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct pcmcia_cfg_mem {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	struct pcmcia_device *p_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	int (*conf_check) (struct pcmcia_device *p_dev, void *priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	void *priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	cisparse_t parse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	cistpl_cftable_entry_t dflt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * pcmcia_do_loop_config() - internal helper for pcmcia_loop_config()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * pcmcia_do_loop_config() is the internal callback for the call from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * pcmcia_loop_config() to pccard_loop_tuple(). Data is transferred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * by a struct pcmcia_cfg_mem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static int pcmcia_do_loop_config(tuple_t *tuple, cisparse_t *parse, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct pcmcia_cfg_mem *cfg_mem = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct pcmcia_device *p_dev = cfg_mem->p_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	cistpl_cftable_entry_t *cfg = &parse->cftable_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	cistpl_cftable_entry_t *dflt = &cfg_mem->dflt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	unsigned int flags = p_dev->config_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	unsigned int vcc = p_dev->socket->socket.Vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	dev_dbg(&p_dev->dev, "testing configuration %x, autoconf %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		cfg->index, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	/* default values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	cfg_mem->p_dev->config_index = cfg->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		cfg_mem->dflt = *cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	/* check for matching Vcc? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	if (flags & CONF_AUTO_CHECK_VCC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 				return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 				return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	/* set Vpp? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (flags & CONF_AUTO_SET_VPP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			p_dev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			p_dev->vpp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	/* enable audio? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	if ((flags & CONF_AUTO_AUDIO) && (cfg->flags & CISTPL_CFTABLE_AUDIO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		p_dev->config_flags |= CONF_ENABLE_SPKR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	/* IO window settings? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (flags & CONF_AUTO_SET_IO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		p_dev->resource[0]->start = p_dev->resource[0]->end = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		p_dev->resource[1]->start = p_dev->resource[1]->end = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (io->nwin == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		p_dev->resource[0]->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 					pcmcia_io_cfg_data_width(io->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		if (io->nwin > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			/* For multifunction cards, by convention, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			 * configure the network function with window 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			 * and serial with window 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			i = (io->win[1].len > io->win[0].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			p_dev->resource[1]->flags = p_dev->resource[0]->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			p_dev->resource[1]->start = io->win[1-i].base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			p_dev->resource[1]->end = io->win[1-i].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		p_dev->resource[0]->start = io->win[i].base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		p_dev->resource[0]->end = io->win[i].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	/* MEM window settings? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	if (flags & CONF_AUTO_SET_IOMEM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		/* so far, we only set one memory window */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		p_dev->resource[2]->start = p_dev->resource[2]->end = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		if (mem->nwin == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		p_dev->resource[2]->start = mem->win[0].host_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		p_dev->resource[2]->end = mem->win[0].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		if (p_dev->resource[2]->end < 0x1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			p_dev->resource[2]->end = 0x1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		p_dev->card_addr = mem->win[0].card_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	dev_dbg(&p_dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		"checking configuration %x: %pr %pr %pr (%d lines)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		p_dev->config_index, p_dev->resource[0], p_dev->resource[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		p_dev->resource[2], p_dev->io_lines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	return cfg_mem->conf_check(p_dev, cfg_mem->priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  * pcmcia_loop_config() - loop over configuration options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * @p_dev:	the struct pcmcia_device which we need to loop for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  * @conf_check:	function to call for each configuration option.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  *		It gets passed the struct pcmcia_device and private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  *		being passed to pcmcia_loop_config()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  * @priv_data:	private data to be passed to the conf_check function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * pcmcia_loop_config() loops over all configuration options, and calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  * the driver-specific conf_check() for each one, checking whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  * it is a valid one. Returns 0 on success or errorcode otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) int pcmcia_loop_config(struct pcmcia_device *p_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		       int	(*conf_check)	(struct pcmcia_device *p_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 						 void *priv_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		       void *priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	struct pcmcia_cfg_mem *cfg_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (cfg_mem == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	cfg_mem->p_dev = p_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	cfg_mem->conf_check = conf_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	cfg_mem->priv_data = priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	ret = pccard_loop_tuple(p_dev->socket, p_dev->func,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 				CISTPL_CFTABLE_ENTRY, &cfg_mem->parse,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 				cfg_mem, pcmcia_do_loop_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	kfree(cfg_mem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) EXPORT_SYMBOL(pcmcia_loop_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct pcmcia_loop_mem {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	struct pcmcia_device *p_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	void *priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	int (*loop_tuple) (struct pcmcia_device *p_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			   tuple_t *tuple,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			   void *priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)  * pcmcia_do_loop_tuple() is the internal callback for the call from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)  * pcmcia_loop_tuple() to pccard_loop_tuple(). Data is transferred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)  * by a struct pcmcia_cfg_mem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static int pcmcia_do_loop_tuple(tuple_t *tuple, cisparse_t *parse, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	struct pcmcia_loop_mem *loop = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)  * pcmcia_loop_tuple() - loop over tuples in the CIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)  * @p_dev:	the struct pcmcia_device which we need to loop for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)  * @code:	which CIS code shall we look for?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  * @priv_data:	private data to be passed to the loop_tuple function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  * @loop_tuple:	function to call for each CIS entry of type @function. IT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  *		gets passed the raw tuple and @priv_data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)  * pcmcia_loop_tuple() loops over all CIS entries of type @function, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * calls the @loop_tuple function for each entry. If the call to @loop_tuple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  * returns 0, the loop exits. Returns 0 on success or errorcode otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		      int (*loop_tuple) (struct pcmcia_device *p_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 					 tuple_t *tuple,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 					 void *priv_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		      void *priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	struct pcmcia_loop_mem loop = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		.p_dev = p_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		.loop_tuple = loop_tuple,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		.priv_data = priv_data};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 				 &loop, pcmcia_do_loop_tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) EXPORT_SYMBOL(pcmcia_loop_tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct pcmcia_loop_get {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	cisdata_t **buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)  * pcmcia_do_get_tuple() - internal helper for pcmcia_get_tuple()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  * pcmcia_do_get_tuple() is the internal callback for the call from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  * pcmcia_get_tuple() to pcmcia_loop_tuple(). As we're only interested in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  * the first tuple, return 0 unconditionally. Create a memory buffer large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  * enough to hold the content of the tuple, and fill it with the tuple data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  * The caller is responsible to free the buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static int pcmcia_do_get_tuple(struct pcmcia_device *p_dev, tuple_t *tuple,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			       void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	struct pcmcia_loop_get *get = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	*get->buf = kzalloc(tuple->TupleDataLen, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	if (*get->buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		get->len = tuple->TupleDataLen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		memcpy(*get->buf, tuple->TupleData, tuple->TupleDataLen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		dev_dbg(&p_dev->dev, "do_get_tuple: out of memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  * pcmcia_get_tuple() - get first tuple from CIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)  * @p_dev:	the struct pcmcia_device which we need to loop for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)  * @code:	which CIS code shall we look for?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)  * @buf:        pointer to store the buffer to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  * pcmcia_get_tuple() gets the content of the first CIS entry of type @code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  * It returns the buffer length (or zero). The caller is responsible to free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  * the buffer passed in @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			unsigned char **buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	struct pcmcia_loop_get get = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		.len = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		.buf = buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	*get.buf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	pcmcia_loop_tuple(p_dev, code, pcmcia_do_get_tuple, &get);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	return get.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) EXPORT_SYMBOL(pcmcia_get_tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)  * pcmcia_do_get_mac() - internal helper for pcmcia_get_mac_from_cis()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)  * pcmcia_do_get_mac() is the internal callback for the call from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)  * pcmcia_get_mac_from_cis() to pcmcia_loop_tuple(). We check whether the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)  * tuple contains a proper LAN_NODE_ID of length 6, and copy the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)  * to struct net_device->dev_addr[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			     void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	struct net_device *dev = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	if (tuple->TupleDataLen < ETH_ALEN + 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		dev_warn(&p_dev->dev, "Invalid CIS tuple length for "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			"LAN_NODE_ID\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	if (tuple->TupleData[1] != ETH_ALEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		dev_warn(&p_dev->dev, "Invalid header for LAN_NODE_ID\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	for (i = 0; i < 6; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		dev->dev_addr[i] = tuple->TupleData[i+2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)  * pcmcia_get_mac_from_cis() - read out MAC address from CISTPL_FUNCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)  * @p_dev:	the struct pcmcia_device for which we want the address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)  * @dev:	a properly prepared struct net_device to store the info to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)  * pcmcia_get_mac_from_cis() reads out the hardware MAC address from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  * CISTPL_FUNCE and stores it into struct net_device *dev->dev_addr which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  * must be set up properly by the driver (see examples!).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	return pcmcia_loop_tuple(p_dev, CISTPL_FUNCE, pcmcia_do_get_mac, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) EXPORT_SYMBOL(pcmcia_get_mac_from_cis);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)