[Midnightbsd-cvs] src [8912] trunk/sys/dev/bce: Make tables, device ID strings etc const.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Sep 26 18:46:54 EDT 2016
Revision: 8912
http://svnweb.midnightbsd.org/src/?rev=8912
Author: laffer1
Date: 2016-09-26 18:46:54 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
Make tables, device ID strings etc const. Use NULL instead of 0. do not bzero redundantly. Remove softc members not used. do not use RF_SHAREABLE on MSI.
Modified Paths:
--------------
trunk/sys/dev/bce/if_bce.c
trunk/sys/dev/bce/if_bcereg.h
Modified: trunk/sys/dev/bce/if_bce.c
===================================================================
--- trunk/sys/dev/bce/if_bce.c 2016-09-26 22:45:50 UTC (rev 8911)
+++ trunk/sys/dev/bce/if_bce.c 2016-09-26 22:46:54 UTC (rev 8912)
@@ -95,7 +95,7 @@
/****************************************************************************/
#define BCE_DEVDESC_MAX 64
-static struct bce_type bce_devs[] = {
+static const struct bce_type bce_devs[] = {
/* BCM5706C Controllers and OEM boards. */
{ BRCM_VENDORID, BRCM_DEVICEID_BCM5706, HP_VENDORID, 0x3101,
"HP NC370T Multifunction Gigabit Server Adapter" },
@@ -161,7 +161,7 @@
/****************************************************************************/
/* Supported Flash NVRAM device data. */
/****************************************************************************/
-static struct flash_spec flash_table[] =
+static const struct flash_spec flash_table[] =
{
#define BUFFERED_FLAGS (BCE_NV_BUFFERED | BCE_NV_TRANSLATE)
#define NONBUFFERED_FLAGS (BCE_NV_WREN)
@@ -258,7 +258,7 @@
* logical-to-physical mapping is required in the
* driver.
*/
-static struct flash_spec flash_5709 = {
+static const struct flash_spec flash_5709 = {
.flags = BCE_NV_BUFFERED,
.page_bits = BCM5709_FLASH_PAGE_BITS,
.page_size = BCM5709_FLASH_PAGE_SIZE,
@@ -481,8 +481,8 @@
MODULE_DEPEND(bce, ether, 1, 1, 1);
MODULE_DEPEND(bce, miibus, 1, 1, 1);
-DRIVER_MODULE(bce, pci, bce_driver, bce_devclass, 0, 0);
-DRIVER_MODULE(miibus, bce, miibus_driver, miibus_devclass, 0, 0);
+DRIVER_MODULE(bce, pci, bce_driver, bce_devclass, NULL, NULL);
+DRIVER_MODULE(miibus, bce, miibus_driver, miibus_devclass, NULL, NULL);
/****************************************************************************/
@@ -647,7 +647,7 @@
static int
bce_probe(device_t dev)
{
- struct bce_type *t;
+ const struct bce_type *t;
struct bce_softc *sc;
char *descbuf;
u16 vid = 0, did = 0, svid = 0, sdid = 0;
@@ -655,7 +655,6 @@
t = bce_devs;
sc = device_get_softc(dev);
- bzero(sc, sizeof(struct bce_softc));
sc->bce_unit = device_get_unit(dev);
sc->bce_dev = dev;
@@ -1040,7 +1039,7 @@
struct bce_softc *sc;
struct ifnet *ifp;
u32 val;
- int error, rid, rc = 0;
+ int count, error, rc = 0, rid;
sc = device_get_softc(dev);
sc->bce_dev = dev;
@@ -1077,6 +1076,7 @@
bce_probe_pci_caps(dev, sc);
rid = 1;
+ count = 0;
#if 0
/* Try allocating MSI-X interrupts. */
if ((sc->bce_cap_flags & BCE_MSIX_CAPABLE_FLAG) &&
@@ -1084,14 +1084,14 @@
((sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&rid, RF_ACTIVE)) != NULL)) {
- msi_needed = sc->bce_msi_count = 1;
+ msi_needed = count = 1;
- if (((error = pci_alloc_msix(dev, &sc->bce_msi_count)) != 0) ||
- (sc->bce_msi_count != msi_needed)) {
+ if (((error = pci_alloc_msix(dev, &count)) != 0) ||
+ (count != msi_needed)) {
BCE_PRINTF("%s(%d): MSI-X allocation failed! Requested = %d,"
"Received = %d, error = %d\n", __FILE__, __LINE__,
- msi_needed, sc->bce_msi_count, error);
- sc->bce_msi_count = 0;
+ msi_needed, count, error);
+ count = 0;
pci_release_msi(dev);
bus_release_resource(dev, SYS_RES_MEMORY, rid,
sc->bce_res_irq);
@@ -1100,7 +1100,6 @@
DBPRINT(sc, BCE_INFO_LOAD, "%s(): Using MSI-X interrupt.\n",
__FUNCTION__);
sc->bce_flags |= BCE_USING_MSIX_FLAG;
- sc->bce_intr = bce_intr;
}
}
#endif
@@ -1107,12 +1106,12 @@
/* Try allocating a MSI interrupt. */
if ((sc->bce_cap_flags & BCE_MSI_CAPABLE_FLAG) &&
- (bce_msi_enable >= 1) && (sc->bce_msi_count == 0)) {
- sc->bce_msi_count = 1;
- if ((error = pci_alloc_msi(dev, &sc->bce_msi_count)) != 0) {
+ (bce_msi_enable >= 1) && (count == 0)) {
+ count = 1;
+ if ((error = pci_alloc_msi(dev, &count)) != 0) {
BCE_PRINTF("%s(%d): MSI allocation failed! "
"error = %d\n", __FILE__, __LINE__, error);
- sc->bce_msi_count = 0;
+ count = 0;
pci_release_msi(dev);
} else {
DBPRINT(sc, BCE_INFO_LOAD, "%s(): Using MSI "
@@ -1120,24 +1119,20 @@
sc->bce_flags |= BCE_USING_MSI_FLAG;
if (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5709)
sc->bce_flags |= BCE_ONE_SHOT_MSI_FLAG;
- sc->bce_irq_rid = 1;
- sc->bce_intr = bce_intr;
+ rid = 1;
}
}
/* Try allocating a legacy interrupt. */
- if (sc->bce_msi_count == 0) {
+ if (count == 0) {
DBPRINT(sc, BCE_INFO_LOAD, "%s(): Using INTx interrupt.\n",
__FUNCTION__);
rid = 0;
- sc->bce_intr = bce_intr;
}
sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
- &rid, RF_SHAREABLE | RF_ACTIVE);
+ &rid, RF_ACTIVE | (count != 0 ? 0 : RF_SHAREABLE));
- sc->bce_irq_rid = rid;
-
/* Report any IRQ allocation errors. */
if (sc->bce_res_irq == NULL) {
BCE_PRINTF("%s(%d): PCI map interrupt failed!\n",
@@ -1635,7 +1630,7 @@
static u32
bce_reg_rd(struct bce_softc *sc, u32 offset)
{
- u32 val = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, offset);
+ u32 val = REG_RD(sc, offset);
DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%08X\n",
__FUNCTION__, offset, val);
return val;
@@ -1653,7 +1648,7 @@
{
DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%04X\n",
__FUNCTION__, offset, val);
- bus_space_write_2(sc->bce_btag, sc->bce_bhandle, offset, val);
+ REG_WR16(sc, offset, val);
}
@@ -1668,7 +1663,7 @@
{
DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%08X\n",
__FUNCTION__, offset, val);
- bus_space_write_4(sc->bce_btag, sc->bce_bhandle, offset, val);
+ REG_WR(sc, offset, val);
}
#endif
@@ -1879,13 +1874,6 @@
sc = device_get_softc(dev);
- /* Make sure we are accessing the correct PHY address. */
- if (phy != sc->bce_phy_addr) {
- DBPRINT(sc, BCE_INSANE_PHY, "Invalid PHY address %d "
- "for PHY read!\n", phy);
- return(0);
- }
-
/*
* The 5709S PHY is an IEEE Clause 45 PHY
* with special mappings to work with IEEE
@@ -1968,13 +1956,6 @@
sc = device_get_softc(dev);
- /* Make sure we are accessing the correct PHY address. */
- if (phy != sc->bce_phy_addr) {
- DBPRINT(sc, BCE_INSANE_PHY, "Invalid PHY address %d "
- "for PHY write!\n", phy);
- return(0);
- }
-
DB_PRINT_PHY_REG(reg, val);
/*
@@ -2535,7 +2516,7 @@
{
u32 val;
int j, entry_count, rc = 0;
- struct flash_spec *flash;
+ const struct flash_spec *flash;
DBENTER(BCE_VERBOSE_NVRAM);
@@ -3949,8 +3930,8 @@
if (sc->bce_res_irq != NULL) {
DBPRINT(sc, BCE_INFO_RESET, "Releasing IRQ.\n");
- bus_release_resource(dev, SYS_RES_IRQ, sc->bce_irq_rid,
- sc->bce_res_irq);
+ bus_release_resource(dev, SYS_RES_IRQ,
+ rman_get_rid(sc->bce_res_irq), sc->bce_res_irq);
}
if (sc->bce_flags & (BCE_USING_MSI_FLAG | BCE_USING_MSIX_FLAG)) {
@@ -11650,4 +11631,3 @@
return;
}
#endif
-
Modified: trunk/sys/dev/bce/if_bcereg.h
===================================================================
--- trunk/sys/dev/bce/if_bcereg.h 2016-09-26 22:45:50 UTC (rev 8911)
+++ trunk/sys/dev/bce/if_bcereg.h 2016-09-26 22:46:54 UTC (rev 8912)
@@ -623,7 +623,7 @@
u_int16_t bce_did;
u_int16_t bce_svid;
u_int16_t bce_sdid;
- char *bce_name;
+ const char *bce_name;
};
/****************************************************************************/
@@ -717,7 +717,7 @@
u32 page_size;
u32 addr_mask;
u32 total_size;
- u8 *name;
+ const u8 *name;
};
@@ -2002,7 +2002,7 @@
#define BCE_MISC_ENABLE_CLR_BITS_UMP_ENABLE (1L<<27)
#define BCE_MISC_ENABLE_CLR_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
#define BCE_MISC_ENABLE_CLR_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
-
+
#define BCE_MISC_ENABLE_CLR_DEFAULT 0x17ffffff
#define BCE_MISC_CLOCK_CONTROL_BITS 0x00000818
@@ -6319,19 +6319,19 @@
u32 text_addr;
u32 text_len;
u32 text_index;
- u32 *text;
+ const u32 *text;
/* Data section. */
u32 data_addr;
u32 data_len;
u32 data_index;
- u32 *data;
+ const u32 *data;
/* SBSS section. */
u32 sbss_addr;
u32 sbss_len;
u32 sbss_index;
- u32 *sbss;
+ const u32 *sbss;
/* BSS section. */
u32 bss_addr;
@@ -6422,7 +6422,7 @@
struct bce_softc
{
- /* Interface info. Must be first!! */
+ /* Interface info */
struct ifnet *bce_ifp;
/* Parent device handle */
@@ -6452,10 +6452,7 @@
struct mtx bce_mtx;
/* Interrupt handler. */
- driver_intr_t *bce_intr;
void *bce_intrhand;
- int bce_irq_rid;
- int bce_msi_count;
/* ASIC Chip ID. */
u32 bce_chipid;
@@ -6510,7 +6507,7 @@
u16 link_speed;
/* Flash NVRAM settings */
- struct flash_spec *bce_flash_info;
+ const struct flash_spec *bce_flash_info;
/* Flash NVRAM size */
u32 bce_flash_size;
@@ -6519,7 +6516,7 @@
u32 bce_shmem_base;
/* Name string */
- char *bce_name;
+ const char *bce_name;
/* Tracks the version of bootcode firmware. */
char bce_bc_ver[32];
@@ -6835,4 +6832,3 @@
};
#endif /* __BCEREG_H_DEFINED */
-
More information about the Midnightbsd-cvs
mailing list