-
Notifications
You must be signed in to change notification settings - Fork 47
clean up luahid #347
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
clean up luahid #347
Conversation
lneto
commented
Dec 25, 2025
- add lunatik_monitor
- remove unecessary branch on error handling
- simplify error levels
- fix style
| if (!lua_isboolean(L, -1)) | ||
| lua_pushinteger(L, -EINVAL); | ||
| else | ||
| lua_pushinteger(L, 0); |
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.
@qrsikno2 why should we return 0 if it's not error?
| } | ||
|
|
||
| LUAHID_CALLBACK(probe, 2, 1, err); | ||
| LUAHID_CALLBACK(report_fixup, 4, 0, warn); |
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.
@qrsikno2 there was any reason to use warn here?
| }; | ||
|
|
||
| static const luaL_Reg luahid_mt[] = { | ||
| {"__index", lunatik_monitorobject}, |
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.
@qrsikno2 there was any reason to not use monitor here?
| if (luahid_checkdriver(L, hid, -1)) { \ | ||
| pr_err(#NAME ": invaild driver\n"); \ | ||
| lua_pushinteger(L, -ENXIO); \ | ||
| return 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.
@qrsikno2 please check if it will make any difference.. from Lua perspective, it will just discard the return value if there's no assignment
|
@qrsikno2 I noticed that we use both lunatik_run and lunatik_runirq to run different callbacks.. is that guaranteed that the driver will not call them concurrently? |
lib/luahid.c
Outdated
| else | ||
| lua_pushinteger(L, 0); | ||
|
|
||
| lua_pushinteger(L, !lua_isboolean(L, -1) ? EINVAL : 0); |
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 you want -EINVAL here
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.
good catch! thanks!
* add lunatik_monitor * remove unecessary branch on error handling * simplify error levels and the overall logics * fix style
Instead of suffixing the callback function with pre and post, use a proper struct with function pointers. Signed-off-by: Ashwani Kumar Kamal <[email protected]>
glk0
left a comment
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.
Nothing looks bad to me.