From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Andrew Lunn <andrew@lunn.ch>, GregKH <greg@kroah.com>
Cc: maxime.ripard@free-electrons.com, wsa@the-dreams.de,
broonie@kernel.org, vz@mleia.com, fd@ti.com,
linux-kernel@vger.kernel.org, pantelis.antoniou@konsulko.com,
bgolaszewski@baylibre.com
Subject: Re: [PATCHv4 7/7] misc: at24: replace memory_accessor with nvmem_device_read
Date: Wed, 17 Feb 2016 10:18:06 +0000 [thread overview]
Message-ID: <56C448DE.9030107@linaro.org> (raw)
In-Reply-To: <1455666097-9115-8-git-send-email-andrew@lunn.ch>
On 16/02/16 23:41, Andrew Lunn wrote:
> Now that the AT24 uses the NVMEM framework, replace the
> memory_accessor in the setup() callback with nvmem API calls.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> arch/arm/mach-davinci/board-mityomapl138.c | 5 +++--
> arch/arm/mach-davinci/common.c | 4 ++--
> drivers/misc/eeprom/at24.c | 31 +-----------------------------
> include/linux/davinci_emac.h | 4 ++--
> include/linux/memory.h | 11 -----------
> include/linux/platform_data/at24.h | 10 +++++-----
> 6 files changed, 13 insertions(+), 52 deletions(-)
Thanks for this patch, I like this.
>
> diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
> index de1316bf643a..62ebac51bab9 100644
> --- a/arch/arm/mach-davinci/board-mityomapl138.c
> +++ b/arch/arm/mach-davinci/board-mityomapl138.c
> @@ -115,13 +115,14 @@ static void mityomapl138_cpufreq_init(const char *partnum)
> static void mityomapl138_cpufreq_init(const char *partnum) { }
> #endif
>
> -static void read_factory_config(struct memory_accessor *a, void *context)
> +static void read_factory_config(struct nvmem_device *nvmem, void *context)
> {
> int ret;
> const char *partnum = NULL;
> struct davinci_soc_info *soc_info = &davinci_soc_info;
>
> - ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config));
> + ret = nvmem_device_read(nvmem, 0, sizeof(factory_config),
> + &factory_config);
> if (ret != sizeof(struct factory_config)) {
> pr_warn("Read Factory Config Failed: %d\n", ret);
> goto bad_config;
> diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c
> index a794f6d9d444..f55ef2ef2f92 100644
> --- a/arch/arm/mach-davinci/common.c
> +++ b/arch/arm/mach-davinci/common.c
> @@ -28,13 +28,13 @@ EXPORT_SYMBOL(davinci_soc_info);
> void __iomem *davinci_intc_base;
> int davinci_intc_type;
>
> -void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context)
> +void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context)
> {
> char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
> off_t offset = (off_t)context;
>
> /* Read MAC addr from EEPROM */
> - if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
> + if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
> pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
> }
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index f15cda93fc4c..089d6943f68a 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -56,7 +56,6 @@
>
> struct at24_data {
> struct at24_platform_data chip;
> - struct memory_accessor macc;
> int use_smbus;
> int use_smbus_write;
>
> @@ -410,30 +409,6 @@ static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
> /*-------------------------------------------------------------------------*/
>
> /*
> - * This lets other kernel code access the eeprom data. For example, it
> - * might hold a board's Ethernet address, or board-specific calibration
> - * data generated on the manufacturing floor.
> - */
> -
> -static ssize_t at24_macc_read(struct memory_accessor *macc, char *buf,
> - off_t offset, size_t count)
> -{
> - struct at24_data *at24 = container_of(macc, struct at24_data, macc);
> -
> - return at24_read(at24, buf, offset, count);
> -}
> -
> -static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf,
> - off_t offset, size_t count)
> -{
> - struct at24_data *at24 = container_of(macc, struct at24_data, macc);
> -
> - return at24_write(at24, buf, offset, count);
> -}
> -
> -/*-------------------------------------------------------------------------*/
> -
> -/*
> * Provide a regmap interface, which is registered with the NVMEM
> * framework
> */
> @@ -600,16 +575,12 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
> at24->chip = chip;
> at24->num_addresses = num_addresses;
>
> - at24->macc.read = at24_macc_read;
> -
> writable = !(chip.flags & AT24_FLAG_READONLY);
> if (writable) {
> if (!use_smbus || use_smbus_write) {
>
> unsigned write_max = chip.page_size;
>
> - at24->macc.write = at24_macc_write;
> -
> if (write_max > io_limit)
> write_max = io_limit;
> if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
> @@ -683,7 +654,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
>
> /* export data to kernel code */
> if (chip.setup)
> - chip.setup(&at24->macc, chip.context);
> + chip.setup(at24->nvmem, chip.context);
>
> return 0;
>
> diff --git a/include/linux/davinci_emac.h b/include/linux/davinci_emac.h
> index 542888504994..05b97144d342 100644
> --- a/include/linux/davinci_emac.h
> +++ b/include/linux/davinci_emac.h
> @@ -12,7 +12,7 @@
> #define _LINUX_DAVINCI_EMAC_H
>
> #include <linux/if_ether.h>
> -#include <linux/memory.h>
> +#include <linux/nvmem-consumer.h>
>
> struct mdio_platform_data {
> unsigned long bus_freq;
> @@ -46,5 +46,5 @@ enum {
> EMAC_VERSION_2, /* DM646x */
> };
>
> -void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context);
> +void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context);
> #endif
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index 8b8d8d12348e..b723a686fc10 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -137,17 +137,6 @@ extern struct memory_block *find_memory_block(struct mem_section *);
> #endif
>
> /*
> - * 'struct memory_accessor' is a generic interface to provide
> - * in-kernel access to persistent memory such as i2c or SPI EEPROMs
> - */
> -struct memory_accessor {
> - ssize_t (*read)(struct memory_accessor *, char *buf, off_t offset,
> - size_t count);
> - ssize_t (*write)(struct memory_accessor *, const char *buf,
> - off_t offset, size_t count);
> -};
> -
> -/*
> * Kernel text modification mutex, used for code patching. Users of this lock
> * can sleep.
> */
> diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h
> index c42aa89d34ee..dc9a13e5acda 100644
> --- a/include/linux/platform_data/at24.h
> +++ b/include/linux/platform_data/at24.h
> @@ -9,7 +9,7 @@
> #define _LINUX_AT24_H
>
> #include <linux/types.h>
> -#include <linux/memory.h>
> +#include <linux/nvmem-consumer.h>
>
> /**
> * struct at24_platform_data - data to set up at24 (generic eeprom) driver
> @@ -17,7 +17,7 @@
> * @page_size: number of byte which can be written in one go
> * @flags: tunable options, check AT24_FLAG_* defines
> * @setup: an optional callback invoked after eeprom is probed; enables kernel
> - code to access eeprom via memory_accessor, see example
> + code to access eeprom via nvmem, see example
> * @context: optional parameter passed to setup()
> *
> * If you set up a custom eeprom type, please double-check the parameters.
> @@ -26,13 +26,13 @@
> *
> * An example in pseudo code for a setup() callback:
> *
> - * void get_mac_addr(struct memory_accessor *mem_acc, void *context)
> + * void get_mac_addr(struct mvmem_device *nvmem, void *context)
> * {
> * u8 *mac_addr = ethernet_pdata->mac_addr;
> * off_t offset = context;
> *
> * // Read MAC addr from EEPROM
> - * if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
> + * if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
> * pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
> * }
> *
> @@ -48,7 +48,7 @@ struct at24_platform_data {
> #define AT24_FLAG_IRUGO 0x20 /* sysfs-entry will be world-readable */
> #define AT24_FLAG_TAKE8ADDR 0x10 /* take always 8 addresses (24c00) */
>
> - void (*setup)(struct memory_accessor *, void *context);
> + void (*setup)(struct nvmem_device *nvmem, void *context);
> void *context;
> };
>
>
next prev parent reply other threads:[~2016-02-17 10:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 23:41 [PATCHv4 0/7] Convert exiting EEPROM drivers to NVMEM Andrew Lunn
2016-02-16 23:41 ` [PATCHv4 1/7] nvmem: Add flag to export NVMEM to root only Andrew Lunn
2016-02-17 10:17 ` Srinivas Kandagatla
2016-02-17 13:32 ` Andrew Lunn
2016-02-16 23:41 ` [PATCHv4 2/7] nvmem: Add backwards compatibility support for older EEPROM drivers Andrew Lunn
2016-02-17 10:17 ` Srinivas Kandagatla
2016-02-17 13:27 ` Andrew Lunn
2016-02-16 23:41 ` [PATCHv4 3/7] eeprom: at24: extend driver to plug into the NVMEM framework Andrew Lunn
2016-02-17 10:17 ` Srinivas Kandagatla
2016-02-17 10:21 ` Wolfram Sang
2016-02-17 11:00 ` Srinivas Kandagatla
2016-02-17 11:00 ` Srinivas Kandagatla
2016-02-16 23:41 ` [PATCHv4 4/7] eeprom: at25: Remove in kernel API for accessing the EEPROM Andrew Lunn
2016-02-17 10:17 ` Srinivas Kandagatla
2016-02-16 23:41 ` [PATCHv4 5/7] eeprom: at25: extend driver to plug into the NVMEM framework Andrew Lunn
2016-02-17 10:17 ` Srinivas Kandagatla
2016-02-17 13:42 ` Andrew Lunn
2016-02-17 13:45 ` Srinivas Kandagatla
2016-02-16 23:41 ` [PATCHv4 6/7] eeprom: 93xx46: " Andrew Lunn
2016-02-17 10:17 ` Srinivas Kandagatla
2016-02-17 13:46 ` Srinivas Kandagatla
2016-02-16 23:41 ` [PATCHv4 7/7] misc: at24: replace memory_accessor with nvmem_device_read Andrew Lunn
2016-02-17 10:18 ` Srinivas Kandagatla [this message]
2016-02-17 10:17 ` [PATCHv4 0/7] Convert exiting EEPROM drivers to NVMEM Srinivas Kandagatla
2016-02-17 13:39 ` Andrew Lunn
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=56C448DE.9030107@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=andrew@lunn.ch \
--cc=bgolaszewski@baylibre.com \
--cc=broonie@kernel.org \
--cc=fd@ti.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=pantelis.antoniou@konsulko.com \
--cc=vz@mleia.com \
--cc=wsa@the-dreams.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.