mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
![Joe Perches](/assets/img/avatar_default.png)
Adding casts of objects to the same type is unnecessary and confusing for a human reader. For example, this cast: int y; int *p = (int *)&y; I used the coccinelle script below to find and remove these unnecessary casts. I manually removed the conversions this script produces of casts with __force, __iomem and __user. @@ type T; T *p; @@ - (T *)p + p A function in atl1e_main.c was passed a const pointer when it actually modified elements of the structure. Change the argument to a non-const pointer. A function in stmmac needed a __force to avoid a sparse warning. Added it. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
93 lines
2.1 KiB
C
93 lines
2.1 KiB
C
/*
|
|
* Linux network driver for Brocade Converged Network Adapter.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License (GPL) Version 2 as
|
|
* published by the Free Software Foundation
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*/
|
|
/*
|
|
* Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
|
|
* All rights reserved
|
|
* www.brocade.com
|
|
*/
|
|
#include <linux/firmware.h>
|
|
#include "bnad.h"
|
|
#include "bfi.h"
|
|
#include "cna.h"
|
|
|
|
const struct firmware *bfi_fw;
|
|
static u32 *bfi_image_ct_cna, *bfi_image_ct2_cna;
|
|
static u32 bfi_image_ct_cna_size, bfi_image_ct2_cna_size;
|
|
|
|
static u32 *
|
|
cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
|
|
u32 *bfi_image_size, char *fw_name)
|
|
{
|
|
const struct firmware *fw;
|
|
|
|
if (request_firmware(&fw, fw_name, &pdev->dev)) {
|
|
pr_alert("Can't locate firmware %s\n", fw_name);
|
|
goto error;
|
|
}
|
|
|
|
*bfi_image = (u32 *)fw->data;
|
|
*bfi_image_size = fw->size/sizeof(u32);
|
|
bfi_fw = fw;
|
|
|
|
return *bfi_image;
|
|
error:
|
|
return NULL;
|
|
}
|
|
|
|
u32 *
|
|
cna_get_firmware_buf(struct pci_dev *pdev)
|
|
{
|
|
if (pdev->device == BFA_PCI_DEVICE_ID_CT2) {
|
|
if (bfi_image_ct2_cna_size == 0)
|
|
cna_read_firmware(pdev, &bfi_image_ct2_cna,
|
|
&bfi_image_ct2_cna_size, CNA_FW_FILE_CT2);
|
|
return bfi_image_ct2_cna;
|
|
} else if (bfa_asic_id_ct(pdev->device)) {
|
|
if (bfi_image_ct_cna_size == 0)
|
|
cna_read_firmware(pdev, &bfi_image_ct_cna,
|
|
&bfi_image_ct_cna_size, CNA_FW_FILE_CT);
|
|
return bfi_image_ct_cna;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
u32 *
|
|
bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off)
|
|
{
|
|
switch (asic_gen) {
|
|
case BFI_ASIC_GEN_CT:
|
|
return (bfi_image_ct_cna + off);
|
|
break;
|
|
case BFI_ASIC_GEN_CT2:
|
|
return (bfi_image_ct2_cna + off);
|
|
break;
|
|
default:
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
u32
|
|
bfa_cb_image_get_size(enum bfi_asic_gen asic_gen)
|
|
{
|
|
switch (asic_gen) {
|
|
case BFI_ASIC_GEN_CT:
|
|
return bfi_image_ct_cna_size;
|
|
break;
|
|
case BFI_ASIC_GEN_CT2:
|
|
return bfi_image_ct2_cna_size;
|
|
break;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|