mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH v1 03/10] eeprom: digsy_mtc: Convert to use GPIO descriptors
Date: Wed,  8 May 2024 21:46:56 +0300	[thread overview]
Message-ID: <20240508184905.2102633-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240508184905.2102633-1-andriy.shevchenko@linux.intel.com>

This converts the driver to use GPIO descriptors exclusively
to retrieve GPIO lines. Drop the old GPIO handling in favor of
the core managing it exclusively.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/eeprom/digsy_mtc_eeprom.c | 46 +++++++++++---------------
 1 file changed, 20 insertions(+), 26 deletions(-)

diff --git a/drivers/misc/eeprom/digsy_mtc_eeprom.c b/drivers/misc/eeprom/digsy_mtc_eeprom.c
index 4eddc5ba1af9..88888485e6f8 100644
--- a/drivers/misc/eeprom/digsy_mtc_eeprom.c
+++ b/drivers/misc/eeprom/digsy_mtc_eeprom.c
@@ -14,13 +14,12 @@
  * and delete this driver.
  */
 
-#include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_gpio.h>
-#include <linux/eeprom_93xx46.h>
 
 #define GPIO_EEPROM_CLK		216
 #define GPIO_EEPROM_CS		210
@@ -29,22 +28,13 @@
 #define GPIO_EEPROM_OE		255
 #define EE_SPI_BUS_NUM	1
 
-static void digsy_mtc_op_prepare(void *p)
-{
-	/* enable */
-	gpio_set_value(GPIO_EEPROM_OE, 0);
-}
+static const struct property_entry digsy_mtc_spi_properties[] = {
+	PROPERTY_ENTRY_U32("data-size", 8),
+	{ }
+};
 
-static void digsy_mtc_op_finish(void *p)
-{
-	/* disable */
-	gpio_set_value(GPIO_EEPROM_OE, 1);
-}
-
-struct eeprom_93xx46_platform_data digsy_mtc_eeprom_data = {
-	.flags		= EE_ADDR8 | EE_SIZE1K,
-	.prepare	= digsy_mtc_op_prepare,
-	.finish		= digsy_mtc_op_finish,
+static const struct software_node digsy_mtc_spi_node = {
+	.properties = digsy_mtc_spi_properties,
 };
 
 static struct spi_gpio_platform_data eeprom_spi_gpio_data = {
@@ -70,18 +60,19 @@ static struct gpiod_lookup_table eeprom_spi_gpiod_table = {
 			    "miso", GPIO_ACTIVE_HIGH),
 		GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CS,
 			    "cs", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_OE,
+			    "select", GPIO_ACTIVE_LOW),
 		{ },
 	},
 };
 
 static struct spi_board_info digsy_mtc_eeprom_info[] __initdata = {
 	{
-		.modalias		= "93xx46",
+		.modalias		= "eeprom-93xx46",
 		.max_speed_hz		= 1000000,
 		.bus_num		= EE_SPI_BUS_NUM,
 		.chip_select		= 0,
 		.mode			= SPI_MODE_0,
-		.platform_data		= &digsy_mtc_eeprom_data,
 	},
 };
 
@@ -89,15 +80,18 @@ static int __init digsy_mtc_eeprom_devices_init(void)
 {
 	int ret;
 
-	ret = gpio_request_one(GPIO_EEPROM_OE, GPIOF_OUT_INIT_HIGH,
-				"93xx46 EEPROMs OE");
-	if (ret) {
-		pr_err("can't request gpio %d\n", GPIO_EEPROM_OE);
-		return ret;
-	}
 	gpiod_add_lookup_table(&eeprom_spi_gpiod_table);
 	spi_register_board_info(digsy_mtc_eeprom_info,
 				ARRAY_SIZE(digsy_mtc_eeprom_info));
-	return platform_device_register(&digsy_mtc_eeprom);
+
+	ret = device_add_software_node(&digsy_mtc_eeprom.dev, &digsy_mtc_spi_node);
+	if (ret)
+		return ret;
+
+	ret = platform_device_register(&digsy_mtc_eeprom);
+	if (ret)
+		device_remove_software_node(&digsy_mtc_eeprom.dev);
+
+	return ret;
 }
 device_initcall(digsy_mtc_eeprom_devices_init);
-- 
2.43.0.rc1.1336.g36b5255a03ac


  parent reply	other threads:[~2024-05-08 18:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 18:46 [PATCH v1 00/10] misc: eeprom_93xx46: Get rid of legacy GPIO APIs Andy Shevchenko
2024-05-08 18:46 ` [PATCH v1 01/10] misc: eeprom_93xx46: Make use of device properties Andy Shevchenko
2024-05-27 13:21   ` Linus Walleij
2024-05-08 18:46 ` [PATCH v1 02/10] eeprom: digsy_mtc: Fix 93xx46 driver probe failure Andy Shevchenko
2024-05-08 18:46 ` Andy Shevchenko [this message]
2024-05-27 13:24   ` [PATCH v1 03/10] eeprom: digsy_mtc: Convert to use GPIO descriptors Linus Walleij
2024-05-08 18:46 ` [PATCH v1 04/10] misc: eeprom_93xx46: Hide legacy platform data in the driver Andy Shevchenko
2024-05-27 13:24   ` Linus Walleij
2024-05-08 18:46 ` [PATCH v1 05/10] misc: eeprom_93xx46: Remove ->prepare() and ->finish() customisation Andy Shevchenko
2024-05-27 13:25   ` Linus Walleij
2024-05-08 18:46 ` [PATCH v1 06/10] misc: eeprom_93xx46: Use spi_message_init_with_transfers() Andy Shevchenko
2024-05-08 18:47 ` [PATCH v1 07/10] misc: eeprom_93xx46: Convert to use kstrtox() Andy Shevchenko
2024-05-27 13:26   ` Linus Walleij
2024-05-08 18:47 ` [PATCH v1 08/10] misc: eeprom_93xx46: Replace explicit castings with proper specifiers Andy Shevchenko
2024-05-27 13:29   ` Linus Walleij
2024-05-08 18:47 ` [PATCH v1 09/10] misc: eeprom_93xx46: Use string_choices API instead of ternary operator Andy Shevchenko
2024-05-27 13:30   ` Linus Walleij
2024-05-08 18:47 ` [PATCH v1 10/10] misc: eeprom_93xx46: Convert to DEVICE_ATTR_WO() Andy Shevchenko
2024-05-27 13:31   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240508184905.2102633-4-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®