From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 F361E185935; Mon, 23 Dec 2024 20:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734986772; cv=none; b=uEuL7DkpL3XDOhSyt+k4TOfKbGffLBvJno4oSdAe3mELq99qsmsxEGOYLPfhwVpSNEmvmlhufpp+rY877Kcaq/JWiKyDSs4IA1lvHXUJWS5YYw7dPN0OB/g8wDR5Ap3CL4AVT5+IFSlAOfrSqhjkeYKEpWYSfi83PtT3oQutpa8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734986772; c=relaxed/simple; bh=t4pxdrzieGE73TTsbJ1bsHMRefkpTgQOO9TzjYxiCLE=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GB/HgImLrduuqwmD6O947vOITfsUHRJobQCiQshghmGX2grucrD+/fSXiW6qAVrij4Zx+l7fTNXIVXiiRqxJo1BCP3VpKdzGL8Y7u+UJM/H/2LG1Z/UGLVXL+439pVxybR3TunPeLydNugpCsPdsOl7CgMWGw1kdGbkS6QhBZDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YH95q4XLzz6K6mm; Tue, 24 Dec 2024 04:45:51 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 228F4140A70; Tue, 24 Dec 2024 04:46:09 +0800 (CST) Received: from localhost (10.47.75.118) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 23 Dec 2024 21:46:07 +0100 Date: Mon, 23 Dec 2024 20:46:05 +0000 From: Jonathan Cameron To: Zijun Hu CC: Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , James Bottomley , Thomas =?ISO-8859-1?Q?Wei=DFschu?= =?ISO-8859-1?Q?h?= , , , , , , , , , , , , , , , , , , , , , Zijun Hu Subject: Re: [PATCH v4 09/11] driver core: Introduce an device matching API device_match_type() Message-ID: <20241223204605.000067e0@huawei.com> In-Reply-To: <20241211-const_dfc_done-v4-9-583cc60329df@quicinc.com> References: <20241211-const_dfc_done-v4-0-583cc60329df@quicinc.com> <20241211-const_dfc_done-v4-9-583cc60329df@quicinc.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To frapeml500008.china.huawei.com (7.182.85.71) On Wed, 11 Dec 2024 08:08:11 +0800 Zijun Hu wrote: > From: Zijun Hu > > Introduce device_match_type() for purposes below: > > - Test if a device matches with a specified device type. > - As argument of various device finding APIs to find a device with > specified type. > > device_find_child() will use it to simplify operations later. > > Signed-off-by: Zijun Hu Seems useful enough to have a generic helper. Reviewed-by: Jonathan Cameron > --- > drivers/base/core.c | 6 ++++++ > include/linux/device/bus.h | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 289f2dafa8f3831931d0f316d66ee12c2cb8a2e1..8bdbc9e657e832a063542391426f570ccb5c18b9 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -5228,6 +5228,12 @@ int device_match_name(struct device *dev, const void *name) > } > EXPORT_SYMBOL_GPL(device_match_name); > > +int device_match_type(struct device *dev, const void *type) > +{ > + return dev->type == type; > +} > +EXPORT_SYMBOL_GPL(device_match_type); > + > int device_match_of_node(struct device *dev, const void *np) > { > return dev->of_node == np; > diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h > index cdc4757217f9bb4b36b5c3b8a48bab45737e44c5..bc3fd74bb763e6d2d862859bd2ec3f0d443f2d7a 100644 > --- a/include/linux/device/bus.h > +++ b/include/linux/device/bus.h > @@ -131,6 +131,7 @@ typedef int (*device_match_t)(struct device *dev, const void *data); > > /* Generic device matching functions that all busses can use to match with */ > int device_match_name(struct device *dev, const void *name); > +int device_match_type(struct device *dev, const void *type); > int device_match_of_node(struct device *dev, const void *np); > int device_match_fwnode(struct device *dev, const void *fwnode); > int device_match_devt(struct device *dev, const void *pdevt); >