Skip to content

Commit

Permalink
orinoco: Replace net_device with orinoco_private in driver interfaces
Browse files Browse the repository at this point in the history
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: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
David Kilroy authored and John W. Linville committed Jul 10, 2009
1 parent 44d8dad commit a260836
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 139 deletions.
36 changes: 18 additions & 18 deletions drivers/net/wireless/orinoco/airport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -111,16 +111,16 @@ 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)
unregister_netdev(dev);
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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -185,27 +185,27 @@ 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,
airport_hard_reset, NULL);
if (!dev) {
priv = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev,
airport_hard_reset, NULL);
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;
card->mdev = mdev;

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);
Expand All @@ -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;
}
Expand Down
31 changes: 15 additions & 16 deletions drivers/net/wireless/orinoco/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 *),
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/wireless/orinoco/orinoco.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/********************************************************************/
Expand Down
39 changes: 18 additions & 21 deletions drivers/net/wireless/orinoco/orinoco_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
orinoco_cs_hard_reset, NULL);
if (!dev)
priv = alloc_orinocodev(sizeof(*card), &handle_to_dev(link),
orinoco_cs_hard_reset, NULL);
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
Expand All @@ -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 */

/*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit a260836

Please sign in to comment.