Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4215142ybg; Fri, 25 Oct 2019 15:14:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCTkLQyN1DysXKcykscKLQ4yjayl1srweQ2MSU8DNv0ATHV32xplVU+Axn9uH7rWEX/9bk X-Received: by 2002:aa7:cc18:: with SMTP id q24mr6519130edt.150.1572041661873; Fri, 25 Oct 2019 15:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572041661; cv=none; d=google.com; s=arc-20160816; b=kRJ5Tna4u3vD/PmoIARxMosXXk9FP52tHUoczN00Q2kDJ2bfPb3Rc7z2iPWWrmUst0 /xxJr6rKWjtC/KwsE4qWH8N/G8t6xbb2w9yzt9hkDA/nhyI9zXPcnFc6z13adqRdEsLU MOdDTC5+Wbnae7zVK7gyXFX7UsZdICUXz2m6fRt+8a9yRYCo8iOG+znxPg/xFmC9DSp6 vn4g5j9ykYRSiQdCIvOScXnHk/PTyNSFO8/BLVLMTBLE0rDgffvRBM8PzkKSB+ReJBL7 FDQcq989F0+meJ+pK1HRFwJoI32v3kqI5k8ReC0DRHBx8tyccKdgGPdgVw1GNslo4q09 EtRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=U4hO9uBvlU4QEyO5iATTMNJQpZJOaOt0G7UtwKa+MWI=; b=0DGRSm9nchAmlWFOkHckFwlCbd0T8UqTmBW1v0/uoIPIX5R44r0XpFjQcJXzRKdxwj x7LSVURHBvNmDsrCE8USrW0O3JYRZ7E1n8l+KoyCaWrziCofhHNUCkm1f9sFhKXRhei5 K2m9mxrCPhjUrV1uTB0DdSMBPOwg7gHrOm4cHmucekzqkhipxDOz3a7KFSezbfFMNCDU QF5taPbFUR0D8DB+ydk6SAFlHgT2GxioJ4WdkHnVtgcdh+NhShTeBTlPoR/dICQwIH20 xUZAuBc5QdBmiloi5TozVMzAzWWHeqNARyHBP6jBRWxZE8k/KpwE2S/ZjnokYEaJ/r/C 1LIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si2076039ejj.334.2019.10.25.15.13.55; Fri, 25 Oct 2019 15:14:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405805AbfJYG7h (ORCPT + 99 others); Fri, 25 Oct 2019 02:59:37 -0400 Received: from inva020.nxp.com ([92.121.34.13]:56786 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405710AbfJYG7g (ORCPT ); Fri, 25 Oct 2019 02:59:36 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 82D751A0409; Fri, 25 Oct 2019 08:59:34 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3797E1A0221; Fri, 25 Oct 2019 08:59:29 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 720F5402DA; Fri, 25 Oct 2019 14:59:22 +0800 (SGT) From: Anson Huang To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, daniel.baluta@nxp.com, aisheng.dong@nxp.com, abel.vesa@nxp.com, leonard.crestez@nxp.com, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH 2/2] soc: imx-scu: Using existing serial_number instead of UID Date: Fri, 25 Oct 2019 14:56:23 +0800 Message-Id: <1571986583-21138-2-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571986583-21138-1-git-send-email-Anson.Huang@nxp.com> References: <1571986583-21138-1-git-send-email-Anson.Huang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The soc_device_attribute structure already contains a serial_number attribute to show SoC's unique ID, just use it to show SoC's unique ID instead of creating a new file called soc_uid. Signed-off-by: Anson Huang --- drivers/soc/imx/soc-imx-scu.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/soc/imx/soc-imx-scu.c b/drivers/soc/imx/soc-imx-scu.c index c68882e..fb70b8a 100644 --- a/drivers/soc/imx/soc-imx-scu.c +++ b/drivers/soc/imx/soc-imx-scu.c @@ -33,12 +33,10 @@ struct imx_sc_msg_misc_get_soc_uid { u32 uid_high; } __packed; -static ssize_t soc_uid_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int imx_scu_soc_uid(u64 *soc_uid) { struct imx_sc_msg_misc_get_soc_uid msg; struct imx_sc_rpc_msg *hdr = &msg.hdr; - u64 soc_uid; int ret; hdr->ver = IMX_SC_RPC_VERSION; @@ -52,15 +50,13 @@ static ssize_t soc_uid_show(struct device *dev, return ret; } - soc_uid = msg.uid_high; - soc_uid <<= 32; - soc_uid |= msg.uid_low; + *soc_uid = msg.uid_high; + *soc_uid <<= 32; + *soc_uid |= msg.uid_low; - return sprintf(buf, "%016llX\n", soc_uid); + return 0; } -static DEVICE_ATTR_RO(soc_uid); - static int imx_scu_soc_id(void) { struct imx_sc_msg_misc_get_soc_id msg; @@ -89,6 +85,7 @@ static int imx_scu_soc_probe(struct platform_device *pdev) struct soc_device_attribute *soc_dev_attr; struct soc_device *soc_dev; int id, ret; + u64 uid = 0; u32 val; ret = imx_scu_get_handle(&soc_ipc_handle); @@ -112,6 +109,10 @@ static int imx_scu_soc_probe(struct platform_device *pdev) if (id < 0) return -EINVAL; + ret = imx_scu_soc_uid(&uid); + if (ret < 0) + return -EINVAL; + /* format soc_id value passed from SCU firmware */ val = id & 0x1f; soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "0x%x", val); @@ -130,19 +131,22 @@ static int imx_scu_soc_probe(struct platform_device *pdev) goto free_soc_id; } + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", uid); + if (!soc_dev_attr->serial_number) { + ret = -ENOMEM; + goto free_revision; + } + soc_dev = soc_device_register(soc_dev_attr); if (IS_ERR(soc_dev)) { ret = PTR_ERR(soc_dev); - goto free_revision; + goto free_serial_number; } - ret = device_create_file(soc_device_to_device(soc_dev), - &dev_attr_soc_uid); - if (ret) - goto free_revision; - return 0; +free_serial_number: + kfree(soc_dev_attr->serial_number); free_revision: kfree(soc_dev_attr->revision); free_soc_id: -- 2.7.4