summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2016-02-11 00:12:49 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2016-02-23 21:27:02 -0500
commit9d7ab5aa9fa4592a073973deabe6826ea1b76d4c (patch)
treed10c14634a0c613317e8e52bc2603e54cfab788b
parent648a0a7da34f281410e8e3a59de8c13ec6ea380a (diff)
scsi: ppa: use new parport device model
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> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/ppa.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index ee00e27ba396..f6ad579280d4 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -37,6 +37,7 @@ typedef struct {
37 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */ 37 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
38 unsigned int failed:1; /* Failure flag */ 38 unsigned int failed:1; /* Failure flag */
39 unsigned wanted:1; /* Parport sharing busy flag */ 39 unsigned wanted:1; /* Parport sharing busy flag */
40 unsigned int dev_no; /* Device number */
40 wait_queue_head_t *waiting; 41 wait_queue_head_t *waiting;
41 struct Scsi_Host *host; 42 struct Scsi_Host *host;
42 struct list_head list; 43 struct list_head list;
@@ -985,15 +986,40 @@ static struct scsi_host_template ppa_template = {
985 986
986static LIST_HEAD(ppa_hosts); 987static LIST_HEAD(ppa_hosts);
987 988
989/*
990 * Finds the first available device number that can be alloted to the
991 * new ppa device and returns the address of the previous node so that
992 * we can add to the tail and have a list in the ascending order.
993 */
994
995static inline ppa_struct *find_parent(void)
996{
997 ppa_struct *dev, *par = NULL;
998 unsigned int cnt = 0;
999
1000 if (list_empty(&ppa_hosts))
1001 return NULL;
1002
1003 list_for_each_entry(dev, &ppa_hosts, list) {
1004 if (dev->dev_no != cnt)
1005 return par;
1006 cnt++;
1007 par = dev;
1008 }
1009
1010 return par;
1011}
1012
988static int __ppa_attach(struct parport *pb) 1013static int __ppa_attach(struct parport *pb)
989{ 1014{
990 struct Scsi_Host *host; 1015 struct Scsi_Host *host;
991 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting); 1016 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
992 DEFINE_WAIT(wait); 1017 DEFINE_WAIT(wait);
993 ppa_struct *dev; 1018 ppa_struct *dev, *temp;
994 int ports; 1019 int ports;
995 int modes, ppb, ppb_hi; 1020 int modes, ppb, ppb_hi;
996 int err = -ENOMEM; 1021 int err = -ENOMEM;
1022 struct pardev_cb ppa_cb;
997 1023
998 dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL); 1024 dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL);
999 if (!dev) 1025 if (!dev)
@@ -1002,8 +1028,15 @@ static int __ppa_attach(struct parport *pb)
1002 dev->mode = PPA_AUTODETECT; 1028 dev->mode = PPA_AUTODETECT;
1003 dev->recon_tmo = PPA_RECON_TMO; 1029 dev->recon_tmo = PPA_RECON_TMO;
1004 init_waitqueue_head(&waiting); 1030 init_waitqueue_head(&waiting);
1005 dev->dev = parport_register_device(pb, "ppa", NULL, ppa_wakeup, 1031 temp = find_parent();
1006 NULL, 0, dev); 1032 if (temp)
1033 dev->dev_no = temp->dev_no + 1;
1034
1035 memset(&ppa_cb, 0, sizeof(ppa_cb));
1036 ppa_cb.private = dev;
1037 ppa_cb.wakeup = ppa_wakeup;
1038
1039 dev->dev = parport_register_dev_model(pb, "ppa", &ppa_cb, dev->dev_no);
1007 1040
1008 if (!dev->dev) 1041 if (!dev->dev)
1009 goto out; 1042 goto out;
@@ -1110,9 +1143,10 @@ static void ppa_detach(struct parport *pb)
1110} 1143}
1111 1144
1112static struct parport_driver ppa_driver = { 1145static struct parport_driver ppa_driver = {
1113 .name = "ppa", 1146 .name = "ppa",
1114 .attach = ppa_attach, 1147 .match_port = ppa_attach,
1115 .detach = ppa_detach, 1148 .detach = ppa_detach,
1149 .devmodel = true,
1116}; 1150};
1117 1151
1118static int __init ppa_driver_init(void) 1152static int __init ppa_driver_init(void)