Message ID | 20210322110638.2681-1-heikki.krogerus@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: Intel: Handle device properties with software node API | expand |
On 3/22/21 6:06 AM, Heikki Krogerus wrote: > The function device_add_properties() is going to be removed. > Replacing it with software node API equivalents. > > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > Hi, > > This patch depends on a fix from mainline, available in v5.12-rc4: > > 2a92c90f2ecc ("software node: Fix device_add_software_node()") > > Cheers, > --- > sound/soc/intel/boards/bytcht_es8316.c | 2 +- > sound/soc/intel/boards/bytcr_rt5640.c | 2 +- > sound/soc/intel/boards/bytcr_rt5651.c | 2 +- > sound/soc/intel/boards/sof_sdw_rt711.c | 20 +++++++++++++++----- > sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 20 +++++++++++++++----- > 5 files changed, 33 insertions(+), 13 deletions(-) > > diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c > index 06df2d46d910b..4a9817a95928c 100644 > --- a/sound/soc/intel/boards/bytcht_es8316.c > +++ b/sound/soc/intel/boards/bytcht_es8316.c > @@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) > props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); > > if (cnt) { > - ret = device_add_properties(codec_dev, props); > + ret = device_create_managed_software_node(codec_dev, props, NULL); I don't think this is correct. This is using the codec_dev device, but this property is created in the machine driver - different device. I think the proper fix is to remove the property in the machine driver .remove() callback, as done below for the SoundWire case, and not to rely on devm_ with the wrong device. there was a thread between July and October on this in https://github.com/thesofproject/linux/pull/2306/ It seems that we need to restart this work. Heikki, do you mind if I take your patches (keeping you as the author) and rework+test them with the SOF tree + CI ? > if (ret) { > put_device(codec_dev); > return ret; > diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c > index 59d6d47c8d829..661dad81e5bce 100644 > --- a/sound/soc/intel/boards/bytcr_rt5640.c > +++ b/sound/soc/intel/boards/bytcr_rt5640.c > @@ -918,7 +918,7 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name) > if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) > props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); > > - ret = device_add_properties(i2c_dev, props); > + ret = device_create_managed_software_node(i2c_dev, props, NULL); > put_device(i2c_dev); > > return ret; > diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c > index 148b7b1bd3e8c..4cb6ef4c3a3d9 100644 > --- a/sound/soc/intel/boards/bytcr_rt5651.c > +++ b/sound/soc/intel/boards/bytcr_rt5651.c > @@ -547,7 +547,7 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev) > if (byt_rt5651_quirk & BYT_RT5651_JD_NOT_INV) > props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); > > - return device_add_properties(i2c_dev, props); > + return device_create_managed_software_node(i2c_dev, props, NULL); > } > > static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) > diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c > index 04074c09dded9..b7c635c0fadd5 100644 > --- a/sound/soc/intel/boards/sof_sdw_rt711.c > +++ b/sound/soc/intel/boards/sof_sdw_rt711.c > @@ -24,19 +24,29 @@ > static int rt711_add_codec_device_props(const char *sdw_dev_name) > { > struct property_entry props[MAX_NO_PROPS] = {}; > + struct fwnode_handle *fwnode; > struct device *sdw_dev; > int ret; > > + if (!SOF_RT711_JDSRC(sof_sdw_quirk)) > + return 0; > + > sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name); > if (!sdw_dev) > return -EPROBE_DEFER; > > - if (SOF_RT711_JDSRC(sof_sdw_quirk)) { > - props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", > - SOF_RT711_JDSRC(sof_sdw_quirk)); > + props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", > + SOF_RT711_JDSRC(sof_sdw_quirk)); > + > + fwnode = fwnode_create_software_node(props, NULL); > + if (IS_ERR(fwnode)) { > + put_device(sdw_dev); > + return PTR_ERR(fwnode); > } > > - ret = device_add_properties(sdw_dev, props); > + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); > + > + fwnode_handle_put(fwnode); > put_device(sdw_dev); > > return ret; > @@ -144,7 +154,7 @@ int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link) > if (!sdw_dev) > return -EINVAL; > > - device_remove_properties(sdw_dev); > + device_remove_software_node(sdw_dev); > put_device(sdw_dev); > > return 0; > diff --git a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c > index 19496f0f9110c..300a52d155069 100644 > --- a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c > +++ b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c > @@ -24,19 +24,29 @@ > static int rt711_sdca_add_codec_device_props(const char *sdw_dev_name) > { > struct property_entry props[MAX_NO_PROPS] = {}; > + struct fwnode_handle *fwnode; > struct device *sdw_dev; > int ret; > > + if (!SOF_RT711_JDSRC(sof_sdw_quirk)) > + return 0; > + > sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name); > if (!sdw_dev) > return -EPROBE_DEFER; > > - if (SOF_RT711_JDSRC(sof_sdw_quirk)) { > - props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", > - SOF_RT711_JDSRC(sof_sdw_quirk)); > + props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", > + SOF_RT711_JDSRC(sof_sdw_quirk)); > + > + fwnode = fwnode_create_software_node(props, NULL); > + if (IS_ERR(fwnode)) { > + put_device(sdw_dev); > + return PTR_ERR(fwnode); > } > > - ret = device_add_properties(sdw_dev, props); > + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); > + > + fwnode_handle_put(fwnode); > put_device(sdw_dev); > > return ret; > @@ -144,7 +154,7 @@ int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_lin > if (!sdw_dev) > return -EINVAL; > > - device_remove_properties(sdw_dev); > + device_remove_software_node(sdw_dev); > put_device(sdw_dev); > > return 0; >
On Mon, Mar 22, 2021 at 10:02:40AM -0500, Pierre-Louis Bossart wrote: > > > On 3/22/21 6:06 AM, Heikki Krogerus wrote: > > The function device_add_properties() is going to be removed. > > Replacing it with software node API equivalents. > > > > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > > --- > > Hi, > > > > This patch depends on a fix from mainline, available in v5.12-rc4: > > > > 2a92c90f2ecc ("software node: Fix device_add_software_node()") > > > > Cheers, > > --- > > sound/soc/intel/boards/bytcht_es8316.c | 2 +- > > sound/soc/intel/boards/bytcr_rt5640.c | 2 +- > > sound/soc/intel/boards/bytcr_rt5651.c | 2 +- > > sound/soc/intel/boards/sof_sdw_rt711.c | 20 +++++++++++++++----- > > sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 20 +++++++++++++++----- > > 5 files changed, 33 insertions(+), 13 deletions(-) > > > > diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c > > index 06df2d46d910b..4a9817a95928c 100644 > > --- a/sound/soc/intel/boards/bytcht_es8316.c > > +++ b/sound/soc/intel/boards/bytcht_es8316.c > > @@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) > > props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); > > if (cnt) { > > - ret = device_add_properties(codec_dev, props); > > + ret = device_create_managed_software_node(codec_dev, props, NULL); > > I don't think this is correct. This is using the codec_dev device, but this > property is created in the machine driver - different device. I think the > proper fix is to remove the property in the machine driver .remove() > callback, as done below for the SoundWire case, and not to rely on devm_ > with the wrong device. > > there was a thread between July and October on this in > https://github.com/thesofproject/linux/pull/2306/ > > It seems that we need to restart this work. > > Heikki, do you mind if I take your patches (keeping you as the author) and > rework+test them with the SOF tree + CI ? OK by me (though, I'm not sure about the author part after that). thanks,
Hi Heikki, >>> diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c >>> index 06df2d46d910b..4a9817a95928c 100644 >>> --- a/sound/soc/intel/boards/bytcht_es8316.c >>> +++ b/sound/soc/intel/boards/bytcht_es8316.c >>> @@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) >>> props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); >>> if (cnt) { >>> - ret = device_add_properties(codec_dev, props); >>> + ret = device_create_managed_software_node(codec_dev, props, NULL); >> >> I don't think this is correct. This is using the codec_dev device, but this >> property is created in the machine driver - different device. I think the >> proper fix is to remove the property in the machine driver .remove() >> callback, as done below for the SoundWire case, and not to rely on devm_ >> with the wrong device. >> >> there was a thread between July and October on this in >> https://github.com/thesofproject/linux/pull/2306/ >> >> It seems that we need to restart this work. >> >> Heikki, do you mind if I take your patches (keeping you as the author) and >> rework+test them with the SOF tree + CI ? > > OK by me (though, I'm not sure about the author part after that). I took the code and split it in two for BYT/CHT (modified to remove devm_) and SoundWire parts (added as is). https://github.com/thesofproject/linux/pull/2810 Both cases result in a refcount error on device_remove_sof when removing the platform device. I don't understand the code well enough to figure out what happens, but it's likely a case of the software node being removed twice? kernel: [ 872.695132] refcount_t: underflow; use-after-free. kernel: [ 872.695153] WARNING: CPU: 7 PID: 16086 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0 <snip> kernel: [ 872.695222] CPU: 7 PID: 16086 Comm: rmmod Not tainted 5.12.0-rc4-pr2810-5522-default #439c50f6 kernel: [ 872.695225] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP, BIOS TGLSFWI1.R00.3264.A00.2006251828 06/25/2020 kernel: [ 872.695226] RIP: 0010:refcount_warn_saturate+0xa6/0xf0 < snip> kernel: [ 872.695244] Call Trace: kernel: [ 872.695248] sof_sdw_rt711_exit+0x2d/0x40 [snd_soc_sof_sdw] kernel: [ 872.695253] mc_remove+0xa8/0xe0 [snd_soc_sof_sdw] kernel: [ 872.695256] ? rt711_rtd_init+0x170/0x170 [snd_soc_sof_sdw] kernel: [ 872.695259] platform_remove+0x1a/0x40 kernel: [ 872.695264] device_release_driver_internal+0xf1/0x1d0 kernel: [ 872.695267] bus_remove_device+0xed/0x160 kernel: [ 872.695269] device_del+0x187/0x3e0 kernel: [ 872.695272] platform_device_del.part.0+0xe/0x60 kernel: [ 872.695274] platform_device_unregister+0x17/0x30 kernel: [ 872.695277] snd_sof_device_remove+0x53/0xf0 [snd_sof] kernel: [ 872.695283] sof_pci_remove+0x15/0x40 [snd_sof_pci] kernel: [ 872.695286] pci_device_remove+0x36/0xa0 kernel: [ 872.695290] device_release_driver_internal+0xf1/0x1d0 kernel: [ 872.695292] driver_detach+0x42/0x90 kernel: [ 872.695294] bus_remove_driver+0x56/0xd0 kernel: [ 872.695296] pci_unregister_driver+0x36/0x80 kernel: [ 872.695299] __x64_sys_delete_module+0x18f/0x250
On Mon, Apr 12, 2021 at 03:36:20PM -0500, Pierre-Louis Bossart wrote: > I took the code and split it in two for BYT/CHT (modified to remove devm_) > and SoundWire parts (added as is). > > https://github.com/thesofproject/linux/pull/2810 > > Both cases result in a refcount error on device_remove_sof when removing the > platform device. I don't understand the code well enough to figure out what > happens, but it's likely a case of the software node being removed twice? Right. Because you are injecting the node to an already existing device, the node does not get linked with the device in sysfs. That would increment the reference count in a normal case. It all happens in the function software_node_notify(). Driver core calls it when a device is added and also when it's removed. In this case it is only called when it's removed. I think the best way to handle this now is to simply not decrementing the ref count when you add the properties, so don't call fwnode_handle_put() there (but add a comment explaining why you are not calling it). For a better solution you would call device_reprobe() after you have injected the software node, but before that you need to modify device_reprobe() so it calls device_platform_notify() (which it really should call in any case). But this should probable be done later, separately. thanks, P.S. Have you guys considered the possibility of describing the connections between all these components by using one of the methods that we now have for that in kernel, for example device graph? It can now be used also with software nodes (OF graph and ACPI device graph are of course already fully supported).
On Tue, Apr 13, 2021 at 03:20:45PM +0300, Heikki Krogerus wrote: > On Mon, Apr 12, 2021 at 03:36:20PM -0500, Pierre-Louis Bossart wrote: > > I took the code and split it in two for BYT/CHT (modified to remove devm_) > > and SoundWire parts (added as is). > > > > https://github.com/thesofproject/linux/pull/2810 > > > > Both cases result in a refcount error on device_remove_sof when removing the > > platform device. I don't understand the code well enough to figure out what > > happens, but it's likely a case of the software node being removed twice? > > Right. Because you are injecting the node to an already existing > device, the node does not get linked with the device in sysfs. That > would increment the reference count in a normal case. It all happens > in the function software_node_notify(). Driver core calls it when a > device is added and also when it's removed. In this case it is only > called when it's removed. > > I think the best way to handle this now is to simply not decrementing > the ref count when you add the properties, so don't call > fwnode_handle_put() there (but add a comment explaining why you are > not calling it). No, sorry... That's just too hacky. Let's not do that after all. We can also fix this in the software node code. I'm attaching a patch that should make it possible to inject the software nodes also afterwards safely. This is definitely also not without its problems, but we can go with that if it works. Let me know. > For a better solution you would call device_reprobe() after you have > injected the software node, but before that you need to modify > device_reprobe() so it calls device_platform_notify() (which it really > should call in any case). But this should probable be done later, > separately. > > thanks, > > P.S. > > Have you guys considered the possibility of describing the connections > between all these components by using one of the methods that we now > have for that in kernel, for example device graph? It can now be > used also with software nodes (OF graph and ACPI device graph are of > course already fully supported). Br,
On 4/13/21 9:05 AM, Heikki Krogerus wrote: > On Tue, Apr 13, 2021 at 03:20:45PM +0300, Heikki Krogerus wrote: >> On Mon, Apr 12, 2021 at 03:36:20PM -0500, Pierre-Louis Bossart wrote: >>> I took the code and split it in two for BYT/CHT (modified to remove devm_) >>> and SoundWire parts (added as is). >>> >>> https://github.com/thesofproject/linux/pull/2810 >>> >>> Both cases result in a refcount error on device_remove_sof when removing the >>> platform device. I don't understand the code well enough to figure out what >>> happens, but it's likely a case of the software node being removed twice? >> >> Right. Because you are injecting the node to an already existing >> device, the node does not get linked with the device in sysfs. That >> would increment the reference count in a normal case. It all happens >> in the function software_node_notify(). Driver core calls it when a >> device is added and also when it's removed. In this case it is only >> called when it's removed. >> >> I think the best way to handle this now is to simply not decrementing >> the ref count when you add the properties, so don't call >> fwnode_handle_put() there (but add a comment explaining why you are >> not calling it). > > No, sorry... That's just too hacky. Let's not do that after all. > > We can also fix this in the software node code. I'm attaching a patch > that should make it possible to inject the software nodes also > afterwards safely. This is definitely also not without its problems, > but we can go with that if it works. Let me know. I tested manually on bytcr w/ RT5640 and used the SOF CI farm to test the SoundWire cases, I don't see any issues with your patch. The refcount issue is gone and the module load/unload cycles don't report any problems. Would you queue it for 5.13-rc1, or is this too late already? >> For a better solution you would call device_reprobe() after you have >> injected the software node, but before that you need to modify >> device_reprobe() so it calls device_platform_notify() (which it really >> should call in any case). But this should probable be done later, >> separately. >> >> thanks, >> >> P.S. >> >> Have you guys considered the possibility of describing the connections >> between all these components by using one of the methods that we now >> have for that in kernel, for example device graph? It can now be >> used also with software nodes (OF graph and ACPI device graph are of >> course already fully supported). I must admit I've never heard of a 'device graph'. Any pointers or APIs you can think of? It's a good comment since we are planning to rework the SOF clients and machine driver handling.
On Tue, Apr 13, 2021 at 10:47:49AM -0500, Pierre-Louis Bossart wrote: > > > On 4/13/21 9:05 AM, Heikki Krogerus wrote: > > On Tue, Apr 13, 2021 at 03:20:45PM +0300, Heikki Krogerus wrote: > > > On Mon, Apr 12, 2021 at 03:36:20PM -0500, Pierre-Louis Bossart wrote: > > > > I took the code and split it in two for BYT/CHT (modified to remove devm_) > > > > and SoundWire parts (added as is). > > > > > > > > https://github.com/thesofproject/linux/pull/2810 > > > > > > > > Both cases result in a refcount error on device_remove_sof when removing the > > > > platform device. I don't understand the code well enough to figure out what > > > > happens, but it's likely a case of the software node being removed twice? > > > > > > Right. Because you are injecting the node to an already existing > > > device, the node does not get linked with the device in sysfs. That > > > would increment the reference count in a normal case. It all happens > > > in the function software_node_notify(). Driver core calls it when a > > > device is added and also when it's removed. In this case it is only > > > called when it's removed. > > > > > > I think the best way to handle this now is to simply not decrementing > > > the ref count when you add the properties, so don't call > > > fwnode_handle_put() there (but add a comment explaining why you are > > > not calling it). > > > > No, sorry... That's just too hacky. Let's not do that after all. > > > > We can also fix this in the software node code. I'm attaching a patch > > that should make it possible to inject the software nodes also > > afterwards safely. This is definitely also not without its problems, > > but we can go with that if it works. Let me know. > > I tested manually on bytcr w/ RT5640 and used the SOF CI farm to test the > SoundWire cases, I don't see any issues with your patch. The refcount issue > is gone and the module load/unload cycles don't report any problems. > > Would you queue it for 5.13-rc1, or is this too late already? I'll send it out now. Let's see what happens. thanks, > > > For a better solution you would call device_reprobe() after you have > > > injected the software node, but before that you need to modify > > > device_reprobe() so it calls device_platform_notify() (which it really > > > should call in any case). But this should probable be done later, > > > separately. > > > > > > thanks, > > > > > > P.S. > > > > > > Have you guys considered the possibility of describing the connections > > > between all these components by using one of the methods that we now > > > have for that in kernel, for example device graph? It can now be > > > used also with software nodes (OF graph and ACPI device graph are of > > > course already fully supported). > > I must admit I've never heard of a 'device graph'. Any pointers or APIs you > can think of? > It's a good comment since we are planning to rework the SOF clients and > machine driver handling.
Hi Heikki, Going back to this initial patch, I have a doubt based on Andy Shevchenko's comment on an update [1] > The function device_add_properties() is going to be removed. > Replacing it with software node API equivalents. The replacement pattern takes this one line: > - ret = device_add_properties(sdw_dev, props); which gets replaced by > + fwnode = fwnode_create_software_node(props, NULL); > + if (IS_ERR(fwnode)) { > + return PTR_ERR(fwnode); > } > > + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); > + > + fwnode_handle_put(fwnode); is the fwnode_handle_put() actually required here? This seems to work fine in our tests but I wasn't able to find in the code a matching _get(). Thanks for any pointers/comments! -Pierre [1] https://github.com/thesofproject/linux/pull/3041#discussion_r671450168
diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index 06df2d46d910b..4a9817a95928c 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); if (cnt) { - ret = device_add_properties(codec_dev, props); + ret = device_create_managed_software_node(codec_dev, props, NULL); if (ret) { put_device(codec_dev); return ret; diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 59d6d47c8d829..661dad81e5bce 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -918,7 +918,7 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name) if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); - ret = device_add_properties(i2c_dev, props); + ret = device_create_managed_software_node(i2c_dev, props, NULL); put_device(i2c_dev); return ret; diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 148b7b1bd3e8c..4cb6ef4c3a3d9 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -547,7 +547,7 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev) if (byt_rt5651_quirk & BYT_RT5651_JD_NOT_INV) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); - return device_add_properties(i2c_dev, props); + return device_create_managed_software_node(i2c_dev, props, NULL); } static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c index 04074c09dded9..b7c635c0fadd5 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711.c +++ b/sound/soc/intel/boards/sof_sdw_rt711.c @@ -24,19 +24,29 @@ static int rt711_add_codec_device_props(const char *sdw_dev_name) { struct property_entry props[MAX_NO_PROPS] = {}; + struct fwnode_handle *fwnode; struct device *sdw_dev; int ret; + if (!SOF_RT711_JDSRC(sof_sdw_quirk)) + return 0; + sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name); if (!sdw_dev) return -EPROBE_DEFER; - if (SOF_RT711_JDSRC(sof_sdw_quirk)) { - props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", - SOF_RT711_JDSRC(sof_sdw_quirk)); + props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", + SOF_RT711_JDSRC(sof_sdw_quirk)); + + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) { + put_device(sdw_dev); + return PTR_ERR(fwnode); } - ret = device_add_properties(sdw_dev, props); + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); put_device(sdw_dev); return ret; @@ -144,7 +154,7 @@ int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link) if (!sdw_dev) return -EINVAL; - device_remove_properties(sdw_dev); + device_remove_software_node(sdw_dev); put_device(sdw_dev); return 0; diff --git a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c index 19496f0f9110c..300a52d155069 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c +++ b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c @@ -24,19 +24,29 @@ static int rt711_sdca_add_codec_device_props(const char *sdw_dev_name) { struct property_entry props[MAX_NO_PROPS] = {}; + struct fwnode_handle *fwnode; struct device *sdw_dev; int ret; + if (!SOF_RT711_JDSRC(sof_sdw_quirk)) + return 0; + sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name); if (!sdw_dev) return -EPROBE_DEFER; - if (SOF_RT711_JDSRC(sof_sdw_quirk)) { - props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", - SOF_RT711_JDSRC(sof_sdw_quirk)); + props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", + SOF_RT711_JDSRC(sof_sdw_quirk)); + + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) { + put_device(sdw_dev); + return PTR_ERR(fwnode); } - ret = device_add_properties(sdw_dev, props); + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); put_device(sdw_dev); return ret; @@ -144,7 +154,7 @@ int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_lin if (!sdw_dev) return -EINVAL; - device_remove_properties(sdw_dev); + device_remove_software_node(sdw_dev); put_device(sdw_dev); return 0;
The function device_add_properties() is going to be removed. Replacing it with software node API equivalents. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> --- Hi, This patch depends on a fix from mainline, available in v5.12-rc4: 2a92c90f2ecc ("software node: Fix device_add_software_node()") Cheers, --- sound/soc/intel/boards/bytcht_es8316.c | 2 +- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/sof_sdw_rt711.c | 20 +++++++++++++++----- sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 20 +++++++++++++++----- 5 files changed, 33 insertions(+), 13 deletions(-)