Commit 63aac5db authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman
Browse files

staging: wfx: avoid c99 comments



The wfx driver is a network driver. C99 comments are prohibited in this
part of the kernel.

Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20210913130203.1903622-28-Jerome.Pouiller@silabs.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9885474d
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -32,18 +32,20 @@ static void device_wakeup(struct wfx_dev *wdev)
	}
	for (;;) {
		gpiod_set_value_cansleep(wdev->pdata.gpio_wakeup, 1);
		// completion.h does not provide any function to wait
		// completion without consume it (a kind of
		// wait_for_completion_done_timeout()). So we have to emulate
		// it.
		/* completion.h does not provide any function to wait
		 * completion without consume it (a kind of
		 * wait_for_completion_done_timeout()). So we have to emulate
		 * it.
		 */
		if (wait_for_completion_timeout(&wdev->hif.ctrl_ready,
						msecs_to_jiffies(2))) {
			complete(&wdev->hif.ctrl_ready);
			return;
		} else if (max_retry-- > 0) {
			// Older firmwares have a race in sleep/wake-up process.
			// Redo the process is sufficient to unfreeze the
			// chip.
			/* Older firmwares have a race in sleep/wake-up process.
			 * Redo the process is sufficient to unfreeze the
			 * chip.
			 */
			dev_err(wdev->dev, "timeout while wake up chip\n");
			gpiod_set_value_cansleep(wdev->pdata.gpio_wakeup, 0);
			usleep_range(2000, 2500);
@@ -74,7 +76,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)
	WARN(read_len > round_down(0xFFF, 2) * sizeof(u16),
	     "%s: request exceed the chip capability", __func__);

	// Add 2 to take into account piggyback size
	/* Add 2 to take into account piggyback size */
	alloc_len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, read_len + 2);
	skb = dev_alloc_skb(alloc_len);
	if (!skb)
@@ -119,7 +121,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)
	}

	skb_put(skb, le16_to_cpu(hif->len));
	// wfx_handle_rx takes care on SKB livetime
	/* wfx_handle_rx takes care on SKB livetime */
	wfx_handle_rx(wdev, skb);
	if (!wdev->hif.tx_buffers_used)
		wake_up(&wdev->hif.tx_buffers_empty);
@@ -148,7 +150,7 @@ static int bh_work_rx(struct wfx_dev *wdev, int max_msg, int *num_cnf)
			ctrl_reg = 0;
		if (!(ctrl_reg & CTRL_NEXT_LEN_MASK))
			return i;
		// ctrl_reg units are 16bits words
		/* ctrl_reg units are 16bits words */
		len = (ctrl_reg & CTRL_NEXT_LEN_MASK) * 2;
		piggyback = rx_helper(wdev, len, num_cnf);
		if (piggyback < 0)
+4 −4
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id,
	/* Use queue mode buffers */
	if (reg_id == WFX_REG_IN_OUT_QUEUE)
		sdio_addr |= bus->buf_id_tx << 7;
	// FIXME: discards 'const' qualifier for src
	/* FIXME: discards 'const' qualifier for src */
	ret = sdio_memcpy_toio(bus->func, sdio_addr, (void *)src, count);
	if (!ret && reg_id == WFX_REG_IN_OUT_QUEUE)
		bus->buf_id_tx = (bus->buf_id_tx + 1) % 32;
@@ -198,7 +198,7 @@ static int wfx_sdio_probe(struct sdio_func *func,
	} else {
		dev_warn(&func->dev,
			 "device is not declared in DT, features will be limited\n");
		// FIXME: ignore VID/PID and only rely on device tree
		/* FIXME: ignore VID/PID and only rely on device tree */
		// return -ENODEV;
	}

