Auto detect an OSDv2 or OSDv1 target at run time. Note how none of the OSD calls change, apart from the added detection code. This test passes against both the IBM-OSD-SIM OSD1 target as well as Pete's OSC's OSD2 target. Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx> Reviewed-by: Benny Halevy <bhalevy@xxxxxxxxxxx> --- drivers/scsi/osd/osd_ktests.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/osd/osd_ktests.c b/drivers/scsi/osd/osd_ktests.c index 3186fc8..45a0dcc 100644 --- a/drivers/scsi/osd/osd_ktests.c +++ b/drivers/scsi/osd/osd_ktests.c @@ -101,6 +101,11 @@ int test_exec(struct osd_request *or, void *caps, const struct osd_obj_id *obj) #define ATTR_DEF_RI(id, len) ATTR_DEF(OSD_APAGE_ROOT_INFORMATION, id, len) +static char *osd_ver_desc(struct osd_request *or) +{ + return osd_req_is_ver1(or) ? "OSD1" : "OSD2"; +} + int ktest_read_system_info(struct osd_dev *osd_dev) { struct osd_request *or; @@ -131,14 +136,14 @@ int ktest_read_system_info(struct osd_dev *osd_dev) ret = test_exec(or, g_caps, &osd_root_object); if (ret) { - OSD_ERR("Failed to detect %s => %d\n", "OSD1", ret); + OSD_ERR("Failed to detect %s => %d\n", osd_ver_desc(or), ret); goto out; } osd_req_decode_get_attr_list(or, get_attrs, &nelem, &iter); OSD_INFO("Detected %s device\n", - "OSD1"); + osd_ver_desc(or)); pFirst = get_attrs[a++].val_ptr; OSD_INFO("OSD_ATTR_RI_VENDOR_IDENTIFICATION [%s]\n", @@ -459,8 +464,13 @@ int do_test_17(struct scsi_device *scsi_dev) osd_dev_init(&osd_dev, scsi_dev); - if (ktest_read_system_info(&osd_dev)) - goto dev_fini; + /* Auto-detect the osd version */ + if (ktest_read_system_info(&osd_dev)) { + osd_dev_set_ver(&osd_dev, OSD_VER1); + OSD_DEBUG("converting to OSD1\n"); + if (ktest_read_system_info(&osd_dev)) + goto dev_fini; + } /* osd_format */ if (ktest_format(&osd_dev)) -- 1.5.6.rc1.5.gadf6 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html