Skip to content

Commit c19bb00

Browse files
Russell Kingdavem330
authored andcommitted
sfp: convert to fwnode
Convert sfp-bus to use fwnode rather than device_node internally, so we can support more than just device tree firmware. Signed-off-by: Russell King <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b6e67d6 commit c19bb00

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

drivers/net/phy/phylink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ static int phylink_register_sfp(struct phylink *pl, struct device_node *np)
499499
if (!sfp_np)
500500
return 0;
501501

502-
pl->sfp_bus = sfp_register_upstream(sfp_np, pl->netdev, pl,
502+
pl->sfp_bus = sfp_register_upstream(of_fwnode_handle(sfp_np),
503+
pl->netdev, pl,
503504
&sfp_phylink_ops);
504505
if (!pl->sfp_bus)
505506
return -ENOMEM;

drivers/net/phy/sfp-bus.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct sfp_bus {
1515
/* private: */
1616
struct kref kref;
1717
struct list_head node;
18-
struct device_node *device_node;
18+
struct fwnode_handle *fwnode;
1919

2020
const struct sfp_socket_ops *socket_ops;
2121
struct device *sfp_dev;
@@ -260,7 +260,7 @@ static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus)
260260
return bus->registered ? bus->upstream_ops : NULL;
261261
}
262262

263-
static struct sfp_bus *sfp_bus_get(struct device_node *np)
263+
static struct sfp_bus *sfp_bus_get(struct fwnode_handle *fwnode)
264264
{
265265
struct sfp_bus *sfp, *new, *found = NULL;
266266

@@ -269,7 +269,7 @@ static struct sfp_bus *sfp_bus_get(struct device_node *np)
269269
mutex_lock(&sfp_mutex);
270270

271271
list_for_each_entry(sfp, &sfp_buses, node) {
272-
if (sfp->device_node == np) {
272+
if (sfp->fwnode == fwnode) {
273273
kref_get(&sfp->kref);
274274
found = sfp;
275275
break;
@@ -278,7 +278,7 @@ static struct sfp_bus *sfp_bus_get(struct device_node *np)
278278

279279
if (!found && new) {
280280
kref_init(&new->kref);
281-
new->device_node = np;
281+
new->fwnode = fwnode;
282282
list_add(&new->node, &sfp_buses);
283283
found = new;
284284
new = NULL;
@@ -423,11 +423,11 @@ EXPORT_SYMBOL_GPL(sfp_upstream_stop);
423423
*
424424
* On error, returns %NULL.
425425
*/
426-
struct sfp_bus *sfp_register_upstream(struct device_node *np,
426+
struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
427427
struct net_device *ndev, void *upstream,
428428
const struct sfp_upstream_ops *ops)
429429
{
430-
struct sfp_bus *bus = sfp_bus_get(np);
430+
struct sfp_bus *bus = sfp_bus_get(fwnode);
431431
int ret = 0;
432432

433433
if (bus) {
@@ -537,7 +537,7 @@ EXPORT_SYMBOL_GPL(sfp_module_remove);
537537
struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp,
538538
const struct sfp_socket_ops *ops)
539539
{
540-
struct sfp_bus *bus = sfp_bus_get(dev->of_node);
540+
struct sfp_bus *bus = sfp_bus_get(dev->fwnode);
541541
int ret = 0;
542542

543543
if (bus) {

include/linux/sfp.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ enum {
356356
SFP_PAGE = 0x7f,
357357
};
358358

359-
struct device_node;
359+
struct fwnode_handle;
360360
struct ethtool_eeprom;
361361
struct ethtool_modinfo;
362362
struct net_device;
@@ -397,7 +397,7 @@ int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
397397
u8 *data);
398398
void sfp_upstream_start(struct sfp_bus *bus);
399399
void sfp_upstream_stop(struct sfp_bus *bus);
400-
struct sfp_bus *sfp_register_upstream(struct device_node *np,
400+
struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
401401
struct net_device *ndev, void *upstream,
402402
const struct sfp_upstream_ops *ops);
403403
void sfp_unregister_upstream(struct sfp_bus *bus);
@@ -441,7 +441,8 @@ static inline void sfp_upstream_stop(struct sfp_bus *bus)
441441
{
442442
}
443443

444-
static inline struct sfp_bus *sfp_register_upstream(struct device_node *np,
444+
static inline struct sfp_bus *sfp_register_upstream(
445+
struct fwnode_handle *fwnode,
445446
struct net_device *ndev, void *upstream,
446447
const struct sfp_upstream_ops *ops)
447448
{

0 commit comments

Comments
 (0)