From patchwork Mon Oct 9 16:57:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2000904vqo; Mon, 9 Oct 2023 09:58:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6SA1+Ta7Iv0KhcIrjoj+yXV5+lUzlPqM8V9cnhorGh7dTkIZ8UAETQRcodaKbAhxpQhUJ X-Received: by 2002:a05:6a00:124f:b0:68a:3b39:a486 with SMTP id u15-20020a056a00124f00b0068a3b39a486mr17595805pfi.24.1696870688495; Mon, 09 Oct 2023 09:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870688; cv=none; d=google.com; s=arc-20160816; b=JrppzOfhfADWDC5kH8BVst+4KgLSiKeZyic/QC0R81SJwGQkHOkP2AhwOFWm/7fHMs bvW/9rQ0O4JmBEnv2KzY3iUR8BlrRkJ2FfQEfOzVp40hkwfb5zq54q+BSUiiBx51I3gc fXNJYzZY1p2VfB/Y1JUIydd9u1mS3SU4kP9YXXfilC+ufdcKzRciTp2cvDOqxrjnIWag MZiZss6RobwXAd8/1VXRN8Kgesvb91EbuDXgiO+6LOqaEcOekG+bM7ypUl+V+Wbsqe0P /gdO6Ir9XreGaP/93oTGS1EebYrJNnf0wwSRJDqaVZMlwQ4UeINo1ZzCO5EW+tMwF7C7 dNjA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Czavm+hA74AE3KkSlm2hXBEMwAG3Dh3p+tVw2heAB7A=; fh=hq1fRiNVtaCpELIzc/6Lx4IdLppwjJcBiFRTvnqozPs=; b=v9S9WPAjktZeiznwn9/vl5MMgJAhEazTjYb1zUX1x3m0gmNg2lyFeOxAGvNfdPJpIx OrET4K3Tx0JBsP2HvR4u9npMCsUCb4on6OVLAW5zhUtj4ugHoph2VkMNiZJb6mngHlSZ qpS3QmfBHllL99v+QYGOLpU9vhWZnBQh9ykCv8BB7mqjVUCol/O9vxcYVuPaGgnDtj+d A0ps4oEiMSWOsM51qlDy4LNYxtO3ibvjkcM9rHksltAK+hSh15YrsynFLZ92bFq2StBK HbgpdZzB0PK5mefsJH9tSXx/IqnxI6SvJOXVm1U69zDT7HKQzT+TB5Y5ik70RfOmi6nf 3nPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=MCdfFnbR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d8-20020a056a0010c800b0068fc9c6eafdsi7868848pfu.137.2023.10.09.09.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=MCdfFnbR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 240C8804039E; Mon, 9 Oct 2023 09:58:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377138AbjJIQ5y (ORCPT + 18 others); Mon, 9 Oct 2023 12:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376910AbjJIQ5x (ORCPT ); Mon, 9 Oct 2023 12:57:53 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6FD694 for ; Mon, 9 Oct 2023 09:57:51 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32003aae100so3545717f8f.0 for ; Mon, 09 Oct 2023 09:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870670; x=1697475470; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Czavm+hA74AE3KkSlm2hXBEMwAG3Dh3p+tVw2heAB7A=; b=MCdfFnbRJW1WAaKwEDUwiHSCpY562wWuKtkxn4NY+1haJGcoYfPPVi1Zy39PxNOJ7C ZIUFW+etlhHrfUNjVtyh6xIhdf0IJLjA6HPu0/wLTVMyQhcmgilBs0hn8GRb6TPt7QWM ilYe4fObxWLV3dXIT5XJOG35AgwwMTOPkNHvlZFPsBbHpNpbZsv9p7Q7Y+wv23qWcVJW OsYV1NNiJRjXsXSEfihdZoxL2aFa2KWVxZYGq0snyIAhlMZiUmIbnv5gi+FjofVCzE+O VK+uqe2ahdGNTnyftZSfTSS8JUAOOZDYPK9rzbGS+ThhViz/fbmI0WKqQ60mZlAGzG94 VO1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870670; x=1697475470; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Czavm+hA74AE3KkSlm2hXBEMwAG3Dh3p+tVw2heAB7A=; b=KqN5X2MdAGDaLRhws309Ik3XxbQXcEU4Z+ARh0j1HFhv5MxNT0DUAq2mJ/S9OGSQR3 q4gbQ+TqO4BiZcwbXB/syjsEYtgVECsB1Ob7b8gM1o2Yq2pDc0DFW4vvcOsRA3Qn2+Ex GPz7OBvjE+B3BPY3ap1/HMZ3hLe4cgu33G5KCFVoGg3LIW2NB6kLG9x2wh6ZIHYr3MoK lH+KiUQe3normogigyk/ev0TKE0Ac+Fx0g21FNdBvMgzgr/x9qwgyFu/0e+O7/GSrRI7 5AOyoFBDaQV5wQM0CcxpVztIGhgODOqn3WpwWbFXcEm/Dqoh21we0oc4ftW6tnYmC7e7 fKBw== X-Gm-Message-State: AOJu0Yy6aCEl7jEKhcl7QJBfqC3l+VUbkqxNzNMDYKB+Mxpc4vFSimiV WoZXWncBscFTGKzn5ozXngPybA== X-Received: by 2002:a5d:4dcb:0:b0:319:6997:9432 with SMTP id f11-20020a5d4dcb000000b0031969979432mr11098692wru.1.1696870670148; Mon, 09 Oct 2023 09:57:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:57:49 -0700 (PDT) From: Max Kellermann To: Alessandro Zummo , Alexandre Belloni Cc: Max Kellermann , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] drivers/rtc/sysfs: move code to count_attribute_groups() Date: Mon, 9 Oct 2023 18:57:34 +0200 Message-Id: <20231009165741.746184-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:58:03 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297879207663105 X-GMAIL-MSGID: 1779297879207663105 This avoids overloading the "groups" variable for three different purposes Signed-off-by: Max Kellermann --- drivers/rtc/sysfs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c index e3062c4d3f2c..617933d52324 100644 --- a/drivers/rtc/sysfs.c +++ b/drivers/rtc/sysfs.c @@ -313,21 +313,25 @@ const struct attribute_group **rtc_get_dev_attribute_groups(void) return rtc_attr_groups; } +static size_t count_attribute_groups(const struct attribute_group *const*groups) +{ + size_t count = 0; + + for (; *groups; ++groups) + ++count; + return count; +} + int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) { - size_t old_cnt = 0, add_cnt = 0, new_cnt; + size_t old_cnt, add_cnt, new_cnt; const struct attribute_group **groups, **old; if (!grps) return -EINVAL; - groups = rtc->dev.groups; - if (groups) - for (; *groups; groups++) - old_cnt++; - - for (groups = grps; *groups; groups++) - add_cnt++; + old_cnt = rtc->dev.groups ? count_attribute_groups(rtc->dev.groups) : 0; + add_cnt = count_attribute_groups(grps); new_cnt = old_cnt + add_cnt + 1; groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL); 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; } From patchwork Mon Oct 9 16:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2001087vqo; Mon, 9 Oct 2023 09:58:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVsFo3te8K5AhDqxDPbLm39SM7+Yr9ZcdGolMDxy1REisrhXx5KOWfO+krf6qZsiCS/Peq X-Received: by 2002:a17:90b:1643:b0:268:10a3:cea8 with SMTP id il3-20020a17090b164300b0026810a3cea8mr12990391pjb.9.1696870708198; Mon, 09 Oct 2023 09:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870708; cv=none; d=google.com; s=arc-20160816; b=UelFaN/snuAjbog3pvsyiptpAsfbuzujAmNOFdF4SwNOmglnTX48gt5nytN6zVU6m6 ljGYpjQE1u+GILCIzLn4Vqa09qeXV6sdop2Z8EvJsCBcTTK+F0f4ZZ8UJnazhnYqcTcT eQJv75ZF5y1G6FwUZVJVoU9sTaxb+n7YnAIlDO99J7UojrmQjKPmQunSYMKknNu382tS OsCAyXSepZaz32VWde9+5xRnIyFcIClQ6+ZqqfKgwym0o+O7WVzJzP1ctjv19uf0uYic z8PFzM8nnqTwqkJUtCGJjnEHtf3U9/K786AsmEOQgV0jYMT9SegaPFqTcR27K0aB2fsF 3raA== 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=cBjS1gShjaJkPyX/KQvNob7ffrl0lyd3plKPyysabEY=; fh=nfvfGULRixEUQS47ZFVU1vQGtb0Wy82sG2oSs3tSDLM=; b=hI5hcTcs1l8uWQwHJP8HYLksdU0Ib25brLsrikx6ErYvlSNFkyyYQsS7fFSRAva8Nw yvBtBprlbe+Ls+Fr0mvzOEiUZDNsQjY2ZXTfa8yNV7HCZB3thkaySS+EBSCSdLrraIRh pnxpKo4BGs2rzi4bP3+GViy6//QhpYAaEZzakICfDpdu3Zzq3cnqE7LgYNU6gSJh5IgU 2q0wnpJzT4PjuNxfVNQ40d4A11NHvokhLrey0J8OoL8c/CUArH8F9I+xOjC8leddXCLq Q/V1gbyXgJjm7cpH+aeplSa3HRYK4SiMoXpIOdQiBz1i8xsFqYyZkiWIMEEekrm3lI+n oaZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KWSsWKwF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e6-20020a17090a4a0600b0027901ee93fbsi11331419pjh.156.2023.10.09.09.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KWSsWKwF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 01FC0801B9DB; Mon, 9 Oct 2023 09:58:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377812AbjJIQ6C (ORCPT + 18 others); Mon, 9 Oct 2023 12:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377354AbjJIQ5y (ORCPT ); Mon, 9 Oct 2023 12:57:54 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CAD1AF for ; Mon, 9 Oct 2023 09:57:53 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32003aae100so3545740f8f.0 for ; Mon, 09 Oct 2023 09:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870672; x=1697475472; 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=cBjS1gShjaJkPyX/KQvNob7ffrl0lyd3plKPyysabEY=; b=KWSsWKwFhuZjxNlw57LlhSLmB000RjfrYKSEWyZFpizdKupo89jsTs+1Pn1dj3r6VN l0/CuLolEgtuG1LnUrIBr/Cvel6LQ06QQ2qUJwqJVbJRGpoIZjC2CFJ9GQhFI5fSa8R0 PTsfZkHvwt67JoQH9OZ+eR2bFjP8gTipg35fkJovfSCM8+X2i9lchx9ap1wyJmPZO4d9 YMIoftOEy8yY9XyiQxE8QWjsj3pGWzpjLwQffhfxyEXPr4Wu/Rv1lQrRGFvqX4PHdspl zWAJLo+oYMNn6tIlJ75Vfui+IDeDZZWuD/kpkd5wqeGAWCCicZf4BUfBH0thUKTfwETq SI6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870672; x=1697475472; 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=cBjS1gShjaJkPyX/KQvNob7ffrl0lyd3plKPyysabEY=; b=hEUbXJNM1iL6Y6x9i4vuU4Tq+i3fvixr+lSnH1we1t7HU9CHqfvRDZUKoxXRQFpora UEsUlaKCn0/ArIgUOotOm5s7Mpys/Q186hgHqYLU0DIrkCFS6k6KxcPI8dbfdupG+qBo 6EpWqW9q8FAa99TyKlQkBI3MFQSuGg+342YCGG0Q5jY+Iu+D/evhdKh8QZdc+2EGXKXE 26WKVrU6ddikcpwdUIldM/WG8jQ9zLF5nttfLDijI2RotYvVBETQlc+anqVSAAfAKVaz PzGXWZ9AMXwx3PU1Jj0jTTBcq+JkHOX+DGIdO8n1ud7k6JkAsS6srJShgLsLJZn6m+si C6oA== X-Gm-Message-State: AOJu0YwaEmrISc0oDs4tn9jEyo3HBqG/1/PH9lQJ6b7mFs1j9OVD352f Zju/mkDx/q9AJ4cYiS7eEzxBeQ== X-Received: by 2002:a5d:6b11:0:b0:323:1d0a:5562 with SMTP id v17-20020a5d6b11000000b003231d0a5562mr9559403wrw.6.1696870672140; Mon, 09 Oct 2023 09:57:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:57:51 -0700 (PDT) From: Max Kellermann To: MyungJoo Ham , Chanwoo Choi Cc: Max Kellermann , linux-kernel@vger.kernel.org Subject: [PATCH 3/7] drivers/extcon: add local variable for newly allocated attribute_group** Date: Mon, 9 Oct 2023 18:57:36 +0200 Message-Id: <20231009165741.746184-3-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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:58:21 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297899608649069 X-GMAIL-MSGID: 1779297899608649069 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/extcon/extcon.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 6f7a60d2ed91..e879690d4fef 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1202,6 +1202,7 @@ static int extcon_alloc_muex(struct extcon_dev *edev) */ static int extcon_alloc_groups(struct extcon_dev *edev) { + const struct attribute_group **groups; int index; if (!edev) @@ -1210,20 +1211,20 @@ static int extcon_alloc_groups(struct extcon_dev *edev) if (!edev->max_supported) return 0; - edev->extcon_dev_type.groups = kcalloc(edev->max_supported + 2, - sizeof(*edev->extcon_dev_type.groups), + edev->extcon_dev_type.groups = groups = kcalloc(edev->max_supported + 2, + sizeof(*groups), GFP_KERNEL); - if (!edev->extcon_dev_type.groups) + if (!groups) return -ENOMEM; edev->extcon_dev_type.name = dev_name(&edev->dev); edev->extcon_dev_type.release = dummy_sysfs_dev_release; for (index = 0; index < edev->max_supported; index++) - edev->extcon_dev_type.groups[index] = &edev->cables[index].attr_g; + groups[index] = &edev->cables[index].attr_g; if (edev->mutually_exclusive) - edev->extcon_dev_type.groups[index] = &edev->attr_g_muex; + groups[index] = &edev->attr_g_muex; edev->dev.type = &edev->extcon_dev_type; 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; From patchwork Mon Oct 9 16:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2001023vqo; Mon, 9 Oct 2023 09:58:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYTv7uwXuq/6wzFuzaMY0+wIPZBvgDEohq6KXT0V2ggSJ3IDfly7IcHGMQ3mA8R6HdFiU6 X-Received: by 2002:a05:6358:41a:b0:164:8225:83a8 with SMTP id 26-20020a056358041a00b00164822583a8mr7366713rwd.0.1696870701249; Mon, 09 Oct 2023 09:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870701; cv=none; d=google.com; s=arc-20160816; b=WoJCX7UC6djYUnXRIqYDlpgs0IycTWk1Z3CzzE6ROcpkWLWZJhZxlW8BvYF9EOUmHr w9m2o6J97tu7hGwwnCjMELPcK/SwqYxPkwky0YpYFEsdrdXRxgEgumgKKV2oPiWxX28x kBVRebG0fhCY7bMNzwN7FYIaqUxtloZFtyw1nCkjXehcaSF9UzQnlPpAgf+0erc6clre zJx70/c2PN/YpGCHr+RlnZmfYdaTQrn95I2phgFwZNbpREonWrGgoy1QSIfW5hN+ktMN csgAxSqwrMR359tAGbDpXNEF8xXoMAItbBKPvFLmJQRqsNbMDs9BAJqPKKJReYd/rQvX LtQw== 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=I7+J+nUrKbyMvawtQTntvidw+Zsr1uIeHfIIaD4oAvY=; fh=naTd8YvlVzacRDDJQTsZHEGD90SEkvLzbYNaVK0oPGU=; b=bcSw9SmograShwWxPBMk9TkjZqZ5LLYnASCEgMFyTBWl8gTiHtd6CQQISizv0cWcK1 mTQSjQAOanMiG5xaDuh3smhOlBsVBJM/1nS5a/vU9BBvM0iG515KDz4YIYcLr8mtdzqW g5gDO7BivcwbwfknEnW9zKzGw1h/MyZFMOPQ7h99zDUdHKOaW8I8gjRUgf8cSmEagZjB mOspewBdxSa/NGbZO6tZNahZR2akTNacJkkCzXiFHOpBtX9tbGdXOcDbqprl9+hr/McM 7ab5KyLiBUyyWDZM2EIiL1Ic4oiLmw6nuaMAcoXzraBvaa9JjyzB7Fr4p0sTm99/T8Ub tqfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Aufp1Hk3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id y7-20020a636407000000b0057821ea0674si10439965pgb.812.2023.10.09.09.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Aufp1Hk3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 F0A698028F9E; 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 S1377848AbjJIQ6G (ORCPT + 18 others); Mon, 9 Oct 2023 12:58:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377753AbjJIQ54 (ORCPT ); Mon, 9 Oct 2023 12:57:56 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88219D for ; Mon, 9 Oct 2023 09:57:55 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31c5cac3ae2so4326118f8f.3 for ; Mon, 09 Oct 2023 09:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870674; x=1697475474; 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=I7+J+nUrKbyMvawtQTntvidw+Zsr1uIeHfIIaD4oAvY=; b=Aufp1Hk3lgohXDgybb8nz5yFHPTAFEirM9xUWWNAkdB53DGRHVGISI+ukMBCv0A7BK jGqKObvJDU/XidDJTA/DZXeQ8XOWuScLoGK8X/ldkwVe0BY3Ug34DXoLgQzflX6KPjul /22eqZIO7kUkecYFxTKONV6E8VBAytzo/ot3JxIobU3BQpx2a2fpOoW//Q2YG8TUX9rC jFyDgiqzp2tbeIsHY3H4jkiurNby+vN2nvg4xmLNMWn8aTxw9IefFNxA2alzck3epKzd alhIrZmWMIczhH5TKYO0x/kfCBhD0X5WkMWU+Flzs25d1LYZF1NNCEjoV1l4cRVQewec 7Hnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870674; x=1697475474; 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=I7+J+nUrKbyMvawtQTntvidw+Zsr1uIeHfIIaD4oAvY=; b=nB+HQA+1E6stStI/hBwYBskdgdR0dscghNLY1xTTZNOKOFfOafv2TR+b56g83stoZO 8UNVBbe9wzT9Jt/byRS/BZeqHigTOJZ/gzxUyBC0hO4ax+j6j6GSzHUR5Aaa4RxtUT2r YRa6//G7nFcxT5EHVZnF24ufNVLjZNi5KRffjDXsiN8+vm8xyMAzOWcqSbNTaDtKqghi wqW3PJGMZ+VdEuNl1GPU0Cj/+Fi8ju8aIGpiFqoc88LJmT9N8bRaHvSJ+fNydxl4LEYS djAU1Z0bgWHcN0W7yvlwAHgKodP+NZZslzeZYQs+HW0pIpGCUsDkYrlbQtsnZ0rNMUBl 26TQ== X-Gm-Message-State: AOJu0Yy6BdRJG1OfnP5xVmTC2tnwGnUpYNIspDuk7WF5kPZouFHY9jaB W7B0DskfhuKoccdX09Dbk3ILMrqd4ZCPEQQG6+c= X-Received: by 2002:a5d:56c3:0:b0:31f:e32f:a503 with SMTP id m3-20020a5d56c3000000b0031fe32fa503mr12560299wrw.20.1696870674198; Mon, 09 Oct 2023 09:57:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:57:54 -0700 (PDT) From: Max Kellermann To: Greg Kroah-Hartman , Jiri Slaby Cc: Max Kellermann , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 5/7] drivers/tty/serial_core: add local variable for newly allocated attribute_group** Date: Mon, 9 Oct 2023 18:57:38 +0200 Message-Id: <20231009165741.746184-5-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:19 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297892298614855 X-GMAIL-MSGID: 1779297892298614855 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/tty/serial/serial_core.c | 11 ++++++----- include/linux/serial_core.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 7bdc21d5e13b..e253ef474fb4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3082,6 +3082,7 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u struct uart_state *state; struct tty_port *port; int ret = 0; + const struct attribute_group **tty_groups; struct device *tty_dev; int num_groups; @@ -3132,22 +3133,22 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u if (uport->attr_group) num_groups++; - uport->tty_groups = kcalloc(num_groups, sizeof(*uport->tty_groups), + uport->tty_groups = tty_groups = kcalloc(num_groups, sizeof(*tty_groups), GFP_KERNEL); - if (!uport->tty_groups) { + if (!tty_groups) { ret = -ENOMEM; goto out; } - uport->tty_groups[0] = &tty_dev_attr_group; + tty_groups[0] = &tty_dev_attr_group; if (uport->attr_group) - uport->tty_groups[1] = uport->attr_group; + tty_groups[1] = uport->attr_group; /* * Register the port whether it's detected or not. This allows * setserial to be used to alter this port's parameters. */ tty_dev = tty_port_register_device_attr_serdev(port, drv->tty_driver, - uport->line, uport->dev, port, uport->tty_groups); + uport->line, uport->dev, port, tty_groups); if (!IS_ERR(tty_dev)) { device_set_wakeup_capable(tty_dev, 1); } else { diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index bb6f073bc159..597de109dbf5 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -578,8 +578,8 @@ struct uart_port { unsigned char suspended; unsigned char console_reinit; const char *name; /* port name */ - struct attribute_group *attr_group; /* port specific attributes */ - const struct attribute_group **tty_groups; /* all attributes (serial core use only) */ + const struct attribute_group *attr_group; /* port specific attributes */ + const struct attribute_group *const*tty_groups; /* all attributes (serial core use only) */ struct serial_rs485 rs485; struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */ struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */ From patchwork Mon Oct 9 16:57:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2001094vqo; Mon, 9 Oct 2023 09:58:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJOAr9xCEao9mgNrzxCPISsjcOhnZzCvC5oqoGxOfCjSSl2e7MEKM60RpIRU/j6nsHPm3c X-Received: by 2002:a17:90b:4b06:b0:273:e689:8dfc with SMTP id lx6-20020a17090b4b0600b00273e6898dfcmr13504853pjb.32.1696870708789; Mon, 09 Oct 2023 09:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870708; cv=none; d=google.com; s=arc-20160816; b=ezYIAETk10EUxUCzcJV3hCXKpcFMBjZd6W+NptQVxd8gmho0VemhJ9PZXkgJ3OL8bY Ru0DSKoNydxudOpkKq1BB2qbRIw/et9gNOWzEC89pGZcKBQ5XrLrpFX/fmgF+VEdF1Bi vwR81PqpCOcxd8r9/6rVeZ7pzkSJVe1iMwo+2jJsJImWNOSPbSKgYieoOJJy2t+m1Okj wwWXG8Xt9SnqomfYojHNxOjyeijXB+/MHRbBZv7QLksNOA5RWliJSAg0k1v491Vj7msV W64vJ2hwTqf6R+9y6gqJweIHDPjy6qzi5sed0Dw6zCLRj+uRjxwCk3KKh4pFMr55aR1D YMxg== 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=1fGEDKmvpwz1xyuvst+pSH7DqilbUjJUGxnttYPFgHE=; fh=81UE/Bh6bU7++hvwMiPvRTHE2p6x60U4vkK4u0P00hk=; b=XkdNMbNKQUsyvJVNN05XxDYXQq2McDMES7DmslteU4vsYrReAE2pwgMJeF+Ls3v9jx hp60NfyhKZplnGfx9qxpNl3ITqw97XiVDGNHdiafDGWctmOJvVSpJ2ImpUspAlofwT1g FECWMgvtsvUXoP3Jb/V3vqkHe7RtO4Euqt3XCW36xzXKdCkcKlsgck4VBWax8SE/aoRe agd/Qr8k1DmLbnjDTC71KOihD++7hba2jG41hPFwZiekqr9hggN9pwMbjLzckePx/AEY qvDlAZVZZK8cS8mhB6KHI/G1S+EnO4zW5kjxHnVEmQcyYZ2stOW/GLDkUp8DSIF54HKL ryYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WKd5Spu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id fs8-20020a17090af28800b00278fe0b91edsi11781278pjb.56.2023.10.09.09.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WKd5Spu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 05483801D0EF; Mon, 9 Oct 2023 09:58:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377711AbjJIQ6R (ORCPT + 18 others); Mon, 9 Oct 2023 12:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377781AbjJIQ6M (ORCPT ); Mon, 9 Oct 2023 12:58:12 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4940710F for ; Mon, 9 Oct 2023 09:58:05 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32329d935d4so4333375f8f.2 for ; Mon, 09 Oct 2023 09:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870684; x=1697475484; 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=1fGEDKmvpwz1xyuvst+pSH7DqilbUjJUGxnttYPFgHE=; b=WKd5Spu6K0x9fmdgnJFqll07QmERoj6j3OEVVu1ZSaS6hZfEZS9cCU2l982Gihauu9 lbbbIvRcvPScIoJl4tM0KS9KbAqKyNmcEYiJHasTeD5X0rJMNv+ByVyuqMrvfip3P3Zi cM5X2NWxq3blGIa2gaC6XMuWaOObPLZHs6SNKiRYcm+23ZW37CjGxPWG7uJqKVBOELKz 8uHaXWO+1xMO71aFG94Edo1nX4h5FM1SQlFoLDUa5m6AWJ8ouFz49Odp4JFKHLYKAPl7 3aGvqF6I5VFvC5Fjo0VvBq2j+ppp0AtUPAMgGkxFOGrNNXYIDUNIBUh9T8X7fqnIMWUJ g8uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870684; x=1697475484; 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=1fGEDKmvpwz1xyuvst+pSH7DqilbUjJUGxnttYPFgHE=; b=W4xMs/maXweu07EBlYIlzuU3q3/581FoK3MmzP/Y2oCiA75GAjnUoUjGcjM1KMWvfF ZgcgtFeiqfEofhuHZrz0vDEiagZ6pZVkokbmK3D/uUgzkuWuSsFnZAewmiFBkosZjZ7a xwpQ3llsKxJdc3YJp4roHeujYC805/oFjLMxj8xY4MIaK/+JoOFsTcUGD/YPv8tbF515 Y33PJEseyGsSDn8gW0bl0J885uM2oAQnjcDkDNVRRX2BSR++wLpYhDVSb5IAvjilqkUQ VG/iLdimRLykmNF57VzwzKkjnTHu66VUw331pXxiH8BTkKVm3xwL9+bcUGFdfFfaeAQg mAuQ== X-Gm-Message-State: AOJu0YzqZIwAD/k5ejOvarSxvvCkZ9EfWZQWNZXTwuTr5lFzIVIzBRZQ yyc4piLHb/jPe/Pv9W4BN1zgWQ== X-Received: by 2002:a5d:58c2:0:b0:319:7a9f:c63 with SMTP id o2-20020a5d58c2000000b003197a9f0c63mr14278217wrf.50.1696870683538; Mon, 09 Oct 2023 09:58:03 -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.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:03 -0700 (PDT) From: Max Kellermann To: Jens Axboe , Greg Kroah-Hartman , "Rafael J. Wysocki" , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Jean Delvare , Guenter Roeck , Jason Gunthorpe , Leon Romanovsky , Bart Van Assche , Joerg Roedel , Will Deacon , Robin Murphy , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Keith Busch , Christoph Hellwig , Sagi Grimberg , Alessandro Zummo , Alexandre Belloni , Jiri Slaby , Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , Thomas Gleixner , Peter Zijlstra , Pavel Machek , Lee Jones , Arnd Bergmann , Bjorn Helgaas , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Sebastian Reichel , Krzysztof Kozlowski , Wim Van Sebroeck , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Max Kellermann , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-rtc@vger.kernel.org, linux-serial@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-leds@vger.kernel.org, linux-pci@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH 6/7] fs/sysfs/group: make attribute_group pointers const Date: Mon, 9 Oct 2023 18:57:39 +0200 Message-Id: <20231009165741.746184-6-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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:58:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297900746974666 X-GMAIL-MSGID: 1779297900746974666 This allows passing arrays of const pointers. The goal is to make lots of global variables "const" to allow them to live in the ".rodata" section. Signed-off-by: Max Kellermann --- block/genhd.c | 2 +- drivers/base/base.h | 4 ++-- drivers/base/bus.c | 6 +++--- drivers/base/cacheinfo.c | 4 ++-- drivers/base/core.c | 14 +++++++------- drivers/base/cpu.c | 4 ++-- drivers/base/driver.c | 4 ++-- drivers/edac/edac_mc.c | 2 +- drivers/edac/edac_mc.h | 2 +- drivers/edac/edac_mc_sysfs.c | 2 +- drivers/edac/edac_module.h | 2 +- drivers/hwmon/hwmon.c | 12 ++++++------ drivers/hwmon/pmbus/pmbus.h | 2 +- drivers/infiniband/core/core_priv.h | 4 ++-- drivers/infiniband/core/sysfs.c | 4 ++-- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- drivers/iommu/iommu-sysfs.c | 2 +- drivers/nvdimm/dimm_devs.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/rtc/rtc-core.h | 4 ++-- drivers/rtc/sysfs.c | 6 +++--- drivers/tty/tty_io.c | 2 +- drivers/tty/tty_port.c | 4 ++-- fs/sysfs/group.c | 10 +++++----- include/linux/blkdev.h | 2 +- include/linux/coresight.h | 2 +- include/linux/cpu.h | 2 +- include/linux/device.h | 16 ++++++++-------- include/linux/device/bus.h | 6 +++--- include/linux/device/class.h | 4 ++-- include/linux/device/driver.h | 4 ++-- include/linux/hwmon.h | 8 ++++---- include/linux/iommu.h | 4 ++-- include/linux/kobject.h | 2 +- include/linux/leds.h | 4 ++-- include/linux/libnvdimm.h | 8 ++++---- include/linux/miscdevice.h | 2 +- include/linux/pci.h | 4 ++-- include/linux/perf_event.h | 2 +- include/linux/power_supply.h | 2 +- include/linux/rtc.h | 4 ++-- include/linux/sysfs.h | 16 ++++++++-------- include/linux/tty_driver.h | 2 +- include/linux/tty_port.h | 4 ++-- include/linux/usb.h | 4 ++-- include/linux/w1.h | 2 +- include/linux/watchdog.h | 2 +- include/rdma/ib_verbs.h | 2 +- include/scsi/scsi_host.h | 4 ++-- 49 files changed, 107 insertions(+), 107 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index cc32a0c704eb..d82560a79b04 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -394,7 +394,7 @@ int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode) * with the kernel. */ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { struct device *ddev = disk_to_dev(disk); diff --git a/drivers/base/base.h b/drivers/base/base.h index eb4c0ace9242..a2c011d9a5ca 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -175,8 +175,8 @@ static inline void dev_sync_state(struct device *dev) dev->driver->sync_state(dev); } -int driver_add_groups(struct device_driver *drv, const struct attribute_group **groups); -void driver_remove_groups(struct device_driver *drv, const struct attribute_group **groups); +int driver_add_groups(struct device_driver *drv, const struct attribute_group *const*groups); +void driver_remove_groups(struct device_driver *drv, const struct attribute_group *const*groups); void device_driver_detach(struct device *dev); int devres_release_all(struct device *dev); diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 84a21084d67d..d0331d07fffe 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -1195,7 +1195,7 @@ static void system_root_device_release(struct device *dev) } static int subsys_register(struct bus_type *subsys, - const struct attribute_group **groups, + const struct attribute_group *const*groups, struct kobject *parent_of_root) { struct subsys_private *sp; @@ -1265,7 +1265,7 @@ static int subsys_register(struct bus_type *subsys, * /sys/devices/system/. */ int subsys_system_register(struct bus_type *subsys, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return subsys_register(subsys, groups, &system_kset->kobj); } @@ -1283,7 +1283,7 @@ EXPORT_SYMBOL_GPL(subsys_system_register); * constructs which need sysfs interface. */ int subsys_virtual_register(struct bus_type *subsys, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { struct kobject *virtual_dir; diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index cbae8be1fe52..b91c31c2a393 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -803,7 +803,7 @@ __weak cache_get_priv_group(struct cacheinfo *this_leaf) return NULL; } -static const struct attribute_group ** +static const struct attribute_group *const* cache_get_attribute_groups(struct cacheinfo *this_leaf) { const struct attribute_group *priv_group = @@ -868,7 +868,7 @@ static int cache_add_dev(unsigned int cpu) int rc; struct device *ci_dev, *parent; struct cacheinfo *this_leaf; - const struct attribute_group **cache_groups; + const struct attribute_group *const*cache_groups; rc = cpu_cache_sysfs_init(cpu); if (unlikely(rc < 0)) diff --git a/drivers/base/core.c b/drivers/base/core.c index 4d8b315c48a1..b0debc3b751d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2721,14 +2721,14 @@ static ssize_t removable_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(removable); -int device_add_groups(struct device *dev, const struct attribute_group **groups) +int device_add_groups(struct device *dev, const struct attribute_group *const*groups) { return sysfs_create_groups(&dev->kobj, groups); } EXPORT_SYMBOL_GPL(device_add_groups); void device_remove_groups(struct device *dev, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { sysfs_remove_groups(&dev->kobj, groups); } @@ -2736,7 +2736,7 @@ EXPORT_SYMBOL_GPL(device_remove_groups); union device_attr_group_devres { const struct attribute_group *group; - const struct attribute_group **groups; + const struct attribute_group *const*groups; }; static void devm_attr_group_remove(struct device *dev, void *res) @@ -2751,7 +2751,7 @@ static void devm_attr_group_remove(struct device *dev, void *res) static void devm_attr_groups_remove(struct device *dev, void *res) { union device_attr_group_devres *devres = res; - const struct attribute_group **groups = devres->groups; + const struct attribute_group *const*groups = devres->groups; dev_dbg(dev, "%s: removing groups %p\n", __func__, groups); sysfs_remove_groups(&dev->kobj, groups); @@ -2803,7 +2803,7 @@ EXPORT_SYMBOL_GPL(devm_device_add_group); * Returns 0 on success or error code from sysfs_create_group on failure. */ int devm_device_add_groups(struct device *dev, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { union device_attr_group_devres *devres; int error; @@ -4281,7 +4281,7 @@ static void device_create_release(struct device *dev) static __printf(6, 0) struct device * device_create_groups_vargs(const struct class *class, struct device *parent, dev_t devt, void *drvdata, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, va_list args) { struct device *dev = NULL; @@ -4381,7 +4381,7 @@ EXPORT_SYMBOL_GPL(device_create); struct device *device_create_with_groups(const struct class *class, struct device *parent, dev_t devt, void *drvdata, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, ...) { va_list vargs; diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 9ea22e165acd..bd51cb4e6e8c 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -434,7 +434,7 @@ static void device_create_release(struct device *dev) __printf(4, 0) static struct device * __cpu_device_create(struct device *parent, void *drvdata, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, va_list args) { struct device *dev = NULL; @@ -467,7 +467,7 @@ __cpu_device_create(struct device *parent, void *drvdata, } struct device *cpu_device_create(struct device *parent, void *drvdata, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, ...) { va_list vargs; diff --git a/drivers/base/driver.c b/drivers/base/driver.c index c8436c26ed6a..770bc8543f46 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -200,13 +200,13 @@ void driver_remove_file(struct device_driver *drv, EXPORT_SYMBOL_GPL(driver_remove_file); int driver_add_groups(struct device_driver *drv, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return sysfs_create_groups(&drv->p->kobj, groups); } void driver_remove_groups(struct device_driver *drv, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { sysfs_remove_groups(&drv->p->kobj, groups); } diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index 6faeb2ab3960..766ba8ac4f47 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -598,7 +598,7 @@ EXPORT_SYMBOL_GPL(edac_get_owner); /* FIXME - should a warning be printed if no error detection? correction? */ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { int ret = -EINVAL; edac_dbg(0, "\n"); diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h index 881b00eadf7a..0ded68555d1c 100644 --- a/drivers/edac/edac_mc.h +++ b/drivers/edac/edac_mc.h @@ -146,7 +146,7 @@ extern const char *edac_get_owner(void); * 0 on Success, or an error code on failure */ extern int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, - const struct attribute_group **groups); + const struct attribute_group *const*groups); #define edac_mc_add_mc(mci) edac_mc_add_mc_with_groups(mci, NULL) /** diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 15f63452a9be..9ef2b139d8ae 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -931,7 +931,7 @@ static const struct device_type mci_attr_type = { * !0 Failure */ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { struct dimm_info *dimm; int err; diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index 47593afdc234..734673339be5 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h @@ -27,7 +27,7 @@ int edac_mc_sysfs_init(void); void edac_mc_sysfs_exit(void); extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, - const struct attribute_group **groups); + const struct attribute_group *const*groups); extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci); extern int edac_mc_get_log_ue(void); extern int edac_mc_get_log_ce(void); diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index e50ab229b27d..d0305eaefa8b 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -37,7 +37,7 @@ struct hwmon_device { const struct hwmon_chip_info *chip; struct list_head tzdata; struct attribute_group group; - const struct attribute_group **groups; + const struct attribute_group *const*groups; }; #define to_hwmon_device(d) container_of(d, struct hwmon_device, dev) @@ -756,7 +756,7 @@ __hwmon_create_attrs(const void *drvdata, const struct hwmon_chip_info *chip) static struct device * __hwmon_device_register(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *chip, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { struct hwmon_device *hwdev; const char *label; @@ -884,7 +884,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, struct device * hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { if (!name) return ERR_PTR(-EINVAL); @@ -911,7 +911,7 @@ struct device * hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *chip, - const struct attribute_group **extra_groups) + const struct attribute_group *const*extra_groups) { if (!dev || !name || !chip) return ERR_PTR(-EINVAL); @@ -1004,7 +1004,7 @@ static void devm_hwmon_release(struct device *dev, void *res) struct device * devm_hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { struct device **ptr, *hwdev; @@ -1044,7 +1044,7 @@ struct device * devm_hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *chip, - const struct attribute_group **extra_groups) + const struct attribute_group *const*extra_groups) { struct device **ptr, *hwdev; diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index b0832a4c690d..bf039994b84f 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -456,7 +456,7 @@ struct pmbus_driver_info { const struct regulator_desc *reg_desc; /* custom attributes */ - const struct attribute_group **groups; + const struct attribute_group *const*groups; }; /* Regulator ops */ diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index f66f48d860ec..d4a444e52743 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h @@ -351,9 +351,9 @@ int ib_setup_device_attrs(struct ib_device *ibdev); int rdma_compatdev_set(u8 enable); int ib_port_register_client_groups(struct ib_device *ibdev, u32 port_num, - const struct attribute_group **groups); + const struct attribute_group *const*groups); void ib_port_unregister_client_groups(struct ib_device *ibdev, u32 port_num, - const struct attribute_group **groups); + const struct attribute_group *const*groups); int ib_device_set_netns_put(struct sk_buff *skb, struct ib_device *dev, u32 ns_fd); diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index ee59d7391568..fdd15d6a9c2f 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -1464,7 +1464,7 @@ int ib_setup_port_attrs(struct ib_core_device *coredev) * Do not use. Only for legacy sysfs compatibility. */ int ib_port_register_client_groups(struct ib_device *ibdev, u32 port_num, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return sysfs_create_groups(&ibdev->port_data[port_num].sysfs->kobj, groups); @@ -1472,7 +1472,7 @@ int ib_port_register_client_groups(struct ib_device *ibdev, u32 port_num, EXPORT_SYMBOL(ib_port_register_client_groups); void ib_port_unregister_client_groups(struct ib_device *ibdev, u32 port_num, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return sysfs_remove_groups(&ibdev->port_data[port_num].sysfs->kobj, groups); diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 2916e77f589b..0633b17fc082 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1021,7 +1021,7 @@ static int srp_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd) */ static void srp_del_scsi_host_attr(struct Scsi_Host *shost) { - const struct attribute_group **g; + const struct attribute_group *const*g; struct attribute **attr; for (g = shost->hostt->shost_groups; *g; ++g) { diff --git a/drivers/iommu/iommu-sysfs.c b/drivers/iommu/iommu-sysfs.c index cbe378c34ba3..ef92144b679f 100644 --- a/drivers/iommu/iommu-sysfs.c +++ b/drivers/iommu/iommu-sysfs.c @@ -53,7 +53,7 @@ postcore_initcall(iommu_dev_init); */ int iommu_device_sysfs_add(struct iommu_device *iommu, struct device *parent, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, ...) { va_list vargs; diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c index 1273873582be..924dfc43f94c 100644 --- a/drivers/nvdimm/dimm_devs.c +++ b/drivers/nvdimm/dimm_devs.c @@ -580,7 +580,7 @@ bool is_nvdimm(const struct device *dev) static struct lock_class_key nvdimm_key; struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus, - void *provider_data, const struct attribute_group **groups, + void *provider_data, const struct attribute_group *const*groups, unsigned long flags, unsigned long cmd_mask, int num_flush, struct resource *flush_wpq, const char *dimm_id, const struct nvdimm_security_ops *sec_ops, diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index f35647c470af..90d0a1892b23 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -524,7 +524,7 @@ struct nvme_ctrl_ops { #define NVME_F_METADATA_SUPPORTED (1 << 1) #define NVME_F_BLOCKING (1 << 2) - const struct attribute_group **dev_attr_groups; + const struct attribute_group *const*dev_attr_groups; int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val); int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val); int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val); diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h index 4b10a1b8f370..d21a967914dc 100644 --- a/drivers/rtc/rtc-core.h +++ b/drivers/rtc/rtc-core.h @@ -34,9 +34,9 @@ static inline void rtc_proc_del_device(struct rtc_device *rtc) #endif #ifdef CONFIG_RTC_INTF_SYSFS -const struct attribute_group **rtc_get_dev_attribute_groups(void); +const struct attribute_group *const*rtc_get_dev_attribute_groups(void); #else -static inline const struct attribute_group **rtc_get_dev_attribute_groups(void) +static inline const struct attribute_group *const*rtc_get_dev_attribute_groups(void) { return NULL; } diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c index 617933d52324..9c45c2557e28 100644 --- a/drivers/rtc/sysfs.c +++ b/drivers/rtc/sysfs.c @@ -308,7 +308,7 @@ static const struct attribute_group *rtc_attr_groups[] = { NULL }; -const struct attribute_group **rtc_get_dev_attribute_groups(void) +const struct attribute_group *const*rtc_get_dev_attribute_groups(void) { return rtc_attr_groups; } @@ -322,10 +322,10 @@ static size_t count_attribute_groups(const struct attribute_group *const*groups) return count; } -int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) +int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group *const*grps) { size_t old_cnt, add_cnt, new_cnt; - const struct attribute_group **groups, **old; + const struct attribute_group **groups, *const *old; if (!grps) return -EINVAL; diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 8a94e5a43c6d..2bbc193a6f47 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3212,7 +3212,7 @@ static void tty_device_create_release(struct device *dev) struct device *tty_register_device_attr(struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, - const struct attribute_group **attr_grp) + const struct attribute_group *const*attr_grp) { char name[64]; dev_t devt = MKDEV(driver->major, driver->minor_start) + index; diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 624d104bd145..f0f95e64ca64 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(tty_port_register_device); struct device *tty_port_register_device_attr(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, - const struct attribute_group **attr_grp) + const struct attribute_group *const*attr_grp) { tty_port_link_device(port, driver, index); return tty_register_device_attr(driver, index, device, drvdata, @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(tty_port_register_device_attr); struct device *tty_port_register_device_attr_serdev(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, - const struct attribute_group **attr_grp) + const struct attribute_group *const*attr_grp) { struct device *dev; diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 138676463336..4e14df4da39d 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -180,7 +180,7 @@ int sysfs_create_group(struct kobject *kobj, EXPORT_SYMBOL_GPL(sysfs_create_group); static int internal_create_groups(struct kobject *kobj, int update, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { int error = 0; int i; @@ -213,7 +213,7 @@ static int internal_create_groups(struct kobject *kobj, int update, * Returns 0 on success or error code from sysfs_create_group on failure. */ int sysfs_create_groups(struct kobject *kobj, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return internal_create_groups(kobj, 0, groups); } @@ -231,7 +231,7 @@ EXPORT_SYMBOL_GPL(sysfs_create_groups); * Returns 0 on success or error code from sysfs_update_group on failure. */ int sysfs_update_groups(struct kobject *kobj, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return internal_create_groups(kobj, 1, groups); } @@ -306,7 +306,7 @@ EXPORT_SYMBOL_GPL(sysfs_remove_group); * If groups is not NULL, remove the specified groups from the kobject. */ void sysfs_remove_groups(struct kobject *kobj, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { int i; @@ -561,7 +561,7 @@ EXPORT_SYMBOL_GPL(sysfs_group_change_owner); * Returns 0 on success or error code on failure. */ int sysfs_groups_change_owner(struct kobject *kobj, - const struct attribute_group **groups, + const struct attribute_group *const*groups, kuid_t kuid, kgid_t kgid) { int error = 0, i; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index eef450f25982..7917b072775e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -729,7 +729,7 @@ static inline unsigned int blk_queue_depth(struct request_queue *q) for (; _bio; _bio = _bio->bi_next) int __must_check device_add_disk(struct device *parent, struct gendisk *disk, - const struct attribute_group **groups); + const struct attribute_group *const*groups); static inline int __must_check add_disk(struct gendisk *disk) { return device_add_disk(NULL, disk, NULL); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index a269fffaf991..5dbe3883c02f 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -157,7 +157,7 @@ struct coresight_desc { const struct coresight_ops *ops; struct coresight_platform_data *pdata; struct device *dev; - const struct attribute_group **groups; + const struct attribute_group *const*groups; const char *name; struct csdev_access access; }; diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 0abd60a7987b..612955f50ed7 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -78,7 +78,7 @@ extern ssize_t cpu_show_gds(struct device *dev, extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, ...); #ifdef CONFIG_HOTPLUG_CPU extern void unregister_cpu(struct cpu *cpu); diff --git a/include/linux/device.h b/include/linux/device.h index 56d93a1ffb7b..cf6ee60ecdb4 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -73,9 +73,9 @@ int subsys_interface_register(struct subsys_interface *sif); void subsys_interface_unregister(struct subsys_interface *sif); int subsys_system_register(struct bus_type *subsys, - const struct attribute_group **groups); + const struct attribute_group *const*groups); int subsys_virtual_register(struct bus_type *subsys, - const struct attribute_group **groups); + const struct attribute_group *const*groups); /* * The type of device, "struct device" is embedded in. A class @@ -88,7 +88,7 @@ int subsys_virtual_register(struct bus_type *subsys, */ struct device_type { const char *name; - const struct attribute_group **groups; + const struct attribute_group *const*groups; int (*uevent)(const struct device *dev, struct kobj_uevent_env *env); char *(*devnode)(const struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid); @@ -782,7 +782,7 @@ struct device { struct list_head devres_head; const struct class *class; - const struct attribute_group **groups; /* optional groups */ + const struct attribute_group *const*groups; /* optional groups */ void (*release)(struct device *dev); struct iommu_group *iommu_group; @@ -1177,14 +1177,14 @@ device_create(const struct class *cls, struct device *parent, dev_t devt, void *drvdata, const char *fmt, ...); __printf(6, 7) struct device * device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt, - void *drvdata, const struct attribute_group **groups, + void *drvdata, const struct attribute_group *const*groups, const char *fmt, ...); void device_destroy(const struct class *cls, dev_t devt); int __must_check device_add_groups(struct device *dev, - const struct attribute_group **groups); + const struct attribute_group *const*groups); void device_remove_groups(struct device *dev, - const struct attribute_group **groups); + const struct attribute_group *const*groups); static inline int __must_check device_add_group(struct device *dev, const struct attribute_group *grp) @@ -1203,7 +1203,7 @@ static inline void device_remove_group(struct device *dev, } int __must_check devm_device_add_groups(struct device *dev, - const struct attribute_group **groups); + const struct attribute_group *const*groups); int __must_check devm_device_add_group(struct device *dev, const struct attribute_group *grp); diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h index ae10c4322754..5867948b64ca 100644 --- a/include/linux/device/bus.h +++ b/include/linux/device/bus.h @@ -80,9 +80,9 @@ struct fwnode_handle; struct bus_type { const char *name; const char *dev_name; - const struct attribute_group **bus_groups; - const struct attribute_group **dev_groups; - const struct attribute_group **drv_groups; + const struct attribute_group *const*bus_groups; + const struct attribute_group *const*dev_groups; + const struct attribute_group *const*drv_groups; int (*match)(struct device *dev, struct device_driver *drv); int (*uevent)(const struct device *dev, struct kobj_uevent_env *env); diff --git a/include/linux/device/class.h b/include/linux/device/class.h index abf3d3bfb6fe..649020a67b87 100644 --- a/include/linux/device/class.h +++ b/include/linux/device/class.h @@ -52,8 +52,8 @@ struct fwnode_handle; struct class { const char *name; - const struct attribute_group **class_groups; - const struct attribute_group **dev_groups; + const struct attribute_group *const*class_groups; + const struct attribute_group *const*dev_groups; int (*dev_uevent)(const struct device *dev, struct kobj_uevent_env *env); char *(*devnode)(const struct device *dev, umode_t *mode); diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7738f458995f..cb8171124bbf 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -112,8 +112,8 @@ struct device_driver { void (*shutdown) (struct device *dev); int (*suspend) (struct device *dev, pm_message_t state); int (*resume) (struct device *dev); - const struct attribute_group **groups; - const struct attribute_group **dev_groups; + const struct attribute_group *const*groups; + const struct attribute_group *const*dev_groups; const struct dev_pm_ops *pm; void (*coredump) (struct device *dev); diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index 8cd6a6b33593..fa3f3a6be5b5 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -453,16 +453,16 @@ struct device *hwmon_device_register(struct device *dev); struct device * hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, - const struct attribute_group **groups); + const struct attribute_group *const*groups); struct device * devm_hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, - const struct attribute_group **groups); + const struct attribute_group *const*groups); struct device * hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *info, - const struct attribute_group **extra_groups); + const struct attribute_group *const*extra_groups); struct device * hwmon_device_register_for_thermal(struct device *dev, const char *name, void *drvdata); @@ -470,7 +470,7 @@ struct device * devm_hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *info, - const struct attribute_group **extra_groups); + const struct attribute_group *const*extra_groups); void hwmon_device_unregister(struct device *dev); void devm_hwmon_device_unregister(struct device *dev); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c50a769d569a..4169cfca3098 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -441,7 +441,7 @@ int iommu_device_register(struct iommu_device *iommu, void iommu_device_unregister(struct iommu_device *iommu); int iommu_device_sysfs_add(struct iommu_device *iommu, struct device *parent, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, ...) __printf(4, 5); void iommu_device_sysfs_remove(struct iommu_device *iommu); int iommu_device_link(struct iommu_device *iommu, struct device *link); @@ -975,7 +975,7 @@ static inline void iommu_device_unregister(struct iommu_device *iommu) static inline int iommu_device_sysfs_add(struct iommu_device *iommu, struct device *parent, - const struct attribute_group **groups, + const struct attribute_group *const*groups, const char *fmt, ...) { return -ENODEV; diff --git a/include/linux/kobject.h b/include/linux/kobject.h index c30affcc43b4..989afe775880 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -116,7 +116,7 @@ char *kobject_get_path(const struct kobject *kobj, gfp_t flag); struct kobj_type { void (*release)(struct kobject *kobj); const struct sysfs_ops *sysfs_ops; - const struct attribute_group **default_groups; + const struct attribute_group *const*default_groups; const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj); const void *(*namespace)(const struct kobject *kobj); void (*get_ownership)(const struct kobject *kobj, kuid_t *uid, kgid_t *gid); diff --git a/include/linux/leds.h b/include/linux/leds.h index aa16dc2a8230..6d84f5eb0883 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -166,7 +166,7 @@ struct led_classdev { int (*pattern_clear)(struct led_classdev *led_cdev); struct device *dev; - const struct attribute_group **groups; + const struct attribute_group *const*groups; struct list_head node; /* LED Device list */ const char *default_trigger; /* Trigger to use */ @@ -484,7 +484,7 @@ struct led_trigger { /* Link to next registered trigger */ struct list_head next_trig; - const struct attribute_group **groups; + const struct attribute_group *const*groups; }; /* diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h index e772aae71843..7c629ee16215 100644 --- a/include/linux/libnvdimm.h +++ b/include/linux/libnvdimm.h @@ -82,7 +82,7 @@ typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc, struct device_node; struct nvdimm_bus_descriptor { - const struct attribute_group **attr_groups; + const struct attribute_group *const*attr_groups; unsigned long cmd_mask; unsigned long dimm_family_mask; unsigned long bus_family_mask; @@ -126,7 +126,7 @@ struct nd_region_desc { struct resource *res; struct nd_mapping_desc *mapping; u16 num_mappings; - const struct attribute_group **attr_groups; + const struct attribute_group *const*attr_groups; struct nd_interleave_set *nd_set; void *provider_data; int num_lanes; @@ -259,13 +259,13 @@ struct kobject *nvdimm_kobj(struct nvdimm *nvdimm); unsigned long nvdimm_cmd_mask(struct nvdimm *nvdimm); void *nvdimm_provider_data(struct nvdimm *nvdimm); struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus, - void *provider_data, const struct attribute_group **groups, + void *provider_data, const struct attribute_group *const*groups, unsigned long flags, unsigned long cmd_mask, int num_flush, struct resource *flush_wpq, const char *dimm_id, const struct nvdimm_security_ops *sec_ops, const struct nvdimm_fw_ops *fw_ops); static inline struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, - void *provider_data, const struct attribute_group **groups, + void *provider_data, const struct attribute_group *const*groups, unsigned long flags, unsigned long cmd_mask, int num_flush, struct resource *flush_wpq) { diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index c0fea6ca5076..32b0caf86cd1 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h @@ -83,7 +83,7 @@ struct miscdevice { struct list_head list; struct device *parent; struct device *this_device; - const struct attribute_group **groups; + const struct attribute_group *const*groups; const char *nodename; umode_t mode; }; diff --git a/include/linux/pci.h b/include/linux/pci.h index 8c7c2c3c6c65..57dbfd890ae7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -928,8 +928,8 @@ struct pci_driver { int (*sriov_set_msix_vec_count)(struct pci_dev *vf, int msix_vec_count); /* On PF */ u32 (*sriov_get_vf_total_msix)(struct pci_dev *pf); const struct pci_error_handlers *err_handler; - const struct attribute_group **groups; - const struct attribute_group **dev_groups; + const struct attribute_group *const*groups; + const struct attribute_group *const*dev_groups; struct device_driver driver; struct pci_dynids dynids; bool driver_managed_dma; diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index e85cd1c0eaf3..e9d68c611974 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -306,7 +306,7 @@ struct pmu { struct device *dev; struct device *parent; const struct attribute_group **attr_groups; - const struct attribute_group **attr_update; + const struct attribute_group *const*attr_update; const char *name; int type; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index a427f13c757f..b7f592a20729 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -232,7 +232,7 @@ struct power_supply_config { void *drv_data; /* Device specific sysfs attributes */ - const struct attribute_group **attr_grp; + const struct attribute_group *const*attr_grp; char **supplied_to; size_t num_supplicants; diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 4c0bcbeb1f00..f72e70186b2f 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -247,7 +247,7 @@ static inline int devm_rtc_nvmem_register(struct rtc_device *rtc, #ifdef CONFIG_RTC_INTF_SYSFS int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp); -int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps); +int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group *const*grps); #else static inline int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp) @@ -256,7 +256,7 @@ int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp) } static inline -int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) +int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group *const*grps) { return 0; } diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index fd3fe5c8c17f..2b97fb34204b 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -307,15 +307,15 @@ void sysfs_delete_link(struct kobject *dir, struct kobject *targ, int __must_check sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp); int __must_check sysfs_create_groups(struct kobject *kobj, - const struct attribute_group **groups); + const struct attribute_group *const*groups); int __must_check sysfs_update_groups(struct kobject *kobj, - const struct attribute_group **groups); + const struct attribute_group *const*groups); int sysfs_update_group(struct kobject *kobj, const struct attribute_group *grp); void sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp); void sysfs_remove_groups(struct kobject *kobj, - const struct attribute_group **groups); + const struct attribute_group *const*groups); int sysfs_add_file_to_group(struct kobject *kobj, const struct attribute *attr, const char *group); void sysfs_remove_file_from_group(struct kobject *kobj, @@ -348,7 +348,7 @@ int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid); int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ, const char *name, kuid_t kuid, kgid_t kgid); int sysfs_groups_change_owner(struct kobject *kobj, - const struct attribute_group **groups, + const struct attribute_group *const*groups, kuid_t kuid, kgid_t kgid); int sysfs_group_change_owner(struct kobject *kobj, const struct attribute_group *groups, kuid_t kuid, @@ -487,13 +487,13 @@ static inline int sysfs_create_group(struct kobject *kobj, } static inline int sysfs_create_groups(struct kobject *kobj, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return 0; } static inline int sysfs_update_groups(struct kobject *kobj, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { return 0; } @@ -510,7 +510,7 @@ static inline void sysfs_remove_group(struct kobject *kobj, } static inline void sysfs_remove_groups(struct kobject *kobj, - const struct attribute_group **groups) + const struct attribute_group *const*groups) { } @@ -591,7 +591,7 @@ static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t k } static inline int sysfs_groups_change_owner(struct kobject *kobj, - const struct attribute_group **groups, + const struct attribute_group *const*groups, kuid_t kuid, kgid_t kgid) { return 0; diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 18beff0cec1a..3041bebb1051 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -571,7 +571,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev); struct device *tty_register_device_attr(struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, - const struct attribute_group **attr_grp); + const struct attribute_group *const*attr_grp); void tty_unregister_device(struct tty_driver *driver, unsigned index); #ifdef CONFIG_PROC_FS diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h index 6b367eb17979..811aa134150c 100644 --- a/include/linux/tty_port.h +++ b/include/linux/tty_port.h @@ -146,14 +146,14 @@ struct device *tty_port_register_device(struct tty_port *port, struct device *tty_port_register_device_attr(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, - const struct attribute_group **attr_grp); + const struct attribute_group *const*attr_grp); struct device *tty_port_register_device_serdev(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device); struct device *tty_port_register_device_attr_serdev(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, - const struct attribute_group **attr_grp); + const struct attribute_group *const*attr_grp); void tty_port_unregister_device(struct tty_port *port, struct tty_driver *driver, unsigned index); int tty_port_alloc_xmit_buf(struct tty_port *port); diff --git a/include/linux/usb.h b/include/linux/usb.h index a21074861f91..321ded34928f 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1239,7 +1239,7 @@ struct usb_driver { int (*post_reset)(struct usb_interface *intf); const struct usb_device_id *id_table; - const struct attribute_group **dev_groups; + const struct attribute_group *const*dev_groups; struct usb_dynids dynids; struct usbdrv_wrap drvwrap; @@ -1287,7 +1287,7 @@ struct usb_device_driver { int (*suspend) (struct usb_device *udev, pm_message_t message); int (*resume) (struct usb_device *udev, pm_message_t message); - const struct attribute_group **dev_groups; + const struct attribute_group *const*dev_groups; struct usbdrv_wrap drvwrap; const struct usb_device_id *id_table; unsigned int supports_autosuspend:1; diff --git a/include/linux/w1.h b/include/linux/w1.h index 9a2a0ef39018..0c86a9ed7013 100644 --- a/include/linux/w1.h +++ b/include/linux/w1.h @@ -253,7 +253,7 @@ void w1_remove_master_device(struct w1_bus_master *master); struct w1_family_ops { int (*add_slave)(struct w1_slave *sl); void (*remove_slave)(struct w1_slave *sl); - const struct attribute_group **groups; + const struct attribute_group *const*groups; const struct hwmon_chip_info *chip_info; }; diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 99660197a36c..1f4a0fae13ab 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -94,7 +94,7 @@ struct watchdog_ops { struct watchdog_device { int id; struct device *parent; - const struct attribute_group **groups; + const struct attribute_group *const*groups; const struct watchdog_info *info; const struct watchdog_ops *ops; const struct watchdog_governor *gov; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 533ab92684d8..1a9511b99506 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2343,7 +2343,7 @@ struct ib_device_ops { * mechanism exists only for existing drivers. */ const struct attribute_group *device_group; - const struct attribute_group **port_groups; + const struct attribute_group *const*port_groups; int (*post_send)(struct ib_qp *qp, const struct ib_send_wr *send_wr, const struct ib_send_wr **bad_send_wr); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 4c2dc8150c6d..c9da91e96232 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -478,13 +478,13 @@ struct scsi_host_template { /* * Pointer to the SCSI host sysfs attribute groups, NULL terminated. */ - const struct attribute_group **shost_groups; + const struct attribute_group *const*shost_groups; /* * Pointer to the SCSI device attribute groups for this host, * NULL terminated. */ - const struct attribute_group **sdev_groups; + const struct attribute_group *const*sdev_groups; /* * Vendor Identifier associated with the host From patchwork Mon Oct 9 16:57:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 150215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2001533vqo; Mon, 9 Oct 2023 09:59:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmP2nZqmvyNIXRwc9wGRsfAurQ6kxuni6UvtEFNVyeRsVSJ9fwoXjlt8pP/yTstAGOH0Ub X-Received: by 2002:a05:6a20:9152:b0:160:83e1:712f with SMTP id x18-20020a056a20915200b0016083e1712fmr18716897pzc.23.1696870755606; Mon, 09 Oct 2023 09:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870755; cv=none; d=google.com; s=arc-20160816; b=u6AFBRR7PonSKYT4Jh3lud/Zw4F3XnoffjrMVscFwUqXntnD0z4G/MM9oA7YYLbEW5 zMX2luw9LiYTJ6hH+0e6HAi86hICI+xtsURK55rW1H9doVHZGG4JHUF4kgDHjg06hdgG RWVqFk32ZyJtbLhZR0zKAcOcWle6PG0E1lRCHF65mNrUF4Fo9aqe3VlWQLdrrheBh+I2 WXUXARaEKPeCLMtlMXCCJbrUk8R+SVEGddZLO79Fs2h82EiwOdxIQUaVLHSZ4OrDTH9p OxESEHOTHkvLq/X/LB3fsgLngKSPjNDynHwU0atVjVRXd22J04SuQIWAhslHHuqamvz8 4nXw== 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=22Ou7Kmf9cNKCIWXUI7bhNPHKqi+qktoDIUHvbRcMX8=; fh=lt48xHA+UaW7Ul83uAyQ7yH263WQwdr6EYMyLL7sNzA=; b=M9JTkjyFe7rG0izjJ0bNWgHzau/yMzFIhurJuEum0zcXFR+WR9l8e33znO164KXqUk YjGKKPX8iLC+wryzln+rdcm9xWLXP7C0KG68+goEF8yw6B298ih93YWeskDPXIsu4mGG YGmTqcUJCqKN2Nn5Kl9pl4xdGCwPoG0nA846hK++tu5fJpf4R5jsvtz4duCUOxNbU7vi /AxWN/altfBfK53nNkH5eMpViBAR6G/bTJt4tkewYW94t/oZHg6BL50CDxcydYinHjwR OVMjbR6d75gzBmgo9sbc0Nyqvh5N+kO0q1xhogqvGhMFycBPg3aW9xLYwSgnizKmOdBz V8LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=JECFaq1m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id eg7-20020a056a00800700b0068e41f07f33si7788122pfb.94.2023.10.09.09.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=JECFaq1m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 2EE81801BAA8; Mon, 9 Oct 2023 09:59:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377890AbjJIQ6V (ORCPT + 18 others); Mon, 9 Oct 2023 12:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377871AbjJIQ6R (ORCPT ); Mon, 9 Oct 2023 12:58:17 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4454D181 for ; Mon, 9 Oct 2023 09:58:09 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40566f8a093so44369685e9.3 for ; Mon, 09 Oct 2023 09:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696870687; x=1697475487; 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=22Ou7Kmf9cNKCIWXUI7bhNPHKqi+qktoDIUHvbRcMX8=; b=JECFaq1mexHaZ4hDpKa1/Tny3Uu5Q6DByCMj10zWwN9mIhUTg8q3EYK1ns5+PFO3ji uVM8d2wwFHlt7gNoe5PkAHQztk+vk5uCHNx+ro8/sM53Bl/NftGk5W8KH+w+E9WEy49d RCIwzZJITdYOfjidnPssSAcXD5O4zUDI9IhUz9e3SXU8N/X3R4hKpq7dKhMcVbr/htHz CVGfUpU73+2g719IAIUMU3rUeBjvVrDp/Y+osFFZY9Ckbp2/5qj+ju4OQg52tuDhJtXp F7n1C2vohleBiL7DSOSr2dlsOu2mtNIRSOWtrV2v3J6eC5xn0qYmMRVliGYRegNF0rH9 yh2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696870687; x=1697475487; 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=22Ou7Kmf9cNKCIWXUI7bhNPHKqi+qktoDIUHvbRcMX8=; b=V5kXoNBg96LmGbKYvvZNCdzympoOS/bCCfNNzOl1m7VDytf9J9yxiHsBPG6X/eKk1a 3SGEmArJ7HZw2qhsy3BnlOCWtx7M9bgYnwIULqbjPz5tzILIVs1rFvYFstzZMF3LYehR mcevDhUpbXc+nowQ7m1LJfkhkFQuFKYNabEl/gPaJ6QTajKsGezGsRKRPMVpU5VdzHLS KGuRq7aWUGTqMuhWfcW0vQ7U1HDjMJ/Ye/6ArtG27BRjpwLDL+pbAD1uUfc/PBkliH5E 512m/pFLXxS8NxL7DkC1c4/TKIAIMNcbIYSByRmKVo1FoxibgXEewLUcVnvBYAbYsCTu eu9w== X-Gm-Message-State: AOJu0YyM0huiisiRdafxQAIV8siyDXNkJKMUZusSX5fztwEiARB73YVF sLYZGWP9R0z4lFNaw16Y4y6HzQ== X-Received: by 2002:a7b:c8d7:0:b0:405:3b92:2fed with SMTP id f23-20020a7bc8d7000000b004053b922fedmr13656996wml.26.1696870687296; Mon, 09 Oct 2023 09:58:07 -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.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:58:06 -0700 (PDT) From: Max Kellermann To: Jens Axboe , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ilya Dryomov , Dongsheng Yang , Dmitry Torokhov , Bjorn Helgaas , Rodolfo Giometti , Alessandro Zummo , Alexandre Belloni , Jiri Slaby , Mark Fasheh , Joel Becker , Joseph Qi , Andrew Morton Cc: Max Kellermann , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-input@vger.kernel.org, linux-pci@vger.kernel.org, linux-rtc@vger.kernel.org, linux-serial@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 7/7] block, drivers: make lots of attribute_group globals const Date: Mon, 9 Oct 2023 18:57:40 +0200 Message-Id: <20231009165741.746184-7-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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:59:13 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779297949393384622 X-GMAIL-MSGID: 1779297949393384622 This moves those variables to the ".rodata" section which reduces the kernel size a bit and protects the variables by putting them on read-only pages at runtime. Signed-off-by: Max Kellermann --- block/blk-sysfs.c | 6 +++--- block/genhd.c | 4 ++-- block/partitions/core.c | 2 +- drivers/base/cacheinfo.c | 2 +- drivers/block/loop.c | 2 +- drivers/block/rbd.c | 4 ++-- drivers/input/input.c | 2 +- drivers/input/serio/serio.c | 2 +- drivers/pci/pci-sysfs.c | 8 ++++---- drivers/pci/pci.h | 6 +++--- drivers/pps/sysfs.c | 2 +- drivers/rtc/sysfs.c | 2 +- drivers/tty/serial/8250/8250_port.c | 2 +- fs/ocfs2/cluster/sys.c | 2 +- include/linux/khugepaged.h | 2 +- include/linux/pps_kernel.h | 2 +- mm/khugepaged.c | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 63e481262336..feea5d68b5a1 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -699,12 +699,12 @@ static umode_t blk_mq_queue_attr_visible(struct kobject *kobj, return attr->mode; } -static struct attribute_group queue_attr_group = { +static const struct attribute_group queue_attr_group = { .attrs = queue_attrs, .is_visible = queue_attr_visible, }; -static struct attribute_group blk_mq_queue_attr_group = { +static const struct attribute_group blk_mq_queue_attr_group = { .attrs = blk_mq_queue_attrs, .is_visible = blk_mq_queue_attr_visible, }; @@ -750,7 +750,7 @@ static const struct sysfs_ops queue_sysfs_ops = { .store = queue_attr_store, }; -static const struct attribute_group *blk_queue_attr_groups[] = { +static const struct attribute_group *const blk_queue_attr_groups[] = { &queue_attr_group, &blk_mq_queue_attr_group, NULL diff --git a/block/genhd.c b/block/genhd.c index d82560a79b04..9fa16e5de6d2 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1115,12 +1115,12 @@ static umode_t disk_visible(struct kobject *kobj, struct attribute *a, int n) return a->mode; } -static struct attribute_group disk_attr_group = { +static const struct attribute_group disk_attr_group = { .attrs = disk_attrs, .is_visible = disk_visible, }; -static const struct attribute_group *disk_attr_groups[] = { +static const struct attribute_group *const disk_attr_groups[] = { &disk_attr_group, #ifdef CONFIG_BLK_DEV_IO_TRACE &blk_trace_attr_group, diff --git a/block/partitions/core.c b/block/partitions/core.c index e137a87f4db0..463298e26757 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -232,7 +232,7 @@ static const struct attribute_group part_attr_group = { .attrs = part_attrs, }; -static const struct attribute_group *part_attr_groups[] = { +static const struct attribute_group *const part_attr_groups[] = { &part_attr_group, #ifdef CONFIG_BLK_DEV_IO_TRACE &blk_trace_attr_group, diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index b91c31c2a393..3642eed8ef74 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -786,7 +786,7 @@ static const struct attribute_group cache_default_group = { .is_visible = cache_default_attrs_is_visible, }; -static const struct attribute_group *cache_default_groups[] = { +static const struct attribute_group *const cache_default_groups[] = { &cache_default_group, NULL, }; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 9f2d412fc560..c1718b17b5ef 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -736,7 +736,7 @@ static struct attribute *loop_attrs[] = { NULL, }; -static struct attribute_group loop_attribute_group = { +static const struct attribute_group loop_attribute_group = { .name = "loop", .attrs= loop_attrs, }; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index a999b698b131..73e616453c34 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -5246,11 +5246,11 @@ static struct attribute *rbd_attrs[] = { NULL }; -static struct attribute_group rbd_attr_group = { +static const struct attribute_group rbd_attr_group = { .attrs = rbd_attrs, }; -static const struct attribute_group *rbd_attr_groups[] = { +static const struct attribute_group *const rbd_attr_groups[] = { &rbd_attr_group, NULL }; diff --git a/drivers/input/input.c b/drivers/input/input.c index 8c5fdb0f858a..d97126d54947 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1597,7 +1597,7 @@ static const struct attribute_group input_dev_caps_attr_group = { .attrs = input_dev_caps_attrs, }; -static const struct attribute_group *input_dev_attr_groups[] = { +static const struct attribute_group *const input_dev_attr_groups[] = { &input_dev_attr_group, &input_dev_id_attr_group, &input_dev_caps_attr_group, diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 767fc9efb4a8..ef82d20572b0 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -474,7 +474,7 @@ static const struct attribute_group serio_device_attr_group = { .attrs = serio_device_attrs, }; -static const struct attribute_group *serio_device_attr_groups[] = { +static const struct attribute_group *const serio_device_attr_groups[] = { &serio_id_attr_group, &serio_device_attr_group, NULL diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index d9eede2dbc0e..f2147da6e4a5 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -455,7 +455,7 @@ static const struct attribute_group pci_bus_group = { .attrs = pci_bus_attrs, }; -const struct attribute_group *pci_bus_groups[] = { +const struct attribute_group *const pci_bus_groups[] = { &pci_bus_group, NULL, }; @@ -647,7 +647,7 @@ static const struct attribute_group pcibus_group = { .attrs = pcibus_attrs, }; -const struct attribute_group *pcibus_groups[] = { +const struct attribute_group *const pcibus_groups[] = { &pcibus_group, NULL, }; @@ -1604,7 +1604,7 @@ static const struct attribute_group pci_dev_group = { .attrs = pci_dev_attrs, }; -const struct attribute_group *pci_dev_groups[] = { +const struct attribute_group *const pci_dev_groups[] = { &pci_dev_group, &pci_dev_config_attr_group, &pci_dev_rom_attr_group, @@ -1641,7 +1641,7 @@ static const struct attribute_group pcie_dev_attr_group = { .is_visible = pcie_dev_attrs_are_visible, }; -static const struct attribute_group *pci_dev_attr_groups[] = { +static const struct attribute_group *const pci_dev_attr_groups[] = { &pci_dev_attr_group, &pci_dev_hp_attr_group, #ifdef CONFIG_PCI_IOV diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 39a8932dc340..046d6c9944cd 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -182,10 +182,10 @@ static inline int pci_no_d1d2(struct pci_dev *dev) return (dev->no_d1d2 || parent_dstates); } -extern const struct attribute_group *pci_dev_groups[]; -extern const struct attribute_group *pcibus_groups[]; +extern const struct attribute_group *const pci_dev_groups[]; +extern const struct attribute_group *const pcibus_groups[]; extern const struct device_type pci_dev_type; -extern const struct attribute_group *pci_bus_groups[]; +extern const struct attribute_group *const pci_bus_groups[]; extern unsigned long pci_hotplug_io_size; extern unsigned long pci_hotplug_mmio_size; diff --git a/drivers/pps/sysfs.c b/drivers/pps/sysfs.c index 134bc33f6ad0..355ce20b6e53 100644 --- a/drivers/pps/sysfs.c +++ b/drivers/pps/sysfs.c @@ -93,7 +93,7 @@ static const struct attribute_group pps_group = { .attrs = pps_attrs, }; -const struct attribute_group *pps_groups[] = { +const struct attribute_group *const pps_groups[] = { &pps_group, NULL, }; diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c index 9c45c2557e28..c126cb706b27 100644 --- a/drivers/rtc/sysfs.c +++ b/drivers/rtc/sysfs.c @@ -303,7 +303,7 @@ static struct attribute_group rtc_attr_group = { .attrs = rtc_attrs, }; -static const struct attribute_group *rtc_attr_groups[] = { +static const struct attribute_group *const rtc_attr_groups[] = { &rtc_attr_group, NULL }; diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 141627370aab..7af8f196e00f 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -3187,7 +3187,7 @@ static struct attribute *serial8250_dev_attrs[] = { NULL }; -static struct attribute_group serial8250_dev_attr_group = { +static const struct attribute_group serial8250_dev_attr_group = { .attrs = serial8250_dev_attrs, }; diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c index 022f716c74ff..63e14ef53610 100644 --- a/fs/ocfs2/cluster/sys.c +++ b/fs/ocfs2/cluster/sys.c @@ -31,7 +31,7 @@ static struct attribute *o2cb_attrs[] = { NULL, }; -static struct attribute_group o2cb_attr_group = { +static const struct attribute_group o2cb_attr_group = { .attrs = o2cb_attrs, }; diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h index f68865e19b0b..85b442e9e638 100644 --- a/include/linux/khugepaged.h +++ b/include/linux/khugepaged.h @@ -5,7 +5,7 @@ #include /* MMF_VM_HUGEPAGE */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE -extern struct attribute_group khugepaged_attr_group; +extern const struct attribute_group khugepaged_attr_group; extern int khugepaged_init(void); extern void khugepaged_destroy(void); diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index 78c8ac4951b5..996db99f983f 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -66,7 +66,7 @@ struct pps_device { * Global variables */ -extern const struct attribute_group *pps_groups[]; +extern const struct attribute_group *const pps_groups[]; /* * Internal functions. diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 88433cc25d8a..cd1b26075d1b 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -339,7 +339,7 @@ static struct attribute *khugepaged_attr[] = { NULL, }; -struct attribute_group khugepaged_attr_group = { +const struct attribute_group khugepaged_attr_group = { .attrs = khugepaged_attr, .name = "khugepaged", };