Lines Matching full:bus

14  * struct sfp_bus - internal representation of a sfp bus
37 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
49 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_port() argument
88 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
112 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
118 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_may_have_phy() argument
139 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
148 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_support() argument
288 dev_warn(bus->sfp_dev, in sfp_parse_support()
328 if (bus->sfp_quirk && bus->sfp_quirk->modes) in sfp_parse_support()
329 bus->sfp_quirk->modes(id, modes, interfaces); in sfp_parse_support()
341 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
347 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
379 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
388 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
390 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
426 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
428 list_del(&bus->node); in sfp_bus_release()
430 kfree(bus); in sfp_bus_release()
435 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
440 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
442 if (bus) in sfp_bus_put()
443 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
447 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
449 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
454 ops->link_down(bus->upstream); in sfp_register_bus()
455 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
456 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
461 bus->registered = true; in sfp_register_bus()
462 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
463 if (bus->started) in sfp_register_bus()
464 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
465 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
469 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
471 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
473 if (bus->registered) { in sfp_unregister_bus()
474 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
475 if (bus->started) in sfp_unregister_bus()
476 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
477 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
478 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
479 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
481 bus->registered = false; in sfp_unregister_bus()
486 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
490 * the sfp bus specified by @bus.
494 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
496 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
502 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
511 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
514 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
520 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
530 int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, in sfp_get_module_eeprom_by_page() argument
534 return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); in sfp_get_module_eeprom_by_page()
540 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
547 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
549 if (bus->registered) in sfp_upstream_start()
550 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
551 bus->started = true; in sfp_upstream_start()
557 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
564 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
566 if (bus->registered) in sfp_upstream_stop()
567 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
568 bus->started = false; in sfp_upstream_stop()
572 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
574 bus->upstream_ops = NULL; in sfp_upstream_clear()
575 bus->upstream = NULL; in sfp_upstream_clear()
579 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
582 * Parse the parent device's firmware node for a SFP bus, and locate
593 * - %-ENOMEM if we failed to allocate the bus.
599 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
614 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
616 if (!bus) in sfp_bus_find_fwnode()
619 return bus; in sfp_bus_find_fwnode()
625 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
629 * Add upstream driver for the SFP bus, and if the bus is complete, register
630 * the SFP bus using sfp_register_upstream(). This takes a reference on the
631 * bus, so it is safe to put the bus after this call.
640 * - %-ENOMEM if we failed to allocate the bus.
643 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
648 /* If no bus, return success */ in sfp_bus_add_upstream()
649 if (!bus) in sfp_bus_add_upstream()
653 kref_get(&bus->kref); in sfp_bus_add_upstream()
654 bus->upstream_ops = ops; in sfp_bus_add_upstream()
655 bus->upstream = upstream; in sfp_bus_add_upstream()
657 if (bus->sfp) { in sfp_bus_add_upstream()
658 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
660 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
667 sfp_bus_put(bus); in sfp_bus_add_upstream()
674 * sfp_bus_del_upstream() - Delete a sfp bus
675 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
678 * module. @bus should have been added by sfp_bus_add_upstream().
680 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
682 if (bus) { in sfp_bus_del_upstream()
684 if (bus->sfp) in sfp_bus_del_upstream()
685 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
686 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
689 sfp_bus_put(bus); in sfp_bus_del_upstream()
695 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
697 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
701 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
704 bus->phydev = phydev; in sfp_add_phy()
710 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
712 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
715 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
716 bus->phydev = NULL; in sfp_remove_phy()
720 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
722 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
725 ops->link_up(bus->upstream); in sfp_link_up()
729 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
731 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
734 ops->link_down(bus->upstream); in sfp_link_down()
738 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_module_insert() argument
741 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
744 bus->sfp_quirk = quirk; in sfp_module_insert()
747 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
753 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
755 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
758 ops->module_remove(bus->upstream); in sfp_module_remove()
760 bus->sfp_quirk = NULL; in sfp_module_remove()
764 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
766 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
770 ret = ops->module_start(bus->upstream); in sfp_module_start()
776 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
778 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
781 ops->module_stop(bus->upstream); in sfp_module_stop()
785 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
787 bus->sfp_dev = NULL; in sfp_socket_clear()
788 bus->sfp = NULL; in sfp_socket_clear()
789 bus->socket_ops = NULL; in sfp_socket_clear()
795 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
798 if (bus) { in sfp_register_socket()
800 bus->sfp_dev = dev; in sfp_register_socket()
801 bus->sfp = sfp; in sfp_register_socket()
802 bus->socket_ops = ops; in sfp_register_socket()
804 if (bus->upstream_ops) { in sfp_register_socket()
805 ret = sfp_register_bus(bus); in sfp_register_socket()
807 sfp_socket_clear(bus); in sfp_register_socket()
813 sfp_bus_put(bus); in sfp_register_socket()
814 bus = NULL; in sfp_register_socket()
817 return bus; in sfp_register_socket()
821 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
824 if (bus->upstream_ops) in sfp_unregister_socket()
825 sfp_unregister_bus(bus); in sfp_unregister_socket()
826 sfp_socket_clear(bus); in sfp_unregister_socket()
829 sfp_bus_put(bus); in sfp_unregister_socket()