[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181220010647.4059-5-marex@denx.de>
Date: Thu, 20 Dec 2018 02:06:44 +0100
From: Marek Vasut <marex@...x.de>
To: netdev@...r.kernel.org
Cc: f.fainelli@...il.com, andrew@...n.ch, Marek Vasut <marex@...x.de>,
Tristram Ha <Tristram.Ha@...rochip.com>,
Woojung Huh <Woojung.Huh@...rochip.com>
Subject: [RFT][PATCH 4/7] net: dsa: microchip: Remove dev->txbuf
Previous patches unconver that ksz_spi_write() is always ever called
with len = 1, 2 or 4. We can thus drop the if (len > SPI_TX_BUF_LEN)
check and we can also drop the allocation of the txbuf which is part
of the driver data. This wastes 256 bytes for no reason and can be
replaced with 8-byte stack allocated buffer, which is what this patch
does. This is an intermediate step though, which will go away after
regmap conversion.
Signed-off-by: Marek Vasut <marex@...x.de>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Florian Fainelli <f.fainelli@...il.com>
Cc: Tristram Ha <Tristram.Ha@...rochip.com>
Cc: Woojung Huh <Woojung.Huh@...rochip.com>
---
drivers/net/dsa/microchip/ksz9477_spi.c | 10 ++++------
drivers/net/dsa/microchip/ksz_priv.h | 2 --
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz9477_spi.c b/drivers/net/dsa/microchip/ksz9477_spi.c
index 9ca150a472ea..69baf9677def 100644
--- a/drivers/net/dsa/microchip/ksz9477_spi.c
+++ b/drivers/net/dsa/microchip/ksz9477_spi.c
@@ -65,11 +65,11 @@ static int ksz_spi_write(struct ksz_device *dev, u32 reg, void *data,
unsigned int len)
{
struct spi_device *spi = dev->priv;
+ u8 txbuf[8];
- if (len > SPI_TX_BUF_LEN)
- len = SPI_TX_BUF_LEN;
- memcpy(&dev->txbuf[4], data, len);
- return ksz9477_spi_write_reg(spi, reg, dev->txbuf, len);
+ memcpy(txbuf + 4, data, len);
+
+ return ksz9477_spi_write_reg(spi, reg, txbuf, len);
}
static int ksz_spi_read8(struct ksz_device *dev, u32 reg, u8 *val)
@@ -135,8 +135,6 @@ static int ksz9477_spi_probe(struct spi_device *spi)
if (spi->dev.platform_data)
dev->pdata = spi->dev.platform_data;
- dev->txbuf = devm_kzalloc(dev->dev, 4 + SPI_TX_BUF_LEN, GFP_KERNEL);
-
ret = ksz9477_switch_register(dev);
/* Main DSA driver may not be started yet. */
diff --git a/drivers/net/dsa/microchip/ksz_priv.h b/drivers/net/dsa/microchip/ksz_priv.h
index c3a272505af1..3ab14ee0e36b 100644
--- a/drivers/net/dsa/microchip/ksz_priv.h
+++ b/drivers/net/dsa/microchip/ksz_priv.h
@@ -81,8 +81,6 @@ struct ksz_device {
u64 mib_value[TOTAL_SWITCH_COUNTER_NUM];
- u8 *txbuf;
-
struct ksz_port *ports;
struct timer_list mib_read_timer;
struct work_struct mib_read;
--
2.19.2
Powered by blists - more mailing lists