habanalabs: Add check for pci_enable_device
[linux-2.6-microblaze.git] / drivers / misc / habanalabs / common / debugfs.c
index fc084ee..f184955 100644 (file)
@@ -890,6 +890,8 @@ static ssize_t hl_set_power_state(struct file *f, const char __user *buf,
                pci_set_power_state(hdev->pdev, PCI_D0);
                pci_restore_state(hdev->pdev);
                rc = pci_enable_device(hdev->pdev);
+               if (rc < 0)
+                       return rc;
        } else if (value == 2) {
                pci_save_state(hdev->pdev);
                pci_disable_device(hdev->pdev);
@@ -1054,42 +1056,12 @@ static ssize_t hl_device_write(struct file *f, const char __user *buf,
 static ssize_t hl_clk_gate_read(struct file *f, char __user *buf,
                                        size_t count, loff_t *ppos)
 {
-       struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
-       struct hl_device *hdev = entry->hdev;
-       char tmp_buf[200];
-       ssize_t rc;
-
-       if (*ppos)
-               return 0;
-
-       sprintf(tmp_buf, "0x%llx\n", hdev->clock_gating_mask);
-       rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
-                       strlen(tmp_buf) + 1);
-
-       return rc;
+       return 0;
 }
 
 static ssize_t hl_clk_gate_write(struct file *f, const char __user *buf,
                                     size_t count, loff_t *ppos)
 {
-       struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
-       struct hl_device *hdev = entry->hdev;
-       u64 value;
-       ssize_t rc;
-
-       if (hdev->reset_info.in_reset) {
-               dev_warn_ratelimited(hdev->dev,
-                               "Can't change clock gating during reset\n");
-               return 0;
-       }
-
-       rc = kstrtoull_from_user(buf, count, 16, &value);
-       if (rc)
-               return rc;
-
-       hdev->clock_gating_mask = value;
-       hdev->asic_funcs->set_clock_gating(hdev);
-
        return count;
 }
 
@@ -1101,6 +1073,9 @@ static ssize_t hl_stop_on_err_read(struct file *f, char __user *buf,
        char tmp_buf[200];
        ssize_t rc;
 
+       if (!hdev->asic_prop.configurable_stop_on_err)
+               return -EOPNOTSUPP;
+
        if (*ppos)
                return 0;
 
@@ -1119,6 +1094,9 @@ static ssize_t hl_stop_on_err_write(struct file *f, const char __user *buf,
        u32 value;
        ssize_t rc;
 
+       if (!hdev->asic_prop.configurable_stop_on_err)
+               return -EOPNOTSUPP;
+
        if (hdev->reset_info.in_reset) {
                dev_warn_ratelimited(hdev->dev,
                                "Can't change stop on error during reset\n");