s390/dasd: Enable automatic loading of dasd_diag_mod
authorPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
Mon, 11 May 2015 11:08:05 +0000 (13:08 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 13 May 2015 07:58:19 +0000 (09:58 +0200)
Enabling a DASD that was configured to use the DIAG250 access method
while the corresponding kernel module dasd_diag_mod has not been loaded
fails with an error message. To fix this, users need to manually load
the dasd_diag_mod module.

This procedure can be simplified by automatically loading the
dasd_diag_mod from within the kernel when a DASD configured for DIAG250
is set online.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/block/dasd.c

index 57fd66357b959fadaccfa3ecf269dda848bc7166..1aec8ff0b58743214ff2ad520dea009d0a1f3f96 100644 (file)
@@ -38,6 +38,8 @@
  */
 #define DASD_CHANQ_MAX_SIZE 4
 
+#define DASD_DIAG_MOD          "dasd_diag_mod"
+
 /*
  * SECTION: exported variables of dasd.c
  */
@@ -3300,6 +3302,21 @@ int dasd_generic_set_online(struct ccw_device *cdev,
        discipline = base_discipline;
        if (device->features & DASD_FEATURE_USEDIAG) {
                if (!dasd_diag_discipline_pointer) {
+                       /* Try to load the required module. */
+                       rc = request_module(DASD_DIAG_MOD);
+                       if (rc) {
+                               pr_warn("%s Setting the DASD online failed "
+                                       "because the required module %s "
+                                       "could not be loaded (rc=%d)\n",
+                                       dev_name(&cdev->dev), DASD_DIAG_MOD,
+                                       rc);
+                               dasd_delete_device(device);
+                               return -ENODEV;
+                       }
+               }
+               /* Module init could have failed, so check again here after
+                * request_module(). */
+               if (!dasd_diag_discipline_pointer) {
                        pr_warn("%s Setting the DASD online failed because of missing DIAG discipline\n",
                                dev_name(&cdev->dev));
                        dasd_delete_device(device);