Skip to content

Commit 6914ee9

Browse files
charleskeepaxbroonie
authored andcommitted
spi: cs42l43: Refactor accessing the SDCA extension properties
Refactor accessing the SDCA extension properties to make it easier to access multiple properties to assist with future features. Return the node itself and allow the caller to read the actual properties. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240611132556.1557075-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 313d2c9 commit 6914ee9

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

drivers/spi/spi-cs42l43.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,10 @@ static size_t cs42l43_spi_max_length(struct spi_device *spi)
246246
return CS42L43_SPI_MAX_LENGTH;
247247
}
248248

249-
static bool cs42l43_has_sidecar(struct fwnode_handle *fwnode)
249+
static struct fwnode_handle *cs42l43_find_xu_node(struct fwnode_handle *fwnode)
250250
{
251251
static const u32 func_smart_amp = 0x1;
252252
struct fwnode_handle *child_fwnode, *ext_fwnode;
253-
unsigned int val;
254253
u32 function;
255254
int ret;
256255

@@ -266,21 +265,12 @@ static bool cs42l43_has_sidecar(struct fwnode_handle *fwnode)
266265
if (!ext_fwnode)
267266
continue;
268267

269-
ret = fwnode_property_read_u32(ext_fwnode,
270-
"01fa-sidecar-instances",
271-
&val);
272-
273-
fwnode_handle_put(ext_fwnode);
274-
275-
if (ret)
276-
continue;
277-
278268
fwnode_handle_put(child_fwnode);
279269

280-
return !!val;
270+
return ext_fwnode;
281271
}
282272

283-
return false;
273+
return NULL;
284274
}
285275

286276
static void cs42l43_release_of_node(void *data)
@@ -298,7 +288,8 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
298288
struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
299289
struct cs42l43_spi *priv;
300290
struct fwnode_handle *fwnode = dev_fwnode(cs42l43->dev);
301-
bool has_sidecar = cs42l43_has_sidecar(fwnode);
291+
struct fwnode_handle *xu_fwnode __free(fwnode_handle) = cs42l43_find_xu_node(fwnode);
292+
int nsidecars = 0;
302293
int ret;
303294

304295
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -350,7 +341,9 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
350341
return ret;
351342
}
352343

353-
if (has_sidecar) {
344+
fwnode_property_read_u32(xu_fwnode, "01fa-sidecar-instances", &nsidecars);
345+
346+
if (nsidecars) {
354347
ret = software_node_register(&cs42l43_gpiochip_swnode);
355348
if (ret)
356349
return dev_err_probe(priv->dev, ret,
@@ -373,7 +366,7 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
373366
return dev_err_probe(priv->dev, ret,
374367
"Failed to register SPI controller\n");
375368

376-
if (has_sidecar) {
369+
if (nsidecars) {
377370
if (!spi_new_device(priv->ctlr, &ampl_info))
378371
return dev_err_probe(priv->dev, -ENODEV,
379372
"Failed to create left amp slave\n");

0 commit comments

Comments
 (0)