]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
[nvme-cli] Update enclosure changes based on review comments.
authorJeff Lien <jeff.lien@wdc.com>
Wed, 7 Oct 2020 20:15:47 +0000 (15:15 -0500)
committerKeith Busch <kbusch@kernel.org>
Tue, 13 Oct 2020 18:06:09 +0000 (12:06 -0600)
plugins/wdc/wdc-nvme.c

index 866dd24b910231aaf36014f7dafd6cb070b99441..49a1c3a47c052eee4b47ca7dfeeea4bf063c3c58 100644 (file)
@@ -1038,15 +1038,7 @@ static int wdc_get_vendor_id(int fd, uint32_t *vendor_id)
 
 static bool wdc_check_power_of_2(int num)
 {
-       int first_set = 1;
-
-       if (num == 0)
-               return false;
-
-       while ((first_set & num) == 0)
-               first_set <<= 1;
-
-       return (~first_set & num) ? false : true;
+       return (num && ( !(num & (num-1))));
 }
 
 static int wdc_get_model_number(int fd, char *model)