LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Zhenzhong Duan <zhenzhong.duan@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: jdike@addtoit.com, richard@nod.at,
	anton.ivanov@cambridgegreys.com, miguel.ojeda.sandonis@gmail.com,
	willy@haproxy.com, ksenija.stanojevic@gmail.com, arnd@arndb.de,
	gregkh@linuxfoundation.org, mpm@selenic.com,
	herbert@gondor.apana.org.au, jonathan@buzzard.org.uk,
	benh@kernel.crashing.org, davem@davemloft.net,
	b.zolnierkie@samsung.com, rjw@rjwysocki.net, pavel@ucw.cz,
	len.brown@intel.com, Zhenzhong Duan <zhenzhong.duan@gmail.com>,
	William Hubbs <w.d.hubbs@gmail.com>,
	Chris Brannon <chris@the-brannons.com>,
	Kirk Reiser <kirk@reisers.ca>,
	Samuel Thibault <samuel.thibault@ens-lyon.org>
Subject: [PATCH RFC 3/3] speakup: misc: Use dynamic minor numbers for speakup devices
Date: Mon,  9 Mar 2020 10:17:47 +0800	[thread overview]
Message-ID: <20200309021747.626-4-zhenzhong.duan@gmail.com> (raw)
In-Reply-To: <20200309021747.626-1-zhenzhong.duan@gmail.com>

Arnd notes in the link:
   | To clarify: the only numbers that I think should be changed to dynamic
   | allocation are for drivers/staging/speakup. While this is a fairly old
   | subsystem, I would expect that it being staging means we can be a
   | little more progressive with the changes.

This releases misc device minor numbers 25-27 for dynamic usage.

Link: https://lore.kernel.org/lkml/20200120221323.GJ15860@mit.edu/t/
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/speakup/devsynth.c     | 10 +++-------
 drivers/staging/speakup/speakup_soft.c | 14 +++++++-------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/speakup/devsynth.c b/drivers/staging/speakup/devsynth.c
index d920256..d305716 100644
--- a/drivers/staging/speakup/devsynth.c
+++ b/drivers/staging/speakup/devsynth.c
@@ -1,16 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/errno.h>
-#include <linux/miscdevice.h>	/* for misc_register, and SYNTH_MINOR */
+#include <linux/miscdevice.h>	/* for misc_register, and MISC_DYNAMIC_MINOR */
 #include <linux/types.h>
 #include <linux/uaccess.h>
 
 #include "speakup.h"
 #include "spk_priv.h"
 
-#ifndef SYNTH_MINOR
-#define SYNTH_MINOR 25
-#endif
-
 static int misc_registered;
 static int dev_opened;
 
@@ -67,7 +63,7 @@ static int speakup_file_release(struct inode *ip, struct file *fp)
 };
 
 static struct miscdevice synth_device = {
-	.minor = SYNTH_MINOR,
+	.minor = MISC_DYNAMIC_MINOR,
 	.name = "synth",
 	.fops = &synth_fops,
 };
@@ -81,7 +77,7 @@ void speakup_register_devsynth(void)
 		pr_warn("Couldn't initialize miscdevice /dev/synth.\n");
 	} else {
 		pr_info("initialized device: /dev/synth, node (MAJOR %d, MINOR %d)\n",
-			MISC_MAJOR, SYNTH_MINOR);
+			MISC_MAJOR, synth_device.minor);
 		misc_registered = 1;
 	}
 }
diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
index 9d85a3a..eed246f 100644
--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -10,7 +10,7 @@
  */
 
 #include <linux/unistd.h>
-#include <linux/miscdevice.h>	/* for misc_register, and SYNTH_MINOR */
+#include <linux/miscdevice.h>	/* for misc_register, and MISC_DYNAMIC_MINOR */
 #include <linux/poll.h>		/* for poll_wait() */
 
 /* schedule(), signal_pending(), TASK_INTERRUPTIBLE */
@@ -20,8 +20,6 @@
 #include "speakup.h"
 
 #define DRV_VERSION "2.6"
