From patchwork Fri Jun 9 11:41:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773817 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 3wkgPh5ftGz9s7m for ; Fri, 9 Jun 2017 21:42:16 +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="VWzC3BBw"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751578AbdFILl5 (ORCPT ); Fri, 9 Jun 2017 07:41:57 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:36296 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751528AbdFILlz (ORCPT ); Fri, 9 Jun 2017 07:41:55 -0400 Received: by mail-wr0-f179.google.com with SMTP id v111so30023135wrc.3 for ; Fri, 09 Jun 2017 04:41:50 -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=VWzC3BBwpmG7p+NLFBYhqqnECyMaln4ox9xTsUFIub9M8lQXbDauqSH8556BF8HcL5 /TEpipSuarc6ywvrnbV2Vtq4plcPAjoNphiM/QGTrhGcQRrhifLbMHMGqtsYUJ+bSM66 iqHBlXdGvjgln6z+w3CO0AuX4GOaWM+RiwNFIw+fgwbUaBFNR+pwg67nY2vyCVldRg06 dH7djIdurjrx/O+gqAYRiYVxzadXCRYN2GxGYvhPTS8aocApCWasnKup9PDY1kQO2OK1 rDMGuPmQI6yafLyC9Cl67ZncPQ2VO4uhEFbR7XzQLPf40eiO26d9U01oYA6pyOg6ruyc YZ0A== 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=aCvJ3BAhM61Z1ZlP+tSt/8ExQdFyI6DS1xXZOqz7bQfkqDcOvPIeL459W5HnkBT+lM 4tyAWtTmcWPfgVFIieaG+XoR1nSjWPxoga2UeMP+hyos+v9MAmJ4YPVeRU06odTQtSYM p4uwlkx9XK4LWoEd9C7nuDYIS+969bqYuknfLazCga3t4viiBLKlYgLIBro6kLvS9NVf 2MvC+T5LPSMStLpN9CqvY8ZLHodJDOUcMfmDU+n84bwgmMmP4Qi3z1SJ+kyLlAefD5TA CEatIg7sttgNslhlAs2qfh34OuT0UP8DN8F0JToitUdh8bp+gtVh62QARU34QYKKcoIk UAMA== X-Gm-Message-State: AODbwcBkZOcSoXc39TAKXKDWbN1m+uLGDuZOTkHjjWDzWkoVGLV1FWDQ mjyq+xB0XlGWZigS X-Received: by 10.28.181.201 with SMTP id e192mr7391932wmf.48.1497008509398; Fri, 09 Jun 2017 04:41:49 -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 r186sm1237510wmr.30.2017.06.09.04.41.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Jun 2017 04:41:48 -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 v3 8/8] gpio: mockup: use devm_kcalloc() where applicable Date: Fri, 9 Jun 2017 13:41:32 +0200 Message-Id: <1497008492-14907-9-git-send-email-brgl@bgdev.pl> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1497008492-14907-1-git-send-email-brgl@bgdev.pl> References: <1497008492-14907-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;