BigW Consortium Gitlab

Commit 22f5b0fc by David Frey

mt7697q: Remove tx/rx buffers from mt7697_qinfo

There was no point in permanently allocating the buffers since their lifetime was function scoped and thus they could be converted to stack variables.
parent 3b24d517
...@@ -31,16 +31,15 @@ static bool mt7697io_busy(u16 value) ...@@ -31,16 +31,15 @@ static bool mt7697io_busy(u16 value)
static int mt7697io_write16(struct mt7697q_info *qinfo, u8 reg, u16 value) static int mt7697io_write16(struct mt7697q_info *qinfo, u8 reg, u16 value)
{ {
int ret; int ret;
u8 txBuffer[] = {
MT7697_IO_CMD_WRITE,
reg,
((value >> 8) & 0xFF),
value & 0xFF,
};
WARN_ON(reg % sizeof(u16)); WARN_ON(reg % sizeof(u16));
ret = qinfo->hw_ops->write(qinfo->hw_priv, txBuffer, sizeof(txBuffer));
qinfo->txBuffer[0] = MT7697_IO_CMD_WRITE;
qinfo->txBuffer[1] = reg;
qinfo->txBuffer[2] = ((value >> 8) & 0xFF);
qinfo->txBuffer[3] = value & 0xFF;
ret = qinfo->hw_ops->write(qinfo->hw_priv, qinfo->txBuffer,
sizeof(qinfo->txBuffer));
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, "%s(): write() failed(%d)\n", dev_err(qinfo->dev, "%s(): write() failed(%d)\n",
__func__, ret); __func__, ret);
...@@ -78,21 +77,21 @@ cleanup: ...@@ -78,21 +77,21 @@ cleanup:
static int mt7697io_read16(struct mt7697q_info *qinfo, u8 reg, u16 *value) static int mt7697io_read16(struct mt7697q_info *qinfo, u8 reg, u16 *value)
{ {
int ret; int ret;
u8 spi_buffer[4] = {
MT7697_IO_CMD_READ,
reg,
};
WARN_ON(reg % sizeof(u16)); WARN_ON(reg % sizeof(u16));
ret = qinfo->hw_ops->write_then_read(qinfo->hw_priv, spi_buffer,
qinfo->txBuffer[0] = MT7697_IO_CMD_READ; spi_buffer, sizeof(spi_buffer));
qinfo->txBuffer[1] = reg;
ret = qinfo->hw_ops->write_then_read(qinfo->hw_priv,
qinfo->txBuffer, qinfo->rxBuffer, sizeof(u16) + sizeof(u16));
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, "%s(): write_then_read() failed(%d)\n", dev_err(qinfo->dev, "%s(): write_then_read() failed(%d)\n",
__func__, ret); __func__, ret);
goto cleanup; goto cleanup;
} }
*value = ((qinfo->rxBuffer[2] << 8) | qinfo->rxBuffer[3]); *value = ((spi_buffer[2] << 8) | spi_buffer[3]);
cleanup: cleanup:
return ret; return ret;
......
...@@ -55,8 +55,6 @@ struct mt7697q_spec { ...@@ -55,8 +55,6 @@ struct mt7697q_spec {
struct mt7697q_info { struct mt7697q_info {
struct mt7697q_spec queues[MT7697_NUM_QUEUES]; struct mt7697q_spec queues[MT7697_NUM_QUEUES];
struct mt7697_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
u8 txBuffer[sizeof(u32)];
u8 rxBuffer[sizeof(u32)];
struct device *dev; struct device *dev;
void *hw_priv; void *hw_priv;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment