Skip to content

Commit 052621d

Browse files
committed
plugins: adrv9002: removed CHANNEL_COUNT define
- replaced it with ADRV9002_NUM_CHANNELS which has the same value - remove implied size for lists in profile_gen_update_channels() Signed-off-by: Andrei Popa <[email protected]>
1 parent a5f67a4 commit 052621d

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

Diff for: plugins/adrv9002.c

+15-16
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ typedef struct rx_radio_channel_config
6767

6868
} rx_radio_channel_config;
6969

70-
#define CHANNEL_COUNT 2
7170

7271
/**
7372
* @struct tx_radio_channel_config
@@ -1262,7 +1261,7 @@ static void profile_gen_update_orx(GtkComboBox *self, struct plugin_private *pri
12621261

12631262
tdd_en = atoi(gtk_combo_box_get_active_id(
12641263
GTK_COMBO_BOX(gtk_builder_get_object(priv->builder, "cb_radio_duplex")))) == 0;
1265-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1264+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
12661265
sprintf(widget_str, "cb_tx_chan%d_en", chann + 1);
12671266
tx_en = gtk_toggle_button_get_active(
12681267
GTK_TOGGLE_BUTTON(gtk_builder_get_object(priv->builder, widget_str)));
@@ -1391,7 +1390,7 @@ static int profile_gen_config_get_from_device(struct adrv9002_config *cfg, gpoin
13911390

13921391
int chann;
13931392
char chann_str[32];
1394-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1393+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
13951394
sprintf(chann_str, "voltage%d", chann);
13961395
struct iio_channel *tx = iio_device_find_channel(priv->adrv9002, chann_str, true);
13971396
if(tx == NULL) {
@@ -1446,7 +1445,7 @@ static int profile_gen_config_get_from_device(struct adrv9002_config *cfg, gpoin
14461445
// radio_config.rx_config
14471446
rx_radio_channel_config rx_config[2];
14481447

1449-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1448+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
14501449
sprintf(chann_str, "voltage%d", chann);
14511450
struct iio_channel *rx = iio_device_find_channel(priv->adrv9002, chann_str, false);
14521451
if(rx == NULL) {
@@ -1671,7 +1670,7 @@ static int profile_gen_config_set_live_device(struct adrv9002_config *cfg, gpoin
16711670
gtk_combo_box_set_active_id(GTK_COMBO_BOX(gtk_builder_get_object(priv->builder, "cb_radio_duplex")), str_value);
16721671

16731672
// TX
1674-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1673+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
16751674
// channel_bandwidth_hz
16761675
sprintf(widget_str, "cb_tx_chan%d_bw", chann + 1);
16771676
sprintf(value, "%d", cfg->radio_cfg.tx_config[chann].channel_bandwidth_hz);
@@ -1702,7 +1701,7 @@ static int profile_gen_config_set_live_device(struct adrv9002_config *cfg, gpoin
17021701
}
17031702

17041703
// RX
1705-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1704+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
17061705
// channel_bandwidth_hz
17071706
sprintf(widget_str, "cb_rx_chan%d_bw", chann + 1);
17081707
sprintf(value, "%d", cfg->radio_cfg.rx_config[chann].channel_bandwidth_hz);
@@ -1798,7 +1797,7 @@ static int profile_gen_config_set_LTE(struct adrv9002_config *cfg, gpointer data
17981797

17991798
// sample_rate_hz
18001799
for(ch_type = 0; ch_type < ARRAY_SIZE(ch_types); ch_type++) {
1801-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1800+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
18021801
sprintf(widget_str, "cb_%s_chan%d_interface", ch_types[ch_type], chann + 1);
18031802
populate_combo_box(GTK_COMBO_BOX_TEXT(gtk_builder_get_object(priv->builder, widget_str)),
18041803
value_list, value_count, false, NULL);
@@ -1816,7 +1815,7 @@ static int profile_gen_config_set_LTE(struct adrv9002_config *cfg, gpointer data
18161815

18171816
// channel_bandwidth_hz
18181817
for(ch_type = 0; ch_type < ARRAY_SIZE(ch_types); ch_type++) {
1819-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1818+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
18201819
sprintf(widget_str, "cb_%s_chan%d_interface", ch_types[ch_type], chann + 1);
18211820
char *current_sample_rate = gtk_combo_box_text_get_active_text(
18221821
GTK_COMBO_BOX_TEXT(gtk_builder_get_object(priv->builder, widget_str)));
@@ -1870,7 +1869,7 @@ static int profile_gen_config_set_LTE(struct adrv9002_config *cfg, gpointer data
18701869

18711870
// RX and TX
18721871
for(ch_type = 0; ch_type < ARRAY_SIZE(ch_types); ch_type++) {
1873-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1872+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
18741873
// enabled
18751874
sprintf(widget_str, "cb_%s_chan%d_en", ch_types[ch_type], chann + 1);
18761875
if(reset_preset) {
@@ -1891,7 +1890,7 @@ static int profile_gen_config_set_LTE(struct adrv9002_config *cfg, gpointer data
18911890

18921891
// RX specific
18931892
// ft_port
1894-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1893+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
18951894
sprintf(widget_str, "cb_rx_chan%d_rf_port", chann + 1);
18961895
sprintf(value, "%d", cfg->radio_cfg.rx_config[chann].rf_port);
18971896
if(reset_preset) {
@@ -1971,7 +1970,7 @@ static int profile_gen_config_populate_from_ui(struct adrv9002_config *cfg, gpoi
19711970
atoi(gtk_combo_box_get_active_id(GTK_COMBO_BOX(gtk_builder_get_object(priv->builder, widget_str))));
19721971

19731972
// RX
1974-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1973+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
19751974
sprintf(widget_str, "cb_rx_chan%d_bw", chann + 1);
19761975
cfg->radio_cfg.rx_config[chann].channel_bandwidth_hz =
19771976
(uint32_t)atoi(gtk_combo_box_text_get_active_text(
@@ -1995,7 +1994,7 @@ static int profile_gen_config_populate_from_ui(struct adrv9002_config *cfg, gpoi
19951994
}
19961995

19971996
// TX
1998-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
1997+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
19991998
sprintf(widget_str, "cb_tx_chan%d_bw", chann + 1);
20001999
cfg->radio_cfg.tx_config[chann].channel_bandwidth_hz =
20012000
(uint32_t)atoi(gtk_combo_box_text_get_active_text(
@@ -2076,7 +2075,7 @@ static char *profile_gen_config_to_str(struct adrv9002_config *cfg)
20762075

20772076
// radio_cfg.rx_config
20782077
cJSON_AddItemToObject(radio_cfg, "rx_config", rx_config = cJSON_CreateArray());
2079-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
2078+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
20802079
cJSON_AddItemToArray(rx_config, tmp_object = cJSON_CreateObject());
20812080
cJSON_AddNumberToObject(tmp_object, "enabled", cfg->radio_cfg.rx_config[chann].enabled);
20822081
cJSON_AddNumberToObject(tmp_object, "adc_high_performance_mode",
@@ -2100,7 +2099,7 @@ static char *profile_gen_config_to_str(struct adrv9002_config *cfg)
21002099

21012100
// radio_cfg.tx_config
21022101
cJSON_AddItemToObject(radio_cfg, "tx_config", tx_config = cJSON_CreateArray());
2103-
for(chann = 0; chann < CHANNEL_COUNT; chann++) {
2102+
for(chann = 0; chann < ADRV9002_NUM_CHANNELS; chann++) {
21042103
cJSON_AddItemToArray(tx_config, tmp_object = cJSON_CreateObject());
21052104
cJSON_AddNumberToObject(tmp_object, "enabled", cfg->radio_cfg.tx_config[chann].enabled);
21062105
cJSON_AddNumberToObject(tmp_object, "sample_rate_hz", cfg->radio_cfg.tx_config[chann].sample_rate_hz);
@@ -2407,8 +2406,8 @@ static void profile_gen_update_channels(GtkComboBox *self, struct plugin_private
24072406
GtkWidget *channel_frame;
24082407
bool channel_en;
24092408
unsigned long i;
2410-
char *ch_frames[4] = {"frame_tx1_controls", "frame_tx2_controls", "frame_rx1_controls", "frame_rx2_controls"};
2411-
char *ch_buttons[4] = {"cb_tx_chan1_en", "cb_tx_chan2_en", "cb_rx_chan1_en", "cb_rx_chan2_en"};
2409+
char *ch_frames[] = {"frame_tx1_controls", "frame_tx2_controls", "frame_rx1_controls", "frame_rx2_controls"};
2410+
char *ch_buttons[] = {"cb_tx_chan1_en", "cb_tx_chan2_en", "cb_rx_chan1_en", "cb_rx_chan2_en"};
24122411

24132412
for (i = 0; i < ARRAY_SIZE(ch_frames); i++) {
24142413
channel_frame = GTK_WIDGET(gtk_builder_get_object(priv->builder, ch_frames[i]));

0 commit comments

Comments
 (0)