diff mbox

[U-Boot,2/2] x86: i2c: Avoid using BSS before it is available

Message ID 1470454528-26998-2-git-send-email-sjg@chromium.org
State Superseded
Delegated to: Heiko Schocher
Headers show

Commit Message

Simon Glass Aug. 6, 2016, 3:35 a.m. UTC
If intel_i2c_bind() is called before relocation there is no BSS section
available. Use the data section instead, which is always available.

A better fix might be to use global_data, perhaps a new member in
x86's struct arch_global_data. Comments welcome.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/i2c/intel_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bin Meng Aug. 7, 2016, 6:54 a.m. UTC | #1
On Sat, Aug 6, 2016 at 11:35 AM, Simon Glass <sjg@chromium.org> wrote:
> If intel_i2c_bind() is called before relocation there is no BSS section
> available. Use the data section instead, which is always available.
>
> A better fix might be to use global_data, perhaps a new member in
> x86's struct arch_global_data. Comments welcome.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/i2c/intel_i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Heiko Schocher Aug. 8, 2016, 2:45 p.m. UTC | #2
Hello Simon,

Am 07.08.2016 um 08:54 schrieb Bin Meng:
> On Sat, Aug 6, 2016 at 11:35 AM, Simon Glass <sjg@chromium.org> wrote:
>> If intel_i2c_bind() is called before relocation there is no BSS section
>> available. Use the data section instead, which is always available.
>>
>> A better fix might be to use global_data, perhaps a new member in
>> x86's struct arch_global_data. Comments welcome.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   drivers/i2c/intel_i2c.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Hmm... I see no i2c_bind() in mainline U-Boot drivers/i2c/intel_i2c.c
driver ?

Is this patch and also patch:
http://patchwork.ozlabs.org/patch/656335/

dependend on another patch(or patchserie) ?

bye,
Heiko
Simon Glass Aug. 8, 2016, 9:44 p.m. UTC | #3
Hi Heiko,

On 8 August 2016 at 08:45, Heiko Schocher <hs@denx.de> wrote:
> Hello Simon,
>
>
> Am 07.08.2016 um 08:54 schrieb Bin Meng:
>>
>> On Sat, Aug 6, 2016 at 11:35 AM, Simon Glass <sjg@chromium.org> wrote:
>>>
>>> If intel_i2c_bind() is called before relocation there is no BSS section
>>> available. Use the data section instead, which is always available.
>>>
>>> A better fix might be to use global_data, perhaps a new member in
>>> x86's struct arch_global_data. Comments welcome.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>   drivers/i2c/intel_i2c.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>
>> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>
>
> Hmm... I see no i2c_bind() in mainline U-Boot drivers/i2c/intel_i2c.c
> driver ?
>
> Is this patch and also patch:
> http://patchwork.ozlabs.org/patch/656335/
>
> dependend on another patch(or patchserie) ?

Yes it depends on Stefan's x86 i2c driver. He asked me to take a look.
It can be squashed in - will leave this to Stefan.

Regards,
Simon
Stefan Roese Aug. 9, 2016, 5:37 a.m. UTC | #4
Hi Simon,

On 08.08.2016 23:44, Simon Glass wrote:
> On 8 August 2016 at 08:45, Heiko Schocher <hs@denx.de> wrote:
>> Hello Simon,
>>
>>
>> Am 07.08.2016 um 08:54 schrieb Bin Meng:
>>>
>>> On Sat, Aug 6, 2016 at 11:35 AM, Simon Glass <sjg@chromium.org> wrote:
>>>>
>>>> If intel_i2c_bind() is called before relocation there is no BSS section
>>>> available. Use the data section instead, which is always available.
>>>>
>>>> A better fix might be to use global_data, perhaps a new member in
>>>> x86's struct arch_global_data. Comments welcome.
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>> ---
>>>>
>>>>   drivers/i2c/intel_i2c.c | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>
>>> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>>
>>
>> Hmm... I see no i2c_bind() in mainline U-Boot drivers/i2c/intel_i2c.c
>> driver ?
>>
>> Is this patch and also patch:
>> http://patchwork.ozlabs.org/patch/656335/
>>
>> dependend on another patch(or patchserie) ?
>
> Yes it depends on Stefan's x86 i2c driver. He asked me to take a look.
> It can be squashed in - will leave this to Stefan.

I have squashed it in v2 of the SMBus I2C driver patch which will
hit the list very soon.

Thanks,
Stefan
Avoid
diff mbox

Patch

diff --git a/drivers/i2c/intel_i2c.c b/drivers/i2c/intel_i2c.c
index 5b7953a..01badf2 100644
--- a/drivers/i2c/intel_i2c.c
+++ b/drivers/i2c/intel_i2c.c
@@ -289,7 +289,7 @@  static int intel_i2c_probe(struct udevice *dev)
 
 static int intel_i2c_bind(struct udevice *dev)
 {
-	static int num_cards;
+	static int num_cards __attribute__ ((section(".data")));
 	char name[20];
 
 	/* Create a unique device name for PCI type devices */