Skip to content
  • Dan Williams's avatar
    libnvdimm: register nvdimm_bus devices with an nd_bus driver · 18515942
    Dan Williams authored
    
    
    A recent effort to add a new nvdimm bus provider attribute highlighted a
    race between interrogating nvdimm_bus->nd_desc and nvdimm_bus tear down.
    The typical way to handle these races is to take the device_lock() in
    the attribute method and validate that the device is still active.  In
    order for a device to be 'active' it needs to be associated with a
    driver.  So, we create the small boilerplate for a driver and register
    nvdimm_bus devices on the 'nvdimm_bus_type' bus.
    
    A result of this change is that ndbusX devices now appear under
    /sys/bus/nd/devices.  In fact this makes /sys/class/nd somewhat
    redundant, but removing that will need to take a long deprecation period
    given its use by ndctl binaries in the field.
    
    This change naturally pulls code from drivers/nvdimm/core.c to
    drivers/nvdimm/bus.c, so it is a nice code organization clean-up as
    well.
    
    Cc: Vishal Verma <vishal.l.verma@intel.com>
    Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
    18515942