@@ -210,7 +210,7 @@ static int wfx_sdio_probe(struct sdio_func *func,

	sdio_claim_host(func);
	ret = sdio_enable_func(func);
	// Block of 64 bytes is more efficient than 512B for frame sizes < 4k
	/* Block of 64 bytes is more efficient than 512B for frame sizes < 4k */
	sdio_set_block_size(func, 64);
	sdio_release_host(func);
	if (ret)
@@ -251,7 +251,7 @@ static void wfx_sdio_remove(struct sdio_func *func)
#define SDIO_DEVICE_ID_SILABS_WF200  0x1000
static const struct sdio_device_id wfx_sdio_ids[] = {
	{ SDIO_DEVICE(SDIO_VENDOR_ID_SILABS, SDIO_DEVICE_ID_SILABS_WF200) },
	// FIXME: ignore VID/PID and only rely on device tree
	/* FIXME: ignore VID/PID and only rely on device tree */
	// { SDIO_DEVICE(SDIO_ANY_ID, SDIO_ANY_ID) },
	{ },
};
+7 −5
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ static int wfx_spi_copy_to_io(void *priv, unsigned int addr,
{
	struct wfx_spi_priv *bus = priv;
	u16 regaddr = (addr << 12) | (count / 2);
	// FIXME: use a bounce buffer
	/* FIXME: use a bounce buffer */
	u16 *src16 = (void *)src;
	int ret, i;
	struct spi_message      m;
@@ -104,8 +104,9 @@ static int wfx_spi_copy_to_io(void *priv, unsigned int addr,

	cpu_to_le16s(&regaddr);

	// Register address and CONFIG content always use 16bit big endian
	// ("BADC" order)
	/* Register address and CONFIG content always use 16bit big endian
	 * ("BADC" order)
	 */
	if (bus->need_swab)
		swab16s(&regaddr);
	if (bus->need_swab && addr == WFX_REG_CONFIG)
@@ -163,7 +164,8 @@ static int wfx_spi_irq_unsubscribe(void *priv)

static size_t wfx_spi_align_size(void *priv, size_t size)
{
	// Most of SPI controllers avoid DMA if buffer size is not 32bit aligned
	/* Most of SPI controllers avoid DMA if buffer size is not 32bit aligned
	 */
	return ALIGN(size, 4);
}

@@ -187,7 +189,7 @@ static int wfx_spi_probe(struct spi_device *func)
	ret = spi_setup(func);
	if (ret)
		return ret;
	// Trace below is also displayed by spi_setup() if compiled with DEBUG
	/* Trace below is also displayed by spi_setup() if compiled with DEBUG */
	dev_dbg(&func->dev, "SPI params: CS=%d, mode=%d bits/word=%d speed=%d\n",
		func->chip_select, func->mode, func->bits_per_word,
		func->max_speed_hz);
+3 −2
Original line number Diff line number Diff line
@@ -76,8 +76,9 @@ void wfx_rx_cb(struct wfx_vif *wvif,
	if (arg->encryp)
		hdr->flag |= RX_FLAG_DECRYPTED;

	// Block ack negotiation is offloaded by the firmware. However,
	// re-ordering must be done by the mac80211.
	/* Block ack negotiation is offloaded by the firmware. However,
	 * re-ordering must be done by the mac80211.
	 */
	if (ieee80211_is_action(frame->frame_control) &&
	    mgmt->u.action.category == WLAN_CATEGORY_BACK &&
	    skb->len > IEEE80211_MIN_ACTION_SIZE) {
+30 −26
Original line number Diff line number Diff line
@@ -31,8 +31,9 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
		}
		return rate->idx + 14;
	}
	// The device only support 2GHz, else band information should be
	// retrieved from ieee80211_tx_info
	/* The device only support 2GHz, else band information should be
	 * retrieved from ieee80211_tx_info
	 */
	band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
	if (rate->idx >= band->n_bitrates) {
		WARN(1, "wrong rate->idx value: %d", rate->idx);
@@ -57,7 +58,7 @@ static void wfx_tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy,
			break;
		WARN_ON(rates[i].count > 15);
		rateid = wfx_get_hw_rate(wdev, &rates[i]);
		// Pack two values in each byte of policy->rates
		/* Pack two values in each byte of policy->rates */
		count = rates[i].count;
		if (rateid % 2)
			count <<= 4;
@@ -238,7 +239,7 @@ static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates)
	int i;
	bool finished;

	// Firmware is not able to mix rates with different flags
	/* Firmware is not able to mix rates with different flags */
	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
		if (rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
			rates[i].flags |= IEEE80211_TX_RC_SHORT_GI;
@@ -248,7 +249,7 @@ static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates)
			rates[i].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS;
	}

	// Sort rates and remove duplicates
	/* Sort rates and remove duplicates */
	do {
		finished = true;
		for (i = 0; i < IEEE80211_TX_MAX_RATES - 1; i++) {
@@ -268,19 +269,19 @@ static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates)
			}
		}
	} while (!finished);
	// Ensure that MCS0 or 1Mbps is present at the end of the retry list
	/* Ensure that MCS0 or 1Mbps is present at the end of the retry list */
	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
		if (rates[i].idx == 0)
			break;
		if (rates[i].idx == -1) {
			rates[i].idx = 0;
			rates[i].count = 8; // == hw->max_rate_tries
			rates[i].count = 8; /* == hw->max_rate_tries */
			rates[i].flags = rates[i - 1].flags &
					 IEEE80211_TX_RC_MCS;
			break;
		}
	}
	// All retries use long GI
	/* All retries use long GI */
	for (i = 1; i < IEEE80211_TX_MAX_RATES; i++)
		rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI;
}
@@ -342,13 +343,13 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta,
	WARN(queue_id >= IEEE80211_NUM_ACS, "unsupported queue_id");
	wfx_tx_fixup_rates(tx_info->driver_rates);

	// From now tx_info->control is unusable
	/* From now tx_info->control is unusable */
	memset(tx_info->rate_driver_data, 0, sizeof(struct wfx_tx_priv));
	// Fill tx_priv
	/* Fill tx_priv */
	tx_priv = (struct wfx_tx_priv *)tx_info->rate_driver_data;
	tx_priv->icv_size = wfx_tx_get_icv_len(hw_key);

	// Fill hif_msg
	/* Fill hif_msg */
	WARN(skb_headroom(skb) < wmsg_len, "not enough space in skb");
	WARN(offset & 1, "attempt to transmit an unaligned frame");
	skb_put(skb, tx_priv->icv_size);
