From patchwork Mon Mar 13 18:18:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 69014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1344735wrd; Mon, 13 Mar 2023 11:40:53 -0700 (PDT) X-Google-Smtp-Source: AK7set+vJ3vWy1YGyh9kRVq1kosAz5xsBeOIEahYP2fyxU+w8vhQ5v2nAjBB5GJMfpMPVsIF0Cl/ X-Received: by 2002:a17:90b:3886:b0:23d:3057:12a3 with SMTP id mu6-20020a17090b388600b0023d305712a3mr712670pjb.27.1678732852851; Mon, 13 Mar 2023 11:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678732852; cv=none; d=google.com; s=arc-20160816; b=aqgMxpXRjhnAUh+KesGUPGLoDo4yC8vTMXDca+YH4a/wsljYgXtoZ3aawJ6GAhE1T7 kbEvC4AVegL7IvUBbVxga04EHmYMtZ3+6MISm+YWD3iHtJXSyja6dfln/4mMc52I+lqC 5M24VTSM+DL+XVfackam888sMqHRI7vyJk0Vfkd/5CyYPhQqaj+HV7pl8oLDU4J3/G09 a6ekFvmQbsE4MOMe/r9mIAhy/gTuYgAxP827KTGX5AWRlCbJjIXEcYv8qw8AEA2iUGRZ PlagP2Yd6R9bifBRGBc86fDkOyzGKQChEYCumQcWl3l1sRO7luGqCUjDlwfPDGxwa25p vTnQ== 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=MApOrITKw8RNlEtrFH/B0UYdn70yz2YQ/riD3wyZfts=; b=JIYcaScecn3yfZE78e6it47HuEsI3C8QSGdpRDwT9+f6X0ODUePOf2jXdk/zUi5ZjI /ily4OJnTFJtIImhSKvX3Kf4hQNFj4M3qzJZsFoAkGl/kfj+6NMPWVLVglyFi+ZsqQIU pwXc+F0qR0DtixUfS/SsVX4wxavVZQA0NUNa7Jc2apDF9Li5ZWm1e0boj5EBrouRif/m M0AU6bFoX2xBjULi3K+FDBzmx8IOvOuumleQDQmgX/Ex3E+1nxFS/Jw9yf39pkQ0NXqy 7Avh39gNSRexSmyOyf2h1LNuPr1bqGASA1yxvVhJI9mQFDUMTV4FU2aI9d2R/uu/VWov weKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2fKwdA1U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a6553c3000000b004cd1e13283fsi167749pgr.318.2023.03.13.11.40.36; Mon, 13 Mar 2023 11:40:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2fKwdA1U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjCMSUL (ORCPT + 99 others); Mon, 13 Mar 2023 14:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230324AbjCMSTo (ORCPT ); Mon, 13 Mar 2023 14:19:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F363B79B0A for ; Mon, 13 Mar 2023 11:19:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3BC126147A for ; Mon, 13 Mar 2023 18:19:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F5B8C433D2; Mon, 13 Mar 2023 18:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678731559; bh=JS9C7IGfylyo5Tx9AQ/9FAAw1hnxWblRtBybqCiSb00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2fKwdA1UaoQtZkycHxLrojCmmUkHBg/OEjaQxxI8zM+MRxkAULFjzlJM6BDE3Oeph 7iYwZ3WKlKW00i9AoQPXTaFDhajufanzbK2skcTr5ainbpO/2JqcqdcYUjsKUotANw ofefyr1MChJV78i1phEYxTWJJbqVGEMLSFO/WY6Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: rafael@kernel.org, Greg Kroah-Hartman Subject: [PATCH 08/12] driver core: class: make class_create/remove_file*() options const Date: Mon, 13 Mar 2023 19:18:39 +0100 Message-Id: <20230313181843.1207845-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313181843.1207845-1-gregkh@linuxfoundation.org> References: <20230313181843.1207845-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2514; i=gregkh@linuxfoundation.org; h=from:subject; bh=JS9C7IGfylyo5Tx9AQ/9FAAw1hnxWblRtBybqCiSb00=; b=owGbwMvMwCRo6H6F97bub03G02pJDCn8mUz3hauuHLQQW/JvGdMT1pW+ER7Nbz97BifPa7prc iPCUnhNRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEykfhbDgqb1HLz5RoLnunQr xVillr6MbW6ZwDA/eZfwxoBIZ1PB35xpp5Q2W15Z+a4fAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760278980024053000?= X-GMAIL-MSGID: =?utf-8?q?1760278980024053000?= The class_create_file*() and class_remove_file*() functions do not modify the struct class at all, so mark them as const * to enforce that. Cc: "Rafael J. Wysocki" Signed-off-by: Greg Kroah-Hartman --- drivers/base/class.c | 4 ++-- include/linux/device/class.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/base/class.c b/drivers/base/class.c index 52ba0187e66d..3d65221b0dcb 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -87,7 +87,7 @@ static const struct kobj_type class_ktype = { static struct kset *class_kset; -int class_create_file_ns(struct class *cls, const struct class_attribute *attr, +int class_create_file_ns(const struct class *cls, const struct class_attribute *attr, const void *ns) { int error; @@ -101,7 +101,7 @@ int class_create_file_ns(struct class *cls, const struct class_attribute *attr, } EXPORT_SYMBOL_GPL(class_create_file_ns); -void class_remove_file_ns(struct class *cls, const struct class_attribute *attr, +void class_remove_file_ns(const struct class *cls, const struct class_attribute *attr, const void *ns) { if (cls) diff --git a/include/linux/device/class.h b/include/linux/device/class.h index dfa8958105e7..75c1451fcc63 100644 --- a/include/linux/device/class.h +++ b/include/linux/device/class.h @@ -200,20 +200,20 @@ struct class_attribute { #define CLASS_ATTR_WO(_name) \ struct class_attribute class_attr_##_name = __ATTR_WO(_name) -extern int __must_check class_create_file_ns(struct class *class, +extern int __must_check class_create_file_ns(const struct class *class, const struct class_attribute *attr, const void *ns); -extern void class_remove_file_ns(struct class *class, +extern void class_remove_file_ns(const struct class *class, const struct class_attribute *attr, const void *ns); -static inline int __must_check class_create_file(struct class *class, - const struct class_attribute *attr) +static inline int __must_check class_create_file(const struct class *class, + const struct class_attribute *attr) { return class_create_file_ns(class, attr, NULL); } -static inline void class_remove_file(struct class *class, +static inline void class_remove_file(const struct class *class, const struct class_attribute *attr) { return class_remove_file_ns(class, attr, NULL);