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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBD6DC4742C for ; Mon, 2 Nov 2020 14:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99B04206B7 for ; Mon, 2 Nov 2020 14:26:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Iz+6HeRy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgKBO0N (ORCPT ); Mon, 2 Nov 2020 09:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbgKBOWh (ORCPT ); Mon, 2 Nov 2020 09:22:37 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1032BC061A04 for ; Mon, 2 Nov 2020 06:22:37 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id n15so14860620wrq.2 for ; Mon, 02 Nov 2020 06:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9A0YZTtyChgf0u6PFbkMOtS/8IXdoUAvGcveYosNg8o=; b=Iz+6HeRyJ0MzqEaZdma++F+Cl26ft+hc4SvyuEOwHNxpA9O2d9Ccrt//8K9HHCIGeZ PN3iov4vxUF8uIwsXYRP/xOxjR9AG1Icc1aQarzzAZ9ds+u7ghaZnJwLeuYXdoqYJprL xB8zPvuA1ahdRu3rRVh598nguAmJqCg2KA4KTNPDisAigjNyFkA8Z/yh0W4W40YktLVg bs9JczBvspN3PnSZ738KfquAPGW2rtBneSeDWY2SSINssmt+xct8YHlDqWDp7jPOL6iz HGjKojUFxD2tr4fe/2JUXl6sZ7XjLoHEzurMV9I0JIaQxwP7qOFQl8Ps9bd6R/LsA4XY CUHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9A0YZTtyChgf0u6PFbkMOtS/8IXdoUAvGcveYosNg8o=; b=eFYCGUX7vazR729ldll0h70LymKMpuN2XDIw+ZHrGUSa6mu0eIty5z9KtgiqJrL9FC dLPG6Tr72PiNK7tbA4PmFooRRKDTCCqkKq1GfQqX6SyKfd4T0opOWyCXhELN5wwFkE3/ qBuQdKvgNJDoKuC5KBDkCDXjH29LxU13guHX19qvUvCKUF3QAxIm1jMfE5dRv6xtQ/AS onhmpVWmDw67lA/RrelnhKgelfbn1TijlOYpNrEeeRy0H5hYgyl3rrBBhFboQb6oaqv+ C1fwcWQC3Sn/UeKibdt13CEnypG4lTQ27gsZ2P3yaXt+F4DZ7ZqS7cjmfb5dyq1KrtjZ FBjA== X-Gm-Message-State: AOAM5308nIAGFtCisl5LPmWBrVSJ5t/rrIOFHeam5EwsYLfXEwkjQYP5 gpZNn3ZCepe7fzLhmHtn3Yu6mw== X-Google-Smtp-Source: ABdhPJzEMMHZfL1mdwXFbBpQAWTyd9NcamKKsSu8d3RLFB6kvwNmlyzoTY0otzx1aVegApUhQc86jQ== X-Received: by 2002:adf:ea11:: with SMTP id q17mr21799947wrm.251.1604326955882; Mon, 02 Nov 2020 06:22:35 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id 3sm16182987wmd.19.2020.11.02.06.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 06:22:35 -0800 (PST) From: Bartosz Golaszewski To: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Michal Simek Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 3/4] iio: adc: xilinx: use devm_krealloc_array() instead of kfree() + kcalloc() Date: Mon, 2 Nov 2020 15:22:27 +0100 Message-Id: <20201102142228.14949-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201102142228.14949-1-brgl@bgdev.pl> References: <20201102142228.14949-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Bartosz Golaszewski We now have devm_krealloc_array() in the kernel Use it indstead of calling kfree() and kcalloc() separately. Signed-off-by: Bartosz Golaszewski --- drivers/iio/adc/xilinx-xadc-core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 8494eb424b33..7792aa4cf9cb 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -586,14 +586,18 @@ static int xadc_update_scan_mode(struct iio_dev *indio_dev, { struct xadc *xadc = iio_priv(indio_dev); unsigned int n; + void *data; n = bitmap_weight(mask, indio_dev->masklength); - kfree(xadc->data); - xadc->data = kcalloc(n, sizeof(*xadc->data), GFP_KERNEL); - if (!xadc->data) + data = devm_krealloc_array(indio_dev->dev.parent, xadc->data, n, + sizeof(*xadc->data), GFP_KERNEL); + if (!data) return -ENOMEM; + memset(data, 0, n * sizeof(*xadc->data)); + xadc->data = data; + return 0; } @@ -1372,7 +1376,6 @@ static int xadc_remove(struct platform_device *pdev) free_irq(xadc->irq, indio_dev); cancel_delayed_work_sync(&xadc->zynq_unmask_work); clk_disable_unprepare(xadc->clk); - kfree(xadc->data); return 0; } -- 2.29.1 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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF7FCC388F2 for ; Mon, 2 Nov 2020 14:24:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 606DD206F8 for ; Mon, 2 Nov 2020 14:24:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UN3qYFdC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Iz+6HeRy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 606DD206F8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CpQBmOL57ewARsAEl/8bBo9FjrF/8QBKSdvq9vfETC4=; b=UN3qYFdCBHL2CiQ6w7tD/ZwNr e4oRwM1z4x4/BPsSnbDN/bQX8fXq0NKpKqAoANYXflGPKqCHfYFjgOGL9GVHFw9/xx/QoudRldHfo 4YSnxij6KhYB9o2rivH1pbztXBdKQcXh+52Obp4u8ZWMleiQIzi+s2JL+8qVqIouBDfV/Qjri+jaN gHJHMOuQ/FF+TZEn7kmZy/g9V/xT8H6HD2C4RTWLSXM474oWEMJSTWl4kIQ37Ncc9q6bdPvo0JaDN OC6RSNsdopk7Ro06sd8VD4gLB/GkvKpImgg9gG1J57/8u4I8sVj8CAoCISPknZCiyr+/6aIu9rm8w anHPdALQQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZajY-0001H0-OW; Mon, 02 Nov 2020 14:22:56 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZajE-00019f-KU for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 14:22:38 +0000 Received: by mail-wr1-x441.google.com with SMTP id n18so14809904wrs.5 for ; Mon, 02 Nov 2020 06:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9A0YZTtyChgf0u6PFbkMOtS/8IXdoUAvGcveYosNg8o=; b=Iz+6HeRyJ0MzqEaZdma++F+Cl26ft+hc4SvyuEOwHNxpA9O2d9Ccrt//8K9HHCIGeZ PN3iov4vxUF8uIwsXYRP/xOxjR9AG1Icc1aQarzzAZ9ds+u7ghaZnJwLeuYXdoqYJprL xB8zPvuA1ahdRu3rRVh598nguAmJqCg2KA4KTNPDisAigjNyFkA8Z/yh0W4W40YktLVg bs9JczBvspN3PnSZ738KfquAPGW2rtBneSeDWY2SSINssmt+xct8YHlDqWDp7jPOL6iz HGjKojUFxD2tr4fe/2JUXl6sZ7XjLoHEzurMV9I0JIaQxwP7qOFQl8Ps9bd6R/LsA4XY CUHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9A0YZTtyChgf0u6PFbkMOtS/8IXdoUAvGcveYosNg8o=; b=S4yGWkglY+RrcuckaTbtzSH9WMqAjCgPRAnapdY/uKGvu4YOIJ9sz/MA9WYo9oO/z7 NXOtbgzdHH9bKhFTk45UR/kPtMEoDtFhsD868GRtUFlmHmPzRaYJcSFeR6yfB2Rwey/5 2a14fHyCn4MM5LzjMgwfSyPlr5HNk+/R/BkC119JlhOTaVBH1VoEAUoYiQlPmQU+1Tot XSTJCLAHv4TCKMYeazoe4QGgDzy/abTqgalYMke7k9fsxLR/a4gZ3VboKJ3upJ2cdy1v DIhu0kiQakUHSrrNePgTI9OilvANpO0jsndUvpkT/KU0QceQjbp7IOZ3TA/tqPFduUsf FCNA== X-Gm-Message-State: AOAM533d+RzQYKhF79VoHJA9x+kRgk1Rof/3AdWHWqaWYDReZJK7jByq gzXgO99yFIlJlPlnCJZgFwJC5w== X-Google-Smtp-Source: ABdhPJzEMMHZfL1mdwXFbBpQAWTyd9NcamKKsSu8d3RLFB6kvwNmlyzoTY0otzx1aVegApUhQc86jQ== X-Received: by 2002:adf:ea11:: with SMTP id q17mr21799947wrm.251.1604326955882; Mon, 02 Nov 2020 06:22:35 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id 3sm16182987wmd.19.2020.11.02.06.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 06:22:35 -0800 (PST) From: Bartosz Golaszewski To: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Michal Simek Subject: [PATCH v2 3/4] iio: adc: xilinx: use devm_krealloc_array() instead of kfree() + kcalloc() Date: Mon, 2 Nov 2020 15:22:27 +0100 Message-Id: <20201102142228.14949-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201102142228.14949-1-brgl@bgdev.pl> References: <20201102142228.14949-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201102_092236_744003_C438B402 X-CRM114-Status: GOOD ( 15.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-iio@vger.kernel.org, Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 From: Bartosz Golaszewski We now have devm_krealloc_array() in the kernel Use it indstead of calling kfree() and kcalloc() separately. Signed-off-by: Bartosz Golaszewski --- drivers/iio/adc/xilinx-xadc-core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 8494eb424b33..7792aa4cf9cb 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -586,14 +586,18 @@ static int xadc_update_scan_mode(struct iio_dev *indio_dev, { struct xadc *xadc = iio_priv(indio_dev); unsigned int n; + void *data; n = bitmap_weight(mask, indio_dev->masklength); - kfree(xadc->data); - xadc->data = kcalloc(n, sizeof(*xadc->data), GFP_KERNEL); - if (!xadc->data) + data = devm_krealloc_array(indio_dev->dev.parent, xadc->data, n, + sizeof(*xadc->data), GFP_KERNEL); + if (!data) return -ENOMEM; + memset(data, 0, n * sizeof(*xadc->data)); + xadc->data = data; + return 0; } @@ -1372,7 +1376,6 @@ static int xadc_remove(struct platform_device *pdev) free_irq(xadc->irq, indio_dev); cancel_delayed_work_sync(&xadc->zynq_unmask_work); clk_disable_unprepare(xadc->clk); - kfree(xadc->data); return 0; } -- 2.29.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel