From patchwork Mon Oct 10 13:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Frayer X-Patchwork-Id: 13002580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F904C433F5 for ; Mon, 10 Oct 2022 13:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kXpL8IT597Ke9FzBwKCV7oJ4R5vhwNp0Q5MqauKzsp4=; b=RYRfV1ZM9rHOLS skvga48p8IFYJcjiL0eJVULl5NiYZQtFqC3J14JZXqHEFn9RDrD3rN5v23vwRMRAKIMpeRHpY6UF8 StGD9ZqFU/ZL5Vz/P72lU5Y4UBB+5/WYaT8cIIZcX8ej/G06bFcfUiFC7ddkQJpC5m7Bwa4r+uWkJ IsBtSkRRf540IDHja8kBDhoTs4WzZm9y2Z5yNwS6WNfP+kOp4DT8BYeRd1sEvdLhitGtr9bZ9XNN9 UV2Ev6YvLUjN3znJ3SlM3zNUGG6ik/QN0h6qtR1l2BkcItKbKOgS/MUJHSNCVgxnvpOTXvY4gKPNE to+PIfJMzAIc9e/kaLCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohsdg-000zLM-VK; Mon, 10 Oct 2022 13:16:13 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohsdP-000zGH-OB for linux-arm-kernel@lists.infradead.org; Mon, 10 Oct 2022 13:15:57 +0000 Received: by mail-wm1-x332.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so335271wmq.4 for ; Mon, 10 Oct 2022 06:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qLxER1Bc4Cb8rJkHZ6/zcim8Vi82bUeWN4IV0cotQO4=; b=xHYPcrMNOxzhcqJjflVJH71h6IDjKfO/hImGeC53aP3OTfE1yOfTu6WMB4ifJfM2pn yEjfQJNwNG1pKrd/fxc4z8HET4c+dCCWEMbNofpQCaIhluX6z6whFfgUy/XDu8xtiYhZ IT85WNb6smH9LT6lUHM83EFeVR1ykXEoCCPrTPXERUPAJLcjiSWJq5RhcPJLOjVGjmCO QAElA98f9mS5uNbBsevTAmHkbrrOu6u28wADLkQ+g1HHpc2nGkd6R9ruHc07t6+pnYk2 VcwtUxcVvgCm+PO/Ct3VATHEpSsP6hCDb/r17yYvmzvSo77Zo3lr2gJg+ek+elydF/m/ XHdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qLxER1Bc4Cb8rJkHZ6/zcim8Vi82bUeWN4IV0cotQO4=; b=U4JE/vC1E/VOfilbiNilKdc5UO10ZNrVayA1r1hAyYnv/+nSeOFTnaJ60vaAvHjIac PvG/39VwFOeX3DfpOdWm2lqjDvOlDw2/Q9fhOtxV9CwPDIuTj9L/ZZHyiMQ1gl9j/t9n uaZPHRoLSEGEHp2zjlpAjo09Bv1noqJGcQVz8+eYL/udg+7f7pKRtu0TWUG+D4AxCYMG 7ZiobaSoRSN5rY3Qb3TOY8qbhwGUPCrePbzZOh5Gc6LLX2VFaY+BaUYbRjOTF/O6dCjU wiDaZx4AFkZBD31N3QxxA7dhNVkTjWhM5eW5vpmfGEzYUhtf5UYXmAHnx2qtAqhNVOmi oGdA== X-Gm-Message-State: ACrzQf1TUJccHId2E/EVYFAzbSSHevXoCsT1vMRHUcTD23O77FgbpNsX eaPeEeNpKKJyau4nwyZ+c88IBg== X-Google-Smtp-Source: AMsMyM7qWrCfoqDWIHvXcTAFcGH8yWUDEQyCCXS00fM5oi2JuREBmmTO6ZTLyc1qJZ2hhrTWlOBluw== X-Received: by 2002:a05:600c:b4e:b0:3c5:c61c:8e20 with SMTP id k14-20020a05600c0b4e00b003c5c61c8e20mr5225361wmr.103.1665407753867; Mon, 10 Oct 2022 06:15:53 -0700 (PDT) Received: from nicolas-Precision-3551.home ([2001:861:5180:dcc0:f62:307f:b07a:ff0e]) by smtp.gmail.com with ESMTPSA id a8-20020a1cf008000000b003a6a3595edasm9930780wmb.27.2022.10.10.06.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 06:15:53 -0700 (PDT) From: Nicolas Frayer To: nm@ti.com, ssantosh@kernel.org Cc: linux-arm-kernel@lists.infradead.org, khilman@baylibre.com, glaroque@baylibre.com, granquet@baylibre.com, Nicolas Frayer Subject: [PATCH v2 1/2] soc: ti: Convert allocations to devm Date: Mon, 10 Oct 2022 15:15:37 +0200 Message-Id: <20221010131538.7333-2-nfrayer@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221010131538.7333-1-nfrayer@baylibre.com> References: <20221010131538.7333-1-nfrayer@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221010_061555_811861_D4503770 X-CRM114-Status: GOOD ( 16.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Changed the memory and resource allocations in the probe function to devm. Also added a remove callback. Signed-off-by: Nicolas Frayer --- drivers/soc/ti/k3-socinfo.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c index e6047b23a86f..3311797145ed 100644 --- a/drivers/soc/ti/k3-socinfo.c +++ b/drivers/soc/ti/k3-socinfo.c @@ -97,21 +97,18 @@ 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(sizeof(*soc_dev_attr), GFP_KERNEL); + soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM; - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", variant); - if (!soc_dev_attr->revision) { - ret = -ENOMEM; - goto err; - } + soc_dev_attr->revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "SR%x.0", variant); + if (!soc_dev_attr->revision) + return -ENOMEM; ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr); if (ret) { dev_err(dev, "Unknown SoC JTAGID[0x%08X]\n", jtag_id); - ret = -ENODEV; - goto err_free_rev; + return -ENODEV; } node = of_find_node_by_path("/"); @@ -119,22 +116,26 @@ 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); + + platform_set_drvdata(pdev, soc_dev); dev_info(dev, "Family:%s rev:%s JTAGID[0x%08x] Detected\n", soc_dev_attr->family, soc_dev_attr->revision, jtag_id); return 0; +} + +static int k3_chipinfo_remove(struct platform_device *pdev) +{ + struct soc_device *soc_dev = platform_get_drvdata(pdev); -err_free_rev: - kfree(soc_dev_attr->revision); -err: - kfree(soc_dev_attr); - return ret; + if (soc_dev != NULL) + soc_device_unregister(soc_dev); + + return 0; } static const struct of_device_id k3_chipinfo_of_match[] = { @@ -148,6 +149,7 @@ static struct platform_driver k3_chipinfo_driver = { .of_match_table = k3_chipinfo_of_match, }, .probe = k3_chipinfo_probe, + .remove = k3_chipinfo_remove, }; static int __init k3_chipinfo_init(void)