From patchwork Mon Oct 9 16:57:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150214 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2001166vqo; Mon, 9 Oct 2023 09:58:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJJa7zLnhcholS2iFDUWyktbCNdzvFnQr6tXOVvnt6bdbUEUfOPNr9k8j4ryfAtRqr058Z X-Received: by 2002:a05:6a20:138a:b0:159:c918:1016 with SMTP id hn10-20020a056a20138a00b00159c9181016mr12459606pzc.49.1696870714783; Mon, 09 Oct 2023 09:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870714; cv=none; d=google.com; s=arc-20160816; b=CC2lu51bLpsWatW4MQnu+4G3nxPCilMWl33Y/b2MVY7WQyQ3Ad5aNtAnTSaw0k+aCA 3o1PeHfp/TtdF8rfnTDE0lUuxGGZ/AvqU6KdNFjNSxOHM6sQ3A8SAgIsKgxvq69vhSrm tMu2vXmNH99YvhlRjWWOKLammdL98+xslfcYzAjAA1J8sdDEriB4vcvi9qO7RmDSA15x O7JYTuyVC1niB6Qvnkl0fcGSr8cGe8IPjdec3CdidirmwB8xBTjoLKa9FHme85TN6kEI LyNPVU+yE7q3wSUfW9N1KBRa31OhM8QYaFGyOrhGKls7ACCdoaQT5OQ2JZGJyaQ3GFyf 99vg== 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 :dkim-signature; bh=nZAV/Qw52sFDXsSaIlMwU7Snqmg7zw6UPrOsGwKv28I=; fh=cuLvoHX9Ajmuv5XlviAdu70AqC2y0B1pmoGXNJDobNI=; b=v1ZgLWbOcjql1rIi7l3cs4SYmcZ05/Iy9BkvuXpeDAFfuMNcHyw1/21wP2BBvIHgpP 7cMJ348MPVXWwHBDs+G//4j432ZXrnFxZPp5ITAhSI7n0AH8rpxiOFsUZ8TUhHdOerFF eLDNReKg6ucq1v4zzsQuCLOZI8vGPgcsT8Na4bLOIy2r+Q2qBAP+qRhOTZrUf9B7oWZb yxa64AfqCuIfB815gjYsp/k7ZStchNFjSOqtP9kxfk1yiM/Ujh8B+jEAke5OmDDDChl1 zeu5Hh7d0KkYGMjJXHxsi5a3KkFuf57ymiUEn/qv8IV0iFZCa5TnA5c5RNF8vIe0RwgQ X5dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Xij2wRHZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id r16-20020a632b10000000b00565e865d381si9577585pgr.447.2023.10.09.09.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Xij2wRHZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 57EF38047552; Mon, 9 Oct 2023 09:58:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377359AbjJIQ54 (ORCPT + 18 others); Mon, 9 Oct 2023 12:57:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377268AbjJIQ5y (ORCPT ); Mon, 9 Oct 2023 12:57:54 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D7359E for ; Mon, 9 Oct 2023 09:57:52 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-406618d0991so44395385e9.2 for ; Mon, 09 Oct 2023 09:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870671; x=1697475471; darn=vger.kernel.org; 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=nZAV/Qw52sFDXsSaIlMwU7Snqmg7zw6UPrOsGwKv28I=; b=Xij2wRHZ5KF7wmkX7GQJ2dIPxBy1Epr8FAvrKi2bwiEVfKZHdCcVU/T8Lt75EygD2u oe5rYLMJ5PoMdo9nxW3OwXWw/fbH51WHlEoJcgrE6i8t3Y7Bfnthw2A4j56PJ5/9nmKU vDAwZeNWLZSVBWHFs+3Cowk1wjMQP9sLR7KSvag3y8H+OkkgsafHS6+F8J7Fbq01onng Qd2jI3AEfaH2F0zV6KnHeGHPRNkkuL4VRbNfz5CZYkrF4CogUPEKA6mG6EK6/WTwYelK SatIrPdYGt+kOHtTXAsSJfK4Jd9IkEUfg5AF7lwjhZJT5w5We8WtrtxddaJRpHApGGMT po7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870671; x=1697475471; 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=nZAV/Qw52sFDXsSaIlMwU7Snqmg7zw6UPrOsGwKv28I=; b=RlGRFHZYgCvIh15B+LVnEhbLd3g3DPj1gfrDRUTuPY+J8GRnZcYCqQIr+VHVMZiY34 biJZvZl22ABbXR1TezAN0aNzybTSqrOFd+0TpO7046vHXKAPKYiKsC6QKy7cE7kSjxuF JMdRw0vBJpj8wnCS0rxRPdJ+y9zjhw4kiXSMAkBuFrCn+4d8/ZsPicuG3UIDJ9HbWe7Z 36NC0Rcol/ZOr5s4xrSxtf7+9rgBq3+3lc2ylaN3iVuyjqM6RaQVywXyUiknULCt99aC RdmM6OWrNh5ijjohqhjnmP4CpMC3VowyP/qNmhwCc3QjfSOKmgSVZHhXGq+y5PZnSVhh mL4g== X-Gm-Message-State: AOJu0Yz3tjLxHEZyI97buqeBfR0/DW+YhbXTuOFMBQikuwl6QRl878bl vQTG/hsVSwuWmgzwneP9YCS7RA== X-Received: by 2002:a7b:cb8b:0:b0:402:8c7e:3fc4 with SMTP id m11-20020a7bcb8b000000b004028c7e3fc4mr14562722wmi.30.1696870671100; Mon, 09 Oct 2023 09:57:51 -0700 (PDT) Received: from heron.intern.cm-ag (p200300dc6f49a600529a4cfffe3dd983.dip0.t-ipconnect.de. [2003:dc:6f49:a600:529a:4cff:fe3d:d983]) by smtp.gmail.com with ESMTPSA id d9-20020adff2c9000000b00324887a13f7sm10199828wrp.0.2023.10.09.09.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:57:50 -0700 (PDT) From: Max Kellermann To: Jean Delvare , Guenter Roeck Cc: Max Kellermann , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] drivers/hwmon: add local variable for newly allocated attribute_group** Date: Mon, 9 Oct 2023 18:57:35 +0200 Message-Id: <20231009165741.746184-2-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009165741.746184-1-max.kellermann@ionos.com> References: <20231009165741.746184-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:58:22 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297906236364720 X-GMAIL-MSGID: 1779297906236364720 This allows the compiler to keep the pointer in a register and prepares for making the struct field "const". Signed-off-by: Max Kellermann --- drivers/hwmon/hwmon.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index c7dd3f5b2bd5..e50ab229b27d 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -783,6 +783,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, hdev = &hwdev->dev; if (chip) { + const struct attribute_group **new_groups; struct attribute **attrs; int ngroups = 2; /* terminating NULL plus &hwdev->groups */ @@ -790,8 +791,8 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, for (i = 0; groups[i]; i++) ngroups++; - hwdev->groups = kcalloc(ngroups, sizeof(*groups), GFP_KERNEL); - if (!hwdev->groups) { + hwdev->groups = new_groups = kcalloc(ngroups, sizeof(*new_groups), GFP_KERNEL); + if (!new_groups) { err = -ENOMEM; goto free_hwmon; } @@ -804,14 +805,14 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, hwdev->group.attrs = attrs; ngroups = 0; - hwdev->groups[ngroups++] = &hwdev->group; + new_groups[ngroups++] = &hwdev->group; if (groups) { for (i = 0; groups[i]; i++) - hwdev->groups[ngroups++] = groups[i]; + new_groups[ngroups++] = groups[i]; } - hdev->groups = hwdev->groups; + hdev->groups = new_groups; } else { hdev->groups = groups; }