From patchwork Thu Nov 17 09:54:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Frayer X-Patchwork-Id: 13046506 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 5903BC433FE for ; Thu, 17 Nov 2022 10:19:42 +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=8VW1inV2mttvFCIcNpiM667GTK88mP0uuy2bkwpji1w=; b=JaxLc+6TyqbKbX f8uWBX3JXfeqRnKqikiROfBeGYIBq70nuxFpovlmm399gKUFAm9BwQv3f9wSe9letCWz53SHVzHec aXbyDA0UdzWzREqffwxCyjHI2iLotipFFCGaDcszMWrXTuNZBcq0hE6I0vq2+QHwmDZZ9o+7tXLZH H4iW9YBNDWF7wWSJYud5DKr0iNdp/cAdfZ9vHDHIBPiUdVaUVLX74mL6TTWscPYpc88V8t+6APrKO pCNz66I0dYQ7KSjqFMcy2VjlAkTA96U7hAt1xX/lGASS75vwZTBObOy9xChB1Aq9T2hKAbbtK2PIb M49DZsWt6gkkfC6smpAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovbyQ-00CTzF-8A; Thu, 17 Nov 2022 10:18:23 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovbbN-00CIke-5x for linux-arm-kernel@lists.infradead.org; Thu, 17 Nov 2022 09:54:34 +0000 Received: by mail-wr1-x42c.google.com with SMTP id w14so2866563wru.8 for ; Thu, 17 Nov 2022 01:54:29 -0800 (PST) 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=1o2x75QMXnEx7W9bo3sYlpr0oxVXvlHN3ieGl1S2FPc=; b=F2sxDaqNmyRFU3z4S0Onk+bOJP0mQcW/5PONPT8SXUJziEIvIo/1FwHHO266M0witV ZIFDxUV1eikIhGo9ZFkzd20h8+WtXuGnEJy6mulsQkRanw4LYXkuWlIFJVVwbJ7m6job rTy8mAbNoqlqhz0GudToFxJL5w97RH56WUrfTNItIIMzKamn2Qwee972p2Ou1uzWG8F2 eHVUL6mFW7uBV78aAIyZq58qk8rHKMXpRA+sEne3sEs7lHEFLYVWLxePOqy/6ZcMg1ha DfwDX/SWL7qboeqAHfvN7bhyE2lo4pk8iQa5e8nkwvkXDCWJagqjI1f+VY+owbjgyn/0 2JCg== 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=1o2x75QMXnEx7W9bo3sYlpr0oxVXvlHN3ieGl1S2FPc=; b=XgYKIMxLo1PcYSh+LAkWC6hx2LWs0RsAXlErmT3NosbiCgynwF620zGn+R4J9wsNnv Pu9O0FAcD/C6fJH0RtNOQqXbUz5Ni2PRFqmxFWzJwruFM8b9zy3sb9RHB7wqJyvXG9Iz YjRNXySbz9QV8S5GGj5GnACK4lkRLpWaCTOEmViKxPYcqZ4puqdegjdDSlj5BJKMX4Kt nWaX2qdufeJP9GyZrCRPn89PX9p+3k11uea7VdR+WLQvxVRsWh9+M1IAY+eNLglsz0wb Tol1mmlA0YoQ284iy2nDjlChfYYFqvIm4VAi/TQ1yS5PS9aew7hOsLfcF5rjLU0K0S+7 L+lQ== X-Gm-Message-State: ANoB5pnIykn9bgLgAMYuqXR+UxzlBovP1mXshQ51NejN4+KIT4e+hGUf 9BBH3uSVryI3kZV6m9csyf7k+A== X-Google-Smtp-Source: AA0mqf6DQq9HKMbJVhBHzcujBbtwoXJUJKNe0Bf2Bb0RioItGpEc2WaOe6H3EboIddDlE1YESX6pTQ== X-Received: by 2002:a5d:58c7:0:b0:236:60f3:d28f with SMTP id o7-20020a5d58c7000000b0023660f3d28fmr976253wrf.454.1668678867980; Thu, 17 Nov 2022 01:54:27 -0800 (PST) Received: from nicolas-Precision-3551.home ([2001:861:5180:dcc0:9287:74a3:4740:e7a0]) by smtp.gmail.com with ESMTPSA id v18-20020a5d6112000000b00236e834f050sm497021wrt.35.2022.11.17.01.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 01:54:27 -0800 (PST) From: Nicolas Frayer To: nm@ti.com, ssantosh@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: khilman@baylibre.com, glaroque@baylibre.com, nfrayer@baylibre.com Subject: [PATCH v6 1/2] soc: ti: k3-socinfo: Convert allocations to devm Date: Thu, 17 Nov 2022 10:54:18 +0100 Message-Id: <20221117095419.171906-2-nfrayer@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117095419.171906-1-nfrayer@baylibre.com> References: <20221117095419.171906-1-nfrayer@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221117_015433_312267_AB38DB5A X-CRM114-Status: GOOD ( 15.09 ) 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 91f441ee6175..19f3e74f5376 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) + 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)