drivers: rearrange for standard use of extern "C" in private headers
Consistently place C++ use of extern "C" after all include directives, within the negative branch of _ASMLANGUAGE if used. Only updated in headers that already had support for drivers built with a C++ compiler. The spi_dw.h file defines macros to declare functions, then uses them within a file that may have out-of-tree overrides. In this case we leave the including file extern "C" active for backward compatibility. Background from issue #17997: Declarations that use C linkage should be placed within extern "C" so the language linkage is correct when the header is included by a C++ compiler. Similarly #include directives should be outside the extern "C" to ensure the language-specific default linkage is applied to any declarations provided by the included header. See: https://en.cppreference.com/w/cpp/language/language_linkage Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
b6dafeb612
commit
5f481bb042
3 changed files with 18 additions and 13 deletions
|
@ -7,15 +7,15 @@
|
||||||
#ifndef MPXXDTYY_H
|
#ifndef MPXXDTYY_H
|
||||||
#define MPXXDTYY_H
|
#define MPXXDTYY_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <audio/dmic.h>
|
#include <audio/dmic.h>
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include "OpenPDMFilter.h"
|
#include "OpenPDMFilter.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MPXXDTYY_MIN_PDM_FREQ 1200000 /* 1.2MHz */
|
#define MPXXDTYY_MIN_PDM_FREQ 1200000 /* 1.2MHz */
|
||||||
#define MPXXDTYY_MAX_PDM_FREQ 3250000 /* 3.25MHz */
|
#define MPXXDTYY_MAX_PDM_FREQ 3250000 /* 3.25MHz */
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
#ifndef ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
|
#ifndef ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
|
||||||
#define ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
|
#define ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <drivers/i2c.h>
|
#include <drivers/i2c.h>
|
||||||
#include <dt-bindings/i2c/i2c.h>
|
#include <dt-bindings/i2c/i2c.h>
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline u32_t i2c_map_dt_bitrate(u32_t bitrate)
|
static inline u32_t i2c_map_dt_bitrate(u32_t bitrate)
|
||||||
{
|
{
|
||||||
switch (bitrate) {
|
switch (bitrate) {
|
||||||
|
|
|
@ -9,8 +9,11 @@
|
||||||
#ifndef ZEPHYR_DRIVERS_SPI_SPI_DW_H_
|
#ifndef ZEPHYR_DRIVERS_SPI_SPI_DW_H_
|
||||||
#define ZEPHYR_DRIVERS_SPI_SPI_DW_H_
|
#define ZEPHYR_DRIVERS_SPI_SPI_DW_H_
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <drivers/spi.h>
|
#include <drivers/spi.h>
|
||||||
|
|
||||||
|
#include "spi_context.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,8 +32,6 @@ struct spi_dw_config {
|
||||||
u8_t op_modes;
|
u8_t op_modes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "spi_context.h"
|
|
||||||
|
|
||||||
struct spi_dw_data {
|
struct spi_dw_data {
|
||||||
#ifdef CONFIG_CLOCK_CONTROL
|
#ifdef CONFIG_CLOCK_CONTROL
|
||||||
struct device *clock;
|
struct device *clock;
|
||||||
|
@ -194,6 +195,10 @@ struct spi_dw_data {
|
||||||
/*
|
/*
|
||||||
* Including the right register definition file
|
* Including the right register definition file
|
||||||
* SoC SPECIFIC!
|
* SoC SPECIFIC!
|
||||||
|
*
|
||||||
|
* The file included next uses the DEFINE_MM_REG macros above to
|
||||||
|
* declare functions. In this situation we'll leave the containing
|
||||||
|
* extern "C" active in C++ compilations.
|
||||||
*/
|
*/
|
||||||
#include "spi_dw_regs.h"
|
#include "spi_dw_regs.h"
|
||||||
|
|
||||||
|
@ -215,8 +220,6 @@ DEFINE_TEST_BIT_OP(sr_busy, DW_SPI_REG_SR, DW_SPI_SR_BUSY_BIT)
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_CONTROL
|
#ifdef CONFIG_CLOCK_CONTROL
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static inline int clock_config(struct device *dev)
|
static inline int clock_config(struct device *dev)
|
||||||
{
|
{
|
||||||
const struct spi_dw_config *info = dev->config->config_info;
|
const struct spi_dw_config *info = dev->config->config_info;
|
||||||
|
@ -260,7 +263,8 @@ static inline void clock_off(struct device *dev)
|
||||||
|
|
||||||
extra_clock_off(dev);
|
extra_clock_off(dev);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
#else /* CONFIG_CLOCK_CONTROL */
|
||||||
#define clock_config(...)
|
#define clock_config(...)
|
||||||
#define clock_on(...)
|
#define clock_on(...)
|
||||||
#define clock_off(...)
|
#define clock_off(...)
|
||||||
|
@ -269,4 +273,5 @@ static inline void clock_off(struct device *dev)
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ZEPHYR_DRIVERS_SPI_SPI_DW_H_ */
|
#endif /* ZEPHYR_DRIVERS_SPI_SPI_DW_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue