From patchwork Tue May 9 09:49:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 91493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2758358vqo; Tue, 9 May 2023 03:08:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6thVIP2DhvdQJKbeYrpX+IjQV2+5XvZqQF6ysk1+QMH/0GOhRK4wcqzkoyFw/Is+V+BvnE X-Received: by 2002:a05:6a20:160f:b0:f5:68c9:6fa6 with SMTP id l15-20020a056a20160f00b000f568c96fa6mr15502603pzj.17.1683626892904; Tue, 09 May 2023 03:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683626892; cv=none; d=google.com; s=arc-20160816; b=Jb8v9m36RyFI/YNs+6pHce/mWyBF4djg9+Vm97/fqFng6Ej5lsy/yvuEsxP2gCWi6Z GBxkxPSwhsUsan/fSe5+HO1tbHIdauGVWFVMwsfJJ3oLoAgf8mh1YE2CHOmLEF9RAoJx bwivT347kgWe8VXl0tUmpRwb45PRmmbascrEK1/Y9BIE1vDu/E29mStrsjEGIc3TYHy8 FNyQ9tkos1OUnuA3/A6KBtyiB/Z8ZmzA3kQGxXSJBPGu+Ozva/r6KfJIZcUIz/T8+iR9 Om9IIuUeYYjGyXxCQar675cv/l6UmoRAyKMcEISWjsXjkJCVwfqqKrV/e4Z6bt+3i2a1 VMMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=N4zAcNAt58LgZEEJ8P03Qt50w6DERVK3VdghAtiFprw=; b=G9ls+0RfDDfTdlE6baGV4E1xdXWohkiqcgatlh94R/5CRimiOqu4REqfzZHr6PdzQZ Q/1joIqE7HjvllMSlAg7SNNh+uU0Zc7xC02HI1mC1EB4lfGe8i6Od3RXh/I2mg1eL7IZ tfVHtfJobml2vq8+KQjhJc/RVwg9jacZXR7YGo2gwwCeN6oHgp2Pfxwgjc+5y6h7Kruo joWAdiwUs+Ji7VP3c162NcQm2bidjlsO8HfMgS/R0lfVePo6k9DacMKH6O8MR31EshtI Wx5K/SFVTrOBaCP1dctSF3IbU9/WX5q4mwr8B46stCqqK2Jyh+rr49W/Ikfstsi9zh8g t/gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020aa79f8a000000b0064762d151fcsi256080pfr.183.2023.05.09.03.07.58; Tue, 09 May 2023 03:08:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235069AbjEIJul (ORCPT + 99 others); Tue, 9 May 2023 05:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234489AbjEIJuG (ORCPT ); Tue, 9 May 2023 05:50:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 47A13E7; Tue, 9 May 2023 02:50:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 785AF1576; Tue, 9 May 2023 02:50:49 -0700 (PDT) Received: from e127643.arm.com (unknown [10.57.83.64]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 206523F67D; Tue, 9 May 2023 02:50:00 -0700 (PDT) From: James Clark To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Cc: linux@roeck-us.net, michal.simek@amd.com, Jonathan.Cameron@huawei.com, James Clark , Jonathan Corbet , Jean Delvare , Anand Ashok Dumbre , Jonathan Cameron , Lars-Peter Clausen , Andy Gross , Bjorn Andersson , Konrad Dybcio , Jiri Slaby , linux-doc@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v4 2/4] hwmon: pmbus: Use devm_krealloc_array Date: Tue, 9 May 2023 10:49:39 +0100 Message-Id: <20230509094942.396150-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509094942.396150-1-james.clark@arm.com> References: <20230509094942.396150-1-james.clark@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765410753170191743?= X-GMAIL-MSGID: =?utf-8?q?1765410753170191743?= Now that it exists, use it instead of doing the multiplication manually. Acked-by: Guenter Roeck Reviewed-by: Jonathan Cameron Signed-off-by: James Clark --- drivers/hwmon/pmbus/pmbus_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 9d14954da94f..fa06325f5a7c 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1191,9 +1191,9 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr) { if (data->num_attributes >= data->max_attributes - 1) { int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE; - void *new_attrs = devm_krealloc(data->dev, data->group.attrs, - new_max_attrs * sizeof(void *), - GFP_KERNEL); + void *new_attrs = devm_krealloc_array(data->dev, data->group.attrs, + new_max_attrs, sizeof(void *), + GFP_KERNEL); if (!new_attrs) return -ENOMEM; data->group.attrs = new_attrs;