From dbb22f0d65ccc2e9dfeb4c420942f2757a80f8d2 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 10 Jan 2006 20:41:27 +0100 Subject: [PATCH] pcmcia: access config_t using pointer instead of array Access the PCMCIA config_t struct (one per device function) using a pointer in struct pcmcia_device, instead of looking them up in an array. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 8e2a9639647..ac11fb1e8d6 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -131,6 +131,7 @@ typedef struct dev_link_t { struct pcmcia_socket; +struct config_t; struct pcmcia_driver { int (*probe) (struct pcmcia_device *dev); @@ -160,6 +161,7 @@ struct pcmcia_device { /* the hardware "function" device; certain subdevices can * share one hardware "function" device. */ u8 func; + struct config_t* function_config; struct list_head socket_device_list; -- cgit v1.2.3 From cbbddd1046d44d90d31c7f246ed0207117602b89 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 10 Jan 2006 20:54:46 +0100 Subject: [PATCH] pcmcia: remove unused defines Remove unused fields and declarations. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index ac11fb1e8d6..8512cf9a121 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -106,7 +106,6 @@ typedef struct dev_node_t { typedef struct dev_link_t { dev_node_t *dev; u_int state, open; - wait_queue_head_t pending; client_handle_t handle; io_req_t io; irq_req_t irq; -- cgit v1.2.3 From 0e0fad8f71a8a23fad223b7d72b4ba06d57f764f Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 15 Jan 2006 01:14:31 +0100 Subject: [PATCH] pcmcia: size reduction if ioctl isn't compiled If the kernel is configured to not include the deprecated PCMCIA ioctl, some code doesn't need to be built. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 8512cf9a121..ce76ab587df 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -183,10 +183,12 @@ struct pcmcia_device { char * prod_id[4]; + struct device dev; + +#ifdef CONFIG_PCMCIA_IOCTL /* device driver wanted by cardmgr */ struct pcmcia_driver * cardmgr; - - struct device dev; +#endif }; #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) -- cgit v1.2.3 From 8661bb5b4af1849c1f5a4e80c4e275fd13c155d6 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 2 Mar 2006 00:02:33 +0100 Subject: [PATCH] pcmcia: default suspend and resume handling In all but one case, the suspend and resume functions of PCMCIA drivers contain mostly of calls to pcmcia_release_configuration() and pcmcia_request_configuration(). Therefore, move this code out of the drivers and into the core. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index ce76ab587df..8a6a95ea26e 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -118,8 +118,7 @@ typedef struct dev_link_t { /* Flags for device state */ #define DEV_PRESENT 0x01 #define DEV_CONFIG 0x02 -#define DEV_STALE_CONFIG 0x04 /* release on close */ -#define DEV_STALE_LINK 0x08 /* detach on release */ +#define DEV_SUSPEND_NORELEASE 0x04 #define DEV_CONFIG_PENDING 0x10 #define DEV_RELEASE_PENDING 0x20 #define DEV_SUSPEND 0x40 -- cgit v1.2.3 From a78f4dd331a4f6a396eb5849656a4a72a70a56d7 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 15 Jan 2006 16:26:00 +0100 Subject: [PATCH] pcmcia: rename pcmcia_device.state Rename pcmcia_device.state (which is used in very few places) to p_state in order to avoid a namespace collision when moving the deprecated dev_link_t into struct pcmcia_device Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 8a6a95ea26e..7f712df3e29 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -166,7 +166,7 @@ struct pcmcia_device { /* deprecated, a cleaned up version will be moved into this struct soon */ dev_link_t *instance; - u_int state; + u_int p_state; /* information about this device */ u8 has_manf_id:1; -- cgit v1.2.3 From fd238232cd0ff4840ae6946bb338502154096d88 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 5 Mar 2006 10:45:09 +0100 Subject: [PATCH] pcmcia: embed dev_link_t into struct pcmcia_device Embed dev_link_t into struct pcmcia_device(), as they basically address the same entity. The actual contents of dev_link_t will be cleaned up step by step. This patch includes a bugfix from and signed-off-by Andrew Morton. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 7f712df3e29..61f7d2dec19 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -39,7 +39,7 @@ typedef struct win_info_t { typedef struct bind_info_t { dev_info_t dev_info; u_char function; - struct dev_link_t *instance; + struct pcmcia_device *instance; char name[DEV_NAME_LEN]; u_short major, minor; void *next; @@ -103,18 +103,6 @@ typedef struct dev_node_t { struct dev_node_t *next; } dev_node_t; -typedef struct dev_link_t { - dev_node_t *dev; - u_int state, open; - client_handle_t handle; - io_req_t io; - irq_req_t irq; - config_req_t conf; - window_handle_t win; - void *priv; - struct dev_link_t *next; -} dev_link_t; - /* Flags for device state */ #define DEV_PRESENT 0x01 #define DEV_CONFIG 0x02 @@ -163,9 +151,17 @@ struct pcmcia_device { struct list_head socket_device_list; - /* deprecated, a cleaned up version will be moved into this - struct soon */ - dev_link_t *instance; + /* deprecated, will be cleaned up soon */ + dev_node_t *dev_node; + u_int state; + u_int open; + struct pcmcia_device *handle; + io_req_t io; + irq_req_t irq; + config_req_t conf; + window_handle_t win; + void *priv; + u_int p_state; /* information about this device */ @@ -189,6 +185,7 @@ struct pcmcia_device { struct pcmcia_driver * cardmgr; #endif }; +typedef struct pcmcia_device dev_link_t; #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) @@ -196,7 +193,7 @@ struct pcmcia_device { #define handle_to_pdev(handle) (handle) #define handle_to_dev(handle) (handle->dev) -#define dev_to_instance(dev) (dev->instance) +#define dev_to_instance(dev) (dev) /* error reporting */ void cs_error(client_handle_t handle, int func, int ret); -- cgit v1.2.3 From fba395eee7d3f342ca739c20f5b3ee635d0420a0 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 31 Mar 2006 17:21:06 +0200 Subject: [PATCH] pcmcia: remove dev_link_t and client_handle_t indirection dev_link_t * and client_handle_t both mean struct pcmcai_device * by now. Therefore, remove all such indirections. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 61f7d2dec19..557d8aea1a8 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -155,7 +155,6 @@ struct pcmcia_device { dev_node_t *dev_node; u_int state; u_int open; - struct pcmcia_device *handle; io_req_t io; irq_req_t irq; config_req_t conf; @@ -185,18 +184,14 @@ struct pcmcia_device { struct pcmcia_driver * cardmgr; #endif }; -typedef struct pcmcia_device dev_link_t; #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) -#define handle_to_pdev(handle) (handle) #define handle_to_dev(handle) (handle->dev) -#define dev_to_instance(dev) (dev) - /* error reporting */ -void cs_error(client_handle_t handle, int func, int ret); +void cs_error(struct pcmcia_device *handle, int func, int ret); #endif /* __KERNEL__ */ #endif /* _LINUX_DS_H */ -- cgit v1.2.3 From f6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 20 Jan 2006 15:10:23 +0100 Subject: [PATCH] pcmcia: remove unused p_dev->state flags Remove the unused DEV_RELEASE_PENDING flag, and move the DEV_SUSPEND flag into the p_dev structure, and make use of it at the core level. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 557d8aea1a8..93a7ebc3415 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -108,8 +108,6 @@ typedef struct dev_node_t { #define DEV_CONFIG 0x02 #define DEV_SUSPEND_NORELEASE 0x04 #define DEV_CONFIG_PENDING 0x10 -#define DEV_RELEASE_PENDING 0x20 -#define DEV_SUSPEND 0x40 #define DEV_BUSY 0x80 #define DEV_OK(l) \ @@ -163,13 +161,15 @@ struct pcmcia_device { u_int p_state; + u8 suspended:1; + u8 reserved:3; + /* information about this device */ u8 has_manf_id:1; u8 has_card_id:1; u8 has_func_id:1; u8 allow_func_id_match:1; - u8 reserved:4; u8 func_id; u16 manf_id; -- cgit v1.2.3 From e2d4096365e06b9a3799afbadc28b4519c0b3526 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 2 Mar 2006 00:09:29 +0100 Subject: [PATCH] pcmcia: use bitfield instead of p_state and state Instead of the two status values struct pcmcia_device->p_state and state, use descriptive bitfields. Most value-checking in drivers was invalid, as the core now only calls the ->remove() (a.k.a. detach) function in case the attachement _and_ configuration was successful. Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 93a7ebc3415..a8ce8fc1151 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -96,6 +96,7 @@ typedef union ds_ioctl_arg_t { #ifdef __KERNEL__ #include +#include typedef struct dev_node_t { char dev_name[DEV_NAME_LEN]; @@ -103,15 +104,11 @@ typedef struct dev_node_t { struct dev_node_t *next; } dev_node_t; -/* Flags for device state */ -#define DEV_PRESENT 0x01 -#define DEV_CONFIG 0x02 -#define DEV_SUSPEND_NORELEASE 0x04 -#define DEV_CONFIG_PENDING 0x10 -#define DEV_BUSY 0x80 +#define pcmcia_dev_present(p_dev) \ + (p_dev->socket->pcmcia_state.present) #define DEV_OK(l) \ - ((l) && ((l->state & ~DEV_BUSY) == (DEV_CONFIG|DEV_PRESENT))) + ((l) && (!l->suspended) && pcmcia_dev_present(l)) struct pcmcia_socket; @@ -133,6 +130,7 @@ struct pcmcia_driver { int pcmcia_register_driver(struct pcmcia_driver *driver); void pcmcia_unregister_driver(struct pcmcia_driver *driver); + struct pcmcia_device { /* the socket and the device_no [for multifunction devices] uniquely define a pcmcia_device */ @@ -151,25 +149,32 @@ struct pcmcia_device { /* deprecated, will be cleaned up soon */ dev_node_t *dev_node; - u_int state; u_int open; io_req_t io; irq_req_t irq; config_req_t conf; window_handle_t win; - void *priv; - u_int p_state; + /* Is the device suspended? */ + u16 suspended:1; + + /* Flags whether io, irq, win configurations were + * requested, and whether the configuration is "locked" */ + u16 _irq:1; + u16 _io:1; + u16 _win:4; + u16 _locked:1; - u8 suspended:1; - u8 reserved:3; + /* Flag whether a "fuzzy" func_id based match is + * allowed. */ + u16 allow_func_id_match:1; /* information about this device */ - u8 has_manf_id:1; - u8 has_card_id:1; - u8 has_func_id:1; + u16 has_manf_id:1; + u16 has_card_id:1; + u16 has_func_id:1; - u8 allow_func_id_match:1; + u16 reserved:4; u8 func_id; u16 manf_id; @@ -183,6 +188,9 @@ struct pcmcia_device { /* device driver wanted by cardmgr */ struct pcmcia_driver * cardmgr; #endif + + /* data private to drivers */ + void *priv; }; #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) -- cgit v1.2.3 From 9940ec3617fec1db13e589bbc3f37e37878c7683 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 5 Mar 2006 11:04:33 +0100 Subject: [PATCH] pcmcia: convert DEV_OK to pcmcia_dev_present Instead of the DEV_OK macro, drivers should use pcmcia_dev_present(). Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'include/pcmcia/ds.h') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index a8ce8fc1151..8c339f5678c 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -104,12 +104,6 @@ typedef struct dev_node_t { struct dev_node_t *next; } dev_node_t; -#define pcmcia_dev_present(p_dev) \ - (p_dev->socket->pcmcia_state.present) - -#define DEV_OK(l) \ - ((l) && (!l->suspended) && pcmcia_dev_present(l)) - struct pcmcia_socket; struct config_t; @@ -155,8 +149,10 @@ struct pcmcia_device { config_req_t conf; window_handle_t win; - /* Is the device suspended? */ + /* Is the device suspended, or in the process of + * being removed? */ u16 suspended:1; + u16 _removed:1; /* Flags whether io, irq, win configurations were * requested, and whether the configuration is "locked" */ @@ -174,7 +170,7 @@ struct pcmcia_device { u16 has_card_id:1; u16 has_func_id:1; - u16 reserved:4; + u16 reserved:3; u8 func_id; u16 manf_id; -- cgit v1.2.3