From patchwork Mon Mar 13 18:18:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 69003 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1336402wrd; Mon, 13 Mar 2023 11:20:49 -0700 (PDT) X-Google-Smtp-Source: AK7set9jJiEDfxwLlri93HeQwoFQd4oxSjuuDA4jBgGpBL8XI4RzoFSERRAMXSRuuQF+Hk83GmyK X-Received: by 2002:a05:6a20:b713:b0:d3:89a1:76d1 with SMTP id fg19-20020a056a20b71300b000d389a176d1mr7133227pzb.11.1678731649050; Mon, 13 Mar 2023 11:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678731649; cv=none; d=google.com; s=arc-20160816; b=yIIJ0UYdP5s/zHtBkefDWcrHp6X0Xe41ZnLFdY8G8IA6AlbBb4+w/PBuSeHQOyuOkm Jv+DAW8qvMFZyQ57a0aMyJ5jW/L+9KGr9kpGfuJ/uoxgvFRdTWTddQTFdNSHdvB/pFbl e2+jr/mgMxybOyw9pPW6cIv37JsKZvZyQ843ctwMp1KkCR37Bt60EkU+NaTi7IRRpd+p SHABLQOR8fS+H17jBhiGASrAX43yi/OmesYogElfpuJaxhnR1rhNgtg1cVu9quD8J4kv tHbd7ETujB+9EjRb/h4gSWL5ZWyMscLIlj99hIWdPOTfHe3K/eJ8laqP5AnmtEcBYD+5 FfJw== 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=gti0c0217McovTh2bTanPWg7tO6Ujf72RxdxpiPDaz0=; b=gFMyschL7m7sSb/lbhfzbn1+IsnuwB63C6Xs4FI9vgW/batpf7wz60kZ7THp63bB57 V1uBlE09ILQF4daOja7lCS+iaI33nf+8seflo56hY79KeujNUANQbu8vsy7USNoNiwzA GBNIbkEHoEb83/W4lCBQgyfbAhFABnzo76y1iNt+nsldUeT+s/IPMsKYk4kLRXNz6ET7 pfMn7zq90XGfcVbBnb0ZAIlvTcASkPnHtu3x02DY2MEc1iYU/o7Iwmd/bmZ4oL7blHrn a8NzPJ6gGuxI7padzXjQIe+3XbJCXe+J3LvtW/LisSQtxU2HPiqaefcu1N5KPOp1BER2 kJug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wdg8jHRR; 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 u12-20020a63600c000000b004fd50189889si146371pgb.29.2023.03.13.11.20.34; Mon, 13 Mar 2023 11:20:49 -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=wdg8jHRR; 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 S230119AbjCMSTX (ORCPT + 99 others); Mon, 13 Mar 2023 14:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjCMSTJ (ORCPT ); Mon, 13 Mar 2023 14:19:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D4060413 for ; Mon, 13 Mar 2023 11:19:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id B93DCB811C0 for ; Mon, 13 Mar 2023 18:19:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12EBEC433EF; Mon, 13 Mar 2023 18:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678731543; bh=ctjKqSuJOUxpeEuy+4gwiXJmrXmRPpbRLRRhC9+pDrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wdg8jHRR4oPOiF1OhWuEOaVOifv3pVQV3R56+fwa9OM0XCYSn8x9uXmpIojcKbA52 QnaVDIPe9qNub1PZ114EV4jiWSfVNqC1RAfT3+Toi87uuWxC1cLumFTWza0IrAodWT /3hsojjpGpWjtG9dSUw9ZBTV8YfZ7CEKs6WpTt70= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: rafael@kernel.org, Greg Kroah-Hartman Subject: [PATCH 12/12] driver core: device: make device_create*() take a const struct class * Date: Mon, 13 Mar 2023 19:18:43 +0100 Message-Id: <20230313181843.1207845-12-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=2761; i=gregkh@linuxfoundation.org; h=from:subject; bh=ctjKqSuJOUxpeEuy+4gwiXJmrXmRPpbRLRRhC9+pDrM=; b=owGbwMvMwCRo6H6F97bub03G02pJDCn8mcx6/w9MZPH7XKIss+ydt33Zvnnh/fNizi2+cYt/X 7z8nUUPO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAi4R8Y5hef8rv0XGQ2UzxD 2alZSsJMl9hvtzLM4TXqblW75CBXfFYvynNzpH7Dh7cuAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1760277718124221424?= X-GMAIL-MSGID: =?utf-8?q?1760277718124221424?= The functions device_create() and device_create_with_groups() do not modify the struct class passed into it, so enforce this by changing the function parameters to be struct const class. Cc: "Rafael J. Wysocki" Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 6 +++--- include/linux/device.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 0970db630839..f1889b9cab45 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4253,7 +4253,7 @@ static void device_create_release(struct device *dev) } static __printf(6, 0) struct device * -device_create_groups_vargs(struct class *class, struct device *parent, +device_create_groups_vargs(const struct class *class, struct device *parent, dev_t devt, void *drvdata, const struct attribute_group **groups, const char *fmt, va_list args) @@ -4317,7 +4317,7 @@ device_create_groups_vargs(struct class *class, struct device *parent, * Note: the struct class passed to this function must have previously * been created with a call to class_create(). */ -struct device *device_create(struct class *class, struct device *parent, +struct device *device_create(const struct class *class, struct device *parent, dev_t devt, void *drvdata, const char *fmt, ...) { va_list vargs; @@ -4358,7 +4358,7 @@ EXPORT_SYMBOL_GPL(device_create); * Note: the struct class passed to this function must have previously * been created with a call to class_create(). */ -struct device *device_create_with_groups(struct class *class, +struct device *device_create_with_groups(const struct class *class, struct device *parent, dev_t devt, void *drvdata, const struct attribute_group **groups, diff --git a/include/linux/device.h b/include/linux/device.h index f97a793c6683..b050c545a4dd 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1013,10 +1013,10 @@ bool device_is_bound(struct device *dev); * Easy functions for dynamically creating devices on the fly */ __printf(5, 6) struct device * -device_create(struct class *cls, struct device *parent, dev_t devt, +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(struct class *cls, struct device *parent, dev_t devt, +device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt, void *drvdata, const struct attribute_group **groups, const char *fmt, ...); void device_destroy(const struct class *cls, dev_t devt);