Skip to contentSkip to conversation

Constify a few sfp/phy fwnodes

PATCH Applied Russell King (Oracle) 4 participants 11 messages Mar 24, 2023 – Mar 27, 2023

Subsystems (4)
lore
Share & tools
lore

Russell King (Oracle)

author maintainer
#0 lore raw

cover Constify a few sfp/phy fwnodes

Hi,

This series constifies a bunch of fwnode_handle pointers that are only used to refer to but not modify the contents of the fwnode structures.

 drivers/net/phy/phy_device.c | 2 +-
 drivers/net/phy/sfp-bus.c    | 6 +++---
 include/linux/phy.h          | 2 +-
 include/linux/sfp.h          | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
author maintainer
#1 lore raw

Oops, I typo'd one of the addresses when sending the series. I'll re-send. Please ignore this posting.

Quoted 15 lines · Russell King (Oracle)

Hi,

This series constifies a bunch of fwnode_handle pointers that are only used to refer to but not modify the contents of the fwnode structures.

 drivers/net/phy/phy_device.c | 2 +-
 drivers/net/phy/sfp-bus.c    | 6 +++---
 include/linux/phy.h          | 2 +-
 include/linux/sfp.h          | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
author maintainer
#2 lore raw

cover Constify a few sfp/phy fwnodes

In reply to Russell King (Oracle)

Hi,

This series constifies a bunch of fwnode_handle pointers that are only used to refer to but not modify the contents of the fwnode structures.

 drivers/net/phy/phy_device.c | 2 +-
 drivers/net/phy/sfp-bus.c    | 6 +++---
 include/linux/phy.h          | 2 +-
 include/linux/sfp.h          | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#3 lore raw

PATCH 1/3 net: sfp: make sfp_bus_find_fwnode() take a const fwnode

sfp_bus_find_fwnode() does not write to the fwnode, so let's make it const.

---
 drivers/net/phy/sfp-bus.c | 2 +-
 include/linux/sfp.h       | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/phy/sfp-bus.c +1 -1
index 1dd50f2ca05d..b4680f859269 100644
@@ -593,7 +593,7 @@ static void sfp_upstream_clear(struct sfp_bus *bus)
  *	- %-ENOMEM if we failed to allocate the bus.
  *	- an error from the upstream's connect_phy() method.
  */
-struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode)
+struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode)
 {
 	struct fwnode_reference_args ref;
 	struct sfp_bus *bus;
include/linux/sfp.h +3 -2
index 52b98f9666a2..ef06a195b3c2 100644
@@ -557,7 +557,7 @@ int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
 void sfp_upstream_start(struct sfp_bus *bus);
 void sfp_upstream_stop(struct sfp_bus *bus);
 void sfp_bus_put(struct sfp_bus *bus);
-struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode);
+struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode);
 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
 			 const struct sfp_upstream_ops *ops);
 void sfp_bus_del_upstream(struct sfp_bus *bus);
@@ -619,7 +619,8 @@ static inline void sfp_bus_put(struct sfp_bus *bus)
 {
 }
 
-static inline struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode)
+static inline struct sfp_bus *
+sfp_bus_find_fwnode(const struct fwnode_handle *fwnode)
 {
 	return NULL;
 }
Signature · 1 line
2.30.2
#5 lore raw

PATCH 2/3 net: sfp: constify sfp-bus internal fwnode uses

In reply to Russell King (Oracle)

Constify sfp-bus internal fwnode uses, since we do not modify the fwnode structures.

---
 drivers/net/phy/sfp-bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/sfp-bus.c +2 -2
index b4680f859269..9372e5a4cadc 100644
@@ -17,7 +17,7 @@ struct sfp_bus {
 	/* private: */
 	struct kref kref;
 	struct list_head node;
-	struct fwnode_handle *fwnode;
+	const struct fwnode_handle *fwnode;
 
 	const struct sfp_socket_ops *socket_ops;
 	struct device *sfp_dev;
@@ -390,7 +390,7 @@ static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus)
 	return bus->registered ? bus->upstream_ops : NULL;
 }
 
