[U-Boot] [PATCH V2 4/7] Tegra30: Add common CPU (shared) files
Tom Warren
twarren.nvidia at gmail.com
Wed Dec 5 22:43:18 CET 2012
On Wed, Dec 5, 2012 at 2:38 PM, Stephen Warren <swarren at wwwdotorg.org> wrote:
> On 12/05/2012 02:32 PM, Tom Warren wrote:
>> On Wed, Dec 5, 2012 at 1:37 PM, Stephen Warren <swarren at wwwdotorg.org> wrote:
>>> On 12/03/2012 04:45 PM, Tom Warren wrote:
>>>> These files are used by both SPL and main U-Boot.
>>>> Also made minor changes to shared Tegra code to support
>>>> T30 differences.
> ...
>>>> diff --git a/arch/arm/cpu/tegra-common/sys_info.c b/arch/arm/cpu/tegra-common/sys_info.c
> ...
>>>> /* Print CPU information */
>>>> int print_cpuinfo(void)
>>>> {
>>>> +#if defined(CONFIG_TEGRA20)
>>>> puts("TEGRA20\n");
>>>> -
>>>> +#else /* Tegra30 */
>>>> + puts("TEGRA30\n");
>>>> +#endif
>>>
>>> This is fine, but the following wouldn't require editing again for
>>> future chips:
>>>
>>> puts(CONFIG_SYS_SOC);
>>> puts("\n");
>>>
>>> (although it ends up being all lower-case; perhaps there's some other
>>> variable that is upper-case?)
>>
>> How about this:
>>
>> #include <common.h>
>> #include <linux/ctype.h>
>>
>> #ifdef CONFIG_DISPLAY_CPUINFO
>> void upstring(char *s)
>> {
>> while(*s) {
>> *s = toupper(*s);
>> s++;
>> }
>> }
>>
>> /* Print CPU information */
>> int print_cpuinfo(void)
>> {
>> upstring(CONFIG_SYS_SOC);
>> puts(CONFIG_SYS_SOC);
>> puts("\n");
>>
>> return 0;
>> )
>> #endif
>>
>> What do you think?
>
> CONFIG_SYS_SOC is presumably stored in a read-only segment, so that
> might not even work, although I dare say memory protection isn't enabled
> to prevent this. That would also end up modifying the string itself,
> which is probably used elsewhere, where such modification might not be
> desirable.
It does work - I wouldn't present code w/o testing it :)
But the side-effect of modifying CONFIG_SYS_SOC is probably a bad thing.
>
> If you called upstring() on a copy of the string e.g. on the stack, that
> seems reasonable.
I'll copy the string first. I was trying to minimize the amount of
extra code added.
Thanks
More information about the U-Boot
mailing list