Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp619697rwb; Thu, 22 Sep 2022 04:28:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM69nMOPD0k3k3QaUZUCvj6mqSZkPyN0A9AzyNwM3y2/ZZ6LO4jZGv3RbF15rkUYCRG6qyRY X-Received: by 2002:a17:907:a425:b0:781:3b90:fb84 with SMTP id sg37-20020a170907a42500b007813b90fb84mr2471554ejc.388.1663846080162; Thu, 22 Sep 2022 04:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663846080; cv=none; d=google.com; s=arc-20160816; b=tlcmVrpwoaaiRlcuIDnc9ODY5Q6hUZdX7GQOzZtvTSa4izAcDiPTXpZUSgR9zoZQxf lMyCuu/xdmk0UewNahg5Gik5zq+Ns4/UZqITemiUvD+x6QjkoSoqxmzfI5cRBD85ldwD 5PlSV/LQ969RBgSYd1wXpogm4xsZ6Rbfjqmpbn0t8HuBHbzBeS52/MHkbjol4hBRO2/o PhDfncjuhB64elQXG42t5V6pCUAUxAb5JGePE85CihmzMZipVFGsVWlUs0YDoCB4EGD/ 3iiW+Of+xTyIB66/UJRFm4KLNNRywA59ry+qQrPvEBlmneS+gn5QK0kpJTq7A+Vk1wF9 KRKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=io+eH671YCfWAZNn8T989hrjqRuIh2EWWmI1ft7dIYQ=; b=VORS3xajchG4uCXkUzLmA+YjLuU5wKl0eGmfR8khXvAW/5QNx7r/t+gz+mhhxddm/c MQUVeQH6EGgnGQ/QDOZzGxBpgwomWYa4cJkbAaeC5b/1oqn1yVDiNdnEofuKE6K8kJS5 sm5PThY6xEDyA21Bv5qmZCoHMlkU7zuquE3apnAA/DXd9K6VQMtCgHHJEZwNzjGNmGfZ xidRRIqHpqcpyh7kGOZ3xRWlr8RUnP+5r7WcgyTNYP/shayv9z2ys0m1vn+/zPerpZow F/t7IhtyefFxM0TKeDlW/lCnPyrjLXLwkTgmith1a1+aXcN5he0hpMt4F7vR9p1miE1m maAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd44-20020a17090796ac00b00782650a2738si909745ejc.24.2022.09.22.04.27.33; Thu, 22 Sep 2022 04:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231589AbiIVLS4 (ORCPT + 99 others); Thu, 22 Sep 2022 07:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbiIVLSz (ORCPT ); Thu, 22 Sep 2022 07:18:55 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78889DED5D; Thu, 22 Sep 2022 04:18:54 -0700 (PDT) Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MYCMx3fZZz688vP; Thu, 22 Sep 2022 19:14:05 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 13:18:52 +0200 Received: from localhost (10.81.208.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 12:18:51 +0100 Date: Thu, 22 Sep 2022 12:18:50 +0100 From: Jonathan Cameron To: Andy Shevchenko CC: Mark Brown , , , Wei Yongjun , Jonathan Cameron , Subject: Re: [PATCH v1 1/1] spi: Introduce spi_get_device_match_data() helper Message-ID: <20220922121850.000006f3@huawei.com> In-Reply-To: <20220921204520.23984-1-andriy.shevchenko@linux.intel.com> References: <20220921204520.23984-1-andriy.shevchenko@linux.intel.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.81.208.231] X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Sep 2022 23:45:20 +0300 Andy Shevchenko wrote: > The proposed spi_get_device_match_data() helper is for retrieving > a driver data associated with the ID in an ID table. First, it tries > to get driver data of the device enumerated by firmware interface > (usually Device Tree or ACPI). If none is found it falls back to > the SPI ID table matching. > > Signed-off-by: Andy Shevchenko I like this in general, but we need to keep a close eye on usecases that are introduced to make sure that there is alignment between the contents of the tables. Perhaps the text should also explain a bit about why we would allow both paths (in many case, the fallback will work fine)... Previously a strong reason for that was that there was nothing to ensure that all dt table entries were mirrored in the spi_device_id table. As a side effect of the check to ensure module autoloading works, there is now a check for that. My personal view is we should still use the more generic path, even if magic under the hood puts the data in spi_id->driver_data. Jonathan > --- > drivers/spi/spi.c | 12 ++++++++++++ > include/linux/spi/spi.h | 3 +++ > 2 files changed, 15 insertions(+) > > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > index ad254b94308e..a0947d63afbc 100644 > --- a/drivers/spi/spi.c > +++ b/drivers/spi/spi.c > @@ -360,6 +360,18 @@ const struct spi_device_id *spi_get_device_id(const struct spi_device *sdev) > } > EXPORT_SYMBOL_GPL(spi_get_device_id); > > +const void *spi_get_device_match_data(const struct spi_device *sdev) > +{ > + const void *match; > + > + match = device_get_match_data(&sdev->dev); > + if (match) > + return match; > + > + return (const void *)spi_get_device_id(sdev)->driver_data; > +} > +EXPORT_SYMBOL_GPL(spi_get_device_match_data); > + > static int spi_match_device(struct device *dev, struct device_driver *drv) > { > const struct spi_device *spi = to_spi_device(dev); > diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h > index 6ea889df0813..f2565c24ef27 100644 > --- a/include/linux/spi/spi.h > +++ b/include/linux/spi/spi.h > @@ -1510,6 +1510,9 @@ extern void spi_unregister_device(struct spi_device *spi); > extern const struct spi_device_id * > spi_get_device_id(const struct spi_device *sdev); > > +extern const void * > +spi_get_device_match_data(const struct spi_device *sdev); > + > static inline bool > spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer) > {