Jump to content
    

Драйвер для I2C

37 минут назад, ericN сказал:

Может какой-нибудь директивой сказать компилятору, чтоб он не оптимизировал и сделал то, что от него просят? Ни как не могу заставить компилятор пройти по циклу 4 раза!

Попробуйте скомпилировать модуль с отключенной оптимизацией (опция -O0).

Share this post


Link to post
Share on other sites

В 21.03.2023 в 14:15, makc сказал:

Попробуйте скомпилировать модуль с отключенной оптимизацией (опция -O0).

помогло. добавил 

#pragma GCC optimize("O0")
static int ch423_probe(struct i2c_client *client)
{

Тело for стало выполняться как положено 4 раза. 

Share this post


Link to post
Share on other sites

1 час назад, ericN сказал:

помогло. добавил 

#pragma GCC optimize("O0")
static int ch423_probe(struct i2c_client *client)
{

Тело for стало выполняться как положено 4 раза. 

Какая у вас версия компилятора, который творит такой беспредел?

Share this post


Link to post
Share on other sites

вообще собираю на хосте с помощью buildroot. в опциях билрута стоит версия 10. этим же buildroot-ом собрал кросскомпилятор для хоста. кросскомпилятор выдает следующее

Цитата

~/tools/arm-rez2-linux-gnueabihf_sdk-buildroot/bin/arm-linux-gcc --version
arm-linux-gcc.br_real (Buildroot 2021.11-1126-gfeb9185fc1-dirty) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

думаю, что этим же gcc собирается ядро. 

 

ps удалил лишние printk, несколько раз собрал с прагмой O0 и без неё. результат подтвердился. с прагмой O0 цикл выполняется 4 раза, без неё - 5 раз.  

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...