mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
![Bart Van Assche](/assets/img/avatar_default.png)
struct device supports attribute groups directly but does not support struct device_attribute directly. Hence switch to attribute groups. Link: https://lore.kernel.org/r/20211012233558.4066756-39-bvanassche@acm.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* QLogic iSCSI Offload Driver
|
|
* Copyright (c) 2016 Cavium Inc.
|
|
*/
|
|
|
|
#include "qedi.h"
|
|
#include "qedi_gbl.h"
|
|
#include "qedi_iscsi.h"
|
|
#include "qedi_dbg.h"
|
|
|
|
static inline struct qedi_ctx *qedi_dev_to_hba(struct device *dev)
|
|
{
|
|
struct Scsi_Host *shost = class_to_shost(dev);
|
|
|
|
return iscsi_host_priv(shost);
|
|
}
|
|
|
|
static ssize_t port_state_show(struct device *dev,
|
|
struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
|
|
|
|
if (atomic_read(&qedi->link_state) == QEDI_LINK_UP)
|
|
return sprintf(buf, "Online\n");
|
|
else
|
|
return sprintf(buf, "Linkdown\n");
|
|
}
|
|
|
|
static ssize_t speed_show(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
|
|
struct qed_link_output if_link;
|
|
|
|
qedi_ops->common->get_link(qedi->cdev, &if_link);
|
|
|
|
return sprintf(buf, "%d Gbit\n", if_link.speed / 1000);
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(port_state);
|
|
static DEVICE_ATTR_RO(speed);
|
|
|
|
static struct attribute *qedi_shost_attrs[] = {
|
|
&dev_attr_port_state.attr,
|
|
&dev_attr_speed.attr,
|
|
NULL
|
|
};
|
|
|
|
static const struct attribute_group qedi_shost_attr_group = {
|
|
.attrs = qedi_shost_attrs
|
|
};
|
|
|
|
const struct attribute_group *qedi_shost_groups[] = {
|
|
&qedi_shost_attr_group,
|
|
NULL
|
|
};
|