History log of /linux-master/drivers/misc/eeprom/at24.c
Revision Date Author Comments
# 2b0eee4f 23-Nov-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

eeprom: at24: use of_match_ptr()

This driver does not depend on CONFIG_OF so using of_match_ptr() makes
sense to reduce the size a bit.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# e68f4871 20-Dec-2023 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: Use pm_runtime_resume_and_get to simplify the code

Use helper pm_runtime_resume_and_get() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/c3045427-da42-4f7c-8a96-3c4756646cd0@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# caba40ec 20-Dec-2023 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: Probe for DDR3 thermal sensor in the SPD case

The DDR3 SPD data structure advertises the presence of a thermal
sensor on a DDR3 module in byte 32, bit 7. Let's use this information
to explicitly instantiate the thermal sensor I2C client instead of
having to rely on class-based I2C probing.

The temp sensor i2c address can be derived from the SPD i2c address,
so we can directly instantiate the device and don't have to probe
for it. If the temp sensor has been instantiated already by other
means (e.g. class-based auto-detection), then the busy-check in
i2c_new_client_device will detect this.

Note: Thermal sensors on DDR4 DIMM's are instantiated from the
ee1004 driver.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/68113672-3724-44d5-9ff8-313dd6628f8c@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3774740f 13-Oct-2023 Alexander Stein <alexander.stein@ew.tq-group.com>

eeprom: at24: add ST M24C64-D Additional Write lockable page support

The ST M24C64-D behaves as a regular M24C64, except for the -D variant
which uses up another I2C address for Additional Write lockable page.
This page is 32 Bytes long and can contain additional data. Add entry
for it, so users can describe that page in DT. Note that users still
have to describe the main M24C64 area separately as that is on separate
I2C address from this page.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 4791146e 10-Oct-2023 Marek Vasut <marex@denx.de>

eeprom: at24: add ST M24C32-D Additional Write lockable page support

The ST M24C32-D behaves as a regular M24C32, except for the -D variant
which uses up another I2C address for Additional Write lockable page.
This page is 32 Bytes long and can contain additional data. Add entry
for it, so users can describe that page in DT. Note that users still
have to describe the main M24C32 area separately as that is on separate
I2C address from this page.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 997a29bb 22-Sep-2023 Kees Cook <keescook@chromium.org>

eeprom: at24: Annotate struct at24_data with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct at24_data.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 4cdc5dbb 02-Sep-2023 Biju Das <biju.das.jz@bp.renesas.com>

eeprom: at24: Drop at24_get_chip_data()

Replace at24_get_chip_data()->i2c_get_match_data() as it is
redundant.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# f050bb8f 17-May-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

misc: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

While touching these drivers, fix alignment in apds990x.c and bh1770glc.c.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Link: https://lore.kernel.org/r/20230517220135.170379-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a3c10035 16-May-2023 Alexander Stein <alexander.stein@ew.tq-group.com>

eeprom: at24: Use dev_err_probe for nvmem register failure

When using nvmem layouts it is possible devm_nvmem_register returns
-EPROBE_DEFER, resulting in an 'empty' in
/sys/kernel/debug/devices_deferred. Use dev_err_probe for providing
additional information.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# ed5c2f5f 15-Aug-2022 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

i2c: Make remove callback return void

