[PATCH] pcmcia: socket callbacks now use "struct pcmcia_socket"

Dominik Brodowski linux at brodo.de
Mon May 19 09:16:13 BST 2003


On Sun, May 18, 2003 at 11:28:08PM +0100, Russell King wrote:
> On Sat, May 17, 2003 at 10:16:03PM +0200, Dominik Brodowski wrote:
> > Passing a "socket number" between the core and the socket drivers is
> > awful. Change it to "struct pcmcia_socket" (which will be filled with
> > more life later).
> 
> I have an itch with this set of patches - we seem to be adding more
> levels of indirection between the "cs" layer and the socket driver
> itself.  I think this is becoming overly complex.

Only in the short term. And passing a "struct"  instead of a number is less
complex by itself.

> Is the idea to eventually kill socket_info_t in cs.c?  If this is
> the case, can't we just rename socket_info_t to struct pcmcia_socket
> (and keep the socket_info_t typedef around for a while.)

The idea is to integrate socket_info_t into struct pcmcia_socket. It can't
just be typedef'd as socket_info_t is widely used. Also, I want to keep
struct pcmcia_socket clean which means that only stuff is added to it which
is there to be kept, and available in a _sane_ format. Only exception, for
obvious reasons: void* s_info and socket_no.

> Also, imo the "thing" we pass to cs.c would be the class_device, and
> the "thing" that cs.c passes back would likewise be the same pointer
> - ie, the same class_device structure.  cs.c would then use
> class_dev->class_data for its private data, and the socket driver
> would then do a "pcmcia_class_drv_data(class_dev, parent_struct)"
> which would return a pointer to the parent structure.

IMHO this is ugly. Struct device, and also struct class_device are meant to
be embedded into a larger struct (just see
Documentation/driver-model/overview.txt, l.59ff.). Also, stuff like
socket_cap_t can and should be embedded in struct pcmcia_socket; and become
easily accessible by _both_ cs.c and the socket drivers.
 
> I think this would remove a fair amount of the triple/quadruple
> indirection.

As more and more functions within cs.c are converted from being based on
socket_info_t to being based on struct pcmcia_socket, one additional
level of indirection will go away. However, using struct class_device will
only add more levels of indirection as both cs.c and the socket drivers will
need access to struct pcmcia_socket.

I agree that the current assumption of

class_device->class_data == container_of(class_device, struct pcmcia_socket, class_device)

is not strictly necessary. But it inflicts less harm than the sorts of
indirections you propose.

> Comments?

I prefer the struct pcmcia_socket I sent in my patches, but I won't object
to any other patch as long as it works towards the same solution -- clean up
the cs.c / socket drivers interaction.

	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/20030519/7be01379/attachment.bin


More information about the linux-pcmcia mailing list