From mboxrd@z Thu Jan 1 00:00:00 1970 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 A972DC433F5 for ; Mon, 3 Oct 2022 16:24:15 +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=Y3sKAdONOzdPqyPhHHaphOp7WRXEtZtfPPnE268jcCw=; b=rGDdx8A4S/MrQH a8IvbDZHM4E7q4OuIfgM0TctnMhFG3y4p25FFUn158QLq4x/W96ELUZc/rvB4Pna1Zh4SfcgViSuA zCluxSAdkKH5UmmUx+b2fGJkBcHMKyVb0M49gnlq7HgYS9XVnXmtgNNYw0XOEFO3dfXahMhiPn9Rx WeuJf11joB/MHbUcVQTyGu+XE5aAFgAFfQDJTogz7N/1HHuK4hvvStBA34nxxdWgOeZZ/wd61+rHG xeQEjt1iwDA3YH+AZU2UknWctP7q4q0BvmJALsbd02ktgl+tS2BmUcifcdJUzpa+qiVflxt51dG5s Pee7baQKyZUHadKw8PoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofODn-006jtv-GJ; Mon, 03 Oct 2022 16:23:11 +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 1ofODZ-006jkv-VA for linux-arm-kernel@lists.infradead.org; Mon, 03 Oct 2022 16:23:03 +0000 Received: by mail-wm1-x332.google.com with SMTP id d12-20020a05600c3acc00b003b4c12e47f3so6114727wms.4 for ; Mon, 03 Oct 2022 09:22:54 -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; bh=Vm4TpO3JY+1vWDls351l9UZb/Y7basVTL7Grm/yg+jM=; b=yYR6LKSmAZpSxokSxEbfYCHsJt0L9EhXrQz2BCR+OUUdNKgKcUYJXkJt3gQRYFBbUh 1EKFWtd2fZrgvpTKVE75r0Fw1GVXqB9HiC/3e+KebkzKnBghZcXI2vDP/ND83wu9Tc+2 BLKI7+VyEcUARtZHMuNGTDpq3WVsZhtPapZNl5fKyEGhdwa2W+xbkb9aMunbwWOVzoEa H7AFJXXywsYdp46zvP8hr0w3nSW3pcgfzkGFlh6vDRFeuoAxqAeAGb3qLebsEsRWwZZG KHCzZSSjwPpX9q0YItHtdfbof/wI9PbqKEKHz6LDjpJR3XA+kxIeZd3w1KrwRhcPfCkx Xgsg== 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; bh=Vm4TpO3JY+1vWDls351l9UZb/Y7basVTL7Grm/yg+jM=; b=aNTFYXS97tASVo8iNsvCuq1zQ6ZWdDe2Cd49tD/0vHsjFbv+hLY97v5bsdwl7On6c3 WLDqr9g8z/RkgsEH4es9eFOHTaDBekD2ENeCGQf5+8fL56TeCvOPdexQLg7iQoMbeT12 fPSh5fc0yZOcdhPd06fepYSgxUq1t3hPqZ7rdpXsyCc0hNZEo4tUFTiLk3h7obwj+Ezx ByEMERv5wycqhmazbIhlC4m7HtrbK3KNFD0Ksi/InbEyqQnDSZ3YEZUF61pp9MnjByBl 4DRIcTzsaS/UbmmMinPMd3gW4cq5KI88DjJlBTpSuEUV06HTCYT5SANv5p5PZ/GDP5Zi PD4g== X-Gm-Message-State: ACrzQf3YFscp1Rc52m46o7znOYdcPPORqI2tOda8IGr6zOYdfMgmidwv dcOU0smM7Uz3DXo+8HdYk5FJAw== X-Google-Smtp-Source: AMsMyM7iBQpmrvrPhRSQHqhIdExMihROfbTYBdhq2fnqtHZmsod8yYUp/QGRWTVKnv7pDHy/ZOOmHA== X-Received: by 2002:a05:600c:2043:b0:3b3:c84c:ca33 with SMTP id p3-20020a05600c204300b003b3c84cca33mr7388136wmg.15.1664814173612; Mon, 03 Oct 2022 09:22:53 -0700 (PDT) Received: from nicolas-Precision-3551.home ([2001:861:5180:dcc0:2304:5860:1e75:709c]) by smtp.gmail.com with ESMTPSA id w10-20020a05600c474a00b003b4ac05a8a4sm21926967wmo.27.2022.10.03.09.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 09:22: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 RESEND 1/2] soc: ti: Convert allocations to devm Date: Mon, 3 Oct 2022 18:22:36 +0200 Message-Id: <20221003162237.30451-2-nfrayer@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003162237.30451-1-nfrayer@baylibre.com> References: <20221003162237.30451-1-nfrayer@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221003_092258_030401_A4EE4803 X-CRM114-Status: GOOD ( 15.62 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 91f441ee6175..a29f5a23395f 100644 --- a/drivers/soc/ti/k3-socinfo.c +++ b/drivers/soc/ti/k3-socinfo.c @@ -96,21 +96,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("/"); @@ -118,22 +115,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[] = { @@ -147,6 +148,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) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel