From c88908baec1a5f594bc70f28808a8e676311a69f Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Tue, 27 Aug 2024 21:09:56 +0200 Subject: [PATCH 1/5] net: vertexcom: mse102x: Use DEFINE_SIMPLE_DEV_PM_OPS This macro has the advantage over SET_SYSTEM_SLEEP_PM_OPS that we don't have to care about when the functions are actually used. Also make use of pm_sleep_ptr() to discard all PM_SLEEP related stuff if CONFIG_PM_SLEEP isn't enabled. Signed-off-by: Stefan Wahren Reviewed-by: Simon Horman Link: https://patch.msgid.link/20240827191000.3244-2-wahrenst@gmx.net Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/vertexcom/mse102x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/vertexcom/mse102x.c b/drivers/net/ethernet/vertexcom/mse102x.c index edd8b59680e5..0711641fc3c9 100644 --- a/drivers/net/ethernet/vertexcom/mse102x.c +++ b/drivers/net/ethernet/vertexcom/mse102x.c @@ -622,8 +622,6 @@ static const struct ethtool_ops mse102x_ethtool_ops = { /* driver bus management functions */ -#ifdef CONFIG_PM_SLEEP - static int mse102x_suspend(struct device *dev) { struct mse102x_net *mse = dev_get_drvdata(dev); @@ -649,9 +647,8 @@ static int mse102x_resume(struct device *dev) return 0; } -#endif -static SIMPLE_DEV_PM_OPS(mse102x_pm_ops, mse102x_suspend, mse102x_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(mse102x_pm_ops, mse102x_suspend, mse102x_resume); static int mse102x_probe_spi(struct spi_device *spi) { @@ -761,7 +758,7 @@ static struct spi_driver mse102x_driver = { .driver = { .name = DRV_NAME, .of_match_table = mse102x_match_table, - .pm = &mse102x_pm_ops, + .pm = pm_sleep_ptr(&mse102x_pm_ops), }, .probe = mse102x_probe_spi, .remove = mse102x_remove_spi, From 0069716da006146809c9b5714bec79285453fbee Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Tue, 27 Aug 2024 21:09:57 +0200 Subject: [PATCH 2/5] net: vertexcom: mse102x: Silence TX timeout As long as the MSE102x is not operational, every packet transmission will run into a TX timeout and flood the kernel log. So log only the first TX timeout and a user is at least informed about this issue. The amount of timeouts are still available via netstat. Signed-off-by: Stefan Wahren Reviewed-by: Simon Horman Link: https://patch.msgid.link/20240827191000.3244-3-wahrenst@gmx.net Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/vertexcom/mse102x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/vertexcom/mse102x.c b/drivers/net/ethernet/vertexcom/mse102x.c index 0711641fc3c9..336435fe8241 100644 --- a/drivers/net/ethernet/vertexcom/mse102x.c +++ b/drivers/net/ethernet/vertexcom/mse102x.c @@ -451,7 +451,7 @@ static void mse102x_tx_work(struct work_struct *work) if (ret == -ETIMEDOUT) { if (netif_msg_timer(mse)) - netdev_err(mse->ndev, "tx work timeout\n"); + netdev_err_once(mse->ndev, "tx work timeout\n"); mse->stats.tx_timeout++; } From d3a41dc7e9b04aca289e4bad0b96f1ac9b135f0c Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Tue, 27 Aug 2024 21:09:58 +0200 Subject: [PATCH 3/5] net: vertexcom: mse102x: Fix random MAC address log At the time of MAC address assignment the netdev is not registered yet, so netdev log functions won't work as expected. While we are at this downgrade the log level to a warning, because a random MAC address is not a real error. Signed-off-by: Stefan Wahren Reviewed-by: Simon Horman Link: https://patch.msgid.link/20240827191000.3244-4-wahrenst@gmx.net Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/vertexcom/mse102x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/vertexcom/mse102x.c b/drivers/net/ethernet/vertexcom/mse102x.c index 336435fe8241..4ce027f8e376 100644 --- a/drivers/net/ethernet/vertexcom/mse102x.c +++ b/drivers/net/ethernet/vertexcom/mse102x.c @@ -485,8 +485,8 @@ static void mse102x_init_mac(struct mse102x_net *mse, struct device_node *np) if (ret) { eth_hw_addr_random(ndev); - netdev_err(ndev, "Using random MAC address: %pM\n", - ndev->dev_addr); + dev_warn(ndev->dev.parent, "Using random MAC address: %pM\n", + ndev->dev_addr); } } From 7f37d20929c05bf7817b59615b79a0167f3690a3 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Tue, 27 Aug 2024 21:09:59 +0200 Subject: [PATCH 4/5] net: vertexcom: mse102x: Drop log message on remove This message is a leftover from initial development. It's unnecessary now and can be dropped. Signed-off-by: Stefan Wahren Reviewed-by: Simon Horman Link: https://patch.msgid.link/20240827191000.3244-5-wahrenst@gmx.net Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/vertexcom/mse102x.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/vertexcom/mse102x.c b/drivers/net/ethernet/vertexcom/mse102x.c index 4ce027f8e376..8a72d8699b84 100644 --- a/drivers/net/ethernet/vertexcom/mse102x.c +++ b/drivers/net/ethernet/vertexcom/mse102x.c @@ -733,9 +733,6 @@ static void mse102x_remove_spi(struct spi_device *spi) struct mse102x_net *mse = dev_get_drvdata(&spi->dev); struct mse102x_net_spi *mses = to_mse102x_spi(mse); - if (netif_msg_drv(mse)) - dev_info(&spi->dev, "remove\n"); - mse102x_remove_device_debugfs(mses); unregister_netdev(mse->ndev); } From bc682b8064be82f5f9d2fda79f5b8a14e3ecc4df Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Tue, 27 Aug 2024 21:10:00 +0200 Subject: [PATCH 5/5] net: vertexcom: mse102x: Use ETH_ZLEN There is already a define for minimum Ethernet frame length without FCS. So used this instead of the magic number. Signed-off-by: Stefan Wahren Reviewed-by: Simon Horman Link: https://patch.msgid.link/20240827191000.3244-6-wahrenst@gmx.net Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/vertexcom/mse102x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/vertexcom/mse102x.c b/drivers/net/ethernet/vertexcom/mse102x.c index 8a72d8699b84..a04d4073def9 100644 --- a/drivers/net/ethernet/vertexcom/mse102x.c +++ b/drivers/net/ethernet/vertexcom/mse102x.c @@ -377,8 +377,8 @@ static int mse102x_tx_pkt_spi(struct mse102x_net *mse, struct sk_buff *txb, int ret; bool first = true; - if (txb->len < 60) - pad = 60 - txb->len; + if (txb->len < ETH_ZLEN) + pad = ETH_ZLEN - txb->len; while (1) { mse102x_tx_cmd_spi(mse, CMD_RTS | (txb->len + pad));