Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sudip Mukherjee and committed by
Martin K. Petersen
9d7ab5aa 648a0a7d

+40 -6
+40 -6
drivers/scsi/ppa.c
··· 37 37 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */ 38 38 unsigned int failed:1; /* Failure flag */ 39 39 unsigned wanted:1; /* Parport sharing busy flag */ 40 + unsigned int dev_no; /* Device number */ 40 41 wait_queue_head_t *waiting; 41 42 struct Scsi_Host *host; 42 43 struct list_head list; ··· 986 985 987 986 static LIST_HEAD(ppa_hosts); 988 987 988 + /* 989 + * Finds the first available device number that can be alloted to the 990 + * new ppa device and returns the address of the previous node so that 991 + * we can add to the tail and have a list in the ascending order. 992 + */ 993 + 994 + static inline ppa_struct *find_parent(void) 995 + { 996 + ppa_struct *dev, *par = NULL; 997 + unsigned int cnt = 0; 998 + 999 + if (list_empty(&ppa_hosts)) 1000 + return NULL; 1001 + 1002 + list_for_each_entry(dev, &ppa_hosts, list) { 1003 + if (dev->dev_no != cnt) 1004 + return par; 1005 + cnt++; 1006 + par = dev; 1007 + } 1008 + 1009 + return par; 1010 + } 1011 + 989 1012 static int __ppa_attach(struct parport *pb) 990 1013 { 991 1014 struct Scsi_Host *host; 992 1015 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting); 993 1016 DEFINE_WAIT(wait); 994 - ppa_struct *dev; 1017 + ppa_struct *dev, *temp; 995 1018 int ports; 996 1019 int modes, ppb, ppb_hi; 997 1020 int err = -ENOMEM; 1021 + struct pardev_cb ppa_cb; 998 1022 999 1023 dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL); 1000 1024 if (!dev) ··· 1028 1002 dev->mode = PPA_AUTODETECT; 1029 1003 dev->recon_tmo = PPA_RECON_TMO; 1030 1004 init_waitqueue_head(&waiting); 1031 - dev->dev = parport_register_device(pb, "ppa", NULL, ppa_wakeup, 1032 - NULL, 0, dev); 1005 + temp = find_parent(); 1006 + if (temp) 1007 + dev->dev_no = temp->dev_no + 1; 1008 + 1009 + memset(&ppa_cb, 0, sizeof(ppa_cb)); 1010 + ppa_cb.private = dev; 1011 + ppa_cb.wakeup = ppa_wakeup; 1012 + 1013 + dev->dev = parport_register_dev_model(pb, "ppa", &ppa_cb, dev->dev_no); 1033 1014 1034 1015 if (!dev->dev) 1035 1016 goto out; ··· 1143 1110 } 1144 1111 1145 1112 static struct parport_driver ppa_driver = { 1146 - .name = "ppa", 1147 - .attach = ppa_attach, 1148 - .detach = ppa_detach, 1113 + .name = "ppa", 1114 + .match_port = ppa_attach, 1115 + .detach = ppa_detach, 1116 + .devmodel = true, 1149 1117 }; 1150 1118 1151 1119 static int __init ppa_driver_init(void)