mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
Staging: rt3070: remove dead BIN_IN_FILE code
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
7baea26a2d
commit
55468fae98
@ -40,8 +40,6 @@
|
||||
#include "../rt_config.h"
|
||||
#include "../firmware.h"
|
||||
|
||||
//#define BIN_IN_FILE /* use *.bin firmware */
|
||||
|
||||
UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
|
||||
ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008,
|
||||
0x00000010, 0x00000020, 0x00000040, 0x00000080,
|
||||
@ -2927,207 +2925,6 @@ VOID NICEraseFirmware(
|
||||
NDIS_STATUS NICLoadFirmware(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
#ifdef BIN_IN_FILE
|
||||
#define NICLF_DEFAULT_USE() \
|
||||
flg_default_firm_use = TRUE; \
|
||||
printk("%s - Use default firmware!\n", __func__);
|
||||
|
||||
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
|
||||
PUCHAR src;
|
||||
struct file *srcf;
|
||||
INT retval, orgfsuid, orgfsgid, i;
|
||||
mm_segment_t orgfs;
|
||||
PUCHAR pFirmwareImage;
|
||||
UINT FileLength = 0;
|
||||
UINT32 MacReg;
|
||||
ULONG Index;
|
||||
ULONG firm;
|
||||
BOOLEAN flg_default_firm_use = FALSE;
|
||||
|
||||
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __func__));
|
||||
|
||||
/* init */
|
||||
pFirmwareImage = NULL;
|
||||
src = RTMP_FIRMWARE_FILE_NAME;
|
||||
|
||||
/* save uid and gid used for filesystem access.
|
||||
set user and group to 0 (root) */
|
||||
orgfsuid = current->fsuid;
|
||||
orgfsgid = current->fsgid;
|
||||
current->fsuid = current->fsgid = 0;
|
||||
orgfs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
|
||||
pAd->FirmwareVersion = (FIRMWARE_MAJOR_VERSION << 8) + \
|
||||
FIRMWARE_MINOR_VERSION;
|
||||
|
||||
|
||||
/* allocate firmware buffer */
|
||||
pFirmwareImage = kmalloc(MAX_FIRMWARE_IMAGE_SIZE, MEM_ALLOC_FLAG);
|
||||
if (pFirmwareImage == NULL)
|
||||
{
|
||||
/* allocate fail, use default firmware array in firmware.h */
|
||||
printk("%s - Allocate memory fail!\n", __func__);
|
||||
NICLF_DEFAULT_USE();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* allocate ok! zero the firmware buffer */
|
||||
memset(pFirmwareImage, 0x00, MAX_FIRMWARE_IMAGE_SIZE);
|
||||
} /* End of if */
|
||||
|
||||
|
||||
/* if ok, read firmware file from *.bin file */
|
||||
if (flg_default_firm_use == FALSE)
|
||||
{
|
||||
do
|
||||
{
|
||||
/* open the bin file */
|
||||
srcf = filp_open(src, O_RDONLY, 0);
|
||||
|
||||
if (IS_ERR(srcf))
|
||||
{
|
||||
printk("%s - Error %ld opening %s\n",
|
||||
__func__, -PTR_ERR(srcf), src);
|
||||
NICLF_DEFAULT_USE();
|
||||
break;
|
||||
} /* End of if */
|
||||
|
||||
/* the object must have a read method */
|
||||
if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
|
||||
{
|
||||
printk("%s - %s does not have a write method\n", __func__, src);
|
||||
NICLF_DEFAULT_USE();
|
||||
break;
|
||||
} /* End of if */
|
||||
|
||||
/* read the firmware from the file *.bin */
|
||||
FileLength = srcf->f_op->read(srcf,
|
||||
pFirmwareImage,
|
||||
MAX_FIRMWARE_IMAGE_SIZE,
|
||||
&srcf->f_pos);
|
||||
|
||||
if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
|
||||
{
|
||||
printk("%s: error file length (=%d) in RT2860AP.BIN\n",
|
||||
__func__, FileLength);
|
||||
NICLF_DEFAULT_USE();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
PUCHAR ptr = pFirmwareImage;
|
||||
USHORT crc = 0xffff;
|
||||
|
||||
|
||||
/* calculate firmware CRC */
|
||||
for(i=0; i<(MAX_FIRMWARE_IMAGE_SIZE-2); i++, ptr++)
|
||||
crc = ByteCRC16(BitReverse(*ptr), crc);
|
||||
/* End of for */
|
||||
|
||||
if ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2] != \
|
||||
(UCHAR)BitReverse((UCHAR)(crc>>8))) ||
|
||||
(pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1] != \
|
||||
(UCHAR)BitReverse((UCHAR)crc)))
|
||||
{
|
||||
/* CRC fail */
|
||||
printk("%s: CRC = 0x%02x 0x%02x "
|
||||
"error, should be 0x%02x 0x%02x\n",
|
||||
__func__,
|
||||
pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
|
||||
pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
|
||||
(UCHAR)(crc>>8), (UCHAR)(crc));
|
||||
NICLF_DEFAULT_USE();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* firmware is ok */
|
||||
pAd->FirmwareVersion = \
|
||||
(pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4] << 8) +
|
||||
pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3];
|
||||
|
||||
/* check if firmware version of the file is too old */
|
||||
if ((pAd->FirmwareVersion) < \
|
||||
((FIRMWARE_MAJOR_VERSION << 8) +
|
||||
FIRMWARE_MINOR_VERSION))
|
||||
{
|
||||
printk("%s: firmware version too old!\n", __func__);
|
||||
NICLF_DEFAULT_USE();
|
||||
break;
|
||||
} /* End of if */
|
||||
} /* End of if */
|
||||
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("NICLoadFirmware: CRC ok, ver=%d.%d\n",
|
||||
pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4],
|
||||
pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3]));
|
||||
} /* End of if (FileLength == MAX_FIRMWARE_IMAGE_SIZE) */
|
||||
break;
|
||||
} while(TRUE);
|
||||
|
||||
/* close firmware file */
|
||||
if (IS_ERR(srcf))
|
||||
;
|
||||
else
|
||||
{
|
||||
retval = filp_close(srcf, NULL);
|
||||
if (retval)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("--> Error %d closing %s\n", -retval, src));
|
||||
} /* End of if */
|
||||
} /* End of if */
|
||||
} /* End of if */
|
||||
|
||||
|
||||
/* write firmware to ASIC */
|
||||
if (flg_default_firm_use == TRUE)
|
||||
{
|
||||
/* use default fimeware, free allocated buffer */
|
||||
if (pFirmwareImage != NULL)
|
||||
kfree(pFirmwareImage);
|
||||
/* End of if */
|
||||
|
||||
/* use default *.bin array */
|
||||
pFirmwareImage = FirmwareImage;
|
||||
FileLength = sizeof(FirmwareImage);
|
||||
} /* End of if */
|
||||
|
||||
/* enable Host program ram write selection */
|
||||
RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x10000);
|
||||
|
||||
for(i=0; i<FileLength; i+=4)
|
||||
{
|
||||
firm = pFirmwareImage[i] +
|
||||
(pFirmwareImage[i+3] << 24) +
|
||||
(pFirmwareImage[i+2] << 16) +
|
||||
(pFirmwareImage[i+1] << 8);
|
||||
|
||||
RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, firm);
|
||||
} /* End of for */
|
||||
|
||||
RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00000);
|
||||
RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x00001);
|
||||
|
||||
/* initialize BBP R/W access agent */
|
||||
RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0);
|
||||
RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
|
||||
|
||||
if (flg_default_firm_use == FALSE)
|
||||
{
|
||||
/* use file firmware, free allocated buffer */
|
||||
if (pFirmwareImage != NULL)
|
||||
kfree(pFirmwareImage);
|
||||
/* End of if */
|
||||
} /* End of if */
|
||||
|
||||
set_fs(orgfs);
|
||||
current->fsuid = orgfsuid;
|
||||
current->fsgid = orgfsgid;
|
||||
#else
|
||||
|
||||
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
|
||||
PUCHAR pFirmwareImage;
|
||||
ULONG FileLength, Index;
|
||||
@ -3167,8 +2964,6 @@ NDIS_STATUS NICLoadFirmware(
|
||||
|
||||
RT28XX_WRITE_FIRMWARE(pAd, pFirmwareImage, FileLength);
|
||||
|
||||
#endif
|
||||
|
||||
/* check if MCU is ready */
|
||||
Index = 0;
|
||||
do
|
||||
|
Loading…
Reference in New Issue
Block a user