From: Moteen Shah <m-shah@ti.com>
To: <conor+dt@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
<nm@ti.com>, <ssantosh@kernel.org>
Cc: <u-kumar1@ti.com>, <gehariprasath@ti.com>, <m-shah@ti.com>,
<vigneshr@ti.com>, <afd@ti.com>, <a-limaye@ti.com>,
<y-abhilashchandra@ti.com>, <johan@kernel.org>, <kees@kernel.org>,
<jm@ti.com>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH v3 2/4] soc: ti: k3-socinfo: Use device managed allocations and unregistration
Date: Thu, 12 Nov 2026 13:40:45 +0530 [thread overview]
Message-ID: <20261112081047.1550471-3-m-shah@ti.com> (raw)
In-Reply-To: <20261112081047.1550471-1-m-shah@ti.com>
Allocate the SoC attributes and revision string with devm and unregister
the SoC device through a devm action. This drops the manual error unwinding
in k3_chipinfo_probe().
Signed-off-by: Moteen Shah <m-shah@ti.com>
---
drivers/soc/ti/k3-socinfo.c | 43 +++++++++++++++++++------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c
index 48dbef3acceb4..e21a2cd14c811 100644
--- a/drivers/soc/ti/k3-socinfo.c
+++ b/drivers/soc/ti/k3-socinfo.c
@@ -115,14 +115,14 @@ k3_chipinfo_variant_to_sr(struct device *dev, unsigned int partno,
case JTAG_ID_PARTNO_J721E:
if (variant >= ARRAY_SIZE(j721e_rev_string_map))
goto err_unknown_variant;
- soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%s",
- j721e_rev_string_map[variant]);
+ soc_dev_attr->revision = devm_kasprintf(dev, GFP_KERNEL, "SR%s",
+ j721e_rev_string_map[variant]);
break;
case JTAG_ID_PARTNO_AM62LX:
if (variant >= ARRAY_SIZE(am62lx_rev_string_map))
goto err_unknown_variant;
- soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%s",
- am62lx_rev_string_map[variant]);
+ soc_dev_attr->revision = devm_kasprintf(dev, GFP_KERNEL, "SR%s",
+ am62lx_rev_string_map[variant]);
break;
case JTAG_ID_PARTNO_AM62PX:
/* Check GP_SW1 for silicon revision */
@@ -134,13 +134,13 @@ k3_chipinfo_variant_to_sr(struct device *dev, unsigned int partno,
gpsw_variant);
gpsw_variant = 0;
}
- soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%s",
- am62p_gpsw_rev_string_map[gpsw_variant]);
+ soc_dev_attr->revision = devm_kasprintf(dev, GFP_KERNEL, "SR%s",
+ am62p_gpsw_rev_string_map[gpsw_variant]);
break;
default:
variant++;
- soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0",
- variant);
+ soc_dev_attr->revision = devm_kasprintf(dev, GFP_KERNEL, "SR%x.0",
+ variant);
}
if (!soc_dev_attr->revision)
@@ -158,6 +158,11 @@ static const struct regmap_config k3_chipinfo_regmap_cfg = {
.reg_stride = 4,
};
+static void k3_chipinfo_unregister(void *data)
+{
+ soc_device_unregister(data);
+}
+
static int k3_chipinfo_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
@@ -198,20 +203,20 @@ static int k3_chipinfo_probe(struct platform_device *pdev)
partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >>
CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT;
- soc_dev_attr = kzalloc_obj(*soc_dev_attr);
+ soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
if (!soc_dev_attr)
return -ENOMEM;
ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr);
if (ret) {
dev_err(dev, "Unknown SoC JTAGID[0x%08X]: %d\n", jtag_id, ret);
- goto err;
+ return ret;
}
ret = k3_chipinfo_variant_to_sr(dev, partno_id, variant, soc_dev_attr);
if (ret) {
dev_err(dev, "Unknown SoC SR[0x%08X]: %d\n", jtag_id, ret);
- goto err;
+ return ret;
}
node = of_find_node_by_path("/");
@@ -219,22 +224,18 @@ static int k3_chipinfo_probe(struct platform_device *pdev)
of_node_put(node);
soc_dev = soc_device_register(soc_dev_attr);
- if (IS_ERR(soc_dev)) {
- ret = PTR_ERR(soc_dev);
- goto err_free_rev;
- }
+ if (IS_ERR(soc_dev))
+ return PTR_ERR(soc_dev);
+
+ ret = devm_add_action_or_reset(dev, k3_chipinfo_unregister, soc_dev);
+ if (ret)
+ return ret;
dev_info(dev, "Family:%s rev:%s JTAGID[0x%08x] Detected\n",
soc_dev_attr->family,
soc_dev_attr->revision, jtag_id);
return 0;
-
-err_free_rev:
- kfree(soc_dev_attr->revision);
-err:
- kfree(soc_dev_attr);
- return ret;
}
static const struct of_device_id k3_chipinfo_of_match[] = {
--
2.34.1
next prev parent reply other threads:[~2026-11-12 8:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 8:10 [PATCH v3 0/4] soc: ti: Add TDA54 SCM configuration syscon support Moteen Shah
2026-11-12 8:10 ` [PATCH v3 1/4] dt-bindings: soc: ti: Document the ti,tda54-mcu-scm-conf Moteen Shah
2026-11-12 8:10 ` Moteen Shah [this message]
2026-11-12 8:10 ` [PATCH v3 3/4] soc: ti: k3-socinfo: Export SoC registration helper Moteen Shah
2026-11-12 8:10 ` [PATCH v3 4/4] soc: ti: Add TDA54 SCM configuration syscon support Moteen Shah
2026-11-12 16:16 ` kernel test robot
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=20261112081047.1550471-3-m-shah@ti.com \
--to=m-shah@ti.com \
--cc=a-limaye@ti.com \
--cc=afd@ti.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gehariprasath@ti.com \
--cc=jm@ti.com \
--cc=johan@kernel.org \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nm@ti.com \
--cc=robh@kernel.org \
--cc=ssantosh@kernel.org \
--cc=u-kumar1@ti.com \
--cc=vigneshr@ti.com \
--cc=y-abhilashchandra@ti.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
all inboxes | Powered by JetHome®