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 4DB231AE01E; Mon, 23 Dec 2024 20:39:41 +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=1734986383; cv=none; b=pYr4RnN/lr23GyQCXirUc709q4PfZhhOAjiWFLou8ddp68gS8Pc9wqapo6gKRj1ztUpPLjUGZF3kkPOkJ07rAuXfGhGM8OKeQHrb8vl4B/FrQFSDucD6cnGtlzOB74p0BhndsUkhtRdUDAIrvmbSNkDLk/dbI0NmdJMKNouMdCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734986383; c=relaxed/simple; bh=qWA5dR+bAhEbXQPoTB8QS7dwg991wuF5JVOmVjFcw1M=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LQKOQvlLKul1EmaDExGzduv7NqPxrPiQfnI+C9eHTGY58EHjtzuU03sUj23SQGGOhrk+RLb2y/UEEs8Yq7V7x2xHVSo7hzgkPf+Xr7XPIjnpphnhTpvp1HZvJgV4a7ODZYXGTwJ70avZ3zPMNAi/YtKB1s0Pg2TcKl5BB0BoP10= 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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YH8tC65GQz6K5VT; Tue, 24 Dec 2024 04:35:47 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id CFA67140524; Tue, 24 Dec 2024 04:39:38 +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:39:37 +0100 Date: Mon, 23 Dec 2024 20:39:35 +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 05/11] driver core: Simplify API device_find_child_by_name() implementation Message-ID: <20241223203935.00003de0@huawei.com> In-Reply-To: <20241211-const_dfc_done-v4-5-583cc60329df@quicinc.com> References: <20241211-const_dfc_done-v4-0-583cc60329df@quicinc.com> <20241211-const_dfc_done-v4-5-583cc60329df@quicinc.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: netdev@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: lhrpeml500009.china.huawei.com (7.191.174.84) To frapeml500008.china.huawei.com (7.182.85.71) On Wed, 11 Dec 2024 08:08:07 +0800 Zijun Hu wrote: > From: Zijun Hu > > Simplify device_find_child_by_name() implementation by both existing > API device_find_child() and device_match_name(). There is a subtle difference. In theory old code could dereference a NULL if parent->p == NULL, now it can't. Sounds at most like a harmless change but maybe you should mention it. Otherwise LGTM Reviewed-by: Jonathan Cameron > > Signed-off-by: Zijun Hu > --- > drivers/base/core.c | 13 +------------ > 1 file changed, 1 insertion(+), 12 deletions(-) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index bc3b523a4a6366080c3c9fd190e54c7fd13c8ded..8116bc8dd6e9eba0653ca686a90c7008de9e2840 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -4110,18 +4110,7 @@ EXPORT_SYMBOL_GPL(device_find_child); > struct device *device_find_child_by_name(struct device *parent, > const char *name) > { > - struct klist_iter i; > - struct device *child; > - > - if (!parent) > - return NULL; > - > - klist_iter_init(&parent->p->klist_children, &i); > - while ((child = next_device(&i))) > - if (sysfs_streq(dev_name(child), name) && get_device(child)) > - break; > - klist_iter_exit(&i); > - return child; > + return device_find_child(parent, name, device_match_name); > } > EXPORT_SYMBOL_GPL(device_find_child_by_name); > >