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 01/10] misc: eeprom_93xx46: Make use of device properties
Date: Wed,  8 May 2024 21:46:54 +0300	[thread overview]
Message-ID: <20240508184905.2102633-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240508184905.2102633-1-andriy.shevchenko@linux.intel.com>

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 <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/eeprom/eeprom_93xx46.c | 41 ++++++++++++++---------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index 45c8ae0db8f9..bbcc9412bb4e 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -10,13 +10,15 @@
 #include <linux/gpio/consumer.h>
 #include <linux/kernel.h>
 #include <linux/log2.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/spi/spi.h>
+
 #include <linux/nvmem-provider.h>
+
 #include <linux/eeprom_93xx46.h>
 
 #define OP_START	0x4
@@ -422,22 +424,20 @@ static const struct spi_device_id eeprom_93xx46_spi_ids[] = {
 };
 MODULE_DEVICE_TABLE(spi, eeprom_93xx46_spi_ids);
 
-static int eeprom_93xx46_probe_dt(struct spi_device *spi)
+static int eeprom_93xx46_probe_fw(struct device *dev)
 {
-	const struct of_device_id *of_id =
-		of_match_device(eeprom_93xx46_of_table, &spi->dev);
-	struct device_node *np = spi->dev.of_node;
+	const struct eeprom_93xx46_devtype_data *data;
 	struct eeprom_93xx46_platform_data *pd;
 	u32 tmp;
 	int ret;
 
-	pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL);
+	pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return -ENOMEM;
 
-	ret = of_property_read_u32(np, "data-size", &tmp);
+	ret = device_property_read_u32(dev, "data-size", &tmp);
 	if (ret < 0) {
-		dev_err(&spi->dev, "data-size property not found\n");
+		dev_err(dev, "data-size property not found\n");
 		return ret;
 	}
 
@@ -446,30 +446,28 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
 	} else if (tmp == 16) {
 		pd->flags |= EE_ADDR16;
 	} else {
-		dev_err(&spi->dev, "invalid data-size (%d)\n", tmp);
+		dev_err(dev, "invalid data-size (%d)\n", tmp);
 		return -EINVAL;
 	}
 
-	if (of_property_read_bool(np, "read-only"))
+	if (device_property_read_bool(dev, "read-only"))
 		pd->flags |= EE_READONLY;
 
-	pd->select = devm_gpiod_get_optional(&spi->dev, "select",
-					     GPIOD_OUT_LOW);
+	pd->select = devm_gpiod_get_optional(dev, "select", GPIOD_OUT_LOW);
 	if (IS_ERR(pd->select))
 		return PTR_ERR(pd->select);
+	gpiod_set_consumer_name(pd->select, "93xx46 EEPROMs OE");
 
 	pd->prepare = select_assert;
 	pd->finish = select_deassert;
-	gpiod_direction_output(pd->select, 0);
-
-	if (of_id->data) {
-		const struct eeprom_93xx46_devtype_data *data = of_id->data;
 
+	data = spi_get_device_match_data(to_spi_device(dev));
+	if (data) {
 		pd->quirks = data->quirks;
 		pd->flags |= data->flags;
 	}
 
-	spi->dev.platform_data = pd;
+	dev->platform_data = pd;
 
 	return 0;
 }
@@ -478,10 +476,11 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
 {
 	struct eeprom_93xx46_platform_data *pd;
 	struct eeprom_93xx46_dev *edev;
+	struct device *dev = &spi->dev;
 	int err;
 
-	if (spi->dev.of_node) {
-		err = eeprom_93xx46_probe_dt(spi);
+	if (dev_fwnode(dev)) {
+		err = eeprom_93xx46_probe_fw(dev);
 		if (err < 0)
 			return err;
 	}
@@ -565,7 +564,7 @@ static void eeprom_93xx46_remove(struct spi_device *spi)
 static struct spi_driver eeprom_93xx46_driver = {
 	.driver = {
 		.name	= "93xx46",
-		.of_match_table = of_match_ptr(eeprom_93xx46_of_table),
+		.of_match_table = eeprom_93xx46_of_table,
 	},
 	.probe		= eeprom_93xx46_probe,
 	.remove		= eeprom_93xx46_remove,
-- 
2.43.0.rc1.1336.g36b5255a03ac


  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 ` Andy Shevchenko [this message]
2024-05-27 13:21   ` [PATCH v1 01/10] misc: eeprom_93xx46: Make use of device properties 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 ` [PATCH v1 03/10] eeprom: digsy_mtc: Convert to use GPIO descriptors Andy Shevchenko
2024-05-27 13:24   ` 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-2-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®