Skip to content

Commit 406b947

Browse files
committed
More pointers to state
1 parent 53b01d8 commit 406b947

File tree

7 files changed

+127
-125
lines changed

7 files changed

+127
-125
lines changed

rigs/dorji/dra818.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void dra818_subaudio(RIG *rig, char *subaudio, int subaudio_len,
100100

101101
static int dra818_setgroup(RIG *rig)
102102
{
103-
const struct dra818_priv *priv = rig->state.priv;
103+
const struct dra818_priv *priv = STATE(rig)->priv;
104104
char cmd[80];
105105
char subtx[8] = { 0 };
106106
char subrx[8] = { 0 };
@@ -121,7 +121,7 @@ static int dra818_setgroup(RIG *rig)
121121

122122
static int dra818_setvolume(RIG *rig)
123123
{
124-
const struct dra818_priv *priv = rig->state.priv;
124+
const struct dra818_priv *priv = STATE(rig)->priv;
125125
char cmd[80];
126126

127127
SNPRINTF(cmd, sizeof(cmd), "AT+DMOSETVOLUME=%1d\r\n", priv->vol);
@@ -136,14 +136,14 @@ int dra818_init(RIG *rig)
136136

137137
rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_init called\n", __func__);
138138

139-
rig->state.priv = calloc(sizeof(*priv), 1);
139+
STATE(rig)->priv = calloc(sizeof(*priv), 1);
140140

141-
if (!rig->state.priv)
141+
if (!STATE(rig)->priv)
142142
{
143143
return -RIG_ENOMEM;
144144
}
145145

146-
priv = rig->state.priv;
146+
priv = STATE(rig)->priv;
147147

148148
switch (rig->caps->rig_model)
149149
{
@@ -174,7 +174,7 @@ int dra818_cleanup(RIG *rig)
174174
{
175175
rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_cleanup called\n", __func__);
176176

177-
free(rig->state.priv);
177+
free(STATE(rig)->priv);
178178

179179
return RIG_OK;
180180
}
@@ -214,7 +214,7 @@ int dra818_open(RIG *rig)
214214

215215
int dra818_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
216216
{
217-
struct dra818_priv *priv = rig->state.priv;
217+
struct dra818_priv *priv = STATE(rig)->priv;
218218

219219
/* Nearest channel */
220220
shortfreq_t sfreq = ((freq + priv->bw / 2) / priv->bw);
@@ -252,7 +252,7 @@ int dra818_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
252252

253253
int dra818_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
254254
{
255-
struct dra818_priv *priv = rig->state.priv;
255+
struct dra818_priv *priv = STATE(rig)->priv;
256256

257257
if (width > 12500)
258258
{
@@ -270,7 +270,7 @@ int dra818_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
270270

271271
int dra818_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
272272
{
273-
const struct dra818_priv *priv = rig->state.priv;
273+
const struct dra818_priv *priv = STATE(rig)->priv;
274274

275275
*mode = RIG_MODE_FM;
276276
*width = priv->bw;
@@ -280,7 +280,7 @@ int dra818_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
280280

281281
int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
282282
{
283-
const struct dra818_priv *priv = rig->state.priv;
283+
const struct dra818_priv *priv = STATE(rig)->priv;
284284
hamlib_port_t *rp = RIGPORT(rig);
285285
char cmd[80];
286286
char response[8];
@@ -313,7 +313,7 @@ int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
313313

314314
int dra818_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
315315
{
316-
const struct dra818_priv *priv = rig->state.priv;
316+
const struct dra818_priv *priv = STATE(rig)->priv;
317317

318318
switch (vfo)
319319
{
@@ -334,7 +334,7 @@ int dra818_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
334334

335335
int dra818_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
336336
{
337-
struct dra818_priv *priv = rig->state.priv;
337+
struct dra818_priv *priv = STATE(rig)->priv;
338338

339339
priv->split = split;
340340

@@ -348,7 +348,7 @@ int dra818_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
348348

349349
int dra818_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
350350
{
351-
const struct dra818_priv *priv = rig->state.priv;
351+
const struct dra818_priv *priv = STATE(rig)->priv;
352352

353353
*split = priv->split;
354354

@@ -366,7 +366,7 @@ int dra818_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
366366

367367
int dra818_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
368368
{
369-
const struct dra818_priv *priv = rig->state.priv;
369+
const struct dra818_priv *priv = STATE(rig)->priv;
370370

371371
switch (level)
372372
{
@@ -389,7 +389,7 @@ int dra818_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
389389

390390
int dra818_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
391391
{
392-
struct dra818_priv *priv = rig->state.priv;
392+
struct dra818_priv *priv = STATE(rig)->priv;
393393

394394
switch (level)
395395
{
@@ -434,7 +434,7 @@ int dra818_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
434434

435435
int dra818_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
436436
{
437-
struct dra818_priv *priv = rig->state.priv;
437+
struct dra818_priv *priv = STATE(rig)->priv;
438438

439439
priv->dcs_code = code;
440440

@@ -448,7 +448,7 @@ int dra818_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
448448

449449
int dra818_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
450450
{
451-
struct dra818_priv *priv = rig->state.priv;
451+
struct dra818_priv *priv = STATE(rig)->priv;
452452

453453
priv->ctcss_tone = tone;
454454

@@ -462,7 +462,7 @@ int dra818_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
462462

463463
int dra818_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
464464
{
465-
struct dra818_priv *priv = rig->state.priv;
465+
struct dra818_priv *priv = STATE(rig)->priv;
466466

467467
priv->dcs_sql = code;
468468

@@ -476,7 +476,7 @@ int dra818_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
476476

477477
int dra818_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
478478
{
479-
struct dra818_priv *priv = rig->state.priv;
479+
struct dra818_priv *priv = STATE(rig)->priv;
480480

481481
priv->ctcss_sql = tone;
482482

@@ -490,31 +490,31 @@ int dra818_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
490490

491491
int dra818_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
492492
{
493-
const struct dra818_priv *priv = rig->state.priv;
493+
const struct dra818_priv *priv = STATE(rig)->priv;
494494

495495
*tone = priv->ctcss_sql;
496496
return RIG_OK;
497497
}
498498

499499
int dra818_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
500500
{
501-
const struct dra818_priv *priv = rig->state.priv;
501+
const struct dra818_priv *priv = STATE(rig)->priv;
502502

503503
*code = priv->dcs_sql;
504504
return RIG_OK;
505505
}
506506

507507
int dra818_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
508508
{
509-
const struct dra818_priv *priv = rig->state.priv;
509+
const struct dra818_priv *priv = STATE(rig)->priv;
510510

511511
*code = priv->dcs_code;
512512
return RIG_OK;
513513
}
514514

515515
int dra818_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
516516
{
517-
const struct dra818_priv *priv = rig->state.priv;
517+
const struct dra818_priv *priv = STATE(rig)->priv;
518518

519519
*tone = priv->ctcss_tone;
520520
return RIG_OK;

rigs/drake/drake.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
9797
int drake_init(RIG *rig)
9898
{
9999
struct drake_priv_data *priv;
100-
rig->state.priv = calloc(1, sizeof(struct drake_priv_data));
100+
STATE(rig)->priv = calloc(1, sizeof(struct drake_priv_data));
101101

102-
if (!rig->state.priv)
102+
if (!STATE(rig)->priv)
103103
{
104104
return -RIG_ENOMEM;
105105
}
106106

107-
priv = rig->state.priv;
107+
priv = STATE(rig)->priv;
108108

109109
priv->curr_ch = 0;
110110

@@ -113,7 +113,7 @@ int drake_init(RIG *rig)
113113

114114
int drake_cleanup(RIG *rig)
115115
{
116-
struct drake_priv_data *priv = rig->state.priv;
116+
struct drake_priv_data *priv = STATE(rig)->priv;
117117

118118
free(priv);
119119

@@ -552,7 +552,7 @@ int drake_set_mem(RIG *rig, vfo_t vfo, int ch)
552552
{
553553
int ack_len, retval;
554554
char buf[16], ackbuf[16];
555-
struct drake_priv_data *priv = rig->state.priv;
555+
struct drake_priv_data *priv = STATE(rig)->priv;
556556

557557
priv->curr_ch = ch;
558558

@@ -576,7 +576,7 @@ int drake_set_mem(RIG *rig, vfo_t vfo, int ch)
576576
*/
577577
int drake_get_mem(RIG *rig, vfo_t vfo, int *ch)
578578
{
579-
struct drake_priv_data *priv = rig->state.priv;
579+
struct drake_priv_data *priv = STATE(rig)->priv;
580580
int mdbuf_len, retval;
581581
char mdbuf[BUFSZ];
582582
int chan;
@@ -612,7 +612,7 @@ int drake_get_mem(RIG *rig, vfo_t vfo, int *ch)
612612
*/
613613
int drake_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan)
614614
{
615-
const struct drake_priv_data *priv = rig->state.priv;
615+
const struct drake_priv_data *priv = STATE(rig)->priv;
616616
vfo_t old_vfo;
617617
int old_chan;
618618
char mdbuf[16], ackbuf[16];
@@ -668,7 +668,7 @@ int drake_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan)
668668
*/
669669
int drake_get_chan(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
670670
{
671-
const struct drake_priv_data *priv = rig->state.priv;
671+
const struct drake_priv_data *priv = STATE(rig)->priv;
672672
vfo_t old_vfo;
673673
int old_chan;
674674
char mdbuf[BUFSZ], freqstr[BUFSZ];
@@ -880,7 +880,7 @@ int drake_get_chan(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
880880
*/
881881
int drake_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
882882
{
883-
const struct drake_priv_data *priv = rig->state.priv;
883+
const struct drake_priv_data *priv = STATE(rig)->priv;
884884
char buf[16], ackbuf[16];
885885
int len, ack_len, retval;
886886

0 commit comments

Comments
 (0)