From 78155b54aca453650f6e24421d2e20a7d8ba4a97 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 5 Feb 2016 01:05:56 +0100 Subject: [PATCH] unify drvdata handling Signed-off-by: Felix Fietkau --- mac80211.c | 2 ++ mt7603_pci.c | 5 ++--- mt76x2_pci.c | 9 ++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mac80211.c b/mac80211.c index fc01bba6..0dca789c 100644 --- a/mac80211.c +++ b/mac80211.c @@ -166,6 +166,8 @@ int mt76_register_device(struct mt76_dev *dev, bool vht, struct wiphy *wiphy = hw->wiphy; int ret; + dev_set_drvdata(dev->dev, dev); + spin_lock_init(&dev->lock); INIT_LIST_HEAD(&dev->txwi_cache); diff --git a/mt7603_pci.c b/mt7603_pci.c index ca648907..06a82259 100644 --- a/mt7603_pci.c +++ b/mt7603_pci.c @@ -48,8 +48,6 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]); - pci_set_drvdata(pdev, dev); - dev->mt76.rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) | (mt76_rr(dev, MT_HW_REV) & 0xff); dev_printk(KERN_INFO, dev->mt76.dev, "ASIC revision: %04x\n", dev->mt76.rev); @@ -72,7 +70,8 @@ error: static void mt76pci_remove(struct pci_dev *pdev) { - struct mt7603_dev *dev = pci_get_drvdata(pdev); + struct mt76_dev *mdev = pci_get_drvdata(pdev); + struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); mt76_unregister_device(&dev->mt76); mt7603_mcu_exit(dev); diff --git a/mt76x2_pci.c b/mt76x2_pci.c index ab19e726..8800a46b 100644 --- a/mt76x2_pci.c +++ b/mt76x2_pci.c @@ -49,8 +49,6 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]); - pci_set_drvdata(pdev, dev); - dev->mt76.rev = mt76_rr(dev, MT_ASIC_VERSION); dev_printk(KERN_INFO, dev->mt76.dev, "ASIC revision: %08x\n", dev->mt76.rev); @@ -84,11 +82,12 @@ error: static void mt76pci_remove(struct pci_dev *pdev) { - struct mt76x2_dev *dev = pci_get_drvdata(pdev); + struct mt76_dev *mdev = pci_get_drvdata(pdev); + struct mt76x2_dev *dev = container_of(mdev, struct mt76x2_dev, mt76); - ieee80211_unregister_hw(mt76_hw(dev)); + ieee80211_unregister_hw(mdev->hw); mt76x2_cleanup(dev); - ieee80211_free_hw(mt76_hw(dev)); + ieee80211_free_hw(mdev->hw); } MODULE_DEVICE_TABLE(pci, mt76pci_device_table);