Skip to content

Commit 92c9db2

Browse files
gmarullcarlescufi
authored andcommitted
device: rename some *DEVICE*DEFINE* arguments
drv_name -> name pm_device -> pm data_ptr -> data cfg_ptr -> config api_ptr -> api state_ptr -> state Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 3316122 commit 92c9db2

File tree

7 files changed

+152
-181
lines changed

7 files changed

+152
-181
lines changed

include/zephyr/device.h

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ typedef int16_t device_handle_t;
124124
* @param dev_id A unique token which is used in the name of the
125125
* global device structure as a C identifier.
126126
*
127-
* @param drv_name A string name for the device, which will be stored
127+
* @param name A string name for the device, which will be stored
128128
* in the device structure's @p name field. This name can be used to
129129
* look up the device with device_get_binding(). This must be less
130130
* than Z_DEVICE_MAX_NAME_LEN characters (including terminating NUL)
@@ -133,15 +133,15 @@ typedef int16_t device_handle_t;
133133
* @param init_fn Pointer to the device's initialization function,
134134
* which will be run by the kernel during system initialization.
135135
*
136-
* @param pm_device Pointer to the device's power management
136+
* @param pm Pointer to the device's power management
137137
* resources, a <tt>struct pm_device</tt>, which will be stored in the
138138
* device structure's @p pm field. Use NULL if the device does not use
139139
* PM.
140140
*
141-
* @param data_ptr Pointer to the device's private mutable data, which
141+
* @param data Pointer to the device's private mutable data, which
142142
* will be stored in the device structure's @p data field.
143143
*
144-
* @param cfg_ptr Pointer to the device's private constant data, which
144+
* @param config Pointer to the device's private constant data, which
145145
* will be stored in the device structure's @p config field.
146146
*
147147
* @param level The device's initialization level. See SYS_INIT() for
@@ -150,13 +150,13 @@ typedef int16_t device_handle_t;
150150
* @param prio The device's priority within its initialization level.
151151
* See SYS_INIT() for details.
152152
*
153-
* @param api_ptr Pointer to the device's API structure. Can be NULL.
153+
* @param api Pointer to the device's API structure. Can be NULL.
154154
*/
155-
#define DEVICE_DEFINE(dev_id, drv_name, init_fn, pm_device, data_ptr, cfg_ptr, \
156-
level, prio, api_ptr) \
155+
#define DEVICE_DEFINE(dev_id, name, init_fn, pm, data, config, level, prio, \
156+
api) \
157157
Z_DEVICE_STATE_DEFINE(DT_INVALID_NODE, dev_id); \
158-
Z_DEVICE_DEFINE(DT_INVALID_NODE, dev_id, drv_name, init_fn, pm_device, \
159-
data_ptr, cfg_ptr, level, prio, api_ptr, \
158+
Z_DEVICE_DEFINE(DT_INVALID_NODE, dev_id, name, init_fn, pm, data, \
159+
config, level, prio, api, \
160160
&Z_DEVICE_STATE_NAME(dev_id))
161161

162162
/**
@@ -195,15 +195,15 @@ typedef int16_t device_handle_t;
195195
* @param init_fn Pointer to the device's initialization function,
196196
* which will be run by the kernel during system initialization.
197197
*
198-
* @param pm_device Pointer to the device's power management
198+
* @param pm Pointer to the device's power management
199199
* resources, a <tt>struct pm_device</tt>, which will be stored in the
200200
* device structure's @p pm field. Use NULL if the device does not use
201201
* PM.
202202
*
203-
* @param data_ptr Pointer to the device's private mutable data, which
203+
* @param data Pointer to the device's private mutable data, which
204204
* will be stored in the device structure's @p data field.
205205
*
206-
* @param cfg_ptr Pointer to the device's private constant data, which
206+
* @param config Pointer to the device's private constant data, which
207207
* will be stored in the device structure's @p config field.
208208
*
209209
* @param level The device's initialization level. See SYS_INIT() for
@@ -212,14 +212,14 @@ typedef int16_t device_handle_t;
212212
* @param prio The device's priority within its initialization level.
213213
* See SYS_INIT() for details.
214214
*
215-
* @param api_ptr Pointer to the device's API structure. Can be NULL.
215+
* @param api Pointer to the device's API structure. Can be NULL.
216216
*/
217-
#define DEVICE_DT_DEFINE(node_id, init_fn, pm_device, data_ptr, cfg_ptr, level,\
218-
prio, api_ptr, ...) \
217+
#define DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, prio, api, \
218+
...) \
219219
Z_DEVICE_STATE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id)); \
220220
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
221-
DEVICE_DT_NAME(node_id), init_fn, pm_device, data_ptr, \
222-
cfg_ptr, level, prio, api_ptr, \
221+
DEVICE_DT_NAME(node_id), init_fn, pm, data, config, \
222+
level, prio, api, \
223223
&Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME(node_id)), \
224224
__VA_ARGS__)
225225

