Clk API

The KUnit clk API is used to test clk providers and clk consumers.

intclk_prepare_enable_kunit(structkunit*test,structclk*clk)

Test managedclk_prepare_enable()

Parameters

structkunit*test

The test context

structclk*clk

clk to prepare and enable

Return

0 on success, or negative errno on failure.

structclk*clk_get_kunit(structkunit*test,structdevice*dev,constchar*con_id)

Test managedclk_get()

Parameters

structkunit*test

The test context

structdevice*dev

device for clock “consumer”

constchar*con_id

clock consumer ID

Description

Just likeclk_get(), except the clk is managed by the test case and isautomatically put withclk_put() after the test case concludes.

Return

new clk consumer or ERR_PTR on failure.

structclk*of_clk_get_kunit(structkunit*test,structdevice_node*np,intindex)

Test managedof_clk_get()

Parameters

structkunit*test

The test context

structdevice_node*np

device_node for clock “consumer”

intindex

index in ‘clocks’ property ofnp

Description

Just likeof_clk_get(), except the clk is managed by the test case and isautomatically put withclk_put() after the test case concludes.

Return

new clk consumer or ERR_PTR on failure.

structclk*clk_hw_get_clk_kunit(structkunit*test,structclk_hw*hw,constchar*con_id)

Test managedclk_hw_get_clk()

Parameters

structkunit*test

The test context

structclk_hw*hw

clk_hw associated with the clk being consumed

constchar*con_id

connection ID string on device

Description

Just likeclk_hw_get_clk(), except the clk is managed by the test case andis automatically put withclk_put() after the test case concludes.

Return

new clk consumer or ERR_PTR on failure.

structclk*clk_hw_get_clk_prepared_enabled_kunit(structkunit*test,structclk_hw*hw,constchar*con_id)

Test managedclk_hw_get_clk() +clk_prepare_enable()

Parameters

structkunit*test

The test context

structclk_hw*hw

clk_hw associated with the clk being consumed

constchar*con_id

connection ID string on device

Description

Just like

structclk*clk=clk_hw_get_clk(...);clk_prepare_enable(clk);

except the clk is managed by the test case and is automatically disabled andunprepared withclk_disable_unprepare() and put withclk_put() after thetest case concludes.

Return

new clk consumer that is prepared and enabled or ERR_PTR on failure.

intclk_hw_register_kunit(structkunit*test,structdevice*dev,structclk_hw*hw)

Test managedclk_hw_register()

Parameters

structkunit*test

The test context

structdevice*dev

device that is registering this clock

structclk_hw*hw

link to hardware-specific clock data

Description

Just likeclk_hw_register(), except the clk registration is managed by thetest case and is automatically unregistered after the test case concludes.

Return

0 on success or a negative errno value on failure.

intof_clk_hw_register_kunit(structkunit*test,structdevice_node*node,structclk_hw*hw)

Test managedof_clk_hw_register()

Parameters

structkunit*test

The test context

structdevice_node*node

device_node of device that is registering this clock

structclk_hw*hw

link to hardware-specific clock data

Description

Just likeof_clk_hw_register(), except the clk registration is managed bythe test case and is automatically unregistered after the test caseconcludes.

Return

0 on success or a negative errno value on failure.

intof_clk_add_hw_provider_kunit(structkunit*test,structdevice_node*np,structclk_hw*(*get)(structof_phandle_args*clkspec,void*data),void*data)

Test managedof_clk_add_hw_provider()

Parameters

structkunit*test

The test context

structdevice_node*np

Device node pointer associated with clock provider

structclk_hw*(*get)(structof_phandle_args*clkspec,void*data)

Callback for decoding clk_hw

void*data

Context pointer forget callback.

Description

Just likeof_clk_add_hw_provider(), except the clk_hw provider is managed bythe test case and is automatically unregistered after the test caseconcludes.

Return

0 on success or a negative errno value on failure.