[Prism54-devel] How to integrate USB?

Johannes Steingraeber Jo_Stein@web.de
Tue, 16 Mar 2004 22:50:40 +0100


The current driver is (naturally, because that's what it is made for)
deeply bound to PCI/PCMCIA.

I would like to share some thoughts about how USB could be integrated
into existing sources.

DISCLAIMER: I'm not familiar with kernel hacking nor do I know much
about the innards of prism54 driver. So please forgive me if this
should be totally off the path...

One place to share code seems to be isl_ioctl.

Current code (just an example):

  static int
  prism54_reset(struct net_device *ndev, struct iw_request_info *info,
                __u32 * uwrq, char *extra)
  {
        islpci_reset(ndev->priv, 0);
  
        return 0;
  }

Here are two alternatives based on some kind of new isl38xx_private, a
union of islpci_private and islusb_private sharing as much as possible.

Alternative code through switching, assumes isl38xx_private has a
field "devtype" to tell PCI and USB apart:

  static int
  prism54_reset(struct net_device *ndev, struct iw_request_info *info,
                __u32 * uwrq, char *extra)
  {
        isl38xx_private* priv = ndev->priv;

        switch (priv->devtype) {
	case ISL38XX_USB:
	        islusb_reset(ndev->priv, 0);
		break;
	case ISL38XX_PCI:
	        islpci_reset(ndev->priv, 0);
		break;
	}
        return 0;
  }

Alternative code through function pointers, assumes isl38xx_private
has a (pointer to a) struct of function pointers to all relevant
functions which is setup during initialisation:

  static int
  prism54_reset(struct net_device *ndev, struct iw_request_info *info,
                __u32 * uwrq, char *extra)
  {
        isl38xx_private* priv = ndev->priv;

        priv->devfn.reset(ndev->priv, 0);
        return 0;
  }

But may be both these alternatives are not good at all! A totally
different approach would be to not share any code but only include
files.

Any ideas?

Johannes
-- 
Not using mail encoding is like always writing on postcards.
Key ID = 1024D/8014B0E9
Key fingerprint = 71FB 4193 DFC5 9827 7D06  B9F4 A6C2 D414 8014 B0E9