From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB5C0C433EF for ; Wed, 8 Jun 2022 11:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238233AbiFHLgc (ORCPT ); Wed, 8 Jun 2022 07:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238090AbiFHLg1 (ORCPT ); Wed, 8 Jun 2022 07:36:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D390012DBE7; Wed, 8 Jun 2022 04:36:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9E0EB82725; Wed, 8 Jun 2022 11:36:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E59C1C34116; Wed, 8 Jun 2022 11:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654688181; bh=dP9Oy9WgkXliN2Ot6SgwXyz2r0kt7Q/vFTkP+WlQgx4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AaIGMkPng8ojejS7t6MKm/Ln1HkuE+bxJhOpqA4XVLVC9p6BXaisvA/Ah/aC1T8c5 /DjroI2fuvLlbeN0ynkfuRqaXrIGJyVZxYGvEcuW4tnAHrtf8r1jtVmX6Xrk5UdJPm CLQi8Nh8qaPMUwbm56W9WGQUdBzBRrIFjevoNGVY= Date: Wed, 8 Jun 2022 13:36:17 +0200 From: Greg Kroah-Hartman To: Andy Shevchenko Cc: Mark Brown , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH v1 2/2] spi: Use device_find_first_child() instead of custom approach Message-ID: References: <20220607202058.8304-1-andriy.shevchenko@linux.intel.com> <20220607202058.8304-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220607202058.8304-2-andriy.shevchenko@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 07, 2022 at 11:20:58PM +0300, Andy Shevchenko wrote: > We have already a helper to get the first child device, use it and > drop custom approach. > > Signed-off-by: Andy Shevchenko > --- > drivers/spi/spi.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > index ea09d1b42bf6..87dc8773108b 100644 > --- a/drivers/spi/spi.c > +++ b/drivers/spi/spi.c > @@ -2613,11 +2613,6 @@ int spi_slave_abort(struct spi_device *spi) > } > EXPORT_SYMBOL_GPL(spi_slave_abort); > > -static int match_true(struct device *dev, void *data) > -{ > - return 1; > -} > - > static ssize_t slave_show(struct device *dev, struct device_attribute *attr, > char *buf) > { > @@ -2625,7 +2620,7 @@ static ssize_t slave_show(struct device *dev, struct device_attribute *attr, > dev); > struct device *child; > > - child = device_find_child(&ctlr->dev, NULL, match_true); > + child = device_find_first_child(&ctlr->dev); > return sprintf(buf, "%s\n", > child ? to_spi_device(child)->modalias : NULL); > } Horrible naming convention asside, what is this really showing? I do not see this documented in Documentation/ABI/ anywhere, so can it just be dropped entirely? Ah, it's in Documentation/spi/spi-summary.rst not where it belongs... Looks like "any" of the child devices could match here, so it's just finding the first one by default. So you aren't explicitly asking for the real first device, you could return the last one as well, and it would still work as there is just "one" device in this list from what I can tell. So is does this really deserve a new driver core api call? thanks, greg k-h