Skip to content

Commit

Permalink
scripts: Replace hard-coded subsystem list with __subsystem annotations.
Browse files Browse the repository at this point in the history
This change removes the hardcoded subsystem list in gen_kobject_list.py
favor of marking the relevant driver API structs with the _subsystem
sentinel.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
  • Loading branch information
Corey Wharton committed Mar 5, 2020
1 parent 2bad994 commit 495773e
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 48 deletions.
2 changes: 1 addition & 1 deletion include/crypto/cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "cipher_structs.h"

/* The API a crypto driver should implement */
struct crypto_driver_api {
__subsystem struct crypto_driver_api {
int (*query_hw_caps)(struct device *dev);

/* Setup a crypto session */
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ typedef int (*adc_api_read_async)(struct device *dev,
*
* This is the mandatory API any ADC driver needs to expose.
*/
struct adc_driver_api {
__subsystem struct adc_driver_api {
adc_api_channel_setup channel_setup;
adc_api_read read;
#ifdef CONFIG_ADC_ASYNC
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ struct zcan_work {
void *cb_arg;
};

struct can_driver_api {
__subsystem struct can_driver_api {
can_configure_t configure;
can_send_t send;
can_attach_isr_t attach_isr;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ typedef u32_t (*counter_api_get_guard_period)(struct device *dev, u32_t flags);
typedef int (*counter_api_set_guard_period)(struct device *dev, u32_t ticks,
u32_t flags);

struct counter_driver_api {
__subsystem struct counter_driver_api {
counter_api_start start;
counter_api_stop stop;
counter_api_get_value get_value;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ typedef int (*dma_api_stop)(struct device *dev, u32_t channel);
typedef int (*dma_api_get_status)(struct device *dev, u32_t channel,
struct dma_status *status);

struct dma_driver_api {
__subsystem struct dma_driver_api {
dma_api_config config;
dma_api_reload reload;
dma_api_start start;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef int (*eeprom_api_write)(struct device *dev, off_t offset,
const void *data, size_t len);
typedef size_t (*eeprom_api_size)(struct device *dev);

struct eeprom_driver_api {
__subsystem struct eeprom_driver_api {
eeprom_api_read read;
eeprom_api_write write;
eeprom_api_size size;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/entropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef int (*entropy_get_entropy_isr_t)(struct device *dev,
u8_t *buffer,
u16_t length,
u32_t flags);
struct entropy_driver_api {
__subsystem struct entropy_driver_api {
entropy_get_entropy_t get_entropy;
entropy_get_entropy_isr_t get_entropy_isr;
};
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/espi.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ typedef int (*espi_api_manage_callback)(struct device *dev,
struct espi_callback *callback,
bool set);

struct espi_driver_api {
__subsystem struct espi_driver_api {
espi_api_config config;
espi_api_get_channel_status get_channel_status;
espi_api_read_request read_request;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ typedef void (*flash_api_pages_layout)(struct device *dev,
size_t *layout_size);
#endif /* CONFIG_FLASH_PAGE_LAYOUT */

struct flash_driver_api {
__subsystem struct flash_driver_api {
flash_api_read read;
flash_api_write write;
flash_api_erase erase;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ enum gpio_int_trig {
GPIO_INT_TRIG_BOTH = GPIO_INT_LOW_0 | GPIO_INT_HIGH_1,
};

struct gpio_driver_api {
__subsystem struct gpio_driver_api {
int (*pin_configure)(struct device *port, gpio_pin_t pin, gpio_flags_t flags);
int (*port_get_raw)(struct device *port, gpio_port_value_t *value);
int (*port_set_masked_raw)(struct device *port, gpio_port_pins_t mask,
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ typedef int (*i2c_api_slave_register_t)(struct device *dev,
typedef int (*i2c_api_slave_unregister_t)(struct device *dev,
struct i2c_slave_config *cfg);

struct i2c_driver_api {
__subsystem struct i2c_driver_api {
i2c_api_configure_t configure;
i2c_api_full_io_t transfer;
i2c_api_slave_register_t slave_register;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ struct i2s_config {
*
* For internal use only, skip these in public documentation.
*/
struct i2s_driver_api {
__subsystem struct i2s_driver_api {
int (*configure)(struct device *dev, enum i2s_dir dir,
struct i2s_config *cfg);
struct i2s_config *(*config_get)(struct device *dev,
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/ipm.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ typedef void (*ipm_register_callback_t)(struct device *port, ipm_callback_t cb,
*/
typedef int (*ipm_set_enabled_t)(struct device *ipmdev, int enable);

struct ipm_driver_api {
__subsystem struct ipm_driver_api {
ipm_send_t send;
ipm_register_callback_t register_callback;
ipm_max_data_size_get_t max_data_size_get;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/kscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef int (*kscan_config_t)(struct device *dev,
typedef int (*kscan_disable_callback_t)(struct device *dev);
typedef int (*kscan_enable_callback_t)(struct device *dev);

struct kscan_driver_api {
__subsystem struct kscan_driver_api {
kscan_config_t config;
kscan_disable_callback_t disable_callback;
kscan_enable_callback_t enable_callback;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef int (*led_api_off)(struct device *dev, u32_t led);
*
* This is the mandatory API any LED driver needs to expose.
*/
struct led_driver_api {
__subsystem struct led_driver_api {
led_api_blink blink;
led_api_set_brightness set_brightness;
led_api_on on;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/pinmux.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef int (*pmux_pullup)(struct device *dev, u32_t pin, u8_t func);
*/
typedef int (*pmux_input)(struct device *dev, u32_t pin, u8_t func);

struct pinmux_driver_api {
__subsystem struct pinmux_driver_api {
pmux_set set;
pmux_get get;
pmux_pullup pullup;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/ps2.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef int (*ps2_write_t)(struct device *dev, u8_t value);
typedef int (*ps2_disable_callback_t)(struct device *dev);
typedef int (*ps2_enable_callback_t)(struct device *dev);

struct ps2_driver_api {
__subsystem struct ps2_driver_api {
ps2_config_t config;
ps2_read_t read;
ps2_write_t write;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef int (*pwm_get_cycles_per_sec_t)(struct device *dev, u32_t pwm,
u64_t *cycles);

/** @brief PWM driver API definition. */
struct pwm_driver_api {
__subsystem struct pwm_driver_api {
pwm_pin_set_t pin_set;
pwm_get_cycles_per_sec_t get_cycles_per_sec;
};
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ typedef int (*sensor_channel_get_t)(struct device *dev,
enum sensor_channel chan,
struct sensor_value *val);

struct sensor_driver_api {
__subsystem struct sensor_driver_api {
sensor_attr_set_t attr_set;
sensor_trigger_set_t trigger_set;
sensor_sample_fetch_t sample_fetch;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ typedef int (*spi_api_release)(struct device *dev,
* @brief SPI driver API
* This is the mandatory API any SPI driver needs to expose.
*/
struct spi_driver_api {
__subsystem struct spi_driver_api {
spi_api_io transceive;
#ifdef CONFIG_SPI_ASYNC
spi_api_io_async transceive_async;
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ struct uart_device_config {
};

/** @brief Driver API structure. */
struct uart_driver_api {
__subsystem struct uart_driver_api {

#ifdef CONFIG_UART_ASYNC_API

Expand Down
2 changes: 1 addition & 1 deletion include/drivers/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ typedef int (*wdt_api_install_timeout)(struct device *dev,
typedef int (*wdt_api_feed)(struct device *dev, int channel_id);

/** @cond INTERNAL_HIDDEN */
struct wdt_driver_api {
__subsystem struct wdt_driver_api {
wdt_api_setup setup;
wdt_api_disable disable;
wdt_api_install_timeout install_timeout;
Expand Down
2 changes: 1 addition & 1 deletion include/ptp_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
#define PTP_CLOCK_NAME "PTP_CLOCK"
#endif

struct ptp_clock_driver_api {
__subsystem struct ptp_clock_driver_api {
int (*set)(struct device *dev, struct net_ptp_time *tm);
int (*get)(struct device *dev, struct net_ptp_time *tm);
int (*adjust)(struct device *dev, int increment);
Expand Down
2 changes: 1 addition & 1 deletion samples/userspace/prod_consumer/src/sample_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef int (*sample_driver_set_callback_t)(struct device *dev,

typedef int (*sample_driver_state_set_t)(struct device *dev, bool active);

struct sample_driver_api {
__subsystem struct sample_driver_api {
sample_driver_write_t write;
sample_driver_set_callback_t set_callback;
sample_driver_state_set_t state_set;
Expand Down
30 changes: 6 additions & 24 deletions scripts/gen_kobject_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,12 @@
])

subsystems = [
"adc_driver_api",
"aio_cmp_driver_api",
"counter_driver_api",
"crypto_driver_api",
"dma_driver_api",
"flash_driver_api",
"gpio_driver_api",
"i2c_driver_api",
"i2s_driver_api",
"ipm_driver_api",
"led_driver_api",
"pinmux_driver_api",
"pwm_driver_api",
"entropy_driver_api",
"sensor_driver_api",
"spi_driver_api",
"uart_driver_api",
"can_driver_api",
"ptp_clock_driver_api",
"eeprom_driver_api",
"wdt_driver_api",

# Fake 'sample driver' subsystem, used by tests/samples
"sample_driver_api"
# Editing the list is deprecated, add the __subsystem sentinal to your driver
# api declaration instead. e.x.
#
# __subsystem struct my_driver_api {
# ....
#};
]

header = """%compare-lengths
Expand Down

0 comments on commit 495773e

Please sign in to comment.