-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audio: Add setup method and add reference counter on shutdown #11799
base: master
Are you sure you want to change the base?
Conversation
Add an 'setup' method on the 'struct audio_ops_s' to notify to the driver that the related device file has been opened and is ready for use. And also add refcount argument on shutdown method to know how many device file is still opened.
|
||
if (lower && lower->ops && lower->ops->setup) | ||
{ | ||
ret = lower->ops->setup(lower, tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cold we call setup only when cref equals 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe few lower drivers want to know how many users are exists.
So I think this should be kept, how do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you give an example?
@@ -223,7 +235,7 @@ static int audio_close(FAR struct file *filep) | |||
DEBUGASSERT(lower->ops->shutdown != NULL); | |||
audinfo("calling shutdown\n"); | |||
|
|||
lower->ops->shutdown(lower); | |||
lower->ops->shutdown(lower, upper->crefs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's call shutdown when the last reference close and drop opencnt from shutdown prototype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shutdown is called not only close method, but also SHUTDOWN ioctl, so I think it should be kept.
@@ -534,6 +536,10 @@ typedef CODE void (*audio_callback_t)(FAR void *priv, uint16_t reason, | |||
struct audio_lowerhalf_s; | |||
struct audio_ops_s | |||
{ | |||
/* This method is called when the related device file is opened. */ | |||
|
|||
CODE int (*setup)(FAR struct audio_lowerhalf_s *dev, int opencnt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move the new callback to last to keep the source code compatibility, and revert the change from the individual driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I agree.
I will modify.
@@ -2698,7 +2699,7 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type, | |||
* | |||
****************************************************************************/ | |||
|
|||
static int cxd56_shutdown(struct audio_lowerhalf_s *lower) | |||
static int cxd56_shutdown(struct audio_lowerhalf_s *lower, int opencnt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the commit message you said "refcount" but here you used "opencnt" and in the classd_shutdown() you used only "cnt". I think it is a good idea to use just a single name here.
Please rebase to fix the CI issue, also fix the suggestions |
Summary
Add an 'setup' method on the 'struct audio_ops_s' to notify to the driver that the related device file has been opened and is ready for use.
And also add refcount argument on shutdown method to know how many device file is still opened.
Impact
Audio drivers
Testing
Build check