in sync with the values current in the channel subsystem).
                Note: This is an I/O-subchannel specific attribute.
 Users:         s390-tools, HAL
+
+What:          /sys/bus/css/devices/.../driver_override
+Date:          June 2019
+Contact:       Cornelia Huck <cohuck@redhat.com>
+               linux-s390@vger.kernel.org
+Description:   This file allows the driver for a device to be specified. When
+               specified, only a driver with a name matching the value written
+               to driver_override will have an opportunity to bind to the
+               device. The override is specified by writing a string to the
+               driver_override file (echo vfio-ccw > driver_override) and
+               may be cleared with an empty string (echo > driver_override).
+               This returns the device to standard matching rules binding.
+               Writing to driver_override does not automatically unbind the
+               device from its current driver or make any attempt to
+               automatically load the specified driver.  If no driver with a
+               matching name is currently loaded in the kernel, the device
+               will not bind to any driver.  This also allows devices to
+               opt-out of driver binding using a driver_override name such as
+               "none".  Only a single driver may be specified in the override,
+               there is no support for parsing delimiters.
+               Note that unlike the mechanism of the same name for pci, this
+               file does not allow to override basic matching rules. I.e.,
+               the driver must still match the subchannel type of the device.
 
 
        sch->config.intparm = 0;
        cio_commit_config(sch);
+       kfree(sch->driver_override);
        kfree(sch->lock);
        kfree(sch);
 }
 
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t driver_override_store(struct device *dev,
+                                    struct device_attribute *attr,
+                                    const char *buf, size_t count)
+{
+       struct subchannel *sch = to_subchannel(dev);
+       char *driver_override, *old, *cp;
+
+       /* We need to keep extra room for a newline */
+       if (count >= (PAGE_SIZE - 1))
+               return -EINVAL;
+
+       driver_override = kstrndup(buf, count, GFP_KERNEL);
+       if (!driver_override)
+               return -ENOMEM;
+
+       cp = strchr(driver_override, '\n');
+       if (cp)
+               *cp = '\0';
+
+       device_lock(dev);
+       old = sch->driver_override;
+       if (strlen(driver_override)) {
+               sch->driver_override = driver_override;
+       } else {
+               kfree(driver_override);
+               sch->driver_override = NULL;
+       }
+       device_unlock(dev);
+
+       kfree(old);
+
+       return count;
+}
+
+static ssize_t driver_override_show(struct device *dev,
+                                   struct device_attribute *attr, char *buf)
+{
+       struct subchannel *sch = to_subchannel(dev);
+       ssize_t len;
+
+       device_lock(dev);
+       len = snprintf(buf, PAGE_SIZE, "%s\n", sch->driver_override);
+       device_unlock(dev);
+       return len;
+}
+static DEVICE_ATTR_RW(driver_override);
+
 static struct attribute *subch_attrs[] = {
        &dev_attr_type.attr,
        &dev_attr_modalias.attr,
+       &dev_attr_driver_override.attr,
        NULL,
 };
 
        struct css_driver *driver = to_cssdriver(drv);
        struct css_device_id *id;
 
+       /* When driver_override is set, only bind to the matching driver */
+       if (sch->driver_override && strcmp(sch->driver_override, drv->name))
+               return 0;
+
        for (id = driver->subchannel_type; id->match_flags; id++) {
                if (sch->st == id->type)
                        return 1;