@@ -958,21 +958,20 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
958958
* @param node_id Devicetree node id for the device (DT_INVALID_NODE if a
959959
* software device).
960960
* @param dev_id Device identifier (used to name the defined struct device).
961-
* @param drv_name Name of the device.
961+
* @param name Name of the device.
962962
* @param init_fn Device init function.
963-
* @param pm_device Reference to struct pm_device associated with the device.
963+
* @param pm Reference to struct pm_device associated with the device.
964964
* (optional).
965-
* @param data_ptr Reference to device data.
966-
* @param cfg_ptr Reference to device config.
965+
* @param data Reference to device data.
966+
* @param config Reference to device config.
967967
* @param level Initialization level.
968968
* @param prio Initialization priority.
969-
* @param api_ptr Reference to device API.
970-
* @param state_ptr Reference to device state.
969+
* @param api Reference to device API.
970+
* @param state Reference to device state.
971971
* @param ... Optional dependencies, manually specified.
972972
*/
973-
#define Z_DEVICE_DEFINE(node_id, dev_id, drv_name, init_fn, pm_device, \
974-
data_ptr, cfg_ptr, level, prio, api_ptr, state_ptr, \
975-
...) \
973+
#define Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, pm, data, config, \
974+
level, prio, api, state, ...) \
976975
Z_DEVICE_NAME_CHECK(name); \
977976
\
978977
Z_DEVICE_HANDLES_DEFINE(node_id, dev_id, __VA_ARGS__); \

include/zephyr/drivers/can.h

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -591,28 +591,25 @@ struct can_device_state {
591591
*
592592
* @param node_id The devicetree node identifier.
593593
* @param init_fn Name of the init function of the driver.
594-
* @param pm_device PM device resources reference (NULL if device does not use PM).
595-
* @param data_ptr Pointer to the device's private data.
596-
* @param cfg_ptr The address to the structure containing the configuration
594+
* @param pm PM device resources reference (NULL if device does not use PM).
595+
* @param data Pointer to the device's private data.
596+
* @param config The address to the structure containing the configuration
597597
* information for this instance of the driver.
598598
* @param level The initialization level. See SYS_INIT() for
599599
* details.
600600
* @param prio Priority within the selected initialization level. See
601601
* SYS_INIT() for details.
602-
* @param api_ptr Provides an initial pointer to the API function struct
602+
* @param api Provides an initial pointer to the API function struct
603603
* used by the driver. Can be NULL.
604604
*/
605-
#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
606-
data_ptr, cfg_ptr, level, prio, \
607-
api_ptr, ...) \
605+
#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
606+
prio, api, ...) \
608607
Z_CAN_DEVICE_STATE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id)); \
609608
Z_CAN_INIT_FN(Z_DEVICE_DT_DEV_NAME(node_id), init_fn) \
610609
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
611610
DEVICE_DT_NAME(node_id), \
612611
&UTIL_CAT(Z_DEVICE_DT_DEV_NAME(node_id), _init), \
613-
pm_device, \
614-
data_ptr, cfg_ptr, level, prio, \
615-
api_ptr, \
612+
pm, data, config, level, prio, api, \
616613
&(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME(node_id)).devstate), \
617614
__VA_ARGS__)
618615

@@ -625,12 +622,10 @@ struct can_device_state {
625622
#define CAN_STATS_FORM_ERROR_INC(dev_)
626623
#define CAN_STATS_ACK_ERROR_INC(dev_)
627624

628-
#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
629-
data_ptr, cfg_ptr, level, prio, \
630-
api_ptr, ...) \
631-
DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
632-
data_ptr, cfg_ptr, level, prio, \
633-
api_ptr, __VA_ARGS__)
625+
#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
626+
prio, api, ...) \
627+
DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
628+
prio, api, __VA_ARGS__)
634629

635630
#endif /* CONFIG_CAN_STATS */
636631

