Commit 7bc26a68 authored by Daeseok Youn's avatar Daeseok Youn Committed by Greg Kroah-Hartman

staging: dgap: make dgap_found_board() return a brd pointer

Make dgap_found_board() return a brd pointer and that brd pointer
assign to dgap_board[] in the end of the dgap_init_one().
Signed-off-by: default avatarDaeseok Youn <daeseok.youn@gmail.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 55a4ea71
...@@ -70,7 +70,8 @@ MODULE_SUPPORTED_DEVICE("dgap"); ...@@ -70,7 +70,8 @@ MODULE_SUPPORTED_DEVICE("dgap");
static int dgap_start(void); static int dgap_start(void);
static void dgap_init_globals(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_cleanup_board(struct board_t *brd);
static void dgap_poll_handler(ulong dummy); static void dgap_poll_handler(ulong dummy);
static int dgap_init_pci(void); static int dgap_init_pci(void);
...@@ -582,11 +583,10 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -582,11 +583,10 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) if (rc)
return -EIO; return -EIO;
rc = dgap_found_board(pdev, ent->driver_data, dgap_numboards); brd = dgap_found_board(pdev, ent->driver_data, dgap_numboards);
if (rc) if (IS_ERR(brd))
return rc; return PTR_ERR(brd);
brd = dgap_board[dgap_numboards++];
rc = dgap_firmware_load(pdev, ent->driver_data, brd); rc = dgap_firmware_load(pdev, ent->driver_data, brd);
if (rc) if (rc)
goto cleanup_brd; goto cleanup_brd;
...@@ -617,6 +617,8 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -617,6 +617,8 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
brd->state = BOARD_READY; brd->state = BOARD_READY;
brd->dpastatus = BD_RUNNING; brd->dpastatus = BD_RUNNING;
dgap_board[dgap_numboards++] = brd;
return 0; return 0;
tty_free: tty_free:
...@@ -630,7 +632,7 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -630,7 +632,7 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
cleanup_brd: cleanup_brd:
dgap_release_remap(brd); dgap_release_remap(brd);
kfree(brd); kfree(brd);
dgap_board[--dgap_numboards] = NULL;
return rc; return rc;
} }
...@@ -717,7 +719,8 @@ static void dgap_cleanup_board(struct board_t *brd) ...@@ -717,7 +719,8 @@ static void dgap_cleanup_board(struct board_t *brd)
* *
* A board has been found, init it. * 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; struct board_t *brd;
unsigned int pci_irq; unsigned int pci_irq;
...@@ -727,9 +730,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum) ...@@ -727,9 +730,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum)
/* get the board structure and prep it */ /* get the board structure and prep it */
brd = kzalloc(sizeof(struct board_t), GFP_KERNEL); brd = kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd) if (!brd)
return -ENOMEM; return ERR_PTR(-ENOMEM);
dgap_board[boardnum] = brd;
/* store the info for the board we've found */ /* store the info for the board we've found */
brd->magic = DGAP_BOARD_MAGIC; brd->magic = DGAP_BOARD_MAGIC;
...@@ -828,13 +829,12 @@ static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum) ...@@ -828,13 +829,12 @@ static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum)
pr_info("dgap: board %d: %s (rev %d), irq %ld\n", pr_info("dgap: board %d: %s (rev %d), irq %ld\n",
boardnum, brd->name, brd->rev, brd->irq); boardnum, brd->name, brd->rev, brd->irq);
return 0; return brd;
free_brd: free_brd:
kfree(brd); kfree(brd);
dgap_board[boardnum] = NULL;
return ret; return ERR_PTR(ret);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment