From patchwork Mon Jun 18 07:45:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138859 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643915lji; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJtfpWwPaNWWKR6z4RQ2JXBwgJiOzRQsrMO3acb+/sO7kebf9MESaV9S8wk6DI1nIDMLLIQ X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr10355211pge.11.1529307979819; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307979; cv=none; d=google.com; s=arc-20160816; b=KW5jdUl5o4NXzTgQoxRM/wsDferiCTE3eu8z7qhhZQchQFZEK+rGc99aJLJeV9w99L wiJzCu+HftuDGUnY1WRyUKT8KZmS55hy4HkrZ+bRRsVx2/1cvqr83r7YdoNYQJDiDXID Tl5tB5mezSsgnCgRPwh9ib2lglmX/06SQyEqNtl+gKQDisSsFbtglqBcETAJjKxppNF4 bRTBR9+ImQc12ahT7LAkj+XusDEenteryg7N18PKT4S/NsiMvI5p5ZeamYeAakDC26mT Dmk9xo9vzYmMCaOJuYIalZQKkywrL7HlT+rdcfIJm/wGXs9ewxtnimOnHZh0iGhT2lhX 1pXQ== 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=I64qpXXBPr0KxjmB57F0kqcVuaa8E0tycPhFE0T39Mc=; b=XLTXldcEOl4pUW//LkFPJjl98GJW5c6ELWi9svLYkCtf04WVTmLFNVbJEMkJvJGVw7 c1EzryqWw0p5/LK6OrbB30f4aZ2OS4LS1PAS2ft/ng0FnKxaAWerMuY/kCPB8jFoqBeg N4vyHapktsz84yVNd7pjvaqPHXOV1sxMK4MwEyAsg4Jtif/6wg3NQWXLKVfAKnQyDnbX vm9u04Kphh5Ygr8Q5X/7E5b84OUsw6fLsbukNK8nW9Bbg4aiYmua5pEVcgTHtUFsw9ro 36T8mIEqpdLtG2T1Yixm60jgCMM1+Ac3rMySWAy6C7skG+0Fd/BDfVdSpuPA1KRDV9y5 LRZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=S+yvVAzr; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (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 w2-v6si11655956pgs.59.2018.06.18.00.46.19; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=S+yvVAzr; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755188AbeFRHqT (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:19 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:40784 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754983AbeFRHqS (ORCPT ); Mon, 18 Jun 2018 03:46:18 -0400 Received: by mail-lf0-f65.google.com with SMTP id q11-v6so23120420lfc.7 for ; Mon, 18 Jun 2018 00:46:17 -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=qMxxS4Flb5C1krxYYrdSlGB/4puq1cJ1JbMAz74PBPA=; b=S+yvVAzri6GVSl869nKYsd/igxKprWuhOCzMKqHSkRCq2Oan8UL3ZuZnbktmEUR0R0 pXYFGsIFFPxQJt2iSB4Inrlvh5hqkhMqK/On7l8ZpiEUeFgVqG0UjaUK8n15R3KM/iZX bSpp8VCPsGfZ02+ZVayHgIPqIDz+dg8PCoe50= 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=qMxxS4Flb5C1krxYYrdSlGB/4puq1cJ1JbMAz74PBPA=; b=O+gLM8OQ0iFWnJmnPMQs5LA5oX8g6OXX6yJzPwm6C8UG9VJ3H7jVylFDzMxSayOLIG 7P9JOUyBzHy2e4eXWm2JWfecsN7ZwQCp87f37QP+k5hn3sZTnfgbdkuBYEqD8lUknak7 pnG8xw9TCZ1F01KAVT84ZFipOnks5HgXLt5W8mvQuqjJbMmB4nOGD2udepQrzPjDRmgy /zjTeHOhuoyen3+7YVMTiiGa/0G0KC58CYEsgpUycDpEoXAwC0l9bOkESppWzklliny8 IUUmWcERn2BG/I86t/ITck8z26u3YIlEMq64q7C6ux/BCKi454UuBGKtxHiJjqiouzCB aPJQ== X-Gm-Message-State: APt69E15UXE69e3w5o3OrEPhJinXaQ5mCNEt1JGsNgc1Iy6rFoeH4AR7 bXYbk1aZD5mhhbpE0rzUhrPCsJXumho= X-Received: by 2002:a19:a892:: with SMTP id r140-v6mr6555672lfe.39.1529307976900; Mon, 18 Jun 2018 00:46:16 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:15 -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 Subject: [PATCH 3/5] RFC: spi: Make of_find_spi_device_by_node() available Date: Mon, 18 Jun 2018 09:45:54 +0200 Message-Id: <20180618074556.6944-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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. Signed-off-by: Linus Walleij --- drivers/spi/spi.c | 33 ++++++++++++++++++--------------- include/linux/spi/spi.h | 4 ++++ 2 files changed, 22 insertions(+), 15 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); /*