diff mbox series

ASoC: cs42l56: fix DT probe

Message ID 20230126135552.3625887-1-arnd@kernel.org (mailing list archive)
State Superseded
Headers show
Series ASoC: cs42l56: fix DT probe | expand

Commit Message

Arnd Bergmann Jan. 26, 2023, 1:55 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

While looking through legacy platform data users, I noticed that
this one could never be used with DT based probing as the
platform_data structure gets overwritten directly after it
is initialized.

There have never been any boards defining the platform_data in
the mainline kernel either, so this driver so far only worked
with patched kernels.

For the benefit of possible downstream users, fix the DT probe
by no longer overwriting the data.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/soc/codecs/cs42l56.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Mark Brown Jan. 26, 2023, 2:03 p.m. UTC | #1
On Thu, Jan 26, 2023 at 02:55:29PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> While looking through legacy platform data users, I noticed that
> this one could never be used with DT based probing as the
> platform_data structure gets overwritten directly after it
> is initialized.
> 
> There have never been any boards defining the platform_data in
> the mainline kernel either, so this driver so far only worked
> with patched kernels.

Or there is no mandatory properties/platform data and the
defaults are fine for most systems (which is a common case).
Charles Keepax Jan. 26, 2023, 2:46 p.m. UTC | #2
On Thu, Jan 26, 2023 at 02:03:35PM +0000, Mark Brown wrote:
> On Thu, Jan 26, 2023 at 02:55:29PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > 
> > While looking through legacy platform data users, I noticed that
> > this one could never be used with DT based probing as the
> > platform_data structure gets overwritten directly after it
> > is initialized.
> > 
> > There have never been any boards defining the platform_data in
> > the mainline kernel either, so this driver so far only worked
> > with patched kernels.
> 
> Or there is no mandatory properties/platform data and the
> defaults are fine for most systems (which is a common case).

I think Arnd is right here, the driver appears to allocate a big
block of zeros and then blat that over the top of everything it
read from device tree. So you can literally never use any of the
DT properties as it stands.

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Mark Brown Jan. 26, 2023, 3:32 p.m. UTC | #3
On Thu, Jan 26, 2023 at 02:46:35PM +0000, Charles Keepax wrote:
> On Thu, Jan 26, 2023 at 02:03:35PM +0000, Mark Brown wrote:

> > Or there is no mandatory properties/platform data and the
> > defaults are fine for most systems (which is a common case).

> I think Arnd is right here, the driver appears to allocate a big
> block of zeros and then blat that over the top of everything it
> read from device tree. So you can literally never use any of the
> DT properties as it stands.

Oh, the fix is fixing a real issue - it's the claim in the commit
log that the driver could never have worked that's not obviously
correct.
diff mbox series

Patch

diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c
index 26066682c983..3b0e715549c9 100644
--- a/sound/soc/codecs/cs42l56.c
+++ b/sound/soc/codecs/cs42l56.c
@@ -1191,18 +1191,12 @@  static int cs42l56_i2c_probe(struct i2c_client *i2c_client)
 	if (pdata) {
 		cs42l56->pdata = *pdata;
 	} else {
-		pdata = devm_kzalloc(&i2c_client->dev, sizeof(*pdata),
-				     GFP_KERNEL);
-		if (!pdata)
-			return -ENOMEM;
-
 		if (i2c_client->dev.of_node) {
 			ret = cs42l56_handle_of_data(i2c_client,
 						     &cs42l56->pdata);
 			if (ret != 0)
 				return ret;
 		}
-		cs42l56->pdata = *pdata;
 	}
 
 	if (cs42l56->pdata.gpio_nreset) {