Skip to content

Commit 7d1f802

Browse files
committed
wilc1000: move setting of tx_power WID to work queue
Handling passing of tx_pwer WID from work queue. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
1 parent d1606c2 commit 7d1f802

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

  • drivers/net/wireless/microchip/wilc1000

drivers/net/wireless/microchip/wilc1000/hif.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ struct host_if_set_ant {
6565
u8 gpio_mode;
6666
};
6767

68+
struct tx_power {
69+
u8 tx_pwr;
70+
};
71+
6872
struct power_mgmt_param {
6973
bool enabled;
7074
u32 timeout;
@@ -84,6 +88,7 @@ union wilc_message_body {
8488
struct host_if_wowlan_trigger wow_trigger;
8589
struct send_buffered_eap send_buff_eap;
8690
struct host_if_set_ant set_ant;
91+
struct tx_power tx_power;
8792
struct power_mgmt_param pwr_mgmt_info;
8893
};
8994

@@ -2439,16 +2444,46 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
24392444
return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
24402445
}
24412446

2442-
int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
2447+
static void handle_get_tx_pwr(struct work_struct *work)
24432448
{
2449+
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
2450+
struct wilc_vif *vif = msg->vif;
2451+
u8 *tx_pwr = &msg->body.tx_power.tx_pwr;
2452+
int ret;
24442453
struct wid wid;
24452454

24462455
wid.id = WID_TX_POWER;
24472456
wid.type = WID_CHAR;
2448-
wid.val = tx_power;
2457+
wid.val = tx_pwr;
24492458
wid.size = sizeof(char);
24502459

2451-
return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
2460+
ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
2461+
if (ret)
2462+
PRINT_ER(vif->ndev, "Failed to get TX PWR\n");
2463+
2464+
complete(&msg->work_comp);
2465+
}
2466+
2467+
int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
2468+
{
2469+
int ret;
2470+
struct host_if_msg *msg;
2471+
2472+
msg = wilc_alloc_work(vif, handle_get_tx_pwr, true);
2473+
if (IS_ERR(msg))
2474+
return PTR_ERR(msg);
2475+
2476+
ret = wilc_enqueue_work(msg);
2477+
if (ret) {
2478+
PRINT_ER(vif->ndev, "enqueue work failed\n");
2479+
} else {
2480+
wait_for_completion(&msg->work_comp);
2481+
*tx_power = msg->body.tx_power.tx_pwr;
2482+
}
2483+
2484+
/* free 'msg' after copying data */
2485+
kfree(msg);
2486+
return ret;
24522487
}
24532488

24542489
static bool is_valid_gpio(struct wilc_vif *vif, u8 gpio)

0 commit comments

Comments
 (0)