Skip to content

Commit 32707ec

Browse files
ConnorRigbyfhunleth
authored andcommitted
rename info to identifiers
Signed-off-by: Connor Rigby <[email protected]>
1 parent 26f81fd commit 32707ec

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

lib/gpio.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ defmodule Circuits.GPIO do
118118
or be more helpful that the `:location`. It may be passed to `GPIO.open/3`.
119119
* `:controller` - the name or an alias for the GPIO controller. Empty string if unused
120120
"""
121-
@type info() :: %{
121+
@type identifiers() :: %{
122122
location: {controller(), non_neg_integer()},
123123
controller: controller(),
124124
label: label()
@@ -186,11 +186,11 @@ defmodule Circuits.GPIO do
186186
See `t:gpio_spec/0` for the ways of referring to GPIOs. If the GPIO is found,
187187
this function returns information about the GPIO.
188188
"""
189-
@spec info(gpio_spec()) :: {:ok, info()} | {:error, atom()}
190-
def info(gpio_spec) do
189+
@spec identifiers(gpio_spec()) :: {:ok, identifiers()} | {:error, atom()}
190+
def identifiers(gpio_spec) do
191191
{backend, backend_defaults} = default_backend()
192192

193-
backend.gpio_info(gpio_spec, backend_defaults)
193+
backend.gpio_identifiers(gpio_spec, backend_defaults)
194194
end
195195

196196
@doc """
@@ -225,7 +225,7 @@ defmodule Circuits.GPIO do
225225
226226
Returns `{:ok, handle}` on success.
227227
"""
228-
@spec open(gpio_spec() | info(), direction(), open_options()) ::
228+
@spec open(gpio_spec() | identifiers(), direction(), open_options()) ::
229229
{:ok, Handle.t()} | {:error, atom()}
230230
def open(gpio_spec_or_line_info, direction, options \\ [])
231231

@@ -401,7 +401,7 @@ defmodule Circuits.GPIO do
401401
itself can also be passed to `open/3` and the function will figure out how to
402402
access the GPIO.
403403
"""
404-
@spec enumerate(backend() | nil) :: [info()]
404+
@spec enumerate(backend() | nil) :: [identifiers()]
405405
def enumerate(backend \\ nil)
406406
def enumerate(nil), do: enumerate(default_backend())
407407
def enumerate({backend, options}), do: backend.enumerate(options)

lib/gpio/backend.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ defmodule Circuits.GPIO.Backend do
1212
@doc """
1313
Return a list of GPIOs
1414
15-
See `t:GPIO.gpio_info/0` for the information that is returned. The `options` contain
15+
See `t:GPIO.identifiers/0` for the information that is returned. The `options` contain
1616
backend-specific options to help with enumeration.
1717
"""
18-
@callback enumerate(options :: GPIO.open_options()) :: [GPIO.info()]
18+
@callback enumerate(options :: GPIO.open_options()) :: [GPIO.identifiers()]
1919

2020
@doc """
21-
Return information about a GPIO
21+
Return identifying information about a GPIO
2222
2323
See `t:gpio_spec/0` for the ways of referring to GPIOs. The `options` contain
2424
backend-specific options to help enumerating GPIOs.
2525
2626
If the GPIO is found, this function returns information about the GPIO.
2727
"""
28-
@callback gpio_info(
28+
@callback gpio_identifiers(
2929
gpio_spec :: GPIO.gpio_spec(),
3030
options :: GPIO.open_options()
31-
) :: {:ok, GPIO.info()} | {:error, atom()}
31+
) :: {:ok, GPIO.identifiers()} | {:error, atom()}
3232

3333
@doc """
3434
Return a GPIO's current status
3535
3636
This function returns how a GPIO is configured. The GPIO doesn't need to be
37-
opened. It's different from `gpio_info/2` since it returns dynamic information
38-
whereas `gpio_info/2` only returns information about how to refer to a GPIO
37+
opened. It's different from `gpio_identifiers/2` since it returns dynamic information
38+
whereas `gpio_identifiers/2` only returns information about how to refer to a GPIO
3939
and where it exists in the system.
4040
4141
See `t:gpio_spec/0` for the ways of referring to GPIOs. The `options` contain

