Skip to content

Commit

Permalink
block/sx8: add error handling support for add_disk()
Browse files Browse the repository at this point in the history
We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

A completion is used to notify the initial probe what is
happening and so we must defer error handling on completion.
Do this by remembering the error and using the shared cleanup
function.

The tags are shared and so are hanlded later for the
driver already.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
  • Loading branch information
mcgrof authored and intel-lab-lkp committed Jul 15, 2021
1 parent 819248f commit 6b028ff
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/block/sx8.c
Expand Up @@ -297,6 +297,7 @@ struct carm_host {

struct work_struct fsm_task;

int probe_err;
struct completion probe_comp;
};

Expand Down Expand Up @@ -1202,8 +1203,11 @@ static void carm_fsm_task (struct work_struct *work)
struct gendisk *disk = port->disk;

set_capacity(disk, port->capacity);
add_disk(disk);
activated++;
host->probe_err = add_disk(disk);
if (!host->probe_err)
activated++;
else
break;
}

printk(KERN_INFO DRV_NAME "(%s): %d ports activated\n",
Expand All @@ -1213,11 +1217,9 @@ static void carm_fsm_task (struct work_struct *work)
reschedule = 1;
break;
}

case HST_PROBE_FINISHED:
complete(&host->probe_comp);
break;

case HST_ERROR:
/* FIXME: TODO */
break;
Expand Down Expand Up @@ -1515,7 +1517,10 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_free_irq;

DPRINTK("waiting for probe_comp\n");
host->probe_err = -ENODEV;
wait_for_completion(&host->probe_comp);
if (host->probe_err)
goto err_out_disks;

printk(KERN_INFO "%s: pci %s, ports %d, io %llx, irq %u, major %d\n",
host->name, pci_name(pdev), (int) CARM_MAX_PORTS,
Expand All @@ -1526,6 +1531,8 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_drvdata(pdev, host);
return 0;

err_out_disks:
carm_free_all_disks(host);
err_out_free_irq:
free_irq(pdev->irq, host);
err_out_blkdev_disks:
Expand Down

0 comments on commit 6b028ff

Please sign in to comment.