From patchwork Tue Dec 3 00:33:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 2017472 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=icloud.com header.i=@icloud.com header.a=rsa-sha256 header.s=1a1hai header.b=miqyYlVd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=y/2t=s4=vger.kernel.org=sparclinux+bounces-2699-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y2MBT39TVz1yCt for ; Tue, 3 Dec 2024 11:35:29 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Y2MBN5kYPz4wy6 for ; Tue, 3 Dec 2024 11:35:24 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Y2MBN5cdnz4x04; Tue, 3 Dec 2024 11:35:24 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45e3:2400::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1733186124; cv=pass; b=D4UFoi/wr0SKguDAu672cKAMjZPtdVvRFuhDoHR62d8TWX+CsV92TI3Xxu5FXMJkgIBi0ZQbuD6Ci+glRqynOSUSVXyeRc9rCEkmbe+x1k7lkQPgtq+hxEjNKmPbzGa2v3EyZdQwhYIZItPFkCw6QyUQQic2umrCbb15wOA443pkt6jOLLBFAEx1ALhOA4h/6UOkJLxe35UcA8XyeZuZusuu5m9YEN+/PnPrpJ61k7dGjT2jNJlEBCRSjq2FsQpkE78yJIbPgepOYg3AUHkhCJbVbx76giQGEy2RconGzU3PJLSgEJK5nlHv1cZ07W8YHpVcU41ecOmg522hj2tROQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1733186124; c=relaxed/relaxed; bh=oHbx7nufqBC9FciDzS/LGxt7hmN8dQX6iuRN6cbwUA4=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=NVOf5vLlz1o9SkLIoCj+WlezDlNQhLy4ArKdCTbyvfFeYUEV8oaAeJZJ6Ghcq5gDSZl++bn6np5P2vWtczeDYJpO44xCudPao/t5hWKZFPNV2ZcKDGAN+EB7SGh6XcHMo1arUsgUe8ItsubKj/tb/lyyNXOyVMJ62KfVhywO9yzZ9zIMwhuAW6feamJVJX+MrDKcbKLV3sKJesN0ClaqkM0gTa2kRRGi7jWwPxksItlvV7dr5ahUYpHprJHXFI1Iqyt8S+QOq0teKmw6kPxgyMcs4CjODEpEVSDm093inA5Ei9UpTGHkQhJ5onp3vHFgg8KoShAsGeoVty47mu2CKg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; dkim=pass (2048-bit key; unprotected) header.d=icloud.com header.i=@icloud.com header.a=rsa-sha256 header.s=1a1hai header.b=miqyYlVd; dkim-atps=neutral; spf=pass (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-2699-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=icloud.com header.i=@icloud.com header.a=rsa-sha256 header.s=1a1hai header.b=miqyYlVd; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-2699-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Y2MBJ6qs2z4wy6 for ; Tue, 3 Dec 2024 11:35:20 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 40B57282323 for ; Tue, 3 Dec 2024 00:35:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59CF52B9B9; Tue, 3 Dec 2024 00:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="miqyYlVd" X-Original-To: sparclinux@vger.kernel.org Received: from pv50p00im-zteg10011501.me.com (pv50p00im-zteg10011501.me.com [17.58.6.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E074518B03 for ; Tue, 3 Dec 2024 00:34:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733186103; cv=none; b=dzn+We5CRaeCXTFhBYDULVN60V4SNlh/SPYbLc/QFFTKXAresCNhDBjgUqg2ZEYgBk8PEVOAEW7Loux953dN5tmpylfI9Y3YQyKAKz0elXaKX8T8Vyw3CANLqJ+4frNF+F8HgcMffVDK2PZih0WMN3xVm5UJZ+Y1TveDBa54u3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733186103; c=relaxed/simple; bh=90Z3uIVjxiaduJ4fj5p/v/pFRaVs8rKzXxaWEN8s1Fs=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=jJLHz+DhdYA44HMsS0SVnwnyf05bn8QaBuf3ot4Jv690B+8otuSqIwIsdzI9jemv6lINn1btfQ7DvhEFbJY03u+wcfSTDOTIkwNelPhxj2yJla+fIJifyiDRITEY0btAHReGgPFbTYLXLcvB8MJ+jq+A08ncfqyFwbJgtm/JyyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=miqyYlVd; arc=none smtp.client-ip=17.58.6.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1733186099; bh=oHbx7nufqBC9FciDzS/LGxt7hmN8dQX6iuRN6cbwUA4=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To: x-icloud-hme; b=miqyYlVd243flQ1IvVsliQiE9DHrrSD+z1j3Ao2U3BsVp7icRgsik+yX27rSCj4D+ T5K/safPmJG6H2G4WE9j7bBQvaFexypWm7FZEDou1MHIH9tDRRWMiQ1UPriELs/+hg sXJNUkBBU1moy8uzw4v/v66n2uZ4nRbGFXnHbTcyy0JERpSfQmvHQ8NAx4kDoEqPtw K44qvDlYPQIBfuW/hOl+sPtWJcXOrD96VbESU02KGCiiJXJdFSzYBJ54ViTlBPnRB9 QOAY9cdzyUWJL5EMG594jIK63Bf2SXcNzUNd7nw2qi11pPaZME4OnmSK9qWoRG15E/ 2icgiJHx3EH4g== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011501.me.com (Postfix) with ESMTPSA id A517C4A0115; Tue, 3 Dec 2024 00:34:38 +0000 (UTC) From: Zijun Hu Subject: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Date: Tue, 03 Dec 2024 08:33:22 +0800 Message-Id: <20241203-const_dfc_done-v2-0-7436a98c497f@quicinc.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIANJRTmcC/2XMQQ6CMBCF4auQWVvTFozgynsYQsp0KrOwxRaJh vTuVrYu/5e8b4NEkSnBpdog0sqJgy+hDxXgZPydBNvSoKVulJZKYPBpGazDwQZPwhjCs6J6HMl AOc2RHL938NaXnjgtIX52f1W/dadkq/6oVQkpOtueqHZdU+N4fb4Y2eMRwwP6nPMXYHxV6a4AA AA= X-Change-ID: 20241201-const_dfc_done-aaec71e3bbea To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Chun-Kuang Hu , Philipp Zabel , David Airlie , Simona Vetter , Matthias Brugger , AngeloGioacchino Del Regno , Jean Delvare , Guenter Roeck , Martin Tuma , Mauro Carvalho Chehab , Andreas Noever , Michael Jamet , Mika Westerberg , Yehezkel Bernat , Linus Walleij , Bartosz Golaszewski , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Takashi Sakamoto , Jiri Slaby , Heikki Krogerus , Srinivas Kandagatla , Lee Duncan , Chris Leech , Mike Christie , "James E.J. Bottomley" , "Martin K. Petersen" , Nilesh Javali , Manish Rangankar , GR-QLogic-Storage-Upstream@marvell.com, Davidlohr Bueso , Jonathan Cameron , Alison Schofield , Andreas Larsson , Stuart Yoder , Laurentiu Tudor , Jens Axboe , Sudeep Holla , Cristian Marussi , Ard Biesheuvel , Bjorn Andersson , Mathieu Poirier Cc: Zijun Hu , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-media@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pwm@vger.kernel.org, nvdimm@lists.linux.dev, linux1394-devel@lists.sourceforge.net, linux-serial@vger.kernel.org, linux-sound@vger.kernel.org, open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, linux-cxl@vger.kernel.org, sparclinux@vger.kernel.org, linux-block@vger.kernel.org, arm-scmi@vger.kernel.org, linux-efi@vger.kernel.org, linux-remoteproc@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: cTyu1VL48UqVhY7zPwUQPPYeAfZYowdo X-Proofpoint-ORIG-GUID: cTyu1VL48UqVhY7zPwUQPPYeAfZYowdo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-02_14,2024-12-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 clxscore=1011 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412030002 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on gandalf.ozlabs.org This patch series is to constify the following API: struct device *device_find_child(struct device *dev, void *data, int (*match)(struct device *dev, void *data)); To : struct device *device_find_child(struct device *dev, const void *data, device_match_t match); typedef int (*device_match_t)(struct device *dev, const void *data); Why to constify the API? - Protect caller's match data @*data which is for comparison and lookup and the API does not actually need to modify @*data. - Make the API's parameters (@match)() and @data have the same type as all of other device finding APIs (bus|class|driver)_find_device(). - All kinds of existing device matching functions can be directly taken as the API's argument, they were exported by driver core. How to constify the API? - Now, no (@match)() argument of the API usages is modifying its match data @*data after previous cleanup, so it is easy and safe to make its parameter @data take const void * as type. - Simplify involved codes further if it is possbile with benefits brought by constifying the API. Signed-off-by: Zijun Hu --- Changes in v2: - Series v1 have no code review comments and are posted a long time ago, so may ignore differences. - Link to v1: https://lore.kernel.org/r/20240811-const_dfc_done-v1-0-9d85e3f943cb@quicinc.com - Motivation link: https://lore.kernel.org/lkml/917359cc-a421-41dd-93f4-d28937fe2325@icloud.com --- Zijun Hu (32): driver core: Constify API device_find_child() driver core: Introduce device_match_type() to match device with a device type drm/mediatek: Adapt for constified device_find_child() hwmon: Adapt for constified device_find_child() media: pci: mgb4: Adapt for constified device_find_child() thunderbolt: Adapt for constified device_find_child() gpio: sim: Remove gpio_sim_dev_match_fwnode() net: dsa: Adapt for constified device_find_child() pwm: Adapt for constified device_find_child() nvdimm: Adapt for constified device_find_child() libnvdimm: Simplify nd_namespace_store() implementation firewire: core: Adapt for constified device_find_child() serial: core: Adapt for constified device_find_child() usb: typec: class: Remove both cable_match() and partner_match() usb: typec: class: Adapt for constified device_find_child() slimbus: core: Simplify of_find_slim_device() implementation slimbus: core: Constify slim_eaddr_equal() slimbus: core: Adapt for constified device_find_child() scsi: iscsi: Constify API iscsi_find_flashnode_sess() scsi: qla4xxx: Adapt for constified iscsi_find_flashnode_sess() scsi: iscsi: Adapt for constified device_find_child() cxl/region: Adapt for constified device_find_child() cxl/pmem: Remove match_nvdimm_bridge() cxl/core/pci: Adapt for constified device_find_child() cxl/test: Adapt for constified device_find_child() sparc: vio: Adapt for constified device_find_child() bus: fsl-mc: Adapt for constified device_find_child() block: sunvdc: Adapt for constified device_find_child() firmware: arm_scmi: Adapt for constified device_find_child() efi: dev-path-parser: Adapt for constified device_find_child() rpmsg: core: Adapt for constified device_find_child() driver core: Simplify API device_find_child_by_name() implementation arch/sparc/kernel/vio.c | 6 +++--- drivers/base/core.c | 30 ++++++++++-------------------- drivers/block/sunvdc.c | 6 +++--- drivers/bus/fsl-mc/dprc-driver.c | 6 +++--- drivers/cxl/core/pci.c | 4 ++-- drivers/cxl/core/pmem.c | 9 +++------ drivers/cxl/core/region.c | 21 ++++++++++++--------- drivers/firewire/core-device.c | 4 ++-- drivers/firmware/arm_scmi/bus.c | 4 ++-- drivers/firmware/efi/dev-path-parser.c | 4 ++-- drivers/gpio/gpio-sim.c | 7 +------ drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 +- drivers/hwmon/hwmon.c | 2 +- drivers/media/pci/mgb4/mgb4_core.c | 4 ++-- drivers/nvdimm/bus.c | 2 +- drivers/nvdimm/claim.c | 9 +-------- drivers/pwm/core.c | 2 +- drivers/rpmsg/rpmsg_core.c | 4 ++-- drivers/scsi/qla4xxx/ql4_os.c | 3 ++- drivers/scsi/scsi_transport_iscsi.c | 10 +++++----- drivers/slimbus/core.c | 17 +++++------------ drivers/thunderbolt/retimer.c | 2 +- drivers/thunderbolt/xdomain.c | 2 +- drivers/tty/serial/serial_core.c | 4 ++-- drivers/usb/typec/class.c | 31 ++++++++++++++----------------- include/linux/device.h | 4 ++-- include/linux/device/bus.h | 1 + include/scsi/scsi_transport_iscsi.h | 4 ++-- net/dsa/dsa.c | 2 +- tools/testing/cxl/test/cxl.c | 2 +- 30 files changed, 89 insertions(+), 119 deletions(-) --- base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37 change-id: 20241201-const_dfc_done-aaec71e3bbea Best regards,