The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=295fd9c1caeb42a4c93005080320d011bf01e4c0

commit 295fd9c1caeb42a4c93005080320d011bf01e4c0
Author:     Joerg Pulz <joerg.p...@frm2.tum.de>
AuthorDate: 2023-07-07 21:43:34 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2023-07-07 21:45:30 +0000

    isp(4): Remove redundant functions for reading data from FLT and flash
    
    Rename isp_rd_2400_nvram to isp_rd_2xxx_flash.
    Cleanup some leftovers.
    Hide all output regarding FLT parsing behind ISP_LOGDEBUG0.
    
    Thanks to imp@ and mav@ for reviewing and commenting.
    
    PR: 271062
    Reviewed by: imp, mav
    Sponsored by: Technical University of Munich
    Pull Request: https://github.com/freebsd/freebsd-src/pull/726
---
 sys/dev/isp/isp.c | 115 +++++++++++++++---------------------------------------
 1 file changed, 31 insertions(+), 84 deletions(-)

diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index 87f2b04becdb..7645da635b7a 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -119,14 +119,12 @@ static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
 
 static void isp_setdfltfcparm(ispsoftc_t *, int);
 static int isp_read_nvram(ispsoftc_t *, int);
+static void isp_rd_2xxx_flash(ispsoftc_t *, uint32_t, uint32_t *);
 static int isp_read_flthdr_2xxx(ispsoftc_t *);
-static void isp_rd_2xxx_flthdr(ispsoftc_t *, uint32_t, uint32_t *);
 static void isp_parse_flthdr_2xxx(ispsoftc_t *, uint8_t *);
 static int isp_read_flt_2xxx(ispsoftc_t *);
-static void isp_rd_2xxx_flt(ispsoftc_t *, uint32_t, uint32_t *);
 static int isp_parse_flt_2xxx(ispsoftc_t *, uint8_t *);
 static int isp_read_nvram_2400(ispsoftc_t *);
-static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
 static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
 
 static void
@@ -4383,6 +4381,30 @@ isp_read_nvram(ispsoftc_t *isp, int bus)
        return (isp_read_nvram_2400(isp));
 }
 
