Skip to content

Commit 2174a04

Browse files
Mike ChristieJames Bottomley
authored andcommitted
[SCSI] iscsi_transport, qla4xxx: have class lookup host for drivers
We are going to be adding more host level sysfs attrs and set_params, so this patch has them take a scsi_host instead of either a scsi_host or host no. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Cc: David C Somayajulu <david.somayajulu@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent aa1e93a commit 2174a04

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

drivers/scsi/qla4xxx/ql4_os.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha);
5454
/*
5555
* iSCSI template entry points
5656
*/
57-
static int qla4xxx_tgt_dscvr(enum iscsi_tgt_dscvr type, uint32_t host_no,
58-
uint32_t enable, struct sockaddr *dst_addr);
57+
static int qla4xxx_tgt_dscvr(struct Scsi_Host *shost,
58+
enum iscsi_tgt_dscvr type, uint32_t enable,
59+
struct sockaddr *dst_addr);
5960
static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
6061
enum iscsi_param param, char *buf);
6162
static int qla4xxx_sess_get_param(struct iscsi_cls_session *sess,
@@ -243,21 +244,15 @@ static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
243244
return len;
244245
}
245246

246-
static int qla4xxx_tgt_dscvr(enum iscsi_tgt_dscvr type, uint32_t host_no,
247-
uint32_t enable, struct sockaddr *dst_addr)
247+
static int qla4xxx_tgt_dscvr(struct Scsi_Host *shost,
248+
enum iscsi_tgt_dscvr type, uint32_t enable,
249+
struct sockaddr *dst_addr)
248250
{
249251
struct scsi_qla_host *ha;
250-
struct Scsi_Host *shost;
251252
struct sockaddr_in *addr;
252253
struct sockaddr_in6 *addr6;
253254
int ret = 0;
254255

255-
shost = scsi_host_lookup(host_no);
256-
if (IS_ERR(shost)) {
257-
printk(KERN_ERR "Could not find host no %u\n", host_no);
258-
return -ENODEV;
259-
}
260-
261256
ha = (struct scsi_qla_host *) shost->hostdata;
262257

263258
switch (type) {
@@ -281,8 +276,6 @@ static int qla4xxx_tgt_dscvr(enum iscsi_tgt_dscvr type, uint32_t host_no,
281276
default:
282277
ret = -ENOSYS;
283278
}
284-
285-
scsi_host_put(shost);
286279
return ret;
287280
}
288281

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,15 +945,26 @@ static int
945945
iscsi_tgt_dscvr(struct iscsi_transport *transport,
946946
struct iscsi_uevent *ev)
947947
{
948+
struct Scsi_Host *shost;
948949
struct sockaddr *dst_addr;
950+
int err;
949951

950952
if (!transport->tgt_dscvr)
951953
return -EINVAL;
952954

955+
shost = scsi_host_lookup(ev->u.tgt_dscvr.host_no);
956+
if (IS_ERR(shost)) {
957+
printk(KERN_ERR "target discovery could not find host no %u\n",
958+
ev->u.tgt_dscvr.host_no);
959+
return -ENODEV;
960+
}
961+
962+
953963
dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
954-
return transport->tgt_dscvr(ev->u.tgt_dscvr.type,
955-
ev->u.tgt_dscvr.host_no,
956-
ev->u.tgt_dscvr.enable, dst_addr);
964+
err = transport->tgt_dscvr(shost, ev->u.tgt_dscvr.type,
965+
ev->u.tgt_dscvr.enable, dst_addr);
966+
scsi_host_put(shost);
967+
return err;
957968
}
958969

959970
static int

include/scsi/scsi_transport_iscsi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct iscsi_transport {
127127
uint64_t *ep_handle);
128128
int (*ep_poll) (uint64_t ep_handle, int timeout_ms);
129129
void (*ep_disconnect) (uint64_t ep_handle);
130-
int (*tgt_dscvr) (enum iscsi_tgt_dscvr type, uint32_t host_no,
130+
int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
131131
uint32_t enable, struct sockaddr *dst_addr);
132132
};
133133

0 commit comments

Comments
 (0)