Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2396955rdg; Mon, 16 Oct 2023 03:16:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnRIONWQchkStAW1dVsNLR5DV/+vwULwum9OswW8x1MRJC7ksFQ+ob6z6vlnhG7GSfUH6y X-Received: by 2002:a05:6a00:1886:b0:68f:f38d:f76c with SMTP id x6-20020a056a00188600b0068ff38df76cmr33895716pfh.6.1697451370352; Mon, 16 Oct 2023 03:16:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697451370; cv=pass; d=google.com; s=arc-20160816; b=pjSHwHjaZniHQhKpaOmQ9Dky/94YXBiBhsCheBfU8+RzMOpeS/2FfW/O30p2R8zj6X I1C6VT6VnfVqGdsUzxjek9qzOB1KYKnH4kdetB46vblWumHqQXcTfALSUTYJw3W71bK5 44ZhklMNiacN0MdUe9eTeMxB0ZR9sUGVKAM5nqkdEgRZ97HFrVqZFvpkqZ+J2TMfhs6u gWdx3UzjpeB8SUsNyKlGorlbxy4tePQ/JlXd7d+RvcYkisHuSl2Z1qmF3LF8zwgb37BF 9WIwxyhDjnoucoKRK4bKp1GAL1iLYqokyYDj6/vSS6KMGyRbgontXc6ttqW6owYbgxMg XT8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wHnqTB/I/hBTi1klkL4hU/OmFUiU9wc9yjCWyXOOe8c=; fh=WbbGAqTwxxTqGDtZLSrOYDkqRNeOYHUFpJWT8dEgneI=; b=E05p9pSLRR78Wz109wSaNLvYKKgRJkuOS4DVx2EmoDDtXnOhTyKd0eiqw1rWVG0mlE kNm+aUtHn1B9oOnuhiqLZf1104zeqbfo/Q8OQqe5nIQloCiJn04pgV4YZ738RDzCxz3g T0qqOz9y+JfIYX+6QdvBM1JuT2ws5o1ykgynI08KtWvyilH/nJsZ5DsRU7T/TFkA74q0 lMfxhpPIJ1MBPFJsDrQ9gFusVbtwy1/QGm17/X5coW39I631hd22cmR8i4jxh1C/upKV /Xa0sN6x8295G73nSJzMCE1EPXL+7I1O2lmCVpy9k83htNHeHFKcSGhchgijNpi3FKuG LfQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Q0KCnjBj; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j3-20020a056a00130300b006bd0842622asi2369184pfu.239.2023.10.16.03.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 03:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Q0KCnjBj; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E49BE8051A81; Mon, 16 Oct 2023 03:16:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233343AbjJPKP5 (ORCPT + 99 others); Mon, 16 Oct 2023 06:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233064AbjJPKPl (ORCPT ); Mon, 16 Oct 2023 06:15:41 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2044.outbound.protection.outlook.com [40.107.92.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6374B109; Mon, 16 Oct 2023 03:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foYmv0pVzymGenQmeCJ2M7Y9BlLVVhsn04awBQoVViJZlUujE5jVzZc4uiFrilSO5l5V1q49TRnqIy5UAVg04XI5Ysh47ZVOvj+u+vPU4xgcE2Py0bQGpS9OgPOZ2jYofuAlr7BVINdz8AX3zU0r5WfOm8K4BONjVcmCt549kh1OmLDEWoqmOPEimrem8WzJ59wMqY9pH0uJmSe0PLV7AuXDWwfRXP2pHPDw6TzlNBLKbAxWr4cYBYJ+xmq+zjMFH1YXB/j9TMbVazcO0G5PCDVnTmVpy8SG4uM1GG/f5xTsS9Eov8EwDTcnSNv2zpBmyEMLfb8WO9DG3d4Jx4HA2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wHnqTB/I/hBTi1klkL4hU/OmFUiU9wc9yjCWyXOOe8c=; b=Jo6YVWh24Czukgvo1w7wMHq/vCMzi57nfaDIQQlT3Nx3brZLsbQ0zdv2u1ZymJUoNuOCcWx0vbjkanqJhC6vn8yzkLH1N20sKMJBs2cv/U7GR4KyUye28QnCjQtpQY/+P90/bAOwf8qrL7Fx+OQs+xpIIQhqGeZQqCd2eEsotL3B2Y9TmHSc9FMw95ZRbs8X59p21puUE5ccEK8bBRPTcKz07/REDN31AA6fm3YMQosNFgCXm7nZLAg5jDQqTk4XVQi3udCfz9yA4bfo8nVCJeDpdQ//dUbyLKCPS2QhGdnyWl7yD7t24x2dvW5krixmrxhHbpHmvYnKa1PAYbbSng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wHnqTB/I/hBTi1klkL4hU/OmFUiU9wc9yjCWyXOOe8c=; b=Q0KCnjBjaWIYsP3gV6WZik7Xaw2efOFp5lC9IpdTpe+GO9+G32zLS0wkx2EXBpWwYMmmAgO5R2hWlE8xm+OXo0MoNoUwUlOYe/jPvnX9z5jvpHxrqL0fNJnvLVvZyU30oBkahm7Sx/ijYCoLOY+XLFbOKSOygaB4CKXXVAmOADWvj67stOqmiSHGk84I74JKb1uVi4CJzNSJg0Si9guUIml9WD3aS+6dBhBfdxYJ2AFL04Nm1mm9aS8EccnE68S3NPr0czhDh0wePGsx0KF3aCFvcuEeJuWY5laaxO94bJrD1FRT3MJPnLnInXo7BKH5Ae46WOmUHAyydD/+QveVhQ== Received: from DM6PR10CA0003.namprd10.prod.outlook.com (2603:10b6:5:60::16) by BL1PR12MB5078.namprd12.prod.outlook.com (2603:10b6:208:313::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Mon, 16 Oct 2023 10:15:31 +0000 Received: from DS3PEPF000099D5.namprd04.prod.outlook.com (2603:10b6:5:60:cafe::38) by DM6PR10CA0003.outlook.office365.com (2603:10b6:5:60::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36 via Frontend Transport; Mon, 16 Oct 2023 10:15:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099D5.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 10:15:31 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 16 Oct 2023 03:15:18 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 16 Oct 2023 03:15:17 -0700 Received: from localhost.localdomain (10.127.8.10) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 16 Oct 2023 03:15:12 -0700 From: Kartik To: , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 5/8] soc/tegra: fuse: Add function to add lookups Date: Mon, 16 Oct 2023 15:44:33 +0530 Message-ID: <20231016101436.7146-6-kkartik@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016101436.7146-1-kkartik@nvidia.com> References: <20231016101436.7146-1-kkartik@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D5:EE_|BL1PR12MB5078:EE_ X-MS-Office365-Filtering-Correlation-Id: b62457a4-14b7-4380-8e55-08dbce30d411 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mk0LP8BUIStzTxQ2wtmF3yyB/C5EOqvazvEOHseQ7JBPFt37IU4PoQo4BWxSHtph2TKHnt/MFE/iWT36/KEVKoqt9J5HDeuSLUybBoMCvAOrLoFuQGkbyqI4MnnHlY/omDCx5/CHqEUUh50v6YY71flzvxji457HK++wMBcHH2RFARpGDvU3EX/Y0mDnos8LfYhATF/FXBuXNVvP4eGfQsHmrMYxiweeFY0ews8BzsKxQVHk+WJy+Yx48wPzxtEvK29qD+RVpHX1S9dyLBSqtZkhzNE4mowiUOHqZINSZh8+Wls8kz+R/ruZf9xq2iXw17tS9BGOh5XY/T0b2/dO+t9rwPs9hFmBrTILKeFqKXcHH2JHNLwUapDI+oTyTUjYl5dOTF9vYlyN3IgxJ7BNE9qmsmEhWwwTgMqgh34NSNdbx/favm80gMtwwnbz/W9BucCqOWzU/IpgJ5Bw2wIzR+hJuLDcAQKqBOrh8mX5E2x8PDZBOJKR9TAfuq98lpdk966W50RKVOE0YI5iQCXknRAy70NVYlqrDSLqThaYNcKBVK1vnysKUzg5NFoZlcYOdQSaC1zFmirtXuBBpWlvYhn8/5fIl2iZFKsBeau7YU7hcLP2+Zi+dHKkxWkMXdlwautHCgwwFGqgDdqaqF7qn7xLGH7QxxO7alJyHyGwfvDIG053CmHgAsFt0VmzIl4a3XwVnuKfCiH4zc7mg0dvsazyCGUnipLJqu5mNWfKL2SvuhMnXr69vE/pQqgS9cxKmdDLbjpOwViHDCvzBYQSbB9+9O1W63Mi7DzF9V9k6uzDi9VrHZagHUzJ/2oE7oDZqyt37ty9+Sgld0kpZae7fg== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(1800799009)(186009)(64100799003)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(47076005)(478600001)(6666004)(70206006)(70586007)(316002)(110136005)(1076003)(26005)(2616005)(336012)(426003)(8676002)(8936002)(7416002)(2906002)(5660300002)(41300700001)(36756003)(7636003)(86362001)(921005)(356005)(36860700001)(83380400001)(82740400003)(40460700003)(40480700001)(334744004)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 10:15:31.3167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b62457a4-14b7-4380-8e55-08dbce30d411 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5078 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 03:16:08 -0700 (PDT) Add helper function tegra_fuse_add_lookups() to register Tegra fuse nvmem lookups. So, this can be shared between tegra_fuse_init() and ACPI probe, which is to be introduced later. Use kmemdup_array to duplicate fuse->soc->lookups. Signed-off-by: Kartik --- v3 -> v4: * Use kmemdup_array to duplicate fuse->soc->lookups. * Return err at the end of tegra_fuse_probe to remove redundant code. v1 -> v2: * Use size_mul to calculate lookups array size. --- drivers/soc/tegra/fuse/fuse-tegra.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c index 98805885158e..4ebb5597a77b 100644 --- a/drivers/soc/tegra/fuse/fuse-tegra.c +++ b/drivers/soc/tegra/fuse/fuse-tegra.c @@ -113,6 +113,18 @@ static void tegra_fuse_restore(void *base) fuse->clk = NULL; } +static int tegra_fuse_add_lookups(struct tegra_fuse *fuse) +{ + fuse->lookups = kmemdup_array(fuse->soc->lookups, sizeof(*fuse->lookups), + fuse->soc->num_lookups, GFP_KERNEL); + if (!fuse->lookups) + return -ENOMEM; + + nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups); + + return 0; +} + static int tegra_fuse_probe(struct platform_device *pdev) { void __iomem *base = fuse->base; @@ -398,6 +410,7 @@ static int __init tegra_init_fuse(void) const struct of_device_id *match; struct device_node *np; struct resource regs; + int err; tegra_init_apbmisc(); @@ -495,15 +508,11 @@ static int __init tegra_init_fuse(void) pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n", tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id); - if (fuse->soc->lookups) { - size_t size = sizeof(*fuse->lookups) * fuse->soc->num_lookups; + err = tegra_fuse_add_lookups(fuse); + if (err) + pr_err("failed to add FUSE lookups\n"); - fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL); - if (fuse->lookups) - nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups); - } - - return 0; + return err; } early_initcall(tegra_init_fuse); -- 2.34.1