From patchwork Thu Dec 5 00:10:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 847797 Received: from pv50p00im-tydg10011801.me.com (pv50p00im-tydg10011801.me.com [17.58.6.52]) (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 E521F2391B8 for ; Thu, 5 Dec 2024 00:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733357591; cv=none; b=CHo3TN6hyc+1zdqYpUJyRKn0vSBDl/yPqIR1VB8QCgAv5EbgvN82ssOpTjBf4Koe3OjMiUMoJPfuJN2BemaOLr85hevNf5mIJTmqhoJ5iKX7YechxsUGBP2w4fRUTpEUwXfJhyo1GBDOCdBgM5BVgkmp7DNQAXB2B0v77ItJxqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733357591; c=relaxed/simple; bh=9CVfL3LBZDuGqTPOlB/Hz3fqVHtXJi1gTAsCkM1ms9c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BetHDnMfQTU3anvij6lug3HSW9iQe9bCeCkAKxanwpS304udR+ThwSquZK472aX8RfzThu61rgWFOErr4QGyYzq6SWQklViw/gV1sFpqfX8TSNflvDesUQXPJqnmSkR3COMw/QvdDm2C4xXGcvm4jCYYzbV07Bx4WSiaDNj7Bbs= 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=t2KTkk30; arc=none smtp.client-ip=17.58.6.52 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="t2KTkk30" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1733357589; bh=t5prCo8UotA+1FRQmsP8HYiQwFRGgFHZ6D5HPcEJxkY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=t2KTkk30j/x8cwgwejUYwek4VjEcxvplqznK79L1VULbmbGc8ou6ycm+rwwfEhTTT JOueTBNF2mp/zwSxcMu/VtvGuDduuIvrRyjs918+nC81xYIbUQrEH3l7zNMQn45jq5 ZS2Wf15OXou1M+D9min87hMiwC20ZSLHH9UfQwFBhvNC2aqm1DVRhAVZZaydyaXO7b e93Q4ScxXqL4B+jcufIMkxNyvs8Say+zLJymJXLzwZYkfoKDBRtH/MZJasFyv+4W9Q 7VDFlrk5wo4wXg/geYB1LEf/oH1wpsLc1V2iSnMt4bHHCqtnPt4jOY1A4QtPl58UXK VhcOwTTLVWhPQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-tydg10011801.me.com (Postfix) with ESMTPSA id 0A474800382; Thu, 5 Dec 2024 00:12:58 +0000 (UTC) From: Zijun Hu Date: Thu, 05 Dec 2024 08:10:20 +0800 Subject: [PATCH v3 11/11] usb: typec: class: Remove both cable_match() and partner_match() Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241205-const_dfc_done-v3-11-1611f1486b5a@quicinc.com> References: <20241205-const_dfc_done-v3-0-1611f1486b5a@quicinc.com> In-Reply-To: <20241205-const_dfc_done-v3-0-1611f1486b5a@quicinc.com> To: Greg Kroah-Hartman Cc: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , James Bottomley , =?utf-8?q?Thomas_?= =?utf-8?q?Wei=C3=9Fschuh?= , Zijun Hu , linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-sound@vger.kernel.org, sparclinux@vger.kernel.org, linux-block@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, arm-scmi@vger.kernel.org, linux-efi@vger.kernel.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com, linux-usb@vger.kernel.org, linux-serial@vger.kernel.org, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: VdKDrx-KLtW7yCbNEje76WJIjR4qS0Q9 X-Proofpoint-GUID: VdKDrx-KLtW7yCbNEje76WJIjR4qS0Q9 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-04_19,2024-12-04_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 clxscore=1015 phishscore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=901 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412040186 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu cable_match(), as matching function of device_find_child(), is to match a device with device type @typec_cable_dev_type, and is unnecessary. partner_match() is similar with cable_match() but with different device type @typec_partner_dev_type. Remove both functions and directly use API device_match_type() plus respective device type instead. Signed-off-by: Zijun Hu --- drivers/usb/typec/class.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 601a81aa1e1024265f2359393dee531a7779c6ea..3a4e0bd0131774afd0d746d2f0a306190219feec 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1282,11 +1282,6 @@ const struct device_type typec_cable_dev_type = { .release = typec_cable_release, }; -static int cable_match(struct device *dev, const void *data) -{ - return is_typec_cable(dev); -} - /** * typec_cable_get - Get a reference to the USB Type-C cable * @port: The USB Type-C Port the cable is connected to @@ -1298,7 +1293,8 @@ struct typec_cable *typec_cable_get(struct typec_port *port) { struct device *dev; - dev = device_find_child(&port->dev, NULL, cable_match); + dev = device_find_child(&port->dev, &typec_cable_dev_type, + device_match_type); if (!dev) return NULL; @@ -2028,16 +2024,12 @@ const struct device_type typec_port_dev_type = { /* --------------------------------------- */ /* Driver callbacks to report role updates */ -static int partner_match(struct device *dev, const void *data) -{ - return is_typec_partner(dev); -} - static struct typec_partner *typec_get_partner(struct typec_port *port) { struct device *dev; - dev = device_find_child(&port->dev, NULL, partner_match); + dev = device_find_child(&port->dev, &typec_partner_dev_type, + device_match_type); if (!dev) return NULL; @@ -2170,7 +2162,9 @@ void typec_set_pwr_opmode(struct typec_port *port, sysfs_notify(&port->dev.kobj, NULL, "power_operation_mode"); kobject_uevent(&port->dev.kobj, KOBJ_CHANGE); - partner_dev = device_find_child(&port->dev, NULL, partner_match); + partner_dev = device_find_child(&port->dev, + &typec_partner_dev_type, + device_match_type); if (partner_dev) { struct typec_partner *partner = to_typec_partner(partner_dev); @@ -2334,7 +2328,9 @@ int typec_get_negotiated_svdm_version(struct typec_port *port) enum usb_pd_svdm_ver svdm_version; struct device *partner_dev; - partner_dev = device_find_child(&port->dev, NULL, partner_match); + partner_dev = device_find_child(&port->dev, + &typec_partner_dev_type, + device_match_type); if (!partner_dev) return -ENODEV; @@ -2361,7 +2357,8 @@ int typec_get_cable_svdm_version(struct typec_port *port) enum usb_pd_svdm_ver svdm_version; struct device *cable_dev; - cable_dev = device_find_child(&port->dev, NULL, cable_match); + cable_dev = device_find_child(&port->dev, &typec_cable_dev_type, + device_match_type); if (!cable_dev) return -ENODEV;