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: 144902 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp24155ljw; Thu, 23 Aug 2018 03:33:56 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxGiMQEYnDzFnf7JGpbSY0v1iMJrMycWi9tHNuKySKzw3iOOH/4yqGmIG4JGdv8kVykksIn X-Received: by 2002:a63:e318:: with SMTP id f24-v6mr54363618pgh.175.1535020436044; Thu, 23 Aug 2018 03:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535020436; cv=none; d=google.com; s=arc-20160816; b=0JWoiovf2G9uGZXUYyvr0ADN+ygi78H+vn8a6n2uVBrUP7UQvU8kwNtzRmkqQZ7ZfJ 2+mb734H95DEF+f6YZN0T9bnBpsdg7XtYZ80cNVsuJbVdhxjshN7zUeGhm7CN3XV/k2I wiG6wpKsjRQHwwdxtzt+YSqFsDK1awpDCRFuT/1SsOp6HhNaY0+0NwFLxeqoaQKa/T+D 1l1IyuCmh298jIR/ghWuyx82AkU/tj0TkMl1bsvlXOJPblbNxX/PUFAiHPNd9FMHYnyP fKKW0/HP8Tvdqo75S4GVcCG7H8wlV31xS/iX01WYKmKPnNXL1Ehbk3DDL2X5suQhG39O WDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Md0Lqpdguoe3lO4kVNCF0PjHgEQLifusrdlUq5KP0Ic=; b=FZ/RGCRpu2ZAeHdlnMLF7ULvXCAN1AWcsY/IT+OUYX4EMw95W47f8D3w2pOqP06/s5 nX4wZN9iqsx03Jw9tuMsGgqrLNgpsUU64IQ+xw2FDxhVsMIIN3XVGh03teke6oOVcFK8 bI88G2JIoOCgOsTffe0ts6BZDASq/Kvmsn3x1G5En1eikf2GExbb/q86qNOcq4VmbsWq /cqGHR7x0pTGyPkCZ5H3cOjVQVydcMkJD6yQoeXsKEJTVbFahaSTiqdwez7S53F3AIbV I9aNbE7lNDUPpUPVH++rOqJeVnRXcaGnBuBKaO6pkW9+WRvWjT+Ey0WcRtnbwEdgxuwl 9/fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hygMGPRZ; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si4040393pls.431.2018.08.23.03.33.55; Thu, 23 Aug 2018 03:33:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hygMGPRZ; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbeHWOC6 (ORCPT + 1 other); 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-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 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(-) -- 2.17.0 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); /*