Lines Matching full:bus
13 * struct sfp_bus - internal representation of a sfp bus
35 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
47 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_port() argument
86 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
110 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
117 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_support() argument
208 dev_warn(bus->sfp_dev, in sfp_parse_support()
246 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
255 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
277 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
286 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
288 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
324 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
326 list_del(&bus->node); in sfp_bus_release()
328 kfree(bus); in sfp_bus_release()
331 static void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
333 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
336 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
338 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
343 ops->link_down(bus->upstream); in sfp_register_bus()
344 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
345 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
350 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
351 if (bus->started) in sfp_register_bus()
352 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
353 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
354 bus->registered = true; in sfp_register_bus()
358 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
360 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
362 if (bus->registered) { in sfp_unregister_bus()
363 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
364 if (bus->started) in sfp_unregister_bus()
365 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
366 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
367 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
368 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
370 bus->registered = false; in sfp_unregister_bus()
375 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
379 * the sfp bus specified by @bus.
383 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
385 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
391 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
400 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
403 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
409 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
416 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
418 if (bus->registered) in sfp_upstream_start()
419 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
420 bus->started = true; in sfp_upstream_start()
426 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
433 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
435 if (bus->registered) in sfp_upstream_stop()
436 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
437 bus->started = false; in sfp_upstream_stop()
441 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
443 bus->upstream_ops = NULL; in sfp_upstream_clear()
444 bus->upstream = NULL; in sfp_upstream_clear()
449 * @fwnode: firmware node for the SFP bus
453 * Register the upstream device (eg, PHY) with the SFP bus. MAC drivers
463 struct sfp_bus *bus = sfp_bus_get(fwnode); in sfp_register_upstream() local
466 if (bus) { in sfp_register_upstream()
468 bus->upstream_ops = ops; in sfp_register_upstream()
469 bus->upstream = upstream; in sfp_register_upstream()
471 if (bus->sfp) { in sfp_register_upstream()
472 ret = sfp_register_bus(bus); in sfp_register_upstream()
474 sfp_upstream_clear(bus); in sfp_register_upstream()
480 sfp_bus_put(bus); in sfp_register_upstream()
481 bus = NULL; in sfp_register_upstream()
484 return bus; in sfp_register_upstream()
489 * sfp_unregister_upstream() - Unregister sfp bus
490 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
493 * module. @bus is returned from sfp_register_upstream().
495 void sfp_unregister_upstream(struct sfp_bus *bus) in sfp_unregister_upstream() argument
498 if (bus->sfp) in sfp_unregister_upstream()
499 sfp_unregister_bus(bus); in sfp_unregister_upstream()
500 sfp_upstream_clear(bus); in sfp_unregister_upstream()
503 sfp_bus_put(bus); in sfp_unregister_upstream()
508 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
510 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
514 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
517 bus->phydev = phydev; in sfp_add_phy()
523 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
525 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
528 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
529 bus->phydev = NULL; in sfp_remove_phy()
533 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
535 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
538 ops->link_up(bus->upstream); in sfp_link_up()
542 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
544 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
547 ops->link_down(bus->upstream); in sfp_link_down()
551 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_module_insert() argument
553 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
557 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
563 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
565 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
568 ops->module_remove(bus->upstream); in sfp_module_remove()
572 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
574 bus->sfp_dev = NULL; in sfp_socket_clear()
575 bus->sfp = NULL; in sfp_socket_clear()
576 bus->socket_ops = NULL; in sfp_socket_clear()
582 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
585 if (bus) { in sfp_register_socket()
587 bus->sfp_dev = dev; in sfp_register_socket()
588 bus->sfp = sfp; in sfp_register_socket()
589 bus->socket_ops = ops; in sfp_register_socket()
591 if (bus->upstream_ops) { in sfp_register_socket()
592 ret = sfp_register_bus(bus); in sfp_register_socket()
594 sfp_socket_clear(bus); in sfp_register_socket()
600 sfp_bus_put(bus); in sfp_register_socket()
601 bus = NULL; in sfp_register_socket()
604 return bus; in sfp_register_socket()
608 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
611 if (bus->upstream_ops) in sfp_unregister_socket()
612 sfp_unregister_bus(bus); in sfp_unregister_socket()
613 sfp_socket_clear(bus); in sfp_unregister_socket()
616 sfp_bus_put(bus); in sfp_unregister_socket()