Skip to contentSkip to conversation

use devicemodel with parport

PATCH In review Sudip Mukherjee 9 participants 27 messages May 20, 2015 – Jun 1, 2015

Subsystems (6)
lore
Share & tools
lore

Sudip Mukherjee

author maintainer
#0 lore raw

cover use devicemodel with parport

After 5 versions of WIP, finally a patch submission. parport subsystem is now in the transition stage and supports the old model and the new device model. 3 of the drivers have been converted into new model and tested.
After other drivers are converted we can remove the old code from parport.

Sudip Mukherjee (6):
parport: add device-model to parport subsystem
staging: panel: use new parport device model
i2c-parport: define ports to connect
i2c-parport: use new parport device model
paride: use new parport device model
MAINTAINERS: maintain parport

 MAINTAINERS                      |   7 +-
 drivers/block/paride/paride.c    |  57 ++++++-
 drivers/block/paride/paride.h    |   2 +
 drivers/block/paride/pcd.c       |   9 +
 drivers/block/paride/pd.c        |  12 +-
 drivers/block/paride/pf.c        |   7 +
 drivers/block/paride/pg.c        |   8 +
 drivers/block/paride/pt.c        |   8 +
 drivers/i2c/busses/i2c-parport.c |  38 ++++-
 drivers/parport/parport_pc.c     |   4 +-
 drivers/parport/procfs.c         |  15 +-
 drivers/parport/share.c          | 345 ++++++++++++++++++++++++++++++++++++---
 drivers/staging/panel/panel.c    |  14 +-
 include/linux/parport.h          |  43 ++++-
 14 files changed, 522 insertions(+), 47 deletions(-)
Signature · 1 line
1.8.1.2
author maintainer
#1 lore raw

PATCH 1/6 parport: add device-model to parport subsystem

parport subsystem starts using the device-model. Drivers using the device-model has to define devmodel as true and should register the device with parport using parport_register_dev_model().

---

patch: renaming of cnt and one label, added one comment.
instead of probe check for devmodel. Define a default probe. No change in core functionality.

v5:
a) addition/removal of ports are now handled.
b) is_parport moved to the core level
c) common parport_driver_register code
d) parport_register_dev_model now accepts instance number.

v4: use of is_parport() is introduced to check the type of device
that has been passed to probe or match_port.

v3: started use of parport_del_port(). previously it was creating
some ghost parallel ports during port probing. parport_del_port() removes registered ports if probing has failed.

v2: started using probe function. Without probe,whenever any driver
is trying to register, it is getting bound to all the available parallel ports. To solve that probe was required. Now the driver is binding only to the device it has registered. And that device will appear as a subdevice of the particular parallel port it wants to use.

In v1 Greg mentioned that we do not need to maintain our own list. That has been partially done. we are no longer maintaining the list of drivers. But we still need to maintain the list of ports and devices as that will be used by drivers which are not yet converted to device model. When all drivers are converted to use the device-model parallel port all these lists can be removed.

 drivers/parport/parport_pc.c |   4 +-
 drivers/parport/procfs.c     |  15 +-
 drivers/parport/share.c      | 345 ++++++++++++++++++++++++++++++++++++++++---
 include/linux/parport.h      |  43 +++++-
 4 files changed, 379 insertions(+), 28 deletions(-)
drivers/parport/parport_pc.c +2 -2
index 53d15b3..78530d1 100644
@@ -2255,7 +2255,7 @@ out5:
 		release_region(base+0x3, 5);
 	release_region(base, 3);
 out4:
-	parport_put_port(p);
+	parport_del_port(p);
 out3:
 	kfree(priv);
 out2:
@@ -2294,7 +2294,7 @@ void parport_pc_unregister_port(struct parport *p)
 				    priv->dma_handle);
 #endif
 	kfree(p->private_data);
-	parport_put_port(p);
+	parport_del_port(p);
 	kfree(ops); /* hope no-one cached it */
 }
 EXPORT_SYMBOL(parport_pc_unregister_port);
drivers/parport/procfs.c +14 -1
index 3b47080..c776333 100644
@@ -21,6 +21,7 @@
 #include <linux/parport.h>
 #include <linux/ctype.h>
 #include <linux/sysctl.h>
+#include <linux/device.h>
 
 #include <asm/uaccess.h>
 
@@ -558,8 +559,18 @@ int parport_device_proc_unregister(struct pardevice *device)
 
 static int __init parport_default_proc_register(void)
 {
+	int ret;
+
 	parport_default_sysctl_table.sysctl_header =
 		register_sysctl_table(parport_default_sysctl_table.dev_dir);
+	if (!parport_default_sysctl_table.sysctl_header)
+		return -ENOMEM;
+	ret = parport_bus_init();
+	if (ret) {
+		unregister_sysctl_table(parport_default_sysctl_table.
+					sysctl_header);
+		return ret;
+	}
 	return 0;
 }
 
@@ -570,6 +581,7 @@ static void __exit parport_default_proc_unregister(void)
 					sysctl_header);
 		parport_default_sysctl_table.sysctl_header = NULL;
 	}
