From patchwork Thu Aug 23 10:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10573711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92F8C14E1 for ; Thu, 23 Aug 2018 10:33:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86AF92B521 for ; Thu, 23 Aug 2018 10:33:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AAED2B6AE; Thu, 23 Aug 2018 10:33:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AC452B521 for ; Thu, 23 Aug 2018 10:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbeHWOC6 (ORCPT ); Thu, 23 Aug 2018 10:02:58 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:43533 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728156AbeHWOC6 (ORCPT ); Thu, 23 Aug 2018 10:02:58 -0400 Received: by mail-lf1-f68.google.com with SMTP id h64-v6so2179334lfi.10 for ; Thu, 23 Aug 2018 03:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Md0Lqpdguoe3lO4kVNCF0PjHgEQLifusrdlUq5KP0Ic=; b=hygMGPRZcDhP7uRY0MvWqQPrVwdnV7NPKlIu8shM/jT1h/Mcrcvg6QOhRQp7pgwQ5y TvpfPXkYfDekps8qnE0bW+Euk+vyGZcd/ILkCSRYFoPOGY4SfTw2nW+5+R3DEmNNMZ6X xvsI1HO78ji4MNWA4+m/VLpGdn/UPKjHN7fbM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Md0Lqpdguoe3lO4kVNCF0PjHgEQLifusrdlUq5KP0Ic=; b=A+WGNcqSl2T8JsvA0sa7Dv59sbraGGrFTlfLxNv1OzW0sEAzOlzv5T9pJ9uYeBAcYo jdq85JwCvRniKOTcGo0cZb4HF56N3ZYs9HKJl0QgTWZFTDCbXH/2+P+whiIN+8dSbMj1 Spfk13R6BdG0l0trr8EMQME8i2kkh4lw9cwxq6w7brFus9DGX5d5bmFdqfXAo2YFxAOa EbNegY1To567dr95WzoM4ZQ7EFJDZAAQGiTCKi/lj51rZJ3BSZpBne0oWbJlrTpoOtjV J6IjjGl/zf7lA3z4XS7Jr7I58O+PwBMZeBNKQ32jer3yImq1TgPkrLeU/kc9fQ6hMNFq z5Kg== X-Gm-Message-State: AOUpUlGSZAqJ/wTk9aQgpbXAv3XteqCBw4tJJKDDaYTlg9mZ9DJV4Tpi TRe6XAUc1d2SGAO/CJc51zdK3A== X-Google-Smtp-Source: AA+uWPxyl1G07SFWikq2Fl1iUDCfHvXYFQzXLhObxO82FkhXkQo6rBV2cW8L6dwTeNFEYGW9accKTw== X-Received: by 2002:a19:e51a:: with SMTP id c26-v6mr9699744lfh.78.1535020432781; Thu, 23 Aug 2018 03:33:52 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s74-v6sm556898lfg.79.2018.08.23.03.33.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 03:33:51 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij , linux-spi@vger.kernel.org Subject: [PATCH 2/4] spi: Make of_find_spi_device_by_node() available Date: Thu, 23 Aug 2018 12:33:30 +0200 Message-Id: <20180823103332.32047-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180823103332.32047-1-linus.walleij@linaro.org> References: <20180823103332.32047-1-linus.walleij@linaro.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This externalizes and exports the symbol of_find_spi_device_by_node() from the SPI core akin to how of_find_i2c_adapter_by_node() is already available. As we will need this also for non-dynamic OF setups, we move it under a CONFIG_OF check. Cc: Mark Brown Cc: linux-spi@vger.kernel.org Signed-off-by: Linus Walleij --- ChangeLog RFC->v1: - No changes - Requesting an ACK from the SPI mainatiner so that this patch can be applied with the rest of the series. --- drivers/spi/spi.c | 33 ++++++++++++++++++--------------- include/linux/spi/spi.h | 4 ++++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ec395a6baf9c..6a1085077317 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3314,27 +3314,14 @@ EXPORT_SYMBOL_GPL(spi_write_then_read); /*-------------------------------------------------------------------------*/ -#if IS_ENABLED(CONFIG_OF_DYNAMIC) -static int __spi_of_device_match(struct device *dev, void *data) -{ - return dev->of_node == data; -} - -/* must call put_device() when done with returned spi_device device */ -static struct spi_device *of_find_spi_device_by_node(struct device_node *node) -{ - struct device *dev = bus_find_device(&spi_bus_type, NULL, node, - __spi_of_device_match); - return dev ? to_spi_device(dev) : NULL; -} - +#if IS_ENABLED(CONFIG_OF) static int __spi_of_controller_match(struct device *dev, const void *data) { return dev->of_node == data; } /* the spi controllers are not using spi_bus, so we find it with another way */ -static struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) +struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) { struct device *dev; @@ -3349,6 +3336,22 @@ static struct spi_controller *of_find_spi_controller_by_node(struct device_node /* reference got in class_find_device */ return container_of(dev, struct spi_controller, dev); } +EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node); +#endif + +#if IS_ENABLED(CONFIG_OF_DYNAMIC) +static int __spi_of_device_match(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +/* must call put_device() when done with returned spi_device device */ +static struct spi_device *of_find_spi_device_by_node(struct device_node *node) +{ + struct device *dev = bus_find_device(&spi_bus_type, NULL, node, + __spi_of_device_match); + return dev ? to_spi_device(dev) : NULL; +} static int of_spi_notify(struct notifier_block *nb, unsigned long action, void *arg) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index a64235e05321..c2be93224bd1 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -639,6 +639,10 @@ extern int devm_spi_register_controller(struct device *dev, struct spi_controller *ctlr); extern void spi_unregister_controller(struct spi_controller *ctlr); +#if IS_ENABLED(CONFIG_OF) +struct spi_controller *of_find_spi_controller_by_node(struct device_node *node); +#endif + extern struct spi_controller *spi_busnum_to_master(u16 busnum); /*