Lines Matching full:bus
20 * struct sfp_bus - internal representation of a sfp bus
109 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
121 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_port() argument
160 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
184 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
190 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_may_have_phy() argument
211 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
218 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_support() argument
320 dev_warn(bus->sfp_dev, in sfp_parse_support()
348 if (bus->sfp_quirk) in sfp_parse_support()
349 bus->sfp_quirk->modes(id, modes); in sfp_parse_support()
361 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
367 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
388 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
397 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
399 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
435 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
437 list_del(&bus->node); in sfp_bus_release()
439 kfree(bus); in sfp_bus_release()
444 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
449 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
451 if (bus) in sfp_bus_put()
452 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
456 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
458 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
463 ops->link_down(bus->upstream); in sfp_register_bus()
464 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
465 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
470 bus->registered = true; in sfp_register_bus()
471 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
472 if (bus->started) in sfp_register_bus()
473 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
474 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
478 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
480 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
482 if (bus->registered) { in sfp_unregister_bus()
483 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
484 if (bus->started) in sfp_unregister_bus()
485 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
486 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
487 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
488 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
490 bus->registered = false; in sfp_unregister_bus()
495 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
499 * the sfp bus specified by @bus.
503 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
505 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
511 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
520 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
523 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
529 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
536 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
538 if (bus->registered) in sfp_upstream_start()
539 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
540 bus->started = true; in sfp_upstream_start()
546 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
553 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
555 if (bus->registered) in sfp_upstream_stop()
556 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
557 bus->started = false; in sfp_upstream_stop()
561 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
563 bus->upstream_ops = NULL; in sfp_upstream_clear()
564 bus->upstream = NULL; in sfp_upstream_clear()
568 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
571 * Parse the parent device's firmware node for a SFP bus, and locate
582 * - %-ENOMEM if we failed to allocate the bus.
588 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
598 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
600 if (!bus) in sfp_bus_find_fwnode()
603 return bus; in sfp_bus_find_fwnode()
609 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
613 * Add upstream driver for the SFP bus, and if the bus is complete, register
614 * the SFP bus using sfp_register_upstream(). This takes a reference on the
615 * bus, so it is safe to put the bus after this call.
624 * - %-ENOMEM if we failed to allocate the bus.
627 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
632 /* If no bus, return success */ in sfp_bus_add_upstream()
633 if (!bus) in sfp_bus_add_upstream()
637 kref_get(&bus->kref); in sfp_bus_add_upstream()
638 bus->upstream_ops = ops; in sfp_bus_add_upstream()
639 bus->upstream = upstream; in sfp_bus_add_upstream()
641 if (bus->sfp) { in sfp_bus_add_upstream()
642 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
644 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
651 sfp_bus_put(bus); in sfp_bus_add_upstream()
658 * sfp_bus_del_upstream() - Delete a sfp bus
659 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
662 * module. @bus should have been added by sfp_bus_add_upstream().
664 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
666 if (bus) { in sfp_bus_del_upstream()
668 if (bus->sfp) in sfp_bus_del_upstream()
669 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
670 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
673 sfp_bus_put(bus); in sfp_bus_del_upstream()
679 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
681 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
685 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
688 bus->phydev = phydev; in sfp_add_phy()
694 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
696 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
699 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
700 bus->phydev = NULL; in sfp_remove_phy()
704 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
706 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
709 ops->link_up(bus->upstream); in sfp_link_up()
713 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
715 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
718 ops->link_down(bus->upstream); in sfp_link_down()
722 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_module_insert() argument
724 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
727 bus->sfp_quirk = sfp_lookup_quirk(id); in sfp_module_insert()
730 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
736 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
738 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
741 ops->module_remove(bus->upstream); in sfp_module_remove()
743 bus->sfp_quirk = NULL; in sfp_module_remove()
747 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
749 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
753 ret = ops->module_start(bus->upstream); in sfp_module_start()
759 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
761 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
764 ops->module_stop(bus->upstream); in sfp_module_stop()
768 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
770 bus->sfp_dev = NULL; in sfp_socket_clear()
771 bus->sfp = NULL; in sfp_socket_clear()
772 bus->socket_ops = NULL; in sfp_socket_clear()
778 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
781 if (bus) { in sfp_register_socket()
783 bus->sfp_dev = dev; in sfp_register_socket()
784 bus->sfp = sfp; in sfp_register_socket()
785 bus->socket_ops = ops; in sfp_register_socket()
787 if (bus->upstream_ops) { in sfp_register_socket()
788 ret = sfp_register_bus(bus); in sfp_register_socket()
790 sfp_socket_clear(bus); in sfp_register_socket()
796 sfp_bus_put(bus); in sfp_register_socket()
797 bus = NULL; in sfp_register_socket()
800 return bus; in sfp_register_socket()
804 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
807 if (bus->upstream_ops) in sfp_unregister_socket()
808 sfp_unregister_bus(bus); in sfp_unregister_socket()
809 sfp_socket_clear(bus); in sfp_unregister_socket()
812 sfp_bus_put(bus); in sfp_unregister_socket()