net: Replace min macro with min_t
Instead of an explicit cast, use the min_t macro. Signed-off-by: Silvan Jegen <s.jegen@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
9ffd2e9a17
commit
c8e4955653
|
@ -1549,7 +1549,7 @@ static void b43_write_beacon_template(struct b43_wldev *dev,
|
|||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(dev->wl->current_beacon);
|
||||
|
||||
bcn = (const struct ieee80211_mgmt *)(dev->wl->current_beacon->data);
|
||||
len = min((size_t) dev->wl->current_beacon->len,
|
||||
len = min_t(size_t, dev->wl->current_beacon->len,
|
||||
0x200 - sizeof(struct b43_plcp_hdr6));
|
||||
rate = ieee80211_get_tx_rate(dev->wl->hw, info)->hw_value;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static int get_integer(const char *buf, size_t count)
|
|||
|
||||
if (count == 0)
|
||||
goto out;
|
||||
count = min(count, (size_t) 10);
|
||||
count = min_t(size_t, count, 10);
|
||||
memcpy(tmp, buf, count);
|
||||
ret = simple_strtol(tmp, NULL, 10);
|
||||
out:
|
||||
|
|
|
@ -337,7 +337,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
|
|||
/* iv16 */
|
||||
memcpy(txhdr->iv + 10, ((u8 *) wlhdr) + wlhdr_len, 3);
|
||||
} else {
|
||||
iv_len = min((size_t) info->control.hw_key->iv_len,
|
||||
iv_len = min_t(size_t, info->control.hw_key->iv_len,
|
||||
ARRAY_SIZE(txhdr->iv));
|
||||
memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len);
|
||||
}
|
||||
|
|
|
@ -978,7 +978,7 @@ static void b43legacy_write_beacon_template(struct b43legacy_wldev *dev,
|
|||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(dev->wl->current_beacon);
|
||||
|
||||
bcn = (const struct ieee80211_mgmt *)(dev->wl->current_beacon->data);
|
||||
len = min((size_t)dev->wl->current_beacon->len,
|
||||
len = min_t(size_t, dev->wl->current_beacon->len,
|
||||
0x200 - sizeof(struct b43legacy_plcp_hdr6));
|
||||
rate = ieee80211_get_tx_rate(dev->wl->hw, info)->hw_value;
|
||||
|
||||
|
@ -1155,7 +1155,7 @@ static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev,
|
|||
b43legacy_write_probe_resp_plcp(dev, 0x350, size,
|
||||
&b43legacy_b_ratetable[3]);
|
||||
|
||||
size = min((size_t)size,
|
||||
size = min_t(size_t, size,
|
||||
0x200 - sizeof(struct b43legacy_plcp_hdr6));
|
||||
b43legacy_write_template_common(dev, probe_resp_data,
|
||||
size, ram_offset,
|
||||
|
|
|
@ -42,7 +42,7 @@ static int get_integer(const char *buf, size_t count)
|
|||
|
||||
if (count == 0)
|
||||
goto out;
|
||||
count = min(count, (size_t)10);
|
||||
count = min_t(size_t, count, 10);
|
||||
memcpy(tmp, buf, count);
|
||||
ret = simple_strtol(tmp, NULL, 10);
|
||||
out:
|
||||
|
|
|
@ -254,7 +254,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
|
|||
B43legacy_TX4_MAC_KEYALG_SHIFT) &
|
||||
B43legacy_TX4_MAC_KEYALG;
|
||||
wlhdr_len = ieee80211_hdrlen(wlhdr->frame_control);
|
||||
iv_len = min((size_t)info->control.hw_key->iv_len,
|
||||
iv_len = min_t(size_t, info->control.hw_key->iv_len,
|
||||
ARRAY_SIZE(txhdr->iv));
|
||||
memcpy(txhdr->iv, ((u8 *)wlhdr) + wlhdr_len, iv_len);
|
||||
} else {
|
||||
|
|
|
@ -202,8 +202,8 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
|
|||
}
|
||||
|
||||
/* calculate the block size */
|
||||
tx_size = block_size = min((size_t)(firmware->size - put),
|
||||
(size_t)DOWNLOAD_BLOCK_SIZE);
|
||||
tx_size = block_size = min_t(size_t, firmware->size - put,
|
||||
DOWNLOAD_BLOCK_SIZE);
|
||||
|
||||
memcpy(buf, &firmware->data[put], block_size);
|
||||
if (block_size < DOWNLOAD_BLOCK_SIZE) {
|
||||
|
|
|
@ -7065,7 +7065,7 @@ static int ipw2100_wx_set_nick(struct net_device *dev,
|
|||
if (wrqu->data.length > IW_ESSID_MAX_SIZE)
|
||||
return -E2BIG;
|
||||
|
||||
wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
|
||||
wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick));
|
||||
memset(priv->nick, 0, sizeof(priv->nick));
|
||||
memcpy(priv->nick, extra, wrqu->data.length);
|
||||
|
||||
|
|
|
@ -9169,7 +9169,7 @@ static int ipw_wx_set_nick(struct net_device *dev,
|
|||
if (wrqu->data.length > IW_ESSID_MAX_SIZE)
|
||||
return -E2BIG;
|
||||
mutex_lock(&priv->mutex);
|
||||
wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
|
||||
wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick));
|
||||
memset(priv->nick, 0, sizeof(priv->nick));
|
||||
memcpy(priv->nick, extra, wrqu->data.length);
|
||||
IPW_DEBUG_TRACE("<<\n");
|
||||
|
|
|
@ -498,7 +498,7 @@ static int if_sdio_prog_helper(struct if_sdio_card *card,
|
|||
*/
|
||||
mdelay(2);
|
||||
|
||||
chunk_size = min(size, (size_t)60);
|
||||
chunk_size = min_t(size_t, size, 60);
|
||||
|
||||
*((__le32*)chunk_buffer) = cpu_to_le32(chunk_size);
|
||||
memcpy(chunk_buffer + 4, firmware, chunk_size);
|
||||
|
@ -639,7 +639,7 @@ static int if_sdio_prog_real(struct if_sdio_card *card,
|
|||
req_size = size;
|
||||
|
||||
while (req_size) {
|
||||
chunk_size = min(req_size, (size_t)512);
|
||||
chunk_size = min_t(size_t, req_size, 512);
|
||||
|
||||
memcpy(chunk_buffer, firmware, chunk_size);
|
||||
/*
|
||||
|
|
|
@ -493,7 +493,7 @@ mwifiex_regrdwr_write(struct file *file,
|
|||
{
|
||||
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
||||
char *buf = (char *) addr;
|
||||
size_t buf_size = min(count, (size_t) (PAGE_SIZE - 1));
|
||||
size_t buf_size = min_t(size_t, count, PAGE_SIZE - 1);
|
||||
int ret;
|
||||
u32 reg_type = 0, reg_offset = 0, reg_value = UINT_MAX;
|
||||
|
||||
|
@ -594,7 +594,7 @@ mwifiex_rdeeprom_write(struct file *file,
|
|||
{
|
||||
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
||||
char *buf = (char *) addr;
|
||||
size_t buf_size = min(count, (size_t) (PAGE_SIZE - 1));
|
||||
size_t buf_size = min_t(size_t, count, PAGE_SIZE - 1);
|
||||
int ret = 0;
|
||||
int offset = -1, bytes = -1;
|
||||
|
||||
|
|
|
@ -513,7 +513,7 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
|
|||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
left = block_size = min((size_t)P54U_FW_BLOCK, priv->fw->size);
|
||||
left = block_size = min_t(size_t, P54U_FW_BLOCK, priv->fw->size);
|
||||
strcpy(buf, p54u_firmware_upload_3887);
|
||||
left -= strlen(p54u_firmware_upload_3887);
|
||||
tmp += strlen(p54u_firmware_upload_3887);
|
||||
|
|
|
@ -644,7 +644,7 @@ prism54_translate_bss(struct net_device *ndev, struct iw_request_info *info,
|
|||
wpa_ie_len = prism54_wpa_bss_ie_get(priv, bss->address, wpa_ie);
|
||||
if (wpa_ie_len > 0) {
|
||||
iwe.cmd = IWEVGENIE;
|
||||
iwe.u.data.length = min(wpa_ie_len, (size_t)MAX_WPA_IE_LEN);
|
||||
iwe.u.data.length = min_t(size_t, wpa_ie_len, MAX_WPA_IE_LEN);
|
||||
current_ev = iwe_stream_add_point(info, current_ev, end_buf,
|
||||
&iwe, wpa_ie);
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ static ssize_t rt2x00debug_read_queue_dump(struct file *file,
|
|||
if (retval)
|
||||
return retval;
|
||||
|
||||
status = min((size_t)skb->len, length);
|
||||
status = min_t(size_t, skb->len, length);
|
||||
if (copy_to_user(buf, skb->data, status)) {
|
||||
status = -EFAULT;
|
||||
goto exit;
|
||||
|
|
|
@ -800,7 +800,7 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen)
|
|||
size_t len;
|
||||
|
||||
/* Make sure we have enough room */
|
||||
len = min(maxlen, (size_t)(PAGE_SIZE - wl->fwlog_size));
|
||||
len = min_t(size_t, maxlen, PAGE_SIZE - wl->fwlog_size);
|
||||
|
||||
/* Fill the FW log file, consumed by the sysfs fwlog entry */
|
||||
memcpy(wl->fwlog + wl->fwlog_size, memblock, len);
|
||||
|
|
|
@ -211,7 +211,7 @@ static int __must_check wl12xx_spi_raw_read(struct device *child, int addr,
|
|||
u32 chunk_len;
|
||||
|
||||
while (len > 0) {
|
||||
chunk_len = min((size_t)WSPI_MAX_CHUNK_SIZE, len);
|
||||
chunk_len = min_t(size_t, WSPI_MAX_CHUNK_SIZE, len);
|
||||
|
||||
cmd = &wl->buffer_cmd;
|
||||
busy_buf = wl->buffer_busyword;
|
||||
|
@ -285,7 +285,7 @@ static int __must_check wl12xx_spi_raw_write(struct device *child, int addr,
|
|||
cmd = &commands[0];
|
||||
i = 0;
|
||||
while (len > 0) {
|
||||
chunk_len = min((size_t)WSPI_MAX_CHUNK_SIZE, len);
|
||||
chunk_len = min_t(size_t, WSPI_MAX_CHUNK_SIZE, len);
|
||||
|
||||
*cmd = 0;
|
||||
*cmd |= WSPI_CMD_WRITE;
|
||||
|
|
|
@ -152,7 +152,7 @@ static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj,
|
|||
}
|
||||
|
||||
/* Seeking is not supported - old logs are not kept. Disregard pos. */
|
||||
len = min(count, (size_t)wl->fwlog_size);
|
||||
len = min_t(size_t, count, wl->fwlog_size);
|
||||
wl->fwlog_size -= len;
|
||||
memcpy(buffer, wl->fwlog, len);
|
||||
|
||||
|
|
Loading…
Reference in New Issue