From patchwork Mon Mar 13 18:18:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 69033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1347443wrd; Mon, 13 Mar 2023 11:47:58 -0700 (PDT) X-Google-Smtp-Source: AK7set/j4lt6JCkMQDJAnHmPZfNGj3HAwKNtd2ttLZAoV4nnJQVxiqxDKSSF1u09KUlGeMvihStC X-Received: by 2002:a17:90a:8c97:b0:23b:308f:59e6 with SMTP id b23-20020a17090a8c9700b0023b308f59e6mr8744986pjo.9.1678733278196; Mon, 13 Mar 2023 11:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678733278; cv=none; d=google.com; s=arc-20160816; b=k4vfv18zFq1ZFFFKFgxu65NMl3/y00RALiXqbggkqPsApu8jpPai+aw18ERFgEZ/aD h1LSLLIbh/74bX4On2P9I1i39uxIArXgvOiL4gjLdjlGdj+jRyMaJWkMbvD1resdFGlP BL4+iNANOJQywUP+YNo+vJxgE/yJ5Em6bLkWn4jF9Xzjp+7sxGcQfpRvNV7rj/fS6DVQ 7isMhhoeFrGUbEsLBuRvW3RKDXF3891Y90vJJ+RVaaOQTqclyA8Jnhb/FTGo+ZwVkY/y VeYNjpJ0ZlVMR5Py5GS5i1cu2b95BKT2Aamdpt2GolgkffagrW7F6IeL1OjaCHUFGWnu jkkg== 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=O0WtPwhe8PnEPquI2ReXNlebFoLmXrwztwmpFqVKZ2U=; b=DM+p1lzorBMzzbSKsHOvbZaHFTtjlQXdfNdC4m+Iuljv7Y6HMmZ4/uusFglh0IF3t5 fjR4ZERNFun6UUySL9PZlu9D9HTenophIr2lRQOztp0vovHGL7oE2lTdayVnWN/Tzkp8 3UODzCb1HyZfh70U7/5o3rgqmKaH4JSFgk08pmEIJepRkqCJfu8Z1/bdOuL/XVlPnkv9 gpX1M4hETxGqkF+EFrk6mQ1ATMCk/b0o3iWomU1aSYNDnF4oS0f+AicPLvfUNjr3exXD L1rB2C21LiI8z5M0PmJKi344LWtnEFhCaeB/Dx1+DgJCACjOtH/Z02Qg9fpSxb94ZbGB h7PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p9nQh+fN; 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 gx1-20020a17090b124100b00230ad3a239asi380058pjb.113.2023.03.13.11.47.35; Mon, 13 Mar 2023 11:47:58 -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=p9nQh+fN; 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 S230326AbjCMSUI (ORCPT + 99 others); Mon, 13 Mar 2023 14:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjCMSTh (ORCPT ); Mon, 13 Mar 2023 14:19:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C05B6F622 for ; Mon, 13 Mar 2023 11:19:18 -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 A376461474 for ; Mon, 13 Mar 2023 18:19:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4B6DC43444; Mon, 13 Mar 2023 18:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678731557; bh=pNN6vmAhlLeMrf2ujoqLuBmzLLZa1C/GmAzQf4erYdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p9nQh+fNYAEzJllAphqQT79qmfi5RCzLuhXoTNuoKxuOjdS+AuAPhrUTlY2/7wdcg FPRGg3o3OEIom/IW3qI5//4WdSeygeeR/aLfMTo85BJWh1n9QDLprCzH2E2HBtfieS +9zY+8TSC4YHMUA7kLGVhsWA4dboWv7sHZ07O/Gw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: rafael@kernel.org, Greg Kroah-Hartman Subject: [PATCH 07/12] driver core: class: make class_find_device*() options const Date: Mon, 13 Mar 2023 19:18:38 +0100 Message-Id: <20230313181843.1207845-7-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=4271; i=gregkh@linuxfoundation.org; h=from:subject; bh=pNN6vmAhlLeMrf2ujoqLuBmzLLZa1C/GmAzQf4erYdc=; b=owGbwMvMwCRo6H6F97bub03G02pJDCn8mUxcc3uvyRV8TPty7PJlvubv3154hG7NvvDzrd7Ms uNyL8LWdMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBE7k1nWDAxpOPfNkfW7tQP 0/9s3RS58jvn+SkM80z+qs+0582pnddWvOLf27wQkx3fDwIA 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?1760279425735991344?= X-GMAIL-MSGID: =?utf-8?q?1760279425735991344?= The class_find_device*() functions do not modify the struct class or the struct device passed into it, so mark them as const * to enforce that. Cc: "Rafael J. Wysocki" Signed-off-by: Greg Kroah-Hartman --- drivers/base/class.c | 2 +- include/linux/device/class.h | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/base/class.c b/drivers/base/class.c index 4937d660c571..52ba0187e66d 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -402,7 +402,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device); * @match is allowed to do anything including calling back into class * code. There's no locking restriction. */ -struct device *class_find_device(struct class *class, struct device *start, +struct device *class_find_device(const struct class *class, const struct device *start, const void *data, int (*match)(struct device *, const void *)) { diff --git a/include/linux/device/class.h b/include/linux/device/class.h index fdbcd487e508..dfa8958105e7 100644 --- a/include/linux/device/class.h +++ b/include/linux/device/class.h @@ -112,8 +112,8 @@ extern void class_dev_iter_exit(struct class_dev_iter *iter); extern int class_for_each_device(const struct class *class, const struct device *start, void *data, int (*fn)(struct device *dev, void *data)); -extern struct device *class_find_device(struct class *class, - struct device *start, const void *data, +extern struct device *class_find_device(const struct class *class, + const struct device *start, const void *data, int (*match)(struct device *, const void *)); /** @@ -122,7 +122,7 @@ extern struct device *class_find_device(struct class *class, * @class: class type * @name: name of the device to match */ -static inline struct device *class_find_device_by_name(struct class *class, +static inline struct device *class_find_device_by_name(const struct class *class, const char *name) { return class_find_device(class, NULL, name, device_match_name); @@ -134,8 +134,8 @@ static inline struct device *class_find_device_by_name(struct class *class, * @class: class type * @np: of_node of the device to match. */ -static inline struct device * -class_find_device_by_of_node(struct class *class, const struct device_node *np) +static inline struct device *class_find_device_by_of_node(const struct class *class, + const struct device_node *np) { return class_find_device(class, NULL, np, device_match_of_node); } @@ -146,9 +146,8 @@ class_find_device_by_of_node(struct class *class, const struct device_node *np) * @class: class type * @fwnode: fwnode of the device to match. */ -static inline struct device * -class_find_device_by_fwnode(struct class *class, - const struct fwnode_handle *fwnode) +static inline struct device *class_find_device_by_fwnode(const struct class *class, + const struct fwnode_handle *fwnode) { return class_find_device(class, NULL, fwnode, device_match_fwnode); } @@ -159,7 +158,7 @@ class_find_device_by_fwnode(struct class *class, * @class: class type * @devt: device type of the device to match. */ -static inline struct device *class_find_device_by_devt(struct class *class, +static inline struct device *class_find_device_by_devt(const struct class *class, dev_t devt) { return class_find_device(class, NULL, &devt, device_match_devt); @@ -173,14 +172,14 @@ struct acpi_device; * @class: class type * @adev: ACPI_COMPANION device to match. */ -static inline struct device * -class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev) +static inline struct device *class_find_device_by_acpi_dev(const struct class *class, + const struct acpi_device *adev) { return class_find_device(class, NULL, adev, device_match_acpi_dev); } #else -static inline struct device * -class_find_device_by_acpi_dev(struct class *class, const void *adev) +static inline struct device *class_find_device_by_acpi_dev(const struct class *class, + const void *adev) { return NULL; }