P54: use temporary variables to reduce size of generated code
When there are 2 linked structures, using a temporary variable to hold a pointer to the often used structure usually produces better code (smaller and faster) since compiler does not have to constantly re-fetch data from the first structure. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
David S. Miller
parent
1b34fd390c
commit
eb76bf29dd
@@ -141,6 +141,7 @@ static irqreturn_t p54p_simple_interrupt(int irq, void *dev_id)
|
|||||||
static int p54p_read_eeprom(struct ieee80211_hw *dev)
|
static int p54p_read_eeprom(struct ieee80211_hw *dev)
|
||||||
{
|
{
|
||||||
struct p54p_priv *priv = dev->priv;
|
struct p54p_priv *priv = dev->priv;
|
||||||
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
||||||
int err;
|
int err;
|
||||||
struct p54_control_hdr *hdr;
|
struct p54_control_hdr *hdr;
|
||||||
void *eeprom;
|
void *eeprom;
|
||||||
@@ -164,7 +165,7 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(priv->ring_control, 0, sizeof(*priv->ring_control));
|
memset(ring_control, 0, sizeof(*ring_control));
|
||||||
P54P_WRITE(ring_control_base, priv->ring_control_dma);
|
P54P_WRITE(ring_control_base, priv->ring_control_dma);
|
||||||
P54P_READ(ring_control_base);
|
P54P_READ(ring_control_base);
|
||||||
udelay(10);
|
udelay(10);
|
||||||
@@ -194,14 +195,14 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
|
|||||||
tx_mapping = pci_map_single(priv->pdev, (void *)hdr,
|
tx_mapping = pci_map_single(priv->pdev, (void *)hdr,
|
||||||
EEPROM_READBACK_LEN, PCI_DMA_TODEVICE);
|
EEPROM_READBACK_LEN, PCI_DMA_TODEVICE);
|
||||||
|
|
||||||
priv->ring_control->rx_mgmt[0].host_addr = cpu_to_le32(rx_mapping);
|
ring_control->rx_mgmt[0].host_addr = cpu_to_le32(rx_mapping);
|
||||||
priv->ring_control->rx_mgmt[0].len = cpu_to_le16(0x2010);
|
ring_control->rx_mgmt[0].len = cpu_to_le16(0x2010);
|
||||||
priv->ring_control->tx_data[0].host_addr = cpu_to_le32(tx_mapping);
|
ring_control->tx_data[0].host_addr = cpu_to_le32(tx_mapping);
|
||||||
priv->ring_control->tx_data[0].device_addr = hdr->req_id;
|
ring_control->tx_data[0].device_addr = hdr->req_id;
|
||||||
priv->ring_control->tx_data[0].len = cpu_to_le16(EEPROM_READBACK_LEN);
|
ring_control->tx_data[0].len = cpu_to_le16(EEPROM_READBACK_LEN);
|
||||||
|
|
||||||
priv->ring_control->host_idx[2] = cpu_to_le32(1);
|
ring_control->host_idx[2] = cpu_to_le32(1);
|
||||||
priv->ring_control->host_idx[1] = cpu_to_le32(1);
|
ring_control->host_idx[1] = cpu_to_le32(1);
|
||||||
|
|
||||||
wmb();
|
wmb();
|
||||||
mdelay(100);
|
mdelay(100);
|
||||||
@@ -215,8 +216,8 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
|
|||||||
pci_unmap_single(priv->pdev, rx_mapping,
|
pci_unmap_single(priv->pdev, rx_mapping,
|
||||||
0x2010, PCI_DMA_FROMDEVICE);
|
0x2010, PCI_DMA_FROMDEVICE);
|
||||||
|
|
||||||
alen = le16_to_cpu(priv->ring_control->rx_mgmt[0].len);
|
alen = le16_to_cpu(ring_control->rx_mgmt[0].len);
|
||||||
if (le32_to_cpu(priv->ring_control->device_idx[2]) != 1 ||
|
if (le32_to_cpu(ring_control->device_idx[2]) != 1 ||
|
||||||
alen < 0x10) {
|
alen < 0x10) {
|
||||||
printk(KERN_ERR "%s (prism54pci): Cannot read eeprom!\n",
|
printk(KERN_ERR "%s (prism54pci): Cannot read eeprom!\n",
|
||||||
pci_name(priv->pdev));
|
pci_name(priv->pdev));
|
||||||
@@ -239,16 +240,17 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
|
|||||||
static void p54p_refill_rx_ring(struct ieee80211_hw *dev)
|
static void p54p_refill_rx_ring(struct ieee80211_hw *dev)
|
||||||
{
|
{
|
||||||
struct p54p_priv *priv = dev->priv;
|
struct p54p_priv *priv = dev->priv;
|
||||||
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
||||||
u32 limit, host_idx, idx;
|
u32 limit, host_idx, idx;
|
||||||
|
|
||||||
host_idx = le32_to_cpu(priv->ring_control->host_idx[0]);
|
host_idx = le32_to_cpu(ring_control->host_idx[0]);
|
||||||
limit = host_idx;
|
limit = host_idx;
|
||||||
limit -= le32_to_cpu(priv->ring_control->device_idx[0]);
|
limit -= le32_to_cpu(ring_control->device_idx[0]);
|
||||||
limit = ARRAY_SIZE(priv->ring_control->rx_data) - limit;
|
limit = ARRAY_SIZE(ring_control->rx_data) - limit;
|
||||||
|
|
||||||
idx = host_idx % ARRAY_SIZE(priv->ring_control->rx_data);
|
idx = host_idx % ARRAY_SIZE(ring_control->rx_data);
|
||||||
while (limit-- > 1) {
|
while (limit-- > 1) {
|
||||||
struct p54p_desc *desc = &priv->ring_control->rx_data[idx];
|
struct p54p_desc *desc = &ring_control->rx_data[idx];
|
||||||
|
|
||||||
if (!desc->host_addr) {
|
if (!desc->host_addr) {
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
@@ -270,17 +272,18 @@ static void p54p_refill_rx_ring(struct ieee80211_hw *dev)
|
|||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
host_idx++;
|
host_idx++;
|
||||||
idx %= ARRAY_SIZE(priv->ring_control->rx_data);
|
idx %= ARRAY_SIZE(ring_control->rx_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
wmb();
|
wmb();
|
||||||
priv->ring_control->host_idx[0] = cpu_to_le32(host_idx);
|
ring_control->host_idx[0] = cpu_to_le32(host_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t p54p_interrupt(int irq, void *dev_id)
|
static irqreturn_t p54p_interrupt(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
struct ieee80211_hw *dev = dev_id;
|
struct ieee80211_hw *dev = dev_id;
|
||||||
struct p54p_priv *priv = dev->priv;
|
struct p54p_priv *priv = dev->priv;
|
||||||
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
||||||
__le32 reg;
|
__le32 reg;
|
||||||
|
|
||||||
spin_lock(&priv->lock);
|
spin_lock(&priv->lock);
|
||||||
@@ -298,12 +301,12 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
|
|||||||
struct p54p_desc *desc;
|
struct p54p_desc *desc;
|
||||||
u32 idx, i;
|
u32 idx, i;
|
||||||
i = priv->tx_idx;
|
i = priv->tx_idx;
|
||||||
i %= ARRAY_SIZE(priv->ring_control->tx_data);
|
i %= ARRAY_SIZE(ring_control->tx_data);
|
||||||
priv->tx_idx = idx = le32_to_cpu(priv->ring_control->device_idx[1]);
|
priv->tx_idx = idx = le32_to_cpu(ring_control->device_idx[1]);
|
||||||
idx %= ARRAY_SIZE(priv->ring_control->tx_data);
|
idx %= ARRAY_SIZE(ring_control->tx_data);
|
||||||
|
|
||||||
while (i != idx) {
|
while (i != idx) {
|
||||||
desc = &priv->ring_control->tx_data[i];
|
desc = &ring_control->tx_data[i];
|
||||||
if (priv->tx_buf[i]) {
|
if (priv->tx_buf[i]) {
|
||||||
kfree(priv->tx_buf[i]);
|
kfree(priv->tx_buf[i]);
|
||||||
priv->tx_buf[i] = NULL;
|
priv->tx_buf[i] = NULL;
|
||||||
@@ -318,17 +321,17 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
|
|||||||
desc->flags = 0;
|
desc->flags = 0;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
i %= ARRAY_SIZE(priv->ring_control->tx_data);
|
i %= ARRAY_SIZE(ring_control->tx_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = priv->rx_idx;
|
i = priv->rx_idx;
|
||||||
i %= ARRAY_SIZE(priv->ring_control->rx_data);
|
i %= ARRAY_SIZE(ring_control->rx_data);
|
||||||
priv->rx_idx = idx = le32_to_cpu(priv->ring_control->device_idx[0]);
|
priv->rx_idx = idx = le32_to_cpu(ring_control->device_idx[0]);
|
||||||
idx %= ARRAY_SIZE(priv->ring_control->rx_data);
|
idx %= ARRAY_SIZE(ring_control->rx_data);
|
||||||
while (i != idx) {
|
while (i != idx) {
|
||||||
u16 len;
|
u16 len;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
desc = &priv->ring_control->rx_data[i];
|
desc = &ring_control->rx_data[i];
|
||||||
len = le16_to_cpu(desc->len);
|
len = le16_to_cpu(desc->len);
|
||||||
skb = priv->rx_buf[i];
|
skb = priv->rx_buf[i];
|
||||||
|
|
||||||
@@ -347,7 +350,7 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
i %= ARRAY_SIZE(priv->ring_control->rx_data);
|
i %= ARRAY_SIZE(ring_control->rx_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
p54p_refill_rx_ring(dev);
|
p54p_refill_rx_ring(dev);
|
||||||
@@ -366,6 +369,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data,
|
|||||||
size_t len, int free_on_tx)
|
size_t len, int free_on_tx)
|
||||||
{
|
{
|
||||||
struct p54p_priv *priv = dev->priv;
|
struct p54p_priv *priv = dev->priv;
|
||||||
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct p54p_desc *desc;
|
struct p54p_desc *desc;
|
||||||
dma_addr_t mapping;
|
dma_addr_t mapping;
|
||||||
@@ -373,19 +377,19 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data,
|
|||||||
|
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
spin_lock_irqsave(&priv->lock, flags);
|
||||||
|
|
||||||
device_idx = le32_to_cpu(priv->ring_control->device_idx[1]);
|
device_idx = le32_to_cpu(ring_control->device_idx[1]);
|
||||||
idx = le32_to_cpu(priv->ring_control->host_idx[1]);
|
idx = le32_to_cpu(ring_control->host_idx[1]);
|
||||||
i = idx % ARRAY_SIZE(priv->ring_control->tx_data);
|
i = idx % ARRAY_SIZE(ring_control->tx_data);
|
||||||
|
|
||||||
mapping = pci_map_single(priv->pdev, data, len, PCI_DMA_TODEVICE);
|
mapping = pci_map_single(priv->pdev, data, len, PCI_DMA_TODEVICE);
|
||||||
desc = &priv->ring_control->tx_data[i];
|
desc = &ring_control->tx_data[i];
|
||||||
desc->host_addr = cpu_to_le32(mapping);
|
desc->host_addr = cpu_to_le32(mapping);
|
||||||
desc->device_addr = data->req_id;
|
desc->device_addr = data->req_id;
|
||||||
desc->len = cpu_to_le16(len);
|
desc->len = cpu_to_le16(len);
|
||||||
desc->flags = 0;
|
desc->flags = 0;
|
||||||
|
|
||||||
wmb();
|
wmb();
|
||||||
priv->ring_control->host_idx[1] = cpu_to_le32(idx + 1);
|
ring_control->host_idx[1] = cpu_to_le32(idx + 1);
|
||||||
|
|
||||||
if (free_on_tx)
|
if (free_on_tx)
|
||||||
priv->tx_buf[i] = data;
|
priv->tx_buf[i] = data;
|
||||||
@@ -397,7 +401,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data,
|
|||||||
|
|
||||||
/* FIXME: unlikely to happen because the device usually runs out of
|
/* FIXME: unlikely to happen because the device usually runs out of
|
||||||
memory before we fill the ring up, but we can make it impossible */
|
memory before we fill the ring up, but we can make it impossible */
|
||||||
if (idx - device_idx > ARRAY_SIZE(priv->ring_control->tx_data) - 2)
|
if (idx - device_idx > ARRAY_SIZE(ring_control->tx_data) - 2)
|
||||||
printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy));
|
printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +461,7 @@ static int p54p_open(struct ieee80211_hw *dev)
|
|||||||
static void p54p_stop(struct ieee80211_hw *dev)
|
static void p54p_stop(struct ieee80211_hw *dev)
|
||||||
{
|
{
|
||||||
struct p54p_priv *priv = dev->priv;
|
struct p54p_priv *priv = dev->priv;
|
||||||
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct p54p_desc *desc;
|
struct p54p_desc *desc;
|
||||||
|
|
||||||
@@ -469,7 +474,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
|
|||||||
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
|
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(priv->rx_buf); i++) {
|
for (i = 0; i < ARRAY_SIZE(priv->rx_buf); i++) {
|
||||||
desc = &priv->ring_control->rx_data[i];
|
desc = &ring_control->rx_data[i];
|
||||||
if (desc->host_addr)
|
if (desc->host_addr)
|
||||||
pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
|
pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
|
||||||
MAX_RX_SIZE, PCI_DMA_FROMDEVICE);
|
MAX_RX_SIZE, PCI_DMA_FROMDEVICE);
|
||||||
@@ -478,7 +483,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(priv->tx_buf); i++) {
|
for (i = 0; i < ARRAY_SIZE(priv->tx_buf); i++) {
|
||||||
desc = &priv->ring_control->tx_data[i];
|
desc = &ring_control->tx_data[i];
|
||||||
if (desc->host_addr)
|
if (desc->host_addr)
|
||||||
pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
|
pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
|
||||||
le16_to_cpu(desc->len), PCI_DMA_TODEVICE);
|
le16_to_cpu(desc->len), PCI_DMA_TODEVICE);
|
||||||
@@ -487,7 +492,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
|
|||||||
priv->tx_buf[i] = NULL;
|
priv->tx_buf[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(priv->ring_control, 0, sizeof(*priv->ring_control));
|
memset(ring_control, 0, sizeof(ring_control));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devinit p54p_probe(struct pci_dev *pdev,
|
static int __devinit p54p_probe(struct pci_dev *pdev,
|
||||||
|
Reference in New Issue
Block a user