net: phylink: constify fwnode arguments
Subsystems (4)
PATCH 1/1 net: phylink: constify fwnode arguments
Both phylink_create() and phylink_fwnode_phy_connect() do not modify the fwnode argument that they are passed, so lets constify these.
--- drivers/net/phy/phylink.c | 11 ++++++----- include/linux/phylink.h | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/net/phy/phylink.c +6 -5
@@ -708,7 +708,7 @@ static int phylink_validate(struct phylink *pl, unsigned long *supported, }static int phylink_parse_fixedlink (struct phylink *pl, -struct fwnode_handle *fwnode) +const struct fwnode_handle *fwnode) {struct fwnode_handle *fixed_node;bool pause, asym_pause, autoneg;
@@ -819,7 +819,8 @@ static int phylink_parse_fixedlink(struct phylink *pl,return 0 ; } -static int phylink_parse_mode (struct phylink *pl,struct fwnode_handle *fwnode) +static int phylink_parse_mode (struct phylink *pl, +const struct fwnode_handle *fwnode) {struct fwnode_handle *dn;const char *managed;
@@ -1441,7 +1442,7 @@ static void phylink_fixed_poll(struct timer_list *t)static const struct sfp_upstream_ops sfp_phylink_ops;static int phylink_register_sfp (struct phylink *pl, -struct fwnode_handle *fwnode) +const struct fwnode_handle *fwnode) {struct sfp_bus *bus;int ret;
@@ -1480,7 +1481,7 @@ static int phylink_register_sfp(struct phylink *pl,* must use IS_ERR() to check for errors from this function. */ struct phylink *phylink_create (struct phylink_config *config, -struct fwnode_handle *fwnode, +const struct fwnode_handle *fwnode,phy_interface_t iface,const struct phylink_mac_ops *mac_ops) {
@@ -1809,7 +1810,7 @@ EXPORT_SYMBOL_GPL(phylink_of_phy_connect);* Returns 0 on success or a negative errno. */ int phylink_fwnode_phy_connect (struct phylink *pl, -struct fwnode_handle *fwnode, +const struct fwnode_handle *fwnode,u32 flags) {struct fwnode_handle *phy_fwnode;
include/linux/phylink.h +3 -2
@@ -568,7 +568,8 @@ void phylink_generic_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state); -struct phylink *phylink_create (struct phylink_config *,struct fwnode_handle *, +struct phylink *phylink_create (struct phylink_config *, +const struct fwnode_handle *,phy_interface_t iface,const struct phylink_mac_ops *mac_ops);void phylink_destroy (struct phylink *);
@@ -577,7 +578,7 @@ bool phylink_expects_phy(struct phylink *pl);int phylink_connect_phy (struct phylink *,struct phy_device *);int phylink_of_phy_connect (struct phylink *,struct device_node *,u32 flags);int phylink_fwnode_phy_connect (struct phylink *pl, -struct fwnode_handle *fwnode, +const struct fwnode_handle *fwnode,u32 flags);void phylink_disconnect_phy (struct phylink *);
Signature · 1 line
2.30.2
Quoted 4 lines · Russell King (Oracle)
Both
phylink_create()andphylink_fwnode_phy_connect()do not modify the fwnode argument that they are passed, so lets constify these.Signed-off-by Russell King (Oracle) <[email protected]>
Quoted 3 lines · Russell King (Oracle)
Both
phylink_create()andphylink_fwnode_phy_connect()do not modify the fwnode argument that they are passed, so lets constify these.
Thank you!
Quoted 82 lines
Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/phy/phylink.c | 11 ++++++----- include/linux/phylink.h | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-)drivers/net/phy/phylink.c +6
-5@@ -708,7 +708,7 @@ static int phylink_validate(struct phylink *pl, unsigned long *supported, }static int phylink_parse_fixedlink (struct phylink *pl, -struct fwnode_handle *fwnode) +const struct fwnode_handle *fwnode) {struct fwnode_handle *fixed_node;bool pause, asym_pause, autoneg;@@ -819,7 +819,8 @@ static int phylink_parse_fixedlink(struct phylink *pl,return 0 ; } -static int phylink_parse_mode (struct phylink *pl,struct fwnode_handle *fwnode) +static int phylink_parse_mode (struct phylink *pl, +const struct fwnode_handle *fwnode) {struct fwnode_handle *dn;const char *managed;@@ -1441,7 +1442,7 @@ static void phylink_fixed_poll(struct timer_list *t)static const struct sfp_upstream_ops sfp_phylink_ops;static int phylink_register_sfp (struct phylink *pl, -struct fwnode_handle *fwnode) +const struct fwnode_handle *fwnode) {struct sfp_bus *bus;int ret;@@ -1480,7 +1481,7 @@ static int phylink_register_sfp(struct phylink *pl,* must use IS_ERR() to check for errors from this function. */ struct phylink *phylink_create (struct phylink_config *config, -struct fwnode_handle *fwnode, +const struct fwnode_handle *fwnode,phy_interface_t iface,const struct phylink_mac_ops *mac_ops) {@@ -1809,7 +1810,7 @@ EXPORT_SYMBOL_GPL(phylink_of_phy_connect);* Returns 0 on success or a negative errno. */ int phylink_fwnode_phy_connect (struct phylink *pl, -struct fwnode_handle *fwnode, +const struct fwnode_handle *fwnode,u32 flags) {struct fwnode_handle *phy_fwnode;include/linux/phylink.h +3
-3@@ -568,7 +568,8 @@ void phylink_generic_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state); -struct phylink *phylink_create (struct phylink_config *,struct fwnode_handle *, +struct phylink *phylink_create (struct phylink_config *, +const struct fwnode_handle *,phy_interface_t iface,const struct phylink_mac_ops *mac_ops);void phylink_destroy (struct phylink *);@@ -577,7 +578,7 @@ bool phylink_expects_phy(struct phylink *pl);int phylink_connect_phy (struct phylink *,struct phy_device *);int phylink_of_phy_connect (struct phylink *,struct device_node *,u32 flags);int phylink_fwnode_phy_connect (struct phylink *pl, -struct fwnode_handle *fwnode, +const struct fwnode_handle *fwnode,u32 flags);void phylink_disconnect_phy (struct phylink *); --2.30.2
Signature · 2 lines
With Best Regards, Andy Shevchenko
Paolo Abeni
maintainerinclude/linux/phylink.h void phylink_generic_validate(struct phylink_config *config, · line 572
Quoted 11 lines · Russell King (Oracle)
include/linux/phylink.h +2
-1@@ -568,7 +568,8 @@ void phylink_generic_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state); -struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, +struct phylink *phylink_create(struct phylink_config *, + const struct fwnode_handle *,
While touching the above, could you please also add the missing params name, to keep checkpatch happy and be consistent with the others arguments?
Thanks!
Paolo
Russell King (Oracle)
maintainerQuoted 9 lines · Paolo Abeni
Quoted 8 lines · Russell King (Oracle)
include/linux/phylink.h +0
-0@@ -568,7 +568,8 @@ void phylink_generic_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state);
Quoted 7 lines
include/linux/phylink.h void phylink_generic_validate(struct phylink_config *config, · line 572
Quoted 3 lines
include/linux/phylink.h +2
-1-struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, +struct phylink *phylink_create(struct phylink_config *, + const struct fwnode_handle *,While touching the above, could you please also add the missing params name, to keep checkpatch happy and be consistent with the others arguments?
For interest, when did naming parameters in a prototype become a requirement?
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Paolo Abeni
maintainerQuoted 18 lines · Russell King (Oracle)
Quoted 9 lines · Paolo Abeni
Quoted 8 lines · Russell King (Oracle)
include/linux/phylink.h +0
-0@@ -568,7 +568,8 @@ void phylink_generic_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state);Quoted 7 lines
include/linux/phylink.h void phylink_generic_validate(struct phylink_config *config, · line 572
Quoted 3 lines
include/linux/phylink.h +2
-1-struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, +struct phylink *phylink_create(struct phylink_config *, + const struct fwnode_handle *,While touching the above, could you please also add the missing params name, to keep checkpatch happy and be consistent with the others arguments?
Quoted 2 lines
For interest, when did naming parameters in a prototype become a requirement?
I would not call it a general requirement, but in this specific case we have 2 named params and 2 unnamed ones for the same function, which looks not good to me. Since you are touching that function definition and checkpatch is complaining about the above, I think it would be better to make the function declaration self-consistent.
Looking again at the checkpatch warning, that is possibly a false positive - git history hints such check should apply only to function definition, not declaration.
I still think it would be better removing the mixed unnamed/named params usage.
Thanks,
Paolo
Russell King (Oracle)
maintainerQuoted 28 lines · Paolo Abeni
Quoted 18 lines · Russell King (Oracle)
Quoted 9 lines · Paolo Abeni
Quoted 8 lines · Russell King (Oracle)
include/linux/phylink.h +0
-0@@ -568,7 +568,8 @@ void phylink_generic_validate(struct phylink_config *config,unsigned long *supported, struct phylink_link_state *state);Quoted 7 lines
include/linux/phylink.h void phylink_generic_validate(struct phylink_config *config, · line 572
Quoted 3 lines
include/linux/phylink.h +2
-1-struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, +struct phylink *phylink_create(struct phylink_config *, + const struct fwnode_handle *,While touching the above, could you please also add the missing params name, to keep checkpatch happy and be consistent with the others arguments?
Quoted 2 lines
For interest, when did naming parameters in a prototype become a requirement?
I would not call it a general requirement, but in this specific case we have 2 named params and 2 unnamed ones for the same function, which looks not good to me. Since you are touching that function definition and checkpatch is complaining about the above, I think it would be better to make the function declaration self-consistent.
Quoted 6 lines
Looking again at the checkpatch warning, that is possibly a false positive - git history hints such check should apply only to function definition, not declaration.
I still think it would be better removing the mixed unnamed/named params usage.
In this particular instance, I think removing them is appropriate, since giving names for them doesn't contribute anything useful (since the types give allt he information necessary.)
However, for something like a function that takes e.g. a u32 and a bunch of other unique structs, I think it is entirely appropriate to use mixed named/unnamed parameters - since a "u32" can't describe on its own what it is. Hence, I think, e.g.:
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
is entirely reasonable, since "flags" describes what the u32 is. Adding "pl" and "dn" to the other two arguments doesn't add any useful value.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!