From: rkir@google.com
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Roman Kiryanov <rkir@google.com>
Subject: [PATCH v2 3/3] tty: Replace goldfish_tty_line_count with a #define
Date: Tue, 24 Jul 2018 17:51:33 -0700 [thread overview]
Message-ID: <20180725005133.107823-3-rkir@google.com> (raw)
In-Reply-To: <20180725005133.107823-1-rkir@google.com>
From: Roman Kiryanov <rkir@google.com>
The driver never mutates this variable - no benefits of
keeping it mutable.
Signed-off-by: Roman Kiryanov <rkir@google.com>
---
Changes in v2:
- Replaced "const u32" with "#define".
drivers/tty/goldfish.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 173383f2a4c1..eb88db4f243c 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -49,10 +49,11 @@ struct goldfish_tty {
static DEFINE_MUTEX(goldfish_tty_lock);
static struct tty_driver *goldfish_tty_driver;
-static u32 goldfish_tty_line_count = 8;
static u32 goldfish_tty_current_line_count;
static struct goldfish_tty *goldfish_ttys;
+#define GOLDFISH_TTY_LINE_COUNT 8
+
static void do_rw_io(struct goldfish_tty *qtty,
unsigned long address,
unsigned int count,
@@ -225,7 +226,7 @@ static struct tty_driver *goldfish_tty_console_device(struct console *c,
static int goldfish_tty_console_setup(struct console *co, char *options)
{
- if ((unsigned int)co->index >= goldfish_tty_line_count)
+ if ((unsigned int)co->index >= GOLDFISH_TTY_LINE_COUNT)
return -ENODEV;
if (!goldfish_ttys[co->index].base)
return -ENODEV;
@@ -251,14 +252,14 @@ static int goldfish_tty_create_driver(void)
int ret;
struct tty_driver *tty;
- goldfish_ttys = kcalloc(goldfish_tty_line_count,
+ goldfish_ttys = kcalloc(GOLDFISH_TTY_LINE_COUNT,
sizeof(*goldfish_ttys),
GFP_KERNEL);
if (goldfish_ttys == NULL) {
ret = -ENOMEM;
goto err_alloc_goldfish_ttys_failed;
}
- tty = alloc_tty_driver(goldfish_tty_line_count);
+ tty = alloc_tty_driver(GOLDFISH_TTY_LINE_COUNT);
if (tty == NULL) {
ret = -ENOMEM;
goto err_alloc_tty_driver_failed;
@@ -333,7 +334,7 @@ static int goldfish_tty_probe(struct platform_device *pdev)
else
line = pdev->id;
- if (line >= goldfish_tty_line_count) {
+ if (line >= GOLDFISH_TTY_LINE_COUNT) {
pr_err("goldfish_tty: Reached maximum tty number of %d.\n",
goldfish_tty_current_line_count);
ret = -ENOMEM;
--
2.18.0.233.g985f88cf7e-goog
next prev parent reply other threads:[~2018-07-25 0:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 0:51 [PATCH v2 1/3] tty: Address checkpatch warnings in goldfish.c rkir
2018-07-25 0:51 ` [PATCH v2 2/3] tty: Make constants to be enums instead of #define " rkir
2018-07-28 14:51 ` Greg KH
2018-07-25 0:51 ` rkir [this message]
2018-08-02 8:11 ` [PATCH v2 3/3] tty: Replace goldfish_tty_line_count with a #define Greg KH
2018-08-02 10:02 ` Alan Cox
2018-07-28 14:51 ` [PATCH v2 1/3] tty: Address checkpatch warnings in goldfish.c Greg KH
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=20180725005133.107823-3-rkir@google.com \
--to=rkir@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome