From 0ed8570ef4d51bb46e2028b2e3c3ddd1f860e193 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 21 Dec 2009 16:27:55 -0800 Subject: [SCSI] cxgbi3: remove unnecessary NULL test Stanse found that c3cn is poked many times around in cxgb3i_conn_pdu_ready, there is no need to check if it is NULL. Remove the test. Signed-off-by: Jiri Slaby Reviewed-by: Mike Christie Acked-by: Karen Xie Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/cxgb3i/cxgb3i_pdu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/cxgb3i') diff --git a/drivers/scsi/cxgb3i/cxgb3i_pdu.c b/drivers/scsi/cxgb3i/cxgb3i_pdu.c index 1fe3b0f1f3c..9c38539557f 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_pdu.c +++ b/drivers/scsi/cxgb3i/cxgb3i_pdu.c @@ -461,10 +461,8 @@ void cxgb3i_conn_pdu_ready(struct s3_conn *c3cn) skb = skb_peek(&c3cn->receive_queue); } read_unlock(&c3cn->callback_lock); - if (c3cn) { - c3cn->copied_seq += read; - cxgb3i_c3cn_rx_credits(c3cn, read); - } + c3cn->copied_seq += read; + cxgb3i_c3cn_rx_credits(c3cn, read); conn->rxdata_octets += read; if (err) { -- cgit v1.2.3-70-g09d2 From d9573e7af16de0e3aa55db1703dbe544faf391de Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 10 Feb 2010 16:51:43 -0600 Subject: [SCSI] cxgb3i, bnx2i: remove uses of nipquad use %pi4 Remove uses of NIPQUAD, use %pI4 Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 4 ++-- drivers/scsi/cxgb3i/cxgb3i_iscsi.c | 5 ++--- drivers/scsi/cxgb3i/cxgb3i_offload.c | 7 ++++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/cxgb3i') diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 33b2294625b..51709cb9a93 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1426,8 +1426,8 @@ static int bnx2i_conn_get_param(struct iscsi_cls_conn *cls_conn, break; case ISCSI_PARAM_CONN_ADDRESS: if (bnx2i_conn->ep) - len = sprintf(buf, NIPQUAD_FMT "\n", - NIPQUAD(bnx2i_conn->ep->cm_sk->dst_ip)); + len = sprintf(buf, "%pI4\n", + &bnx2i_conn->ep->cm_sk->dst_ip); break; default: return iscsi_conn_get_param(cls_conn, param, buf); diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c index 969c83162cc..1fd89b229c8 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c +++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c @@ -591,8 +591,7 @@ static int cxgb3i_conn_bind(struct iscsi_cls_session *cls_session, cxgb3i_conn_max_recv_dlength(conn); spin_lock_bh(&conn->session->lock); - sprintf(conn->portal_address, NIPQUAD_FMT, - NIPQUAD(c3cn->daddr.sin_addr.s_addr)); + sprintf(conn->portal_address, "%pI4", &c3cn->daddr.sin_addr.s_addr); conn->portal_port = ntohs(c3cn->daddr.sin_port); spin_unlock_bh(&conn->session->lock); @@ -753,7 +752,7 @@ static int cxgb3i_host_get_param(struct Scsi_Host *shost, __be32 addr; addr = cxgb3i_get_private_ipv4addr(hba->ndev); - len = sprintf(buf, NIPQUAD_FMT, NIPQUAD(addr)); + len = sprintf(buf, "%pI4", &addr); break; } default: diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c b/drivers/scsi/cxgb3i/cxgb3i_offload.c index 15a00e8b712..3e08c430ff2 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_offload.c +++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c @@ -1675,10 +1675,11 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct s3_conn *c3cn, } else c3cn->saddr.sin_addr.s_addr = sipv4; - c3cn_conn_debug("c3cn 0x%p, %u.%u.%u.%u,%u-%u.%u.%u.%u,%u SYN_SENT.\n", - c3cn, NIPQUAD(c3cn->saddr.sin_addr.s_addr), + c3cn_conn_debug("c3cn 0x%p, %pI4,%u-%pI4,%u SYN_SENT.\n", + c3cn, + &c3cn->saddr.sin_addr.s_addr, ntohs(c3cn->saddr.sin_port), - NIPQUAD(c3cn->daddr.sin_addr.s_addr), + &c3cn->daddr.sin_addr.s_addr, ntohs(c3cn->daddr.sin_port)); c3cn_set_state(c3cn, C3CN_STATE_CONNECTING); -- cgit v1.2.3-70-g09d2 From 9010b94636312c7fb12b591ef09e915f8f80bbd5 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Wed, 10 Feb 2010 16:51:44 -0600 Subject: [SCSI] cxgb3i: check for setup netdev If the netdev has not been setup when the host is, we will oops when the iscsi layer calls into the driver and a it tries to reference the netdev in hba->ndev. This can happen if the iscsi driver is loaded before ifup is done. This patch just adds a check, so we can gracefully fail the operation. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/cxgb3i/cxgb3i_iscsi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/scsi/cxgb3i') diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c index 1fd89b229c8..412853c6537 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c +++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c @@ -708,6 +708,12 @@ static int cxgb3i_host_set_param(struct Scsi_Host *shost, { struct cxgb3i_hba *hba = iscsi_host_priv(shost); + if (!hba->ndev) { + shost_printk(KERN_ERR, shost, "Could not set host param. " + "Netdev for host not set.\n"); + return -ENODEV; + } + cxgb3i_api_debug("param %d, buf %s.\n", param, buf); switch (param) { @@ -738,6 +744,12 @@ static int cxgb3i_host_get_param(struct Scsi_Host *shost, struct cxgb3i_hba *hba = iscsi_host_priv(shost); int len = 0; + if (!hba->ndev) { + shost_printk(KERN_ERR, shost, "Could not set host param. " + "Netdev for host not set.\n"); + return -ENODEV; + } + cxgb3i_api_debug("hba %s, param %d.\n", hba->ndev->name, param); switch (param) { -- cgit v1.2.3-70-g09d2