bna: use container_of to resolve bufdesc_ex from bufdesc
authorFabian Frederick <fabf@skynet.be>
Sat, 13 Sep 2014 20:38:27 +0000 (22:38 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Sep 2014 16:49:11 +0000 (12:49 -0400)
Use container_of instead of casting first structure member.

Compiled but untested.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/brocade/bna/bna_enet.c
drivers/net/ethernet/brocade/bna/bna_tx_rx.c

index 13f9636cdba73fdd7bc7f4d148f35a9948f4e04b..903466ef41c06ed4f9812b754f245f1c32644b2f 100644 (file)
@@ -107,7 +107,8 @@ bna_bfi_ethport_admin_rsp(struct bna_ethport *ethport,
 {
        struct bfi_enet_enable_req *admin_req =
                &ethport->bfi_enet_cmd.admin_req;
-       struct bfi_enet_rsp *rsp = (struct bfi_enet_rsp *)msghdr;
+       struct bfi_enet_rsp *rsp =
+               container_of(msghdr, struct bfi_enet_rsp, mh);
 
        switch (admin_req->enable) {
        case BNA_STATUS_T_ENABLED:
@@ -133,7 +134,8 @@ bna_bfi_ethport_lpbk_rsp(struct bna_ethport *ethport,
 {
        struct bfi_enet_diag_lb_req *diag_lb_req =
                &ethport->bfi_enet_cmd.lpbk_req;
-       struct bfi_enet_rsp *rsp = (struct bfi_enet_rsp *)msghdr;
+       struct bfi_enet_rsp *rsp =
+               container_of(msghdr, struct bfi_enet_rsp, mh);
 
        switch (diag_lb_req->enable) {
        case BNA_STATUS_T_ENABLED:
@@ -161,7 +163,8 @@ static void
 bna_bfi_attr_get_rsp(struct bna_ioceth *ioceth,
                        struct bfi_msgq_mhdr *msghdr)
 {
-       struct bfi_enet_attr_rsp *rsp = (struct bfi_enet_attr_rsp *)msghdr;
+       struct bfi_enet_attr_rsp *rsp =
+               container_of(msghdr, struct bfi_enet_attr_rsp, mh);
 
        /**
         * Store only if not set earlier, since BNAD can override the HW
index 85e63546abe3311c2902a5a93cd422942b714b24..8ee3fdcc17cd7b0aa66a2bb43399282f83170692 100644 (file)
@@ -715,7 +715,7 @@ bna_bfi_rxf_ucast_set_rsp(struct bna_rxf *rxf,
                        struct bfi_msgq_mhdr *msghdr)
 {
        struct bfi_enet_rsp *rsp =
-               (struct bfi_enet_rsp *)msghdr;
+               container_of(msghdr, struct bfi_enet_rsp, mh);
 
        if (rsp->error) {
                /* Clear ucast from cache */
@@ -732,7 +732,7 @@ bna_bfi_rxf_mcast_add_rsp(struct bna_rxf *rxf,
        struct bfi_enet_mcast_add_req *req =
                &rxf->bfi_enet_cmd.mcast_add_req;
        struct bfi_enet_mcast_add_rsp *rsp =
-               (struct bfi_enet_mcast_add_rsp *)msghdr;
+               container_of(msghdr, struct bfi_enet_mcast_add_rsp, mh);
 
        bna_rxf_mchandle_attach(rxf, (u8 *)&req->mac_addr,
                ntohs(rsp->handle));