Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bec3c11b authored by Andrew Lunn's avatar Andrew Lunn Committed by Greg Kroah-Hartman
Browse files

misc: at24: replace memory_accessor with nvmem_device_read



Now that the AT24 uses the NVMEM framework, replace the
memory_accessor in the setup() callback with nvmem API calls.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Acked-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: default avatarSekhar Nori <nsekhar@ti.com>
Acked-by: default avatarWolfram Sang <wsa@the-dreams.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1c4b6e2c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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);
}

+1 −30
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@

struct at24_data {
	struct at24_platform_data chip;
	struct memory_accessor macc;
	int use_smbus;
	int use_smbus_write;

@@ -409,30 +408,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;

+2 −2
Original line number Diff line number Diff line
@@ -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
+0 −11
Original line number Diff line number Diff line
@@ -136,17 +136,6 @@ extern struct memory_block *find_memory_block(struct mem_section *);
#define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })
#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.
Loading