include/zephyr/drivers/i2c.h

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
491491
*
492492
* @param init_fn Name of the init function of the driver.
493493
*
494-
* @param pm_device PM device resources reference (NULL if device does not use PM).
494+
* @param pm PM device resources reference (NULL if device does not use PM).
495495
*
496-
* @param data_ptr Pointer to the device's private data.
496+
* @param data Pointer to the device's private data.
497497
*
498-
* @param cfg_ptr The address to the structure containing the
498+
* @param config The address to the structure containing the
499499
* configuration information for this instance of the driver.
500500
*
501501
* @param level The initialization level. See SYS_INIT() for
@@ -504,20 +504,17 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
504504
* @param prio Priority within the selected initialization level. See
505505
* SYS_INIT() for details.
506506
*
507-
* @param api_ptr Provides an initial pointer to the API function struct
507+
* @param api Provides an initial pointer to the API function struct
508508
* used by the driver. Can be NULL.
509509
*/
510-
#define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
511-
data_ptr, cfg_ptr, level, prio, \
512-
api_ptr, ...) \
510+
#define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
511+
prio, api, ...) \
513512
Z_I2C_DEVICE_STATE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id)); \
514513
Z_I2C_INIT_FN(Z_DEVICE_DT_DEV_NAME(node_id), init_fn) \
515514
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
516515
DEVICE_DT_NAME(node_id), \
517516
&UTIL_CAT(Z_DEVICE_DT_DEV_NAME(node_id), _init), \
518-
pm_device, \
519-
data_ptr, cfg_ptr, level, prio, \
520-
api_ptr, \
517+
pm_device, data, config, level, prio, api, \
521518
&(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME(node_id)).devstate), \
522519
__VA_ARGS__)
523520

@@ -531,12 +528,10 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
531528
ARG_UNUSED(num_msgs);
532529
}
533530

534-
#define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
535-
data_ptr, cfg_ptr, level, prio, \
536-
api_ptr, ...) \
537-
DEVICE_DT_DEFINE(node_id, &init_fn, pm_device, \
538-
data_ptr, cfg_ptr, level, prio, \
539-
api_ptr, __VA_ARGS__)
531+
#define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
532+
prio, api, ...) \
533+
DEVICE_DT_DEFINE(node_id, &init_fn, pm, data, config, level, \
534+
prio, api, __VA_ARGS__)
540535

541536
#endif /* CONFIG_I2C_STATS */
542537

include/zephyr/drivers/i3c/devicetree.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,26 @@ extern "C" {
126126
*
127127
* @param init_fn Name of the init function of the driver.
128128
*
129-
* @param pm_device PM device resources reference (NULL if device does not use PM).
129+
* @param pm PM device resources reference (NULL if device does not use PM).
130130
*
131-
* @param data_ptr Pointer to the device's private data.
131+
* @param data Pointer to the device's private data.
132132
*
133-
* @param cfg_ptr The address to the structure containing the
134-
* configuration information for this instance of the driver.
133+
* @param config The address to the structure containing the
134+
* configuration information for this instance of the driver.
135135
*
136136
* @param level The initialization level. See SYS_INIT() for
137137
* details.
138138
*
139139
* @param prio Priority within the selected initialization level. See
140140
* SYS_INIT() for details.
141141
*
142-
* @param api_ptr Provides an initial pointer to the API function struct
143-
* used by the driver. Can be NULL.
142+
* @param api Provides an initial pointer to the API function struct
143+
* used by the driver. Can be NULL.
144144
*/
145-
#define I3C_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
146-
data_ptr, cfg_ptr, level, prio, \
147-
api_ptr, ...) \
148-
DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
149-
data_ptr, cfg_ptr, level, prio, \
150-
api_ptr, __VA_ARGS__)
145+
#define I3C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
146+
prio, api, ...) \
147+
DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
148+
prio, api, __VA_ARGS__)
151149

