Provide a common interface in iprlib for code looking for the microcode
version of an ipr_dev.  This also make the functions get_ioa_fw_version
and get_dev_fw_version internal to iprlib.c and update callers to use
the generic get_fw_version function.

Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com>
---
 iprconfig.c | 10 +++++-----
 iprlib.c    | 27 ++++++++++++++++++++++++++-
 iprlib.h    |  3 +--
 iprupdate.c |  2 +-
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/iprconfig.c b/iprconfig.c
index 7e99d06..d664a23 100644
--- a/iprconfig.c
+++ b/iprconfig.c
@@ -2056,7 +2056,7 @@ static char *ioa_details(char *body, struct ipr_dev *dev)
 
        ipr_inquiry(dev, 2, &dram_vpd, sizeof(dram_vpd));
 
-       fw_level = get_ioa_fw_version(dev->ioa);
+       fw_level = get_fw_version(&dev->ioa->ioa);
 
        body = add_line_to_body(body,"", NULL);
        ipr_strncpy_0(buffer, scsi_dev_data->vendor_id, IPR_VENDOR_ID_LEN);
@@ -15020,7 +15020,7 @@ static int update_ioa_ucode(struct ipr_ioa *ioa, char 
*file)
 
        rc = ipr_update_ioa_fw(ioa, &image, 1);
 
-       if (image.version != get_ioa_fw_version(ioa))
+       if (image.version != get_fw_version(&ioa->ioa))
                return -EIO;
        return rc;
 }
@@ -15050,7 +15050,7 @@ static int update_dev_ucode(struct ipr_dev *dev, char 
*file)
 
        rc = ipr_update_disk_fw(dev, &image, 1);
 
-       if (image.version != get_dev_fw_version(dev))
+       if (image.version != get_fw_version(dev))
                return -EIO;
        return rc;
 }
@@ -15843,9 +15843,9 @@ static int query_ucode_level(char **args, int num_args)
        }
 
        if (&dev->ioa->ioa == dev)
-               printf("%08X\n", get_ioa_fw_version(dev->ioa));
+               printf("%08X\n", get_fw_version(dev));
        else {
-               level = get_dev_fw_version(dev);
+               level = get_fw_version(dev);
                level_sw = htonl(level);
                asc = (char *)&level_sw;
                if (isprint(asc[0]) && isprint(asc[1]) &&
diff --git a/iprlib.c b/iprlib.c
index 141034a..9b0b4a4 100644
--- a/iprlib.c
+++ b/iprlib.c
@@ -8253,7 +8253,7 @@ u32 get_dev_fw_version(struct ipr_dev *dev)
  * Returns:
  *   ioa firmware version
  **/
-u32 get_ioa_fw_version(struct ipr_ioa *ioa)
+static u32 get_ioa_fw_version(struct ipr_ioa *ioa)
 {
        char devpath[PATH_MAX];
        char value[16];
@@ -8270,6 +8270,31 @@ u32 get_ioa_fw_version(struct ipr_ioa *ioa)
 }
 
 /**
+ * get_fw_version - Get microcode version of device.
+ *
+ * @dev:               Device
+ *
+ * Returns:
+ *   ucode version if success / 0 on failure
+ **/
+u32 get_fw_version(struct ipr_dev *dev)
+{
+       if (!dev) {
+               /* FIXME: We should return -ENODEV here but old API
+               returns 0 on failure and any uint > 0 can be a firmware
+               level. A viable option would be writting the fw level to
+               a pointer received as argument, but lets hold to the
+               current API for now. */
+               return 0;
+       }
+
+       if (&dev->ioa->ioa == dev)
+               return get_ioa_fw_version(dev->ioa);
+
+       return get_dev_fw_version(dev);
+}
+
+/**
  * get_ioa_image_type -
  * @ioa:               ipr ioa struct
  *
diff --git a/iprlib.h b/iprlib.h
index 8ba2a00..e66ea47 100644
--- a/iprlib.h
+++ b/iprlib.h
@@ -2721,8 +2721,7 @@ void ipr_del_zeroed_dev(struct ipr_dev *);
 int ipr_device_is_zeroed(struct ipr_dev *);
 struct ipr_array_cap_entry *get_raid_cap_entry(struct ipr_supported_arrays *, 
u8 );
 char *get_prot_level_str(struct ipr_supported_arrays *, int);
-u32 get_dev_fw_version(struct ipr_dev *);
-u32 get_ioa_fw_version(struct ipr_ioa *);
+u32 get_fw_version(struct ipr_dev *);
 int ipr_disable_qerr(struct ipr_dev *);
 void ipr_log_ucode_error(struct ipr_ioa *);
 u32 get_dasd_ucode_version(char *, int);
diff --git a/iprupdate.c b/iprupdate.c
index 3a4c5ad..5c64828 100644
--- a/iprupdate.c
+++ b/iprupdate.c
@@ -31,7 +31,7 @@ static int force_ioas;
 
 static int ioa_needs_update(struct ipr_ioa *ioa, int silent)
 {
-       u32 fw_version = get_ioa_fw_version(ioa);
+       u32 fw_version = get_fw_version(&ioa->ioa);
 
        if (fw_version >= ioa->msl)
                return 0;
-- 
2.1.0


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to