Re: [PATCH 1/4] ASoC: soc-card: Add storage for PCI SSID

From: Richard Fitzgerald
Date: Wed Sep 13 2023 - 09:29:30 EST


On 13/09/2023 13:58, Mark Brown wrote:
On Wed, Sep 13, 2023 at 12:56:03PM +0200, Amadeusz Sławiński wrote:
On 9/12/2023 6:32 PM, Richard Fitzgerald wrote:

+#ifdef CONFIG_PCI
+ /*
+ * PCI does not define 0 as invalid, so pci_subsystem_set indicates
+ * whether a value has been written to these fields.
+ */
+ unsigned short pci_subsystem_vendor;
+ unsigned short pci_subsystem_device;
+ bool pci_subsystem_set;
+#endif /* CONFIG_PCI */
+
char topology_shortname[32];
struct device *dev;

This looks bit weird to me, snd_soc_card is _generic_ struct which is not
device specific in any way, and now you add fields for PCI, can't this
somehow be done using drvdata or something?

You're right that it's a bit messy but if we use driver data then it
becomes specific to a particular driver and there's a goal here to share
with subfunction drivers. I was thinking we could refactor to a union
or otherwise extend if we find other users with a similar need.

Yes, I was trying to avoid multiple custom ways of passing the same
data around. A significant advantage of explicitly passing the SSID
(if it's available) rather than a more abstract identifier (such as a
char *) is that's it's very well defined exactly what a PCI SSID is so
we know we can use it verbatim. A more abstract identifier creates an
implied trust (or mistrust) between the machine driver and the component
receiving it whether it's unique and in a useful format.

I could de-ugly it a bit by moving it out into a separate struct/union
and having just a member of that struct type in snd_soc_card.

An alternative was to add a function like the existing
snd_soc_component_set_whatever() family but that means adding a callback
pointer to struct snd_soc_component_driver, which is creating more
space overhead than one value in the snd_soc_card.