static int dgap_start(void);
static void dgap_init_globals(void);
-static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum);
+static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
+ int boardnum);
static void dgap_cleanup_board(struct board_t *brd);
static void dgap_poll_handler(ulong dummy);
static int dgap_init_pci(void);
if (rc)
return -EIO;
- rc = dgap_found_board(pdev, ent->driver_data, dgap_numboards);
- if (rc)
- return rc;
+ brd = dgap_found_board(pdev, ent->driver_data, dgap_numboards);
+ if (IS_ERR(brd))
+ return PTR_ERR(brd);
- brd = dgap_board[dgap_numboards++];
rc = dgap_firmware_load(pdev, ent->driver_data, brd);
if (rc)
goto cleanup_brd;
brd->state = BOARD_READY;
brd->dpastatus = BD_RUNNING;
+ dgap_board[dgap_numboards++] = brd;
+
return 0;
tty_free:
cleanup_brd:
dgap_release_remap(brd);
kfree(brd);
- dgap_board[--dgap_numboards] = NULL;
+
return rc;
}
*
* A board has been found, init it.
*/
-static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum)
+static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
+ int boardnum)
{
struct board_t *brd;
unsigned int pci_irq;
/* get the board structure and prep it */
brd = kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd)
- return -ENOMEM;
-
- dgap_board[boardnum] = brd;
+ return ERR_PTR(-ENOMEM);
/* store the info for the board we've found */
brd->magic = DGAP_BOARD_MAGIC;
pr_info("dgap: board %d: %s (rev %d), irq %ld\n",
boardnum, brd->name, brd->rev, brd->irq);
- return 0;
+ return brd;
free_brd:
kfree(brd);
- dgap_board[boardnum] = NULL;
- return ret;
+ return ERR_PTR(ret);
}