[PATCH] [SCSI] aic7xxx: Remove ahd_acquire_seeprom and ahd_release_seeprom due to redundant implementation

From: Rand Deeb
Date: Tue Dec 19 2023 - 04:21:35 EST


We removed the ahd_acquire_seeprom and ahd_release_seeprom functions
because both lacked meaningful implementations. The SEEPROM acquisition
and release logic they provided were unused and had been commented out,
making them redundant and non-functional. In addition to some style
fixes.
This change simplifies the codebase and improves code clarity by
eliminating unnecessary code.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Rand Deeb <rand.sec96@xxxxxxxxx>
---
drivers/scsi/aic7xxx/aic79xx.h | 2 -
drivers/scsi/aic7xxx/aic79xx_core.c | 29 ----------
drivers/scsi/aic7xxx/aic79xx_pci.c | 89 ++++++++++++++---------------
drivers/scsi/aic7xxx/aic79xx_proc.c | 36 +++++-------
4 files changed, 56 insertions(+), 100 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index 9a515551641c..e8a7b16a6861 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -962,8 +962,6 @@ int ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
u_int start_addr, u_int count);
int ahd_verify_cksum(struct seeprom_config *sc);
-int ahd_acquire_seeprom(struct ahd_softc *ahd);
-void ahd_release_seeprom(struct ahd_softc *ahd);

/**************************** Message Buffer *********************************/
typedef enum {
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 4c790fe28f73..7d639b98e9aa 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -10089,35 +10089,6 @@ ahd_verify_cksum(struct seeprom_config *sc)
}
}

