From patchwork Mon Oct 9 16:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2001020vqo; Mon, 9 Oct 2023 09:58:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDmaXKGG3/doghD3C/3KSH/BqT1mlj2s5hkeTBrtju6nnB0wIlHTOO6Tp3fDDCoOpqLyue X-Received: by 2002:a05:6a20:1456:b0:134:73f6:5832 with SMTP id a22-20020a056a20145600b0013473f65832mr21116971pzi.16.1696870700908; Mon, 09 Oct 2023 09:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870700; cv=none; d=google.com; s=arc-20160816; b=tAoXrklRz3O0Pk4l/zzpoirOYqUJWpCVpv8okaCrANS7pEdJ55k07Gg2FVOBP+ceqz 0WUsNmHtO8uZ1b6O1q4GSUiepVpr+sWtrcgCOjKS+UMpoP3si0nlSkdRDKOHdyoq7LAQ Bhu8u2xRs2B7jjvqvSIh9U8piy5r5oTUAVsThqnd8Dku8TzeKnF2ZkXt2NzgoWvCmkVx zTRkRgXL6YNF5tx4rSaWcKy/40L9xHgH3dVtTjQDzCMTTKZo8uiYt41HjDYN1n1qho3Q Zx9G07ZFlrLTmZNb10BbgkE7rG5W4z0MK8eIDsSrbz4x+ze2WHxYpNpG1iCu/aDrlBxJ E+XQ== 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=F2D+qd1LEt3eJ/8XHGRVqxXgOIKNs9E3/VA/WHhSU4M=; fh=hOgk8rZnGsqZJe3BQ3HCHvWjKB4vvEK5IbYVCdCAYP4=; b=rS4C6zziLpbtHJUlOh7pc0Xyo10NP7PSMRtFR+dUpVVrAx7npL6T3BodrMe+Ap4bYv t/zMM/vXi1STM656PRfSq+Wl8COZu7jnsj+8nb6vckpOkTDpJd5PhRK911SVdVyk4EaV Bt5ucoPy3PmJX1X+Kr1v6nzjB/lWntOxgzMOrlIKV1pUVlX8zbvbBxM5lzZmKPzKnP91 EF26OkGrPcDnCpEXL02coEJTMR4Te4dXNliCfTw88boqIKL6t7VfFRshSRSZi5lxQsjP gE8j7kVsvhAziou53zXw1tdJH7AptnOC3ibMbjjQiidLDsL4fu3x68XIKn/Dua/BkYPH YFAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=MPD6ZLz3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bt8-20020a632908000000b00584e2f083b6si9599445pgb.85.2023.10.09.09.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=MPD6ZLz3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id ACF4C80CCD3F; Mon, 9 Oct 2023 09:58:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377834AbjJIQ6E (ORCPT + 18 others); Mon, 9 Oct 2023 12:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376910AbjJIQ54 (ORCPT ); Mon, 9 Oct 2023 12:57:56 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A321FA3 for ; Mon, 9 Oct 2023 09:57:54 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40675f06f1fso34270685e9.1 for ; Mon, 09 Oct 2023 09:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870673; x=1697475473; 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=F2D+qd1LEt3eJ/8XHGRVqxXgOIKNs9E3/VA/WHhSU4M=; b=MPD6ZLz3Oygw97Ahyj3zMbBaAvQcaeBhP4L0iVE53kYmz51MUTV7Z40oQDqXtj5PKX /YxCDgtUIoCEgUlOCwFDcZGzuBLalKfv4dyWpAVMJZXoNjjgk9/2/66L92j6R7Wtdnkn //uFE74D9h9n4/EbntkNepOWScQwhUcgxNLA5fBb3G8kSogc7z9KkXMAFq/LTR3EejoJ J4q0afWgH6VWW4GBiOkkiLZQcSKDer3mrri4QkeYhMDa4h3AVX3KGTQGnanAAq57cjlu vAE+7pNAI15CDWdLJrORbaEayWTDDtxKWzmXptNhwhasP8z238s4gcx37w1NHq7U6WYV RMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870673; x=1697475473; 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=F2D+qd1LEt3eJ/8XHGRVqxXgOIKNs9E3/VA/WHhSU4M=; b=eqHWmU0CDTdPDYJc+WJBMHyYqHVjhYaIgvU+tREIep9DYVh64uerw7NLtNxgz5sKmZ J2KYUPzPyAxl1Ya9dYdBGGUHfaeAVS6RCvPooOJcS2p0UNonN365Mv7Iy9PecpUxs/DC yhSRNqSy3WExFpRX8utZnIHavrCKh7MSeoZl/X+RTxG6wu+q9ZMXNLTGj1GeYY/6T4XL kt8JraKEKEik2YGhAICvh3N3vkQSc2T6v1IN8KbSnEZn3AmW8FXkNhi8HJXw7bin0R2c fVRbXgJ7WYkdaDS0ppWRv1h4MGoUobalxIgURPZgaofBumpHj9KqSqDh1mojyR3/NHPk +1Hw== X-Gm-Message-State: AOJu0YwAIWqyc0m0DRnSK+9igc1BZLSmJUI8WbEL8kxG/DTZvQuBZOdq KQd/5RdNowWaX5YqEPO8kQyALA== X-Received: by 2002:a05:6000:1092:b0:320:968:f3b0 with SMTP id y18-20020a056000109200b003200968f3b0mr8718653wrw.35.1696870673079; Mon, 09 Oct 2023 09:57:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:57:52 -0700 (PDT) From: Max Kellermann To: William Breathitt Gray Cc: Max Kellermann , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] drivers/counter: add local variable for newly allocated attribute_group** Date: Mon, 9 Oct 2023 18:57:37 +0200 Message-Id: <20231009165741.746184-4-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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:58:18 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297891977387576 X-GMAIL-MSGID: 1779297891977387576 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/counter/counter-sysfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index 42c523343d32..47e1e2c61cf0 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -1122,6 +1122,7 @@ int counter_sysfs_add(struct counter_device *const counter) struct counter_attribute_group *cattr_groups; size_t i, j; int err; + const struct attribute_group **dev_groups; struct attribute_group *groups; struct counter_attribute *p; @@ -1141,9 +1142,9 @@ int counter_sysfs_add(struct counter_device *const counter) return err; /* Allocate attribute group pointers for association with device */ - dev->groups = devm_kcalloc(dev, num_groups + 1, sizeof(*dev->groups), + dev->groups = dev_groups = devm_kcalloc(dev, num_groups + 1, sizeof(*dev_groups), GFP_KERNEL); - if (!dev->groups) + if (!dev_groups) return -ENOMEM; /* Allocate space for attribute groups */ @@ -1169,7 +1170,7 @@ int counter_sysfs_add(struct counter_device *const counter) groups[i].attrs[j++] = &p->dev_attr.attr; /* Associate attribute group */ - dev->groups[i] = &groups[i]; + dev_groups[i] = &groups[i]; } return 0;