• Home
  • Raw
  • Download

Lines Matching full:bus

20  * struct sfp_bus - internal representation of a sfp bus
124 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
136 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_port() argument
175 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
199 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
205 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_may_have_phy() argument
226 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
233 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_support() argument
335 dev_warn(bus->sfp_dev, in sfp_parse_support()
362 if (bus->sfp_quirk) in sfp_parse_support()
363 bus->sfp_quirk->modes(id, modes); in sfp_parse_support()
375 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
381 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
402 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
411 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
413 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
449 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
451 list_del(&bus->node); in sfp_bus_release()
453 kfree(bus); in sfp_bus_release()
458 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
463 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
465 if (bus) in sfp_bus_put()
466 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
470 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
472 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
477 ops->link_down(bus->upstream); in sfp_register_bus()
478 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
479 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
484 bus->registered = true; in sfp_register_bus()
485 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
486 if (bus->started) in sfp_register_bus()
487 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
488 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
492 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
494 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
496 if (bus->registered) { in sfp_unregister_bus()
497 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
498 if (bus->started) in sfp_unregister_bus()
499 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
500 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
501 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
502 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
504 bus->registered = false; in sfp_unregister_bus()
509 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
513 * the sfp bus specified by @bus.
517 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
519 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
525 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
534 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
537 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
543 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
550 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
552 if (bus->registered) in sfp_upstream_start()
553 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
554 bus->started = true; in sfp_upstream_start()
560 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
567 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
569 if (bus->registered) in sfp_upstream_stop()
570 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
571 bus->started = false; in sfp_upstream_stop()
575 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
577 bus->upstream_ops = NULL; in sfp_upstream_clear()
578 bus->upstream = NULL; in sfp_upstream_clear()
582 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
585 * Parse the parent device's firmware node for a SFP bus, and locate
596 * - %-ENOMEM if we failed to allocate the bus.
602 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
617 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
619 if (!bus) in sfp_bus_find_fwnode()
622 return bus; in sfp_bus_find_fwnode()
628 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
632 * Add upstream driver for the SFP bus, and if the bus is complete, register
633 * the SFP bus using sfp_register_upstream(). This takes a reference on the
634 * bus, so it is safe to put the bus after this call.
643 * - %-ENOMEM if we failed to allocate the bus.
646 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
651 /* If no bus, return success */ in sfp_bus_add_upstream()
652 if (!bus) in sfp_bus_add_upstream()
656 kref_get(&bus->kref); in sfp_bus_add_upstream()
657 bus->upstream_ops = ops; in sfp_bus_add_upstream()
658 bus->upstream = upstream; in sfp_bus_add_upstream()
660 if (bus->sfp) { in sfp_bus_add_upstream()
661 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
663 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
670 sfp_bus_put(bus); in sfp_bus_add_upstream()
677 * sfp_bus_del_upstream() - Delete a sfp bus
678 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
681 * module. @bus should have been added by sfp_bus_add_upstream().
683 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
685 if (bus) { in sfp_bus_del_upstream()
687 if (bus->sfp) in sfp_bus_del_upstream()
688 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
689 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
692 sfp_bus_put(bus); in sfp_bus_del_upstream()
698 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
700 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
704 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
707 bus->phydev = phydev; in sfp_add_phy()
713 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
715 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
718 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
719 bus->phydev = NULL; in sfp_remove_phy()
723 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
725 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
728 ops->link_up(bus->upstream); in sfp_link_up()
732 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
734 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
737 ops->link_down(bus->upstream); in sfp_link_down()
741 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_module_insert() argument
743 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
746 bus->sfp_quirk = sfp_lookup_quirk(id); in sfp_module_insert()
749 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
755 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
757 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
760 ops->module_remove(bus->upstream); in sfp_module_remove()
762 bus->sfp_quirk = NULL; in sfp_module_remove()
766 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
768 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
772 ret = ops->module_start(bus->upstream); in sfp_module_start()
778 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
780 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
783 ops->module_stop(bus->upstream); in sfp_module_stop()
787 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
789 bus->sfp_dev = NULL; in sfp_socket_clear()
790 bus->sfp = NULL; in sfp_socket_clear()
791 bus->socket_ops = NULL; in sfp_socket_clear()
797 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
800 if (bus) { in sfp_register_socket()
802 bus->sfp_dev = dev; in sfp_register_socket()
803 bus->sfp = sfp; in sfp_register_socket()
804 bus->socket_ops = ops; in sfp_register_socket()
806 if (bus->upstream_ops) { in sfp_register_socket()
807 ret = sfp_register_bus(bus); in sfp_register_socket()
809 sfp_socket_clear(bus); in sfp_register_socket()
815 sfp_bus_put(bus); in sfp_register_socket()
816 bus = NULL; in sfp_register_socket()
819 return bus; in sfp_register_socket()
823 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
826 if (bus->upstream_ops) in sfp_unregister_socket()
827 sfp_unregister_bus(bus); in sfp_unregister_socket()
828 sfp_socket_clear(bus); in sfp_unregister_socket()
831 sfp_bus_put(bus); in sfp_unregister_socket()