From patchwork Fri May 17 19:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13667346 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hi4beZuA" 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-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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, }; From patchwork Fri May 17 19:42:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13667347 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 6B5601411C8; Fri, 17 May 2024 19:42:53 +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=tJV21R8ltPG21o0BI9oA9cnT2LW2Qu2JmzXt6yYfAnh4+mBiD/Z1n2arWZmMy6VFebNAKVsjlAokGRqXParygC2q07SxgAvPdsOQKPMkZguus6iaMxyI3UEZU4rw7gKDg0a8iWJ7lkE6AW8AI2BoNJuoownjh+UC6zyMTwgk6+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715974974; c=relaxed/simple; bh=tth4i9z4tN9bpsaaew9NWOzq4W2ulOpkhRXHXUekINA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iQjGWfiCVyI4eswhncEN28viOvgEQGwrg0cdTIJJJcw0L4nhXGb6dtskgnA9+gIsc/iYRZLSmae3IivWakJXiWhRZ2LDtRHmlezbqBdVsMq2o9PccApKkRV4Fnun8daOz38mTnJYAL+FO29rWDh0REOn8pghHbN3Jsv+hs2R08A= 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=LlsXsMjN; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LlsXsMjN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715974974; x=1747510974; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=tth4i9z4tN9bpsaaew9NWOzq4W2ulOpkhRXHXUekINA=; b=LlsXsMjNymHpaXeIW4e1xUuxKQQo7mGdiTRTxFA10N56n/NH99LrVsNl NA42cf/hO22LrWqApuTEDK2bZEuauioWu8avUO/Xckej4EWCWrhC8NzJ0 X+OHtGtuiwcTfkbPwtgUhhgBY2bzHJvYWyAYlG5IlcM3lcLEnSlT8JL5Q fDB58VNjnVn4Y6Zkozcn9yP5Yz0eETgiM+u2/QAVAs9f0TSgZLbJu+6Wc s1Bi7v9MoFeU5kaWwlELFpUd8iTbE0ewKaKRs2JYpLszY0M9cqb2sxJHe 38JQuZYAD6iD8AMmwM9h+rs9n8WYM8KGVyQN4Q0bYBcb5CBi7D8cptugL A==; X-CSE-ConnectionGUID: v8mnb8CNT1iKQr609v54Kg== X-CSE-MsgGUID: O7Jth8EjRc2iEBMIM1tzlg== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12284445" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12284445" 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: Z6FEC964SjqsKys5UHAxBQ== X-CSE-MsgGUID: K0JXPaHlRHiud2vEUOkpuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31877131" 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 6291E2D2; 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 2/3] spi: gpio: Use traditional pattern when checking error codes Date: Fri, 17 May 2024 22:42:02 +0300 Message-ID: <20240517194246.747427-3-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-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of 'if (!ret)' switch to "check for the error first" rule. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-gpio.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index abf426711c22..36c587be9e28 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c @@ -239,8 +239,8 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active) static int spi_gpio_setup(struct spi_device *spi) { struct gpio_desc *cs; - int status = 0; struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + int ret; /* * The CS GPIOs have already been @@ -248,15 +248,14 @@ static int spi_gpio_setup(struct spi_device *spi) */ if (spi_gpio->cs_gpios) { cs = spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)]; - if (!spi->controller_state && cs) - status = gpiod_direction_output(cs, - !(spi->mode & SPI_CS_HIGH)); + if (!spi->controller_state && cs) { + ret = gpiod_direction_output(cs, !(spi->mode & SPI_CS_HIGH)); + if (ret) + return ret; + } } - if (!status) - status = spi_bitbang_setup(spi); - - return status; + return spi_bitbang_setup(spi); } static int spi_gpio_set_direction(struct spi_device *spi, bool output) From patchwork Fri May 17 19:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13667345 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 02CF5140389; 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=1715974973; cv=none; b=WHvBeppmVqgzr1ncb8fCJ0ASppccfGHHoXP58Sfv6FwcbsTrOpu5Ora0jUG0wiGhr9lWJ/mx7SLBc6IjA3eql+13bk5xUIxrqCZ7yteBgyF7YEZzURNorZaVnMOpsrjc/3tBzEfWrXHasfUl1bsQV3DmXfn5VcLv/sw9MnIRpVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715974973; c=relaxed/simple; bh=T1kuw4kCQWu1DfL0XSLMFMWTgv2DAoA+X+Ligd/mQMI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qTlUz6qyaszDeeVTA1ipZ5AmcHroFhMktJxJB5W9Ld4qv8HG6LnPkuo52enKOethWyRUtcDFFhL16jQJyqSkc5ejFA8/PFznZRrrhU6FFXaADB4phH+UQAcK+sBxQViTwkymhyft0eKje6uBf7iuS9M2u63KRArj2/DAFqn8wV8= 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=GqJ6o4sf; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GqJ6o4sf" 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=T1kuw4kCQWu1DfL0XSLMFMWTgv2DAoA+X+Ligd/mQMI=; b=GqJ6o4sfDzw+EX7tfWxPDqOVt+/ejxQUCWTJrnI61Mb+yNFzqwoP2ZNq bUl6ar8Gqv2JE+LLAx9IAJ473jmXc542QDTCuzQoc/XdllZuhs7wnjO/j nekBgSrcJDUQQQwvZvq2If5XSUdn80tW88AVaxSim0CWfo4WtDa9BUDaj 4b+10raSbmk0qh9n8MY8h8ivFQ1+N6aoxxhM0X3pqYOeUl1cMqU/363I/ pGoaxEut8i3lo2icDP11fccFcHrgSMpexaEyhMwq5WXgOimMCobqM0vxx ueTRvzSxu/nXbPZFFGJzH/QX+fua3iz4/66I9cT63eGnjQSn4d1R7KIg2 g==; X-CSE-ConnectionGUID: sal2Nk4GSIWnMTmWUsBqbQ== X-CSE-MsgGUID: xSv3uM8VSfijCMYulG1hIw== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12284443" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12284443" 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: PLe1T2pqTAC0fd0MbVuRgw== X-CSE-MsgGUID: zPPbqklARa6KYf38OCmlCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31877130" 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 786F644E; 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 3/3] spi: gpio: Make num_chipselect 8-bit in the struct spi_gpio_platform_data Date: Fri, 17 May 2024 22:42:03 +0300 Message-ID: <20240517194246.747427-4-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-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no use for whole 16-bit for the number of chip select pins. Drop it to 8 bits. Signed-off-by: Andy Shevchenko --- include/linux/spi/spi_gpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/spi/spi_gpio.h b/include/linux/spi/spi_gpio.h index 5f0e1407917a..30f29df811a4 100644 --- a/include/linux/spi/spi_gpio.h +++ b/include/linux/spi/spi_gpio.h @@ -19,7 +19,7 @@ * @num_chipselect: how many target devices to allow */ struct spi_gpio_platform_data { - u16 num_chipselect; + u8 num_chipselect; }; #endif /* __LINUX_SPI_GPIO_H */