Skip to content

Commit 8d8047c

Browse files
gkalsiCQ Bot
authored andcommitted
[fidl][clk] Make fuchsia.hardware.clock open and flexible
API guidelines say that FIDL protocols should prefer to be open with flexible methods unless there's a good reason for it not to be that way. Update `fuchsia.hardware.clock` ahead of API calibration to satisfy that requirement. Test: fx set core.vim3 && fx build Bug: b/342220727 Change-Id: I507dbe90f27c1d6bde1a3438608542a586a1ea59 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1052894 API-Review: Jocelyn Dang <jocelyndang@google.com> Reviewed-by: Jocelyn Dang <jocelyndang@google.com> Commit-Queue: Gurjant Kalsi <gkalsi@google.com>
1 parent c42a6ee commit 8d8047c

File tree

6 files changed

+42
-24
lines changed

6 files changed

+42
-24
lines changed

sdk/fidl/fuchsia.hardware.clock/clock.fidl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,79 +13,79 @@ type FrequencyInfo = struct {
1313
};
1414

1515
/// Used for driver-to-non-driver communication.
16-
closed protocol Device {
17-
strict Measure(struct {
16+
open protocol Device {
17+
flexible Measure(struct {
1818
clock uint32;
1919
}) -> (struct {
2020
info FrequencyInfo;
2121
});
22-
strict GetCount() -> (struct {
22+
flexible GetCount() -> (struct {
2323
count uint32;
2424
});
2525

2626
// For debugging
27-
strict Enable(struct {
27+
flexible Enable(struct {
2828
clock uint32;
2929
}) -> () error zx.Status;
3030

31-
strict Disable(struct {
31+
flexible Disable(struct {
3232
clock uint32;
3333
}) -> () error zx.Status;
3434
};
3535

3636
/// Used for driver-to-driver communication.
3737
@discoverable
38-
closed protocol Clock {
38+
open protocol Clock {
3939

4040
/// Enables (ungates) this clock.
4141
/// Drivers *must* call enable on all clocks they depend upon.
42-
strict Enable() -> () error zx.Status;
42+
flexible Enable() -> () error zx.Status;
4343

4444
/// Disables (gates) this clock.
4545
/// Drivers should call this method to indicate to the clock subsystem that
4646
/// a particular clock signal is no longer necessary.
47-
strict Disable() -> () error zx.Status;
47+
flexible Disable() -> () error zx.Status;
4848

4949
/// Returns `true` if a given clock is running.
5050
/// May query the hardware or return a cached value.
51-
strict IsEnabled() -> (struct {
51+
flexible IsEnabled() -> (struct {
5252
enabled bool;
5353
}) error zx.Status;
5454

5555
/// Attempt to set the rate of the clock provider.
56-
strict SetRate(struct {
56+
flexible SetRate(struct {
5757
hz uint64;
5858
}) -> () error zx.Status;
5959

6060
/// Query the hardware for the highest supported rate that does not
6161
/// exceed hz_in.
62-
strict QuerySupportedRate(struct {
62+
flexible QuerySupportedRate(struct {
6363
hz_in uint64;
6464
}) -> (struct {
6565
hz_out uint64;
6666
}) error zx.Status;
6767

6868
/// Returns the current rate that a given clock is running at.
69-
strict GetRate() -> (struct {
69+
flexible GetRate() -> (struct {
7070
hz uint64;
7171
}) error zx.Status;
7272

7373
/// Sets the input of this clock by index. I.e. by selecting a mux.
7474
/// This clock has N inputs defined 0 through N-1, which are valid arguemts
7575
/// as the index to SetInput.
76-
strict SetInput(struct {
76+
flexible SetInput(struct {
7777
idx uint32;
7878
}) -> () error zx.Status;
7979

8080
/// Returns the number of inputs this clock has.
8181
/// Any value between 0 and UINT32_MAX is a valid return for this method.
8282
/// A Root Oscillator may return 0 for instance, if it has no inputs.
83-
strict GetNumInputs() -> (struct {
83+
flexible GetNumInputs() -> (struct {
8484
n uint32;
8585
}) error zx.Status;
8686

8787
/// Returns the index of the current input of this clock.
88-
strict GetInput() -> (struct {
88+
flexible GetInput() -> (struct {
8989
index uint32;
9090
}) error zx.Status;
9191
};

sdk/fidl/fuchsia.hardware.clockimpl/clock-impl.fidl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,46 @@ using zx;
1515
@transport("Driver")
1616
open protocol ClockImpl {
1717
/// Clock Gating Control.
18-
strict Enable(struct {
18+
flexible Enable(struct {
1919
id uint32;
2020
}) -> () error zx.Status;
21-
strict Disable(struct {
21+
flexible Disable(struct {
2222
id uint32;
2323
}) -> () error zx.Status;
24-
strict IsEnabled(struct {
24+
flexible IsEnabled(struct {
2525
id uint32;
2626
}) -> (struct {
2727
enabled bool;
2828
}) error zx.Status;
2929

3030
/// Clock Frequency Scaling Control.
31-
strict SetRate(struct {
31+
flexible SetRate(struct {
3232
id uint32;
3333
hz uint64;
3434
}) -> () error zx.Status;
35-
strict QuerySupportedRate(struct {
35+
flexible QuerySupportedRate(struct {
3636
id uint32;
3737
hz uint64;
3838
}) -> (struct {
3939
hz uint64;
4040
}) error zx.Status;
41-
strict GetRate(struct {
41+
flexible GetRate(struct {
4242
id uint32;
4343
}) -> (struct {
4444
hz uint64;
4545
}) error zx.Status;
4646

4747
/// Clock input control.
48-
strict SetInput(struct {
48+
flexible SetInput(struct {
4949
id uint32;
5050
idx uint32;
5151
}) -> () error zx.Status;
52-
strict GetNumInputs(struct {
52+
flexible GetNumInputs(struct {
5353
id uint32;
5454
}) -> (struct {
5555
n uint32;
5656
}) error zx.Status;
57-
strict GetInput(struct {
57+
flexible GetInput(struct {
5858
id uint32;
5959
}) -> (struct {
6060
index uint32;

src/devices/block/drivers/aml-sdmmc/aml-sdmmc-with-banjo-test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ class FakeClock : public fidl::WireServer<fuchsia_hardware_clock::Clock> {
198198
completer.ReplyError(ZX_ERR_NOT_SUPPORTED);
199199
}
200200

201+
void handle_unknown_method(fidl::UnknownMethodMetadata<fuchsia_hardware_clock::Clock> metadata,
202+
fidl::UnknownMethodCompleter::Sync& completer) override {
203+
ZX_ASSERT_MSG(0, "Unexpected FIDL Method Ordinal, ord = 0x%lx", metadata.method_ordinal);
204+
}
205+
201206
fidl::ServerBindingGroup<fuchsia_hardware_clock::Clock> bindings_;
202207

203208
bool enabled_ = false;

src/devices/clock/drivers/amlogic-clk/aml-clk.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class AmlClock : public DeviceType, public ddk::ClockImplProtocol<AmlClock, ddk:
6666
void GetCount(GetCountCompleter::Sync& completer) override;
6767
void Enable(EnableRequestView request, EnableCompleter::Sync& completer) override;
6868
void Disable(DisableRequestView request, DisableCompleter::Sync& completer) override;
69+
void handle_unknown_method(fidl::UnknownMethodMetadata<fuchsia_hardware_clock::Device> metadata,
70+
fidl::UnknownMethodCompleter::Sync& completer) override {
71+
zxlogf(ERROR, "Unexpected Clock FIDL call: 0x%lx", metadata.method_ordinal);
72+
}
6973

7074
// Device protocol implementation.
7175
void DdkUnbind(ddk::UnbindTxn txn);

src/devices/clock/drivers/clock/clock.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ void ClockDevice::GetInput(GetInputCompleter::Sync& completer) {
8484
}
8585
}
8686

87+
void ClockDevice::handle_unknown_method(
88+
fidl::UnknownMethodMetadata<fuchsia_hardware_clock::Clock> metadata,
89+
fidl::UnknownMethodCompleter::Sync& completer) {
90+
zxlogf(ERROR, "Unexpected Clock FIDL call: 0x%lx", metadata.method_ordinal);
91+
}
92+
8793
zx_status_t ClockDevice::ServeOutgoing(fidl::ServerEnd<fuchsia_io::Directory> server_end) {
8894
fuchsia_hardware_clock::Service::InstanceHandler handler({
8995
.clock = bindings_.CreateHandler(this, dispatcher_, fidl::kIgnoreBindingClosure),

src/devices/clock/drivers/clock/clock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class ClockDevice : public ClockDeviceType, public fidl::WireServer<fuchsia_hard
6262
void GetNumInputs(GetNumInputsCompleter::Sync& completer) override;
6363
void GetInput(GetInputCompleter::Sync& completer) override;
6464

65+
void handle_unknown_method(fidl::UnknownMethodMetadata<fuchsia_hardware_clock::Clock> metadata,
66+
fidl::UnknownMethodCompleter::Sync& completer) override;
67+
6568
const ClockImplProxy clock_;
6669
const uint32_t id_;
6770

0 commit comments

Comments
 (0)