diff options
Diffstat (limited to 'drivers/scsi/scsi_transport_iscsi.c')
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index ca7bb6f63bde..65d1737eb664 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -40,13 +40,13 @@ struct iscsi_internal { | |||
40 | struct scsi_transport_template t; | 40 | struct scsi_transport_template t; |
41 | struct iscsi_transport *iscsi_transport; | 41 | struct iscsi_transport *iscsi_transport; |
42 | struct list_head list; | 42 | struct list_head list; |
43 | struct class_device cdev; | 43 | struct device dev; |
44 | 44 | ||
45 | struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; | 45 | struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; |
46 | struct transport_container conn_cont; | 46 | struct transport_container conn_cont; |
47 | struct class_device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; | 47 | struct device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; |
48 | struct transport_container session_cont; | 48 | struct transport_container session_cont; |
49 | struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; | 49 | struct device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ | 52 | static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ |
@@ -63,12 +63,12 @@ static DEFINE_SPINLOCK(iscsi_transport_lock); | |||
63 | #define to_iscsi_internal(tmpl) \ | 63 | #define to_iscsi_internal(tmpl) \ |
64 | container_of(tmpl, struct iscsi_internal, t) | 64 | container_of(tmpl, struct iscsi_internal, t) |
65 | 65 | ||
66 | #define cdev_to_iscsi_internal(_cdev) \ | 66 | #define dev_to_iscsi_internal(_dev) \ |
67 | container_of(_cdev, struct iscsi_internal, cdev) | 67 | container_of(_dev, struct iscsi_internal, dev) |
68 | 68 | ||
69 | static void iscsi_transport_release(struct class_device *cdev) | 69 | static void iscsi_transport_release(struct device *dev) |
70 | { | 70 | { |
71 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); | 71 | struct iscsi_internal *priv = dev_to_iscsi_internal(dev); |
72 | kfree(priv); | 72 | kfree(priv); |
73 | } | 73 | } |
74 | 74 | ||
@@ -78,25 +78,27 @@ static void iscsi_transport_release(struct class_device *cdev) | |||
78 | */ | 78 | */ |
79 | static struct class iscsi_transport_class = { | 79 | static struct class iscsi_transport_class = { |
80 | .name = "iscsi_transport", | 80 | .name = "iscsi_transport", |
81 | .release = iscsi_transport_release, | 81 | .dev_release = iscsi_transport_release, |
82 | }; | 82 | }; |
83 | 83 | ||
84 | static ssize_t | 84 | static ssize_t |
85 | show_transport_handle(struct class_device *cdev, char *buf) | 85 | show_transport_handle(struct device *dev, struct device_attribute *attr, |
86 | char *buf) | ||
86 | { | 87 | { |
87 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); | 88 | struct iscsi_internal *priv = dev_to_iscsi_internal(dev); |
88 | return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); | 89 | return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); |
89 | } | 90 | } |
90 | static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); | 91 | static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); |
91 | 92 | ||
92 | #define show_transport_attr(name, format) \ | 93 | #define show_transport_attr(name, format) \ |
93 | static ssize_t \ | 94 | static ssize_t \ |
94 | show_transport_##name(struct class_device *cdev, char *buf) \ | 95 | show_transport_##name(struct device *dev, \ |
96 | struct device_attribute *attr,char *buf) \ | ||
95 | { \ | 97 | { \ |
96 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); \ | 98 | struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \ |
97 | return sprintf(buf, format"\n", priv->iscsi_transport->name); \ | 99 | return sprintf(buf, format"\n", priv->iscsi_transport->name); \ |
98 | } \ | 100 | } \ |
99 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); | 101 | static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); |
100 | 102 | ||
101 | show_transport_attr(caps, "0x%x"); | 103 | show_transport_attr(caps, "0x%x"); |
102 | show_transport_attr(max_lun, "%d"); | 104 | show_transport_attr(max_lun, "%d"); |
@@ -104,11 +106,11 @@ show_transport_attr(max_conn, "%d"); | |||
104 | show_transport_attr(max_cmd_len, "%d"); | 106 | show_transport_attr(max_cmd_len, "%d"); |
105 | 107 | ||
106 | static struct attribute *iscsi_transport_attrs[] = { | 108 | static struct attribute *iscsi_transport_attrs[] = { |
107 | &class_device_attr_handle.attr, | 109 | &dev_attr_handle.attr, |
108 | &class_device_attr_caps.attr, | 110 | &dev_attr_caps.attr, |
109 | &class_device_attr_max_lun.attr, | 111 | &dev_attr_max_lun.attr, |
110 | &class_device_attr_max_conn.attr, | 112 | &dev_attr_max_conn.attr, |
111 | &class_device_attr_max_cmd_len.attr, | 113 | &dev_attr_max_cmd_len.attr, |
112 | NULL, | 114 | NULL, |
113 | }; | 115 | }; |
114 | 116 | ||
@@ -119,7 +121,7 @@ static struct attribute_group iscsi_transport_group = { | |||
119 | 121 | ||
120 | 122 | ||
121 | static int iscsi_setup_host(struct transport_container *tc, struct device *dev, | 123 | static int iscsi_setup_host(struct transport_container *tc, struct device *dev, |
122 | struct class_device *cdev) | 124 | struct device *cdev) |
123 | { | 125 | { |
124 | struct Scsi_Host *shost = dev_to_shost(dev); | 126 | struct Scsi_Host *shost = dev_to_shost(dev); |
125 | struct iscsi_host *ihost = shost->shost_data; | 127 | struct iscsi_host *ihost = shost->shost_data; |
@@ -139,7 +141,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, | |||
139 | } | 141 | } |
140 | 142 | ||
141 | static int iscsi_remove_host(struct transport_container *tc, struct device *dev, | 143 | static int iscsi_remove_host(struct transport_container *tc, struct device *dev, |
142 | struct class_device *cdev) | 144 | struct device *cdev) |
143 | { | 145 | { |
144 | struct Scsi_Host *shost = dev_to_shost(dev); | 146 | struct Scsi_Host *shost = dev_to_shost(dev); |
145 | struct iscsi_host *ihost = shost->shost_data; | 147 | struct iscsi_host *ihost = shost->shost_data; |
@@ -1337,11 +1339,8 @@ iscsi_if_rx(struct sk_buff *skb) | |||
1337 | mutex_unlock(&rx_queue_mutex); | 1339 | mutex_unlock(&rx_queue_mutex); |
1338 | } | 1340 | } |
1339 | 1341 | ||
1340 | #define iscsi_cdev_to_conn(_cdev) \ | ||
1341 | iscsi_dev_to_conn(_cdev->dev) | ||
1342 | |||
1343 | #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ | 1342 | #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ |
1344 | struct class_device_attribute class_device_attr_##_prefix##_##_name = \ | 1343 | struct device_attribute dev_attr_##_prefix##_##_name = \ |
1345 | __ATTR(_name,_mode,_show,_store) | 1344 | __ATTR(_name,_mode,_show,_store) |
1346 | 1345 | ||
1347 | /* | 1346 | /* |
@@ -1349,9 +1348,10 @@ struct class_device_attribute class_device_attr_##_prefix##_##_name = \ | |||
1349 | */ | 1348 | */ |
1350 | #define iscsi_conn_attr_show(param) \ | 1349 | #define iscsi_conn_attr_show(param) \ |
1351 | static ssize_t \ | 1350 | static ssize_t \ |
1352 | show_conn_param_##param(struct class_device *cdev, char *buf) \ | 1351 | show_conn_param_##param(struct device *dev, \ |
1352 | struct device_attribute *attr, char *buf) \ | ||
1353 | { \ | 1353 | { \ |
1354 | struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ | 1354 | struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \ |
1355 | struct iscsi_transport *t = conn->transport; \ | 1355 | struct iscsi_transport *t = conn->transport; \ |
1356 | return t->get_conn_param(conn, param, buf); \ | 1356 | return t->get_conn_param(conn, param, buf); \ |
1357 | } | 1357 | } |
@@ -1375,17 +1375,16 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); | |||
1375 | iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); | 1375 | iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); |
1376 | iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); | 1376 | iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); |
1377 | 1377 | ||
1378 | #define iscsi_cdev_to_session(_cdev) \ | ||
1379 | iscsi_dev_to_session(_cdev->dev) | ||
1380 | |||
1381 | /* | 1378 | /* |
1382 | * iSCSI session attrs | 1379 | * iSCSI session attrs |
1383 | */ | 1380 | */ |
1384 | #define iscsi_session_attr_show(param, perm) \ | 1381 | #define iscsi_session_attr_show(param, perm) \ |
1385 | static ssize_t \ | 1382 | static ssize_t \ |
1386 | show_session_param_##param(struct class_device *cdev, char *buf) \ | 1383 | show_session_param_##param(struct device *dev, \ |
1384 | struct device_attribute *attr, char *buf) \ | ||
1387 | { \ | 1385 | { \ |
1388 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ | 1386 | struct iscsi_cls_session *session = \ |
1387 | iscsi_dev_to_session(dev->parent); \ | ||
1389 | struct iscsi_transport *t = session->transport; \ | 1388 | struct iscsi_transport *t = session->transport; \ |
1390 | \ | 1389 | \ |
1391 | if (perm && !capable(CAP_SYS_ADMIN)) \ | 1390 | if (perm && !capable(CAP_SYS_ADMIN)) \ |
@@ -1417,9 +1416,10 @@ iscsi_session_attr(abort_tmo, ISCSI_PARAM_ABORT_TMO, 0); | |||
1417 | iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); | 1416 | iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); |
1418 | 1417 | ||
1419 | static ssize_t | 1418 | static ssize_t |
1420 | show_priv_session_state(struct class_device *cdev, char *buf) | 1419 | show_priv_session_state(struct device *dev, struct device_attribute *attr, |
1420 | char *buf) | ||
1421 | { | 1421 | { |
1422 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); | 1422 | struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent); |
1423 | return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); | 1423 | return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); |
1424 | } | 1424 | } |
1425 | static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, | 1425 | static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, |
@@ -1427,9 +1427,11 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, | |||
1427 | 1427 | ||
1428 | #define iscsi_priv_session_attr_show(field, format) \ | 1428 | #define iscsi_priv_session_attr_show(field, format) \ |
1429 | static ssize_t \ | 1429 | static ssize_t \ |
1430 | show_priv_session_##field(struct class_device *cdev, char *buf) \ | 1430 | show_priv_session_##field(struct device *dev, \ |
1431 | struct device_attribute *attr, char *buf) \ | ||
1431 | { \ | 1432 | { \ |
1432 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\ | 1433 | struct iscsi_cls_session *session = \ |
1434 | iscsi_dev_to_session(dev->parent); \ | ||
1433 | return sprintf(buf, format"\n", session->field); \ | 1435 | return sprintf(buf, format"\n", session->field); \ |
1434 | } | 1436 | } |
1435 | 1437 | ||
@@ -1444,9 +1446,10 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); | |||
1444 | */ | 1446 | */ |
1445 | #define iscsi_host_attr_show(param) \ | 1447 | #define iscsi_host_attr_show(param) \ |
1446 | static ssize_t \ | 1448 | static ssize_t \ |
1447 | show_host_param_##param(struct class_device *cdev, char *buf) \ | 1449 | show_host_param_##param(struct device *dev, \ |
1450 | struct device_attribute *attr, char *buf) \ | ||
1448 | { \ | 1451 | { \ |
1449 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1452 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1450 | struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ | 1453 | struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ |
1451 | return priv->iscsi_transport->get_host_param(shost, param, buf); \ | 1454 | return priv->iscsi_transport->get_host_param(shost, param, buf); \ |
1452 | } | 1455 | } |
@@ -1463,7 +1466,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); | |||
1463 | 1466 | ||
1464 | #define SETUP_PRIV_SESSION_RD_ATTR(field) \ | 1467 | #define SETUP_PRIV_SESSION_RD_ATTR(field) \ |
1465 | do { \ | 1468 | do { \ |
1466 | priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \ | 1469 | priv->session_attrs[count] = &dev_attr_priv_sess_##field; \ |
1467 | count++; \ | 1470 | count++; \ |
1468 | } while (0) | 1471 | } while (0) |
1469 | 1472 | ||
@@ -1471,7 +1474,7 @@ do { \ | |||
1471 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ | 1474 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ |
1472 | do { \ | 1475 | do { \ |
1473 | if (tt->param_mask & param_flag) { \ | 1476 | if (tt->param_mask & param_flag) { \ |
1474 | priv->session_attrs[count] = &class_device_attr_sess_##field; \ | 1477 | priv->session_attrs[count] = &dev_attr_sess_##field; \ |
1475 | count++; \ | 1478 | count++; \ |
1476 | } \ | 1479 | } \ |
1477 | } while (0) | 1480 | } while (0) |
@@ -1479,7 +1482,7 @@ do { \ | |||
1479 | #define SETUP_CONN_RD_ATTR(field, param_flag) \ | 1482 | #define SETUP_CONN_RD_ATTR(field, param_flag) \ |
1480 | do { \ | 1483 | do { \ |
1481 | if (tt->param_mask & param_flag) { \ | 1484 | if (tt->param_mask & param_flag) { \ |
1482 | priv->conn_attrs[count] = &class_device_attr_conn_##field; \ | 1485 | priv->conn_attrs[count] = &dev_attr_conn_##field; \ |
1483 | count++; \ | 1486 | count++; \ |
1484 | } \ | 1487 | } \ |
1485 | } while (0) | 1488 | } while (0) |
@@ -1487,7 +1490,7 @@ do { \ | |||
1487 | #define SETUP_HOST_RD_ATTR(field, param_flag) \ | 1490 | #define SETUP_HOST_RD_ATTR(field, param_flag) \ |
1488 | do { \ | 1491 | do { \ |
1489 | if (tt->host_param_mask & param_flag) { \ | 1492 | if (tt->host_param_mask & param_flag) { \ |
1490 | priv->host_attrs[count] = &class_device_attr_host_##field; \ | 1493 | priv->host_attrs[count] = &dev_attr_host_##field; \ |
1491 | count++; \ | 1494 | count++; \ |
1492 | } \ | 1495 | } \ |
1493 | } while (0) | 1496 | } while (0) |
@@ -1578,15 +1581,15 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
1578 | priv->iscsi_transport = tt; | 1581 | priv->iscsi_transport = tt; |
1579 | priv->t.user_scan = iscsi_user_scan; | 1582 | priv->t.user_scan = iscsi_user_scan; |
1580 | 1583 | ||
1581 | priv->cdev.class = &iscsi_transport_class; | 1584 | priv->dev.class = &iscsi_transport_class; |
1582 | snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name); | 1585 | snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name); |
1583 | err = class_device_register(&priv->cdev); | 1586 | err = device_register(&priv->dev); |
1584 | if (err) | 1587 | if (err) |
1585 | goto free_priv; | 1588 | goto free_priv; |
1586 | 1589 | ||
1587 | err = sysfs_create_group(&priv->cdev.kobj, &iscsi_transport_group); | 1590 | err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group); |
1588 | if (err) | 1591 | if (err) |
1589 | goto unregister_cdev; | 1592 | goto unregister_dev; |
1590 | 1593 | ||
1591 | /* host parameters */ | 1594 | /* host parameters */ |
1592 | priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; | 1595 | priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; |
@@ -1663,8 +1666,8 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
1663 | printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); | 1666 | printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); |
1664 | return &priv->t; | 1667 | return &priv->t; |
1665 | 1668 | ||
1666 | unregister_cdev: | 1669 | unregister_dev: |
1667 | class_device_unregister(&priv->cdev); | 1670 | device_unregister(&priv->dev); |
1668 | free_priv: | 1671 | free_priv: |
1669 | kfree(priv); | 1672 | kfree(priv); |
1670 | return NULL; | 1673 | return NULL; |
@@ -1691,8 +1694,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) | |||
1691 | transport_container_unregister(&priv->session_cont); | 1694 | transport_container_unregister(&priv->session_cont); |
1692 | transport_container_unregister(&priv->t.host_attrs); | 1695 | transport_container_unregister(&priv->t.host_attrs); |
1693 | 1696 | ||
1694 | sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); | 1697 | sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group); |
1695 | class_device_unregister(&priv->cdev); | 1698 | device_unregister(&priv->dev); |
1696 | mutex_unlock(&rx_queue_mutex); | 1699 | mutex_unlock(&rx_queue_mutex); |
1697 | 1700 | ||
1698 | return 0; | 1701 | return 0; |