Commit graph

332 commits

Author SHA1 Message Date
Heiner Kallweit
5fe3cba0bf eeprom: ee1004: Add helper ee1004_cleanup
Factor out the cleanup code to a new helper ee1004_cleanup().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/9738cbc7-458d-276f-4012-66551f105d90@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:40 +02:00
Heiner Kallweit
8700a7328e eeprom: ee1004: Add constant EE1004_NUM_PAGES
Add a constant for the number of pages.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/6167f9c5-995a-03c3-c324-e93e2a6c969b@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:40 +02:00
Heiner Kallweit
8aeacb7a2d eeprom: ee1004: Move call to ee1004_set_current_page to ee1004_eeprom_read
Moving the call to ee1004_set_current_page() to ee1004_eeprom_read()
allows to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/2829a131-51e3-8865-462a-564080158b0b@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
6f68dbd6cc eeprom: ee1004: Improve error handling in ee1004_read
Simplify the error handling and make it better readable. No functional
change intended.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/13ad7b39-e722-d70a-e25b-03d1fb1734a7@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
6601017e2a eeprom: ee1004: Factor out setting page to ee1004_set_current_page
Factor out setting the page, this makes the code better readable.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/21e0966f-e6c9-045f-b130-bd9fb071f0d7@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
b2cd8a2f8e eeprom: ee1004: Cache current page at initialization of first device only
The value of ee1004_current_page applies to all SPD eeproms connected
to the adapter. Therefore it's sufficient if we set ee1004_current_page
when the first device is added.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/b9240e58-08bb-3d71-7a9c-9a323b470ab6@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
2ac99039c5 eeprom: ee1004: Switch to i2c probe_new callback
Switch to the new i2c_driver probe callback version.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/eb5be659-7427-46c5-66c2-b39650e08ea3@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
3c03dad765 eeprom: ee1004: Improve creating dummy devices
i2c_new_dummy_device() calls i2c_new_client_device() that complains
if it fails to create the device. Therefore we don't have to emit an
error message in case of failure. In addition ensure that
ee1004_set_page is only set if creating the device succeeded.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/d38df5ac-6ecb-7d5f-b5c3-39bfc6a1e8a1@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
08e5138aa4 eeprom: ee1004: Improve check for SMBUS features
We have to read 512 bytes only, therefore read performance isn't really
a concern. Don't bother the user if i2c block read isn't supported.

For i2c_smbus_read_i2c_block_data_or_emulated() to work it's sufficient
if I2C_FUNC_SMBUS_READ_I2C_BLOCK or I2C_FUNC_SMBUS_READ_BYTE_DATA is
supported. Therefore remove the check for I2C_FUNC_SMBUS_READ_WORD_DATA.