+	parport_bus_exit();
 }
 
 #else /* no sysctl or no procfs*/
@@ -596,11 +608,12 @@ int parport_device_proc_unregister(struct pardevice *device)
 
 static int __init parport_default_proc_register (void)
 {
-	return 0;
+	return parport_bus_init();
 }
 
 static void __exit parport_default_proc_unregister (void)
 {
+	parport_bus_exit();
 }
 #endif
 
drivers/parport/share.c +322 -23

469 lines not on this page · raw message

include/linux/parport.h +41 -2

103 lines not on this page · raw message

Signature · 1 line
1.8.1.2
author maintainer
#2 lore raw

PATCH 2/6 staging: panel: use new parport device model

In reply to Sudip Mukherjee

Converted to use the new device-model parallel port.

---

The comment about panel_cb.flags can be removed, it is kept just for the comment to remind us that it might be better to use PARPORT_DEV_EXCL.

 drivers/staging/panel/panel.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/staging/panel/panel.c +9 -5
index 1d8ed8b..70f0ac6 100644
@@ -2190,6 +2190,8 @@ static struct notifier_block panel_notifier = {
 
 static void panel_attach(struct parport *port)
 {
+	struct pardev_cb panel_cb;
+
 	if (port->number != parport)
 		return;
 
@@ -2199,10 +2201,11 @@ static void panel_attach(struct parport *port)
 		return;
 	}
 
-	pprt = parport_register_device(port, "panel", NULL, NULL,  /* pf, kf */
-				       NULL,
-				       /*PARPORT_DEV_EXCL */
-				       0, (void *)&pprt);
+	memset(&panel_cb, 0, sizeof(panel_cb));
+	panel_cb.private = &pprt;
+	/* panel_cb.flags = 0 should be PARPORT_DEV_EXCL? */
+
+	pprt = parport_register_dev_model(port, "panel", &panel_cb, 0);
 	if (pprt == NULL) {
 		pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n",
 		       __func__, port->number, parport);
@@ -2256,8 +2259,9 @@ static void panel_detach(struct parport *port)
 
 static struct parport_driver panel_driver = {
 	.name = "panel",
-	.attach = panel_attach,
+	.match_port = panel_attach,
 	.detach = panel_detach,
+	.devmodel = true,
 };
 
 /* init function */
Signature · 1 line
1.8.1.2
author maintainer
#3 lore raw

PATCH 3/6 i2c-parport: define ports to connect

In reply to Sudip Mukherjee

As of now i2c-parport was connecting to all the available parallel ports. Lets limit that to maximum of 4 instances and at the same time define which instance connects to which parallel port.

---

MODULE_PARM_DESC modified

 drivers/i2c/busses/i2c-parport.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/i2c/busses/i2c-parport.c +23 -0
index a1fac5a..155da95 100644
@@ -46,6 +46,9 @@ struct i2c_par {
 
 static LIST_HEAD(adapter_list);
 static DEFINE_MUTEX(adapter_list_lock);
+#define MAX_DEVICE 4
+static int parport[MAX_DEVICE] = {0, -1, -1, -1};
+
 
 /* ----- Low-level parallel port access ----------------------------------- */
 
@@ -163,6 +166,19 @@ static void i2c_parport_irq(void *data)
 static void i2c_parport_attach(struct parport *port)
 {
 	struct i2c_par *adapter;
+	int i;
+	struct pardev_cb i2c_parport_cb;
+
+	for (i = 0; i < MAX_DEVICE; i++) {
+		if (parport[i] == -1)
+			continue;
+		if (port->number == parport[i])
+			break;
+	}
+	if (i == MAX_DEVICE) {
+		pr_debug("i2c-parport: Not using parport%d.\n", port->number);
+		return;
+	}
 
 	adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
 	if (adapter == NULL) {
@@ -298,5 +314,12 @@ MODULE_AUTHOR("Jean Delvare <[email protected]>");
 MODULE_DESCRIPTION("I2C bus over parallel port");
 MODULE_LICENSE("GPL");
 
+module_param_array(parport, int, NULL, 0);
+MODULE_PARM_DESC(parport,
+		 "List of parallel ports to bind to, by index.\n"
+		 " Atmost " __stringify(MAX_DEVICE) " devices are supported.\n"
+		 " Default is one device connected to parport0.\n"
+);
+
 module_init(i2c_parport_init);
 module_exit(i2c_parport_exit);
Signature · 1 line
1.8.1.2
Acked-by on v1 3/6
#4 lore raw

Re: [PATCH 3/6] i2c-parport: define ports to connect

Quoted 6 lines · Sudip Mukherjee

As of now i2c-parport was connecting to all the available parallel ports. Lets limit that to maximum of 4 instances and at the same time define which instance connects to which parallel port.

I assume this goes in as one series:

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

author maintainer
#5 lore raw

PATCH 4/6 i2c-parport: use new parport device model

In reply to Sudip Mukherjee

Modify i2c-parport driver to use the new parallel port device model.

---

i2c_parport_cb is made local, devmodel added to driver structure, and probe removed.

 drivers/i2c/busses/i2c-parport.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-parport.c +10 -5
index 155da95..138347e 100644
@@ -185,11 +185,15 @@ static void i2c_parport_attach(struct parport *port)
 		printk(KERN_ERR "i2c-parport: Failed to kzalloc\n");
 		return;
 	}
+	memset(&i2c_parport_cb, 0, sizeof(i2c_parport_cb));
+	i2c_parport_cb.flags = PARPORT_FLAG_EXCL;
+	i2c_parport_cb.irq_func = i2c_parport_irq;
+	i2c_parport_cb.private = adapter;
 
 	pr_debug("i2c-parport: attaching to %s\n", port->name);
 	parport_disable_irq(port);
-	adapter->pdev = parport_register_device(port, "i2c-parport",
-		NULL, NULL, i2c_parport_irq, PARPORT_FLAG_EXCL, adapter);
+	adapter->pdev = parport_register_dev_model(port, "i2c-parport",
+						   &i2c_parport_cb, i);
 	if (!adapter->pdev) {
 		printk(KERN_ERR "i2c-parport: Unable to register with parport\n");
 		goto err_free;
@@ -283,9 +287,10 @@ static void i2c_parport_detach(struct parport *port)
 }
 
 static struct parport_driver i2c_parport_driver = {
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name		= "i2c-parport",
+	.match_port	= i2c_parport_attach,
+	.detach		= i2c_parport_detach,
+	.devmodel	= true,
 };
 
 /* ----- Module loading, unloading and information ------------------------ */
Signature · 1 line
1.8.1.2
Acked-by on v1 4/6
#6 lore raw

Re: [PATCH 4/6] i2c-parport: use new parport device model

Quoted 5 lines · Sudip Mukherjee

Modify i2c-parport driver to use the new parallel port device model.

---

In general:

drivers/i2c/busses/i2c-parport.c static void i2c_parport_detach(struct parport *port) · line 293

Quoted 8 lines

static struct parport_driver i2c_parport_driver = {

drivers/i2c/busses/i2c-parport.c +4 -3
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name		= "i2c-parport",
+	.match_port	= i2c_parport_attach,
+	.detach		= i2c_parport_detach,
+	.devmodel	= true,

Minor nit: I prefer to not use tabs but a single space after the struct member names. Less hazzle in the future and still readable IMO.

author maintainer
#7 lore raw

Re: [PATCH 4/6] i2c-parport: use new parport device model

Quoted 11 lines · Wolfram Sang
Quoted 5 lines · Sudip Mukherjee

Modify i2c-parport driver to use the new parallel port device model.

---

In general:

Quoted 11 lines

drivers/i2c/busses/i2c-parport.c static void i2c_parport_detach(struct parport *port) · line 293

Quoted 8 lines

static struct parport_driver i2c_parport_driver = {

drivers/i2c/busses/i2c-parport.c +4 -3
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name		= "i2c-parport",
+	.match_port	= i2c_parport_attach,
+	.detach		= i2c_parport_detach,
+	.devmodel	= true,

Minor nit: I prefer to not use tabs but a single space after the struct member names. Less hazzle in the future and still readable IMO.

It was having space originally. I changed that into tab as it was looking good with them as aligned.
I will wait today for some more review and send v2 tomorrow with this chanage.

regards
sudip

Quoted 1 line
#8 lore raw

Re: [PATCH 4/6] i2c-parport: use new parport device model

Quoted 12 lines
Quoted 12 lines

drivers/i2c/busses/i2c-parport.c static void i2c_parport_detach(struct parport *port) · line 293

Quoted 9 lines

static struct parport_driver i2c_parport_driver = {

drivers/i2c/busses/i2c-parport.c +4 -3
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name		= "i2c-parport",
+	.match_port	= i2c_parport_attach,
+	.detach		= i2c_parport_detach,
+	.devmodel	= true,

Minor nit: I prefer to not use tabs but a single space after the struct member names. Less hazzle in the future and still readable IMO.

Quoted 4 lines

It was having space originally. I changed that into tab as it was looking good with them as aligned.
I will wait today for some more review and send v2 tomorrow with this chanage.

Thanks. Just to make sure: Keep it one space only, no alignment.

#9 lore raw

Re: [PATCH 4/6] i2c-parport: use new parport device model

In reply to Sudip Mukherjee
Quoted 14 lines · Sudip Mukherjee
Quoted 12 lines · Wolfram Sang

drivers/i2c/busses/i2c-parport.c static void i2c_parport_detach(struct parport *port) · line 293

Quoted 8 lines · Sudip Mukherjee

static struct parport_driver i2c_parport_driver = {

drivers/i2c/busses/i2c-parport.c +4 -3
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name		= "i2c-parport",
+	.match_port	= i2c_parport_attach,
+	.detach		= i2c_parport_detach,
+	.devmodel	= true,

Minor nit: I prefer to not use tabs but a single space after the struct member names. Less hazzle in the future and still readable IMO.

Quoted 2 lines

It was having space originally. I changed that into tab as it was looking good with them as aligned.

As the driver maintainer, I am fine with both unaligned or tab-aligned. Space-aligned as I did originally was not a good idea, I admit.

Signature · 2 lines
Jean Delvare
SUSE L3 Support
maintainer
#10 lore raw

RFC PATCH 1/1 checkpatch: check for 2 or more spaces around assignment of a declaration

Quoted 15 lines · Jean Delvare
Quoted 14 lines · Sudip Mukherjee
Quoted 12 lines · Wolfram Sang

Review

Quoted 8 lines · Sudip Mukherjee

static struct parport_driver i2c_parport_driver = {

(quoted diff) +4 -3
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name		= "i2c-parport",
+	.match_port	= i2c_parport_attach,
+	.detach		= i2c_parport_detach,
+	.devmodel	= true,

Minor nit: I prefer to not use tabs but a single space after the struct member names. Less hazzle in the future and still readable IMO.

Quoted 5 lines
Quoted 2 lines

It was having space originally. I changed that into tab as it was looking good with them as aligned.

As the driver maintainer, I am fine with both unaligned or tab-aligned. Space-aligned as I did originally was not a good idea, I admit.

Perhaps space aligned declarations should have some checkpatch --strict warning for 2 or more spaces around any assignment of the declaration.

	int a   = 1;		// 2+ spaces before =
	int b	=  2;		// 2+ spaces after =
	int c	=	3;	// uses tabs around =, no warning
	int d		= 4;	// uses 2 tabs before =, no warning

Something like:

---
 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +7 -0
index 89b1df4..8f9d26f 100755
@@ -3902,6 +3902,13 @@ sub process {
 			    "multiple assignments should be avoided\n" . $herecurr);
 		}
 
+# check for space aligned declarations
+		if ($line =~ /^.\s*(?:$Declare|$DeclareMisordered)\s*$Ident {2,}=\s*(?:$Lval|$Constant|$String)/ ||
+		    $line =~ /^.\s*(?:$Declare|$DeclareMisordered)\s*$Ident\s*= {2,}(?:$Lval|$Constant|$String)/) {
+			CHK("SPACING",
+			    "Avoid multiple space assigments - prefer a single space or tabs\n" . $herecurr);
+		}
+
 ## # check for multiple declarations, allowing for a function declaration
 ## # continuation.
 ## 		if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
#11 lore raw

Re: [RFC PATCH] checkpatch: check for 2 or more spaces around assignment of a declaration

Quoted 8 lines · Joe Perches

Perhaps space aligned declarations should have some checkpatch --strict warning for 2 or more spaces around any assignment of the declaration.

	int a   = 1;		// 2+ spaces before =
	int b	=  2;		// 2+ spaces after =
	int c	=	3;	// uses tabs around =, no warning
	int d		= 4;	// uses 2 tabs before =, no warning

FWIW, in my own code I've stopped using tabs for this and replaced them with spaces. Tabs are fine *before* code but they completely mangle the display for people using different tab sizes, or even when reading diffs, because they heavily depend on the number of characters *before* them while what you want is to ensure that what is *after* is on a fixed position.

I would even go further and report warnings when tabs are used after text.

Tabs after text were very useful in ASM editors in the past because it was possible to define 3 fixed positions (mnemonic, operands, comments) and that was the primary purpose of tabs. But in todays editors, tabs do not mean "jump to next position" but "add between 1 and 8 to the current position" which doesn't make sense at all if what preceeds can be larger than 8 (which is most often the case in C code).

Willy

author maintainer
#12 lore raw

PATCH v2 4/6 i2c-parport: use new parport device model

In reply to Sudip Mukherjee

Modify i2c-parport driver to use the new parallel port device model.

---

v2: Changed to one space instead of tab in i2c_parport_driver.

i2c_parport_cb is made local, devmodel added to driver structure, and probe removed.

 drivers/i2c/busses/i2c-parport.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-parport.c +10 -5
index 155da95..138347e 100644
@@ -185,11 +185,15 @@ static void i2c_parport_attach(struct parport *port)
 		printk(KERN_ERR "i2c-parport: Failed to kzalloc\n");
 		return;
 	}
+	memset(&i2c_parport_cb, 0, sizeof(i2c_parport_cb));
+	i2c_parport_cb.flags = PARPORT_FLAG_EXCL;
+	i2c_parport_cb.irq_func = i2c_parport_irq;
+	i2c_parport_cb.private = adapter;
 
 	pr_debug("i2c-parport: attaching to %s\n", port->name);
 	parport_disable_irq(port);
-	adapter->pdev = parport_register_device(port, "i2c-parport",
-		NULL, NULL, i2c_parport_irq, PARPORT_FLAG_EXCL, adapter);
+	adapter->pdev = parport_register_dev_model(port, "i2c-parport",
+						   &i2c_parport_cb, i);
 	if (!adapter->pdev) {
 		printk(KERN_ERR "i2c-parport: Unable to register with parport\n");
 		goto err_free;
@@ -283,9 +287,10 @@ static void i2c_parport_detach(struct parport *port)
 }
 
 static struct parport_driver i2c_parport_driver = {
-	.name	= "i2c-parport",
-	.attach	= i2c_parport_attach,
-	.detach	= i2c_parport_detach,
+	.name = "i2c-parport",
+	.match_port = i2c_parport_attach,
+	.detach = i2c_parport_detach,
+	.devmodel = true,
 };
 
 /* ----- Module loading, unloading and information ------------------------ */
Signature · 1 line
1.8.1.2
author maintainer
#13 lore raw

PATCH 5/6 paride: use new parport device model

In reply to Sudip Mukherjee

Modify paride driver to use the new parallel port device model.

---

One change after testing by Alan, par_cb is made a local variable instead of a global one.

 drivers/block/paride/paride.c | 57 ++++++++++++++++++++++++++++++++++++++-----
 drivers/block/paride/paride.h |  2 ++
 drivers/block/paride/pcd.c    |  9 +++++++
 drivers/block/paride/pd.c     | 12 ++++++++-
 drivers/block/paride/pf.c     |  7 ++++++
 drivers/block/paride/pg.c     |  8 ++++++
 drivers/block/paride/pt.c     |  8 ++++++
 7 files changed, 96 insertions(+), 7 deletions(-)
drivers/block/paride/paride.c +51 -6
index 48c50f1..0e28799 100644
@@ -30,6 +30,7 @@
 #include <linux/wait.h>
 #include <linux/sched.h>	/* TASK_* */
 #include <linux/parport.h>
+#include <linux/slab.h>
 
 #include "paride.h"
 
@@ -244,17 +245,19 @@ void paride_unregister(PIP * pr)
 
 EXPORT_SYMBOL(paride_unregister);
 
-static int pi_register_parport(PIA * pi, int verbose)
+static int pi_register_parport(PIA *pi, int verbose, int unit)
 {
 	struct parport *port;
+	struct pardev_cb par_cb;
 
 	port = parport_find_base(pi->port);
 	if (!port)
 		return 0;
-
-	pi->pardev = parport_register_device(port,
-					     pi->device, NULL,
-					     pi_wake_up, NULL, 0, (void *) pi);
+	memset(&par_cb, 0, sizeof(par_cb));
+	par_cb.wakeup = pi_wake_up;
+	par_cb.private = (void *)pi;
+	pi->pardev = parport_register_dev_model(port, pi->device, &par_cb,
+						unit);
 	parport_put_port(port);
 	if (!pi->pardev)
 		return 0;
@@ -311,7 +314,7 @@ static int pi_probe_unit(PIA * pi, int unit, char *scratch, int verbose)
 		e = pi->proto->max_units;
 	}
 
-	if (!pi_register_parport(pi, verbose))
+	if (!pi_register_parport(pi, verbose, s))
 		return 0;
 
 	if (pi->proto->test_port) {
@@ -432,3 +435,45 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
 }
 
 EXPORT_SYMBOL(pi_init);
+
+static int pi_probe(struct pardevice *par_dev)
+{
+	struct device_driver *drv = par_dev->dev.driver;
+	int len = strlen(drv->name);
+
+	if (strncmp(par_dev->name, drv->name, len))
+		return -ENODEV;
+
+	return 0;
+}
+
+void *pi_register_driver(char *name)
+{
+	struct parport_driver *parp_drv;
+	int ret;
+
+	parp_drv = kzalloc(sizeof(*parp_drv), GFP_KERNEL);
+	if (!parp_drv)
+		return NULL;
+
+	parp_drv->name = name;
+	parp_drv->probe = pi_probe;
+	parp_drv->devmodel = true;
+
+	ret = parport_register_driver(parp_drv);
+	if (ret) {
+		kfree(parp_drv);
+		return NULL;
+	}
+	return (void *)parp_drv;
+}
+EXPORT_SYMBOL(pi_register_driver);
+
+void pi_unregister_driver(void *_drv)
+{
+	struct parport_driver *drv = _drv;
+
+	parport_unregister_driver(drv);
+	kfree(drv);
+}
+EXPORT_SYMBOL(pi_unregister_driver);
drivers/block/paride/paride.h +2 -0
index 2bddbf4..ddb9e58 100644
@@ -165,6 +165,8 @@ typedef struct pi_protocol PIP;
 
 extern int paride_register( PIP * );
 extern void paride_unregister ( PIP * );
+void *pi_register_driver(char *);
+void pi_unregister_driver(void *);
 
 #endif /* __DRIVERS_PARIDE_H__ */
 /* end of paride.h */
drivers/block/paride/pcd.c +9 -0
index 3b7c9f1..9336236 100644
@@ -221,6 +221,7 @@ static int pcd_busy;		/* request being processed ? */
 static int pcd_sector;		/* address of next requested sector */
 static int pcd_count;		/* number of blocks still to do */
 static char *pcd_buf;		/* buffer for request in progress */
+static void *par_drv;		/* reference of parport driver */
 
 /* kernel glue structures */
 
@@ -690,6 +691,12 @@ static int pcd_detect(void)
 	printk("%s: %s version %s, major %d, nice %d\n",
 	       name, name, PCD_VERSION, major, nice);
 
+	par_drv = pi_register_driver(name);
+	if (!par_drv) {
+		pr_err("failed to register %s driver\n", name);
+		return -1;
+	}
+
 	k = 0;
 	if (pcd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
 		cd = pcd;
@@ -723,6 +730,7 @@ static int pcd_detect(void)
 	printk("%s: No CD-ROM drive found\n", name);
 	for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
 		put_disk(cd->disk);
+	pi_unregister_driver(par_drv);
 	return -1;
 }
 
@@ -984,6 +992,7 @@ static void __exit pcd_exit(void)
 	}
 	blk_cleanup_queue(pcd_queue);
 	unregister_blkdev(major, name);
+	pi_unregister_driver(par_drv);
 }
 
 MODULE_LICENSE("GPL");
drivers/block/paride/pd.c +11 -1
index dbb4da1..b9242d7 100644
@@ -247,6 +247,8 @@ static char *pd_errs[17] = { "ERR", "INDEX", "ECC", "DRQ", "SEEK", "WRERR",
 	"IDNF", "MC", "UNC", "???", "TMO"
 };
 
+static void *par_drv;		/* reference of parport driver */
+
 static inline int status_reg(struct pd_unit *disk)
 {
 	return pi_read_regr(disk->pi, 1, 6);
@@ -872,6 +874,12 @@ static int pd_detect(void)
 			pd_drive_count++;
 	}
 
+	par_drv = pi_register_driver(name);
+	if (!par_drv) {
+		pr_err("failed to register %s driver\n", name);
+		return -1;
+	}
+
 	if (pd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
 		disk = pd;
 		if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch,
@@ -902,8 +910,10 @@ static int pd_detect(void)
 			found = 1;
 		}
 	}
-	if (!found)
+	if (!found) {
 		printk("%s: no valid drive found\n", name);
+		pi_unregister_driver(par_drv);
+	}
 	return found;
 }
 
drivers/block/paride/pf.c +7 -0
index 9a15fd3..7a7d977 100644
@@ -264,6 +264,7 @@ static int pf_cmd;		/* current command READ/WRITE */
 static struct pf_unit *pf_current;/* unit of current request */
 static int pf_mask;		/* stopper for pseudo-int */
 static char *pf_buf;		/* buffer for request in progress */
+static void *par_drv;		/* reference of parport driver */
 
 /* kernel glue structures */
 
@@ -703,6 +704,11 @@ static int pf_detect(void)
 	printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
 	       name, name, PF_VERSION, major, cluster, nice);
 
+	par_drv = pi_register_driver(name);
+	if (!par_drv) {
+		pr_err("failed to register %s driver\n", name);
+		return -1;
+	}
 	k = 0;
 	if (pf_drive_count == 0) {
 		if (pi_init(pf->pi, 1, -1, -1, -1, -1, -1, pf_scratch, PI_PF,
@@ -735,6 +741,7 @@ static int pf_detect(void)
 	printk("%s: No ATAPI disk detected\n", name);
 	for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
 		put_disk(pf->disk);
+	pi_unregister_driver(par_drv);
 	return -1;
 }
 
drivers/block/paride/pg.c +8 -0
index 876d0c3..bfbd4c8 100644
@@ -227,6 +227,7 @@ static int pg_identify(struct pg *dev, int log);
 static char pg_scratch[512];	/* scratch block buffer */
 
 static struct class *pg_class;
+static void *par_drv;		/* reference of parport driver */
 
 /* kernel glue structures */
 
@@ -481,6 +482,12 @@ static int pg_detect(void)
 
 	printk("%s: %s version %s, major %d\n", name, name, PG_VERSION, major);
 
+	par_drv = pi_register_driver(name);
+	if (!par_drv) {
+		pr_err("failed to register %s driver\n", name);
+		return -1;
+	}
+
 	k = 0;
 	if (pg_drive_count == 0) {
 		if (pi_init(dev->pi, 1, -1, -1, -1, -1, -1, pg_scratch,
@@ -511,6 +518,7 @@ static int pg_detect(void)
 	if (k)
 		return 0;
 
+	pi_unregister_driver(par_drv);
 	printk("%s: No ATAPI device detected\n", name);
 	return -1;
 }
drivers/block/paride/pt.c +8 -0
index 2596042..1740d75 100644
@@ -232,6 +232,7 @@ static int pt_identify(struct pt_unit *tape);
 static struct pt_unit pt[PT_UNITS];
 
 static char pt_scratch[512];	/* scratch block buffer */
+static void *par_drv;		/* reference of parport driver */
 
 /* kernel glue structures */
 
@@ -605,6 +606,12 @@ static int pt_detect(void)
 
 	printk("%s: %s version %s, major %d\n", name, name, PT_VERSION, major);
 
+	par_drv = pi_register_driver(name);
+	if (!par_drv) {
+		pr_err("failed to register %s driver\n", name);
+		return -1;
+	}
+
 	specified = 0;
 	for (unit = 0; unit < PT_UNITS; unit++) {
 		struct pt_unit *tape = &pt[unit];
@@ -644,6 +651,7 @@ static int pt_detect(void)
 	if (found)
 		return 0;
 
+	pi_unregister_driver(par_drv);
 	printk("%s: No ATAPI tape drive detected\n", name);
 	return -1;
 }
Signature · 1 line
1.8.1.2
author maintainer
#14 lore raw

PATCH 6/6 MAINTAINERS: maintain parport

In reply to Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

---
 MAINTAINERS | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
MAINTAINERS +5 -2
index 86d9398..0eb5ce2 100644
@@ -7476,13 +7476,16 @@ S:	Maintained
 F:	Documentation/mn10300/
 F:	arch/mn10300/
 
-PARALLEL PORT SUPPORT
+PARALLEL PORT SUBSYSTEM
+M:	Sudip Mukherjee <[email protected]>
+M:	Sudip Mukherjee <[email protected]>
 L:	[email protected] (subscribers-only)
-S:	Orphan
+S:	Maintained
 F:	drivers/parport/
 F:	include/linux/parport*.h
 F:	drivers/char/ppdev.c
 F:	include/uapi/linux/ppdev.h
+F:	Documentation/parport*.txt
 
 PARAVIRT_OPS INTERFACE
 M:	Jeremy Fitzhardinge <[email protected]>
Signature · 1 line
1.8.1.2
#15 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

Signature · 2 lines
Thanks,
//richard
maintainer
#16 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

Quoted 9 lines · Richard Weinberger
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

MAINTAINERS:85: Orphan: No current maintainer [but maybe you could take the
MAINTAINERS-86- role as you write your new code].

Parport is an orphan, hasn't had a maintainer since at least 2.6.12, and has almost no activity minus drive-by cleanups and new device ID support every once in awhile.

Sudip is writing new code.

If Sudip wants to be a maintainer of parport, assuming he has the time and resources to give it a go, I think he should be welcomed to it.

Thanks Sudip. Best of luck...

author maintainer
#17 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

Quoted 18 lines · Joe Perches
Quoted 9 lines · Richard Weinberger
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

MAINTAINERS:85: Orphan: No current maintainer [but maybe you could take the
MAINTAINERS-86- role as you write your new code].

Parport is an orphan, hasn't had a maintainer since at least 2.6.12, and has almost no activity minus drive-by cleanups and new device ID support every once in awhile.

Quoted 7 lines

Sudip is writing new code.

If Sudip wants to be a maintainer of parport, assuming he has the time and resources to give it a go, I think he should be welcomed to it.

Thanks Sudip. Best of luck...

Thanks Joe & Alan for the support. I consider myself inexperienced to maintain a subsystem, but I hope you all will be there to review and help me in the process.

regards
sudip

#18 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

In reply to Richard Weinberger
Quoted 9 lines · On Wed, 20 May 2015 17:46:44 +0200 Richard Weinberger…
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

It currently (and for some time) has had no maintainer so having a maintainer is IMHO definitely an improvement in things.

Alan

#19 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

Am 20.05.2015 um 18:33 schrieb One Thousand Gnomes:

Quoted 8 lines
Quoted 5 lines · On Wed, 20 May 2015 17:46:44 +0200 Richard Weinberger…
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Quoted 7 lines
Quoted 4 lines

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

It currently (and for some time) has had no maintainer so having a maintainer is IMHO definitely an improvement in things.

Having a maintainer is good.
All I wanted to point out was that it is IMHO uncommon to claim maintainership before being the main contributor or the de facto maintainer of a subsystem.

This "rule" prevents us from "Mommy!!! Look, I'm a maintainer!!!1" patches. ;-)

Thanks,
//richard

author maintainer
#20 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

Quoted 17 lines · Richard Weinberger

Am 20.05.2015 um 18:33 schrieb One Thousand Gnomes:

Quoted 8 lines
Quoted 5 lines · On Wed, 20 May 2015 17:46:44 +0200 Richard Weinberger…
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Quoted 7 lines
Quoted 4 lines

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

It currently (and for some time) has had no maintainer so having a maintainer is IMHO definitely an improvement in things.

Quoted 6 lines

Having a maintainer is good.
All I wanted to point out was that it is IMHO uncommon to claim maintainership before being the main contributor or the de facto maintainer of a subsystem.

This "rule" prevents us from "Mommy!!! Look, I'm a maintainer!!!1" patches. ;-)

I already have my name in the MAINTAINERS file, so that is not a cookie to cry for.
Personnaly I will prefer Joe Perches or Dan Carpenter to be the maintainer. They have reviewed many of my patches since I started contributing here and I have learnt and still learning many things from them.
if this patch is a debatable topic, then lets drop it. I have written these changes, and will write the next changes also, it doesnot matter if my name is there in the MAINTAINERS or not.
The main reason I gave this patch is just because if any problem (read as regression) arises due to these changes then those problem mails would have directly come to my inbox.

regards
sudip

Quoted 3 lines

Thanks,
//richard

#21 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

In reply to Richard Weinberger
Quoted 9 lines · Richard Weinberger
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

Sudip has been volunteering for fixing this code which is marked as "orphan". So whatever his experience and care in this area, it will be better for the driver to have a maintainer than none.

Good luck Sudip, as drivers which have become orphans are probably the ones that deserve the least love :-)

Willy

#22 lore raw

Re: [PATCH 6/6] MAINTAINERS: maintain parport

Quoted 11 lines · Willy Tarreau
Quoted 9 lines · Richard Weinberger
Quoted 2 lines · Sudip Mukherjee

Lets give the parport subsystem a proper name and start maintaining the files.

Excuse me, but usually someone takes over the maintainer role after proving that he
cares for a sub system for a certain period of time.
Or did I miss something?

Quoted 6 lines

Sudip has been volunteering for fixing this code which is marked as "orphan". So whatever his experience and care in this area, it will be better for the driver to have a maintainer than none.

Good luck Sudip, as drivers which have become orphans are probably the ones that deserve the least love :-)

I agree. I've been "baby-sitting" this subsystem for a long time now. If Sudip wants to take it on, and based on his recent patches it looks like he does, I'm all for him to be the maintainer of it. So this patch in the series is fine with me, I'll apply it when the rest of this series gets merged.

thanks,

greg k-h

#23 lore raw
In reply to Sudip Mukherjee
Quoted 6 lines · Sudip Mukherjee

After 5 versions of WIP, finally a patch submission. parport subsystem is now in the transition stage and supports the old model and the new device model. 3 of the drivers have been converted into new model and tested.
After other drivers are converted we can remove the old code from parport.

This looks good, very nice job.

Are you going to continue to fix up the other drivers? I don't want us to have a half-converted subsystem in the kernel.

thanks,

greg k-h

author maintainer
#24 lore raw
Quoted 9 lines · Greg Kroah-Hartman
Quoted 6 lines · Sudip Mukherjee

After 5 versions of WIP, finally a patch submission. parport subsystem is now in the transition stage and supports the old model and the new device model. 3 of the drivers have been converted into new model and tested.
After other drivers are converted we can remove the old code from parport.

This looks good, very nice job.

Thanks, but its not me alone. Dan, Jean, Alan has helped me a lot in this.

Quoted 3 lines

Are you going to continue to fix up the other drivers? I don't want us to have a half-converted subsystem in the kernel.

ofcourse yes. I also donot want to be a maintainer of half converted subsystem. :)
i am thinking, after it is in the linux-next for a few days and seeing any effects of these changes I will start with the other drivers. and after all drivers are converted and that is also in next for sufficient days I will start with the cleanup of the old codes.
And then there are some pending bugs in bugzilla. I am also planning to add the code for epst in paride (i saw in many forums that people are not able to use their scanner on latest kernels).