-static struct sfp_bus *sfp_bus_get(struct fwnode_handle *fwnode)
+static struct sfp_bus *sfp_bus_get(const struct fwnode_handle *fwnode)
 {
 	struct sfp_bus *sfp, *new, *found = NULL;
 
Signature · 1 line
2.30.2
#7 lore raw

PATCH 3/3 net: phy: constify fwnode_get_phy_node() fwnode argument

In reply to Russell King (Oracle)

fwnode_get_phy_node() does not motify the fwnode structure, so make the argument const,

---
 drivers/net/phy/phy_device.c | 2 +-
 include/linux/phy.h          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/phy_device.c +1 -1
index c0760cbf534b..917ba84105fc 100644
@@ -3057,7 +3057,7 @@ EXPORT_SYMBOL_GPL(device_phy_find_device);
  * and "phy-device" are not supported in ACPI. DT supports all the three
  * named references to the phy node.
  */
-struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode)
+struct fwnode_handle *fwnode_get_phy_node(const struct fwnode_handle *fwnode)
 {
 	struct fwnode_handle *phy_node;
 
include/linux/phy.h +1 -1
index fefd5091bc24..2f83cfc206e5 100644
@@ -1546,7 +1546,7 @@ int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id);
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
 struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
 struct phy_device *device_phy_find_device(struct device *dev);
-struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode);
+struct fwnode_handle *fwnode_get_phy_node(const struct fwnode_handle *fwnode);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
Signature · 1 line
2.30.2
#9 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 10 lines · On Fri, 24 Mar 2023 09:23:17 +0000 you wrote:

Hi,

This series constifies a bunch of fwnode_handle pointers that are only used to refer to but not modify the contents of the fwnode structures.

 drivers/net/phy/phy_device.c | 2 +-
 drivers/net/phy/sfp-bus.c    | 6 +++---
 include/linux/phy.h          | 2 +-
 include/linux/sfp.h          | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)

Here is the summary with links:
- [net-next,1/3] net: sfp: make sfp_bus_find_fwnode() take a const fwnode

    https://git.kernel.org/netdev/net/c/a90ac762d345
  - [net-next,2/3] net: sfp: constify sfp-bus internal fwnode uses
    https://git.kernel.org/netdev/net/c/850a8d2dc712
  - [net-next,3/3] net: phy: constify fwnode_get_phy_node() fwnode argument
    https://git.kernel.org/netdev/net/c/4a0faa02d419

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#10 lore raw

Hi David,

I notice you merged this to the net tree rather than the net-next tree which was in the subject tag. Was there a reason for applying it to the net tree?

Thanks.

Quoted 32 lines · On Mon, Mar 27, 2023 at 07:20:18AM +0000, [email protected]…

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 10 lines · On Fri, 24 Mar 2023 09:23:17 +0000 you wrote:

Hi,

This series constifies a bunch of fwnode_handle pointers that are only used to refer to but not modify the contents of the fwnode structures.

 drivers/net/phy/phy_device.c | 2 +-
 drivers/net/phy/sfp-bus.c    | 6 +++---
 include/linux/phy.h          | 2 +-
 include/linux/sfp.h          | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)

Here is the summary with links:
- [net-next,1/3] net: sfp: make sfp_bus_find_fwnode() take a const fwnode

    https://git.kernel.org/netdev/net/c/a90ac762d345
  - [net-next,2/3] net: sfp: constify sfp-bus internal fwnode uses
    https://git.kernel.org/netdev/net/c/850a8d2dc712
  - [net-next,3/3] net: phy: constify fwnode_get_phy_node() fwnode argument
    https://git.kernel.org/netdev/net/c/4a0faa02d419

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!