History

soundwire: bus_type: add sdw_master_device support

In the existing SoundWire code, Master Devices are not explicitly represented - only SoundWire Slave Devices are exposed (the use of capital letters follows the SoundWire specification conventions). With the existing code, the bus is handled without using a proper device, and bus->dev typically points to a platform device. The right thing to do as discussed in multiple reviews is use a device for each bus. The sdw_master_device addition is done with minimal internal plumbing and not exposed externally. The existing API based on sdw_bus_master_add() and sdw_bus_master_delete() will deal with the sdw_master_device life cycle, which minimizes changes to existing drivers. Note that the Intel code will be modified in follow-up patches (no impact on any platform since the connection with ASoC is not supported upstream so far).

Pierre-Louis Bossart committed 6 years ago

Commit 7ceaa401 parent dbb50c77 files · +112 −7Browse files

Showing the changes to include/linux (1 of 7 files). Show all

Unified · Split

include/linux/soundwire/sdw.h+16−1
@@ -632,6 +632,19 @@ struct sdw_slave { · 631 unmodified lines
632 632
633#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)633#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)
634 634
635/**
636 * struct sdw_master_device - SoundWire 'Master Device' representation
637 * @dev: Linux device for this Master
638 * @bus: Bus handle shortcut
639 */
640struct sdw_master_device {
641 struct device dev;
642 struct sdw_bus *bus;
643};
644
645#define dev_to_sdw_master_device(d) \
646 container_of(d, struct sdw_master_device, dev)
647
635struct sdw_driver {648struct sdw_driver {
636 const char *name;649 const char *name;
637 650
@@ -787,7 +800,8 @@ struct sdw_master_ops { · 149 unmodified lines
787 800
788/**801/**
789 * struct sdw_bus - SoundWire bus802 * struct sdw_bus - SoundWire bus
790 * @dev: Master linux device803 * @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
804 * @md: Master device
791 * @link_id: Link id number, can be 0 to N, unique for each Master805 * @link_id: Link id number, can be 0 to N, unique for each Master
792 * @id: bus system-wide unique id806 * @id: bus system-wide unique id
793 * @slaves: list of Slaves on this bus807 * @slaves: list of Slaves on this bus
@@ -813,6 +827,7 @@ struct sdw_master_ops { · 19 unmodified lines
813 */827 */
814struct sdw_bus {828struct sdw_bus {
815 struct device *dev;829 struct device *dev;
830 struct sdw_master_device *md;
816 unsigned int link_id;831 unsigned int link_id;
817 int id;832 int id;
818 struct list_head slaves;833 struct list_head slaves;