+static void
+isp_rd_2xxx_flash(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
+{
+       fcparam *fcp = FCPARAM(isp, 0);
+       int loops = 0;
+       uint32_t base = fcp->flash_data_addr;
+       uint32_t tmp = 0;
+
+       ISP_WRITE(isp, BIU2400_FLASH_ADDR, base + addr);
+       for (loops = 0; loops < 5000; loops++) {
+               ISP_DELAY(10);
+               tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
+               if ((tmp & (1U << 31)) != 0) {
+                       break;
+               }
+       }
+       if (tmp & (1U << 31)) {
+               *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
+               ISP_SWIZZLE_NVRAM_LONG(isp, rp);
+       } else {
+               *rp = 0xffffffff;
+       }
+}
+
 static int
 isp_read_flthdr_2xxx(ispsoftc_t *isp)
 {
@@ -4398,7 +4420,7 @@ isp_read_flthdr_2xxx(ispsoftc_t *isp)
        isp_prt(isp, ISP_LOGDEBUG0,
            "FLTL[DEF]: 0x%x", addr);
        for (lwrds = 0; lwrds < FLT_HEADER_SIZE >> 2; lwrds++) {
-               isp_rd_2xxx_flthdr(isp, addr++, dptr++);
+               isp_rd_2xxx_flash(isp, addr++, dptr++);
        }
        dptr = (uint32_t *) flthdr_data;
        for (csum = 0, lwrds = 0; lwrds < FLT_HEADER_SIZE >> 4; lwrds++) {
@@ -4415,30 +4437,6 @@ out:
        return (retval);
 }
 
-static void
-isp_rd_2xxx_flthdr(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
-{
-       fcparam *fcp = FCPARAM(isp, 0);
-       int loops = 0;
-       uint32_t base = fcp->flash_data_addr;
-       uint32_t tmp = 0;
-
-       ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
-       for (loops = 0; loops < 5000; loops++) {
-               ISP_DELAY(10);
-               tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
-               if ((tmp & (1U << 31)) != 0) {
-                       break;
-               }
-       }
-       if (tmp & (1U << 31)) {
-               *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
-               ISP_SWIZZLE_NVRAM_LONG(isp, rp);
-       } else {
-               *rp = 0xffffffff;
-       }
-}
-
 static void
 isp_parse_flthdr_2xxx(ispsoftc_t *isp, uint8_t *flthdr_data)
 {
@@ -4455,7 +4453,7 @@ isp_parse_flthdr_2xxx(ispsoftc_t *isp, uint8_t 
*flthdr_data)
                    "FLT[DEF]: Invalid length=0x%x(%d)",
                    fcp->flt_length, fcp->flt_length);
        }
-       isp_prt(isp, ISP_LOGCONFIG,
+       isp_prt(isp, ISP_LOGDEBUG0,
            "FLT[DEF]: version=0x%x length=0x%x(%d) checksum=0x%x",
            ver, fcp->flt_length, fcp->flt_length, csum);
 }
@@ -4472,39 +4470,15 @@ isp_read_flt_2xxx(ispsoftc_t *isp)
 
        addr = fcp->flt_region_flt + (FLT_HEADER_SIZE >> 2);
        dptr = (uint32_t *) flt_data;
-       isp_prt(isp, ISP_LOGCONFIG, "FLT[DEF]: regions=%d",
+       isp_prt(isp, ISP_LOGDEBUG0, "FLT[DEF]: regions=%d",
            fcp->flt_region_entries);
        for (lwrds = 0; lwrds < len >> 2; lwrds++) {
-               isp_rd_2xxx_flt(isp, addr++, dptr++);
+               isp_rd_2xxx_flash(isp, addr++, dptr++);
        }
        retval = isp_parse_flt_2xxx(isp, flt_data);
        return (retval);
 }
 
-static void
-isp_rd_2xxx_flt(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
-{
-       fcparam *fcp = FCPARAM(isp, 0);
-       int loops = 0;
-       uint32_t base = fcp->flash_data_addr;
-       uint32_t tmp = 0;
-
-       ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
-       for (loops = 0; loops < 5000; loops++) {
-               ISP_DELAY(10);
-               tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
-               if ((tmp & (1U << 31)) != 0) {
-                       break;
-               }
-       }
-       if (tmp & (1U << 31)) {
-               *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
-               ISP_SWIZZLE_NVRAM_LONG(isp, rp);
-       } else {
-               *rp = 0xffffffff;
-       }
-}
-
 static int
 isp_parse_flt_2xxx(ispsoftc_t *isp, uint8_t *flt_data)
 {
@@ -4676,7 +4650,7 @@ isp_parse_flt_2xxx(ispsoftc_t *isp, uint8_t *flt_data)
                        break;
                }
        }
-       isp_prt(isp, ISP_LOGCONFIG,
+       isp_prt(isp, ISP_LOGDEBUG0,
            "FLT[FLT]: boot=0x%x fw=0x%x vpd_nvram=0x%x vpd=0x%x nvram 0x%x "
            "fdt=0x%x flt=0x%x npiv=0x%x fcp_prif_cfg=0x%x",
            fcp->flt_region_boot, fcp->flt_region_fw, fcp->flt_region_vpd_nvram,
@@ -4698,7 +4672,7 @@ isp_read_nvram_2400(ispsoftc_t *isp)
        addr = fcp->flt_region_nvram;
        dptr = (uint32_t *) nvram_data;
        for (lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
-               isp_rd_2400_nvram(isp, addr++, dptr++);
+               isp_rd_2xxx_flash(isp, addr++, dptr++);
        }
        if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
            nvram_data[2] != 'P') {
@@ -4723,33 +4697,6 @@ out:
        return (retval);
 }
 
-static void
-isp_rd_2400_nvram(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
-{
-       fcparam *fcp = FCPARAM(isp, 0);
-       int loops = 0;
-       uint32_t base; // = 0x7ffe0000;
-       uint32_t tmp = 0;
-
-       base = fcp->flash_data_addr + addr;
-       addr = 0;
-
-       ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
-       for (loops = 0; loops < 5000; loops++) {
-               ISP_DELAY(10);
-               tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
-               if ((tmp & (1U << 31)) != 0) {
-                       break;
-               }
-       }
-       if (tmp & (1U << 31)) {
-               *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
-               ISP_SWIZZLE_NVRAM_LONG(isp, rp);
-       } else {
-               *rp = 0xffffffff;
-       }
-}
-
 static void
 isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
 {

Reply via email to