@@ -541,34 +541,6 @@ static ssize_t device_show(struct device *dev,
541541}
542542static DEVICE_ATTR_RO (device );
543543
544- static ssize_t driver_override_store (struct device * dev ,
545- struct device_attribute * attr ,
546- const char * buf , size_t count )
547- {
548- struct hv_device * hv_dev = device_to_hv_device (dev );
549- int ret ;
550-
551- ret = driver_set_override (dev , & hv_dev -> driver_override , buf , count );
552- if (ret )
553- return ret ;
554-
555- return count ;
556- }
557-
558- static ssize_t driver_override_show (struct device * dev ,
559- struct device_attribute * attr , char * buf )
560- {
561- struct hv_device * hv_dev = device_to_hv_device (dev );
562- ssize_t len ;
563-
564- device_lock (dev );
565- len = sysfs_emit (buf , "%s\n" , hv_dev -> driver_override );
566- device_unlock (dev );
567-
568- return len ;
569- }
570- static DEVICE_ATTR_RW (driver_override );
571-
572544/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
573545static struct attribute * vmbus_dev_attrs [] = {
574546 & dev_attr_id .attr ,
@@ -599,7 +571,6 @@ static struct attribute *vmbus_dev_attrs[] = {
599571 & dev_attr_channel_vp_mapping .attr ,
600572 & dev_attr_vendor .attr ,
601573 & dev_attr_device .attr ,
602- & dev_attr_driver_override .attr ,
603574 NULL ,
604575};
605576
@@ -711,18 +682,23 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(const struct hv_driver *
711682{
712683 const guid_t * guid = & dev -> dev_type ;
713684 const struct hv_vmbus_device_id * id ;
685+ int ret ;
714686
715- /* When driver_override is set, only bind to the matching driver */
716- if (dev -> driver_override && strcmp (dev -> driver_override , drv -> name ))
687+ /* If a driver override is set, only bind to the matching driver */
688+ ret = device_match_driver_override (& dev -> device , & drv -> driver );
689+ if (ret == 0 )
717690 return NULL ;
718691
719692 /* Look at the dynamic ids first, before the static ones */
720693 id = hv_vmbus_dynid_match ((struct hv_driver * )drv , guid );
721694 if (!id )
722695 id = hv_vmbus_dev_match (drv -> id_table , guid );
723696
724- /* driver_override will always match, send a dummy id */
725- if (!id && dev -> driver_override )
697+ /*
698+ * If there's a matching driver override, this function should succeed,
699+ * thus return a dummy device ID if no matching ID is found.
700+ */
701+ if (!id && ret > 0 )
726702 id = & vmbus_device_null ;
727703
728704 return id ;
@@ -1024,6 +1000,7 @@ static const struct dev_pm_ops vmbus_pm = {
10241000/* The one and only one */
10251001static const struct bus_type hv_bus = {
10261002 .name = "vmbus" ,
1003+ .driver_override = true,
10271004 .match = vmbus_match ,
10281005 .shutdown = vmbus_shutdown ,
10291006 .remove = vmbus_remove ,
0 commit comments