drivers/soc/imx/Makefile | 2 +- drivers/soc/imx/soc-imx9.c | 103 +++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/imx/soc-imx9.c
From: "alice.guo" <alice.guo@nxp.com>
i.MX9 SoCs have SoC ID, SoC revision number and chip unique identifier
which are provided by the corresponding ARM trusted firmware API. This
patch intends to use SMC call to obtain these information and then
register i.MX9 SoC as a device.
Signed-off-by: alice.guo <alice.guo@nxp.com>
---
Changes for v2:
- refine error log print
drivers/soc/imx/Makefile | 2 +-
drivers/soc/imx/soc-imx9.c | 103 +++++++++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+), 1 deletion(-)
create mode 100644 drivers/soc/imx/soc-imx9.c
diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile
index 3ad321ca608a..ca6a5fa1618f 100644
--- a/drivers/soc/imx/Makefile
+++ b/drivers/soc/imx/Makefile
@@ -3,4 +3,4 @@ ifeq ($(CONFIG_ARM),y)
obj-$(CONFIG_ARCH_MXC) += soc-imx.o
endif
obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
-obj-$(CONFIG_SOC_IMX9) += imx93-src.o
+obj-$(CONFIG_SOC_IMX9) += imx93-src.o soc-imx9.o
diff --git a/drivers/soc/imx/soc-imx9.c b/drivers/soc/imx/soc-imx9.c
new file mode 100644
index 000000000000..0722e69110f9
--- /dev/null
+++ b/drivers/soc/imx/soc-imx9.c
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2024 NXP
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/slab.h>
+#include <linux/sys_soc.h>
+
+#define IMX_SIP_GET_SOC_INFO 0xc2000006
+#define SOC_ID(x) (((x) & 0xFFFF) >> 8)
+#define SOC_REV_MAJOR(x) ((((x) >> 28) & 0xF) - 0x9)
+#define SOC_REV_MINOR(x) (((x) >> 24) & 0xF)
+
+static int imx9_soc_device_register(void)
+{
+ struct soc_device_attribute *attr;
+ struct arm_smccc_res res;
+ struct soc_device *sdev;
+ u32 soc_id, rev_major, rev_minor;
+ u64 uid127_64, uid63_0;
+ int err;
+
+ attr = kzalloc(sizeof(*attr), GFP_KERNEL);
+ if (!attr)
+ return -ENOMEM;
+
+ err = of_property_read_string(of_root, "model", &attr->machine);
+ if (err) {
+ pr_err("%s: missing model property: %d\n", __func__, err);
+ goto attr;
+ }
+
+ attr->family = kasprintf(GFP_KERNEL, "Freescale i.MX");
+
+ /*
+ * Retrieve the soc id, rev & uid info:
+ * res.a1[31:16]: soc revision;
+ * res.a1[15:0]: soc id;
+ * res.a2: uid[127:64];
+ * res.a3: uid[63:0];
+ */
+ arm_smccc_smc(IMX_SIP_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res);
+ if (res.a0 != SMCCC_RET_SUCCESS) {
+ pr_err("%s: SMC failed: %d\n", __func__, res.a0);
+ err = res.a0;
+ goto family;
+ }
+
+ soc_id = SOC_ID(res.a1);
+ rev_major = SOC_REV_MAJOR(res.a1);
+ rev_minor = SOC_REV_MINOR(res.a1);
+
+ attr->soc_id = kasprintf(GFP_KERNEL, "i.MX%2x", soc_id);
+ attr->revision = kasprintf(GFP_KERNEL, "%d.%d", rev_major, rev_minor);
+
+ uid127_64 = res.a2;
+ uid63_0 = res.a3;
+ attr->serial_number = kasprintf(GFP_KERNEL, "%016llx%016llx", uid127_64, uid63_0);
+
+ sdev = soc_device_register(attr);
+ if (IS_ERR(sdev)) {
+ err = PTR_ERR(sdev);
+ goto soc_id;
+ }
+
+ return 0;
+
+soc_id:
+ kfree(attr->soc_id);
+ kfree(attr->serial_number);
+ kfree(attr->revision);
+family:
+ kfree(attr->family);
+attr:
+ kfree(attr);
+ return err;
+}
+
+static int __init imx9_soc_init(void)
+{
+ int ret = 0;
+
+ if (of_machine_is_compatible("fsl,imx91") ||
+ of_machine_is_compatible("fsl,imx93") ||
+ of_machine_is_compatible("fsl,imx95")) {
+ ret = imx9_soc_device_register();
+ if (ret) {
+ pr_err("%s failed to register SoC as a device: %d\n", __func__, ret);
+ return ret;
+ }
+ }
+
+ return ret;
+}
+device_initcall(imx9_soc_init);
+
+MODULE_AUTHOR("NXP");
+MODULE_DESCRIPTION("NXP i.MX9 SoC");
+MODULE_LICENSE("GPL");
--
2.34.1
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on shawnguo/for-next]
[also build test WARNING on linus/master v6.12-rc5 next-20241029]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/alice-guo-oss-nxp-com/soc-imx-Add-SoC-device-register-for-i-MX9/20241029-163718
base: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next
patch link: https://lore.kernel.org/r/20241029083406.3888861-1-alice.guo%40oss.nxp.com
patch subject: [PATCH v2] soc: imx: Add SoC device register for i.MX9
config: i386-buildonly-randconfig-003-20241029 (https://download.01.org/0day-ci/archive/20241030/202410300140.9q3lC7M2-lkp@intel.com/config)
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241030/202410300140.9q3lC7M2-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410300140.9q3lC7M2-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/soc/imx/soc-imx9.c:48:44: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
48 | pr_err("%s: SMC failed: %d\n", __func__, res.a0);
| ~~ ^~~~~~
| %lu
include/linux/printk.h:533:33: note: expanded from macro 'pr_err'
533 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:490:60: note: expanded from macro 'printk'
490 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:462:19: note: expanded from macro 'printk_index_wrap'
462 | _p_func(_fmt, ##__VA_ARGS__); \
| ~~~~ ^~~~~~~~~~~
1 warning generated.
vim +48 drivers/soc/imx/soc-imx9.c
17
18 static int imx9_soc_device_register(void)
19 {
20 struct soc_device_attribute *attr;
21 struct arm_smccc_res res;
22 struct soc_device *sdev;
23 u32 soc_id, rev_major, rev_minor;
24 u64 uid127_64, uid63_0;
25 int err;
26
27 attr = kzalloc(sizeof(*attr), GFP_KERNEL);
28 if (!attr)
29 return -ENOMEM;
30
31 err = of_property_read_string(of_root, "model", &attr->machine);
32 if (err) {
33 pr_err("%s: missing model property: %d\n", __func__, err);
34 goto attr;
35 }
36
37 attr->family = kasprintf(GFP_KERNEL, "Freescale i.MX");
38
39 /*
40 * Retrieve the soc id, rev & uid info:
41 * res.a1[31:16]: soc revision;
42 * res.a1[15:0]: soc id;
43 * res.a2: uid[127:64];
44 * res.a3: uid[63:0];
45 */
46 arm_smccc_smc(IMX_SIP_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res);
47 if (res.a0 != SMCCC_RET_SUCCESS) {
> 48 pr_err("%s: SMC failed: %d\n", __func__, res.a0);
49 err = res.a0;
50 goto family;
51 }
52
53 soc_id = SOC_ID(res.a1);
54 rev_major = SOC_REV_MAJOR(res.a1);
55 rev_minor = SOC_REV_MINOR(res.a1);
56
57 attr->soc_id = kasprintf(GFP_KERNEL, "i.MX%2x", soc_id);
58 attr->revision = kasprintf(GFP_KERNEL, "%d.%d", rev_major, rev_minor);
59
60 uid127_64 = res.a2;
61 uid63_0 = res.a3;
62 attr->serial_number = kasprintf(GFP_KERNEL, "%016llx%016llx", uid127_64, uid63_0);
63
64 sdev = soc_device_register(attr);
65 if (IS_ERR(sdev)) {
66 err = PTR_ERR(sdev);
67 goto soc_id;
68 }
69
70 return 0;
71
72 soc_id:
73 kfree(attr->soc_id);
74 kfree(attr->serial_number);
75 kfree(attr->revision);
76 family:
77 kfree(attr->family);
78 attr:
79 kfree(attr);
80 return err;
81 }
82
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on shawnguo/for-next]
[also build test WARNING on linus/master v6.12-rc5 next-20241029]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/alice-guo-oss-nxp-com/soc-imx-Add-SoC-device-register-for-i-MX9/20241029-163718
base: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next
patch link: https://lore.kernel.org/r/20241029083406.3888861-1-alice.guo%40oss.nxp.com
patch subject: [PATCH v2] soc: imx: Add SoC device register for i.MX9
config: arm-randconfig-002-20241029 (https://download.01.org/0day-ci/archive/20241030/202410300019.uWGJaR4m-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241030/202410300019.uWGJaR4m-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410300019.uWGJaR4m-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/asm-generic/bug.h:22,
from arch/arm/include/asm/bug.h:60,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/preempt.h:5,
from ./arch/arm/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:79,
from include/linux/spinlock.h:56,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/umh.h:4,
from include/linux/kmod.h:9,
from include/linux/module.h:17,
from drivers/soc/imx/soc-imx9.c:8:
drivers/soc/imx/soc-imx9.c: In function 'imx9_soc_device_register':
>> include/linux/kern_levels.h:5:25: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/printk.h:462:25: note: in definition of macro 'printk_index_wrap'
462 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
include/linux/printk.h:533:9: note: in expansion of macro 'printk'
533 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
include/linux/printk.h:533:16: note: in expansion of macro 'KERN_ERR'
533 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
drivers/soc/imx/soc-imx9.c:48:17: note: in expansion of macro 'pr_err'
48 | pr_err("%s: SMC failed: %d\n", __func__, res.a0);
| ^~~~~~
vim +5 include/linux/kern_levels.h
314ba3520e513a7 Joe Perches 2012-07-30 4
04d2c8c83d0e3ac Joe Perches 2012-07-30 @5 #define KERN_SOH "\001" /* ASCII Start Of Header */
04d2c8c83d0e3ac Joe Perches 2012-07-30 6 #define KERN_SOH_ASCII '\001'
04d2c8c83d0e3ac Joe Perches 2012-07-30 7
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Alice,
Am Dienstag, 29. Oktober 2024, 09:34:06 CET schrieb alice.guo@oss.nxp.com:
> From: "alice.guo" <alice.guo@nxp.com>
>
> i.MX9 SoCs have SoC ID, SoC revision number and chip unique identifier
> which are provided by the corresponding ARM trusted firmware API. This
> patch intends to use SMC call to obtain these information and then
> register i.MX9 SoC as a device.
>
> Signed-off-by: alice.guo <alice.guo@nxp.com>
> ---
>
> Changes for v2:
> - refine error log print
>
> drivers/soc/imx/Makefile | 2 +-
> drivers/soc/imx/soc-imx9.c | 103 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 104 insertions(+), 1 deletion(-)
> create mode 100644 drivers/soc/imx/soc-imx9.c
>
> diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile
> index 3ad321ca608a..ca6a5fa1618f 100644
> --- a/drivers/soc/imx/Makefile
> +++ b/drivers/soc/imx/Makefile
> @@ -3,4 +3,4 @@ ifeq ($(CONFIG_ARM),y)
> obj-$(CONFIG_ARCH_MXC) += soc-imx.o
> endif
> obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
> -obj-$(CONFIG_SOC_IMX9) += imx93-src.o
> +obj-$(CONFIG_SOC_IMX9) += imx93-src.o soc-imx9.o
> diff --git a/drivers/soc/imx/soc-imx9.c b/drivers/soc/imx/soc-imx9.c
> new file mode 100644
> index 000000000000..0722e69110f9
> --- /dev/null
> +++ b/drivers/soc/imx/soc-imx9.c
> @@ -0,0 +1,103 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2024 NXP
> + */
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/slab.h>
> +#include <linux/sys_soc.h>
> +
> +#define IMX_SIP_GET_SOC_INFO 0xc2000006
> +#define SOC_ID(x) (((x) & 0xFFFF) >> 8)
> +#define SOC_REV_MAJOR(x) ((((x) >> 28) & 0xF) - 0x9)
> +#define SOC_REV_MINOR(x) (((x) >> 24) & 0xF)
> +
> +static int imx9_soc_device_register(void)
> +{
> + struct soc_device_attribute *attr;
> + struct arm_smccc_res res;
> + struct soc_device *sdev;
> + u32 soc_id, rev_major, rev_minor;
> + u64 uid127_64, uid63_0;
> + int err;
> +
> + attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> + if (!attr)
> + return -ENOMEM;
> +
> + err = of_property_read_string(of_root, "model", &attr->machine);
> + if (err) {
> + pr_err("%s: missing model property: %d\n", __func__, err);
> + goto attr;
> + }
> +
> + attr->family = kasprintf(GFP_KERNEL, "Freescale i.MX");
> +
> + /*
> + * Retrieve the soc id, rev & uid info:
> + * res.a1[31:16]: soc revision;
> + * res.a1[15:0]: soc id;
> + * res.a2: uid[127:64];
> + * res.a3: uid[63:0];
> + */
> + arm_smccc_smc(IMX_SIP_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res);
> + if (res.a0 != SMCCC_RET_SUCCESS) {
> + pr_err("%s: SMC failed: %d\n", __func__, res.a0);
> + err = res.a0;
> + goto family;
> + }
> +
> + soc_id = SOC_ID(res.a1);
> + rev_major = SOC_REV_MAJOR(res.a1);
> + rev_minor = SOC_REV_MINOR(res.a1);
> +
> + attr->soc_id = kasprintf(GFP_KERNEL, "i.MX%2x", soc_id);
> + attr->revision = kasprintf(GFP_KERNEL, "%d.%d", rev_major, rev_minor);
> +
> + uid127_64 = res.a2;
> + uid63_0 = res.a3;
> + attr->serial_number = kasprintf(GFP_KERNEL, "%016llx%016llx", uid127_64, uid63_0);
> +
> + sdev = soc_device_register(attr);
> + if (IS_ERR(sdev)) {
> + err = PTR_ERR(sdev);
> + goto soc_id;
> + }
> +
> + return 0;
> +
> +soc_id:
> + kfree(attr->soc_id);
> + kfree(attr->serial_number);
> + kfree(attr->revision);
Please free the memory in the reverse order of allocation.
Thanks
Alexander
> +family:
> + kfree(attr->family);
> +attr:
> + kfree(attr);
> + return err;
> +}
> +
> +static int __init imx9_soc_init(void)
> +{
> + int ret = 0;
> +
> + if (of_machine_is_compatible("fsl,imx91") ||
> + of_machine_is_compatible("fsl,imx93") ||
> + of_machine_is_compatible("fsl,imx95")) {
> + ret = imx9_soc_device_register();
> + if (ret) {
> + pr_err("%s failed to register SoC as a device: %d\n", __func__, ret);
> + return ret;
> + }
> + }
> +
> + return ret;
> +}
> +device_initcall(imx9_soc_init);
> +
> +MODULE_AUTHOR("NXP");
> +MODULE_DESCRIPTION("NXP i.MX9 SoC");
> +MODULE_LICENSE("GPL");
>
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
Hi Alice,
Am 29.10.24 um 09:34 schrieb alice.guo@oss.nxp.com:
> From: "alice.guo" <alice.guo@nxp.com>
>
> i.MX9 SoCs have SoC ID, SoC revision number and chip unique identifier
> which are provided by the corresponding ARM trusted firmware API. This
> patch intends to use SMC call to obtain these information and then
> register i.MX9 SoC as a device.
>
> Signed-off-by: alice.guo <alice.guo@nxp.com>
> ---
>
> Changes for v2:
> - refine error log print
>
> drivers/soc/imx/Makefile | 2 +-
> drivers/soc/imx/soc-imx9.c | 103 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 104 insertions(+), 1 deletion(-)
> create mode 100644 drivers/soc/imx/soc-imx9.c
>
> diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile
> index 3ad321ca608a..ca6a5fa1618f 100644
> --- a/drivers/soc/imx/Makefile
> +++ b/drivers/soc/imx/Makefile
> @@ -3,4 +3,4 @@ ifeq ($(CONFIG_ARM),y)
> obj-$(CONFIG_ARCH_MXC) += soc-imx.o
> endif
> obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
> -obj-$(CONFIG_SOC_IMX9) += imx93-src.o
> +obj-$(CONFIG_SOC_IMX9) += imx93-src.o soc-imx9.o
> diff --git a/drivers/soc/imx/soc-imx9.c b/drivers/soc/imx/soc-imx9.c
> new file mode 100644
> index 000000000000..0722e69110f9
> --- /dev/null
> +++ b/drivers/soc/imx/soc-imx9.c
> @@ -0,0 +1,103 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2024 NXP
> + */
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/slab.h>
> +#include <linux/sys_soc.h>
> +
> +#define IMX_SIP_GET_SOC_INFO 0xc2000006
> +#define SOC_ID(x) (((x) & 0xFFFF) >> 8)
> +#define SOC_REV_MAJOR(x) ((((x) >> 28) & 0xF) - 0x9)
> +#define SOC_REV_MINOR(x) (((x) >> 24) & 0xF)
> +
> +static int imx9_soc_device_register(void)
> +{
> + struct soc_device_attribute *attr;
> + struct arm_smccc_res res;
> + struct soc_device *sdev;
> + u32 soc_id, rev_major, rev_minor;
> + u64 uid127_64, uid63_0;
> + int err;
> +
> + attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> + if (!attr)
> + return -ENOMEM;
> +
> + err = of_property_read_string(of_root, "model", &attr->machine);
> + if (err) {
> + pr_err("%s: missing model property: %d\n", __func__, err);
> + goto attr;
> + }
> +
> + attr->family = kasprintf(GFP_KERNEL, "Freescale i.MX");
> +
> + /*
> + * Retrieve the soc id, rev & uid info:
> + * res.a1[31:16]: soc revision;
> + * res.a1[15:0]: soc id;
> + * res.a2: uid[127:64];
> + * res.a3: uid[63:0];
> + */
> + arm_smccc_smc(IMX_SIP_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res);
> + if (res.a0 != SMCCC_RET_SUCCESS) {
> + pr_err("%s: SMC failed: %d\n", __func__, res.a0);
> + err = res.a0;
The pr_err() looks good to me. But in this specific case, I would stick
with assigning -EINVAL to err, because the SMCCC_RET.. codes are
completely different from Linux. I wasn't clear about that in my last
comment.
> + goto family;
> + }
> +
> + soc_id = SOC_ID(res.a1);
> + rev_major = SOC_REV_MAJOR(res.a1);
> + rev_minor = SOC_REV_MINOR(res.a1);
> +
> + attr->soc_id = kasprintf(GFP_KERNEL, "i.MX%2x", soc_id);
> + attr->revision = kasprintf(GFP_KERNEL, "%d.%d", rev_major, rev_minor);
> +
> + uid127_64 = res.a2;
> + uid63_0 = res.a3;
> + attr->serial_number = kasprintf(GFP_KERNEL, "%016llx%016llx", uid127_64, uid63_0);
> +
> + sdev = soc_device_register(attr);
> + if (IS_ERR(sdev)) {
> + err = PTR_ERR(sdev);
pr_err("%s: failed to register SoC as a device: %d\n", __func__, err);
After that we can drop the pr_err() in imx9_soc_init() and avoid
unnecessary error logs.
> + goto soc_id;
> + }
> +
> + return 0;
> +
> +soc_id:
> + kfree(attr->soc_id);
> + kfree(attr->serial_number);
> + kfree(attr->revision);
> +family:
> + kfree(attr->family);
> +attr:
> + kfree(attr);
> + return err;
> +}
> +
> +static int __init imx9_soc_init(void)
> +{
> + int ret = 0;
> +
> + if (of_machine_is_compatible("fsl,imx91") ||
> + of_machine_is_compatible("fsl,imx93") ||
> + of_machine_is_compatible("fsl,imx95")) {
> + ret = imx9_soc_device_register();
> + if (ret) {
> + pr_err("%s failed to register SoC as a device: %d\n", __func__, ret);
> + return ret;
> + }
After dropping the pr_err we can get the rid of the complete condition
for ret.
Thanks
> + }
> +
> + return ret;
> +}
> +device_initcall(imx9_soc_init);
> +
> +MODULE_AUTHOR("NXP");
> +MODULE_DESCRIPTION("NXP i.MX9 SoC");
> +MODULE_LICENSE("GPL");
© 2016 - 2026 Red Hat, Inc.