[PATCHSET] suggestion for a patchset b15: merge client_t into
struct pcmcia_device
Dominik Brodowski
linux at dominikbrodowski.de
Thu Apr 29 17:25:44 BST 2004
Here's my proposal for a patchset named "15-pcmcia". It is
built on top of 2.6.6-rc3 which has most of 11-pcmciaresource included,
and my pcmcia-b12, -b13 and -b14 patchset proposals,
available at
http://www.brodo.de/patches/2004-04-19/pcmcia-b12.tar.bz2
and
http://www.brodo.de/patches/2004-04-19/pcmcia-b13.tar.bz2
and
http://www.brodo.de/patches/2004-04-19/pcmcia-b14.tar.bz2
The aim of this patchset is to add struct client_t as a part of
struct pcmcia_device and to use proper reference counting for
this object.
The patches are available in compressed form
at:
http://www.brodo.de/patches/2004-04-29/pcmcia-b15.tar.bz2
or
http://www.brodo.de/patches/2004-04-29/pcmcia-b15.tar.gz
or as single diff at:
http://www.brodo.de/patches/2004-04-29/pcmcia-b15-complete
http://www.brodo.de/patches/2004-04-29/01-move-and-remove-stuff
Move pcmcia_{de,}register_client() from cs.c to ds.c,
and remove the unused pcmcia_get_{first,next}_client() calls -- they would
be an unnecessary hassle to deal with in the next patches.
drivers/pcmcia/cs.c | 181 ----------------------------------------------------
drivers/pcmcia/ds.c | 129 ++++++++++++++++++++++++++++++++++++-
2 files changed, 130 insertions(+), 180 deletions(-)
http://www.brodo.de/patches/2004-04-29/02-license
As discussed previously, my integration of ds.c and cs.c
with the driver model can[*] and will only be available under
the GPL, as it's too much derived of other buses' implementation
of integration with the driver model.
cs_internal.h did only contain the MPL header before - I contacted
Dave Hinds because of this, and as far as he can tell, it was just an
oversight that this was not marked as dual-licensed as the other files
are.
drivers/pcmcia/bulkmem.c | 45 +++++++++++------------------------------
drivers/pcmcia/cardbus.c | 45 +++++++++++------------------------------
drivers/pcmcia/cistpl.c | 45 +++++++++++------------------------------
drivers/pcmcia/cs.c | 47 ++++++++++++-------------------------------
drivers/pcmcia/cs_internal.h | 18 ++++++----------
drivers/pcmcia/rsrc_mgr.c | 45 +++++++++++------------------------------
include/pcmcia/bulkmem.h | 28 ++++---------------------
include/pcmcia/ciscode.h | 25 ++++------------------
include/pcmcia/cisreg.h | 25 ++++------------------
include/pcmcia/cistpl.h | 25 ++++------------------
include/pcmcia/cs.h | 25 ++++------------------
include/pcmcia/cs_types.h | 25 ++++------------------
include/pcmcia/mem_op.h | 25 ++++------------------
include/pcmcia/ss.h | 25 ++++------------------
14 files changed, 113 insertions(+), 335 deletions(-)
http://www.brodo.de/patches/2004-04-29/03-ds-kref
Switch pcmcia_bus_socket's reference counting to struct kref. Also,
split the access by number into two calls, so that get_bus_socket can be
used in a more generic way.
drivers/pcmcia/ds.c | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
http://www.brodo.de/patches/2004-04-29/04-cs-class_dev
Use the reference counting available for class_devices for
struct pcmcia_socket. This means that register_socket must fail
if pccardd doesn't start up properly.
drivers/pcmcia/cs.c | 34 +++++++++++++++++++++++++++++++---
include/pcmcia/cs.h | 3 +++
2 files changed, 34 insertions(+), 3 deletions(-)
http://www.brodo.de/patches/2004-04-29/05-ds-grab-cs-ref
Grab a reference of struct pcmcia_socket for every struct pcmcia_bus_socket.
drivers/pcmcia/ds.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
http://www.brodo.de/patches/2004-04-29/06-ds-get-ref-for-p_dev
Obtain a reference to struct pcmcia_bus_socket for each pcmcia_device. This
means that pcmcia_device always holds an indirect reference to struct
pcmcia_socket as well.
drivers/pcmcia/ds.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletion(-)
http://www.brodo.de/patches/2004-04-29/07-p_dev-client-pointer
Add a pointer to the "client" structure to struct pcmcia_device.
drivers/pcmcia/ds.c | 1 +
include/pcmcia/ds.h | 2 ++
2 files changed, 3 insertions(+)
http://www.brodo.de/patches/2004-04-29/08-send_event-p_dev
Use a struct pcmcia_device-based approach to inform "clients" of
events. It needs to be done using bus_for_each_device() so that
we don't need to take the device_list spinlock.
drivers/pcmcia/cs.c | 5 +++--
drivers/pcmcia/ds.c | 47 +++++++++++++++++++++++++++++++++++++----------
2 files changed, 40 insertions(+), 12 deletions(-)
http://www.brodo.de/patches/2004-04-29/09-removal-p_dev
Use pcmcia_dev instead of the "client" single-linked list to mark
clients as stale.
drivers/pcmcia/ds.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
http://www.brodo.de/patches/2004-04-29/10-move-inside-ds
Move some code around in ds.c. Avoids forward-declarations, and keeps
related code close to each other.
drivers/pcmcia/ds.c | 253 +++++++++++++++++++++++++---------------------------
1 files changed, 126 insertions(+), 127 deletions(-)
http://www.brodo.de/patches/2004-04-29/11-register_client-p_dev
Search the devices_list for an UNBOUND client in register_client,
instead of the single linked list clients.
drivers/pcmcia/ds.c | 40 ++++++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 8 deletions(-)
http://www.brodo.de/patches/2004-04-29/12-direct_ordered_unbind
Restructure unbind_request():
Before, unbind_request was called by cardmgr on the following occasions:
a) if the CS_EVENT_CARD_INSERTION event failed
b) during do_remove(), which is called on
1) when cardmgr is informed of a CS_EVENT_CARD_REMOVAL event
2) when cardmgr is informed of a CS_EVENT_EJECTION_REQUEST event, if
do_check() succeeds
3) cardmgr exit (SIGINT/SIGTERM), if do_check() succeeds
We can ignore a), as the user is informed of the problem anyway, and can
take appropriate action then (eject the card, update config, write new driver,
insert card...).
b1) can be done directly, even before the userspace cardmgr is informed. This
speeds up the call to ->detach().
b2) All drivers I checked were based on the assumption that a
CS_EVENT_CARD_REMOVAL event is received _first_, before a call to
->detach(). Most notably, some drivers issue first a call to
their release() function [which else is called during EVENT_CARD_REMOVAL]
during ->detach() if it hasn't been issued before. So, it doesn't hurt
if unbind is only called during the EVENT_CARD_REMOVAL step, and not
during EJECTION_REQUEST. The REMOVAL step is only called anyway if
EJECTION_REQUEST succeeds, and the latter can only succeed if do_check()
succeeds.
b3) If cardmgr exits, ds_release() is called. We can check for any
16-bit devices there, and call a CARD_REMOVAL event there. Only difference
is that a failure of do_check() does not block CARD_REMOVAL. IMHO this
is accepatble.
Consequences:
- call unbind_request during CARD_REMOVAL handling, even before userspace
is informed.
- return "0" if UNBIND_REQUEST is called from userspace.
- clean up 16-bit pcmcia devices existing during cardmgr exit
- the driver's event handler is called with CARD_REMOVAL _always_ before
->detach() is called.
drivers/pcmcia/ds.c | 69 ++++++++++++++++++++++++++++++----------------------
1 files changed, 40 insertions(+), 29 deletions(-)
http://www.brodo.de/patches/2004-04-29/13-bug_on_dev_list_not_null
All in-kernel PCMCIA devices do unregister their client in their respective
->detach() function after a REMOVAL event. So, AFAICS, the dev_list iteration
should always be false.
drivers/bluetooth/bluecard_cs.c | 5 +----
drivers/bluetooth/bt3c_cs.c | 5 +----
drivers/bluetooth/btuart_cs.c | 5 +----
drivers/bluetooth/dtl1_cs.c | 5 +----
drivers/char/pcmcia/synclink_cs.c | 8 +-------
drivers/ide/legacy/ide-cs.c | 3 +--
drivers/isdn/hardware/avm/avm_cs.c | 8 +-------
drivers/isdn/hisax/avma1_cs.c | 8 +-------
drivers/isdn/hisax/elsa_cs.c | 5 +----
drivers/isdn/hisax/sedlbauer_cs.c | 8 +-------
drivers/isdn/hisax/teles_cs.c | 5 +----
drivers/mtd/maps/pcmciamtd.c | 30 +-----------------------------
drivers/net/pcmcia/3c574_cs.c | 3 +--
drivers/net/pcmcia/3c589_cs.c | 3 +--
drivers/net/pcmcia/axnet_cs.c | 3 +--
drivers/net/pcmcia/com20020_cs.c | 3 +--
drivers/net/pcmcia/fmvj18x_cs.c | 3 +--
drivers/net/pcmcia/ibmtr_cs.c | 3 +--
drivers/net/pcmcia/nmclan_cs.c | 3 +--
drivers/net/pcmcia/pcnet_cs.c | 3 +--
drivers/net/pcmcia/smc91c92_cs.c | 3 +--
drivers/net/pcmcia/xirc2ps_cs.c | 4 +---
drivers/net/wireless/airo_cs.c | 8 +-------
drivers/net/wireless/atmel_cs.c | 8 +-------
drivers/net/wireless/netwave_cs.c | 4 +---
drivers/net/wireless/orinoco_cs.c | 9 +--------
drivers/net/wireless/ray_cs.c | 3 +--
drivers/net/wireless/wl3501_cs.c | 8 +-------
drivers/parport/parport_cs.c | 5 +----
drivers/scsi/pcmcia/aha152x_stub.c | 5 +----
drivers/scsi/pcmcia/fdomain_stub.c | 5 +----
drivers/scsi/pcmcia/nsp_cs.c | 4 ++--
drivers/scsi/pcmcia/qlogic_stub.c | 5 +----
drivers/serial/serial_cs.c | 5 +----
drivers/telephony/ixj_pcmcia.c | 5 +----
sound/pcmcia/pdaudiocf/pdaudiocf.c | 11 +----------
sound/pcmcia/vx/vx_entry.c | 10 ----------
sound/pcmcia/vx/vxpocket.c | 2 +-
sound/pcmcia/vx/vxpocket.h | 1 -
39 files changed, 38 insertions(+), 186 deletions(-)
http://www.brodo.de/patches/2004-04-29/14-bug_on_list
BUG if the socket's list of clients is not empty on shutdown and/or
removal
drivers/pcmcia/cs.c | 19 ++-----------------
drivers/pcmcia/ds.c | 13 +++++++------
2 files changed, 9 insertions(+), 23 deletions(-)
http://www.brodo.de/patches/2004-04-29/15-move_client
Move the struct client_t inside struct pcmcia_device. This means it gets
proper reference counting as well. The clients list inside struct pcmcia_socket
can be removed now.
drivers/pcmcia/cs.c | 4 --
drivers/pcmcia/cs_internal.h | 14 -------
drivers/pcmcia/ds.c | 82 ++++++++++++-------------------------------
include/pcmcia/ds.h | 17 +++++++-
include/pcmcia/ss.h | 1
5 files changed, 40 insertions(+), 78 deletions(-)
Dominik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-pcmcia/attachments/20040429/082d91ba/attachment.bin
More information about the linux-pcmcia
mailing list