diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-07-24 12:23:21 +0200 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-08-03 09:02:35 +0200 |
commit | 1d5cc192d431bce2ebe9fde64054ce903200e179 (patch) | |
tree | cdcdfb77712349bf46f0876d420e2be81f901d74 /drivers/pcmcia | |
parent | ac8b422838046ffc26be4874a3cbae0d313f4209 (diff) |
pcmcia: use pcmica_{read,write}_config_byte
Use pcmcia_read_config_byte and pcmcia_write_config_byte instead
of pcmcia_access_configuration_register.
CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
CC: linux-serial@vger.kernel.org
CC: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/cistpl.c | 7 | ||||
-rw-r--r-- | drivers/pcmcia/cs_internal.h | 4 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 70 |
3 files changed, 48 insertions, 33 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index ba4a5acc2e9a..1733fab469a1 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -209,7 +209,7 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, * Probably only useful for writing one-byte registers. Must be called * with ops_mutex held. */ -void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, +int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr) { void __iomem *sys, *end; @@ -231,7 +231,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, ((cis_width) ? MAP_16BIT : 0)); if (!sys) { dev_dbg(&s->dev, "could not map memory\n"); - return; /* FIXME: Error */ + return -EINVAL; } writeb(flags, sys+CISREG_ICTRL0); @@ -256,7 +256,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, sys = set_cis_map(s, card_offset, flags); if (!sys) { dev_dbg(&s->dev, "could not map memory\n"); - return; /* FIXME: error */ + return -EINVAL; } end = sys + s->map_size; @@ -270,6 +270,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, addr = 0; } } + return 0; } diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 45e7fd1aa0bf..cebd40da8b9b 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -158,8 +158,8 @@ extern struct bin_attribute pccard_cis_attr; int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr); -void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, - u_int addr, u_int len, void *ptr); +int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, + u_int addr, u_int len, void *ptr); void release_cis_mem(struct pcmcia_socket *s); void destroy_cis_cache(struct pcmcia_socket *s); int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 2394de468602..563750e77eaf 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -108,25 +108,25 @@ static void release_io_space(struct pcmcia_socket *s, unsigned int base, } /* release_io_space */ -/** pccard_access_configuration_register +/** + * pcmcia_access_config() - read or write card configuration registers * - * Access_configuration_register() reads and writes configuration - * registers in attribute memory. Memory window 0 is reserved for - * this and the tuple reading services. + * pcmcia_access_config() reads and writes configuration registers in + * attribute memory. Memory window 0 is reserved for this and the tuple + * reading services. Drivers must use pcmcia_read_config_byte() or + * pcmcia_write_config_byte(). */ - -int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, - conf_reg_t *reg) +static int pcmcia_access_config(struct pcmcia_device *p_dev, + off_t where, u8 *val, + int (*accessf) (struct pcmcia_socket *s, + int attr, unsigned int addr, + unsigned int len, void *ptr)) { struct pcmcia_socket *s; config_t *c; int addr; - u_char val; int ret = 0; - if (!p_dev || !p_dev->function_config) - return -EINVAL; - s = p_dev->socket; mutex_lock(&s->ops_mutex); @@ -138,26 +138,40 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, return -EACCES; } - addr = (c->ConfigBase + reg->Offset) >> 1; + addr = (c->ConfigBase + where) >> 1; + + ret = accessf(s, 1, addr, 1, val); - switch (reg->Action) { - case CS_READ: - ret = pcmcia_read_cis_mem(s, 1, addr, 1, &val); - reg->Value = val; - break; - case CS_WRITE: - val = reg->Value; - pcmcia_write_cis_mem(s, 1, addr, 1, &val); - break; - default: - dev_dbg(&s->dev, "Invalid conf register request\n"); - ret = -EINVAL; - break; - } mutex_unlock(&s->ops_mutex); + return ret; -} /* pcmcia_access_configuration_register */ -EXPORT_SYMBOL(pcmcia_access_configuration_register); +} /* pcmcia_access_config */ + + +/** + * pcmcia_read_config_byte() - read a byte from a card configuration register + * + * pcmcia_read_config_byte() reads a byte from a configuration register in + * attribute memory. + */ +int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val) +{ + return pcmcia_access_config(p_dev, where, val, pcmcia_read_cis_mem); +} +EXPORT_SYMBOL(pcmcia_read_config_byte); + + +/** + * pcmcia_write_config_byte() - write a byte to a card configuration register + * + * pcmcia_write_config_byte() writes a byte to a configuration register in + * attribute memory. + */ +int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val) +{ + return pcmcia_access_config(p_dev, where, &val, pcmcia_write_cis_mem); +} +EXPORT_SYMBOL(pcmcia_write_config_byte); int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, |