linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] tty: rpmsg: Assign returned id to a local variable
@ 2021-10-25 13:51 Andy Shevchenko
  2021-10-25 13:51 ` [PATCH v1 2/5] tty: rpmsg: Unify variable used to keep an error code Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-10-25 13:51 UTC (permalink / raw)
  To: Andy Shevchenko, Arnaud Pouliquen, linux-kernel
  Cc: Greg Kroah-Hartman, Jiri Slaby

Instead of putting garbage in the data structure, assign allocated id
or an error code to a temporary variable. This makes code cleaner.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/rpmsg_tty.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/rpmsg_tty.c b/drivers/tty/rpmsg_tty.c
index 813076341ffd..8c17ddbf371d 100644
--- a/drivers/tty/rpmsg_tty.c
+++ b/drivers/tty/rpmsg_tty.c
@@ -121,15 +121,16 @@ static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void)
 		return ERR_PTR(-ENOMEM);
 
 	mutex_lock(&idr_lock);
-	cport->id = idr_alloc(&tty_idr, cport, 0, MAX_TTY_RPMSG, GFP_KERNEL);
+	err = idr_alloc(&tty_idr, cport, 0, MAX_TTY_RPMSG, GFP_KERNEL);
 	mutex_unlock(&idr_lock);
 
-	if (cport->id < 0) {
-		err = cport->id;
+	if (err < 0) {
 		kfree(cport);
 		return ERR_PTR(err);
 	}
 
+	cport->id = err;
+
 	return cport;
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-02 14:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 13:51 [PATCH v1 1/5] tty: rpmsg: Assign returned id to a local variable Andy Shevchenko
2021-10-25 13:51 ` [PATCH v1 2/5] tty: rpmsg: Unify variable used to keep an error code Andy Shevchenko
2021-10-25 13:51 ` [PATCH v1 3/5] tty: rpmsg: Use dev_err_probe() in ->probe() Andy Shevchenko
2021-10-25 13:51 ` [PATCH v1 4/5] tty: rpmsg: Add pr_fmt() to prefix messages Andy Shevchenko
2021-10-25 13:51 ` [PATCH v1 5/5] tty: rpmsg: Define tty name via constant string literal Andy Shevchenko
2021-11-02 13:19 ` [PATCH v1 1/5] tty: rpmsg: Assign returned id to a local variable Arnaud POULIQUEN
2021-11-02 14:40   ` Andy Shevchenko

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).