152150
/**
153151
* @brief Like I3C_TARGET_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible

include/zephyr/net/ethernet.h

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -835,70 +835,67 @@ static inline bool net_eth_get_vlan_status(struct net_if *iface)
835835
#endif
836836

837837
#if defined(CONFIG_NET_VLAN)
838-
#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, drv_name, init_fn, \
839-
pm_action_cb, data, cfg, prio, api, mtu) \
838+
#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
839+
config, prio, api, mtu) \
840840
Z_DEVICE_STATE_DEFINE(node_id, dev_id); \
841-
Z_DEVICE_DEFINE(node_id, dev_id, drv_name, init_fn, \
842-
pm_action_cb, data, cfg, POST_KERNEL, \
843-
prio, api, &Z_DEVICE_STATE_NAME(dev_id)); \
841+
Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, pm, data, \
842+
config, POST_KERNEL, prio, api, \
843+
&Z_DEVICE_STATE_NAME(dev_id)); \
844844
NET_L2_DATA_INIT(dev_id, 0, NET_L2_GET_CTX_TYPE(ETHERNET_L2)); \
845845
NET_IF_INIT(dev_id, 0, ETHERNET_L2, mtu, NET_VLAN_MAX_COUNT)
846846

847847
#else /* CONFIG_NET_VLAN */
848848

849-
#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, drv_name, init_fn, \
850-
pm_action_cb, data, cfg, prio, api, mtu) \
851-
Z_NET_DEVICE_INIT(node_id, dev_id, drv_name, init_fn, \
852-
pm_action_cb, data, cfg, prio, api, \
853-
ETHERNET_L2, NET_L2_GET_CTX_TYPE(ETHERNET_L2),\
854-
mtu)
849+
#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
850+
config, prio, api, mtu) \
851+
Z_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
852+
config, prio, api, ETHERNET_L2, \
853+
NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)
855854
#endif /* CONFIG_NET_VLAN */
856855

857856
/**
858857
* @brief Create an Ethernet network interface and bind it to network device.
859858
*
860859
* @param dev_id Network device id.
861-
* @param drv_name The name this instance of the driver exposes to
860+
* @param name The name this instance of the driver exposes to
862861
* the system.
863862
* @param init_fn Address to the init function of the driver.
864-
* @param pm_action_cb Pointer to PM action callback.
863+
* @param pm Pointer to PM action callback.
865864
* Can be NULL if not implemented.
866865
* @param data Pointer to the device's private data.
867-
* @param cfg The address to the structure containing the
866+
* @param config The address to the structure containing the
868867
* configuration information for this instance of the driver.
869868
* @param prio The initialization level at which configuration occurs.
870869
* @param api Provides an initial pointer to the API function struct
871870
* used by the driver. Can be NULL.
872871
* @param mtu Maximum transfer unit in bytes for this network interface.
873872
*/
874-
#define ETH_NET_DEVICE_INIT(dev_id, drv_name, init_fn, pm_action_cb, \
875-
data, cfg, prio, api, mtu) \
876-
Z_ETH_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, drv_name, \
877-
init_fn, pm_action_cb, data, cfg, prio, \
878-
api, mtu)
873+
#define ETH_NET_DEVICE_INIT(dev_id, name, init_fn, pm, data, config, \
874+
prio, api, mtu) \
875+
Z_ETH_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, name, init_fn, \
876+
pm, data, config, prio, api, mtu)
879877

880878
/**
881879
* @brief Like ETH_NET_DEVICE_INIT but taking metadata from a devicetree.
882880
* Create an Ethernet network interface and bind it to network device.
883881
*
884882
* @param node_id The devicetree node identifier.
885883
* @param init_fn Address to the init function of the driver.
886-
* @param pm_action_cb Pointer to PM action callback.
884+
* @param pm Pointer to PM action callback.
887885
* Can be NULL if not implemented.
888886
* @param data Pointer to the device's private data.
889-
* @param cfg The address to the structure containing the
887+
* @param config The address to the structure containing the
890888
* configuration information for this instance of the driver.
891889
* @param prio The initialization level at which configuration occurs.
892890
* @param api Provides an initial pointer to the API function struct
893891
* used by the driver. Can be NULL.
894892
* @param mtu Maximum transfer unit in bytes for this network interface.
895893
*/
896-
#define ETH_NET_DEVICE_DT_DEFINE(node_id, init_fn, pm_action_cb, data, \
897-
cfg, prio, api, mtu) \
894+
#define ETH_NET_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, \
895+
prio, api, mtu) \
898896
Z_ETH_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
899-
DEVICE_DT_NAME(node_id), \
900-
init_fn, pm_action_cb, data, cfg, prio, \
901-
api, mtu)
897+
DEVICE_DT_NAME(node_id), init_fn, pm, \
898+
data, config, prio, api, mtu)
902899

903900
/**
904901
* @brief Like ETH_NET_DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT

0 commit comments

Comments
 (0)