* [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC [not found] <476d024cd6b04160a5de381ea2b9856b60088cbd.1663288066.git.nabijaczleweli@nabijaczleweli.xyz> @ 2022-09-16 1:55 ` наб 2022-09-16 6:52 ` Jiri Slaby 0 siblings, 1 reply; 2+ messages in thread From: наб @ 2022-09-16 1:55 UTC (permalink / raw) Cc: Greg Kroah-Hartman, Randy Dunlap, Jiri Slaby, linuxppc-dev, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2168 bytes --] According to Greg, in the context of magic numbers as defined in magic-number.rst, "the tty layer should not need this and I'll gladly take patches" This stretches that definition slightly, since it multiplexes it with the terminal number as a constant offset, but is equivalent Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/ Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> --- drivers/tty/hvc/hvc_iucv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c index 32366caca662..7d49a872de48 100644 --- a/drivers/tty/hvc/hvc_iucv.c +++ b/drivers/tty/hvc/hvc_iucv.c @@ -29,7 +29,6 @@ /* General device driver settings */ -#define HVC_IUCV_MAGIC 0xc9e4c3e5 #define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS #define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4) @@ -131,9 +130,9 @@ static struct iucv_handler hvc_iucv_handler = { */ static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) { - if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices)) + if (num > hvc_iucv_devices) return NULL; - return hvc_iucv_table[num - HVC_IUCV_MAGIC]; + return hvc_iucv_table[num]; } /** @@ -1072,8 +1071,8 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console) priv->is_console = is_console; /* allocate hvc device */ - priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /* PAGE_SIZE */ - HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256); + priv->hvc = hvc_alloc(id, /* PAGE_SIZE */ + id, &hvc_iucv_ops, 256); if (IS_ERR(priv->hvc)) { rc = PTR_ERR(priv->hvc); goto out_error_hvc; @@ -1371,7 +1370,7 @@ static int __init hvc_iucv_init(void) /* register the first terminal device as console * (must be done before allocating hvc terminal devices) */ - rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops); + rc = hvc_instantiate(0, IUCV_HVC_CON_IDX, &hvc_iucv_ops); if (rc) { pr_err("Registering HVC terminal device as " "Linux console failed\n"); -- 2.30.2 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC 2022-09-16 1:55 ` [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC наб @ 2022-09-16 6:52 ` Jiri Slaby 0 siblings, 0 replies; 2+ messages in thread From: Jiri Slaby @ 2022-09-16 6:52 UTC (permalink / raw) To: наб Cc: Greg Kroah-Hartman, Randy Dunlap, linuxppc-dev, linux-kernel On 16. 09. 22, 3:55, наб wrote: > According to Greg, in the context of magic numbers as defined in > magic-number.rst, "the tty layer should not need this and I'll gladly > take patches" > > This stretches that definition slightly, since it multiplexes it with > the terminal number as a constant offset, but is equivalent > > Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/ > Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Acked-by: Jiri Slaby <jirislaby@kernel.org> > --- > drivers/tty/hvc/hvc_iucv.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c > index 32366caca662..7d49a872de48 100644 > --- a/drivers/tty/hvc/hvc_iucv.c > +++ b/drivers/tty/hvc/hvc_iucv.c > @@ -29,7 +29,6 @@ > > > /* General device driver settings */ > -#define HVC_IUCV_MAGIC 0xc9e4c3e5 > #define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS > #define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4) > > @@ -131,9 +130,9 @@ static struct iucv_handler hvc_iucv_handler = { > */ > static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) > { > - if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices)) > + if (num > hvc_iucv_devices) > return NULL; > - return hvc_iucv_table[num - HVC_IUCV_MAGIC]; > + return hvc_iucv_table[num]; > } > > /** > @@ -1072,8 +1071,8 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console) > priv->is_console = is_console; > > /* allocate hvc device */ > - priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /* PAGE_SIZE */ > - HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256); > + priv->hvc = hvc_alloc(id, /* PAGE_SIZE */ > + id, &hvc_iucv_ops, 256); > if (IS_ERR(priv->hvc)) { > rc = PTR_ERR(priv->hvc); > goto out_error_hvc; > @@ -1371,7 +1370,7 @@ static int __init hvc_iucv_init(void) > > /* register the first terminal device as console > * (must be done before allocating hvc terminal devices) */ > - rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops); > + rc = hvc_instantiate(0, IUCV_HVC_CON_IDX, &hvc_iucv_ops); > if (rc) { > pr_err("Registering HVC terminal device as " > "Linux console failed\n"); -- js suse labs ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-16 6:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <476d024cd6b04160a5de381ea2b9856b60088cbd.1663288066.git.nabijaczleweli@nabijaczleweli.xyz>
2022-09-16 1:55 ` [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC наб
2022-09-16 6:52 ` Jiri Slaby
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).