From: Khadija Kamran <kamrankhadijadj@gmail.com>
To: outreachy@lists.linux.dev
Subject: Suggestions on refactoring arche_platform_wd_irq() function
Date: Tue, 28 Mar 2023 15:45:02 +0500 [thread overview]
Message-ID: <ZCLFLqNjNawO2KnO@khadija-virtual-machine> (raw)
Hey Outreachy Mentors,
I am working on a check reported by checkpatch.pl saying,
CHECK: line length of 101 exceeds 100 columns
#182: FILE: drivers/staging/greybus/arche-platform.c:182:
+ WD_STATE_COLDBOOT_TRIG);
To refactor the function Ira sent me a link and suggested the use of
goto statement.
Alison guided me with this problem and asked to share the diff and start
a thread for discussion. Link to Alison's mail:
https://lore.kernel.org/outreachy/ZCHPokeiKV37uOmr@aschofie-mobl2/
Kindly review the following diff:
static irqreturn_t arche_platform_wd_irq(int irq, void *devid)
spin_lock_irqsave(&arche_pdata->wake_lock, flags);
- if (gpiod_get_value(arche_pdata->wake_detect)) {
- /* wake/detect rising */
-
- /*
- * If wake/detect line goes high after low, within less than
- * 30msec, then standby boot sequence is initiated, which is not
- * supported/implemented as of now. So ignore it.
- */
- if (arche_pdata->wake_detect_state == WD_STATE_BOOT_INIT) {
- if (time_before(jiffies,
- arche_pdata->wake_detect_start +
- msecs_to_jiffies(WD_COLDBOOT_PULSE_WIDTH_MS))) {
- arche_platform_set_wake_detect_state(arche_pdata,
- WD_STATE_IDLE);
- } else {
- /*
- * Check we are not in middle of irq thread
- * already
- */
- if (arche_pdata->wake_detect_state !=
- WD_STATE_COLDBOOT_START) {
- arche_platform_set_wake_detect_state(arche_pdata,
- WD_STATE_COLDBOOT_TRIG);
- spin_unlock_irqrestore(&arche_pdata->wake_lock,
- flags);
- return IRQ_WAKE_THREAD;
- }
- }
- }
- } else {
+ if (!gpiod_get_value(arche_pdata->wake_detect)) {
/* wake/detect falling */
- if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
- arche_pdata->wake_detect_start = jiffies;
+ goto falling;
+ }
+
+ /* wake/detect rising */
+
+ /*
+ * If wake/detect line goes high after low, within less than
+ * 30msec, then standby boot sequence is initiated, which is not
+ * supported/implemented as of now. So ignore it.
+ */
+ if (arche_pdata->wake_detect_state == WD_STATE_BOOT_INIT) {
+ if (time_before(jiffies,
+ arche_pdata->wake_detect_start +
+ msecs_to_jiffies(WD_COLDBOOT_PULSE_WIDTH_MS))) {
+ arche_platform_set_wake_detect_state(arche_pdata,
+ WD_STATE_IDLE);
+ } else {
/*
- * In the beginning, when wake/detect goes low
- * (first time), we assume it is meant for coldboot
- * and set the flag. If wake/detect line stays low
- * beyond 30msec, then it is coldboot else fallback
- * to standby boot.
+ * Check we are not in middle of irq thread
+ * already
*/
- arche_platform_set_wake_detect_state(arche_pdata,
- WD_STATE_BOOT_INIT);
+ if (arche_pdata->wake_detect_state !=
+ WD_STATE_COLDBOOT_START) {
+ arche_platform_set_wake_detect_state(arche_pdata,
+ WD_STATE_COLDBOOT_TRIG);
+ spin_unlock_irqrestore(&arche_pdata->wake_lock,
+ flags);
+ return IRQ_WAKE_THREAD;
+ }
}
+ goto out;
}
+falling:
+ if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
+ arche_pdata->wake_detect_start = jiffies;
+ /*
+ * In the beginning, when wake/detect goes low
+ * (first time), we assume it is meant for coldboot
+ * and set the flag. If wake/detect line stays low
+ * beyond 30msec, then it is coldboot else fallback
+ * to standby boot.
+ */
+ arche_platform_set_wake_detect_state(arche_pdata,
+ WD_STATE_BOOT_INIT);
+
+out:
spin_unlock_irqrestore(&arche_pdata->wake_lock, flags);
return IRQ_HANDLED;
Thank you!
Regards,
Khadija
next reply other threads:[~2023-03-28 10:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 10:45 Khadija Kamran [this message]
2023-03-28 10:54 ` Suggestions on refactoring arche_platform_wd_irq() function Julia Lawall
2023-03-28 18:58 ` Alison Schofield
2023-03-28 19:30 ` Khadija Kamran
2023-03-28 23:28 ` Alison Schofield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZCLFLqNjNawO2KnO@khadija-virtual-machine \
--to=kamrankhadijadj@gmail.com \
--cc=outreachy@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.