Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2608362 authored by David Kilroy's avatar David Kilroy Committed by John W. Linville
Browse files

orinoco: Replace net_device with orinoco_private in driver interfaces



Move away from using net_device as the main structure in orinoco
function calls. Use orinoco_private instead.

This makes more sense when we move to cfg80211, and we get wiphys as
well.

Signed-off-by: default avatarDavid Kilroy <kilroyd@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 44d8dade
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@ struct airport {
static int
airport_suspend(struct macio_dev *mdev, pm_message_t state)
{
	struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev);
	struct net_device *dev = priv->ndev;
	unsigned long flags;
	int err;

@@ -48,7 +48,7 @@ airport_suspend(struct macio_dev *mdev, pm_message_t state)
		return 0;
	}

	err = __orinoco_down(dev);
	err = __orinoco_down(priv);
	if (err)
		printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
		       dev->name, err);
@@ -69,8 +69,8 @@ airport_suspend(struct macio_dev *mdev, pm_message_t state)
static int
airport_resume(struct macio_dev *mdev)
{
	struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev);
	struct net_device *dev = priv->ndev;
	unsigned long flags;
	int err;

@@ -82,7 +82,7 @@ airport_resume(struct macio_dev *mdev)

	enable_irq(dev->irq);

	err = orinoco_reinit_firmware(dev);
	err = orinoco_reinit_firmware(priv);
	if (err) {
		printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
		       dev->name, err);
@@ -96,7 +96,7 @@ airport_resume(struct macio_dev *mdev)
	priv->hw_unavailable--;

	if (priv->open && (!priv->hw_unavailable)) {
		err = __orinoco_up(dev);
		err = __orinoco_up(priv);
		if (err)
			printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
			       dev->name, err);
@@ -111,8 +111,8 @@ airport_resume(struct macio_dev *mdev)
static int
airport_detach(struct macio_dev *mdev)
{
	struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev);
	struct net_device *dev = priv->ndev;
	struct airport *card = priv->card;

	if (card->ndev_registered)
@@ -120,7 +120,7 @@ airport_detach(struct macio_dev *mdev)
	card->ndev_registered = 0;

	if (card->irq_requested)
		free_irq(dev->irq, dev);
		free_irq(dev->irq, priv);
	card->irq_requested = 0;

	if (card->vaddr)
@@ -134,7 +134,7 @@ airport_detach(struct macio_dev *mdev)
	ssleep(1);

	macio_set_drvdata(mdev, NULL);
	free_orinocodev(dev);
	free_orinocodev(priv);

	return 0;
}
@@ -185,13 +185,13 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
	}

	/* Allocate space for private device-specific data */
	dev = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev,
	priv = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev,
				airport_hard_reset, NULL);
	if (!dev) {
	if (!priv) {
		printk(KERN_ERR PFX "Cannot allocate network device\n");
		return -ENODEV;
	}
	priv = netdev_priv(dev);
	dev = priv->ndev;
	card = priv->card;

	hw = &priv->hw;
@@ -199,13 +199,13 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)

	if (macio_request_resource(mdev, 0, "airport")) {
		printk(KERN_ERR PFX "can't request IO resource !\n");
		free_orinocodev(dev);
		free_orinocodev(priv);
		return -EBUSY;
	}

	SET_NETDEV_DEV(dev, &mdev->ofdev.dev);

	macio_set_drvdata(mdev, dev);
	macio_set_drvdata(mdev, priv);

	/* Setup interrupts & base address */
	dev->irq = macio_irq(mdev, 0);
@@ -228,7 +228,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
	/* Reset it before we get the interrupt */
	hermes_init(hw);

	if (request_irq(dev->irq, orinoco_interrupt, 0, dev->name, dev)) {
	if (request_irq(dev->irq, orinoco_interrupt, 0, dev->name, priv)) {
		printk(KERN_ERR PFX "Couldn't get IRQ %d\n", dev->irq);
		goto failed;
	}
+15 −16
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ static int orinoco_open(struct net_device *dev)
	if (orinoco_lock(priv, &flags) != 0)
		return -EBUSY;

	err = __orinoco_up(dev);
	err = __orinoco_up(priv);

	if (!err)
		priv->open = 1;
@@ -274,7 +274,7 @@ static int orinoco_stop(struct net_device *dev)

	priv->open = 0;

	err = __orinoco_down(dev);
	err = __orinoco_down(priv);

	spin_unlock_irq(&priv->lock);

@@ -1511,9 +1511,9 @@ static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw)
/* Internal hardware control routines                               */
/********************************************************************/

int __orinoco_up(struct net_device *dev)
int __orinoco_up(struct orinoco_private *priv)
{
	struct orinoco_private *priv = netdev_priv(dev);
	struct net_device *dev = priv->ndev;
	struct hermes *hw = &priv->hw;
	int err;

@@ -1541,9 +1541,9 @@ int __orinoco_up(struct net_device *dev)
}
EXPORT_SYMBOL(__orinoco_up);

