Skip to content

Commit 5b3acff

Browse files
committed
boardinfo: Add sysfs for board id.
Change-Id: I80e35ef7ddf2afa5a9ab55104a00dd1b20dfbb03
1 parent d99c3aa commit 5b3acff

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

drivers/boardinfo/boardinfo.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ static int info_show(struct seq_file *m, void *v)
7575
return 0;
7676
}
7777

78+
static int bid_show(struct seq_file *m, void *v)
79+
{
80+
int id0, id1, id2;
81+
int hwid = -1;
82+
83+
id0 = gpio_get_value(hw_id0);
84+
id1 = gpio_get_value(hw_id1);
85+
id2 = gpio_get_value(hw_id2);
86+
87+
hwid = (id2 << 2) + (id1 << 1) + id0;
88+
89+
seq_printf(m, "%d\n", hwid);
90+
return 0;
91+
}
92+
7893
static int pid_show(struct seq_file *m, void *v)
7994
{
8095
int id0, id1, id2;
@@ -125,6 +140,11 @@ static int info_open(struct inode *inode, struct file *file)
125140
return single_open(file, info_show, NULL);
126141
}
127142

143+
static int bid_open(struct inode *inode, struct file *file)
144+
{
145+
return single_open(file, bid_show, NULL);
146+
}
147+
128148
static int pid_open(struct inode *inode, struct file *file)
129149
{
130150
return single_open(file, pid_show, NULL);
@@ -147,6 +167,12 @@ static struct file_operations boardinfo_ops = {
147167
.read = seq_read,
148168
};
149169

170+
static struct file_operations boardid_ops = {
171+
.owner = THIS_MODULE,
172+
.open = bid_open,
173+
.read = seq_read,
174+
};
175+
150176
static struct file_operations projectid_ops = {
151177
.owner = THIS_MODULE,
152178
.open = pid_open,
@@ -293,6 +319,10 @@ static int board_info_probe(struct platform_device *pdev)
293319
if (!file)
294320
return -ENOMEM;
295321

322+
file = proc_create("boardid", 0444, NULL, &boardid_ops);
323+
if (!file)
324+
return -ENOMEM;
325+
296326
file = proc_create("projectid", 0444, NULL, &projectid_ops);
297327
if (!file)
298328
return -ENOMEM;

0 commit comments

Comments
 (0)