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

Commit 14a3bf89 authored by Gertjan van Wingerde's avatar Gertjan van Wingerde Committed by John W. Linville
Browse files

rt2x00: Convert rt2x00 to use generic DMA-mapping API



At the same time clean up the device administration a bit, by storing a pointer
to struct device instead of a void pointer that is dependent on the type of
device. The normal PCI and USB subsystem provided macros can be used to convert
the device pointer to the right type.
This makes the rt2x00 driver a bit more type-safe.

Signed-off-by: default avatarGertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c95edf54
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1366,7 +1366,7 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
			       IEEE80211_HW_SIGNAL_DBM;
	rt2x00dev->hw->extra_tx_headroom = 0;

	SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev);
	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
				rt2x00_eeprom_addr(rt2x00dev,
						   EEPROM_MAC_ADDR_0));
+1 −1
Original line number Diff line number Diff line
@@ -1688,7 +1688,7 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)

	rt2x00dev->hw->extra_tx_headroom = 0;

	SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev);
	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
				rt2x00_eeprom_addr(rt2x00dev,
						   EEPROM_MAC_ADDR_0));
+3 −2
Original line number Diff line number Diff line
@@ -1588,7 +1588,7 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)

	rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;

	SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev);
	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
				rt2x00_eeprom_addr(rt2x00dev,
						   EEPROM_MAC_ADDR_0));
@@ -1672,7 +1672,8 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
{
	struct rt2x00_dev *rt2x00dev = hw->priv;
	struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev);
	struct usb_device *usb_dev =
		interface_to_usbdev(to_usb_interface(rt2x00dev->dev));
	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
	struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
	struct queue_entry_priv_usb_bcn *bcn_priv;
+1 −5
Original line number Diff line number Diff line
@@ -625,11 +625,7 @@ struct rt2x00_dev {
	 * When accessing this variable, the rt2x00dev_{pci,usb}
	 * macro's should be used for correct typecasting.
	 */
	void *dev;
#define rt2x00dev_pci(__dev)	( (struct pci_dev *)(__dev)->dev )
#define rt2x00dev_usb(__dev)	( (struct usb_interface *)(__dev)->dev )
#define rt2x00dev_usb_dev(__dev)\
	( (struct usb_device *)interface_to_usbdev(rt2x00dev_usb(__dev)) )
	struct device *dev;

	/*
	 * Callback functions.
+9 −10
Original line number Diff line number Diff line
@@ -194,7 +194,6 @@ EXPORT_SYMBOL_GPL(rt2x00pci_txdone);
static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev,
				     struct data_queue *queue)
{
	struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev);
	struct queue_entry_priv_pci *entry_priv;
	void *addr;
	dma_addr_t dma;
@@ -203,7 +202,8 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev,
	/*
	 * Allocate DMA memory for descriptor and buffer.
	 */
	addr = pci_alloc_consistent(pci_dev, dma_size(queue), &dma);
	addr = dma_alloc_coherent(rt2x00dev->dev, dma_size(queue), &dma,
				  GFP_KERNEL | GFP_DMA);
	if (!addr)
		return -ENOMEM;

@@ -226,19 +226,18 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev,
static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev,
				     struct data_queue *queue)
{
	struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev);
	struct queue_entry_priv_pci *entry_priv =
	    queue->entries[0].priv_data;

	if (entry_priv->data)
		pci_free_consistent(pci_dev, dma_size(queue),
		dma_free_coherent(rt2x00dev->dev, dma_size(queue),
				  entry_priv->data, entry_priv->data_dma);
	entry_priv->data = NULL;
}

int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
{
	struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev);
	struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
	struct data_queue *queue;
	int status;

@@ -279,7 +278,7 @@ void rt2x00pci_uninitialize(struct rt2x00_dev *rt2x00dev)
	/*
	 * Free irq line.
	 */
	free_irq(rt2x00dev_pci(rt2x00dev)->irq, rt2x00dev);
	free_irq(to_pci_dev(rt2x00dev->dev)->irq, rt2x00dev);

	/*
	 * Free DMA
@@ -308,7 +307,7 @@ static void rt2x00pci_free_reg(struct rt2x00_dev *rt2x00dev)

static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev)
{
	struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev);
	struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);

	rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0),
				      pci_resource_len(pci_dev, 0));
@@ -357,7 +356,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
	if (pci_set_mwi(pci_dev))
		ERROR_PROBE("MWI not available.\n");

	if (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) {
	if (dma_set_mask(&pci_dev->dev, DMA_32BIT_MASK)) {
		ERROR_PROBE("PCI DMA not supported.\n");
		retval = -EIO;
		goto exit_disable_device;
@@ -373,7 +372,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
	pci_set_drvdata(pci_dev, hw);

	rt2x00dev = hw->priv;
	rt2x00dev->dev = pci_dev;
	rt2x00dev->dev = &pci_dev->dev;
	rt2x00dev->ops = ops;
	rt2x00dev->hw = hw;

Loading