Skip to content

Commit 0494ccb

Browse files
author
Andrey Shvetsov
committed
staging: most: dim2: add sysfs property dci/ni_state
This adds the read only sysfs property "NetInterface status" of the DIM2 device. Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
1 parent 3a840d7 commit 0494ccb

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

drivers/staging/most/hdm-dim2/dim2_hdm.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ struct hdm_channel {
8585
* @netinfo_waitq: waitq for the thread to sleep
8686
* @deliver_netinfo: to identify whether network status received
8787
* @mac_addrs: INIC mac address
88-
* @link_state: network link state
8988
* @atx_idx: index of async tx channel
9089
*/
9190
struct dim2_hdm {
@@ -101,7 +100,6 @@ struct dim2_hdm {
101100
wait_queue_head_t netinfo_waitq;
102101
int deliver_netinfo;
103102
unsigned char mac_addrs[6];
104-
unsigned char link_state;
105103
int atx_idx;
106104
struct medialb_bus *bus;
107105
struct medialb_dci *dci;
@@ -236,7 +234,7 @@ static int deliver_netinfo_thread(void *data)
236234
dev->deliver_netinfo--;
237235
if (dev->on_netinfo) {
238236
dev->on_netinfo(&dev->most_iface,
239-
dev->link_state,
237+
dev->dci->ni_state,
240238
dev->mac_addrs);
241239
}
242240
}
@@ -258,11 +256,10 @@ static void retrieve_netinfo(struct dim2_hdm *dev, struct mbo *mbo)
258256
u8 *data = mbo->virt_address;
259257

260258
mutex_lock(&dev->dci->mt);
259+
dev->dci->ni_state = data[18];
261260
dev->dci->node_position = data[11];
262261
dev->dci->node_address = (u16)data[16] << 8 | data[17];
263262
mutex_unlock(&dev->dci->mt);
264-
dev->link_state = data[18];
265-
pr_info("NIState: %d\n", dev->link_state);
266263
memcpy(dev->mac_addrs, data + 19, 6);
267264
dev->deliver_netinfo++;
268265
wake_up_interruptible(&dev->netinfo_waitq);

drivers/staging/most/hdm-dim2/dim2_sysfs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ struct dci_attr {
9090
ssize_t (*show)(struct medialb_dci *dci, char *buf);
9191
};
9292

93+
static ssize_t ni_state_show(struct medialb_dci *dci, char *buf)
94+
{
95+
return sprintf(buf, "%d\n", dci->ni_state);
96+
}
97+
9398
static ssize_t node_position_show(struct medialb_dci *dci, char *buf)
9499
{
95100
return sprintf(buf, "%d\n", dci->node_position);
@@ -101,13 +106,15 @@ static ssize_t node_address_show(struct medialb_dci *dci, char *buf)
101106
}
102107

103108
static struct dci_attr dci_attrs[] = {
109+
__ATTR_RO(ni_state),
104110
__ATTR_RO(node_position),
105111
__ATTR_RO(node_address),
106112
};
107113

108114
static struct attribute *dci_default_attrs[] = {
109115
&dci_attrs[0].attr,
110116
&dci_attrs[1].attr,
117+
&dci_attrs[2].attr,
111118
NULL,
112119
};
113120

drivers/staging/most/hdm-dim2/dim2_sysfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
struct medialb_dci {
2323
struct kobject kobj_group;
2424
struct mutex mt; /* build vs show */
25+
u8 ni_state;
2526
u8 node_position;
2627
u16 node_address;
2728
};

0 commit comments

Comments
 (0)