diff mbox series

[net-next,v3,03/10] net: pcs: xpcs: Convert xpcs_id to dw_xpcs_desc

Message ID 20240627004142.8106-4-fancer.lancer@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: pcs: xpcs: Add memory-mapped device support | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/apply fail Patch does not apply to net-next-0

Commit Message

Serge Semin June 27, 2024, 12:41 a.m. UTC
A structure with the PCS/PMA MMD IDs data is being introduced in one of
the next commits. In order to prevent the names ambiguity let's convert
the xpcs_id structure name to dw_xpcs_desc. The later version is more
suitable since the structure content is indeed the device descriptor
containing the data and callbacks required for the driver to correctly set
the device up.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

---

Changelog v2:
- This is a new patch introduced on v2 stage of the review.
---
 drivers/net/pcs/pcs-xpcs.c   | 30 +++++++++++++++---------------
 include/linux/pcs/pcs-xpcs.h |  4 ++--
 2 files changed, 17 insertions(+), 17 deletions(-)

Comments

Andrew Lunn June 27, 2024, 1:10 p.m. UTC | #1
> -	for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) {
> -		const struct xpcs_id *entry = &xpcs_id_list[i];
> +	for (i = 0; i < ARRAY_SIZE(xpcs_desc_list); i++) {
> +		const struct dw_xpcs_desc *entry = &xpcs_desc_list[i];
>  
>  		if ((xpcs_id & entry->mask) != entry->id)
>  			continue;
>  
> -		xpcs->id = entry;
> +		xpcs->desc = entry;

Maybe rename entry to desc here?

Otherwise

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Serge Semin June 27, 2024, 2:21 p.m. UTC | #2
On Thu, Jun 27, 2024 at 03:10:18PM +0200, Andrew Lunn wrote:
> > -	for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) {
> > -		const struct xpcs_id *entry = &xpcs_id_list[i];
> > +	for (i = 0; i < ARRAY_SIZE(xpcs_desc_list); i++) {
> > +		const struct dw_xpcs_desc *entry = &xpcs_desc_list[i];
> >  
> >  		if ((xpcs_id & entry->mask) != entry->id)
> >  			continue;
> >  
> > -		xpcs->id = entry;
> > +		xpcs->desc = entry;
> 
> Maybe rename entry to desc here?

Curiously to note that originally I had the same idea in mind and even
implemented it in the first v2 version. But then decided to preserve
the original name to signify that the pointer is a temporary
variable pointing to the desc list entry.

Anyway I don't mind changing the name to desc especially seeing I need
to resubmit the series anyway. Using the desc name here won't make
thing less readable here, but will also provide a notion about the
variable content.

I'll change the name to "desc" in v4.

> 
> Otherwise
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks.

-Serge(y)

> 
>     Andrew
diff mbox series

Patch

diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 2dcfd0ff069a..48c61975db22 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -151,19 +151,19 @@  struct xpcs_compat {
 	int (*pma_config)(struct dw_xpcs *xpcs);
 };
 
-struct xpcs_id {
+struct dw_xpcs_desc {
 	u32 id;
 	u32 mask;
 	const struct xpcs_compat *compat;
 };
 
-static const struct xpcs_compat *xpcs_find_compat(const struct xpcs_id *id,
-						  phy_interface_t interface)
+static const struct xpcs_compat *
+xpcs_find_compat(const struct dw_xpcs_desc *desc, phy_interface_t interface)
 {
 	int i, j;
 
 	for (i = 0; i < DW_XPCS_INTERFACE_MAX; i++) {
-		const struct xpcs_compat *compat = &id->compat[i];
+		const struct xpcs_compat *compat = &desc->compat[i];
 
 		for (j = 0; j < compat->num_interfaces; j++)
 			if (compat->interface[j] == interface)
@@ -177,7 +177,7 @@  int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface)
 {
 	const struct xpcs_compat *compat;
 
-	compat = xpcs_find_compat(xpcs->id, interface);
+	compat = xpcs_find_compat(xpcs->desc, interface);
 	if (!compat)
 		return -ENODEV;
 
@@ -612,7 +612,7 @@  static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported,
 	int i;
 
 	xpcs = phylink_pcs_to_xpcs(pcs);
-	compat = xpcs_find_compat(xpcs->id, state->interface);
+	compat = xpcs_find_compat(xpcs->desc, state->interface);
 	if (!compat)
 		return -EINVAL;
 
@@ -633,7 +633,7 @@  void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)
 	int i, j;
 
 	for (i = 0; i < DW_XPCS_INTERFACE_MAX; i++) {
-		const struct xpcs_compat *compat = &xpcs->id->compat[i];
+		const struct xpcs_compat *compat = &xpcs->desc->compat[i];
 
 		for (j = 0; j < compat->num_interfaces; j++)
 			__set_bit(compat->interface[j], interfaces);
@@ -853,7 +853,7 @@  int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,
 	const struct xpcs_compat *compat;
 	int ret;
 
-	compat = xpcs_find_compat(xpcs->id, interface);
+	compat = xpcs_find_compat(xpcs->desc, interface);
 	if (!compat)
 		return -ENODEV;
 
@@ -1118,7 +1118,7 @@  static void xpcs_get_state(struct phylink_pcs *pcs,
 	const struct xpcs_compat *compat;
 	int ret;
 
-	compat = xpcs_find_compat(xpcs->id, state->interface);
+	compat = xpcs_find_compat(xpcs->desc, state->interface);
 	if (!compat)
 		return;
 
@@ -1341,7 +1341,7 @@  static const struct xpcs_compat nxp_sja1110_xpcs_compat[DW_XPCS_INTERFACE_MAX] =
 	},
 };
 
-static const struct xpcs_id xpcs_id_list[] = {
+static const struct dw_xpcs_desc xpcs_desc_list[] = {
 	{
 		.id = DW_XPCS_ID,
 		.mask = DW_XPCS_ID_MASK,
@@ -1395,18 +1395,18 @@  static int xpcs_init_id(struct dw_xpcs *xpcs)
 
 	xpcs_id = xpcs_get_id(xpcs);
 
-	for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) {
-		const struct xpcs_id *entry = &xpcs_id_list[i];
+	for (i = 0; i < ARRAY_SIZE(xpcs_desc_list); i++) {
+		const struct dw_xpcs_desc *entry = &xpcs_desc_list[i];
 
 		if ((xpcs_id & entry->mask) != entry->id)
 			continue;
 
-		xpcs->id = entry;
+		xpcs->desc = entry;
 
 		break;
 	}
 
-	if (!xpcs->id)
+	if (!xpcs->desc)
 		return -ENODEV;
 
 	ret = xpcs_dev_flag(xpcs);
@@ -1420,7 +1420,7 @@  static int xpcs_init_iface(struct dw_xpcs *xpcs, phy_interface_t interface)
 {
 	const struct xpcs_compat *compat;
 
-	compat = xpcs_find_compat(xpcs->id, interface);
+	compat = xpcs_find_compat(xpcs->desc, interface);
 	if (!compat)
 		return -EINVAL;
 
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index 8dfe90295f12..e706bd16b986 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -28,11 +28,11 @@ 
 /* dev_flag */
 #define DW_DEV_TXGBE			BIT(0)
 
-struct xpcs_id;
+struct dw_xpcs_desc;
 
 struct dw_xpcs {
+	const struct dw_xpcs_desc *desc;
 	struct mdio_device *mdiodev;
-	const struct xpcs_id *id;
 	struct phylink_pcs pcs;
 	phy_interface_t interface;
 	int dev_flag;