Hi,
This is the first part of my analysis on the status of the I2C driver implementation for STM32.
The following points should be addressed, note very few are functional, mostly style or questions (which I will fix myself):
1) i2c_lld_reset(0 function is not used.
2) i2c_lld_set_clock() and i2c_lld_set_opmode() can be static because the HLL does not uses them anymore.
3) i2c_lld_master_transceive() can be static and cannot use the keyword "inline", you could inline it directly because it is used only one time.
3) There are while loop not protected by timeout in i2c_lld_master_receive_timeout() (OK, here I should explain how to do that using VTs).
4) In i2c_lld_master_receive_timeout() and i2c_lld_master_transmit_timeout() is it correct to call first i2c_lld_wait_bus_free() and then wait for I2C_CR1_STOP ?
5) Use of __NOP() is forbidden, it should not even needed.
6) Some fields of the driver structures have "id_" prefixes, this is obsolete, those prefixes have been removed from all drivers.
7) The id_thread field (and several others) cannot be in the "mandatory" part of the driver structure because are not mandated by the HLL driver.
8) The field txbytes of the driver structure is never used.
9) Could the field rxbytes of the driver structure be eliminated with some rework ? (not sure)
10) Driver fields should not be prefixed with the __IO macro, those are not I/O registers and "volatile" should not be necessary unless there are fields you access from ISRs and out of IRSs outside critical zones (and probably this would be an error anyway).
11) The macro i2c_lld_wait_bus_free() hides a lock, this is generally not a good idea for code readability. Better do it in the same place where the unlock() is.
12) The macro i2c_lld_error_wakeup_isr() assigns a critical pointer outside the critical zone.
13) The driver contains non standard sections like "Knowledge base". This kind of documentation should not be in the code. It must be either private or in the user documentation using Doxygen.
14) #define inside function bodies are not allowed. Definitions must go in the proper section and do not have private scope.
15) Compile time checks must be done in the header file (clock checks).
16) Text beyond column 80 is not allowed and various other formatting issues, not "wrong" code but things done using a different style. This will be addressed at the end using the Eclipse reformatter, no need to do anything.
Good ideas I found:
1) Use of chDbgChecks() on configuration parameters, probably this should be extended to other drivers.
2) Except for style considerations (and forgive me if I am a bit of a nazi here

) the driver code itself looks much cleaner than previous versions.
The list is long but really important points are very few, please address just the functional points, I will address style, formatting and documentation issues at the very end. I will also look into the timeout thing later.
Giovanni