From: Bartosz Golaszewski <[email protected]>
As suggested by Jose Abreu: let's drop all 12 boolean fields in
plat_stmmacenet_data and replace them with a common bitfield.
v1 -> v2:
- fix build on intel platforms
Bartosz Golaszewski (12):
net: stmmac: replace the has_integrated_pcs field with a flag
net: stmmac: replace the sph_disable field with a flag
net: stmmac: replace the use_phy_wol field with a flag
net: stmmac: replace the has_sun8i field with a flag
net: stmmac: replace the tso_en field with a flag
net: stmmac: replace the serdes_up_after_phy_linkup field with a flag
net: stmmac: replace the vlan_fail_q_en field with a flag
net: stmmac: replace the multi_msi_en field with a flag
net: stmmac: replace the ext_snapshot_en field with a flag
net: stmmac: replace the int_snapshot_en field with a flag
net: stmmac: replace the rx_clk_runs_in_lpi field with a flag
net: stmmac: replace the en_tx_lpi_clockgating field with a flag
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 4 +-
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 23 +++++------
.../ethernet/stmicro/stmmac/dwmac-mediatek.c | 5 ++-
.../stmicro/stmmac/dwmac-qcom-ethqos.c | 8 ++--
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-tegra.c | 4 +-
.../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 4 +-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 +++++++++++--------
.../net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +-
.../ethernet/stmicro/stmmac/stmmac_platform.c | 10 +++--
.../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 5 ++-
include/linux/stmmac.h | 26 ++++++------
12 files changed, 76 insertions(+), 57 deletions(-)
--
2.39.2
From: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a
simple bitfield flag.
Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
include/linux/stmmac.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 1e714380d125..2b5ebb15bfda 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1227,7 +1227,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
plat_dat->interface = interface;
plat_dat->rx_coe = STMMAC_RX_COE_TYPE2;
plat_dat->tx_coe = 1;
- plat_dat->has_sun8i = true;
+ plat_dat->flags |= STMMAC_FLAG_HAS_SUN8I;
plat_dat->bsp_priv = gmac;
plat_dat->init = sun8i_dwmac_init;
plat_dat->exit = sun8i_dwmac_exit;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a1a59af3961d..3df32658b5bb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -325,7 +325,7 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
priv->clk_csr = STMMAC_CSR_250_300M;
}
- if (priv->plat->has_sun8i) {
+ if (priv->plat->flags & STMMAC_FLAG_HAS_SUN8I) {
if (clk_rate > 160000000)
priv->clk_csr = 0x03;
else if (clk_rate > 80000000)
@@ -6856,7 +6856,7 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
int ret;
/* dwmac-sun8i only work in chain mode */
- if (priv->plat->has_sun8i)
+ if (priv->plat->flags & STMMAC_FLAG_HAS_SUN8I)
chain_mode = 1;
priv->chain_mode = chain_mode;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 15fb07cc89c8..66dcf84d024a 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -207,6 +207,7 @@ struct dwmac4_addrs {
#define STMMAC_FLAG_HAS_INTEGRATED_PCS BIT(0)
#define STMMAC_FLAG_SPH_DISABLE BIT(1)
#define STMMAC_FLAG_USE_PHY_WOL BIT(2)
+#define STMMAC_FLAG_HAS_SUN8I BIT(3)
struct plat_stmmacenet_data {
int bus_id;
@@ -270,7 +271,6 @@ struct plat_stmmacenet_data {
struct reset_control *stmmac_ahb_rst;
struct stmmac_axi *axi;
int has_gmac4;
- bool has_sun8i;
bool tso_en;
int rss_en;
int mac_port_sel_speed;
--
2.39.2
From: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a
simple bitfield flag.
Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 10 +++++-----
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 2 +-
include/linux/stmmac.h | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index a3d0da4e9e91..0ffae785d8bd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -329,7 +329,7 @@ static int intel_crosststamp(ktime_t *device,
if (priv->plat->flags & STMMAC_FLAG_EXT_SNAPSHOT_EN)
return -EBUSY;
- priv->plat->int_snapshot_en = 1;
+ priv->plat->flags |= STMMAC_FLAG_INT_SNAPSHOT_EN;
mutex_lock(&priv->aux_ts_lock);
/* Enable Internal snapshot trigger */
@@ -350,7 +350,7 @@ static int intel_crosststamp(ktime_t *device,
break;
default:
mutex_unlock(&priv->aux_ts_lock);
- priv->plat->int_snapshot_en = 0;
+ priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
return -EINVAL;
}
writel(acr_value, ptpaddr + PTP_ACR);
@@ -376,7 +376,7 @@ static int intel_crosststamp(ktime_t *device,
if (!wait_event_interruptible_timeout(priv->tstamp_busy_wait,
stmmac_cross_ts_isr(priv),
HZ / 100)) {
- priv->plat->int_snapshot_en = 0;
+ priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
return -ETIMEDOUT;
}
@@ -395,7 +395,7 @@ static int intel_crosststamp(ktime_t *device,
}
system->cycles *= intel_priv->crossts_adj;
- priv->plat->int_snapshot_en = 0;
+ priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
return 0;
}
@@ -609,7 +609,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
plat->ext_snapshot_num = AUX_SNAPSHOT0;
plat->crosststamp = intel_crosststamp;
- plat->int_snapshot_en = 0;
+ plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
/* Setup MSI vector offset specific to Intel mGbE controller */
plat->msi_mac_vec = 29;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index afd81aac6644..fa2c3ba7e9fe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -180,7 +180,7 @@ static void timestamp_interrupt(struct stmmac_priv *priv)
u64 ptp_time;
int i;
- if (priv->plat->int_snapshot_en) {
+ if (priv->plat->flags & STMMAC_FLAG_INT_SNAPSHOT_EN) {
wake_up(&priv->tstamp_busy_wait);
return;
}
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 0a77e8b05d3a..47708ddd57fd 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -213,6 +213,7 @@ struct dwmac4_addrs {
#define STMMAC_FLAG_VLAN_FAIL_Q_EN BIT(6)
#define STMMAC_FLAG_MULTI_MSI_EN BIT(7)
#define STMMAC_FLAG_EXT_SNAPSHOT_EN BIT(8)
+#define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9)
struct plat_stmmacenet_data {
int bus_id;
@@ -286,7 +287,6 @@ struct plat_stmmacenet_data {
struct pci_dev *pdev;
int int_snapshot_num;
int ext_snapshot_num;
- bool int_snapshot_en;
int msi_mac_vec;
int msi_wol_vec;
int msi_lpi_vec;
--
2.39.2
From: Bartosz Golaszewski <[email protected]>
Drop the boolean field of the plat_stmmacenet_data structure in favor of a
simple bitfield flag.
Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 4 ++--
include/linux/stmmac.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 2d68a6e84b0e..efe85b086abe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -421,7 +421,7 @@ static int stmmac_enable_eee_mode(struct stmmac_priv *priv)
/* Check and enter in LPI mode */
if (!priv->tx_path_in_lpi_mode)
stmmac_set_eee_mode(priv, priv->hw,
- priv->plat->en_tx_lpi_clockgating);
+ priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING);
return 0;
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 5a67af4526c7..0be3113197b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -465,8 +465,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
plat->force_sf_dma_mode =
of_property_read_bool(np, "snps,force_sf_dma_mode");
- plat->en_tx_lpi_clockgating =
- of_property_read_bool(np, "snps,en-tx-lpi-clockgating");
+ if (of_property_read_bool(np, "snps,en-tx-lpi-clockgating"))
+ plat->flags |= STMMAC_FLAG_EN_TX_LPI_CLOCKGATING;
/* Set the maxmtu to a default of JUMBO_LEN in case the
* parameter is not present in the device tree.
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index c3769dad8238..ef67dba775d0 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -215,6 +215,7 @@ struct dwmac4_addrs {
#define STMMAC_FLAG_EXT_SNAPSHOT_EN BIT(8)
#define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9)
#define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI BIT(10)
+#define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING BIT(11)
struct plat_stmmacenet_data {
int bus_id;
@@ -280,7 +281,6 @@ struct plat_stmmacenet_data {
int has_gmac4;
int rss_en;
int mac_port_sel_speed;
- bool en_tx_lpi_clockgating;
int has_xgmac;
u8 vlan_fail_q;
unsigned int eee_usecs_rate;
--
2.39.2
On Fri, Jun 23, 2023 at 12:08:33PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> As suggested by Jose Abreu: let's drop all 12 boolean fields in
> plat_stmmacenet_data and replace them with a common bitfield.
>
> v1 -> v2:
> - fix build on intel platforms
>
> Bartosz Golaszewski (12):
> net: stmmac: replace the has_integrated_pcs field with a flag
> net: stmmac: replace the sph_disable field with a flag
> net: stmmac: replace the use_phy_wol field with a flag
> net: stmmac: replace the has_sun8i field with a flag
> net: stmmac: replace the tso_en field with a flag
> net: stmmac: replace the serdes_up_after_phy_linkup field with a flag
> net: stmmac: replace the vlan_fail_q_en field with a flag
> net: stmmac: replace the multi_msi_en field with a flag
> net: stmmac: replace the ext_snapshot_en field with a flag
> net: stmmac: replace the int_snapshot_en field with a flag
> net: stmmac: replace the rx_clk_runs_in_lpi field with a flag
> net: stmmac: replace the en_tx_lpi_clockgating field with a flag
>
> .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 4 +-
> .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 23 +++++------
> .../ethernet/stmicro/stmmac/dwmac-mediatek.c | 5 ++-
> .../stmicro/stmmac/dwmac-qcom-ethqos.c | 8 ++--
> .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +-
> .../net/ethernet/stmicro/stmmac/dwmac-tegra.c | 4 +-
> .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 4 +-
> .../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 +++++++++++--------
> .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +-
> .../ethernet/stmicro/stmmac/stmmac_platform.c | 10 +++--
> .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 5 ++-
> include/linux/stmmac.h | 26 ++++++------
> 12 files changed, 76 insertions(+), 57 deletions(-)
>
> --
> 2.39.2
>
The series looks proper to me:
Reviewed-by: Andrew Halaney <[email protected]>