The value returned by an i2c driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Crt Mori <cmo@melexis.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/*
Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5
Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio
Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860
Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b
Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes
Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power
Acked-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>


# d08aea21 10-Dec-2021 Maxim Kochetkov <fido_max@inbox.ru>

eeprom: at24: Add support for 24c1025 EEPROM

Microchip EEPROM 24xx1025 is like a 24c1024. The only difference
between them is that the I2C address bit used to select between the
two banks is bit 2 for the 1025 and not bit 0 as in the 1024.

Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 92e17647 28-Nov-2021 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: remove struct at24_client

We use member client only to get a reference to the associated struct
device, via &client->dev. However we can get the same reference from
the associated regmap, via regmap_get_device(regmap).
Therefore struct at24_client can be removed and replaced with a regmap
pointer.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 1e96078e 18-Oct-2021 Sakari Ailus <sakari.ailus@linux.intel.com>

at24: Support probing while in non-zero ACPI D state

In certain use cases (where the chip is part of a camera module, and the
camera module is wired together with a camera privacy LED), powering on
the device during probe is undesirable. Add support for the at24 to
execute probe while being in ACPI D state other than 0 (which means fully
powered on).

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# c36748ac 01-Jul-2021 Jérôme Glisse <jglisse@redhat.com>

misc: eeprom: at24: Always append device id even if label property is set.

We need to append device id even if eeprom have a label property set as some
platform can have multiple eeproms with same label and we can not register
each of those with same label. Failing to register those eeproms trigger
cascade failures on such platform (system is no longer working).

This fix regression on such platform introduced with 4e302c3b568e

Reported-by: Alexander Fomichev <fomichev.ru@gmail.com>
Fixes: 4e302c3b568e ("misc: eeprom: at24: fix NVMEM name with custom AT24 device name")
Cc: stable@vger.kernel.org
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 2962484d 20-Apr-2021 Hsin-Yi Wang <hsinyi@chromium.org>

misc: eeprom: at24: check suspend status before disable regulator

cd5676db0574 ("misc: eeprom: at24: support pm_runtime control") disables
regulator in runtime suspend. If runtime suspend is called before
regulator disable, it will results in regulator unbalanced disabling.

Fixes: cd5676db0574 ("misc: eeprom: at24: support pm_runtime control")
Cc: stable <stable@vger.kernel.org>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Link: https://lore.kernel.org/r/20210420133050.377209-1-hsinyi@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4e302c3b 03-Dec-2020 Diego Santa Cruz <Diego.SantaCruz@spinetix.com>

misc: eeprom: at24: fix NVMEM name with custom AT24 device name

When the "label" property is set on the AT24 EEPROM the NVMEM devid is
set to NVMEM_DEVID_NONE, but it is not effective since there is a
leftover line setting it back to NVMEM_DEVID_AUTO a few lines after.

Fixes: 61f764c307f6 ("eeprom: at24: Support custom device names for AT24 EEPROMs")
Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 61f764c3 24-Sep-2020 Jon Hunter <jonathanh@nvidia.com>

eeprom: at24: Support custom device names for AT24 EEPROMs

By using the label property, a more descriptive name can be populated
for AT24 EEPROMs NVMEM device. Update the AT24 driver to check to see
if the label property is present and if so, use this as the name for
NVMEM device. Please note that when the 'label' property is present for
the AT24 EEPROM, we do not want the NVMEM driver to append the 'devid'
to the name and so the nvmem_config.id is initialised to
NVMEM_DEVID_NONE.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# f434f9b7 24-Sep-2020 Jon Hunter <jonathanh@nvidia.com>

eeprom: at24: Initialise AT24 NVMEM ID field

The AT24 EEPROM driver does not initialise the 'id' field of the
nvmem_config structure and because the entire structure is not
initialised, it ends up with a random value. This causes the NVMEM
driver to append the device 'devid' value to name of the NVMEM
device. Ideally for I2C devices such as the AT24 that already have a
unique name, we would not bother to append the 'devid'. However, given
that this has always been done for AT24 devices, we cannot remove the
'devid' as this will change the name of the userspace sysfs node for
the NVMEM device. Nonetheless we should ensure that the 'id' field of
the nvmem_config structure is initialised so that there is no chance of
a random value causes problems in the future. Therefore, set the NVMEM
config.id to NVMEM_DEVID_AUTO for AT24 EEPROMs so that the 'devid' is
always appended.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 774b9f43 16-Sep-2020 Vadym Kochan <vadym.kochan@plvision.eu>

eeprom: at24: set type id as EEPROM

Set type as NVMEM_TYPE_EEPROM to expose this info via
sysfs:

$ cat /sys/bus/nvmem/devices/{DEVICE}/type
EEPROM

Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 45df80d7 30-Aug-2020 Vadym Kochan <vadym.kochan@plvision.eu>

misc: eeprom: at24: register nvmem only after eeprom is ready to use

During nvmem_register() the nvmem core sends notifications when:

- cell added
- nvmem added

and during these notifications some callback func may access the nvmem
device, which will fail in case of at24 eeprom because regulator and pm
are enabled after nvmem_register().

Fixes: cd5676db0574 ("misc: eeprom: at24: support pm_runtime control")
Fixes: b20eb4c1f026 ("eeprom: at24: drop unnecessary label")
Cc: stable@vger.kernel.org
Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 99363d1c 25-Aug-2020 Jean Delvare <jdelvare@suse.de>

eeprom: at24: Tidy at24_read()

The elegant code in at24_read() has the drawback that we now need
to make a copy of all parameters to pass them to the post-processing
callback function if there is one. Rewrite the loop in such a way that
the parameters are not modified, so saving them is no longer needed.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# a4423ced 07-Aug-2020 Jean Delvare <jdelvare@suse.de>

eeprom: at24: Add support for the Sony VAIO EEPROMs

Special handling of the Sony VAIO EEPROMs is the last feature of the
legacy eeprom driver that the at24 driver does not support. Adding
this would let us deprecate and eventually remove the legacy eeprom
driver.

So add the option to specify a post-processing callback function that
is called after reading data from the EEPROM, before it is returned
to the user. The 24c02-vaio type is the first use case of that option:
the callback function will mask the sensitive data for non-root users
exactly as the legacy eeprom driver was doing.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[Bartosz: removed a stray newline]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 8965930c 01-Jul-2020 Lee Jones <lee.jones@linaro.org>

misc: eeprom: at24: Tell the compiler that ACPI functions may not be used

... as is the case when !CONFIG_ACPI.

Fixes the following W=1 kernel build warning:

drivers/misc/eeprom/at24.c:228:36: warning: ‘at24_acpi_ids’ defined but not used [-Wunused-const-variable=]

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20200701093616.GX1179328@dell
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 58d6fee5 10-Mar-2020 Michael Auchter <michael.auchter@ni.com>

misc: eeprom: at24: fix regulator underflow

The at24 driver attempts to read a byte from the device to validate that
it's actually present, and if not, disables the vcc regulator and
returns -ENODEV. However, between the read and the error handling path,
pm_runtime_idle() is called and invokes the driver's suspend callback,
which also disables the vcc regulator. This leads to an underflow of the
regulator enable count if the EEPROM is not present.

Move the pm_runtime_suspend() call to be after the error handling path
to resolve this.

Fixes: cd5676db0574 ("misc: eeprom: at24: support pm_runtime control")
Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 4837621c 27-Jan-2020 Markus Pietrek <mpie@msc-ge.com>

eeprom: at24: add TPF0001 ACPI ID for 24c1024 device

This ID is used at leas on some variants of MSC C6B-SLH board.

Signed-off-by: Markus Pietrek <mpie@msc-ge.com>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# cd5676db 22-Jan-2020 Bibby Hsieh <bibby.hsieh@mediatek.com>

misc: eeprom: at24: support pm_runtime control

Although in the most platforms, the power of eeprom are alway
on, some platforms disable the eeprom power in order to meet
low power request. This patch add the pm_runtime ops to control
power to support all platforms.

Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
[Bartosz: rebased on top of current at24/for-next]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 1c89074b 09-Jan-2020 Khouloud Touil <ktouil@baylibre.com>

eeprom: at24: remove the write-protect pin support

NVMEM framework is an interface for the at24 EEPROMs as well as for
other drivers, instead of passing the wp-gpios over the different
drivers each time, it would be better to pass it over the NVMEM
subsystem once and for all.

Removing the support for the write-protect pin after adding it to the
NVMEM subsystem.

Signed-off-by: Khouloud Touil <ktouil@baylibre.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 69afc4b6 02-Jan-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: sort headers alphabetically

For consistency and easier maintenance: sort the headers alphabetically.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 567ec716 19-Dec-2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: update the license tag

The current GPL v2.0 or later SPDX tag is 'GPL-2.0-or-later' as defined
at https://spdx.org/licenses/.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 285be87c 04-Oct-2019 Jean Delvare <jdelvare@suse.de>

eeprom: at24: Improve confusing log message

Currently when binding to an spd EEPROM, the at24 drivers logs the
following message:

256 byte spd EEPROM, read-only, 0 bytes/write

The last part is confusing, as by definition you don't write to a
read-only EEPROM, plus "0 bytes/write" makes no sense whatsoever.

I propose to have a different message for read-only EEPROMs, which
does not include this last part.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 25e5ef30 28-Jul-2019 Jean Delvare <jdelvare@suse.de>

eeprom: at24: make spd world-readable again

The integration of the at24 driver into the nvmem framework broke the
world-readability of spd EEPROMs. Fix it.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: stable@vger.kernel.org
Fixes: 57d155506dd5 ("eeprom: at24: extend driver to plug into the NVMEM framework")
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 10742fee 03-Jul-2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: remove unneeded include

We used to have a call to ilog2() in AT24_DEVICE_MAGIC(). That's long
gone so this header is no longer needed.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>


# dce91ba3 25-Jun-2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: modify a comment referring to platform data

We no longer have platform data in at24, so this comment is invalid.
Make it refer to device tree & properties instead.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>


# 9ae9d9bf 29-May-2019 Gustavo A. R. Silva <gustavo@embeddedor.com>

eeprom: at24: use struct_size() in devm_kzalloc()

One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
int stuff;
struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = devm_kzalloc(dev, size, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = devm_kzalloc(dev, struct_size(instance, entry, count), GFP_KERNEL);

Notice that, in this case, variable at24_size is not necessary, hence it
is removed.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# a8806581 29-May-2019 YueHaibing <yuehaibing@huawei.com>

eeprom: at24: Remove set but not used variable 'addr'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/misc/eeprom/at24.c: In function at24_make_dummy_client:
drivers/misc/eeprom/at24.c:514:21: warning: variable addr set but not used [-Wunused-but-set-variable]

It's not used since commit e7308628d0ae ("eeprom:
at24: use devm_i2c_new_dummy_device()")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# b20eb4c1 20-May-2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: drop unnecessary label

If we move the nvmem registration above the pm enable calls and the
test read, we can drop the error label and make the code more readable
as there's now only a single place where we must call
pm_runtime_disable() in error path.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# e7308628 20-May-2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: use devm_i2c_new_dummy_device()

Now that it's upstream, use the resource managed version
of i2c_new_dummy_device().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


# 950bcbbe 05-Feb-2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: implement support for 'num-addresses' property

If the device node defines 'num-addresses', let it override the default
behavior.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 4fa882c9 06-Aug-2018 Bartosz Golaszewski <bgolaszewski@baylibre.com>

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.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 37cf28d3 29-Nov-2018 Adrian Bunk <bunk@kernel.org>

eeprom: at24: add support for 24c2048

Works with ST M24M02.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 9a9e295e 16-Aug-2018 Wang Xin <xin.wang7@cn.bosch.com>

eeprom: at24: fix unexpected timeout under high load

Within at24_loop_until_timeout the timestamp used for timeout checking
is recorded after the I2C transfer and sleep_range(). Under high CPU
load either the execution time for I2C transfer or sleep_range() could
actually be larger than the timeout value. Worst case the I2C transfer
is only tried once because the loop will exit due to the timeout
although the EEPROM is now ready.

To fix this issue the timestamp is recorded at the beginning of each
iteration. That is, before I2C transfer and sleep. Then the timeout
is actually checked against the timestamp of the previous iteration.
This makes sure that even if the timeout is reached, there is still one
more chance to try the I2C transfer in case the EEPROM is ready.

Example:

If you have a system which combines high CPU load with repeated EEPROM
writes you will run into the following scenario.

- System makes a successful regmap_bulk_write() to EEPROM.
- System wants to perform another write to EEPROM but EEPROM is still
busy with the last write.
- Because of high CPU load the usleep_range() will sleep more than
25 ms (at24_write_timeout).
- Within the over-long sleeping the EEPROM finished the previous write
operation and is ready again.
- at24_loop_until_timeout() will detect timeout and won't try to write.

Signed-off-by: Wang Xin <xin.wang7@cn.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# a2b3bf48 24-Jul-2018 Alan Chiang <alanx.chiang@intel.com>

eeprom: at24: Add support for address-width property

Provide a flexible way to determine the addressing bits of eeprom.
Pass the addressing bits to driver through address-width property.

Signed-off-by: Alan Chiang <alanx.chiang@intel.com>
Signed-off-by: Andy Yeh <andy.yeh@intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 73b0d922 23-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: provide a separate routine for creating dummy i2c clients

Move the code responsible for creating the dummy i2c clients used by
chips taking multiple slave addresses to a separate function.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Peter Rosin <peda@axentia.se>


# 39933e0f 21-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: provide and use a helper for releasing dummy i2c clients

This allows us to drop two opencoded for loops. We also don't need to
check if the i2c client is NULL before calling i2c_unregister_device().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Peter Rosin <peda@axentia.se>


# bbe69841 05-Apr-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: use devm_nvmem_register()

We now have a managed variant of nvmem_register(). Use it
in at24_probe().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Peter Rosin <peda@axentia.se>


# 5fa4d14e 06-May-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: fix retrieving the at24_chip_data structure

Commit feb2f19b1e8f ("eeprom: at24: move platform data processing into
a separate routine") introduced a bug where we incorrectly retireve the
at24_chip_data structure. Remove the unnecessary ampersand operator.

Fixes: feb2f19b1e8f ("eeprom: at24: move platform data processing into a separate routine")
Reported-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 76aa3de7 06-May-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: fix retrieving the at24_chip_data structure

Commit feb2f19b1e8f ("eeprom: at24: move platform data processing into
a separate routine") introduced a bug where we incorrectly retireve the
at24_chip_data structure. Remove the unnecessary ampersand operator.

Fixes: feb2f19b1e8f ("eeprom: at24: move platform data processing into a separate routine")
Reported-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 4ac0d3fb 23-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: use SPDX identifier instead of GPL boiler-plate

Replace the GPL (or later) header with the SPDX identifier
for GPL-2.0+.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 34d43faf 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: simplify the i2c functionality checking

Save one call and make code prettier by checking the i2c functionality
in the beginning of at24_probe(), saving the relevant values and
reusing them later.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# df3da615 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: fix a line break

Align the broken line with the opening parenthesis to stay consistent
with the rest of the driver code.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# de5db101 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: tweak newlines

Remove the newline between the nvmem registration and its return value
check. This is consistent with the rest of the driver code.

Add a missing newline between two pdata checks to stay consistent with
all the others.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 551a1266 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: refactor at24_probe()

The code in at24_probe() is pretty mangled. It can be cleaned up a bit
by doing things one by one.

Let's group the code by logic: parse and verify pdata, initialize the
regmap, allocate and fill the fields of at24_data, allocate dummy i2c
devices, initialize pm & register with nvmem.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7c280664 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: remove at24_platform_data from at24_data

Not all fields from at24_platform_data are needed in at24_data. Let's
keep just the ones we need and not carry the whole platform_data
structure all the time.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# feb2f19b 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: move platform data processing into a separate routine

This driver can receive its device data from different sources
depending on the system. Move the entire code processing platform data,
device tree and acpi into a separate function.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 48b6a7d1 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: switch to using probe_new() from the i2c framework

Use the new probe() style for i2c drivers.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f1a640c5 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: provide and use at24_base_client_dev()

Use a helper function for accessing the device struct of the base
i2c client. This routine is named in a way that reflects its purpose
unlike the previously hand-coded dereferencing.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 11288b7c 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: readability tweak in at24_probe()

Use a helper variable for the size we want to allocate with
devm_kzalloc() and save an ugly line break.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 021c7d7b 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: use a helper variable for dev

We use the &client->dev construct all over in at24_probe(). Use
a helper variable which is more readable and allows to avoid a couple
unnecessary line breaks.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f2adff66 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: rename chip to pdata in at24_probe()

Reflect the purpose of this variable: it contains platform data so name
it such.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1f77d185 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: rename at24_get_pdata()

As preparation for at24_probe() refactoring: rename at24_get_pdata()
to at24_properties_to_pdata(). We're doing it because we'll move the
pdata parsing code into a separate function which will be called
at24_get_pdata(). Current routine with that name actually parses
the device properties so change its name to reflect its purpose.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7c7f428e 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: don't check if byte_len is a power of 2

We support certain models the size of which is not a power of 2. This
is not a reason to emit a warning.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 53998fa8 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: make struct initialization uniform in at24_probe()

When zeroing structs, use "{ }" everywhere.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c4fee330 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: drop redundant variable in at24_write()

We can reuse ret instead of defining a loop-local status variable.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb27fde2 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: drop redundant variable in at24_read()

We can reuse ret instead of defining a loop-local status variable.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 14263b89 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: remove code separators

These are just two left-overs from times when this driver was bigger.

They are not really useful anymore. Remove them.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5ca2b5b7 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: arrange local variables

Arrange declarations of local variables by line length as visually
it's easier to read.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8cdc4e7e 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: remove nvmem_config from at24_data

This structure only needs to exist during the call to nvmem_register().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d154316d 19-Mar-2018 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: disable regmap locking

We use our own mutex for locking. Disable the regmap-specific locking.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0f30aca7 28-Dec-2017 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: extend the list of chips supported in DT

Add all supported at24 variants to the of_match table.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>


# 6ce261e8 19-Dec-2017 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: add support for the write-protect pin

AT24 EEPROMs have a write-protect pin, which - when pulled high -
inhibits writes to the upper quadrant of memory (although it has been
observed that on some chips it disables writing to the entire memory
range).

On some boards, this pin is connected to a GPIO and pulled high by
default, which forces the user to manually change its state before
writing. On linux this means that we either need to hog the line all
the time, or set the GPIO value before writing from outside of the
at24 driver.

Make the driver check if the write-protect GPIO was defined in the
device tree and pull it low whenever writing to the EEPROM.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>


# ef542e59 08-Dec-2017 Sven Van Asbroeck <svendev@arcx.com>

eeprom: at24: remove temporary fix for at24mac402 size

The chip size passed via devicetree, i2c, or acpi device ids is now no
longer limited to a power of two. So the temporary fix can be removed.

Signed-off-by: Sven Van Asbroeck <svendev@arcx.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# b680f4fa 20-Dec-2017 Sven Van Asbroeck <svendev@arcx.com>

eeprom: at24: convert magic numbers to structs

Fundamental properties such as capacity and page size differ among
at24-type chips. But these chips do not have an id register, so this
can't be discovered at runtime.

Traditionally, at24-type eeprom properties were determined in two ways:
- by passing a 'struct at24_platform_data' via platform_data, or
- by naming the chip type in the devicetree, which passes a 'magic
number' to probe(), which is then converted to a 'struct
at24_platform_data'.

Recently a bug was discovered because the magic number rounds down all
chip sizes to the lowest power of two. This was addressed by
a work-around commit 5478e478eee3 ("eeprom: at24: correctly set the
size for at24mac402"), with the wish that magic numbers should over
time be converted to structs.

This patch replaces the magic numbers with 'struct at24_chip_data'.

Signed-off-by: Sven Van Asbroeck <svendev@arcx.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# eef69398 18-Dec-2017 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: code shrink

A regmap_config struct is pretty big and declaring two of them
statically just to tweak the reg_bits value adds unnecessary bloat.

Declare the regmap config locally in at24_probe() instead.

Bloat-o-meter output for ARM:

add/remove: 0/2 grow/shrink: 1/0 up/down: 4/-272 (-268)
Function old new delta
at24_probe 1560 1564 +4
regmap_config_8 136 - -136
regmap_config_16 136 - -136
Total: Before=7012, After=6744, chg -3.82%

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# ec3c2d51 18-Dec-2017 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: use a common prefix for all symbols in at24.c

There are a couple symbols defined in the driver source file which are
missing the at24_ prefix. This patch fixes that.

For module params: use module_param_named() in order to not break
userspace.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# aa4ce228 13-Dec-2017 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: fix coding style issues

Fix issues reported by checkpatch for at24.c.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# e32213fb 08-Dec-2017 Sven Van Asbroeck <svendev@arcx.com>

eeprom: at24: support eeproms that do not auto-rollover reads

Some multi-address eeproms in the at24 family may not automatically
roll-over reads to the next slave address. On those eeproms, reads
that straddle slave boundaries will not work correctly.

Solution:
Mark such eeproms with a flag that prevents reads straddling
slave boundaries. Add the AT24_FLAG_NO_RDROL flag to the eeprom
entry in the device_id table, or add 'no-read-rollover' to the
eeprom devicetree entry.

Note that I have not personally enountered an at24 chip that
does not support read rollovers. They may or may not exist.
However, my hardware requires this functionality because of
a quirk.

Signed-off-by: Sven Van Asbroeck <svendev@arcx.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# a23727cb 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: remove now unneeded smbus-related code

Remove remaining now unneeded code dealing with SMBUS details.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# dd69a9da 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: remove old read functions

Remove the old and now unused read functions.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 4bb5c13c 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: add regmap-based read function

Add regmap-based read function and instead of using three different
read functions (standard, mac, serial) use just one and factor out the
read offset adjustment for mac and serial to at24_adjust_read_offset.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# d4297d67 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: remove old write functions

Remove the old and now unused write functions.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 8e5888e1 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: add regmap-based write function

Add a regmap-based write function.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 46049486 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: change at24_translate_offset return type

Change return type of at24_translate_offset to *at24_client to make
member regmap accessible for subsequent patches of this series.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 5c015258 28-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: add basic regmap_i2c support

This patch adds basic regmap support to be used by subsequent
patches of this series.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 7f6d2ecd 03-Dec-2017 David Lechner <david@lechnology.com>

eeprom: at24: change nvmem stride to 1

Trying to read the MAC address from an eeprom that has an offset that
is not a multiple of 4 causes an error currently.

Fix it by changing the nvmem stride to 1.

Cc: stable@vger.kernel.org
Signed-off-by: David Lechner <david@lechnology.com>
[Bartosz: tweaked the commit message]
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# f9ecc83f 01-Dec-2017 Sakari Ailus <sakari.ailus@linux.intel.com>

eeprom: at24: fix I2C device selection for runtime PM

The at24 driver creates dummy I2C devices to access offsets in the chip
that are outside the area supported using a single I2C address. It is not
meaningful to use runtime PM to such devices; the system firmware (ACPI)
does not know about these devices nor runtime PM was enabled for them.
Always use the real device instead of the dummy ones.

Fixes: 98e8201039af ("eeprom: at24: enable runtime pm support")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Sven Van Asbroeck on a 24AA16/24LC16B <svendev@arcx.com>
[Bartosz: rebased on top of previous fixes for 4.15, tweaked the
commit message]
[Sven: fixed Bartosz's rebase]
Signed-off-by: Sven Van Asbroeck <svendev@arcx.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# d9bcd462 23-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: check at24_read/write arguments

So far we completely rely on the caller to provide valid arguments.
To be on the safe side perform an own sanity check.

Cc: stable@vger.kernel.org
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 644a1f19 27-Nov-2017 Heiner Kallweit <hkallweit1@gmail.com>

eeprom: at24: fix reading from 24MAC402/24MAC602

Chip datasheet mentions that word addresses other than the actual
start position of the MAC delivers undefined results. So fix this.
Current implementation doesn't work due to this wrong offset.

Cc: stable@vger.kernel.org
Fixes: 0b813658c115 ("eeprom: at24: add support for at24mac series")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>


# 5478e478 27-Nov-2017 Bartosz Golaszewski <brgl@bgdev.pl>

eeprom: at24: correctly set the size for at24mac402

There's an ilog2() expansion in AT24_DEVICE_MAGIC() which rounds down
the actual size of EUI-48 byte array in at24mac402 eeproms to 4 from 6,
making it impossible to read it all.

Fix it by manually adjusting the value in probe().

This patch contains a temporary fix that is suitable for stable
branches. Eventually we'll probably remove the call to ilog2() while
converting the magic values to actual structs.

Cc: stable@vger.kernel.org
Fixes: 0b813658c115 ("eeprom: at24: add support for at24mac series")
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>


# 7f2a2f0d 30-Sep-2017 Javier Martinez Canillas <javierm@redhat.com>

eeprom: at24: Add OF device ID table

The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

To maintain backward compatibility with old Device Trees, only use the OF
device ID table .data if the device was registered via OF and the OF node
compatible matches an entry in the OF device ID table.

Suggested-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 98e82010 10-Oct-2017 Divagar Mohandass <divagar.mohandass@intel.com>

eeprom: at24: enable runtime pm support

Currently the device is kept in D0, there is an opportunity
to save power by enabling runtime pm.

Device can be daisy chained from PMIC and we can't rely on I2C core
for auto resume/suspend. Driver will decide when to resume/suspend.

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Divagar Mohandass <divagar.mohandass@intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# dbc1ab9c 10-Oct-2017 Divagar Mohandass <divagar.mohandass@intel.com>

eeprom: at24: add support to fetch eeprom device property "size"

Obtain the size of the EEPROM chip from DT if the "size" property is
specified for the device.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Divagar Mohandass <divagar.mohandass@intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# dd905a61 09-Feb-2017 Ben Gardner <gardner.ben@gmail.com>

misc: eeprom: at24: use device_property_*() functions instead of of_get_property()

Allow the at24 driver to get configuration information from both OF and
ACPI by using the more generic device_property functions.
This change was inspired by the at25.c driver.

I have a custom board with a ST M24C02 EEPROM attached to an I2C bus.
With the following ACPI construct, this patch instantiates a working
instance of the driver.

Device (EEP0) {
Name (_HID, "PRP0001")
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () {"compatible", Package () {"st,24c02"}},
Package () {"pagesize", 16},
},
})
Name (_CRS, ResourceTemplate () {
I2cSerialBus (
0x0057, ControllerInitiated, 400000,
AddressingMode7Bit, "\\_SB.PCI0.I2C3", 0x00,
ResourceConsumer,,)
})
}

Signed-off-by: Ben Gardner <gardner.ben@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 00f0ea70 12-Aug-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: check if the chip is functional in probe()

The at24 driver doesn't check if the chip is functional in its probe
function. This leads to instantiating devices that are not physically
present. For example the cape EEPROMs for BeagleBone Black are defined
in the device tree at four addresses on i2c2, but normally only one of
them is present.

If the userspace doesn't know the location in advance, it will need to
check if reading the nvmem attributes fails to determine which EEPROM
is actually there.

Try to read a single byte in probe() and bail-out with -ENODEV if the
read fails.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 24da3cc0 17-Jul-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: tweak the loop_until_timeout() macro

loop_until_timeout() replaced a do {} while loop in the at24 driver
with a for loop which, under certain circumstances (such as heavy load
or low value of the write_timeout argument), can lead to the code in
the loop never being executed.

Make sure that at least one iteration of the code enclosed within
loop_until_timeout() is always executed.

Suggested-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 0b813658 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: add support for at24mac series

Add a new read function to the at24 driver allowing to retrieve the
factory-programmed mac address embedded in chips from the at24mac
family.

These chips can be instantiated similarily to the at24cs family,
except that there's no way of having access to both the serial number
and the mac address at the same time - the user must instantiate
either an at24cs or at24mac device as both special memory areas are
accessible on the same slave address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 818d0220 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: support reading the serial number for 24csxx

The chips from the at24cs family have two memory areas - a regular
read-write block and a read-only area containing the serial number.

The latter is visible on a different slave address (the address of the
rw memory block + 0x08). In order to access both blocks the user needs
to instantiate a regular at24c device for the rw block address and a
corresponding at24cs device on the serial number block address.

Add a function that allows to access the serial number and assign it
to at24->read_func if the chip allows serial number read operations
and the driver was passed the relevant flag for this device.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# cd0c8615 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: split at24_eeprom_write() into specialized functions

Split at24_eeprom_write() into three smaller functions - one for the
i2c operations and two for the smbus extensions (separate routines for
block and byte transfers). Assign them in at24_probe() depending on
the bus capabilities.

Also: in order to avoid duplications move code adjusting the count
argument into a separate function and use it for i2c and smbus block
writes (no need for a roll-over for byte writes as we're always
writing one byte).

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 9afd6866 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: split at24_eeprom_read() into specialized functions

Split at24_eeprom_read() into two smaller functions - one for the
i2c operations and one for the smbus extensions. Assign them in
at24_probe() depending on the bus capabilities.

Also: in order to avoid duplications move the comments related to
offset calculations above the at24_translate_offset() routine.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 9344a81e 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: hide the read/write loop behind a macro

Before splitting the read/write routines into smaller, more
specialized functions, unduplicate some code in advance.

Use a 'for' loop instead of 'do while' when waiting for the previous
write to complete and hide it behind a macro.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 318aa9c6 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: call read/write functions via function pointers

The first step in simplifying the read and write functions is to call
them via function pointers stored in at24_data. When we eventually
split the routines into smaller ones (depending on whether they use
smbus or i2c operations) we'll simply assign them to said pointers
instead of checking the flags at runtime every time we read/write.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 2da78ac3 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: coding style fixes

Align the arguments in broken lines with the arguments list's opening
brackets and make checkpatch.pl happy by converting 'unsigned' into
'unsigned int'.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# d5bc0047 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: move at24_read() below at24_eeprom_write()

In preparation for splitting at24_eeprom_write() & at24_eeprom_read()
into smaller, specialized routines move at24_read() below, so that it
won't be intertwined with the low-level EEPROM accessors.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# b0b9f7bf 06-Jun-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: improve the device_id table readability

As part of the preparation for introducing support for more chips,
improve the readability of the device table by separating columns
with tabs.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# cf0361a2 24-Apr-2016 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

eeprom: at24: remove nvmem regmap dependency

This patch moves to nvmem support in the driver to use callback instead
of regmap.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1d98d0ec 11-Apr-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: replace msleep() with usleep_range()

We cannot expect msleep(1) to actually sleep for a period shorter than
20 ms. Replace all calls to msleep() with usleep_range().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 5057e8e0 11-Apr-2016 Bartosz Golaszewski <bgolaszewski@baylibre.com>

eeprom: at24: remove a reduntant if

The second check for I2C_FUNC_I2C is reduntant, so remove it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
[wsa: reworded commit message]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# bec3c11b 26-Feb-2016 Andrew Lunn <andrew@lunn.ch>

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: Andrew Lunn <andrew@lunn.ch>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Sekhar Nori <nsekhar@ti.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 57d15550 26-Feb-2016 Andrew Lunn <andrew@lunn.ch>

eeprom: at24: extend driver to plug into the NVMEM framework

Add a regmap for accessing the EEPROM, and then use that with the
NVMEM framework. Set the NVMEM config structure to enable backward, so
that the 'eeprom' file in sys is provided by the framework.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 092462c2 13-Jan-2016 Geliang Tang <geliangtang@163.com>

misc: eeprom: use kobj_to_dev()

Use kobj_to_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 40d8edc9 22-Oct-2015 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

at24: enable ACPI device found on Galileo Gen2

There is a 24c08 chip connected to i2c bus on Intel Galileo Gen2 board. Enable
it via ACPI ID INT3499.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 3861841d 22-Oct-2015 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

at24: enable ACPI device found on Galileo Gen2

There is a 24c08 chip connected to i2c bus on Intel Galileo Gen2 board. Enable
it via ACPI ID INT3499.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 2cd9fbd0 12-Aug-2015 Irina Tirdea <irina.tirdea@intel.com>

eeprom: at24: use i2c_smbus_read_i2c_block_data_or_emulated

For i2c busses that support only SMBUS extensions, the eeprom at24
driver reads data from the device using the SMBus block, word or byte
read protocols depending on availability.

Replace the block read emulation from the driver with the
i2c_smbus_read_i2c_block_data_or_emulated call from i2c core.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 141124e6 10-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

misc: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# d12c0aaf 26-Jul-2015 Vladimir Zapolskiy <vz@mleia.com>

misc: eeprom: at24: clean up at24_bin_write()

The change removes redundant sysfs binary file boundary check, since
this task is already done on caller side in fs/sysfs/file.c

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 14e51e59 10-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

misc: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a839ce66 09-Oct-2014 Christian Gmeiner <christian.gmeiner@gmail.com>

eeprom: at24: extend driver to allow writing via i2c_smbus_write_byte_data

I have a at24 EEPROM connected via i2c bus provided by ISCH i2c
bus driver. This bus driver does not support
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK and so I was looking for a way
to be able to write the eeprom. This patch adds support for
I2C_SMBUS_BYTE_DATA writing via i2c_smbus_write_byte_data.
It is quite slow, but it works.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
[wsa: s/use_smbuse_write/use_smbus_write/]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 7c65e292 28-Oct-2013 Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>

misc/at24: avoid infinite loop on write()

This change fixes a problem of infinite zero byte write() without
an error status, if there is an attempt to write a file bigger than
EEPROM size over sysfs interface.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 25f73ed5 27-Sep-2013 Vivien Didelot <vivien.didelot@gmail.com>

misc: (at24) move header to linux/platform_data/

This patch moves the at24.h header from include/linux/i2c to
include/linux/platform_data and updates existing support accordingly.

It also fixes the following checkpatch warning:

WARNING: please, no space before tabs
#436: FILE: include/linux/platform_data/at24.h:31:
+ * ^Iu8 *mac_addr = ethernet_pdata->mac_addr;$

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# f0ac2363 28-May-2013 Nikolay Balandin <nbalandin@dev.rtsoft.ru>

drivers/misc: at24: convert to use devm_kzalloc

Use devm_kzalloc to make cleanup paths simpler

Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 486a5c28 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

misc: remove use of __devexit

CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Eric Piel <eric.piel@tremplin-utc.net>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2d6bed9c 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

drivers/misc: remove use of __devexit_p

CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Eric Piel <eric.piel@tremplin-utc.net>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 45efe847 17-Nov-2010 Wolfram Sang <wsa@kernel.org>

misc/at24: add more sanity checks for parameters

Side-effects happen when passing 0 to either io_limit or page_size. Give
an error in case of this misconfiguration.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 9ed030d7 17-Nov-2010 Wolfram Sang <wsa@kernel.org>

misc/at24: parse device tree data

Information about the pagesize and read-only-status may also come from
the devicetree. Parse this data, too, and act accordingly. While we are
here, change the initialization printout a bit. write_max is useful to
know to detect performance bottlenecks, the rest is superfluous.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# fbae3fb1 03-Jun-2010 Wolfram Sang <wsa@kernel.org>

i2c: Remove all i2c_set_clientdata(client, NULL) in drivers

I2C drivers can use the clientdata-pointer to point to private data. As I2C
devices are not really unregistered, but merely detached from their driver, it
used to be the drivers obligation to clear this pointer during remove() or a
failed probe(). As a couple of drivers forgot to do this, it was agreed that it
was cleaner if the i2c-core does this clearance when appropriate, as there is
no guarantee for the lifetime of the clientdata-pointer after remove() anyhow.
This feature was added to the core with commit
e4a7b9b04de15f6b63da5ccdd373ffa3057a3681 to fix the faulty drivers.

As there is no need anymore to clear the clientdata-pointer, remove all current
occurrences in the drivers to simplify the code and prevent confusion.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Richard Purdie <rpurdie@linux.intel.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 7aeb9664 21-May-2010 Jean Delvare <khali@linux-fr.org>

at24: Fall back to byte or word reads if needed

Increase the portability of the at24 driver by letting it read from
EEPROM chips connected to cheap SMBus controllers that support neither
raw I2C messages nor even I2C block reads. All SMBus controllers
should support either word reads or byte reads, so read support
becomes universal, much like with the legacy "eeprom" driver.

Obviously, this only works with EEPROM chips up to AT24C16, that use
8-bit offset addressing. 16-bit offset addressing is almost impossible
to support on SMBus controllers.

I did not add universal support for writes, as I had no immediate need
for this, but it could be added later if needed (with the same
performance issue as byte and word reads have, of course.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Konstantin Lazarev <klazarev@sbcglobal.net>


# 2c3c8bea 12-May-2010 Chris Wright <chrisw@sous-sol.org>

sysfs: add struct file* to bin_attr callbacks

This allows bin_attr->read,write,mmap callbacks to check file specific data
(such as inode owner) as part of any privilege validation.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d07b56b3 13-Mar-2010 Wolfram Sang <wsa@kernel.org>

at24: Init dynamic bin_attribute structures

Commit 6992f5334995af474c2b58d010d08bc597f0f2fe introduced this requirement.

Reported-by: Albrecht Dress <albrecht.dress@arcor.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 4d29196c 26-Nov-2009 Wolfram Sang <wsa@kernel.org>

at24: Use timeout also for read

Writes may take some time on EEPROMs, so for consecutive writes, we already
have a loop waiting for the EEPROM to become ready. Use such a loop for reads,
too, in case somebody wants to immediately read after a write. Detailed bug
report and test case can be found here:

http://article.gmane.org/gmane.linux.drivers.i2c/4660

Reported-by: Aleksandar Ivanov <ivanov.aleks@gmail.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: Aleksandar Ivanov <ivanov.aleks@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 280ca299 13-Apr-2009 Geert Uytterhoeven <geert@linux-m68k.org>

at24: make input buffers of at24_*write() const

| drivers/misc/eeprom/at24.c:508: warning: assignment from incompatible pointer type

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 7274ec8b 02-Apr-2009 Kevin Hilman <khilman@deeprootsystems.com>

memory_accessor: implement the new memory_accessor interface for I2C EEPROM

In the case of at24, the platform code registers a 'setup' callback with
the at24_platform_data. When the at24 driver detects an EEPROM, it fills
out the read and write functions of the memory_accessor and calls the
setup callback passing the memory_accessor struct. The platform code can
then use the read/write functions in the memory_accessor struct for
reading and writing the EEPROM.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 5195e509 26-Jan-2009 Wolfram Sang <wsa@kernel.org>

i2c: Move at24 to drivers/misc/eeprom

As drivers/i2c/chips is going to go away, move the driver to
drivers/misc/eeprom. Other eeprom drivers may be moved here later, too.
Update Kconfig text to specify this driver as I2C.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>