Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1235697lqo; Fri, 17 May 2024 15:46:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUisiqb4VtDF+RKPtPm8BoQzl1qWI4DRluJ4J58J04ShtGr96ANmaUD7ITaJ+6nRmTv3aNlz//wYqIy5wwTNe3Rh+cr8JzN8sWl2Kd3wQ== X-Google-Smtp-Source: AGHT+IGX6XBIdvNyGpVUsdg8dF6WOa2oZ7RfzmV9pZV3TGGLV0fSuPn5q5wwX60ULBhSbnBSHgD4 X-Received: by 2002:a92:c249:0:b0:36c:4f83:db3c with SMTP id e9e14a558f8ab-36cc149a38bmr255126065ab.24.1715985991697; Fri, 17 May 2024 15:46:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715985991; cv=pass; d=google.com; s=arc-20160816; b=Xw0XHVin5/YO0mqxeCLLnDWO/i7dfY2Ks77oZb55DSNxP3L2iPgqy7BWD0GbISDPeN j5CIAebW3XxQXLLQKBK4/0Yum0G8QvPZMlAUtYGhIUJt2s0ItyLkHHT0t/2ez5qYMovy K4s0d2Lw+e+puiuawPnv15SSKfQx51+D2tx7wObN/aDl6VTOzw+FmaECMCALS5B3tS9w IlL7AoWgIoE3fesQfWGCkasyeyr5wyqsVzq0WfVzfMbpTZGponmrj+Q8oanxRj6R/ha+ aW5eXvywBG4fn3Hh+YyWKQmf/qrTIlVtDK9jFJL8YL7IXECXFkrbLvczN/USjaJlpCPT QHzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=E0DPoF7eQ7WcXVz/jWUNAKaZYezHNcyKwmBqKb2x1IU=; fh=R8RFELwKVjrwL+P7kR7hr7w+pNRHoMSaO5S66DYdUQk=; b=cgHKXFsAGZsCuGcxdfcH6lYFmFajcw2SrTVzLLlaP9YPd871i7nNhrwx5D7oXo7/8a BMLeFHJwtA8r/BaHNPJf8E4uDmvy+Uw9hl31lXamoLb3eljOtcSkgi9g/L0JXfDKTnEl iYs5jYnXQHjWdwjv1AF67bxVdx/TxKJIX9P9yybi0+imiESR74D6evr74msRQSgiA9fa czDuspVE3CChvRpQ3pVKWbFIYV9XHCOw7XKhNCznq0eQ8keME0CTjrRMZh/0rGKmzKGj AqJW1PiMVLwXzlL8X7eHxHw3m3hr+VGyva1BN9OtJp7rcieZ3sMcjMw/29RLgWJiU7Ai sejg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hi4beZuA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182580-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182580-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6341404fb0asi5196606a12.874.2024.05.17.15.46.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 15:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182580-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hi4beZuA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182580-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182580-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 50E6EB22B0E for ; Fri, 17 May 2024 19:43:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFD71141999; Fri, 17 May 2024 19:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hi4beZuA" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D887140374; Fri, 17 May 2024 19:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715974974; cv=none; b=jeOqM8n+WZ/oa6U/Ey6tax47X2N+ahwVlPiPqO3BEkIllyiP7lTNa1mrEop6/+aoWdzmJiNvLPWpNTJwkpSjgo/NnFk/oobzUFuI5UVUXgwYIZzfPxhf/K1QwJpWKzXvsuUWAzjS3GzbVrvlb4H3tWwVl36qTayqX52H9WlHlZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715974974; c=relaxed/simple; bh=mNrq6bM6WjtCihUhoILAJJMc4Q5aBcdCL+ohBoGOtxs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gTwvUiJXuDMYaoH1VtFgPDe73r2NBVLVChOi+YjqEIx2R1QQhFHK78N4xd3ySQy4ABRyE/+ZGGd6LWB4Br7OpNg0m/9VBCnNw1NM/tcsvs3UE/J4maV+walx7wSgdvqiTgt/QfTWx0AUe19Jg3/D8xfDs2P7cueWzF7HjHWHkxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hi4beZuA; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715974972; x=1747510972; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=mNrq6bM6WjtCihUhoILAJJMc4Q5aBcdCL+ohBoGOtxs=; b=hi4beZuA69WWXjslrbHgLKwB5Sbd0TTF4hiO320rcJm1FHO9H2FcvXLu 8GKLEoYzXMP2G+9lFESDMmJaFfiW1uuGzUWB2NaoMWPHmom8tJKnykxQT Y911dwYIIxznnRCihT2nnFaj+IlrH34+2cpezGdGl88tih44xINa7A+os lZFputwfnl8AnUXVQNZAQXzmnCTGHpNDEqnmZ58TjvFCPVhDGmpY8pxxf kA9C5vf/1HRLHXUl/OscQutiLeqe/0hqDgGpZK81uybPPUcDnkJvidmGS FU37iAH1IDhreg03KwPHoQwO6PqHQ2+y3+VsTIBFYVcFFiryYzqajlr9t g==; X-CSE-ConnectionGUID: 13AMwrsLTcam47HMQEQE5w== X-CSE-MsgGUID: u+y5xakwRYyAFSKpXhQ3Ag== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12284441" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12284441" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 12:42:50 -0700 X-CSE-ConnectionGUID: 1zXn1NLrRSSi4cIybbQj7Q== X-CSE-MsgGUID: LFC95adQRt+5hFgJRvo9XA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31877129" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa008.fm.intel.com with ESMTP; 17 May 2024 12:42:49 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 59707118; Fri, 17 May 2024 22:42:47 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/3] spi: gpio: Make use of device properties Date: Fri, 17 May 2024 22:42:01 +0300 Message-ID: <20240517194246.747427-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240517194246.747427-1-andriy.shevchenko@linux.intel.com> References: <20240517194246.747427-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Convert the module to be property provider agnostic and allow it to be used on non-OF platforms. Include mod_devicetable.h explicitly to replace the dropped of.h which included mod_devicetable.h indirectly. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-gpio.c | 51 +++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index 909cce109bba..abf426711c22 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c @@ -5,17 +5,17 @@ * Copyright (C) 2006,2008 David Brownell * Copyright (C) 2017 Linus Walleij */ +#include #include +#include #include #include -#include -#include +#include #include #include #include - /* * This bitbanging SPI host driver should help make systems usable * when a native hardware SPI engine is not available, perhaps because @@ -326,29 +326,6 @@ static int spi_gpio_request(struct device *dev, struct spi_gpio *spi_gpio) return PTR_ERR_OR_ZERO(spi_gpio->sck); } -#ifdef CONFIG_OF -static const struct of_device_id spi_gpio_dt_ids[] = { - { .compatible = "spi-gpio" }, - {} -}; -MODULE_DEVICE_TABLE(of, spi_gpio_dt_ids); - -static int spi_gpio_probe_dt(struct platform_device *pdev, - struct spi_controller *host) -{ - host->dev.of_node = pdev->dev.of_node; - host->use_gpio_descriptors = true; - - return 0; -} -#else -static inline int spi_gpio_probe_dt(struct platform_device *pdev, - struct spi_controller *host) -{ - return 0; -} -#endif - static int spi_gpio_probe_pdata(struct platform_device *pdev, struct spi_controller *host) { @@ -389,19 +366,21 @@ static int spi_gpio_probe(struct platform_device *pdev) struct spi_controller *host; struct spi_gpio *spi_gpio; struct device *dev = &pdev->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct spi_bitbang *bb; host = devm_spi_alloc_host(dev, sizeof(*spi_gpio)); if (!host) return -ENOMEM; - if (pdev->dev.of_node) - status = spi_gpio_probe_dt(pdev, host); - else + if (fwnode) { + device_set_node(&host->dev, fwnode); + host->use_gpio_descriptors = true; + } else { status = spi_gpio_probe_pdata(pdev, host); - - if (status) - return status; + if (status) + return status; + } spi_gpio = spi_controller_get_devdata(host); @@ -459,10 +438,16 @@ static int spi_gpio_probe(struct platform_device *pdev) MODULE_ALIAS("platform:" DRIVER_NAME); +static const struct of_device_id spi_gpio_dt_ids[] = { + { .compatible = "spi-gpio" }, + {} +}; +MODULE_DEVICE_TABLE(of, spi_gpio_dt_ids); + static struct platform_driver spi_gpio_driver = { .driver = { .name = DRIVER_NAME, - .of_match_table = of_match_ptr(spi_gpio_dt_ids), + .of_match_table = spi_gpio_dt_ids, }, .probe = spi_gpio_probe, }; -- 2.43.0.rc1.1336.g36b5255a03ac