regards
sudip

Quoted 4 lines

thanks,

greg k-h

#25 lore raw
Quoted 12 lines · Sudip Mukherjee
Quoted 9 lines · Greg Kroah-Hartman
Quoted 6 lines · Sudip Mukherjee

After 5 versions of WIP, finally a patch submission. parport subsystem is now in the transition stage and supports the old model and the new device model. 3 of the drivers have been converted into new model and tested.
After other drivers are converted we can remove the old code from parport.

This looks good, very nice job.

Thanks, but its not me alone. Dan, Jean, Alan has helped me a lot in this.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Are you going to continue to fix up the other drivers? I don't want us to have a half-converted subsystem in the kernel.

ofcourse yes. I also donot want to be a maintainer of half converted subsystem. :)
i am thinking, after it is in the linux-next for a few days and seeing any effects of these changes I will start with the other drivers. and after all drivers are converted and that is also in next for sufficient days I will start with the cleanup of the old codes.

Sounds like a good plan.

Quoted 3 lines

And then there are some pending bugs in bugzilla. I am also planning to add the code for epst in paride (i saw in many forums that people are not able to use their scanner on latest kernels).

"epst"? What's that?

author maintainer
#26 lore raw
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Sudip Mukherjee
Quoted 1 line · Greg Kroah-Hartman

On Wed, May 20, 2015 at 08:56:56PM +0530, Sudip Mukherjee wrote:

<snip>

Quoted 6 lines
Quoted 4 lines

And then there are some pending bugs in bugzilla. I am also planning to add the code for epst in paride (i saw in many forums that people are not able to use their scanner on latest kernels).

"epst"? What's that?

it was part of ppscsi, mainly needed to use HP scanjet 5100C. I had a short look and it seems like the other parts of ppscsi are already there in paride, but somehow epst was leftout and Tim says he is not interested with that code now. And besides paride might get orphaned now, so there is noone else to re-add that support in the newer kernels. My only hesitation is that I donot have the scanner to test the code. :(

regards
sudip

Quoted 1 line