From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <andy.shevchenko@gmail.com>, <patches@opensource.cirrus.com>,
<linux-spi@vger.kernel.org>
Subject: [PATCH] spi: cs42l43: Clean up of firmware node
Date: Thu, 1 Feb 2024 10:44:43 +0000 [thread overview]
Message-ID: <20240201104443.363786-1-ckeepax@opensource.cirrus.com> (raw)
As we get a child node in the of case, we should also clean up the
references to this, add code for this.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
drivers/spi/spi-cs42l43.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c
index b24190526ce9..1765d752e341 100644
--- a/drivers/spi/spi-cs42l43.c
+++ b/drivers/spi/spi-cs42l43.c
@@ -218,6 +218,7 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
return -ENOMEM;
spi_controller_set_devdata(priv->ctlr, priv);
+ platform_set_drvdata(pdev, priv);
priv->dev = &pdev->dev;
priv->regmap = cs42l43->regmap;
@@ -228,12 +229,6 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
priv->ctlr->transfer_one = cs42l43_transfer_one;
priv->ctlr->set_cs = cs42l43_set_cs;
priv->ctlr->max_transfer_size = cs42l43_spi_max_length;
-
- if (is_of_node(fwnode))
- fwnode = fwnode_get_named_child_node(fwnode, "spi");
-
- device_set_node(&priv->ctlr->dev, fwnode);
-
priv->ctlr->mode_bits = SPI_3WIRE | SPI_MODE_X_MASK;
priv->ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX;
priv->ctlr->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16) |
@@ -257,14 +252,34 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
regmap_write(priv->regmap, CS42L43_SPI_CONFIG3, 0);
regmap_write(priv->regmap, CS42L43_SPI_CONFIG4, CS42L43_SPI_STALL_ENA_MASK);
+ if (is_of_node(fwnode))
+ fwnode = fwnode_get_named_child_node(fwnode, "spi");
+
+ device_set_node(&priv->ctlr->dev, fwnode);
+
ret = devm_spi_register_controller(priv->dev, priv->ctlr);
if (ret) {
dev_err(priv->dev, "Failed to register SPI controller: %d\n", ret);
+ goto of_node_err;
}
+ return 0;
+
+of_node_err:
+ if (is_of_node(fwnode))
+ fwnode_handle_put(fwnode);
+
return ret;
}
+static void cs42l43_spi_remove(struct platform_device *pdev)
+{
+ struct cs42l43_spi *priv = dev_get_drvdata(&pdev->dev);
+
+ if (is_of_node(priv->ctlr->dev.fwnode))
+ fwnode_handle_put(priv->ctlr->dev.fwnode);
+}
+
static const struct platform_device_id cs42l43_spi_id_table[] = {
{ "cs42l43-spi", },
{}
@@ -276,6 +291,7 @@ static struct platform_driver cs42l43_spi_driver = {
.name = "cs42l43-spi",
},
.probe = cs42l43_spi_probe,
+ .remove_new = cs42l43_spi_remove,
.id_table = cs42l43_spi_id_table,
};
module_platform_driver(cs42l43_spi_driver);
--
2.30.2
next reply other threads:[~2024-02-01 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 10:44 Charles Keepax [this message]
2024-02-01 14:43 ` [PATCH] spi: cs42l43: Clean up of firmware node Andy Shevchenko
2024-02-01 14:45 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201104443.363786-1-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=andy.shevchenko@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox