From patchwork Thu Jun 1 11:47:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 769652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wdlv60nQtz9s7C for ; Thu, 1 Jun 2017 21:47:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="iWXlYUPC"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751083AbdFALrL (ORCPT ); Thu, 1 Jun 2017 07:47:11 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:35603 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbdFALrL (ORCPT ); Thu, 1 Jun 2017 07:47:11 -0400 Received: by mail-wm0-f46.google.com with SMTP id b84so155286462wmh.0 for ; Thu, 01 Jun 2017 04:47:10 -0700 (PDT) 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; bh=PrGK71EynBQUJS1ZiHVeNDYw/uEokCuUwDFCPamEa6Y=; b=iWXlYUPCMoMLdiAN7P8HGAMLKMMAt2S00/fMLv8CA/npAPcEiIsZaEIhYfV2vRtlhC 686p/JM4FFq9N7qr7NJPJHRblBNcl6T+rsKKLAhl5K8D53c66Ygicqs/9D2OyThGu7dL zT7Jdct7dma0QEaeheLeGl8991LqcRCSHIiQLav9Q38kQ/GU0sRUGIL4YfuAflhCFX9r Hr3/nGKVYdJrU5YjdfZfUOCqk8BNjpMvWRdRO0f7oyN1Dgo25ADJ/T9aLKxMOjkgG2zb tIHi0LBCPFLt0S4naLOx0QbRkKhRutU77OJFjlfF1hbVDrb7CV19yLdruaEjbAKBy4nq i3Wg== 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; bh=PrGK71EynBQUJS1ZiHVeNDYw/uEokCuUwDFCPamEa6Y=; b=JR2+vIGNO20YN85BTmPk0NiC3vgBkTtiensskD34svdOL7bipEInTE0e39U/fOqCxI vshQ6TulZrm63uBBaAirdB27DhJSo7oNA/Bnd9b1JX450mbJl1Ih27qeX0e3djEAePVh C9kGU3jrJuhUrYHMZerZmy8JyrHYljdV1/VYt9ev/vjX1CTnkBZdA2tJuPGsMJ9dZ59G R6HN02f43M+al3aMoEQ9ucYpL3GOUEEwI9i+fB/0gAbzkGHcBSBYXQC8n5wsZB8l2i3c vjQbUqWTxsT/OorQMCgw6tWAaxdnRtvUIiG0DrfCeofdmTjnt4kLiVLtkP304bPYZXMq sL7g== X-Gm-Message-State: AODbwcAFWKJFOOQIneNagEbe97aG4/l0OmSg53p89SdEf/tbiuliWEDR Vaisc98pzwYQ6h7f X-Received: by 10.223.161.130 with SMTP id u2mr188864wru.203.1496317629311; Thu, 01 Jun 2017 04:47:09 -0700 (PDT) Received: from bgdev-debian.lan (dynamic-194-228-20-36.ipv4.broadband.iol.cz. [194.228.20.36]) by smtp.gmail.com with ESMTPSA id b30sm22744028wra.6.2017.06.01.04.47.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 04:47:08 -0700 (PDT) From: Bartosz Golaszewski To: Andy Shevchenko , Linus Walleij , Alexandre Courbot , Bamvor Jian Zhang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH] gpio: mockup: use devm_kcalloc() where applicable Date: Thu, 1 Jun 2017 13:47:03 +0200 Message-Id: <1496317623-24026-2-git-send-email-brgl@bgdev.pl> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1496317623-24026-1-git-send-email-brgl@bgdev.pl> References: <1496317623-24026-1-git-send-email-brgl@bgdev.pl> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When allocating a zeroed array of objects use devm_kcalloc() instead of manually calculating the required size and using devm_kzalloc(). Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 536a229..a6565e1 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -128,7 +128,7 @@ static int gpio_mockup_name_lines(struct device *dev, char **names; int i; - names = devm_kzalloc(dev, sizeof(char *) * gc->ngpio, GFP_KERNEL); + names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL); if (!names) return -ENOMEM; @@ -308,8 +308,8 @@ static int gpio_mockup_add(struct device *dev, gc->get_direction = gpio_mockup_get_direction; gc->to_irq = gpio_mockup_to_irq; - chip->lines = devm_kzalloc(dev, sizeof(*chip->lines) * gc->ngpio, - GFP_KERNEL); + chip->lines = devm_kcalloc(dev, gc->ngpio, + sizeof(*chip->lines), GFP_KERNEL); if (!chip->lines) return -ENOMEM; @@ -346,7 +346,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) /* Each chip is described by two values. */ num_chips = gpio_mockup_params_nr / 2; - chips = devm_kzalloc(dev, sizeof(*chips) * num_chips, GFP_KERNEL); + chips = devm_kcalloc(dev, num_chips, sizeof(*chips), GFP_KERNEL); if (!chips) return -ENOMEM;