clockevent `set_mode` vs `set_state_periodic`

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

J4x
Posts: 11
Joined: Thu Jun 22, 2017 8:00 pm

clockevent `set_mode` vs `set_state_periodic`

Tue Jun 27, 2017 9:42 pm

I am trying to implement the simplest TC periodic interrupt in Linux kernel (4.1). By now, I just need to blink an LED or something like.

I started cleaning up "tcb_clksrc.c" and, while navigating through the sources I noted the comment on "clockchips.h":

Code: Select all

/* @set_mode:		legacy set mode function, only for modes <= CLOCK_EVT_MODE_RESUME. */
A little below, another comment says:

Code: Select all

/*
	 * State transition callback(s): Only one of the two groups should be
	 * defined:
	 * - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
	 * - set_state_{shutdown|periodic|oneshot}(), tick_resume().
	 */
In addition, `clock_event_mode` is marked as obsolete. Nevertheless, the only few examples I could find out for using Atmel timer-counter still use it, so I ask:

Can I simply update my code to use `set_state_periodic` instead of `set_mode`?

Code: Select all

struct clock_event_device	clkevt	=
{
	.name		= "tc_clkevt",
	.features	= CLOCK_EVT_FEAT_PERIODIC,
	.rating		= 125,
	.set_next_event	= tc_next_event,
	.set_mode	= tc_mode,
};
change it to:

Code: Select all

struct clock_event_device	clkevt	=
{
	.name		= "tc_clkevt",
	.features	= CLOCK_EVT_FEAT_PERIODIC,
	.rating		= 125,
	.set_next_event	= tc_next_event,
	.set_state_periodic	= tc_my_periodic_setup, // HERE
};
and trust that `clockevents_config_and_register` will set everything as needed?

Thanks!
blue_z
Location: USA
Posts: 1560
Joined: Thu Apr 19, 2007 10:15 pm

Re: clockevent `set_mode` vs `set_state_periodic`

Wed Jun 28, 2017 9:00 pm

J4x wrote:I started cleaning up "tcb_clksrc.c" ...!
What do you think is broken that needs "cleanup"?
J4x wrote:In addition, `clock_event_mode` is marked as obsolete. Nevertheless, the only few examples I could find out for using Atmel timer-counter still use it, so I ask: ...
IMO you're asking the wrong questions.
Reviewing a list of modules that use struct clock_event_device, this structure seems to be internal to the timer subsystem.
Seem like you intend to implement your own timer subsystem, rather than use what's already available, e.g. hrtimer_init and friends.

Regards
J4x
Posts: 11
Joined: Thu Jun 22, 2017 8:00 pm

Re: clockevent `set_mode` vs `set_state_periodic`

Thu Jun 29, 2017 2:13 pm

Thanks for your response once more, blue_z.
blue_z wrote:
J4x wrote:I started cleaning up "tcb_clksrc.c" ...!
What do you think is broken that needs "cleanup"?
Nothing is broken. I just need to have a starting point for my own code and took this as example.
blue_z wrote:
J4x wrote:In addition, `clock_event_mode` is marked as obsolete. Nevertheless, the only few examples I could find out for using Atmel timer-counter still use it, so I ask: ...
IMO you're asking the wrong questions.
Reviewing a list of modules that use struct clock_event_device, this structure seems to be internal to the timer subsystem.
Seem like you intend to implement your own timer subsystem, rather than use what's already available, e.g. hrtimer_init and friends.
I am slowly starting to understand this and really I think I don't need to touch it for my own code.

My doubt still remains, though. If `set_mode` is marked obsolete, it should be avoided and, likely, be revised for future kernel versions.

Am I wrong?

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest