Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1331697 > unrolled thread

[PATCH RESEND] scsi: ppa: use new parport device model

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2016-02-11 06:20 +0100
Last post2016-02-11 15:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RESEND] scsi: ppa: use new parport device model Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-02-11 06:20 +0100
    Re: [PATCH RESEND] scsi: ppa: use new parport device model Johannes Thumshirn <jthumshirn@suse.de> - 2016-02-11 10:10 +0100
    Re: [PATCH RESEND] scsi: ppa: use new parport device model "Martin K. Petersen" <martin.petersen@oracle.com> - 2016-02-11 15:40 +0100

#1331697 — [PATCH RESEND] scsi: ppa: use new parport device model

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2016-02-11 06:20 +0100
Subject[PATCH RESEND] scsi: ppa: use new parport device model
Message-ID<r0RPA-4cy-3@gated-at.bofh.it>
Modify ppa driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

Resending as there was no review or ACK for this change.
This has exactly same changes as done in scsi/imm.c which has already
been accepted.

 drivers/scsi/ppa.c | 46 ++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index ee00e27..f6ad579 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -37,6 +37,7 @@ typedef struct {
 	unsigned long recon_tmo;	/* How many usecs to wait for reconnection (6th bit) */
 	unsigned int failed:1;	/* Failure flag                 */
 	unsigned wanted:1;	/* Parport sharing busy flag    */
+	unsigned int dev_no;	/* Device number		*/
 	wait_queue_head_t *waiting;
 	struct Scsi_Host *host;
 	struct list_head list;
@@ -985,15 +986,40 @@ static struct scsi_host_template ppa_template = {
 
 static LIST_HEAD(ppa_hosts);
 
+/*
+ * Finds the first available device number that can be alloted to the
+ * new ppa device and returns the address of the previous node so that
+ * we can add to the tail and have a list in the ascending order.
+ */
+
+static inline ppa_struct *find_parent(void)
+{
+	ppa_struct *dev, *par = NULL;
+	unsigned int cnt = 0;
+
+	if (list_empty(&ppa_hosts))
+		return NULL;
+
+	list_for_each_entry(dev, &ppa_hosts, list) {
+		if (dev->dev_no != cnt)
+			return par;
+		cnt++;
+		par = dev;
+	}
+
+	return par;
+}
+
 static int __ppa_attach(struct parport *pb)
 {
 	struct Scsi_Host *host;
 	DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
 	DEFINE_WAIT(wait);
-	ppa_struct *dev;
+	ppa_struct *dev, *temp;
 	int ports;
 	int modes, ppb, ppb_hi;
 	int err = -ENOMEM;
+	struct pardev_cb ppa_cb;
 
 	dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL);
 	if (!dev)
@@ -1002,8 +1028,15 @@ static int __ppa_attach(struct parport *pb)
 	dev->mode = PPA_AUTODETECT;
 	dev->recon_tmo = PPA_RECON_TMO;
 	init_waitqueue_head(&waiting);
-	dev->dev = parport_register_device(pb, "ppa", NULL, ppa_wakeup,
-					    NULL, 0, dev);
+	temp = find_parent();
+	if (temp)
+		dev->dev_no = temp->dev_no + 1;
+
+	memset(&ppa_cb, 0, sizeof(ppa_cb));
+	ppa_cb.private = dev;
+	ppa_cb.wakeup = ppa_wakeup;
+
+	dev->dev = parport_register_dev_model(pb, "ppa", &ppa_cb, dev->dev_no);
 
 	if (!dev->dev)
 		goto out;
@@ -1110,9 +1143,10 @@ static void ppa_detach(struct parport *pb)
 }
 
 static struct parport_driver ppa_driver = {
-	.name	= "ppa",
-	.attach	= ppa_attach,
-	.detach	= ppa_detach,
+	.name		= "ppa",
+	.match_port	= ppa_attach,
+	.detach		= ppa_detach,
+	.devmodel	= true,
 };
 
 static int __init ppa_driver_init(void)
-- 
1.9.1

[toc] | [next] | [standalone]


#1331751

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2016-02-11 10:10 +0100
Message-ID<r0Vqa-6Fe-11@gated-at.bofh.it>
In reply to#1331697
On Thu, Feb 11, 2016 at 10:42:49AM +0530, Sudip Mukherjee wrote:
> Modify ppa driver to use the new parallel port device model.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

[toc] | [prev] | [next] | [standalone]


#1332098

From"Martin K. Petersen" <martin.petersen@oracle.com>
Date2016-02-11 15:40 +0100
Message-ID<r10zz-1Ec-73@gated-at.bofh.it>
In reply to#1331697
>>>>> "Sudip" == Sudip Mukherjee <sudipm.mukherjee@gmail.com> writes:

Sudip> Modify ppa driver to use the new parallel port device model.
Sudip> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> ---

Sudip> Resending as there was no review or ACK for this change.  This
Sudip> has exactly same changes as done in scsi/imm.c which has already
Sudip> been accepted.

Applied to 4.6/scsi-queue.

Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web