1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-28 04:44:03 +02:00
openwrt-xburst/package/mac80211/patches/406-ath9k-convert-to-struct-device.patch
juhosg 1be286180b [package] mac80211: add preliminary support for the AR913x SoCs
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13835 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-01-03 13:48:27 +00:00

145 lines
4.2 KiB
Diff

From 5e7bcb74706e6398ea582001fe025e6eb0c5c998 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Fri, 2 Jan 2009 16:10:55 +0100
Subject: [RFC 06/12] ath9k: convert to struct device
Now that we have converted all bus specific routines to replaceable, we
can move the PCI specific codes into a separate file.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
---
drivers/net/wireless/ath9k/core.h | 5 +++--
drivers/net/wireless/ath9k/pci.c | 35 ++++++++++++++++++++---------------
2 files changed, 23 insertions(+), 17 deletions(-)
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -18,7 +18,8 @@
#define CORE_H
#include <linux/etherdevice.h>
-#include <linux/pci.h>
+#include <linux/device.h>
+#include <linux/types.h>
#include <net/mac80211.h>
#include <linux/leds.h>
#include <linux/rfkill.h>
@@ -729,7 +730,7 @@ struct ath_bus_ops {
struct ath_softc {
struct ieee80211_hw *hw;
- struct pci_dev *pdev;
+ struct device *dev;
struct tasklet_struct intr_tq;
struct tasklet_struct bcon_tasklet;
struct ath_hal *sc_ah;
--- a/drivers/net/wireless/ath9k/pci.c
+++ b/drivers/net/wireless/ath9k/pci.c
@@ -15,6 +15,8 @@
*/
#include <linux/nl80211.h>
+#include <linux/pci.h>
+
#include "core.h"
#include "reg.h"
#include "hw.h"
@@ -34,7 +36,8 @@ static void ath_pci_read_cachesize(struc
{
u8 u8tmp;
- pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, (u8 *)&u8tmp);
+ pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE,
+ (u8 *)&u8tmp);
*csz = (int)u8tmp;
/*
@@ -50,49 +53,49 @@ static void ath_pci_read_cachesize(struc
static dma_addr_t ath_pci_map_single_to_device(struct ath_softc *sc,
void *p, size_t size)
{
- return pci_map_single(sc->pdev, p, size, PCI_DMA_TODEVICE);
+ return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_TODEVICE);
}
static void ath_pci_unmap_single_to_device(struct ath_softc *sc,
dma_addr_t da, size_t size)
{
- pci_unmap_single(sc->pdev, da, size, PCI_DMA_TODEVICE);
+ pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_TODEVICE);
}
static dma_addr_t ath_pci_map_single_from_device(struct ath_softc *sc,
void *p, size_t size)
{
- return pci_map_single(sc->pdev, p, size, PCI_DMA_FROMDEVICE);
+ return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_FROMDEVICE);
}
static void ath_pci_unmap_single_from_device(struct ath_softc *sc,
dma_addr_t da, size_t size)
{
- pci_unmap_single(sc->pdev, da, size, PCI_DMA_FROMDEVICE);
+ pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_FROMDEVICE);
}
static int ath_pci_dma_mapping_error(struct ath_softc *sc, dma_addr_t da)
{
- return pci_dma_mapping_error(sc->pdev, da);
+ return pci_dma_mapping_error(to_pci_dev(sc->dev), da);
}
static void ath_pci_sync_single_for_cpu(struct ath_softc *sc, dma_addr_t da,
size_t size)
{
- pci_dma_sync_single_for_cpu(sc->pdev, da, size,
+ pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev), da, size,
PCI_DMA_FROMDEVICE);
}
static void *ath_pci_dma_alloc(struct ath_softc *sc, size_t size,
dma_addr_t *pda)
{
- return pci_alloc_consistent(sc->pdev, size, pda);
+ return pci_alloc_consistent(to_pci_dev(sc->dev), size, pda);
}
static void ath_pci_dma_free(struct ath_softc *sc, size_t size,
void *p, dma_addr_t da)
{
- pci_free_consistent(sc->pdev, size, p, da);
+ pci_free_consistent(to_pci_dev(sc->dev), size, p, da);
}
static u32 ath_pci_reg_read(struct ath_hal *ah, unsigned reg)
@@ -107,12 +110,14 @@ static void ath_pci_reg_write(struct ath
static void ath_pci_cleanup(struct ath_softc *sc)
{
+ struct pci_dev *pdev = to_pci_dev(sc->dev);
+
ath_detach(sc);
- if (sc->pdev->irq)
- free_irq(sc->pdev->irq, sc);
- pci_iounmap(sc->pdev, sc->mem);
- pci_release_region(sc->pdev, 0);
- pci_disable_device(sc->pdev);
+ if (pdev->irq)
+ free_irq(pdev->irq, sc);
+ pci_iounmap(pdev, sc->mem);
+ pci_release_region(pdev, 0);
+ pci_disable_device(pdev);
ieee80211_free_hw(sc->hw);
}
@@ -221,7 +226,7 @@ static int ath_pci_probe(struct pci_dev
sc = hw->priv;
sc->hw = hw;
- sc->pdev = pdev;
+ sc->dev = &pdev->dev;
sc->mem = mem;
sc->bus_ops = &ath_pci_bus_ops;