@@ -345,9 +345,7 @@ int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
345345 struct block_device * bdev ;
346346 int ret = 0 ;
347347
348- if (disk -> flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN ))
349- return - EINVAL ;
350- if (test_bit (GD_SUPPRESS_PART_SCAN , & disk -> state ))
348+ if (!disk_has_partscan (disk ))
351349 return - EINVAL ;
352350 if (disk -> open_partitions )
353351 return - EBUSY ;
@@ -503,8 +501,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
503501 goto out_unregister_bdi ;
504502
505503 /* Make sure the first partition scan will be proceed */
506- if (get_capacity (disk ) && !(disk -> flags & GENHD_FL_NO_PART ) &&
507- !test_bit (GD_SUPPRESS_PART_SCAN , & disk -> state ))
504+ if (get_capacity (disk ) && disk_has_partscan (disk ))
508505 set_bit (GD_NEED_PART_SCAN , & disk -> state );
509506
510507 bdev_add (disk -> part0 , ddev -> devt );
@@ -1040,6 +1037,12 @@ static ssize_t diskseq_show(struct device *dev,
10401037 return sprintf (buf , "%llu\n" , disk -> diskseq );
10411038}
10421039
1040+ static ssize_t partscan_show (struct device * dev ,
1041+ struct device_attribute * attr , char * buf )
1042+ {
1043+ return sprintf (buf , "%u\n" , disk_has_partscan (dev_to_disk (dev )));
1044+ }
1045+
10431046static DEVICE_ATTR (range , 0444 , disk_range_show , NULL) ;
10441047static DEVICE_ATTR (ext_range , 0444 , disk_ext_range_show , NULL) ;
10451048static DEVICE_ATTR (removable , 0444 , disk_removable_show , NULL) ;
@@ -1053,6 +1056,7 @@ static DEVICE_ATTR(stat, 0444, part_stat_show, NULL);
10531056static DEVICE_ATTR (inflight , 0444 , part_inflight_show , NULL) ;
10541057static DEVICE_ATTR (badblocks , 0644 , disk_badblocks_show , disk_badblocks_store ) ;
10551058static DEVICE_ATTR (diskseq , 0444 , diskseq_show , NULL) ;
1059+ static DEVICE_ATTR (partscan , 0444 , partscan_show , NULL) ;
10561060
10571061#ifdef CONFIG_FAIL_MAKE_REQUEST
10581062ssize_t part_fail_show (struct device * dev ,
@@ -1099,6 +1103,7 @@ static struct attribute *disk_attrs[] = {
10991103 & dev_attr_events_async .attr ,
11001104 & dev_attr_events_poll_msecs .attr ,
11011105 & dev_attr_diskseq .attr ,
1106+ & dev_attr_partscan .attr ,
11021107#ifdef CONFIG_FAIL_MAKE_REQUEST
11031108 & dev_attr_fail .attr ,
11041109#endif
0 commit comments