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
2503S: Maintained2503S: Maintained
2504F: Documentation/devicetree/bindings/eeprom/at24.txt2504F: Documentation/devicetree/bindings/eeprom/at24.txt
2505F: drivers/misc/eeprom/at24.c2505F: drivers/misc/eeprom/at24.c
2506F: include/linux/platform_data/at24.h
2507 2506
2508ATA OVER ETHERNET (AOE) DRIVER2507ATA OVER ETHERNET (AOE) DRIVER
2509M: "Ed L. Cashin" <ed.cashin@acm.org>2508M: "Ed L. Cashin" <ed.cashin@acm.org>
drivers/misc/eeprom/at24.c+75−87
@@ -22,10 +22,24 @@ · 21 unmodified lines
22#include <linux/i2c.h>22#include <linux/i2c.h>
23#include <linux/nvmem-provider.h>23#include <linux/nvmem-provider.h>
24#include <linux/regmap.h>24#include <linux/regmap.h>
25#include <linux/platform_data/at24.h>
26#include <linux/pm_runtime.h>25#include <linux/pm_runtime.h>
27#include <linux/gpio/consumer.h>26#include <linux/gpio/consumer.h>
28 27
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
29/*43/*
30 * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.44 * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
31 * Differences between different vendor product lines (like Atmel AT24C or45 * 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
107MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");121MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
108 122
109struct at24_chip_data {123struct at24_chip_data {
110 /*
111 * these fields mirror their equivalents in
112 * struct at24_platform_data
113 */
114 u32 byte_len;124 u32 byte_len;
115 u8 flags;125 u8 flags;
116};126};
@@ -471,63 +481,11 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) · 354 unmodified lines
471 return 0;481 return 0;
472}482}
473 483
474static void at24_properties_to_pdata(struct device *dev,484static const struct at24_chip_data *at24_get_chip_data(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
519static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata)
520{485{
521 struct device_node *of_node = dev->of_node;486 struct device_node *of_node = dev->of_node;
522 const struct at24_chip_data *cdata;487 const struct at24_chip_data *cdata;
523 const struct i2c_device_id *id;488 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 }
531 489
532 id = i2c_match_id(at24_ids, to_i2c_client(dev));490 id = i2c_match_id(at24_ids, to_i2c_client(dev));
533 491
@@ -544,13 +502,9 @@ static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata) · 10 unmodified lines
544 cdata = acpi_device_get_match_data(dev);502 cdata = acpi_device_get_match_data(dev);
545 503
546 if (!cdata)504 if (!cdata)
547 return -ENODEV;505 return ERR_PTR(-ENODEV);
548 506
549 pdata->byte_len = cdata->byte_len;507 return cdata;
550 pdata->flags = cdata->flags;
551 at24_properties_to_pdata(dev, pdata);
552
553 return 0;
554}508}
555 509
556static void at24_remove_dummy_clients(struct at24_data *at24)510static void at24_remove_dummy_clients(struct at24_data *at24)
@@ -619,7 +573,8 @@ static int at24_probe(struct i2c_client *client) · 62 unmodified lines
619{573{
620 struct regmap_config regmap_config = { };574 struct regmap_config regmap_config = { };
621 struct nvmem_config nvmem_config = { };575 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;
623 struct device *dev = &client->dev;578 struct device *dev = &client->dev;
624 bool i2c_fn_i2c, i2c_fn_block;579 bool i2c_fn_i2c, i2c_fn_block;
625 unsigned int i, num_addresses;580 unsigned int i, num_addresses;
@@ -634,35 +589,72 @@ static int at24_probe(struct i2c_client *client) · 8 unmodified lines
634 i2c_fn_block = i2c_check_functionality(client->adapter,589 i2c_fn_block = i2c_check_functionality(client->adapter,
635 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);590 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
636 591
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);
638 if (err)597 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;
640 632
641 if (!i2c_fn_i2c && !i2c_fn_block)633 if (!i2c_fn_i2c && !i2c_fn_block)
642 pdata.page_size = 1;634 page_size = 1;
643 635
644 if (!pdata.page_size) {636 if (!page_size) {
645 dev_err(dev, "page_size must not be 0!\n");637 dev_err(dev, "page_size must not be 0!\n");
646 return -EINVAL;638 return -EINVAL;
647 }639 }
648 640
649 if (!is_power_of_2(pdata.page_size))641 if (!is_power_of_2(page_size))
650 dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");642 dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
651 643
652 if (pdata.flags & AT24_FLAG_TAKE8ADDR)644 if (flags & AT24_FLAG_TAKE8ADDR)
653 num_addresses = 8;645 num_addresses = 8;
654 else646 else
655 num_addresses = DIV_ROUND_UP(pdata.byte_len,647 num_addresses = DIV_ROUND_UP(byte_len,
656 (pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256);648 (flags & AT24_FLAG_ADDR16) ? 65536 : 256);
657 649
658 if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) {650 if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
659 dev_err(dev,651 dev_err(dev,
660 "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");652 "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
661 return -EINVAL;653 return -EINVAL;
662 }654 }
663 655
664 regmap_config.val_bits = 8;656 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;
666 regmap_config.disable_locking = true;658 regmap_config.disable_locking = true;
667 659
668 regmap = devm_regmap_init_i2c(client, &regmap_config);660 regmap = devm_regmap_init_i2c(client, &regmap_config);
@@ -675,11 +667,11 @@ static int at24_probe(struct i2c_client *client) · 6 unmodified lines
675 return -ENOMEM;667 return -ENOMEM;
676 668
677 mutex_init(&at24->lock);669 mutex_init(&at24->lock);
678 at24->byte_len = pdata.byte_len;670 at24->byte_len = byte_len;
679 at24->page_size = pdata.page_size;671 at24->page_size = page_size;
680 at24->flags = pdata.flags;672 at24->flags = flags;
681 at24->num_addresses = num_addresses;673 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);
683 at24->client[0].client = client;675 at24->client[0].client = client;
684 at24->client[0].regmap = regmap;676 at24->client[0].regmap = regmap;
685 677
@@ -687,10 +679,10 @@ static int at24_probe(struct i2c_client *client) · 1 unmodified line
687 if (IS_ERR(at24->wp_gpio))679 if (IS_ERR(at24->wp_gpio))
688 return PTR_ERR(at24->wp_gpio);680 return PTR_ERR(at24->wp_gpio);
689 681
690 writable = !(pdata.flags & AT24_FLAG_READONLY);682 writable = !(flags & AT24_FLAG_READONLY);
691 if (writable) {683 if (writable) {
692 at24->write_max = min_t(unsigned int,684 at24->write_max = min_t(unsigned int,
693 pdata.page_size, at24_io_limit);685 page_size, at24_io_limit);
694 if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX)686 if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX)
695 at24->write_max = I2C_SMBUS_BLOCK_MAX;687 at24->write_max = I2C_SMBUS_BLOCK_MAX;
696 }688 }
@@ -733,7 +725,7 @@ static int at24_probe(struct i2c_client *client) · 36 unmodified lines
733 nvmem_config.priv = at24;725 nvmem_config.priv = at24;
734 nvmem_config.stride = 1;726 nvmem_config.stride = 1;
735 nvmem_config.word_size = 1;727 nvmem_config.word_size = 1;
736 nvmem_config.size = pdata.byte_len;728 nvmem_config.size = byte_len;
737 729
738 at24->nvmem = devm_nvmem_register(dev, &nvmem_config);730 at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
739 if (IS_ERR(at24->nvmem)) {731 if (IS_ERR(at24->nvmem)) {
@@ -742,13 +734,9 @@ static int at24_probe(struct i2c_client *client) · 2 unmodified lines
742 }734 }
743 735
744 dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",736 dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
745 pdata.byte_len, client->name,737 byte_len, client->name,
746 writable ? "writable" : "read-only", at24->write_max);738 writable ? "writable" : "read-only", at24->write_max);
747 739
748 /* export data to kernel code */
749 if (pdata.setup)
750 pdata.setup(at24->nvmem, pdata.context);
751
752 return 0;740 return 0;
753 741
754err_clients:742err_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
43struct 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