aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ipath/ipath_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_sysfs.c')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index e299148c4b..182de34f9f 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -257,7 +257,7 @@ static ssize_t store_guid(struct device *dev,
257 struct ipath_devdata *dd = dev_get_drvdata(dev); 257 struct ipath_devdata *dd = dev_get_drvdata(dev);
258 ssize_t ret; 258 ssize_t ret;
259 unsigned short guid[8]; 259 unsigned short guid[8];
260 __be64 nguid; 260 __be64 new_guid;
261 u8 *ng; 261 u8 *ng;
262 int i; 262 int i;
263 263
@@ -266,7 +266,7 @@ static ssize_t store_guid(struct device *dev,
266 &guid[4], &guid[5], &guid[6], &guid[7]) != 8) 266 &guid[4], &guid[5], &guid[6], &guid[7]) != 8)
267 goto invalid; 267 goto invalid;
268 268
269 ng = (u8 *) &nguid; 269 ng = (u8 *) &new_guid;
270 270
271 for (i = 0; i < 8; i++) { 271 for (i = 0; i < 8; i++) {
272 if (guid[i] > 0xff) 272 if (guid[i] > 0xff)
@@ -274,7 +274,10 @@ static ssize_t store_guid(struct device *dev,
274 ng[i] = guid[i]; 274 ng[i] = guid[i];
275 } 275 }
276 276
277 dd->ipath_guid = nguid; 277 if (new_guid == 0)
278 goto invalid;
279
280 dd->ipath_guid = new_guid;
278 dd->ipath_nguid = 1; 281 dd->ipath_nguid = 1;
279 282
280 ret = strlen(buf); 283 ret = strlen(buf);
@@ -297,6 +300,16 @@ static ssize_t show_nguid(struct device *dev,
297 return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_nguid); 300 return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_nguid);
298} 301}
299 302
303static ssize_t show_nports(struct device *dev,
304 struct device_attribute *attr,
305 char *buf)
306{
307 struct ipath_devdata *dd = dev_get_drvdata(dev);
308
309 /* Return the number of user ports available. */
310 return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_cfgports - 1);
311}
312
300static ssize_t show_serial(struct device *dev, 313static ssize_t show_serial(struct device *dev,
301 struct device_attribute *attr, 314 struct device_attribute *attr,
302 char *buf) 315 char *buf)
@@ -608,6 +621,7 @@ static DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid);
608static DEVICE_ATTR(mtu, S_IWUSR | S_IRUGO, show_mtu, store_mtu); 621static DEVICE_ATTR(mtu, S_IWUSR | S_IRUGO, show_mtu, store_mtu);
609static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, show_enabled, store_enabled); 622static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, show_enabled, store_enabled);
610static DEVICE_ATTR(nguid, S_IRUGO, show_nguid, NULL); 623static DEVICE_ATTR(nguid, S_IRUGO, show_nguid, NULL);
624static DEVICE_ATTR(nports, S_IRUGO, show_nports, NULL);
611static DEVICE_ATTR(reset, S_IWUSR, NULL, store_reset); 625static DEVICE_ATTR(reset, S_IWUSR, NULL, store_reset);
612static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL); 626static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL);
613static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); 627static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
@@ -623,6 +637,7 @@ static struct attribute *dev_attributes[] = {
623 &dev_attr_mlid.attr, 637 &dev_attr_mlid.attr,
624 &dev_attr_mtu.attr, 638 &dev_attr_mtu.attr,
625 &dev_attr_nguid.attr, 639 &dev_attr_nguid.attr,
640 &dev_attr_nports.attr,
626 &dev_attr_serial.attr, 641 &dev_attr_serial.attr,
627 &dev_attr_status.attr, 642 &dev_attr_status.attr,
628 &dev_attr_status_str.attr, 643 &dev_attr_status_str.attr,