]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
habanalabs: ASIC_AUTO_DETECT enum value is redundant
authorOded Gabbay <oded.gabbay@gmail.com>
Thu, 4 Apr 2019 11:33:34 +0000 (14:33 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Thu, 4 Apr 2019 11:33:34 +0000 (14:33 +0300)
This patch removes the enum value of ASIC_AUTO_DETECT because we can use
the validity of the pdev variable to know whether we have a real device or
a simulator. For a real device, we detect the asic type from the device ID
while for a simulator, the simulator code calls create_hdev() with the
specified ASIC type.

Set ASIC_INVALID as the first option in the enum to make sure that no
other enum value will receive the value 0 (which indicates a non-existing
entry in the simulator array).

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/habanalabs.h
drivers/misc/habanalabs/habanalabs_drv.c

index 535d4f9531f6d547bc28b6d4c9f2422067a308f6..2f02bb55f66aa2ef8896b7cac524af0e3e724286 100644 (file)
@@ -390,14 +390,12 @@ struct hl_eq {
 
 /**
  * enum hl_asic_type - supported ASIC types.
- * @ASIC_AUTO_DETECT: ASIC type will be automatically set.
- * @ASIC_GOYA: Goya device.
  * @ASIC_INVALID: Invalid ASIC type.
+ * @ASIC_GOYA: Goya device.
  */
 enum hl_asic_type {
-       ASIC_AUTO_DETECT,
-       ASIC_GOYA,
-       ASIC_INVALID
+       ASIC_INVALID,
+       ASIC_GOYA
 };
 
 struct hl_cs_parser;
index b697339d39049466162e7f79be7de3002639610b..1667df7ca64c53515e448ab0d7e1d1acbe3ec8f6 100644 (file)
@@ -218,7 +218,7 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev,
        hdev->disabled = true;
        hdev->pdev = pdev; /* can be NULL in case of simulator device */
 
-       if (asic_type == ASIC_AUTO_DETECT) {
+       if (pdev) {
                hdev->asic_type = get_asic_type(pdev->device);
                if (hdev->asic_type == ASIC_INVALID) {
                        dev_err(&pdev->dev, "Unsupported ASIC\n");
@@ -337,7 +337,7 @@ static int hl_pci_probe(struct pci_dev *pdev,
                 " device found [%04x:%04x] (rev %x)\n",
                 (int)pdev->vendor, (int)pdev->device, (int)pdev->revision);
 
-       rc = create_hdev(&hdev, pdev, ASIC_AUTO_DETECT, -1);
+       rc = create_hdev(&hdev, pdev, ASIC_INVALID, -1);
        if (rc)
                return rc;