In addition check for I2C_FUNC_SMBUS_WRITE_BYTE (included in
I2C_FUNC_SMBUS_BYTE) which is needed for setting the page.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/840c668e-6310-e933-e50e-5abeaecfb39c@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
b97ba92e29 eeprom: ee1004: Remove usage of i2c_adapter_id in adapter comparison
We can compare the adapter pointers directly instead of using
i2c_adapter_id().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/99a3f94d-e7ca-e01d-6a78-81e109fde086@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
64bf274711 eeprom: ee1004: Remove not needed check in ee1004_eeprom_read
i2c_smbus_read_i2c_block_data_or_emulated() checks its length argument,
so we don't have to do it. In addition remove the unlikely hint from
the checks, we do i2c reads and therefore are in a slow path.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/eb2a8bff-43ec-c763-a417-9d741e6f0034@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
7abdadfcf1 eeprom: ee1004: Remove not needed check in ee1004_read
sysfs_kf_bin_read() checks this for us already. In addition
the function works correctly also w/o this check.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/33889bff-3614-4b73-5010-701635e1edab@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
7adbd54fb2 eeprom: ee1004: Use kobj_to_i2c_client to simplify the code
Switch to helper kobj_to_i2c_client() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/4ae57f09-b803-6ae3-c734-87e733a56eb8@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-27 14:49:39 +02:00
Heiner Kallweit
b63866efa1 eeprom: ee1004: Let device core handle attribute eeprom
Instead of creating/removing the attribute ourselves, just declare the
attribute and let the device core handle it. This allows to simplify
the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/8a6c77f2-f84a-311b-c2b9-21798f690e4d@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-21 22:13:13 +02:00
Greg Kroah-Hartman
03e3e31ee5 Merge 50f09a3dd5 ("Merge tag 'char-misc-5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc") into char-misc-next
We want the char/misc driver fixes in here as well

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-21 09:48:31 +02:00
Hsin-Yi Wang
2962484dfe misc: eeprom: at24: check suspend status before disable regulator
cd5676db05 ("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: cd5676db05 ("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>
2021-05-14 13:50:59 +02:00
Emmanuel Gil Peyrot
14374fbb3f misc: eeprom_93xx46: Add new 93c56 and 93c66 compatible strings
These two devices have respectively 2048 and 4096 bits of storage,
compared to 1024 for the 93c46.

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Link: https://lore.kernel.org/r/20210511210727.24895-3-linkmauve@linkmauve.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-14 13:45:24 +02:00
Emmanuel Gil Peyrot
4a5ff99bbb misc: eeprom_93xx46: Remove hardcoded bit lengths
This avoids using magic numbers based on the length of an address or a
command, while we only want to differentiate between 8-bit and 16-bit.

The driver was previously wrapping around the offset in the write
operation, this now returns -EINVAL instead (but should never happen in
the first place).

If two pointer indirections are too many, we could move the flags to the
main struct instead, but I doubt it’s going to make any sensible
difference on any hardware.

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Link: https://lore.kernel.org/r/20210511210727.24895-2-linkmauve@linkmauve.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-14 13:45:24 +02:00
Aswath Govindraju
f6f1f8e6e3 misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom
A dummy zero bit is sent preceding the data during a read transfer by the
Microchip 93LC46B eeprom (section 2.7 of[1]). This results in right shift
of data during a read. In order to ignore this bit a quirk can be added to
send an extra zero bit after the read address.

Add a quirk to ignore the zero bit sent before data by adding a zero bit
after the read address.

[1] - https://www.mouser.com/datasheet/2/268/20001749K-277859.pdf

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Link: https://lore.kernel.org/r/20210105105817.17644-3-a-govindraju@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-20 18:52:12 +01:00
Aswath Govindraju
4540b9fbd8 misc: eeprom_93xx46: Add module alias to avoid breaking support for non device tree users
Module alias "spi:93xx46" is used by non device tree users like
drivers/misc/eeprom/digsy_mtc_eeprom.c  and removing it will
break support for them.

Fix this by adding back the module alias "spi:93xx46".

Fixes: 13613a2246 ("misc: eeprom_93xx46: Fix module alias to enable module autoprobe")
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Link: https://lore.kernel.org/r/20210113051253.15061-1-a-govindraju@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-13 17:18:52 +01:00
Aswath Govindraju
47771f1715 misc: eeprom_93xx46: Enable module autoprobe for microchip 93LC46B eeprom
Add module alias to enable autoprobe for microchip 93LC46B eeprom by using
/sys/class/.../spi1.0/modalias content.

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Link: https://lore.kernel.org/r/20210107163957.28664-3-a-govindraju@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-07 20:25:11 +01:00
Aswath Govindraju
13613a2246 misc: eeprom_93xx46: Fix module alias to enable module autoprobe
Fix module autoprobe by correcting module alias to match the string from
/sys/class/.../spi1.0/modalias content.

Fixes: 06b4501e88 ("misc/eeprom: add driver for microwire 93xx46 EEPROMs")
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Link: https://lore.kernel.org/r/20210107163957.28664-2-a-govindraju@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-07 20:25:11 +01:00
Linus Torvalds
2911ed9f47 Char / Misc driver updates for 5.11-rc1
Here is the big char/misc driver update for 5.11-rc1.
 
 Continuing the tradition of previous -rc1 pulls, there seems to be more
 and more tiny driver subsystems flowing through this tree.
 
 Lots of different things, all of which have been in linux-next for a
 while with no reported issues:
 	- extcon driver updates
 	- habannalab driver updates
 	- mei driver updates
 	- uio driver updates
 	- binder fixes and features added
 	- soundwire driver updates
 	- mhi bus driver updates
 	- phy driver updates
 	- coresight driver updates
 	- fpga driver updates
 	- speakup driver updates
 	- slimbus driver updates
 	- various small char and misc driver updates
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCX9iDZA8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylRMACgqxKS2CUcY8tPnR5weHEsbz6O+KAAn3BtEFnK
 7V9EnSuZe4L1jNOHOB5V
 =xzHh
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char / misc driver updates from Greg KH:
 "Here is the big char/misc driver update for 5.11-rc1.

  Continuing the tradition of previous -rc1 pulls, there seems to be
  more and more tiny driver subsystems flowing through this tree.

  Lots of different things, all of which have been in linux-next for a
  while with no reported issues:

   - extcon driver updates

   - habannalab driver updates

   - mei driver updates

   - uio driver updates

   - binder fixes and features added

   - soundwire driver updates

   - mhi bus driver updates

   - phy driver updates

   - coresight driver updates

   - fpga driver updates

   - speakup driver updates

   - slimbus driver updates

   - various small char and misc driver updates"

* tag 'char-misc-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (305 commits)
  extcon: max77693: Fix modalias string
  extcon: fsa9480: Support TI TSU6111 variant
  extcon: fsa9480: Rewrite bindings in YAML and extend
  dt-bindings: extcon: add binding for TUSB320
  extcon: Add driver for TI TUSB320
  slimbus: qcom: fix potential NULL dereference in qcom_slim_prg_slew()
  siox: Make remove callback return void
  siox: Use bus_type functions for probe, remove and shutdown
  spmi: Add driver shutdown support
  spmi: fix some coding style issues at the spmi core
  spmi: get rid of a warning when built with W=1
  uio: uio_hv_generic: use devm_kzalloc() for private data alloc
  uio: uio_fsl_elbc_gpcm: use device-managed allocators
  uio: uio_aec: use devm_kzalloc() for uio_info object
  uio: uio_cif: use devm_kzalloc() for uio_info object
  uio: uio_netx: use devm_kzalloc() for or uio_info object
  uio: uio_mf624: use devm_kzalloc() for uio_info object
  uio: uio_sercos3: use device-managed functions for simple allocs
  uio: uio_dmem_genirq: finalize conversion of probe to devm_ handlers
  uio: uio_dmem_genirq: convert simple allocations to device-managed
  ...
2020-12-15 14:10:09 -08:00
Diego Santa Cruz
4e302c3b56 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: 61f764c307 ("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>
2020-12-04 10:46:36 +01:00
Jonathan Neuschäfer
667aef00f3 eeprom: at25: Add example part numbers
To save the interested reader some time, add examples of AT25 part
numbers that correspond to EEPROMs rather than flashes.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Link: https://lore.kernel.org/r/20201107133337.1066271-1-j.neuschaefer@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-14 00:24:32 +01:00
Linus Torvalds
b5df4b5c28 Merge branch 'i2c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:

 - if a host can be a client, too, the I2C core can now use it to
   emulate SMBus HostNotify support (STM32 and R-Car added this so far)

 - also for client mode, a testunit has been added. It can create rare
   situations on the bus, so host controllers can be tested

 - a binding has been added to mark the bus as "single-master". This
   allows for better timeout detections

 - new driver for Mellanox Bluefield

 - massive refactoring of the Tegra driver

 - EEPROMs recognized by the at24 driver can now have custom names

 - rest is driver updates

* 'i2c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (80 commits)
  Documentation: i2c: add testunit docs to index
  i2c: tegra: Improve driver module description
  i2c: tegra: Clean up whitespaces, newlines and indentation
  i2c: tegra: Clean up and improve comments
  i2c: tegra: Clean up printk messages
  i2c: tegra: Clean up variable names
  i2c: tegra: Improve formatting of variables
  i2c: tegra: Check errors for both positive and negative values
  i2c: tegra: Factor out hardware initialization into separate function
  i2c: tegra: Factor out register polling into separate function
  i2c: tegra: Factor out packet header setup from tegra_i2c_xfer_msg()
  i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg()
  i2c: tegra: Rename wait/poll functions
  i2c: tegra: Remove "dma" variable from tegra_i2c_xfer_msg()
  i2c: tegra: Remove redundant check in tegra_i2c_issue_bus_clear()
  i2c: tegra: Remove likely/unlikely from the code
  i2c: tegra: Remove outdated barrier()
  i2c: tegra: Clean up variable types
  i2c: tegra: Reorder location of functions in the code
  i2c: tegra: Clean up probe function
  ...
2020-10-21 10:54:05 -07:00
Liu Shixin
4292aa977f eeprom: ee1004: use module_i2c_driver to simplify the code
Use the module_i2c_driver() macro to make the code smaller
and a bit simpler.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Link: https://lore.kernel.org/r/20200918030225.3902750-1-liushixin2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-02 11:36:37 +02:00
Wolfram Sang
668ba5e690 at24 updates for v5.10
- add support for masking sensitive data in VAIO EEPROMs
 - set the nvmem TYPE to NVMEM_TYPE_EEPROM
 - add support for the new 'label' property
 - set the nvmem ID to NVMEM_DEVID_AUTO by default (for backward
   compatibility) or to NVMEM_DEVID_NONE if label is defined
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl9t8ecACgkQEacuoBRx
 13KQCQ/6A7ijeBaBBHniisx3vcZQiYXGqvjQ/kvbF32mi4CWzfeC7QyWSpbhzVpY
 ZpuR6ER85gUOKhSHg6g/3iT2Yg3reZF2Hea27sH00TKJUh+BPCX+wZAdQ00My6AB
 gY3DnbDf6KRrjsFCYKbQ7C9z1c73diGXk6oHirpuUJMQ21pkiTvcE67iPI/m0gsn
 c5CvOz9V4fXeV/RwEPt1VKEOxf+HoRablOYEM2weK2xLVAdFgI4+pKpzAYkZoqsb
 PLM0bPQUf/5wVe+W56JWWMBSWUA7eWj4suMCsZG0Jjgq53r5oXALcI18snv8M5mh
 dHZZ1+mYwLQ+wUQ2ARPGUL66sk6/eGqFVJxaHjTQrSo7kjQkUHTtelH1MdmC78pe
 qFQOWkTSF11sxmAjnU17eUJKJWUgyGiuDBAE6aQa3sCaShyN/tkSDCcGfI8e5lSw
 FWqtTNNGHE9JiMlSGMOjwpzwae3K6+r62TPmr+YpvQpwYFhXLwMF2E+WlS29SrpP
 2OaJkIaKNzVkmQuwGjXSBxE2ftFH80xj5GtfZ+w6eEvT6ZxWfx9GPaK3hWxwmeQp
 krd77IuTKCdgmKLQmZc5KWANT5NT6NKgkDSHq8iDKGdP+ne8jMbxyu1vBPdct1SO
 gHFdcowKQPoxarS6yhMwPd6ckisDqBy/eJ/OankrEfQAFdRBVVw=
 =KexW
 -----END PGP SIGNATURE-----

Merge tag 'at24-updates-for-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-5.10

at24 updates for v5.10

- add support for masking sensitive data in VAIO EEPROMs
- set the nvmem TYPE to NVMEM_TYPE_EEPROM
- add support for the new 'label' property
- set the nvmem ID to NVMEM_DEVID_AUTO by default (for backward
  compatibility) or to NVMEM_DEVID_NONE if label is defined
2020-09-27 15:16:24 +02:00
Jon Hunter
61f764c307 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>
2020-09-25 15:33:04 +02:00
Jon Hunter
f434f9b7af 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>
2020-09-24 15:18:46 +02:00
Wolfram Sang
8ce98dd21f misc: eeprom: use helper to get i2c_client from kobj
Slightly easier to read.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2020-09-21 11:45:43 +02:00
Vadym Kochan
1d62a2cedf eeprom: 93xx46: 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>
Link: https://lore.kernel.org/r/20200916170933.20302-4-vadym.kochan@plvision.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-17 18:47:22 +02:00
Vadym Kochan
5e180e6f6a eeprom: at25: 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>
Link: https://lore.kernel.org/r/20200916170933.20302-3-vadym.kochan@plvision.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-17 18:47:20 +02:00
Vadym Kochan
774b9f4371 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>
2020-09-17 10:05:20 +02:00
Greg Kroah-Hartman
05fa34dcdb Linux 5.9-rc5
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAl9epdgeHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiG9IMH/jHCRSbcsIXHuQHn
 xcRLlhrDHfXoBza7auHfPWx2+9DZsmaSJs/SEiTGNag0Bi7jBcWcwBpsep7iVG/+
 WiftD5uOMhZigyuvfMFrt0mjr2Kr3wg5p58lwMBeBdm8iL5uKV8ehKsh05/Fral2
 6hu3jP8L0PCZMpF+sZ7s2jlhfVUMmjA8VzXZCvgQtmhoraHiF3mzfkcSMxnHwBPO
 HLo+TDDm49u+LbVsJT7+cSTiWxuUJCbix9Q4PCTx/BGg4ezYsjc6v0BnYRaYtrrA
 1uYiT6PVBEUkYYBHKQlD3N2KnUmbKx7dGUF4t+peTg5/JiocAJMNi1N9Qzvv7N6Q
 CqTiuio=
 =q+kJ
 -----END PGP SIGNATURE-----

Merge 5.9-rc5 into char-misc-next

We want the char/misc fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-14 10:07:08 +02:00
Wolfram Sang
0065ec0054 at24 fixes for v5.9-rc5
- delay registration of the nvmem provider until after power is enabled
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl9XeiIACgkQEacuoBRx
 13Lxww/7Bngrl7TCeLHvW0Gun6Dk8q4gGHi74MhXYdULuyNGi7MIRjthy8jCXafU
 M+aOzxn8Y7kTXIPtfGvgnzPIgC/PHhm5meBalHWwPT26ihG+T2iAntCAbXLnARsZ
 hT3TDhGw1Kx1flaIVrck+jAH6QhLxm0WuM381la7ddS45lNn6t61Hoxg7ZGeiSP+
 bBaYDkRkfIsMu0bw9t+EQApnNyLMM52q3UjC9I1Uy9KfeIcxMqx8mVTUzqPgblFe
 R4McdU025klNwpqUWfCNzJ57br8Pwy50VPH83l6TYLgm7YO90maTiD8w5xBKUNoQ
 tPgbPhs1l/ZPPNCFNYf1679f6ELaOif8hW0/1VwWYXF13Lrcbu3fx8cUFr246FaK
 XM+6SH/O9JGf/yNrtJ8j+oFCVZADLuvIriyEHBnkEihZx7bzYd1z7lJD1bEZSYqI
 Nf5Unaji4nsduYaeRSLu6+XpIAMCmKsgYbEAo+0DT9e+rxsCc7QSMBhmnU2e+lEl
 0IZLvX63BsyVqUUGXoXnRrEziPdMz4Rf34Y3oVwCKEMGN72bsJFI2lVP+/ywnkoV
 PRKr/LKTENmbEJP4CD14fOZsGrrub6MrAqKOEPYL/06omEvUwlA/mJVsoeNIf/TG
 foD8qiVb5roQYAvdQJ/wZtCwIAgcmbLApxLLe+RCQrxtibWTCLI=
 =c7cP
 -----END PGP SIGNATURE-----

Merge tag 'at24-fixes-for-v5.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-current

at24 fixes for v5.9-rc5

- delay registration of the nvmem provider until after power is enabled
2020-09-09 10:17:08 +02:00
Vadym Kochan
45df80d760 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: cd5676db05 ("misc: eeprom: at24: support pm_runtime control")
Fixes: b20eb4c1f0 ("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>
2020-09-01 09:49:55 +02:00
Greg Kroah-Hartman
dd5597245d Merge 5.9-rc3 into char-misc-next
We need the fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-31 07:17:17 +02:00
Christian Eggers
284f52ac1c eeprom: at25: set minimum read/write access stride to 1
SPI eeproms are addressed by byte.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200728092959.24600-1-ceggers@arri.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-28 12:08:09 +02:00
Christian Eggers
d3cd0071a8 eeprom: at25: allow page sizes greater than 16 bit
Storage technologies like FRAM have no "write pages", the whole chip can
be written within one SPI transfer. For these chips, the page size can
be set equal to the device size. Currently available devices are already
bigger than 64 kiB.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Link: https://lore.kernel.org/r/20200727111218.26926-1-ceggers@arri.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-28 12:08:08 +02:00
Jean Delvare
99363d1c26 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>
2020-08-25 17:50:15 +02:00
Gustavo A. R. Silva
df561f6688 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-23 17:36:59 -05:00
Jean Delvare
a4423cedc5 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>
2020-08-18 15:40:20 +02:00
Lee Jones
8965930c0b 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>
2020-07-10 14:50:51 +02:00
Lee Jones
98e72eb643 misc: eeprom: eeprom_93cx6: Repair function arg descriptions
Copy-paste issue.  Looks like the kerneldoc style descriptions for
these functions were taken from existing functions with slightly
different argument names.

Fixes the following W=1 warnings:

 drivers/misc/eeprom/eeprom_93cx6.c:239: warning: Function parameter or member 'byte' not described in 'eeprom_93cx6_readb'
 drivers/misc/eeprom/eeprom_93cx6.c:239: warning: Excess function parameter 'word' description in 'eeprom_93cx6_readb'
 drivers/misc/eeprom/eeprom_93cx6.c:280: warning: Function parameter or member 'bytes' not described in 'eeprom_93cx6_multireadb'
 drivers/misc/eeprom/eeprom_93cx6.c:280: warning: Excess function parameter 'words' description in 'eeprom_93cx6_multireadb'

Cc: Wolfram Sang <wsa@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20200626130525.389469-7-lee.jones@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-06-29 18:45:52 +02:00
Wolfram Sang
6d7e0a3420 Linux 5.6-rc7
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAl54EZgeHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGLpwIAJv475oyWJDefyZn
 Va5GF+LgR3CMGnfOQXyLXphFUU0fYQtuHb6E5w2hmMpovNrlbpzuypuOetqN1gtQ
 DpDgt6htHlBAJCNkNnHOjEARmMZo64D2dnLlTfa6fjJMc4tg3yk/oMFXFpiP0kdd
 ena4DetB293IF2EjP7RWfVbXzbZzG4sLmIsOmUiFH1H1nhTV8tZWG06KvUcwuCSU
 AfrXiOaVj6npiShszjdODYaFRL6mYh5es7q02wQpKeWdZHRU8IuKTgywiOjh6uD4
 J2bXvz0qbDN/2Zgj73H8EfkAP7zm6nCHifQiUm9uRsjzpcfjFRYIn+4/4LAzCIjm
 VI8uvdA=
 =/NN5
 -----END PGP SIGNATURE-----

Merge tag 'v5.6-rc7' into i2c/for-5.7

Linux 5.6-rc7
2020-03-26 12:09:58 +01:00
Michael Auchter
58d6fee50e 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: cd5676db05 ("misc: eeprom: at24: support pm_runtime control")
Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-03-12 09:02:34 +01:00
Markus Pietrek
4837621cd6 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>
2020-02-10 11:03:39 +01:00
Bibby Hsieh
cd5676db05 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>
2020-01-23 12:52:57 +01:00
Khouloud Touil
1c89074bf8 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>
2020-01-09 10:51:13 +01:00
Bartosz Golaszewski
69afc4b623 eeprom: at24: sort headers alphabetically
For consistency and easier maintenance: sort the headers alphabetically.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-01-02 17:56:32 +01:00
Bartosz Golaszewski
567ec716ef 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>
2020-01-02 17:14:32 +01:00
Linus Torvalds
3265568db8 Merge branch 'i2c/for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "I2C has mostly driver updates this time.

  The few noteworthy changes are: the core has now support for analog
  and digital filters with at91 being the first user, a core addition to
  replace the NULL returning i2c_new_probed_device() with an ERR_PTR
  variant, and the pxa driver has finally being moved to use the generic
  I2C slave interface. We have quite a significant number of reviews per
  patch this time, so thank you to all involved!"

* 'i2c/for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (37 commits)
  video: fbdev: matrox: convert to i2c_new_scanned_device
  i2c: icy: convert to i2c_new_scanned_device
  i2c: replace i2c_new_probed_device with an ERR_PTR variant
  i2c: Fix Kconfig indentation
  i2c: smbus: Don't filter out duplicate alerts
  i2c: i801: Correct Intel Jasper Lake SOC naming
  i2c: i2c-stm32f7: fix 10-bits check in slave free id search loop
  i2c: iproc: Add i2c repeated start capability
  i2c: remove helpers for ref-counting clients
  i2c: tegra: Use dma_request_chan() directly for channel request
  i2c: sh_mobile: Use dma_request_chan() directly for channel request
  i2c: qup: Use dma_request_chan() directly for channel request
  i2c: at91: Use dma_request_chan() directly for channel request
  i2c: rcar: Remove superfluous call to clk_get_rate()
  i2c: pxa: remove unused i2c-slave APIs
  i2c: pxa: migrate to new i2c_slave APIs
  i2c: cros-ec-tunnel: Make the device acpi compatible
  i2c: stm32f7: report dma error during probe
  i2c: icy: no need to populate address for scanned device
  i2c: xiic: Fix kerneldoc warnings
  ...
2019-12-01 18:29:36 -08:00
Jean Delvare
3079b54aa9 eeprom: Warn that the driver is deprecated
Deprecating the driver in Kconfig is one thing, but we also need to
let the users themselves know. Log a warning each time a device is
bound to the deprecated eeprom driver.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20191002104844.1dc4d8f3@endymion
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-04 17:56:27 +02:00
Jean Delvare
285be87c79 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>
2019-10-04 10:46:39 +02:00
Linus Torvalds
351c8a09b0 Merge branch 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:

 - new driver for ICY, an Amiga Zorro card :)

 - axxia driver gained slave mode support, NXP driver gained ACPI

 - the slave EEPROM backend gained 16 bit address support

 - and lots of regular driver updates and reworks

* 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (52 commits)
  i2c: tegra: Move suspend handling to NOIRQ phase
  i2c: imx: ACPI support for NXP i2c controller
  i2c: uniphier(-f): remove all dev_dbg()
  i2c: uniphier(-f): use devm_platform_ioremap_resource()
  i2c: slave-eeprom: Add comment about address handling
  i2c: exynos5: Remove IRQF_ONESHOT
  i2c: stm32f7: Make structure stm32f7_i2c_algo constant
  i2c: cht-wc: drop check because i2c_unregister_device() is NULL safe
  i2c-eeprom_slave: Add support for more eeprom models
  i2c: fsi: Add of_put_node() before break
  i2c: synquacer: Make synquacer_i2c_ops constant
  i2c: hix5hd2: Remove IRQF_ONESHOT
  i2c: i801: Use iTCO version 6 in Cannon Lake PCH and beyond
  watchdog: iTCO: Add support for Cannon Lake PCH iTCO
  i2c: iproc: Make bcm_iproc_i2c_quirks constant
  i2c: iproc: Add full name of devicetree node to adapter name
  i2c: piix4: Add ACPI support
  i2c: piix4: Fix probing of reserved ports on AMD Family 16h Model 30h
  i2c: ocores: use request_any_context_irq() to register IRQ handler
  i2c: designware: Fix optional reset error handling
  ...
2019-09-24 16:48:02 -07:00
Jean Delvare
c165d8947b eeprom: Deprecate the legacy eeprom driver
Time has come to get rid of the old eeprom driver. The at24 driver
should be used instead. So mark the eeprom driver as deprecated and
give users some time to migrate. Then we can remove the legacy
eeprom driver completely.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20190902104838.058725c2@endymion
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-04 09:57:35 +02:00
Wolfram Sang
51d138292e at24: updates for v5.4
- don't include an unneeded header
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl1uVqgACgkQEacuoBRx
 13I6yA/6AnhHAaRAnnWab+D1rl7a0SyO5aQ06pWhWIE0dpWOKYZEQGGI1SfVUqp3
 0gez/vRR8ae/SkmS8SiM1YZAlf6JqgE/sNZ3qKkg/8Iiowe4rGCjg/IOw2qv6fh2
 B5qW+M54SJsEZbd7L6YBHRrGdYEq5DI2lBWtS/R0Ut5rte+NtRC12ws9D4sEcnQP
 LacGA9xnFwt1AbMQ9UodRQJAjWD5u85C7Yyozsi34VQdMo5aO4pweo3EWH3tsjJG
 HbCPGTpNN/plSF+2uta2lBQ9rZ0/A+G3CACFVlby2EVivf3LIGiAB3w7GX6klOot
 NnJVdCE4sMrjCB7F4/bL31nkGFA2swoSu6yamdLd0qNpWaXsX1WmrYIj2V404kMA
 /Xa5GRijQcpmeGd6uywxz8KIdZ+9303ONzJO2/XJp2CFQONoYSfcAmzpGv0cbh9s
 2YubDkdgoxTYK7PQtrHw01v8MROABclUapTVLrJg6FkQCeeaE2tFR2DEFTnW9NlT
 VEANXZr0OJUVtCKqJHKOEW97Z6GESqZZa/rQP+oUCz1FKpHs4TlSqTk+Vtg9ubhd
 QCfIUWXH06rA4wxVvEcisl+D/aImtXwan53PJfF4i3gG5ql5Nmpd035suB3G3gso
 Cmv+jhppX2tj+Eae4gHoFqivNhH/6RNcMXvF7PQeoJIAcCH1/7M=
 =FWOl
 -----END PGP SIGNATURE-----

Merge tag 'at24-v5.4-updates-for-wolfram' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-5.4

at24: updates for v5.4

- don't include an unneeded header
2019-09-03 19:30:06 +02:00
Greg Kroah-Hartman
77e38c19f3 Merge 5.3-rc4 into char-misc-next
We need the char-misc fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-12 07:33:23 +02:00
Wolfram Sang
3a5ff11be8 at24 fixes for v5.3-rc3
- make spd eeproms world-readable again
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl1AC2YACgkQEacuoBRx
 13IS3A/9GLU2ZIc9N/+JooR5H53ztTGWtznuFXaCnyuI9v3kI9DH6CDE5D5C6p4a
 wy79v/5qWgETp0BJ+RLkZqyMr5cEPgrETNRIa1IGF12btsaMd5KqOUpSB/1OCoGM
 MB70GcKWyABXrK1w0ijm+6saeVrirPZbUfoTLm4LvhAHIOB7GN6TZdfz8X50ovtf
 9WsJpZjRM5u7plOEE4PAgvq4fq1Av2fwRNKz8if4TfH9pBrmGbzdiu3GPzqxSdBI
 qjh/Bkb3gJ/ZAi/VkL3/Bj9eLqgrSDF+2y+krjTHMpynZiSFpIhkm/sambXQdywj
 Zbq7Es7r/2hy8QP6WgT6dQTHp1YtmyKVMFX12Wcp5XCcnpIUxFKqq5aax4f5ekw5
 9R+eyg5hlQz5yjlw5BoyatyeL4uhp9mVKLqGMf3rGfwIn1sDNz/TOl4GFivp9bUq
 SX1ePq3TPeeBcUQssCwvknzGwv1/noedxOvTXO6lO2jii9gJM380/KrOd8Ll3ik5
 cDI/T7A7owuBeDGhRWtSln9kNGa2psUcn2lIJgvddFvfR9NDsu1z2XyZ2AjmThqI
 wCC8WLAENLbrLw0rcMHThs23Xj+B/C8OH+C4fUcad2En00SufYaS+sHsJn8uER5u
 aJaJwzigfogX2vVDSn/GmvxugX2BJ2UCPr5t8Fm9b3JO8fexKmg=
 =Olm4
 -----END PGP SIGNATURE-----

Merge tag 'at24-v5.3-rc3-fixes-for-wolfram' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-current

at24 fixes for v5.3-rc3

- make spd eeproms world-readable again
2019-08-01 14:05:17 +02:00
Greg Kroah-Hartman
6de465a50a Merge 5.3-rc2 into char-misc-next
We want the char/misc fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-29 08:25:19 +02:00
Jean Delvare
25e5ef302c 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: 57d155506d ("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>
2019-07-28 18:49:20 +02:00
Arseny Solokha
1b5621832f eeprom: make older eeprom drivers select NVMEM_SYSFS
misc/eeprom/{at24,at25,eeprom_93xx46} drivers all register their
corresponding devices in the nvmem framework in compat mode which requires
nvmem sysfs interface to be present. The latter, however, has been split
out from nvmem under a separate Kconfig in commit ae0c2d7255 ("nvmem:
core: add NVMEM_SYSFS Kconfig"). As a result, probing certain I2C-attached
EEPROMs now fails with

  at24: probe of 0-0050 failed with error -38

because of a stub implementation of nvmem_sysfs_setup_compat()
in drivers/nvmem/nvmem.h. Update the nvmem dependency for these drivers
so they could load again:

  at24 0-0050: 32768 byte 24c256 EEPROM, writable, 64 bytes/write

Cc: Adrian Bunk <bunk@kernel.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Link: https://lore.kernel.org/r/20190716111236.27803-1-asolokha@kb.kras.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-25 14:39:51 +02:00
Wolfram Sang
2495aeeca2 misc: eeprom: max6875: convert to i2c_new_dummy_device
Move from i2c_new_dummy() to i2c_new_dummy_device(), so we now get an
ERRPTR which we use in error handling.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20190722172616.3982-3-wsa+renesas@sang-engineering.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-25 10:06:54 +02:00
Wolfram Sang
80257121f4 misc: eeprom: ee1004: convert to i2c_new_dummy_device
Move from i2c_new_dummy() to i2c_new_dummy_device(), so we now get an
ERRPTR which we use in error handling.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20190722172616.3982-2-wsa+renesas@sang-engineering.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-25 10:06:54 +02:00
Bartosz Golaszewski
10742fee98 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>
2019-07-22 14:36:56 +02:00
Linus Torvalds
273cbf61c3 Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "New stuff from the I2C world:

   - in the core, getting irqs from ACPI is now similar to OF

   - new driver for MediaTek MT7621/7628/7688 SoCs

   - bcm2835, i801, and tegra drivers got some more attention

   - GPIO API cleanups

   - cleanups in the core headers

   - lots of usual driver updates"

* 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (74 commits)
  i2c: mt7621: Fix platform_no_drv_owner.cocci warnings
  i2c: cpm: remove casting dma_alloc
  dt-bindings: i2c: sun6i-p2wi: Fix the binding example
  dt-bindings: i2c: mv64xxx: Fix the example compatible
  i2c: i801: Documentation update
  i2c: i801: Add support for Intel Tiger Lake
  i2c: i801: Fix PCI ID sorting
  dt-bindings: i2c-stm32: document optional dmas
  i2c: i2c-stm32f7: Add I2C_SMBUS_I2C_BLOCK_DATA support
  i2c: core: Tidy up handling of init_irq
  i2c: core: Move ACPI gpio IRQ handling into i2c_acpi_get_irq
  i2c: core: Move ACPI IRQ handling to probe time
  i2c: acpi: Factor out getting the IRQ from ACPI
  i2c: acpi: Use available IRQ helper functions
  i2c: core: Allow whole core to use i2c_dev_irq_from_resources
  eeprom: at24: modify a comment referring to platform data
  dt-bindings: i2c: omap: Add new compatible for J721E SoCs
  dt-bindings: i2c: mv64xxx: Add YAML schemas
  dt-bindings: i2c: sun6i-p2wi: Add YAML schemas
  i2c: mt7621: Add MediaTek MT7621/7628/7688 I2C driver
  ...
2019-07-15 21:10:39 -07:00
Wolfram Sang
504ee6b306 at24: updates for v5.3
- simplify the probing code by using devm_i2c_new_dummy_device()
 - simplify the code further by moving the code around a bit
 - use struct_size() instead of calculating the required structure size
   by hand
 - remove any references to now removed platform data from comments
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl0U0qIACgkQEacuoBRx
 13JtDxAA2hX6NnELwZNCxKjEz0eV/qPZtXaq87E5GntkbWxxrbrRqTJ1A8r4OYrA
 JDzMIkt01jOD+FMxnvtKiWioOspVv41juedWcu1BhhEk01BahwJ/aaTOBKkvfGWC
 slYemFA6Ue2UYVcEz++g5tXHscqbjywMwAUtib+3AWKFKk0DBqsTlfvimD5ZAUgn
 V62GyP5iYM+jycF4iDcISjKzxur/aEPgIJ6NBb71aISocHD6Iy5gF7mqGR8XG7NZ
 7B5yIleE86QNkakzuBx5h4v+T88e1s+0lZhvZOMCpWb73Bi5Q7GpfPToyBWdwbma
 p0E8Yz1UbtPdXxEm8g3kkKo/UbwNkWWii/EEUqOud50/SGPrXWf/Ipo8SyCQhvpS
 bvRldfxHj23LhRtrKzRLZQ3wq6wAXM/Aa5/il6GBbQO0xIKrLKcS+8JwvXmLA4iL
 +COhzIjGAJVbhJycbAz0Mue/QAI3leDfbLVFy/52LwDRKUQxrbJPs0wlqcDbeeaQ
 uJC2ddLuKv/eDWWP3xYF9ROyNfQhypWFWw6slNYHTEMDCF5QIoLM3oueT6JPFGCE
 PkjoBX6Ro3fOZHUihE/2AFjVT36PAGh1tJI2/Zn1DRRtBVVeAD3EUIZdw/NvAWnL
 CHti4/eFxjUF/2v6RBgJ2LgMWUrSIanp3Tu8FsXmRaXXgDLtWvQ=
 =4kIu
 -----END PGP SIGNATURE-----

Merge tag 'at24-v5.3-updates-for-wolfram' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-5.3

at24: updates for v5.3

- simplify the probing code by using devm_i2c_new_dummy_device()
- simplify the code further by moving the code around a bit
- use struct_size() instead of calculating the required structure size
  by hand
- remove any references to now removed platform data from comments
2019-06-29 13:01:34 +02:00
Bartosz Golaszewski
dce91ba39c 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>
2019-06-27 15:55:08 +02:00
Greg Kroah-Hartman
8083f3d788 Merge 5.2-rc6 into char-misc-next
We need the char-misc fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-23 09:23:33 +02:00
Greg Kroah-Hartman
f506a547a9 eeprom: idt_89hpesx: remove unneeded csr_file variable
The csr_file variable was only ever set, never read.  So remove it from
struct idt_89hpesx_dev as it is pointless to keep around.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 19:39:28 +02:00
Thomas Gleixner
d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Greg Kroah-Hartman
0154ec71d5 Merge 5.2-rc4 into char-misc-next
We want the char/misc driver fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-09 09:11:21 +02:00
Thomas Gleixner
b886d83c5b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation version 2 of the license

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 315 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190531190115.503150771@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:37:17 +02:00
Gustavo A. R. Silva
9ae9d9bfb7 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>
2019-05-31 09:06:52 +02:00
YueHaibing
a880658124 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 e7308628d0 ("eeprom:
at24: use devm_i2c_new_dummy_device()")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-05-31 09:02:27 +02:00
Thomas Gleixner
c942fddf87 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
Based on 3 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [kishon] [vijay] [abraham]
  [i] [kishon]@[ti] [com] this program is distributed in the hope that
  it will be useful but without any warranty without even the implied
  warranty of merchantability or fitness for a particular purpose see
  the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [graeme] [gregory]
  [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
  [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
  [hk] [hemahk]@[ti] [com] this program is distributed in the hope
  that it will be useful but without any warranty without even the
  implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1105 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:37 -07:00
Thomas Gleixner
2874c5fd28 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 3029 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:32 -07:00
Bartosz Golaszewski
b20eb4c1f0 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>
2019-05-28 17:55:11 +02:00
Bartosz Golaszewski
e7308628d0 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>
2019-05-28 17:54:51 +02:00
Jean Delvare
31641e34e8 eeprom: ee1004: Deal with nack on page selection
Some EE1004 implementations will not properly ack page selection
commands. They still set the page correctly, so there is no actual
error. Deal with this case gracefully by checking the currently
selected page after we receive a nack. If the page is set right then
we can continue.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-24 20:42:50 +02:00
Jean Delvare
5d45875174 eeprom: ee1004: Move selected page detection to a separate function
No functional change, this is in preparation for future needs.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-24 20:42:50 +02:00
Thomas Gleixner
ec8f24b7fa treewide: Add SPDX license identifier - Makefile/Kconfig
Add SPDX license identifiers to all Make/Kconfig files which:

 - Have no license information of any form

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:46 +02:00
Bartosz Golaszewski
950bcbbe31 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>
2019-02-14 09:32:35 +01:00
Bartosz Golaszewski
4fa882c9f6 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>
2019-02-14 09:32:19 +01:00
Adrian Bunk
37cf28d3b5 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>
2018-12-10 16:23:27 +01:00
Linus Torvalds
57dbde63f2 Merge branch 'i2c/for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "I2C has not so much stuff this time. Mostly driver enablement for new
  SoCs, some driver bugfixes, and some cleanups"

* 'i2c/for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (35 commits)
  MAINTAINERS: add maintainer for Renesas RIIC driver
  i2c: sh_mobile: Remove dummy runtime PM callbacks
  i2c: uniphier-f: fix race condition when IRQ is cleared
  i2c: uniphier-f: fix occasional timeout error
  i2c: uniphier-f: make driver robust against concurrency
  i2c: i2c-qcom-geni: Simplify irq handler
  i2c: i2c-qcom-geni: Simplify tx/rx functions
  i2c: designware: Set IRQF_NO_SUSPEND flag for all BYT and CHT controllers
  i2c: mux: mlxcpld: simplify code to reach the adapter
  i2c: mux: ltc4306: simplify code to reach the adapter
  i2c: mux: pca954x: simplify code to reach the adapter
  i2c: core: remove level of indentation in i2c_transfer
  i2c: core: remove outdated DEBUG output
  i2c: zx2967: use core to detect 'no zero length' quirk
  i2c: tegra: use core to detect 'no zero length' quirk
  i2c: qup: use core to detect 'no zero length' quirk
  i2c: omap: use core to detect 'no zero length' quirk
  i2c: Convert to using %pOFn instead of device_node.name
  i2c: brcmstb: Allow enabling the driver on DSL SoCs
  eeprom: at24: fix unexpected timeout under high load
  ...
2018-10-29 14:44:03 -07:00
Jean Delvare
3b7584a296 eeprom: New ee1004 driver for DDR4 memory
The EEPROMs which hold the SPD data on DDR4 memory modules are no
longer standard AT24C02-compatible EEPROMs. They are 512-byte EEPROMs
which use only 1 I2C address for data access. You need to switch
between the lower page and the upper page of data by sending commands
on the SMBus.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-15 20:51:46 +02:00
YueHaibing
5fe9f6ccbb eeprom: at25: remove unneeded 'at25_remove'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/misc/eeprom/at25.c: In function 'at25_remove':
drivers/misc/eeprom/at25.c:384:20: warning:
 variable 'at25' set but not used [-Wunused-but-set-variable]

Since commit 96d08fb43e ("eeprom: at25: use devm_nvmem_register()"),
at25_remove is do nothing, so can be removed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-15 20:51:46 +02:00
Wang Xin
9a9e295e7c 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>
2018-10-02 16:58:21 +02:00
Bartosz Golaszewski
96d08fb43e eeprom: at25: use devm_nvmem_register()
Use the resource managed variant of nvmem_register().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-28 15:14:53 +02:00
Bartosz Golaszewski
c853d6904f eeprom: eeprom_93xx46: use resource management
Use resource managed variants of nvmem_register() and kzalloc().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-28 15:14:53 +02:00
Linus Torvalds
99cc7ad46b Merge branch 'i2c/for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:

 - the core has now a lockless variant of i2c_smbus_xfer. Some open
   coded versions of this got removed in drivers. This also enables
   proper SCCB support in regmap.

 - locking got a more precise naming. i2c_{un}lock_adapter() had to go,
   and we know use i2c_lock_bus() consistently with flags like
   I2C_LOCK_ROOT_ADAPTER and I2C_LOCK_SEGMENT to avoid ambiguity.

 - the gpio fault injector got a new delicate testcase

 - the bus recovery procedure got fixed to handle the new testcase
   correctly

 - a new quirk flag for controllers not able to handle zero length
   messages together with driver updates to use it

 - new drivers: FSI bus attached I2C masters, GENI I2C controller, Owl
   family S900

 - and a good set of driver improvements and bugfixes

* 'i2c/for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (77 commits)
  i2c: rcar: implement STOP and REP_START according to docs
  i2c: rcar: refactor private flags
  i2c: core: ACPI: Make acpi_gsb_i2c_read_bytes() check i2c_transfer return value
  i2c: core: ACPI: Properly set status byte to 0 for multi-byte writes
  dt-bindings: i2c: rcar: Add r8a774a1 support
  dt-bindings: i2c: sh_mobile: Add r8a774a1 support
  i2c: imx: Simplify stopped state tracking
  i2c: imx: Fix race condition in dma read
  i2c: pasemi: remove hardcoded bus numbers on smbus
  i2c: designware: Add SPDX license tag
  i2c: designware: Convert to use struct i2c_timings
  i2c: core: Parse SDA hold time from firmware
  i2c: designware-pcidrv: Mark expected switch fall-through
  i2c: amd8111: Mark expected switch fall-through
  i2c: sh_mobile: use core to detect 'no zero length read' quirk
  i2c: xlr: use core to detect 'no zero length' quirk
  i2c: rcar: use core to detect 'no zero length' quirk
  i2c: stu300: use core to detect 'no zero length' quirk
  i2c: pmcmsp: use core to detect 'no zero length' quirk
  i2c: mxs: use core to detect 'no zero length' quirk
  ...
2018-08-21 17:40:46 -07:00
Parth Y Shah
b83a4141f0 misc: eeprom: assignment outside the if statement
Assignment of any variable should be kept outside the if statement

Signed-off-by: Parth Y Shah <sparth1292@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-05 16:25:10 +02:00
Dan Carpenter
c01513b4b2 eeprom: idt_89hpesx: clean up an error pointer vs NULL inconsistency
We check for IS_ERR_OR_NULL() here, but later we check the same thing
for NULL only.  It turns out that it can only be NULL so we can make the
checking consistent by removing the ERR_PTR stuff.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-02 10:42:25 +02:00
Alan Chiang
a2b3bf4846 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>
2018-07-25 09:17:57 +02:00
Gustavo A. R. Silva
0c2ccd8cd1 eeprom: at25: mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-07 17:38:57 +02:00
Colin Ian King
2e08b1dbbc eeprom: idt_89hpesx: remove redundant variable csrval_len
Variable csrval_len is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'csrval_len' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-03 13:01:57 +02:00
Linus Torvalds
9bca19a01d Merge branch 'i2c/for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:

 - mainly feature additions to drivers (stm32f7, qup, xlp9xx, mlxcpld, ...)

 - conversion to use the i2c_8bit_addr_from_msg macro consistently

 - move includes to platform_data

 - core updates to allow the (still in review) I3C subsystem to connect

 - and the regular share of smaller driver updates

* 'i2c/for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (68 commits)
  i2c: qup: fix building without CONFIG_ACPI
  i2c: tegra: Remove suspend-resume
  i2c: imx-lpi2c: Switch to SPDX identifier
  i2c: mxs: Switch to SPDX identifier
  i2c: busses: make use of i2c_8bit_addr_from_msg
  i2c: algos: make use of i2c_8bit_addr_from_msg
  i2c: rcar: document R8A77980 bindings
  i2c: qup: Add command-line parameter to override SCL frequency
  i2c: qup: Correct duty cycle for FM and FM+
  i2c: qup: Add support for Fast Mode Plus
  i2c: qup: add probe path for Centriq ACPI devices
  i2c: robotfuzz-osif: drop pointless test
  i2c: robotfuzz-osif: remove pointless local variable
  i2c: rk3x: Don't print visible virtual mapping MMIO address
  i2c: opal: don't check number of messages in the driver
  i2c: ibm_iic: don't check number of messages in the driver
  i2c: imx: Switch to SPDX identifier
  i2c: mux: pca954x: merge calls to of_match_device and of_device_get_match_data
  i2c: mux: demux-pinctrl: use proper parent device for demux adapter
  i2c: mux: improve error message for failed symlink
  ...
2018-06-14 16:21:46 +09:00
Kees Cook
6da2ec5605 treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:

        kmalloc(a * b, gfp)

with:
        kmalloc_array(a * b, gfp)

as well as handling cases of:

        kmalloc(a * b * c, gfp)

with:

        kmalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kmalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kmalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kmalloc(
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  kmalloc(
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kmalloc(
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kmalloc
+ kmalloc_array
  (
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kmalloc(
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kmalloc(
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kmalloc(
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kmalloc(
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kmalloc(C1 * C2 * C3, ...)
|
  kmalloc(
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kmalloc(sizeof(THING) * C2, ...)
|
  kmalloc(sizeof(TYPE) * C2, ...)
|
  kmalloc(C1 * C2 * C3, ...)
|
  kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	(E1) * E2
+	E1, E2
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 16:19:22 -07:00