* [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free
@ 2024-04-25 6:03 Shresth Prasad
0 siblings, 0 replies; 6+ messages in thread
From: Shresth Prasad @ 2024-04-25 6:03 UTC (permalink / raw)
To: davem, gregkh, jirislaby
Cc: sparclinux, linux-kernel, linux-serial, skhan,
javier.carrasco.cruz, Shresth Prasad, Julia Lawall
Add `__free` function attribute to `ap` and `match` pointer
initialisations which ensure that the pointers are freed as soon as they
go out of scope, thus removing the need to manually free them using
`of_node_put`.
This also removes the need for the `goto` statement and the `rc`
variable.
Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Shresth Prasad <shresthprasad7@gmail.com>
---
drivers/tty/serial/sunsu.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 67a5fc70bb4b..0f463da5e7ce 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -1382,44 +1382,29 @@ static inline struct console *SUNSU_CONSOLE(void)
static enum su_type su_get_type(struct device_node *dp)
{
- struct device_node *ap = of_find_node_by_path("/aliases");
- enum su_type rc = SU_PORT_PORT;
+ struct device_node *ap __free(device_node) =
+ of_find_node_by_path("/aliases");
if (ap) {
const char *keyb = of_get_property(ap, "keyboard", NULL);
const char *ms = of_get_property(ap, "mouse", NULL);
- struct device_node *match;
if (keyb) {
- match = of_find_node_by_path(keyb);
+ struct device_node *match __free(device_node) =
+ of_find_node_by_path(keyb);
- /*
- * The pointer is used as an identifier not
- * as a pointer, we can drop the refcount on
- * the of__node immediately after getting it.
- */
- of_node_put(match);
-
- if (dp == match) {
- rc = SU_PORT_KBD;
- goto out;
- }
+ if (dp == match)
+ return SU_PORT_KBD;
}
if (ms) {
- match = of_find_node_by_path(ms);
+ struct device_node *match __free(device_node) =
+ of_find_node_by_path(ms);
- of_node_put(match);
-
- if (dp == match) {
- rc = SU_PORT_MS;
- goto out;
- }
+ if (dp == match)
+ return SU_PORT_MS;
}
}
-
-out:
- of_node_put(ap);
- return rc;
+ return SU_PORT_PORT;
}
static int su_probe(struct platform_device *op)
--
2.44.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free
2024-05-01 5:03 ` Greg KH
@ 2024-05-01 5:32 ` Shresth Prasad
0 siblings, 0 replies; 6+ messages in thread
From: Shresth Prasad @ 2024-05-01 5:32 UTC (permalink / raw)
To: Greg KH
Cc: davem, jirislaby, linux-serial, Javier Carrasco, Julia Lawall,
Shuah Khan, sparclinux, linux-kernel
> Yes, but you did not include it in your response at all, so how were we
> to see it?
Oh, really sorry about that.
I thought I was replying to the thread with the patch.
> Great, please say so in your changelog text.
Right, I'll do that. My bad.
I'll resubmit the patch.
Regards,
Shresth
On Wed, May 1, 2024 at 10:33 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, May 01, 2024 at 10:28:35AM +0530, Shresth Prasad wrote:
> > > I don't see anything here, sorry.
> > I'm sorry but is this patch not visible?
> > https://lore.kernel.org/all/20240425060303.8045-2-shresthprasad7@gmail.com/
>
> Yes, but you did not include it in your response at all, so how were we
> to see it?
>
> > > Also, how was this tested?
> > I tested it using a qemu x86_64 virtual machine
>
> Great, please say so in your changelog text.
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free
2024-05-01 4:58 ` Shresth Prasad
@ 2024-05-01 5:03 ` Greg KH
2024-05-01 5:32 ` Shresth Prasad
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2024-05-01 5:03 UTC (permalink / raw)
To: Shresth Prasad
Cc: davem, jirislaby, linux-serial, Javier Carrasco, Julia Lawall,
Shuah Khan, sparclinux, linux-kernel
On Wed, May 01, 2024 at 10:28:35AM +0530, Shresth Prasad wrote:
> > I don't see anything here, sorry.
> I'm sorry but is this patch not visible?
> https://lore.kernel.org/all/20240425060303.8045-2-shresthprasad7@gmail.com/
Yes, but you did not include it in your response at all, so how were we
to see it?
> > Also, how was this tested?
> I tested it using a qemu x86_64 virtual machine
Great, please say so in your changelog text.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free
2024-05-01 4:51 ` Greg KH
@ 2024-05-01 4:58 ` Shresth Prasad
2024-05-01 5:03 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Shresth Prasad @ 2024-05-01 4:58 UTC (permalink / raw)
To: Greg KH
Cc: davem, jirislaby, linux-serial, Javier Carrasco, Julia Lawall,
Shuah Khan, sparclinux, linux-kernel
> I don't see anything here, sorry.
I'm sorry but is this patch not visible?
https://lore.kernel.org/all/20240425060303.8045-2-shresthprasad7@gmail.com/
> Also, how was this tested?
I tested it using a qemu x86_64 virtual machine
Regards,
Shresth
On Wed, May 1, 2024 at 10:21 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, May 01, 2024 at 10:01:00AM +0530, Shresth Prasad wrote:
> > Hi,
> >
> > Could I please get some feedback for this patch?
>
> I don't see anything here, sorry.
>
> Also, how was this tested?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free
2024-05-01 4:31 Shresth Prasad
@ 2024-05-01 4:51 ` Greg KH
2024-05-01 4:58 ` Shresth Prasad
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2024-05-01 4:51 UTC (permalink / raw)
To: Shresth Prasad
Cc: davem, jirislaby, linux-serial, Javier Carrasco, Julia Lawall,
Shuah Khan, sparclinux, linux-kernel
On Wed, May 01, 2024 at 10:01:00AM +0530, Shresth Prasad wrote:
> Hi,
>
> Could I please get some feedback for this patch?
I don't see anything here, sorry.
Also, how was this tested?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free
@ 2024-05-01 4:31 Shresth Prasad
2024-05-01 4:51 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Shresth Prasad @ 2024-05-01 4:31 UTC (permalink / raw)
To: gregkh, davem, jirislaby, linux-serial
Cc: Javier Carrasco, Julia Lawall, Shuah Khan, sparclinux,
linux-kernel, Shresth Prasad
Hi,
Could I please get some feedback for this patch?
Regards,
Shresth
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-01 5:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 6:03 [PATCH][next] tty: sunsu: Simplify device_node cleanup by using __free Shresth Prasad
2024-05-01 4:31 Shresth Prasad
2024-05-01 4:51 ` Greg KH
2024-05-01 4:58 ` Shresth Prasad
2024-05-01 5:03 ` Greg KH
2024-05-01 5:32 ` Shresth Prasad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).