|
@@ -585,6 +585,7 @@ static int if_spi_prog_main_firmware_check_len(struct if_spi_card *card,
|
|
|
static int if_spi_prog_main_firmware(struct if_spi_card *card,
|
|
|
const struct firmware *firmware)
|
|
|
{
|
|
|
+ struct lbs_private *priv = card->priv;
|
|
|
int len, prev_len;
|
|
|
int bytes, crc_err = 0, err = 0;
|
|
|
const u8 *fw;
|
|
@@ -598,8 +599,9 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
|
|
|
|
|
|
err = spu_wait_for_u16(card, IF_SPI_SCRATCH_1_REG, 0, 0);
|
|
|
if (err) {
|
|
|
- pr_err("%s: timed out waiting for initial scratch reg = 0\n",
|
|
|
- __func__);
|
|
|
+ netdev_err(priv->dev,
|
|
|
+ "%s: timed out waiting for initial scratch reg = 0\n",
|
|
|
+ __func__);
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
@@ -617,7 +619,8 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
|
|
|
* If there are no more bytes left, we would normally
|
|
|
* expect to have terminated with len = 0
|
|
|
*/
|
|
|
- pr_err("Firmware load wants more bytes than we have to offer.\n");
|
|
|
+ netdev_err(priv->dev,
|
|
|
+ "Firmware load wants more bytes than we have to offer.\n");
|
|
|
break;
|
|
|
}
|
|
|
if (crc_err) {
|
|
@@ -706,12 +709,14 @@ static int if_spi_c2h_cmd(struct if_spi_card *card)
|
|
|
if (err)
|
|
|
goto out;
|
|
|
if (!len) {
|
|
|
- pr_err("%s: error: card has no data for host\n", __func__);
|
|
|
+ netdev_err(priv->dev, "%s: error: card has no data for host\n",
|
|
|
+ __func__);
|
|
|
err = -EINVAL;
|
|
|
goto out;
|
|
|
} else if (len > IF_SPI_CMD_BUF_SIZE) {
|
|
|
- pr_err("%s: error: response packet too large: %d bytes, but maximum is %d\n",
|
|
|
- __func__, len, IF_SPI_CMD_BUF_SIZE);
|
|
|
+ netdev_err(priv->dev,
|
|
|
+ "%s: error: response packet too large: %d bytes, but maximum is %d\n",
|
|
|
+ __func__, len, IF_SPI_CMD_BUF_SIZE);
|
|
|
err = -EINVAL;
|
|
|
goto out;
|
|
|
}
|
|
@@ -732,7 +737,7 @@ static int if_spi_c2h_cmd(struct if_spi_card *card)
|
|
|
|
|
|
out:
|
|
|
if (err)
|
|
|
- pr_err("%s: err=%d\n", __func__, err);
|
|
|
+ netdev_err(priv->dev, "%s: err=%d\n", __func__, err);
|
|
|
lbs_deb_leave(LBS_DEB_SPI);
|
|
|
return err;
|
|
|
}
|
|
@@ -740,6 +745,7 @@ out:
|
|
|
/* Move data from the card to the host */
|
|
|
static int if_spi_c2h_data(struct if_spi_card *card)
|
|
|
{
|
|
|
+ struct lbs_private *priv = card->priv;
|
|
|
struct sk_buff *skb;
|
|
|
char *data;
|
|
|
u16 len;
|
|
@@ -752,12 +758,14 @@ static int if_spi_c2h_data(struct if_spi_card *card)
|
|
|
if (err)
|
|
|
goto out;
|
|
|
if (!len) {
|
|
|
- pr_err("%s: error: card has no data for host\n", __func__);
|
|
|
+ netdev_err(priv->dev, "%s: error: card has no data for host\n",
|
|
|
+ __func__);
|
|
|
err = -EINVAL;
|
|
|
goto out;
|
|
|
} else if (len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
|
|
|
- pr_err("%s: error: card has %d bytes of data, but our maximum skb size is %zu\n",
|
|
|
- __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
|
|
|
+ netdev_err(priv->dev,
|
|
|
+ "%s: error: card has %d bytes of data, but our maximum skb size is %zu\n",
|
|
|
+ __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
|
|
|
err = -EINVAL;
|
|
|
goto out;
|
|
|
}
|
|
@@ -788,7 +796,7 @@ free_skb:
|
|
|
dev_kfree_skb(skb);
|
|
|
out:
|
|
|
if (err)
|
|
|
- pr_err("%s: err=%d\n", __func__, err);
|
|
|
+ netdev_err(priv->dev, "%s: err=%d\n", __func__, err);
|
|
|
lbs_deb_leave(LBS_DEB_SPI);
|
|
|
return err;
|
|
|
}
|
|
@@ -797,6 +805,7 @@ out:
|
|
|
static void if_spi_h2c(struct if_spi_card *card,
|
|
|
struct if_spi_packet *packet, int type)
|
|
|
{
|
|
|
+ struct lbs_private *priv = card->priv;
|
|
|
int err = 0;
|
|
|
u16 int_type, port_reg;
|
|
|
|
|
@@ -810,7 +819,8 @@ static void if_spi_h2c(struct if_spi_card *card,
|
|
|
port_reg = IF_SPI_CMD_RDWRPORT_REG;
|
|
|
break;
|
|
|
default:
|
|
|
- pr_err("can't transfer buffer of type %d\n", type);
|
|
|
+ netdev_err(priv->dev, "can't transfer buffer of type %d\n",
|
|
|
+ type);
|
|
|
err = -EINVAL;
|
|
|
goto out;
|
|
|
}
|
|
@@ -824,7 +834,7 @@ out:
|
|
|
kfree(packet);
|
|
|
|
|
|
if (err)
|
|
|
- pr_err("%s: error %d\n", __func__, err);
|
|
|
+ netdev_err(priv->dev, "%s: error %d\n", __func__, err);
|
|
|
}
|
|
|
|
|
|
/* Inform the host about a card event */
|
|
@@ -848,7 +858,7 @@ static void if_spi_e2h(struct if_spi_card *card)
|
|
|
lbs_queue_event(priv, cause & 0xff);
|
|
|
out:
|
|
|
if (err)
|
|
|
- pr_err("%s: error %d\n", __func__, err);
|
|
|
+ netdev_err(priv->dev, "%s: error %d\n", __func__, err);
|
|
|
}
|
|
|
|
|
|
static void if_spi_host_to_card_worker(struct work_struct *work)
|
|
@@ -858,8 +868,10 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
|
|
|
u16 hiStatus;
|
|
|
unsigned long flags;
|
|
|
struct if_spi_packet *packet;
|
|
|
+ struct lbs_private *priv;
|
|
|
|
|
|
card = container_of(work, struct if_spi_card, packet_work);
|
|
|
+ priv = card->priv;
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_SPI);
|
|
|
|
|
@@ -870,7 +882,7 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
|
|
|
err = spu_read_u16(card, IF_SPI_HOST_INT_STATUS_REG,
|
|
|
&hiStatus);
|
|
|
if (err) {
|
|
|
- pr_err("I/O error\n");
|
|
|
+ netdev_err(priv->dev, "I/O error\n");
|
|
|
goto err;
|
|
|
}
|
|
|
|
|
@@ -933,7 +945,7 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
|
|
|
|
|
|
err:
|
|
|
if (err)
|
|
|
- pr_err("%s: got error %d\n", __func__, err);
|
|
|
+ netdev_err(priv->dev, "%s: got error %d\n", __func__, err);
|
|
|
|
|
|
lbs_deb_leave(LBS_DEB_SPI);
|
|
|
}
|
|
@@ -956,7 +968,8 @@ static int if_spi_host_to_card(struct lbs_private *priv,
|
|
|
lbs_deb_enter_args(LBS_DEB_SPI, "type %d, bytes %d", type, nb);
|
|
|
|
|
|
if (nb == 0) {
|
|
|
- pr_err("%s: invalid size requested: %d\n", __func__, nb);
|
|
|
+ netdev_err(priv->dev, "%s: invalid size requested: %d\n",
|
|
|
+ __func__, nb);
|
|
|
err = -EINVAL;
|
|
|
goto out;
|
|
|
}
|
|
@@ -984,7 +997,8 @@ static int if_spi_host_to_card(struct lbs_private *priv,
|
|
|
spin_unlock_irqrestore(&card->buffer_lock, flags);
|
|
|
break;
|
|
|
default:
|
|
|
- pr_err("can't transfer buffer of type %d\n", type);
|
|
|
+ netdev_err(priv->dev, "can't transfer buffer of type %d\n",
|
|
|
+ type);
|
|
|
err = -EINVAL;
|
|
|
break;
|
|
|
}
|
|
@@ -1017,6 +1031,7 @@ static irqreturn_t if_spi_host_interrupt(int irq, void *dev_id)
|
|
|
|
|
|
static int if_spi_init_card(struct if_spi_card *card)
|
|
|
{
|
|
|
+ struct lbs_private *priv = card->priv;
|
|
|
struct spi_device *spi = card->spi;
|
|
|
int err, i;
|
|
|
u32 scratch;
|
|
@@ -1045,7 +1060,8 @@ static int if_spi_init_card(struct if_spi_card *card)
|
|
|
break;
|
|
|
}
|
|
|
if (i == ARRAY_SIZE(fw_table)) {
|
|
|
- pr_err("Unsupported chip_id: 0x%02x\n", card->card_id);
|
|
|
+ netdev_err(priv->dev, "Unsupported chip_id: 0x%02x\n",
|
|
|
+ card->card_id);
|
|
|
err = -ENODEV;
|
|
|
goto out;
|
|
|
}
|
|
@@ -1054,7 +1070,8 @@ static int if_spi_init_card(struct if_spi_card *card)
|
|
|
card->card_id, &fw_table[0], &helper,
|
|
|
&mainfw);
|
|
|
if (err) {
|
|
|
- pr_err("failed to find firmware (%d)\n", err);
|
|
|
+ netdev_err(priv->dev, "failed to find firmware (%d)\n",
|
|
|
+ err);
|
|
|
goto out;
|
|
|
}
|
|
|
|