lib/gpio/cdev.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@ defmodule Circuits.GPIO.CDev do
7070
end
7171

7272
@impl Backend
73-
def gpio_info(number, options) when is_integer(number) and number >= 0 do
73+
def gpio_identifiers(number, options) when is_integer(number) and number >= 0 do
7474
retry_find(options, &find_by_index(&1, number))
7575
end
7676

77-
def gpio_info(line_label, options) when is_binary(line_label) do
77+
def gpio_identifiers(line_label, options) when is_binary(line_label) do
7878
retry_find(options, &find_by_label(&1, line_label))
7979
end
8080

81-
def gpio_info(tuple_spec, options)
81+
def gpio_identifiers(tuple_spec, options)
8282
when is_tuple(tuple_spec) and tuple_size(tuple_spec) == 2 do
8383
retry_find(options, &find_by_tuple(&1, tuple_spec))
8484
end
8585

86-
def gpio_info(_gpio_spec, _options) do
86+
def gpio_identifiers(_gpio_spec, _options) do
8787
{:error, :not_found}
8888
end
8989

@@ -101,8 +101,8 @@ defmodule Circuits.GPIO.CDev do
101101
end
102102

103103
defp find_location(gpio_spec, options) do
104-
with {:ok, gpio_info} <- gpio_info(gpio_spec, options) do
105-
{:ok, gpio_info.location}
104+
with {:ok, identifiers} <- gpio_identifiers(gpio_spec, options) do
105+
{:ok, identifiers.location}
106106
end
107107
end
108108

lib/gpio/diagnostics.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ defmodule Circuits.GPIO.Diagnostics do
3737
"""
3838
@spec report(GPIO.gpio_spec(), GPIO.gpio_spec()) :: boolean
3939
def report(out_gpio_spec, in_gpio_spec) do
40-
{:ok, out_gpio_info} = GPIO.info(out_gpio_spec)
41-
{:ok, in_gpio_info} = GPIO.info(in_gpio_spec)
40+
{:ok, out_gpio_identifiers} = GPIO.identifiers(out_gpio_spec)
41+
{:ok, in_gpio_identifiers} = GPIO.identifiers(in_gpio_spec)
4242
results = run(out_gpio_spec, in_gpio_spec)
4343
passed = Enum.all?(results, fn {_, result} -> result == :ok end)
4444
check_connections? = hd(results) != {"Simple writes and reads work", :ok}
@@ -51,8 +51,8 @@ defmodule Circuits.GPIO.Diagnostics do
5151
Output GPIO: #{inspect(out_gpio_spec)}
5252
Input GPIO: #{inspect(in_gpio_spec)}
5353
54-
Output info: #{inspect(out_gpio_info)}
55-
Input info: #{inspect(in_gpio_info)}
54+
Output info: #{inspect(out_gpio_identifiers)}
55+
Input info: #{inspect(in_gpio_identifiers)}
5656
Backend: #{inspect(Circuits.GPIO.backend_info()[:name])}
5757
5858
""",

lib/gpio/nil_backend.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule Circuits.GPIO.NilBackend do
1616
end
1717

1818
@impl Backend
19-
def gpio_info(_gpio_spec, _options) do
19+
def gpio_identifiers(_gpio_spec, _options) do
2020
{:error, :not_found}
2121
end
2222

test/circuits_gpio_test.exs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,33 @@ defmodule Circuits.GPIO2Test do
3737
assert info.pins_open == 0
3838
end
3939

40-
describe "info/2" do
40+
describe "identifiers/2" do
4141
test "all gpio_spec examples" do
4242
expected = %{
4343
location: {"gpiochip0", 5},
4444
label: "pair_2_1",
4545
controller: "stub0"
4646
}
4747

