aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorTony Jones <tonyj@suse.de>2008-02-21 18:13:36 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-19 22:10:33 -0400
commitee959b00c335d7780136c5abda37809191fe52c3 (patch)
tree7775f3b274fd8caf5e7e5154fea89e96f2babd94 /drivers/infiniband
parent56d110e852b0b1c85ad6c9bfe1cb4473ceb16402 (diff)
SCSI: convert struct class_device to struct device
It's big, but there doesn't seem to be a way to split it up smaller... Signed-off-by: Tony Jones <tonyj@suse.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Cc: Roland Dreier <rolandd@cisco.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: Hal Rosenstock <hal.rosenstock@gmail.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c132
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h2
2 files changed, 72 insertions, 62 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 99a110660040..435145709dd6 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1458,9 +1458,10 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
1458 return ret; 1458 return ret;
1459} 1459}
1460 1460
1461static ssize_t show_id_ext(struct class_device *cdev, char *buf) 1461static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
1462 char *buf)
1462{ 1463{
1463 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1464 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1464 1465
1465 if (target->state == SRP_TARGET_DEAD || 1466 if (target->state == SRP_TARGET_DEAD ||
1466 target->state == SRP_TARGET_REMOVED) 1467 target->state == SRP_TARGET_REMOVED)
@@ -1470,9 +1471,10 @@ static ssize_t show_id_ext(struct class_device *cdev, char *buf)
1470 (unsigned long long) be64_to_cpu(target->id_ext)); 1471 (unsigned long long) be64_to_cpu(target->id_ext));
1471} 1472}
1472 1473
1473static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) 1474static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr,
1475 char *buf)
1474{ 1476{
1475 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1477 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1476 1478
1477 if (target->state == SRP_TARGET_DEAD || 1479 if (target->state == SRP_TARGET_DEAD ||
1478 target->state == SRP_TARGET_REMOVED) 1480 target->state == SRP_TARGET_REMOVED)
@@ -1482,9 +1484,10 @@ static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
1482 (unsigned long long) be64_to_cpu(target->ioc_guid)); 1484 (unsigned long long) be64_to_cpu(target->ioc_guid));
1483} 1485}
1484 1486
1485static ssize_t show_service_id(struct class_device *cdev, char *buf) 1487static ssize_t show_service_id(struct device *dev,
1488 struct device_attribute *attr, char *buf)
1486{ 1489{
1487 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1490 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1488 1491
1489 if (target->state == SRP_TARGET_DEAD || 1492 if (target->state == SRP_TARGET_DEAD ||
1490 target->state == SRP_TARGET_REMOVED) 1493 target->state == SRP_TARGET_REMOVED)
@@ -1494,9 +1497,10 @@ static ssize_t show_service_id(struct class_device *cdev, char *buf)
1494 (unsigned long long) be64_to_cpu(target->service_id)); 1497 (unsigned long long) be64_to_cpu(target->service_id));
1495} 1498}
1496 1499
1497static ssize_t show_pkey(struct class_device *cdev, char *buf) 1500static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
1501 char *buf)
1498{ 1502{
1499 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1503 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1500 1504
1501 if (target->state == SRP_TARGET_DEAD || 1505 if (target->state == SRP_TARGET_DEAD ||
1502 target->state == SRP_TARGET_REMOVED) 1506 target->state == SRP_TARGET_REMOVED)
@@ -1505,9 +1509,10 @@ static ssize_t show_pkey(struct class_device *cdev, char *buf)
1505 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); 1509 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
1506} 1510}
1507 1511
1508static ssize_t show_dgid(struct class_device *cdev, char *buf) 1512static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
1513 char *buf)
1509{ 1514{
1510 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1515 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1511 1516
1512 if (target->state == SRP_TARGET_DEAD || 1517 if (target->state == SRP_TARGET_DEAD ||
1513 target->state == SRP_TARGET_REMOVED) 1518 target->state == SRP_TARGET_REMOVED)
@@ -1524,9 +1529,10 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf)
1524 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); 1529 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
1525} 1530}
1526 1531
1527static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) 1532static ssize_t show_orig_dgid(struct device *dev,
1533 struct device_attribute *attr, char *buf)
1528{ 1534{
1529 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1535 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1530 1536
1531 if (target->state == SRP_TARGET_DEAD || 1537 if (target->state == SRP_TARGET_DEAD ||
1532 target->state == SRP_TARGET_REMOVED) 1538 target->state == SRP_TARGET_REMOVED)
@@ -1543,9 +1549,10 @@ static ssize_t show_orig_dgid(struct class_device *cdev, char *buf)
1543 be16_to_cpu(target->orig_dgid[7])); 1549 be16_to_cpu(target->orig_dgid[7]));
1544} 1550}
1545 1551
1546static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) 1552static ssize_t show_zero_req_lim(struct device *dev,
1553 struct device_attribute *attr, char *buf)
1547{ 1554{
1548 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1555 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1549 1556
1550 if (target->state == SRP_TARGET_DEAD || 1557 if (target->state == SRP_TARGET_DEAD ||
1551 target->state == SRP_TARGET_REMOVED) 1558 target->state == SRP_TARGET_REMOVED)
@@ -1554,40 +1561,42 @@ static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
1554 return sprintf(buf, "%d\n", target->zero_req_lim); 1561 return sprintf(buf, "%d\n", target->zero_req_lim);
1555} 1562}
1556 1563
1557static ssize_t show_local_ib_port(struct class_device *cdev, char *buf) 1564static ssize_t show_local_ib_port(struct device *dev,
1565 struct device_attribute *attr, char *buf)
1558{ 1566{
1559 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1567 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1560 1568
1561 return sprintf(buf, "%d\n", target->srp_host->port); 1569 return sprintf(buf, "%d\n", target->srp_host->port);
1562} 1570}
1563 1571
1564static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) 1572static ssize_t show_local_ib_device(struct device *dev,
1573 struct device_attribute *attr, char *buf)
1565{ 1574{
1566 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1575 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1567 1576
1568 return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name); 1577 return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name);
1569} 1578}
1570 1579
1571static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); 1580static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
1572static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); 1581static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
1573static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); 1582static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
1574static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 1583static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
1575static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); 1584static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
1576static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); 1585static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
1577static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); 1586static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
1578static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); 1587static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
1579static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); 1588static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
1580 1589
1581static struct class_device_attribute *srp_host_attrs[] = { 1590static struct device_attribute *srp_host_attrs[] = {
1582 &class_device_attr_id_ext, 1591 &dev_attr_id_ext,
1583 &class_device_attr_ioc_guid, 1592 &dev_attr_ioc_guid,
1584 &class_device_attr_service_id, 1593 &dev_attr_service_id,
1585 &class_device_attr_pkey, 1594 &dev_attr_pkey,
1586 &class_device_attr_dgid, 1595 &dev_attr_dgid,
1587 &class_device_attr_orig_dgid, 1596 &dev_attr_orig_dgid,
1588 &class_device_attr_zero_req_lim, 1597 &dev_attr_zero_req_lim,
1589 &class_device_attr_local_ib_port, 1598 &dev_attr_local_ib_port,
1590 &class_device_attr_local_ib_device, 1599 &dev_attr_local_ib_device,
1591 NULL 1600 NULL
1592}; 1601};
1593 1602
@@ -1639,17 +1648,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1639 return 0; 1648 return 0;
1640} 1649}
1641 1650
1642static void srp_release_class_dev(struct class_device *class_dev) 1651static void srp_release_dev(struct device *dev)
1643{ 1652{
1644 struct srp_host *host = 1653 struct srp_host *host =
1645 container_of(class_dev, struct srp_host, class_dev); 1654 container_of(dev, struct srp_host, dev);
1646 1655
1647 complete(&host->released); 1656 complete(&host->released);
1648} 1657}
1649 1658
1650static struct class srp_class = { 1659static struct class srp_class = {
1651 .name = "infiniband_srp", 1660 .name = "infiniband_srp",
1652 .release = srp_release_class_dev 1661 .dev_release = srp_release_dev
1653}; 1662};
1654 1663
1655/* 1664/*
@@ -1837,11 +1846,12 @@ out:
1837 return ret; 1846 return ret;
1838} 1847}
1839 1848
1840static ssize_t srp_create_target(struct class_device *class_dev, 1849static ssize_t srp_create_target(struct device *dev,
1850 struct device_attribute *attr,
1841 const char *buf, size_t count) 1851 const char *buf, size_t count)
1842{ 1852{
1843 struct srp_host *host = 1853 struct srp_host *host =
1844 container_of(class_dev, struct srp_host, class_dev); 1854 container_of(dev, struct srp_host, dev);
1845 struct Scsi_Host *target_host; 1855 struct Scsi_Host *target_host;
1846 struct srp_target_port *target; 1856 struct srp_target_port *target;
1847 int ret; 1857 int ret;
@@ -1929,27 +1939,27 @@ err:
1929 return ret; 1939 return ret;
1930} 1940}
1931 1941
1932static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); 1942static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target);
1933 1943
1934static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1944static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
1945 char *buf)
1935{ 1946{
1936 struct srp_host *host = 1947 struct srp_host *host = container_of(dev, struct srp_host, dev);
1937 container_of(class_dev, struct srp_host, class_dev);
1938 1948
1939 return sprintf(buf, "%s\n", host->srp_dev->dev->name); 1949 return sprintf(buf, "%s\n", host->srp_dev->dev->name);
1940} 1950}
1941 1951
1942static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1952static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
1943 1953
1944static ssize_t show_port(struct class_device *class_dev, char *buf) 1954static ssize_t show_port(struct device *dev, struct device_attribute *attr,
1955 char *buf)
1945{ 1956{
1946 struct srp_host *host = 1957 struct srp_host *host = container_of(dev, struct srp_host, dev);
1947 container_of(class_dev, struct srp_host, class_dev);
1948 1958
1949 return sprintf(buf, "%d\n", host->port); 1959 return sprintf(buf, "%d\n", host->port);
1950} 1960}
1951 1961
1952static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 1962static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
1953 1963
1954static struct srp_host *srp_add_port(struct srp_device *device, u8 port) 1964static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1955{ 1965{
@@ -1965,24 +1975,24 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1965 host->srp_dev = device; 1975 host->srp_dev = device;
1966 host->port = port; 1976 host->port = port;
1967 1977
1968 host->class_dev.class = &srp_class; 1978 host->dev.class = &srp_class;
1969 host->class_dev.dev = device->dev->dma_device; 1979 host->dev.parent = device->dev->dma_device;
1970 snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", 1980 snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d",
1971 device->dev->name, port); 1981 device->dev->name, port);
1972 1982
1973 if (class_device_register(&host->class_dev)) 1983 if (device_register(&host->dev))
1974 goto free_host; 1984 goto free_host;
1975 if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) 1985 if (device_create_file(&host->dev, &dev_attr_add_target))
1976 goto err_class; 1986 goto err_class;
1977 if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) 1987 if (device_create_file(&host->dev, &dev_attr_ibdev))
1978 goto err_class; 1988 goto err_class;
1979 if (class_device_create_file(&host->class_dev, &class_device_attr_port)) 1989 if (device_create_file(&host->dev, &dev_attr_port))
1980 goto err_class; 1990 goto err_class;
1981 1991
1982 return host; 1992 return host;
1983 1993
1984err_class: 1994err_class:
1985 class_device_unregister(&host->class_dev); 1995 device_unregister(&host->dev);
1986 1996
1987free_host: 1997free_host:
1988 kfree(host); 1998 kfree(host);
@@ -2087,7 +2097,7 @@ static void srp_remove_one(struct ib_device *device)
2087 srp_dev = ib_get_client_data(device, &srp_client); 2097 srp_dev = ib_get_client_data(device, &srp_client);
2088 2098
2089 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { 2099 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
2090 class_device_unregister(&host->class_dev); 2100 device_unregister(&host->dev);
2091 /* 2101 /*
2092 * Wait for the sysfs entry to go away, so that no new 2102 * Wait for the sysfs entry to go away, so that no new
2093 * target ports can be created. 2103 * target ports can be created.
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 67e17c336a50..63d2ae724061 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -99,7 +99,7 @@ struct srp_device {
99struct srp_host { 99struct srp_host {
100 struct srp_device *srp_dev; 100 struct srp_device *srp_dev;
101 u8 port; 101 u8 port;
102 struct class_device class_dev; 102 struct device dev;
103 struct list_head target_list; 103 struct list_head target_list;
104 spinlock_t target_lock; 104 spinlock_t target_lock;
105 struct completion released; 105 struct completion released;