Skip to content
Snippets Groups Projects
Commit 8d72d5bf authored by Simon Glass's avatar Simon Glass Committed by Bin Meng
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
parent 457df233
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,7 @@ struct arch_global_data {
ulong table; /* Table pointer from previous loader */
int turbo_state; /* Current turbo state */
struct irq_routing_table *pirq_routing_table;
int dw_i2c_num_cards; /* Used by designware i2c driver */
#ifdef CONFIG_SEABIOS
u32 high_table_ptr;
u32 high_table_limit;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment