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).
Showing the changes to include/linux (1 of 7 files). Show all
Unified · Split
| @@ -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 | */ | ||
| 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 | |||
| 635 | struct sdw_driver { | 648 | struct 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 bus | 802 | * 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 | ||
| 791 | * @link_id: Link id number, can be 0 to N, unique for each Master | 805 | * @link_id: Link id number, can be 0 to N, unique for each Master |
| 792 | * @id: bus system-wide unique id | 806 | * @id: bus system-wide unique id |
| 793 | * @slaves: list of Slaves on this bus | 807 | * @slaves: list of Slaves on this bus |
| @@ -813,6 +827,7 @@ struct sdw_master_ops { · 19 unmodified lines | |||
| 813 | */ | 827 | */ |
| 814 | struct sdw_bus { | 828 | struct 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; |