Skip to content

Commit 5e9b2db

Browse files
Michael Chandavem330
authored andcommitted
cnic: Put uio init in separate function.
This will allow the 10G iSCSI code to reuse the function. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ec0248e commit 5e9b2db

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

drivers/net/cnic.c

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -762,44 +762,30 @@ static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages)
762762
return 0;
763763
}
764764

765-
static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
766-
{
765+
static int cnic_alloc_uio(struct cnic_dev *dev) {
767766
struct cnic_local *cp = dev->cnic_priv;
768767
struct uio_info *uinfo;
769768
int ret;
770769

771-
ret = cnic_alloc_dma(dev, &cp->kwq_info, KWQ_PAGE_CNT, 1);
772-
if (ret)
773-
goto error;
774-
cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr;
775-
776-
ret = cnic_alloc_dma(dev, &cp->kcq_info, KCQ_PAGE_CNT, 1);
777-
if (ret)
778-
goto error;
779-
cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr;
780-
781-
ret = cnic_alloc_context(dev);
782-
if (ret)
783-
goto error;
784-
785-
ret = cnic_alloc_l2_rings(dev, 2);
786-
if (ret)
787-
goto error;
788-
789770
uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC);
790771
if (!uinfo)
791-
goto error;
772+
return -ENOMEM;
792773

793774
uinfo->mem[0].addr = dev->netdev->base_addr;
794775
uinfo->mem[0].internal_addr = dev->regview;
795776
uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start;
796777
uinfo->mem[0].memtype = UIO_MEM_PHYS;
797778

798779
uinfo->mem[1].addr = (unsigned long) cp->status_blk & PAGE_MASK;
799-
if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
800-
uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9;
801-
else
802-
uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE;
780+
if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
781+
if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
782+
uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9;
783+
else
784+
uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE;
785+
786+
uinfo->name = "bnx2_cnic";
787+
}
788+
803789
uinfo->mem[1].memtype = UIO_MEM_LOGICAL;
804790

805791
uinfo->mem[2].addr = (unsigned long) cp->l2_ring;
@@ -810,7 +796,6 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
810796
uinfo->mem[3].size = cp->l2_buf_size;
811797
uinfo->mem[3].memtype = UIO_MEM_LOGICAL;
812798

813-
uinfo->name = "bnx2_cnic";
814799
uinfo->version = CNIC_MODULE_VERSION;
815800
uinfo->irq = UIO_IRQ_CUSTOM;
816801

@@ -822,10 +807,39 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
822807
ret = uio_register_device(&dev->pcidev->dev, uinfo);
823808
if (ret) {
824809
kfree(uinfo);
825-
goto error;
810+
return ret;
826811
}
827812

828813
cp->cnic_uinfo = uinfo;
814+
return 0;
815+
}
816+
817+
static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
818+
{
819+
struct cnic_local *cp = dev->cnic_priv;
820+
int ret;
821+
822+
ret = cnic_alloc_dma(dev, &cp->kwq_info, KWQ_PAGE_CNT, 1);
823+
if (ret)
824+
goto error;
825+
cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr;
826+
827+
ret = cnic_alloc_dma(dev, &cp->kcq_info, KCQ_PAGE_CNT, 1);
828+
if (ret)
829+
goto error;
830+
cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr;
831+
832+
ret = cnic_alloc_context(dev);
833+
if (ret)
834+
goto error;
835+
836+
ret = cnic_alloc_l2_rings(dev, 2);
837+
if (ret)
838+
goto error;
839+
840+
ret = cnic_alloc_uio(dev);
841+
if (ret)
842+
goto error;
829843

830844
return 0;
831845

0 commit comments

Comments
 (0)