[PATCH] pcmcia: always use device pointer to config_t
Update the remaining users using the static lookup table of the PCMCIA function configuration to use the struct pcmcia_device-contained pointer. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
@@ -126,10 +126,9 @@ extern struct class_interface pccard_sysfs_interface;
|
|||||||
extern struct rw_semaphore pcmcia_socket_list_rwsem;
|
extern struct rw_semaphore pcmcia_socket_list_rwsem;
|
||||||
extern struct list_head pcmcia_socket_list;
|
extern struct list_head pcmcia_socket_list;
|
||||||
int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req);
|
int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req);
|
||||||
int pccard_get_configuration_info(struct pcmcia_socket *s, unsigned int function, config_info_t *config);
|
int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config);
|
||||||
int pccard_reset_card(struct pcmcia_socket *skt);
|
int pccard_reset_card(struct pcmcia_socket *skt);
|
||||||
int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status);
|
int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, cs_status_t *status);
|
||||||
int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int function, conf_reg_t *reg);
|
|
||||||
|
|
||||||
|
|
||||||
struct pcmcia_callback{
|
struct pcmcia_callback{
|
||||||
|
@@ -70,6 +70,22 @@ extern int ds_pc_debug;
|
|||||||
#define ds_dbg(lvl, fmt, arg...) do { } while (0)
|
#define ds_dbg(lvl, fmt, arg...) do { } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s,
|
||||||
|
unsigned int function)
|
||||||
|
{
|
||||||
|
struct pcmcia_device *p_dev = NULL;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
|
||||||
|
list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
|
||||||
|
if (p_dev->func == function) {
|
||||||
|
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
|
||||||
|
return pcmcia_get_dev(p_dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* backwards-compatible accessing of driver --- by name! */
|
/* backwards-compatible accessing of driver --- by name! */
|
||||||
|
|
||||||
@@ -583,9 +599,11 @@ static int ds_ioctl(struct inode * inode, struct file * file,
|
|||||||
if (buf->config.Function &&
|
if (buf->config.Function &&
|
||||||
(buf->config.Function >= s->functions))
|
(buf->config.Function >= s->functions))
|
||||||
ret = CS_BAD_ARGS;
|
ret = CS_BAD_ARGS;
|
||||||
else
|
else {
|
||||||
ret = pccard_get_configuration_info(s,
|
struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function);
|
||||||
buf->config.Function, &buf->config);
|
ret = pccard_get_configuration_info(s, p_dev, &buf->config);
|
||||||
|
pcmcia_put_dev(p_dev);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DS_GET_FIRST_TUPLE:
|
case DS_GET_FIRST_TUPLE:
|
||||||
down(&s->skt_sem);
|
down(&s->skt_sem);
|
||||||
@@ -612,8 +630,11 @@ static int ds_ioctl(struct inode * inode, struct file * file,
|
|||||||
if (buf->status.Function &&
|
if (buf->status.Function &&
|
||||||
(buf->status.Function >= s->functions))
|
(buf->status.Function >= s->functions))
|
||||||
ret = CS_BAD_ARGS;
|
ret = CS_BAD_ARGS;
|
||||||
else
|
else {
|
||||||
ret = pccard_get_status(s, buf->status.Function, &buf->status);
|
struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function);
|
||||||
|
ret = pccard_get_status(s, p_dev, &buf->status);
|
||||||
|
pcmcia_put_dev(p_dev);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DS_VALIDATE_CIS:
|
case DS_VALIDATE_CIS:
|
||||||
down(&s->skt_sem);
|
down(&s->skt_sem);
|
||||||
@@ -638,12 +659,16 @@ static int ds_ioctl(struct inode * inode, struct file * file,
|
|||||||
err = -EPERM;
|
err = -EPERM;
|
||||||
goto free_out;
|
goto free_out;
|
||||||
}
|
}
|
||||||
if (buf->conf_reg.Function &&
|
|
||||||
(buf->conf_reg.Function >= s->functions))
|
|
||||||
ret = CS_BAD_ARGS;
|
ret = CS_BAD_ARGS;
|
||||||
else
|
|
||||||
ret = pccard_access_configuration_register(s,
|
if (!(buf->conf_reg.Function &&
|
||||||
buf->conf_reg.Function, &buf->conf_reg);
|
(buf->conf_reg.Function >= s->functions))) {
|
||||||
|
struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function);
|
||||||
|
if (p_dev)
|
||||||
|
ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg);
|
||||||
|
pcmcia_put_dev(p_dev);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DS_GET_FIRST_REGION:
|
case DS_GET_FIRST_REGION:
|
||||||
case DS_GET_NEXT_REGION:
|
case DS_GET_NEXT_REGION:
|
||||||
|
@@ -165,21 +165,19 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
|
|||||||
* this and the tuple reading services.
|
* this and the tuple reading services.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int pccard_access_configuration_register(struct pcmcia_socket *s,
|
int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
|
||||||
unsigned int function,
|
|
||||||
conf_reg_t *reg)
|
conf_reg_t *reg)
|
||||||
{
|
{
|
||||||
|
struct pcmcia_socket *s;
|
||||||
config_t *c;
|
config_t *c;
|
||||||
int addr;
|
int addr;
|
||||||
u_char val;
|
u_char val;
|
||||||
|
|
||||||
if (!s || !s->config)
|
if (!p_dev || !p_dev->function_config)
|
||||||
return CS_NO_CARD;
|
return CS_NO_CARD;
|
||||||
|
|
||||||
c = &s->config[function];
|
s = p_dev->socket;
|
||||||
|
c = p_dev->function_config;
|
||||||
if (c == NULL)
|
|
||||||
return CS_NO_CARD;
|
|
||||||
|
|
||||||
if (!(c->state & CONFIG_LOCKED))
|
if (!(c->state & CONFIG_LOCKED))
|
||||||
return CS_CONFIGURATION_LOCKED;
|
return CS_CONFIGURATION_LOCKED;
|
||||||
@@ -200,20 +198,12 @@ int pccard_access_configuration_register(struct pcmcia_socket *s,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return CS_SUCCESS;
|
return CS_SUCCESS;
|
||||||
} /* pccard_access_configuration_register */
|
} /* pcmcia_access_configuration_register */
|
||||||
|
|
||||||
int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
|
|
||||||
conf_reg_t *reg)
|
|
||||||
{
|
|
||||||
return pccard_access_configuration_register(p_dev->socket,
|
|
||||||
p_dev->func, reg);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(pcmcia_access_configuration_register);
|
EXPORT_SYMBOL(pcmcia_access_configuration_register);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int pccard_get_configuration_info(struct pcmcia_socket *s,
|
int pccard_get_configuration_info(struct pcmcia_socket *s,
|
||||||
unsigned int function,
|
struct pcmcia_device *p_dev,
|
||||||
config_info_t *config)
|
config_info_t *config)
|
||||||
{
|
{
|
||||||
config_t *c;
|
config_t *c;
|
||||||
@@ -221,7 +211,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
|
|||||||
if (!(s->state & SOCKET_PRESENT))
|
if (!(s->state & SOCKET_PRESENT))
|
||||||
return CS_NO_CARD;
|
return CS_NO_CARD;
|
||||||
|
|
||||||
config->Function = function;
|
config->Function = p_dev->func;
|
||||||
|
|
||||||
#ifdef CONFIG_CARDBUS
|
#ifdef CONFIG_CARDBUS
|
||||||
if (s->state & SOCKET_CARDBUS) {
|
if (s->state & SOCKET_CARDBUS) {
|
||||||
@@ -242,7 +232,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
c = (s->config != NULL) ? &s->config[function] : NULL;
|
c = (p_dev) ? p_dev->function_config : NULL;
|
||||||
|
|
||||||
if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
|
if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
|
||||||
config->Attributes = 0;
|
config->Attributes = 0;
|
||||||
@@ -271,7 +261,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
|
|||||||
int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
|
int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
|
||||||
config_info_t *config)
|
config_info_t *config)
|
||||||
{
|
{
|
||||||
return pccard_get_configuration_info(p_dev->socket, p_dev->func,
|
return pccard_get_configuration_info(p_dev->socket, p_dev,
|
||||||
config);
|
config);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pcmcia_get_configuration_info);
|
EXPORT_SYMBOL(pcmcia_get_configuration_info);
|
||||||
@@ -317,7 +307,7 @@ EXPORT_SYMBOL(pcmcia_get_window);
|
|||||||
* SocketState yet: I haven't seen any point for it.
|
* SocketState yet: I haven't seen any point for it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
|
int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev,
|
||||||
cs_status_t *status)
|
cs_status_t *status)
|
||||||
{
|
{
|
||||||
config_t *c;
|
config_t *c;
|
||||||
@@ -334,7 +324,8 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
|
|||||||
if (!(s->state & SOCKET_PRESENT))
|
if (!(s->state & SOCKET_PRESENT))
|
||||||
return CS_NO_CARD;
|
return CS_NO_CARD;
|
||||||
|
|
||||||
c = (s->config != NULL) ? &s->config[function] : NULL;
|
c = (p_dev) ? p_dev->function_config : NULL;
|
||||||
|
|
||||||
if ((c != NULL) && (c->state & CONFIG_LOCKED) &&
|
if ((c != NULL) && (c->state & CONFIG_LOCKED) &&
|
||||||
(c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
|
(c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
|
||||||
u_char reg;
|
u_char reg;
|
||||||
@@ -370,9 +361,9 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
|
|||||||
return CS_SUCCESS;
|
return CS_SUCCESS;
|
||||||
} /* pccard_get_status */
|
} /* pccard_get_status */
|
||||||
|
|
||||||
int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
|
int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status)
|
||||||
{
|
{
|
||||||
return pccard_get_status(handle->socket, handle->func, status);
|
return pccard_get_status(p_dev->socket, p_dev, status);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pcmcia_get_status);
|
EXPORT_SYMBOL(pcmcia_get_status);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user