History

eeprom: at24: remove at24_platform_data

There are no more users of at24_platform_data. Remove the relevant header and modify the driver code to not use it anymore.

Bartosz Golaszewski committed 8 years ago

Commit 4fa882c1 parent 90733533 files · +75 −148Browse files

Unified · Split

3 files
  1. MAINTAINERS +0 −1
  2. drivers/misc/eeprom/at24.c +75 −87
  3. include/linux/platform_data/at24.h +0 −60
MAINTAINERS+0−1
@@ -2503,7 +2503,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git · 2502 unmodified lines
25032503 S: Maintained
25042504 F: Documentation/devicetree/bindings/eeprom/at24.txt
25052505 F: drivers/misc/eeprom/at24.c
2506−F: include/linux/platform_data/at24.h
25072506
25082507 ATA OVER ETHERNET (AOE) DRIVER
25092508 M: "Ed L. Cashin" <ed.cashin@acm.org>
drivers/misc/eeprom/at24.c+75−87
@@ -22,10 +22,24 @@ · 21 unmodified lines
2222 #include <linux/i2c.h>
2323 #include <linux/nvmem-provider.h>
2424 #include <linux/regmap.h>
25−#include <linux/platform_data/at24.h>
2625 #include <linux/pm_runtime.h>
2726 #include <linux/gpio/consumer.h>
2827
28+/* Address pointer is 16 bit. */
29+#define AT24_FLAG_ADDR16 BIT(7)
30+/* sysfs-entry will be read-only. */
31+#define AT24_FLAG_READONLY BIT(6)
32+/* sysfs-entry will be world-readable. */
33+#define AT24_FLAG_IRUGO BIT(5)
34+/* Take always 8 addresses (24c00). */
35+#define AT24_FLAG_TAKE8ADDR BIT(4)
36+/* Factory-programmed serial number. */
37+#define AT24_FLAG_SERIAL BIT(3)
38+/* Factory-programmed mac address. */
39+#define AT24_FLAG_MAC BIT(2)
40+/* Does not auto-rollover reads to the next slave address. */
41+#define AT24_FLAG_NO_RDROL BIT(1)
42+
2943 /*
3044 * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
3145 * Differences between different vendor product lines (like Atmel AT24C or
@@ -107,10 +121,6 @@ module_param_named(write_timeout, at24_write_timeout, uint, 0); · 75 unmodified lines
107121 MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
108122
109123 struct at24_chip_data {
110− /*
111− * these fields mirror their equivalents in
112− * struct at24_platform_data
113− */
114124 u32 byte_len;
115125 u8 flags;
116126 };
@@ -471,63 +481,11 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) · 354 unmodified lines
471481 return 0;
472482 }
473483
474−static void at24_properties_to_pdata(struct device *dev,
475− struct at24_platform_data *chip)
476−{
477− int err;
478− u32 val;
479−
480− if (device_property_present(dev, "read-only"))
481− chip->flags |= AT24_FLAG_READONLY;
482− if (device_property_present(dev, "no-read-rollover"))
483− chip->flags |= AT24_FLAG_NO_RDROL;
484−
485− err = device_property_read_u32(dev, "address-width", &val);
486− if (!err) {
487− switch (val) {
488− case 8:
489− if (chip->flags & AT24_FLAG_ADDR16)
490− dev_warn(dev, "Override address width to be 8, while default is 16\n");
491− chip->flags &= ~AT24_FLAG_ADDR16;
492− break;
493− case 16:
494− chip->flags |= AT24_FLAG_ADDR16;
495− break;
496− default:
497− dev_warn(dev, "Bad \"address-width\" property: %u\n",
498− val);
499− }
500− }
501−
502− err = device_property_read_u32(dev, "size", &val);
503− if (!err)
504− chip->byte_len = val;
505−
506− err = device_property_read_u32(dev, "pagesize", &val);
507− if (!err) {
508− chip->page_size = val;
509− } else {
510− /*
511− * This is slow, but we can't know all eeproms, so we better
512− * play safe. Specifying custom eeprom-types via platform_data
513− * is recommended anyhow.
514− */
515− chip->page_size = 1;
516− }
517−}
518−
519−static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata)
484+static const struct at24_chip_data *at24_get_chip_data(struct device *dev)
520485 {
521486 struct device_node *of_node = dev->of_node;
522487 const struct at24_chip_data *cdata;
523488 const struct i2c_device_id *id;
524− struct at24_platform_data *pd;
525−
526− pd = dev_get_platdata(dev);
527− if (pd) {
528− memcpy(pdata, pd, sizeof(*pdata));
529− return 0;
530− }
531489
532490 id = i2c_match_id(at24_ids, to_i2c_client(dev));
533491
@@ -544,13 +502,9 @@ static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata) · 10 unmodified lines
544502 cdata = acpi_device_get_match_data(dev);
545503
546504 if (!cdata)
547− return -ENODEV;
505+ return ERR_PTR(-ENODEV);
548506
549− pdata->byte_len = cdata->byte_len;
550− pdata->flags = cdata->flags;
551− at24_properties_to_pdata(dev, pdata);
552−
553− return 0;
507+ return cdata;
554508 }
555509
556510 static void at24_remove_dummy_clients(struct at24_data *at24)
@@ -619,7 +573,8 @@ static int at24_probe(struct i2c_client *client) · 62 unmodified lines
619573 {
620574 struct regmap_config regmap_config = { };
621575 struct nvmem_config nvmem_config = { };
622− struct at24_platform_data pdata = { };
576+ u32 byte_len, page_size, flags, addrw;
577+ const struct at24_chip_data *cdata;
623578 struct device *dev = &client->dev;
624579 bool i2c_fn_i2c, i2c_fn_block;
625580 unsigned int i, num_addresses;
@@ -634,35 +589,72 @@ static int at24_probe(struct i2c_client *client) · 8 unmodified lines
634589 i2c_fn_block = i2c_check_functionality(client->adapter,
635590 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
636591
637− err = at24_get_pdata(dev, &pdata);
592+ cdata = at24_get_chip_data(dev);
593+ if (IS_ERR(cdata))
594+ return PTR_ERR(cdata);
595+
596+ err = device_property_read_u32(dev, "pagesize", &page_size);
638597 if (err)
639− return err;
598+ /*
599+ * This is slow, but we can't know all eeproms, so we better
600+ * play safe. Specifying custom eeprom-types via platform_data
601+ * is recommended anyhow.
602+ */
603+ page_size = 1;
604+
605+ flags = cdata->flags;
606+ if (device_property_present(dev, "read-only"))
607+ flags |= AT24_FLAG_READONLY;
608+ if (device_property_present(dev, "no-read-rollover"))
609+ flags |= AT24_FLAG_NO_RDROL;
610+
611+ err = device_property_read_u32(dev, "address-width", &addrw);
612+ if (!err) {
613+ switch (addrw) {
614+ case 8:
615+ if (flags & AT24_FLAG_ADDR16)
616+ dev_warn(dev,
617+ "Override address width to be 8, while default is 16\n");
618+ flags &= ~AT24_FLAG_ADDR16;
619+ break;
620+ case 16:
621+ flags |= AT24_FLAG_ADDR16;
622+ break;
623+ default:
624+ dev_warn(dev, "Bad \"address-width\" property: %u\n",
625+ addrw);
626+ }
627+ }
628+
629+ err = device_property_read_u32(dev, "size", &byte_len);
630+ if (err)
631+ byte_len = cdata->byte_len;
640632
641633 if (!i2c_fn_i2c && !i2c_fn_block)
642− pdata.page_size = 1;
634+ page_size = 1;
643635
644− if (!pdata.page_size) {
636+ if (!page_size) {
645637 dev_err(dev, "page_size must not be 0!\n");
646638 return -EINVAL;
647639 }
648640
649− if (!is_power_of_2(pdata.page_size))
641+ if (!is_power_of_2(page_size))
650642 dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
651643
652− if (pdata.flags & AT24_FLAG_TAKE8ADDR)
644+ if (flags & AT24_FLAG_TAKE8ADDR)
653645 num_addresses = 8;
654646 else
655− num_addresses = DIV_ROUND_UP(pdata.byte_len,
656− (pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
647+ num_addresses = DIV_ROUND_UP(byte_len,
648+ (flags & AT24_FLAG_ADDR16) ? 65536 : 256);
657649
658− if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) {
650+ if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
659651 dev_err(dev,
660652 "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
661653 return -EINVAL;
662654 }
663655
664656 regmap_config.val_bits = 8;
665− regmap_config.reg_bits = (pdata.flags & AT24_FLAG_ADDR16) ? 16 : 8;
657+ regmap_config.reg_bits = (flags & AT24_FLAG_ADDR16) ? 16 : 8;
666658 regmap_config.disable_locking = true;
667659
668660 regmap = devm_regmap_init_i2c(client, &regmap_config);
@@ -675,11 +667,11 @@ static int at24_probe(struct i2c_client *client) · 6 unmodified lines
675667 return -ENOMEM;
676668
677669 mutex_init(&at24->lock);
678− at24->byte_len = pdata.byte_len;
679− at24->page_size = pdata.page_size;
680− at24->flags = pdata.flags;
670+ at24->byte_len = byte_len;
671+ at24->page_size = page_size;
672+ at24->flags = flags;
681673 at24->num_addresses = num_addresses;
682− at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len);
674+ at24->offset_adj = at24_get_offset_adj(flags, byte_len);
683675 at24->client[0].client = client;
684676 at24->client[0].regmap = regmap;
685677
@@ -687,10 +679,10 @@ static int at24_probe(struct i2c_client *client) · 1 unmodified line
687679 if (IS_ERR(at24->wp_gpio))
688680 return PTR_ERR(at24->wp_gpio);
689681
690− writable = !(pdata.flags & AT24_FLAG_READONLY);
682+ writable = !(flags & AT24_FLAG_READONLY);
691683 if (writable) {
692684 at24->write_max = min_t(unsigned int,
693− pdata.page_size, at24_io_limit);
685+ page_size, at24_io_limit);
694686 if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX)
695687 at24->write_max = I2C_SMBUS_BLOCK_MAX;
696688 }
@@ -733,7 +725,7 @@ static int at24_probe(struct i2c_client *client) · 36 unmodified lines
733725 nvmem_config.priv = at24;
734726 nvmem_config.stride = 1;
735727 nvmem_config.word_size = 1;
736− nvmem_config.size = pdata.byte_len;
728+ nvmem_config.size = byte_len;
737729
738730 at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
739731 if (IS_ERR(at24->nvmem)) {
@@ -742,13 +734,9 @@ static int at24_probe(struct i2c_client *client) · 2 unmodified lines
742734 }
743735
744736 dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
745− pdata.byte_len, client->name,
737+ byte_len, client->name,
746738 writable ? "writable" : "read-only", at24->write_max);
747739
748− /* export data to kernel code */
749− if (pdata.setup)
750− pdata.setup(at24->nvmem, pdata.context);
751−
752740 return 0;
753741
754742 err_clients:
include/linux/platform_data/at24.h+0−60
@@ -1,60 +0,0 @@
1−/*
2− * at24.h - platform_data for the at24 (generic eeprom) driver
3− * (C) Copyright 2008 by Pengutronix
4− * (C) Copyright 2012 by Wolfram Sang
5− * same license as the driver
6− */
7−
8−#ifndef _LINUX_AT24_H
9−#define _LINUX_AT24_H
10−
11−#include <linux/types.h>
12−#include <linux/nvmem-consumer.h>
13−#include <linux/bitops.h>
14−
15−/**
16− * struct at24_platform_data - data to set up at24 (generic eeprom) driver
17− * @byte_len: size of eeprom in byte
18− * @page_size: number of byte which can be written in one go
19− * @flags: tunable options, check AT24_FLAG_* defines
20− * @setup: an optional callback invoked after eeprom is probed; enables kernel
21− code to access eeprom via nvmem, see example
22− * @context: optional parameter passed to setup()
23− *
24− * If you set up a custom eeprom type, please double-check the parameters.
25− * Especially page_size needs extra care, as you risk data loss if your value
26− * is bigger than what the chip actually supports!
27− *
28− * An example in pseudo code for a setup() callback:
29− *
30− * void get_mac_addr(struct nvmem_device *nvmem, void *context)
31− * {
32− * u8 *mac_addr = ethernet_pdata->mac_addr;
33− * off_t offset = context;
34− *
35− * // Read MAC addr from EEPROM
36− * if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
37− * pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
38− * }
39− *
40− * This function pointer and context can now be set up in at24_platform_data.
41− */
42−
43−struct at24_platform_data {
44− u32 byte_len; /* size (sum of all addr) */
45− u16 page_size; /* for writes */
46− u8 flags;
47−#define AT24_FLAG_ADDR16 BIT(7) /* address pointer is 16 bit */
48−#define AT24_FLAG_READONLY BIT(6) /* sysfs-entry will be read-only */
49−#define AT24_FLAG_IRUGO BIT(5) /* sysfs-entry will be world-readable */
50−#define AT24_FLAG_TAKE8ADDR BIT(4) /* take always 8 addresses (24c00) */
51−#define AT24_FLAG_SERIAL BIT(3) /* factory-programmed serial number */
52−#define AT24_FLAG_MAC BIT(2) /* factory-programmed mac address */
53−#define AT24_FLAG_NO_RDROL BIT(1) /* does not auto-rollover reads to */
54− /* the next slave address */
55−
56− void (*setup)(struct nvmem_device *nvmem, void *context);
57− void *context;
58−};
59−
60−#endif /* _LINUX_AT24_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t