Skip to content

Commit

Permalink
drivers/pcf857x: Move compile time check to compilation unit
Browse files Browse the repository at this point in the history
This allows including the header without using the module. Obviously,
calls to the functions provided by the header won't like without using
the module. But including the header can still be useful for e.g.:

    if (IS_USED(MODULE_PCF857x)) {
        /* make use of the module */
    }

In the above example all calls to pcf857x functions would be optimized
out when the module is not used, full compile checks happen in either
case.
  • Loading branch information
maribu committed Sep 15, 2023
1 parent 7336d9c commit d0fccdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions drivers/include/pcf857x.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ extern "C"
#include "event.h"
#endif /* MODULE_PCF857X_IRQ */

#if !IS_USED(MODULE_PCF8574) && !IS_USED(MODULE_PCF8574A) && !IS_USED(MODULE_PCF8575)
#error "Please provide a list of pcf857x variants used by the application (pcf8574, pcf8574a or pcf8575)"
#endif

/**
* @name PCF857X I2C slave addresses
*
Expand Down
4 changes: 4 additions & 0 deletions drivers/pcf857x/pcf857x.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@

#endif /* ENABLE_DEBUG */

#if !IS_USED(MODULE_PCF8574) && !IS_USED(MODULE_PCF8574A) && !IS_USED(MODULE_PCF8575)
#error "Please provide a list of pcf857x variants used by the application (pcf8574, pcf8574a or pcf8575)"
#endif

#if IS_USED(MODULE_PCF857X_IRQ_LOW)
#define PCF857X_EVENT_PRIO EVENT_PRIO_LOWEST
#elif IS_USED(MODULE_PCF857X_IRQ_MEDIUM)
Expand Down

0 comments on commit d0fccdb

Please sign in to comment.