sysfs.c (1c7fd72687d619207e0f075dd1f1c749879d8021) sysfs.c (45808361d4491217de11cdf0661d657081f8f422)
1/*
2 * Copyright(c) 2015-2017 Intel Corporation.
3 *
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *

--- 496 unchanged lines hidden (view full) ---

505static DEVICE_ATTR_RO(hw_rev);
506
507static ssize_t board_id_show(struct device *device,
508 struct device_attribute *attr, char *buf)
509{
510 struct hfi1_ibdev *dev =
511 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
512 struct hfi1_devdata *dd = dd_from_dev(dev);
1/*
2 * Copyright(c) 2015-2017 Intel Corporation.
3 *
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *

--- 496 unchanged lines hidden (view full) ---

505static DEVICE_ATTR_RO(hw_rev);
506
507static ssize_t board_id_show(struct device *device,
508 struct device_attribute *attr, char *buf)
509{
510 struct hfi1_ibdev *dev =
511 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
512 struct hfi1_devdata *dd = dd_from_dev(dev);
513 int ret;
514
515 if (!dd->boardname)
513
514 if (!dd->boardname)
516 ret = -EINVAL;
517 else
518 ret = sysfs_emit(buf, "%s\n", dd->boardname);
519 return ret;
515 return -EINVAL;
516
517 return sysfs_emit(buf, "%s\n", dd->boardname);
520}
521static DEVICE_ATTR_RO(board_id);
522
523static ssize_t boardversion_show(struct device *device,
524 struct device_attribute *attr, char *buf)
525{
526 struct hfi1_ibdev *dev =
527 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);

--- 37 unchanged lines hidden (view full) ---

565
566static ssize_t serial_show(struct device *device,
567 struct device_attribute *attr, char *buf)
568{
569 struct hfi1_ibdev *dev =
570 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
571 struct hfi1_devdata *dd = dd_from_dev(dev);
572
518}
519static DEVICE_ATTR_RO(board_id);
520
521static ssize_t boardversion_show(struct device *device,
522 struct device_attribute *attr, char *buf)
523{
524 struct hfi1_ibdev *dev =
525 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);

--- 37 unchanged lines hidden (view full) ---

563
564static ssize_t serial_show(struct device *device,
565 struct device_attribute *attr, char *buf)
566{
567 struct hfi1_ibdev *dev =
568 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
569 struct hfi1_devdata *dd = dd_from_dev(dev);
570
571 /* dd->serial is already newline terminated in chip.c */
573 return sysfs_emit(buf, "%s", dd->serial);
574}
575static DEVICE_ATTR_RO(serial);
576
577static ssize_t chip_reset_store(struct device *device,
578 struct device_attribute *attr, const char *buf,
579 size_t count)
580{

--- 12 unchanged lines hidden (view full) ---

593 return ret < 0 ? ret : count;
594}
595static DEVICE_ATTR_WO(chip_reset);
596
597/*
598 * Convert the reported temperature from an integer (reported in
599 * units of 0.25C) to a floating point number.
600 */
572 return sysfs_emit(buf, "%s", dd->serial);
573}
574static DEVICE_ATTR_RO(serial);
575
576static ssize_t chip_reset_store(struct device *device,
577 struct device_attribute *attr, const char *buf,
578 size_t count)
579{

--- 12 unchanged lines hidden (view full) ---

592 return ret < 0 ? ret : count;
593}
594static DEVICE_ATTR_WO(chip_reset);
595
596/*
597 * Convert the reported temperature from an integer (reported in
598 * units of 0.25C) to a floating point number.
599 */
601#define temp2str(temp, buf, size, idx) \
602 scnprintf((buf) + (idx), (size) - (idx), "%u.%02u ", \
603 ((temp) >> 2), ((temp) & 0x3) * 25)
600#define temp_d(t) ((t) >> 2)
601#define temp_f(t) (((t)&0x3) * 25u)
604
605/*
606 * Dump tempsense values, in decimal, to ease shell-scripts.
607 */
608static ssize_t tempsense_show(struct device *device,
609 struct device_attribute *attr, char *buf)
610{
611 struct hfi1_ibdev *dev =
612 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
613 struct hfi1_devdata *dd = dd_from_dev(dev);
614 struct hfi1_temp temp;
615 int ret;
616
617 ret = hfi1_tempsense_rd(dd, &temp);
602
603/*
604 * Dump tempsense values, in decimal, to ease shell-scripts.
605 */
606static ssize_t tempsense_show(struct device *device,
607 struct device_attribute *attr, char *buf)
608{
609 struct hfi1_ibdev *dev =
610 rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
611 struct hfi1_devdata *dd = dd_from_dev(dev);
612 struct hfi1_temp temp;
613 int ret;
614
615 ret = hfi1_tempsense_rd(dd, &temp);
618 if (!ret) {
619 int idx = 0;
616 if (ret)
617 return ret;
620
618
621 idx += temp2str(temp.curr, buf, PAGE_SIZE, idx);
622 idx += temp2str(temp.lo_lim, buf, PAGE_SIZE, idx);
623 idx += temp2str(temp.hi_lim, buf, PAGE_SIZE, idx);
624 idx += temp2str(temp.crit_lim, buf, PAGE_SIZE, idx);
625 idx += scnprintf(buf + idx, PAGE_SIZE - idx,
626 "%u %u %u\n", temp.triggers & 0x1,
627 temp.triggers & 0x2, temp.triggers & 0x4);
628 ret = idx;
629 }
630 return ret;
619 return sysfs_emit(buf, "%u.%02u %u.%02u %u.%02u %u.%02u %u %u %u\n",
620 temp_d(temp.curr), temp_f(temp.curr),
621 temp_d(temp.lo_lim), temp_f(temp.lo_lim),
622 temp_d(temp.hi_lim), temp_f(temp.hi_lim),
623 temp_d(temp.crit_lim), temp_f(temp.crit_lim),
624 temp.triggers & 0x1,
625 temp.triggers & 0x2,
626 temp.triggers & 0x4);
631}
632static DEVICE_ATTR_RO(tempsense);
633
634/*
635 * end of per-unit (or driver, in some cases, but replicated
636 * per unit) functions
637 */
638

--- 256 unchanged lines hidden ---
627}
628static DEVICE_ATTR_RO(tempsense);
629
630/*
631 * end of per-unit (or driver, in some cases, but replicated
632 * per unit) functions
633 */
634

--- 256 unchanged lines hidden ---