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
632632
633633 #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)
634634
635+/**
636+ * struct sdw_master_device - SoundWire 'Master Device' representation
637+ * @dev: Linux device for this Master
638+ * @bus: Bus handle shortcut
639+ */
640+struct 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+
635648 struct sdw_driver {
636649 const char *name;
637650
@@ -787,7 +800,8 @@ struct sdw_master_ops { · 149 unmodified lines
787800
788801 /**
789802 * struct sdw_bus - SoundWire bus
790− * @dev: Master linux device
803+ * @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
804+ * @md: Master device
791805 * @link_id: Link id number, can be 0 to N, unique for each Master
792806 * @id: bus system-wide unique id
793807 * @slaves: list of Slaves on this bus
@@ -813,6 +827,7 @@ struct sdw_master_ops { · 19 unmodified lines
813827 */
814828 struct sdw_bus {
815829 struct device *dev;
830+ struct sdw_master_device *md;
816831 unsigned int link_id;
817832 int id;
818833 struct list_head slaves;