48-
assert GPIO.info(5) == {:ok, expected}
49-
assert GPIO.info("pair_2_1") == {:ok, expected}
50-
assert GPIO.info({"gpiochip0", 5}) == {:ok, expected}
51-
assert GPIO.info({"stub0", 5}) == {:ok, expected}
52-
assert GPIO.info({"gpiochip0", "pair_2_1"}) == {:ok, expected}
53-
assert GPIO.info({"stub0", "pair_2_1"}) == {:ok, expected}
54-
55-
assert GPIO.info(-1) == {:error, :not_found}
56-
assert GPIO.info(64) == {:error, :not_found}
57-
assert GPIO.info("something") == {:error, :not_found}
58-
assert GPIO.info({"gpiochip0", 64}) == {:error, :not_found}
59-
assert GPIO.info({"stub0", 64}) == {:error, :not_found}
60-
assert GPIO.info({"gpiochip0", "something"}) == {:error, :not_found}
61-
assert GPIO.info({"stub0", "something"}) == {:error, :not_found}
48+
assert GPIO.identifiers(5) == {:ok, expected}
49+
assert GPIO.identifiers("pair_2_1") == {:ok, expected}
50+
assert GPIO.identifiers({"gpiochip0", 5}) == {:ok, expected}
51+
assert GPIO.identifiers({"stub0", 5}) == {:ok, expected}
52+
assert GPIO.identifiers({"gpiochip0", "pair_2_1"}) == {:ok, expected}
53+
assert GPIO.identifiers({"stub0", "pair_2_1"}) == {:ok, expected}
54+
55+
assert GPIO.identifiers(-1) == {:error, :not_found}
56+
assert GPIO.identifiers(64) == {:error, :not_found}
57+
assert GPIO.identifiers("something") == {:error, :not_found}
58+
assert GPIO.identifiers({"gpiochip0", 64}) == {:error, :not_found}
59+
assert GPIO.identifiers({"stub0", 64}) == {:error, :not_found}
60+
assert GPIO.identifiers({"gpiochip0", "something"}) == {:error, :not_found}
61+
assert GPIO.identifiers({"stub0", "something"}) == {:error, :not_found}
6262
end
6363

6464
test "lines in stub1" do
6565
for spec <- [33, "pair_16_1", {"stub1", "pair_16_1"}] do
66-
info = GPIO.info(spec)
66+
info = GPIO.identifiers(spec)
6767

6868
expected_line_info = %{
6969
location: {"gpiochip1", 1},
@@ -78,7 +78,7 @@ defmodule Circuits.GPIO2Test do
7878

7979
test "nonexistent lines" do
8080
for spec <- [-1, 65, "pair_100_0", {"stub10", "pair_2_0"}] do
81-
info = GPIO.info(spec)
81+
info = GPIO.identifiers(spec)
8282

8383
assert info == {:error, :not_found},
8484
"Unexpected info for #{inspect(spec)} -> #{inspect(info)}"
@@ -468,13 +468,13 @@ defmodule Circuits.GPIO2Test do
468468

469469
# Set the cache to something bogus and check that it's comes back
470470
:persistent_term.put(Circuits.GPIO.CDev, [bogus_gpio])
471-
assert GPIO.info("not_a_gpio") == {:ok, bogus_gpio}
471+
assert GPIO.identifiers("not_a_gpio") == {:ok, bogus_gpio}
472472

473473
# Now check that the cache gets refreshed when a gpio isn't found
474-
assert GPIO.info("pair_18_1") == {:ok, good_gpio}
474+
assert GPIO.identifiers("pair_18_1") == {:ok, good_gpio}
475475

476476
# The bogus GPIO doesn't come back
477-
assert GPIO.info("not_a_gpio") == {:error, :not_found}
477+
assert GPIO.identifiers("not_a_gpio") == {:error, :not_found}
478478
end
479479

480480
test "write_one/2 + read_one/1" do

0 commit comments

Comments
 (0)