diff options
Diffstat (limited to 'drivers/nvmem/eeprom_93xx46.c')
-rw-r--r-- | drivers/nvmem/eeprom_93xx46.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/drivers/nvmem/eeprom_93xx46.c b/drivers/nvmem/eeprom_93xx46.c index 49ed396dc2..3180b0cb69 100644 --- a/drivers/nvmem/eeprom_93xx46.c +++ b/drivers/nvmem/eeprom_93xx46.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Driver for 93xx46 EEPROMs * * (C) 2011 DENX Software Engineering, Anatolij Gustschin <agust@denx.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include <common.h> @@ -13,8 +10,6 @@ #include <driver.h> #include <of.h> #include <spi/spi.h> -#include <of.h> -#include <spi/spi.h> #include <malloc.h> #include <gpio.h> #include <of_gpio.h> @@ -79,10 +74,9 @@ static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev) return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH; } -static int eeprom_93xx46_read(struct device_d *dev, int off, - void *val, int count) +static int eeprom_93xx46_read(void *ctx, unsigned off, void *val, size_t count) { - struct eeprom_93xx46_dev *edev = dev->parent->priv; + struct eeprom_93xx46_dev *edev = ctx; char *buf = val; int err = 0; @@ -241,10 +235,9 @@ eeprom_93xx46_write_word(struct eeprom_93xx46_dev *edev, return ret; } -static int eeprom_93xx46_write(struct device_d *dev, const int off, - const void *val, int count) +static int eeprom_93xx46_write(void *ctx, unsigned off, const void *val, size_t count) { - struct eeprom_93xx46_dev *edev = dev->parent->priv; + struct eeprom_93xx46_dev *edev = ctx; const char *buf = val; int i, ret, step = 1; @@ -307,12 +300,13 @@ static const struct of_device_id eeprom_93xx46_of_table[] = { { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, }, {} }; +MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table); static int eeprom_93xx46_probe_dt(struct spi_device *spi) { const struct of_device_id *of_id = of_match_device(eeprom_93xx46_of_table, &spi->dev); - struct device_node *np = spi->dev.device_node; + struct device_node *np = spi->dev.of_node; struct eeprom_93xx46_platform_data *pd; enum of_gpio_flags of_flags; unsigned long flags = GPIOF_OUT_INIT_INACTIVE; @@ -369,19 +363,14 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi) return 0; } -static const struct nvmem_bus eeprom_93xx46_nvmem_bus = { - .write = eeprom_93xx46_write, - .read = eeprom_93xx46_read, -}; - -static int eeprom_93xx46_probe(struct device_d *dev) +static int eeprom_93xx46_probe(struct device *dev) { struct spi_device *spi = (struct spi_device *)dev->type_data; struct eeprom_93xx46_platform_data *pd; struct eeprom_93xx46_dev *edev; int err; - if (dev->device_node) { + if (dev->of_node) { err = eeprom_93xx46_probe_dt(spi); if (err < 0) return err; @@ -411,14 +400,15 @@ static int eeprom_93xx46_probe(struct device_d *dev) edev->size = 128; edev->nvmem_config.name = dev_name(&spi->dev); edev->nvmem_config.dev = &spi->dev; + edev->nvmem_config.priv = edev; edev->nvmem_config.read_only = pd->flags & EE_READONLY; - edev->nvmem_config.bus = &eeprom_93xx46_nvmem_bus; + edev->nvmem_config.reg_write = eeprom_93xx46_write; + edev->nvmem_config.reg_read = eeprom_93xx46_read; + edev->nvmem_config.stride = 4; edev->nvmem_config.word_size = 1; edev->nvmem_config.size = edev->size; - dev->priv = edev; - edev->nvmem = nvmem_register(&edev->nvmem_config); if (IS_ERR(edev->nvmem)) { err = PTR_ERR(edev->nvmem); @@ -435,7 +425,7 @@ fail: return err; } -static struct driver_d eeprom_93xx46_driver = { +static struct driver eeprom_93xx46_driver = { .name = "93xx46", .probe = eeprom_93xx46_probe, .of_compatible = DRV_OF_COMPAT(eeprom_93xx46_of_table), |