From patchwork Thu Aug 15 14:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13764868 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 3B17B29CE6 for ; Thu, 15 Aug 2024 14:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723733904; cv=none; b=ILSGVsXvcwibM7/ln+6kNJOtblAO1VziGEK6eHOJjbwWgECrB5bcz8CYbGNF6/nBXCU29DF2xGu/0v6DJTEyRXlhQCl3vi6/aTDwwYtjW0ayA4usMSTmxLM8ccsMbmPaJGpSNYjrlSnIAwTtChYYyBt8oZQMlX0m4mCazZBHUk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723733904; c=relaxed/simple; bh=D5kBlArR3VBj/YNFjLvPshcFzIub8HASCAC5DqTanxk=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=r96JL4Heed4VSWU9mCdv4kDq8ikBkfrS2ZUN6dSRHRISgA15s3hjYS295v+gtMD4YefzfYDhR+18LfpQ08K64fwEQ95VRyutiRc0Oe8sPYwiJALQU1Uo/hCSJjODDrJMlSQrD+K6g33QPqetC3Kl5IV/LhrN/w25Caxoe8s7xQA= 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=RduMliW4; arc=none smtp.client-ip=17.58.6.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="RduMliW4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1723733901; bh=yzHbpOIW6NkHcW18s93aDeUltQuaFPLn1cSSYIxW6rg=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To; b=RduMliW45n3coSQN3Mkmvby/u5QCAH3NwcTeKLNjaPTCFyQhfWDUT+phVLyY2ddU8 DYA4k01S/m0aK5LRyhEHeR++SZHicIwSNH4/2Nig3NSdNHnWBOdu1WH1DawejyPjQP ytGlga9IpF2oRvOeMs5tNFTw5r/WFXBbKDnM23LjIBGA3zk+8diIiL5DxT87V7nuw5 kJugHKagI2R4vBQzcyJv0AGwS5pDBSJOqa7mco2mypHTrQYOZDdhmNwI3gmYHqZRkG Qxo2p9+uJ3baR4qZ/3OGyTQdcTnmXsF6XUrVv+1KmUNta69xarpEs/Mg0TIAHfPXmA zv3L/SK3wfSTw== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id D22A7DC043D; Thu, 15 Aug 2024 14:58:15 +0000 (UTC) From: Zijun Hu Subject: [PATCH v2 0/4] driver core: Prevent device_find_child() from modifying caller's match data Date: Thu, 15 Aug 2024 22:58:01 +0800 Message-Id: <20240815-const_dfc_prepare-v2-0-8316b87b8ff9@quicinc.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAHkXvmYC/32NQQ6CMBBFr0JmbQ1tAZGV9zCE4HQqs7DFFomG9 O5WDuDyveS/v0GkwBShKzYItHJk7zKoQwE4je5Ogk1mUKWqylZKgd7FZTAWhznQPAYS2lqlsan PLdWQd9lbfu/Na5954rj48NkvVvmz/2qrFKUwzQmxks1NG315vhjZ4RH9A/qU0hcPrOf0tAAAA A== To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Takashi Sakamoto , Timur Tabi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Zijun Hu , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: B4N9KxfVpvfIqZEcsYxqOgw_K_ymbEWZ X-Proofpoint-GUID: B4N9KxfVpvfIqZEcsYxqOgw_K_ymbEWZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-15_07,2024-08-15_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408150109 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 This patch series is to prepare for constifying the following driver 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, int (*match)(struct device *dev, const void *data)); How to constify the API ? There are total 30 usages of the API in kernel tree: For 3/30 usages, the API's match function (*match)() will modify caller's match data @*data, and this patch series will clean up them. For remaining 27/30, the other patch series will simply change its relevant parameter type to const void *. Why to constify the API ? (1) It normally does not make sense, also does not need to, for such device finding operation to modify caller's match data which is mainly used for comparison. (2) It will make the API's match function and match data parameter have the same type as all other APIs (bus|class|driver)_find_device(). (3) It will give driver author hints about choice between this API and the following one: int device_for_each_child(struct device *dev, void *data, int (*fn)(struct device *dev, void *data)); Signed-off-by: Zijun Hu --- Changes in v2: - Give up introducing the API constify_device_find_child_helper() - Correct commit message and inline comments - Implement a driver specific and equivalent one instead of device_find_child() - Link to v1: https://lore.kernel.org/r/20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com --- Zijun Hu (4): driver core: Make parameter check consistent for API cluster device_(for_each|find)_child() cxl/region: Prevent device_find_child() from modifying caller's match data firewire: core: Prevent device_find_child() from modifying caller's match data net: qcom/emac: Prevent device_find_child() from modifying caller's match data drivers/base/core.c | 6 ++-- drivers/cxl/core/region.c | 36 +++++++++++++++++++++++- drivers/firewire/core-device.c | 37 +++++++++++++++++++++++-- drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 36 ++++++++++++++++++++++-- 4 files changed, 107 insertions(+), 8 deletions(-) --- base-commit: bfa54a793ba77ef696755b66f3ac4ed00c7d1248 change-id: 20240811-const_dfc_prepare-3ff23c6598e5 Best regards,