@@ -366,17 +367,18 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta,
		return -EIO;
	}

	// Fill tx request
	/* Fill tx request */
	req = (struct hif_req_tx *)hif_msg->body;
	// packet_id just need to be unique on device. 32bits are more than
	// necessary for that task, so we tae advantage of it to add some extra
	// data for debug.
	/* packet_id just need to be unique on device. 32bits are more than
	 * necessary for that task, so we tae advantage of it to add some extra
	 * data for debug.
	 */
	req->packet_id = atomic_add_return(1, &wvif->wdev->packet_id) & 0xFFFF;
	req->packet_id |= IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)) << 16;
	req->packet_id |= queue_id << 28;

	req->fc_offset = offset;
	// Queue index are inverted between firmware and Linux
	/* Queue index are inverted between firmware and Linux */
	req->queue_id = 3 - queue_id;
	req->peer_sta_id = wfx_tx_get_link_id(wvif, sta, hdr);
	req->retry_policy_index = wfx_tx_get_retry_policy_id(wvif, tx_info);
@@ -386,7 +388,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta,
	if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM)
		req->after_dtim = 1;

	// Auxiliary operations
	/* Auxiliary operations */
	wfx_tx_queues_put(wvif, skb);
	if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM)
		schedule_work(&wvif->update_tim_work);
@@ -408,15 +410,16 @@ void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
	compiletime_assert(sizeof(struct wfx_tx_priv) <= driver_data_room,
			   "struct tx_priv is too large");
	WARN(skb->next || skb->prev, "skb is already member of a list");
	// control.vif can be NULL for injected frames
	/* control.vif can be NULL for injected frames */
	if (tx_info->control.vif)
		wvif = (struct wfx_vif *)tx_info->control.vif->drv_priv;
	else
		wvif = wvif_iterate(wdev, NULL);
	if (WARN_ON(!wvif))
		goto drop;
	// Because of TX_AMPDU_SETUP_IN_HW, mac80211 does not try to send any
	// BlockAck session management frame. The check below exist just in case.
	/* Because of TX_AMPDU_SETUP_IN_HW, mac80211 does not try to send any
	 * BlockAck session management frame. The check below exist just in case.
	 */
	if (ieee80211_is_action_back(hdr)) {
		dev_info(wdev->dev, "drop BA action\n");
		goto drop;
@@ -457,7 +460,7 @@ static void wfx_tx_fill_rates(struct wfx_dev *wdev,

	tx_count = arg->ack_failures;
	if (!arg->status || arg->ack_failures)
		tx_count += 1; // Also report success
		tx_count += 1; /* Also report success */
	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
		rate = &tx_info->status.rates[i];
		if (rate->idx < 0)
@@ -505,14 +508,15 @@ void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg)
	if (!wvif)
		return;

	// Note that wfx_pending_get_pkt_us_delay() get data from tx_info
	/* Note that wfx_pending_get_pkt_us_delay() get data from tx_info */
	_trace_tx_stats(arg, skb, wfx_pending_get_pkt_us_delay(wdev, skb));
	wfx_tx_fill_rates(wdev, tx_info, arg);
	skb_trim(skb, skb->len - tx_priv->icv_size);

	// From now, you can touch to tx_info->status, but do not touch to
	// tx_priv anymore
	// FIXME: use ieee80211_tx_info_clear_status()
	/* From now, you can touch to tx_info->status, but do not touch to
	 * tx_priv anymore
	 */
	/* FIXME: use ieee80211_tx_info_clear_status() */
	memset(tx_info->rate_driver_data, 0, sizeof(tx_info->rate_driver_data));
	memset(tx_info->pad, 0, sizeof(tx_info->pad));

@@ -527,7 +531,7 @@ void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg)
	} else if (arg->status == HIF_STATUS_TX_FAIL_REQUEUE) {
		WARN(!arg->requeue, "incoherent status and result_flags");
		if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
			wvif->after_dtim_tx_allowed = false; // DTIM period elapsed
			wvif->after_dtim_tx_allowed = false; /* DTIM period elapsed */
			schedule_work(&wvif->update_tim_work);
		}
		tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
Loading