blob: 4af8e29ed996a303cc6226609443fa864c1e26b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package pm
import (
"fmt"
)
// Reader reads the pin configuration from a source.
type Reader interface {
Name() string
Read(key string, arg string) (*Pins, error)
}
// readerlist is registered list of readers.
var readerList []Reader
// ReadPins will use the selected reader and the key to
// read the EC pin data.
func ReadPins(reader, key, arg string) (*Pins, error) {
for _, r := range readerList {
if r.Name() == reader {
return r.Read(key, arg)
}
}
return nil, fmt.Errorf("%s: unknown reader", reader)
}
// Readers returns a list of the reader names.
func Readers() []string {
var l []string
for _, r := range readerList {
l = append(l, r.Name())
}
return l
}
// RegisterReader will add this reader to the registered list of readers.
func RegisterReader(reader Reader) {
readerList = append(readerList, reader)
}
|