aboutsummaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-12-06 21:41:41 -0700
committerBin Meng <bmeng.cn@gmail.com>2019-12-15 11:44:08 +0800
commit8d72d5bf08488ff28a8ed27389dae8a169c39190 (patch)
tree4dc6096e0d8b7b330eba11cbb9849b562503a30e /drivers/i2c
parent457df2337fc90431dc60b9b256ac1fdb8809f4cf (diff)
downloadu-boot-8d72d5bf08488ff28a8ed27389dae8a169c39190.zip
u-boot-8d72d5bf08488ff28a8ed27389dae8a169c39190.tar.gz
u-boot-8d72d5bf08488ff28a8ed27389dae8a169c39190.tar.bz2
i2c: designware: Avoid using static data
Drivers are not allowed to use static data since they may be used in SPL where BSS is not available. It is possible that driver model may provide support for numbering devices in the future. But for now, move this to global_data. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/designware_i2c_pci.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index e8fc6f2..8d6bb37 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -34,7 +34,6 @@ static int designware_i2c_pci_probe(struct udevice *dev)
static int designware_i2c_pci_bind(struct udevice *dev)
{
- static int num_cards;
char name[20];
/*
@@ -45,9 +44,13 @@ static int designware_i2c_pci_bind(struct udevice *dev)
* using this driver is impossible for PCIe I2C devices.
* This can be removed, once a better (correct) way for this
* is found and implemented.
+ *
+ * TODO(sjg@chromium.org): Perhaps if uclasses had platdata this would
+ * be possible. We cannot use static data in drivers since they may be
+ * used in SPL or before relocation.
*/
- dev->req_seq = num_cards;
- sprintf(name, "i2c_designware#%u", num_cards++);
+ dev->req_seq = gd->arch.dw_i2c_num_cards++;
+ sprintf(name, "i2c_designware#%u", dev->req_seq);
device_set_name(dev, name);
return 0;