int __orinoco_down(struct net_device *dev)
int __orinoco_down(struct orinoco_private *priv)
{
	struct orinoco_private *priv = netdev_priv(dev);
	struct net_device *dev = priv->ndev;
	struct hermes *hw = &priv->hw;
	int err;

@@ -1573,9 +1573,8 @@ int __orinoco_down(struct net_device *dev)
}
EXPORT_SYMBOL(__orinoco_down);

int orinoco_reinit_firmware(struct net_device *dev)
int orinoco_reinit_firmware(struct orinoco_private *priv)
{
	struct orinoco_private *priv = netdev_priv(dev);
	struct hermes *hw = &priv->hw;
	int err;

@@ -1887,7 +1886,7 @@ void orinoco_reset(struct work_struct *work)
		}
	}

	err = orinoco_reinit_firmware(dev);
	err = orinoco_reinit_firmware(priv);
	if (err) {
		printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n",
		       dev->name, err);
@@ -1902,7 +1901,7 @@ void orinoco_reset(struct work_struct *work)
	/* priv->open or priv->hw_unavailable might have changed while
	 * we dropped the lock */
	if (priv->open && (!priv->hw_unavailable)) {
		err = __orinoco_up(dev);
		err = __orinoco_up(priv);
		if (err) {
			printk(KERN_ERR "%s: orinoco_reset: Error %d reenabling card\n",
			       dev->name, err);
@@ -1938,8 +1937,8 @@ static void __orinoco_ev_wterr(struct net_device *dev, hermes_t *hw)

irqreturn_t orinoco_interrupt(int irq, void *dev_id)
{
	struct net_device *dev = dev_id;
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = dev_id;
	struct net_device *dev = priv->ndev;
	hermes_t *hw = &priv->hw;
	int count = MAX_IRQLOOPS_PER_IRQ;
	u16 evstat, events;
@@ -2192,7 +2191,7 @@ static const struct net_device_ops orinoco_netdev_ops = {
	.ndo_get_stats		= orinoco_get_stats,
};

struct net_device
struct orinoco_private
*alloc_orinocodev(int sizeof_card,
		  struct device *device,
		  int (*hard_reset)(struct orinoco_private *),
@@ -2255,13 +2254,13 @@ struct net_device
	/* Register PM notifiers */
	orinoco_register_pm_notifier(priv);

	return dev;
	return priv;
}
EXPORT_SYMBOL(alloc_orinocodev);

void free_orinocodev(struct net_device *dev)
void free_orinocodev(struct orinoco_private *priv)
{
	struct orinoco_private *priv = netdev_priv(dev);
	struct net_device *dev = priv->ndev;
	struct orinoco_rx_data *rx_data, *temp;

	/* If the tasklet is scheduled when we call tasklet_kill it
+5 −5
Original line number Diff line number Diff line
@@ -182,14 +182,14 @@ extern int orinoco_debug;
/* Exported prototypes                                              */
/********************************************************************/

extern struct net_device *alloc_orinocodev(
extern struct orinoco_private *alloc_orinocodev(
	int sizeof_card, struct device *device,
	int (*hard_reset)(struct orinoco_private *),
	int (*stop_fw)(struct orinoco_private *, int));
extern void free_orinocodev(struct net_device *dev);
extern int __orinoco_up(struct net_device *dev);
extern int __orinoco_down(struct net_device *dev);
extern int orinoco_reinit_firmware(struct net_device *dev);
extern void free_orinocodev(struct orinoco_private *priv);
extern int __orinoco_up(struct orinoco_private *priv);
extern int __orinoco_down(struct orinoco_private *priv);
extern int orinoco_reinit_firmware(struct orinoco_private *priv);
extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);

/********************************************************************/
+18 −21
Original line number Diff line number Diff line
@@ -106,26 +106,24 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
static int
orinoco_cs_probe(struct pcmcia_device *link)
{
	struct net_device *dev;
	struct orinoco_private *priv;
	struct orinoco_pccard *card;

	dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link),
	priv = alloc_orinocodev(sizeof(*card), &handle_to_dev(link),
				orinoco_cs_hard_reset, NULL);
	if (!dev)
	if (!priv)
		return -ENOMEM;
	priv = netdev_priv(dev);
	card = priv->card;

	/* Link both structures together */
	card->p_dev = link;
	link->priv = dev;
	link->priv = priv;

	/* Interrupt setup */
	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
	link->irq.IRQInfo1 = IRQ_LEVEL_ID;
	link->irq.Handler = orinoco_interrupt;
	link->irq.Instance = dev;
	link->irq.Instance = priv;

	/* General socket configuration defaults can go here.  In this
	 * client, we assume very little, and rely on the CIS for
@@ -146,14 +144,14 @@ orinoco_cs_probe(struct pcmcia_device *link)
 */
static void orinoco_cs_detach(struct pcmcia_device *link)
{
	struct net_device *dev = link->priv;
	struct orinoco_private *priv = link->priv;

	if (link->dev_node)
		unregister_netdev(dev);
		unregister_netdev(priv->ndev);

	orinoco_cs_release(link);

	free_orinocodev(dev);
	free_orinocodev(priv);
}				/* orinoco_cs_detach */

/*
@@ -239,9 +237,9 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
static int
orinoco_cs_config(struct pcmcia_device *link)
{
	struct net_device *dev = link->priv;
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = link->priv;
	struct orinoco_pccard *card = priv->card;
	struct net_device *dev = priv->ndev;
	hermes_t *hw = &priv->hw;
	int last_fn, last_ret;
	void __iomem *mem;
@@ -336,8 +334,7 @@ orinoco_cs_config(struct pcmcia_device *link)
static void
orinoco_cs_release(struct pcmcia_device *link)
{
	struct net_device *dev = link->priv;
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = link->priv;
	unsigned long flags;

	/* We're committed to taking the device away now, so mark the
@@ -353,9 +350,9 @@ orinoco_cs_release(struct pcmcia_device *link)

static int orinoco_cs_suspend(struct pcmcia_device *link)
{
	struct net_device *dev = link->priv;
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = link->priv;
	struct orinoco_pccard *card = priv->card;
	struct net_device *dev = priv->ndev;
	int err = 0;
	unsigned long flags;

@@ -365,7 +362,7 @@ static int orinoco_cs_suspend(struct pcmcia_device *link)
	if (!test_bit(0, &card->hard_reset_in_progress)) {
		spin_lock_irqsave(&priv->lock, flags);

		err = __orinoco_down(dev);
		err = __orinoco_down(priv);
		if (err)
			printk(KERN_WARNING "%s: Error %d downing interface\n",
			       dev->name, err);
@@ -381,14 +378,14 @@ static int orinoco_cs_suspend(struct pcmcia_device *link)

static int orinoco_cs_resume(struct pcmcia_device *link)
{
	struct net_device *dev = link->priv;
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = link->priv;
	struct orinoco_pccard *card = priv->card;
	struct net_device *dev = priv->ndev;
	int err = 0;
	unsigned long flags;

	if (!test_bit(0, &card->hard_reset_in_progress)) {
		err = orinoco_reinit_firmware(dev);
		err = orinoco_reinit_firmware(priv);
		if (err) {
			printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
			       dev->name, err);
@@ -401,7 +398,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
		priv->hw_unavailable--;

		if (priv->open && !priv->hw_unavailable) {
			err = __orinoco_up(dev);
			err = __orinoco_up(priv);
			if (err)
				printk(KERN_ERR "%s: Error %d restarting card\n",
				       dev->name, err);
+12 −12
Original line number Diff line number Diff line
@@ -181,15 +181,15 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
	}

	/* Allocate network device */
	dev = alloc_orinocodev(sizeof(*card), &pdev->dev,
	priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
				orinoco_nortel_cor_reset, NULL);
	if (!dev) {
	if (!priv) {
		printk(KERN_ERR PFX "Cannot allocate network device\n");
		err = -ENOMEM;
		goto fail_alloc;
	}

	priv = netdev_priv(dev);
	dev = priv->ndev;
	card = priv->card;
	card->bridge_io = bridge_io;
	card->attr_io = attr_io;
@@ -198,7 +198,7 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
	hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);

	err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
			  dev->name, dev);
			  dev->name, priv);
	if (err) {
		printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
		err = -EBUSY;
@@ -223,18 +223,18 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
		goto fail;
	}

	pci_set_drvdata(pdev, dev);
	pci_set_drvdata(pdev, priv);
	printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
	       pci_name(pdev));

	return 0;

 fail:
	free_irq(pdev->irq, dev);
	free_irq(pdev->irq, priv);

 fail_irq:
	pci_set_drvdata(pdev, NULL);
	free_orinocodev(dev);
	free_orinocodev(priv);

 fail_alloc:
	pci_iounmap(pdev, hermes_io);
@@ -256,17 +256,17 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,

static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev)
{
	struct net_device *dev = pci_get_drvdata(pdev);
	struct orinoco_private *priv = netdev_priv(dev);
	struct orinoco_private *priv = pci_get_drvdata(pdev);
	struct net_device *dev = priv->ndev;
	struct orinoco_pci_card *card = priv->card;

	/* Clear LEDs */
	iowrite16(0, card->bridge_io + 10);

	unregister_netdev(dev);
	free_irq(pdev->irq, dev);
	free_irq(pdev->irq, priv);
	pci_set_drvdata(pdev, NULL);
	free_orinocodev(dev);
	free_orinocodev(priv);
	pci_iounmap(pdev, priv->hw.iobase);
	pci_iounmap(pdev, card->attr_io);
	pci_iounmap(pdev, card->bridge_io);
Loading