-#define SOFTSYNTH_MINOR 26 /* might as well give it one more than /dev/synth */
-#define SOFTSYNTHU_MINOR 27 /* might as well give it one more than /dev/synth */
 #define PROCSPEECH 0x0d
 #define CLEAR_SYNTH 0x18
 
@@ -375,7 +373,7 @@ static int softsynth_probe(struct spk_synth *synth)
 	if (misc_registered != 0)
 		return 0;
 	memset(&synth_device, 0, sizeof(synth_device));
-	synth_device.minor = SOFTSYNTH_MINOR;
+	synth_device.minor = MISC_DYNAMIC_MINOR;
 	synth_device.name = "softsynth";
 	synth_device.fops = &softsynth_fops;
 	if (misc_register(&synth_device)) {
@@ -384,7 +382,7 @@ static int softsynth_probe(struct spk_synth *synth)
 	}
 
 	memset(&synthu_device, 0, sizeof(synthu_device));
-	synthu_device.minor = SOFTSYNTHU_MINOR;
+	synthu_device.minor = MISC_DYNAMIC_MINOR;
 	synthu_device.name = "softsynthu";
 	synthu_device.fops = &softsynthu_fops;
 	if (misc_register(&synthu_device)) {
@@ -393,8 +391,10 @@ static int softsynth_probe(struct spk_synth *synth)
 	}
 
 	misc_registered = 1;
-	pr_info("initialized device: /dev/softsynth, node (MAJOR 10, MINOR 26)\n");
-	pr_info("initialized device: /dev/softsynthu, node (MAJOR 10, MINOR 27)\n");
+	pr_info("initialized device: /dev/softsynth, node (MAJOR 10, MINOR %d)\n",
+		synth_device.minor);
+	pr_info("initialized device: /dev/softsynthu, node (MAJOR 10, MINOR %d)\n",
+		synthu_device.minor);
 	return 0;
 }
 
-- 
1.8.3.1


  parent reply	other threads:[~2020-03-09  2:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09  2:17 [PATCH RFC 0/3] clean up misc device minor numbers Zhenzhong Duan
2020-03-09  2:17 ` [PATCH RFC 1/3] misc: cleanup minor number definitions in c file into miscdevice.h Zhenzhong Duan
2020-03-09  8:53   ` Herbert Xu
2020-03-11  3:07     ` Zhenzhong Duan
2020-03-09 11:37   ` Miguel Ojeda
2020-03-09 13:08   ` Arnd Bergmann
2020-03-11  2:57     ` Zhenzhong Duan
2020-03-09  2:17 ` [PATCH RFC 2/3] misc: move FLASH_MINOR into miscdevice.h and fix conflicts Zhenzhong Duan
2020-03-09 13:05   ` Arnd Bergmann
2020-03-09  2:17 ` Zhenzhong Duan [this message]
2020-03-09  7:15   ` [PATCH RFC 3/3] speakup: misc: Use dynamic minor numbers for speakup devices Greg KH
2020-03-14 22:21     ` Samuel Thibault
2020-03-09  7:13 ` [PATCH RFC 0/3] clean up misc device minor numbers Greg KH
2020-03-09  9:51 ` Willy TARREAU
2020-03-09 11:36   ` Miguel Ojeda
2020-03-11  3:14     ` Zhenzhong Duan

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=20200309021747.626-4-zhenzhong.duan@gmail.com \
    --to=zhenzhong.duan@gmail.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=arnd@arndb.de \
    --cc=b.zolnierkie@samsung.com \
    --cc=benh@kernel.crashing.org \
    --cc=chris@the-brannons.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jdike@addtoit.com \
    --cc=jonathan@buzzard.org.uk \
    --cc=kirk@reisers.ca \
    --cc=ksenija.stanojevic@gmail.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=mpm@selenic.com \
    --cc=pavel@ucw.cz \
    --cc=richard@nod.at \
    --cc=rjw@rjwysocki.net \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=w.d.hubbs@gmail.com \
    --cc=willy@haproxy.com \
    --subject='Re: [PATCH RFC 3/3] speakup: misc: Use dynamic minor numbers for speakup devices' \
    /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

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