diff options
author | Jan Höppner <hoeppner@linux.vnet.ibm.com> | 2015-08-19 12:16:35 +0300 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2016-03-07 15:12:00 +0300 |
commit | 570d237c19f8d0f1dfd214767f2d995b8291138a (patch) | |
tree | edc7a9b752dc07604106987770fe39ba6429f2c0 /drivers/s390 | |
parent | 8542885bf5338bfccf779868a5d143620e794ff9 (diff) | |
download | linux-570d237c19f8d0f1dfd214767f2d995b8291138a.tar.xz |
s390/dasd: Refactor dasd format functions
Prepare for new format checking function by renaming functions and
moving reusable code to separate functions:
- Move sanity checks into a new function and make it reusable.
- Move common format code to a new function called
dasd_eckd_format_process_data.
- Create the generic function dasd_eckd_format_build_ccw_req, which
itself will then decide what ccw request is being built according to
the input data. (with upcoming functionality).
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/block/dasd_eckd.c | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 8181d6724942..e679209755cf 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -2386,22 +2386,26 @@ dasd_eckd_build_format(struct dasd_device *base, return fcp; } -static int -dasd_eckd_format_device(struct dasd_device *base, - struct format_data_t *fdata, - int enable_pav) +/* + * Wrapper function to build a CCW request depending on input data + */ +static struct dasd_ccw_req * +dasd_eckd_format_build_ccw_req(struct dasd_device *base, + struct format_data_t *fdata, int enable_pav) +{ + return dasd_eckd_build_format(base, fdata, enable_pav); +} + +/* + * Sanity checks on format_data + */ +static int dasd_eckd_format_sanity_checks(struct dasd_device *base, + struct format_data_t *fdata) { - struct dasd_ccw_req *cqr, *n; struct dasd_eckd_private *private; - struct list_head format_queue; - struct dasd_device *device; - int old_start, old_stop, format_step; - int step, retry; - int rc = 0; private = (struct dasd_eckd_private *) base->private; - /* Sanity checks. */ if (fdata->start_unit >= (private->real_cyl * private->rdc_data.trk_per_cyl)) { dev_warn(&base->cdev->dev, @@ -2428,6 +2432,29 @@ dasd_eckd_format_device(struct dasd_device *base, fdata->blksize); return -EINVAL; } + return 0; +} + +/* + * This function will process format_data originally coming from an IOCTL + */ +static int dasd_eckd_format_process_data(struct dasd_device *base, + struct format_data_t *fdata, + int enable_pav) +{ + struct dasd_ccw_req *cqr, *n; + struct dasd_eckd_private *private; + struct list_head format_queue; + struct dasd_device *device; + int old_start, old_stop, format_step; + int step, retry; + int rc; + + private = (struct dasd_eckd_private *) base->private; + + rc = dasd_eckd_format_sanity_checks(base, fdata); + if (rc) + return rc; INIT_LIST_HEAD(&format_queue); @@ -2445,7 +2472,8 @@ dasd_eckd_format_device(struct dasd_device *base, fdata->start_unit + format_step - 1; } - cqr = dasd_eckd_build_format(base, fdata, enable_pav); + cqr = dasd_eckd_format_build_ccw_req(base, fdata, + enable_pav); if (IS_ERR(cqr)) { rc = PTR_ERR(cqr); if (rc == -ENOMEM) { @@ -2492,6 +2520,12 @@ out: return rc; } +static int dasd_eckd_format_device(struct dasd_device *base, + struct format_data_t *fdata, int enable_pav) +{ + return dasd_eckd_format_process_data(base, fdata, enable_pav); +} + static void dasd_eckd_handle_terminated_request(struct dasd_ccw_req *cqr) { if (cqr->retries < 0) { |