-int
-ahd_acquire_seeprom(struct ahd_softc *ahd)
-{
- /*
- * We should be able to determine the SEEPROM type
- * from the flexport logic, but unfortunately not
- * all implementations have this logic and there is
- * no programatic method for determining if the logic
- * is present.
- */
- return (1);
-#if 0
- uint8_t seetype;
- int error;
-
- error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype);
- if (error != 0
- || ((seetype & FLX_ROMSTAT_SEECFG) == FLX_ROMSTAT_SEE_NONE))
- return (0);
- return (1);
-#endif
-}
-
-void
-ahd_release_seeprom(struct ahd_softc *ahd)
-{
- /* Currently a no-op */
-}
-
/*
* Wait at most 2 seconds for flexport arbitration to succeed.
*/
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index 8397ae93f7dd..a25d193eb3ad 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -507,60 +507,55 @@ ahd_check_extport(struct ahd_softc *ahd)
{
struct vpd_config vpd;
struct seeprom_config *sc;
- u_int adapter_control;
- int have_seeprom;
+ u_int adapter_control, start_addr;
+ int have_seeprom = 1;
int error;

sc = ahd->seep_config;
- have_seeprom = ahd_acquire_seeprom(ahd);
- if (have_seeprom) {
- u_int start_addr;

- /*
- * Fetch VPD for this function and parse it.
- */
- if (bootverbose)
- printk("%s: Reading VPD from SEEPROM...",
- ahd_name(ahd));
+ /*
+ * Fetch VPD for this function and parse it.
+ */
+ if (bootverbose)
+ printk("%s: Reading VPD from SEEPROM...",
+ ahd_name(ahd));

- /* Address is always in units of 16bit words */
- start_addr = ((2 * sizeof(*sc))
- + (sizeof(vpd) * (ahd->channel - 'A'))) / 2;
-
- error = ahd_read_seeprom(ahd, (uint16_t *)&vpd,
- start_addr, sizeof(vpd)/2,
- /*bytestream*/TRUE);
- if (error == 0)
- error = ahd_parse_vpddata(ahd, &vpd);
- if (bootverbose)
- printk("%s: VPD parsing %s\n",
- ahd_name(ahd),
- error == 0 ? "successful" : "failed");
-
- if (bootverbose)
- printk("%s: Reading SEEPROM...", ahd_name(ahd));
-
- /* Address is always in units of 16bit words */
- start_addr = (sizeof(*sc) / 2) * (ahd->channel - 'A');
-
- error = ahd_read_seeprom(ahd, (uint16_t *)sc,
- start_addr, sizeof(*sc)/2,
- /*bytestream*/FALSE);
-
- if (error != 0) {
- printk("Unable to read SEEPROM\n");
- have_seeprom = 0;
- } else {
- have_seeprom = ahd_verify_cksum(sc);
+ /* Address is always in units of 16bit words */
+ start_addr = ((2 * sizeof(*sc))
+ + (sizeof(vpd) * (ahd->channel - 'A'))) / 2;

- if (bootverbose) {
- if (have_seeprom == 0)
- printk ("checksum error\n");
- else
- printk ("done.\n");
- }
+ error = ahd_read_seeprom(ahd, (uint16_t *)&vpd,
+ start_addr, sizeof(vpd)/2,
+ /*bytestream*/TRUE);
+ if (error == 0)
+ error = ahd_parse_vpddata(ahd, &vpd);
+ if (bootverbose)
+ printk("%s: VPD parsing %s\n",
+ ahd_name(ahd),
+ error == 0 ? "successful" : "failed");
+
+ if (bootverbose)
+ printk("%s: Reading SEEPROM...", ahd_name(ahd));
+
+ /* Address is always in units of 16bit words */
+ start_addr = (sizeof(*sc) / 2) * (ahd->channel - 'A');
+
+ error = ahd_read_seeprom(ahd, (uint16_t *)sc,
+ start_addr, sizeof(*sc)/2,
+ /*bytestream*/FALSE);
+
+ if (error != 0) {
+ printk("Unable to read SEEPROM\n");
+ have_seeprom = 0;
+ } else {
+ have_seeprom = ahd_verify_cksum(sc);
+
+ if (bootverbose) {
+ if (have_seeprom == 0)
+ printk("checksum error\n");
+ else
+ printk("done.\n");
}
- ahd_release_seeprom(ahd);
}

if (!have_seeprom) {
diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c
index add2da581d66..8a4a1c5601d1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_proc.c
+++ b/drivers/scsi/aic7xxx/aic79xx_proc.c
@@ -213,6 +213,7 @@ ahd_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
u_long s;
int paused;
int written;
+ u_int start_addr;

/* Default to failure. */
written = -EINVAL;
@@ -234,31 +235,22 @@ ahd_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
goto done;
}

- have_seeprom = ahd_acquire_seeprom(ahd);
- if (!have_seeprom) {
- printk("ahd_proc_write_seeprom: No Serial EEPROM\n");
- goto done;
- } else {
- u_int start_addr;
-
+ if (ahd->seep_config == NULL) {
+ ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
if (ahd->seep_config == NULL) {
- ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
- if (ahd->seep_config == NULL) {
- printk("aic79xx: Unable to allocate serial "
- "eeprom buffer. Write failing\n");
- goto done;
- }
+ printk("aic79xx: Unable to allocate serial "
+ "eeprom buffer. Write failing\n");
+ goto done;
}
- printk("aic79xx: Writing Serial EEPROM\n");
- start_addr = 32 * (ahd->channel - 'A');
- ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
- sizeof(struct seeprom_config)/2);
- ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
- start_addr, sizeof(struct seeprom_config)/2,
- /*ByteStream*/FALSE);
- ahd_release_seeprom(ahd);
- written = length;
}
+ printk("aic79xx: Writing Serial EEPROM\n");
+ start_addr = 32 * (ahd->channel - 'A');
+ ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
+ sizeof(struct seeprom_config)/2);
+ ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
+ start_addr, sizeof(struct seeprom_config)/2,
+ /*ByteStream*/FALSE);
+ written = length;

done:
ahd_restore_modes(ahd, saved_modes);
--
2.34.1