Commit 6ff402b8 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Russell King

[PATCH] convert ds.c's socekt_info_t to struct pcmcia_bus_socket

Rename socket_info_t (which is used many, many times differently
within pcmcia) to "struct pcmcia_bus_socket".

Also, a couple of functions in ds.c can be converted to use the "struct
pcmcia_bus_socket" as argument instead of the socket number.
parent 8e5c3584
...@@ -99,18 +99,18 @@ typedef struct user_info_t { ...@@ -99,18 +99,18 @@ typedef struct user_info_t {
} user_info_t; } user_info_t;
/* Socket state information */ /* Socket state information */
typedef struct socket_info_t { struct pcmcia_bus_socket {
client_handle_t handle; client_handle_t handle;
int state; int state;
user_info_t *user; user_info_t *user;
int req_pending, req_result; int req_pending, req_result;
wait_queue_head_t queue, request; wait_queue_head_t queue, request;
struct timer_list removal; struct timer_list removal;
socket_bind_t *bind; socket_bind_t *bind;
struct device *socket_dev; struct device *socket_dev;
struct list_head socket_list; struct list_head socket_list;
unsigned int socket_no; /* deprecated */ unsigned int socket_no; /* deprecated */
} socket_info_t; };
#define SOCKET_PRESENT 0x01 #define SOCKET_PRESENT 0x01
#define SOCKET_BUSY 0x02 #define SOCKET_BUSY 0x02
...@@ -140,7 +140,7 @@ static void cs_error(client_handle_t handle, int func, int ret) ...@@ -140,7 +140,7 @@ static void cs_error(client_handle_t handle, int func, int ret)
/*======================================================================*/ /*======================================================================*/
static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info);
static socket_info_t * get_socket_info_by_nr(unsigned int nr); static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr);
/** /**
* pcmcia_register_driver - register a PCMCIA driver with the bus core * pcmcia_register_driver - register a PCMCIA driver with the bus core
...@@ -165,7 +165,7 @@ EXPORT_SYMBOL(pcmcia_register_driver); ...@@ -165,7 +165,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
void pcmcia_unregister_driver(struct pcmcia_driver *driver) void pcmcia_unregister_driver(struct pcmcia_driver *driver)
{ {
socket_bind_t *b; socket_bind_t *b;
socket_info_t *bus_sock; struct pcmcia_bus_socket *bus_sock;
if (driver->use_count > 0) { if (driver->use_count > 0) {
/* Blank out any left-over device instances */ /* Blank out any left-over device instances */
...@@ -189,7 +189,7 @@ int register_pccard_driver(dev_info_t *dev_info, ...@@ -189,7 +189,7 @@ int register_pccard_driver(dev_info_t *dev_info,
{ {
struct pcmcia_driver *driver; struct pcmcia_driver *driver;
socket_bind_t *b; socket_bind_t *b;
socket_info_t *bus_sock; struct pcmcia_bus_socket *bus_sock;
DEBUG(0, "ds: register_pccard_driver('%s')\n", (char *)dev_info); DEBUG(0, "ds: register_pccard_driver('%s')\n", (char *)dev_info);
driver = get_pcmcia_driver(dev_info); driver = get_pcmcia_driver(dev_info);
...@@ -290,7 +290,7 @@ static void queue_event(user_info_t *user, event_t event) ...@@ -290,7 +290,7 @@ static void queue_event(user_info_t *user, event_t event)
user->event[user->event_head] = event; user->event[user->event_head] = event;
} }
static void handle_event(socket_info_t *s, event_t event) static void handle_event(struct pcmcia_bus_socket *s, event_t event)
{ {
user_info_t *user; user_info_t *user;
for (user = s->user; user; user = user->next) for (user = s->user; user; user = user->next)
...@@ -298,7 +298,7 @@ static void handle_event(socket_info_t *s, event_t event) ...@@ -298,7 +298,7 @@ static void handle_event(socket_info_t *s, event_t event)
wake_up_interruptible(&s->queue); wake_up_interruptible(&s->queue);
} }
static int handle_request(socket_info_t *s, event_t event) static int handle_request(struct pcmcia_bus_socket *s, event_t event)
{ {
if (s->req_pending != 0) if (s->req_pending != 0)
return CS_IN_USE; return CS_IN_USE;
...@@ -317,7 +317,7 @@ static int handle_request(socket_info_t *s, event_t event) ...@@ -317,7 +317,7 @@ static int handle_request(socket_info_t *s, event_t event)
static void handle_removal(u_long sn) static void handle_removal(u_long sn)
{ {
socket_info_t *s = get_socket_info_by_nr(sn); struct pcmcia_bus_socket *s = get_socket_info_by_nr(sn);
handle_event(s, CS_EVENT_CARD_REMOVAL); handle_event(s, CS_EVENT_CARD_REMOVAL);
s->state &= ~SOCKET_REMOVAL_PENDING; s->state &= ~SOCKET_REMOVAL_PENDING;
} }
...@@ -331,13 +331,11 @@ static void handle_removal(u_long sn) ...@@ -331,13 +331,11 @@ static void handle_removal(u_long sn)
static int ds_event(event_t event, int priority, static int ds_event(event_t event, int priority,
event_callback_args_t *args) event_callback_args_t *args)
{ {
socket_info_t *s; struct pcmcia_bus_socket *s;
int i;
DEBUG(1, "ds: ds_event(0x%06x, %d, 0x%p)\n", DEBUG(1, "ds: ds_event(0x%06x, %d, 0x%p)\n",
event, priority, args->client_handle); event, priority, args->client_handle);
s = args->client_data; s = args->client_data;
i = s->socket_no;
switch (event) { switch (event) {
...@@ -374,21 +372,21 @@ static int ds_event(event_t event, int priority, ...@@ -374,21 +372,21 @@ static int ds_event(event_t event, int priority,
======================================================================*/ ======================================================================*/
static int bind_mtd(int i, mtd_info_t *mtd_info) static int bind_mtd(struct pcmcia_bus_socket *bus_sock, mtd_info_t *mtd_info)
{ {
mtd_bind_t bind_req; mtd_bind_t bind_req;
int ret; int ret;
bind_req.dev_info = &mtd_info->dev_info; bind_req.dev_info = &mtd_info->dev_info;
bind_req.Attributes = mtd_info->Attributes; bind_req.Attributes = mtd_info->Attributes;
bind_req.Socket = i; bind_req.Socket = bus_sock->socket_no;
bind_req.CardOffset = mtd_info->CardOffset; bind_req.CardOffset = mtd_info->CardOffset;
ret = pcmcia_bind_mtd(&bind_req); ret = pcmcia_bind_mtd(&bind_req);
if (ret != CS_SUCCESS) { if (ret != CS_SUCCESS) {
cs_error(NULL, BindMTD, ret); cs_error(NULL, BindMTD, ret);
printk(KERN_NOTICE "ds: unable to bind MTD '%s' to socket %d" printk(KERN_NOTICE "ds: unable to bind MTD '%s' to socket %d"
" offset 0x%x\n", " offset 0x%x\n",
(char *)bind_req.dev_info, i, bind_req.CardOffset); (char *)bind_req.dev_info, bus_sock->socket_no, bind_req.CardOffset);
return -ENODEV; return -ENODEV;
} }
return 0; return 0;
...@@ -403,12 +401,11 @@ static int bind_mtd(int i, mtd_info_t *mtd_info) ...@@ -403,12 +401,11 @@ static int bind_mtd(int i, mtd_info_t *mtd_info)
======================================================================*/ ======================================================================*/
static int bind_request(int i, bind_info_t *bind_info) static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info)
{ {
struct pcmcia_driver *driver; struct pcmcia_driver *driver;
socket_bind_t *b; socket_bind_t *b;
bind_req_t bind_req; bind_req_t bind_req;
socket_info_t *s = get_socket_info_by_nr(i);
int ret; int ret;
if (!s) if (!s)
...@@ -434,14 +431,14 @@ static int bind_request(int i, bind_info_t *bind_info) ...@@ -434,14 +431,14 @@ static int bind_request(int i, bind_info_t *bind_info)
return -EBUSY; return -EBUSY;
} }
bind_req.Socket = i; bind_req.Socket = s->socket_no;
bind_req.Function = bind_info->function; bind_req.Function = bind_info->function;
bind_req.dev_info = (dev_info_t *) driver->drv.name; bind_req.dev_info = (dev_info_t *) driver->drv.name;
ret = pcmcia_bind_device(&bind_req); ret = pcmcia_bind_device(&bind_req);
if (ret != CS_SUCCESS) { if (ret != CS_SUCCESS) {
cs_error(NULL, BindDevice, ret); cs_error(NULL, BindDevice, ret);
printk(KERN_NOTICE "ds: unable to bind '%s' to socket %d\n", printk(KERN_NOTICE "ds: unable to bind '%s' to socket %d\n",
(char *)dev_info, i); (char *)dev_info, s->socket_no);
return -ENODEV; return -ENODEV;
} }
...@@ -473,9 +470,8 @@ static int bind_request(int i, bind_info_t *bind_info) ...@@ -473,9 +470,8 @@ static int bind_request(int i, bind_info_t *bind_info)
/*====================================================================*/ /*====================================================================*/
static int get_device_info(int i, bind_info_t *bind_info, int first) static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, int first)
{ {
socket_info_t *s = get_socket_info_by_nr(i);
socket_bind_t *b; socket_bind_t *b;
dev_node_t *node; dev_node_t *node;
...@@ -543,9 +539,8 @@ static int get_device_info(int i, bind_info_t *bind_info, int first) ...@@ -543,9 +539,8 @@ static int get_device_info(int i, bind_info_t *bind_info, int first)
/*====================================================================*/ /*====================================================================*/
static int unbind_request(int i, bind_info_t *bind_info) static int unbind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info)
{ {
socket_info_t *s = get_socket_info_by_nr(i);
socket_bind_t **b, *c; socket_bind_t **b, *c;
DEBUG(2, "unbind_request(%d, '%s')\n", i, DEBUG(2, "unbind_request(%d, '%s')\n", i,
...@@ -579,7 +574,7 @@ static int unbind_request(int i, bind_info_t *bind_info) ...@@ -579,7 +574,7 @@ static int unbind_request(int i, bind_info_t *bind_info)
static int ds_open(struct inode *inode, struct file *file) static int ds_open(struct inode *inode, struct file *file)
{ {
socket_t i = minor(inode->i_rdev); socket_t i = minor(inode->i_rdev);
socket_info_t *s; struct pcmcia_bus_socket *s;
user_info_t *user; user_info_t *user;
DEBUG(0, "ds_open(socket %d)\n", i); DEBUG(0, "ds_open(socket %d)\n", i);
...@@ -613,7 +608,7 @@ static int ds_open(struct inode *inode, struct file *file) ...@@ -613,7 +608,7 @@ static int ds_open(struct inode *inode, struct file *file)
static int ds_release(struct inode *inode, struct file *file) static int ds_release(struct inode *inode, struct file *file)
{ {
socket_t i = minor(inode->i_rdev); socket_t i = minor(inode->i_rdev);
socket_info_t *s; struct pcmcia_bus_socket *s;
user_info_t *user, **link; user_info_t *user, **link;
DEBUG(0, "ds_release(socket %d)\n", i); DEBUG(0, "ds_release(socket %d)\n", i);
...@@ -647,7 +642,7 @@ static ssize_t ds_read(struct file *file, char *buf, ...@@ -647,7 +642,7 @@ static ssize_t ds_read(struct file *file, char *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
socket_t i = minor(file->f_dentry->d_inode->i_rdev); socket_t i = minor(file->f_dentry->d_inode->i_rdev);
socket_info_t *s; struct pcmcia_bus_socket *s;
user_info_t *user; user_info_t *user;
DEBUG(2, "ds_read(socket %d)\n", i); DEBUG(2, "ds_read(socket %d)\n", i);
...@@ -678,7 +673,7 @@ static ssize_t ds_write(struct file *file, const char *buf, ...@@ -678,7 +673,7 @@ static ssize_t ds_write(struct file *file, const char *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
socket_t i = minor(file->f_dentry->d_inode->i_rdev); socket_t i = minor(file->f_dentry->d_inode->i_rdev);
socket_info_t *s; struct pcmcia_bus_socket *s;
user_info_t *user; user_info_t *user;
DEBUG(2, "ds_write(socket %d)\n", i); DEBUG(2, "ds_write(socket %d)\n", i);
...@@ -713,7 +708,7 @@ static ssize_t ds_write(struct file *file, const char *buf, ...@@ -713,7 +708,7 @@ static ssize_t ds_write(struct file *file, const char *buf,
static u_int ds_poll(struct file *file, poll_table *wait) static u_int ds_poll(struct file *file, poll_table *wait)
{ {
socket_t i = minor(file->f_dentry->d_inode->i_rdev); socket_t i = minor(file->f_dentry->d_inode->i_rdev);
socket_info_t *s; struct pcmcia_bus_socket *s;
user_info_t *user; user_info_t *user;
DEBUG(2, "ds_poll(socket %d)\n", i); DEBUG(2, "ds_poll(socket %d)\n", i);
...@@ -737,7 +732,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, ...@@ -737,7 +732,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
u_int cmd, u_long arg) u_int cmd, u_long arg)
{ {
socket_t i = minor(inode->i_rdev); socket_t i = minor(inode->i_rdev);
socket_info_t *s; struct pcmcia_bus_socket *s;
u_int size; u_int size;
int ret, err; int ret, err;
ds_ioctl_arg_t buf; ds_ioctl_arg_t buf;
...@@ -847,20 +842,20 @@ static int ds_ioctl(struct inode * inode, struct file * file, ...@@ -847,20 +842,20 @@ static int ds_ioctl(struct inode * inode, struct file * file,
break; break;
case DS_BIND_REQUEST: case DS_BIND_REQUEST:
if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (!capable(CAP_SYS_ADMIN)) return -EPERM;
err = bind_request(i, &buf.bind_info); err = bind_request(s, &buf.bind_info);
break; break;
case DS_GET_DEVICE_INFO: case DS_GET_DEVICE_INFO:
err = get_device_info(i, &buf.bind_info, 1); err = get_device_info(s, &buf.bind_info, 1);
break; break;
case DS_GET_NEXT_DEVICE: case DS_GET_NEXT_DEVICE:
err = get_device_info(i, &buf.bind_info, 0); err = get_device_info(s, &buf.bind_info, 0);
break; break;
case DS_UNBIND_REQUEST: case DS_UNBIND_REQUEST:
err = unbind_request(i, &buf.bind_info); err = unbind_request(s, &buf.bind_info);
break; break;
case DS_BIND_MTD: case DS_BIND_MTD:
if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (!capable(CAP_SYS_ADMIN)) return -EPERM;
err = bind_mtd(i, &buf.mtd_info); err = bind_mtd(s, &buf.mtd_info);
break; break;
default: default:
err = -EINVAL; err = -EINVAL;
...@@ -913,14 +908,14 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev, unsigned int sock ...@@ -913,14 +908,14 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev, unsigned int sock
{ {
client_reg_t client_reg; client_reg_t client_reg;
bind_req_t bind; bind_req_t bind;
socket_info_t *s, *tmp_s; struct pcmcia_bus_socket *s, *tmp_s;
int ret; int ret;
int i; int i;
s = kmalloc(sizeof(socket_info_t), GFP_KERNEL); s = kmalloc(sizeof(struct pcmcia_bus_socket), GFP_KERNEL);
if(!s) if(!s)
return -ENOMEM; return -ENOMEM;
memset(s, 0, sizeof(socket_info_t)); memset(s, 0, sizeof(struct pcmcia_bus_socket));
/* /*
* Ugly. But we want to wait for the socket threads to have started up. * Ugly. But we want to wait for the socket threads to have started up.
...@@ -1014,7 +1009,7 @@ static int __devexit pcmcia_bus_remove_socket_dev(struct device *dev) ...@@ -1014,7 +1009,7 @@ static int __devexit pcmcia_bus_remove_socket_dev(struct device *dev)
down_write(&bus_socket_list_rwsem); down_write(&bus_socket_list_rwsem);
list_for_each_safe(list_loop, tmp_storage, &bus_socket_list) { list_for_each_safe(list_loop, tmp_storage, &bus_socket_list) {
socket_info_t *bus_sock = container_of(list_loop, socket_info_t, socket_list); struct pcmcia_bus_socket *bus_sock = container_of(list_loop, struct pcmcia_bus_socket, socket_list);
if (bus_sock->socket_dev == dev) { if (bus_sock->socket_dev == dev) {
pcmcia_deregister_client(bus_sock->handle); pcmcia_deregister_client(bus_sock->handle);
list_del(&bus_sock->socket_list); list_del(&bus_sock->socket_list);
...@@ -1089,9 +1084,9 @@ module_exit(exit_pcmcia_bus); ...@@ -1089,9 +1084,9 @@ module_exit(exit_pcmcia_bus);
/* helpers for backwards-compatible functions */ /* helpers for backwards-compatible functions */
static socket_info_t * get_socket_info_by_nr(unsigned int nr) static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr)
{ {
socket_info_t * s; struct pcmcia_bus_socket * s;
down_read(&bus_socket_list_rwsem); down_read(&bus_socket_list_rwsem);
list_for_each_entry(s, &bus_socket_list, socket_list) list_for_each_entry(s, &bus_socket_list, socket_list)
if (s->socket_no == nr) { if (s->socket_no == nr) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment