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>
This commit is contained in:
Sudip Mukherjee 2016-02-11 10:42:49 +05:30 committed by Martin K. Petersen
parent 648a0a7da3
commit 9d7ab5aa9f

View File

@ -37,6 +37,7 @@ typedef struct {
unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */ unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
unsigned int failed:1; /* Failure flag */ unsigned int failed:1; /* Failure flag */
unsigned wanted:1; /* Parport sharing busy flag */ unsigned wanted:1; /* Parport sharing busy flag */
unsigned int dev_no; /* Device number */
wait_queue_head_t *waiting; wait_queue_head_t *waiting;
struct Scsi_Host *host; struct Scsi_Host *host;
struct list_head list; struct list_head list;
@ -985,15 +986,40 @@ static struct scsi_host_template ppa_template = {
static LIST_HEAD(ppa_hosts); 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) static int __ppa_attach(struct parport *pb)
{ {
struct Scsi_Host *host; struct Scsi_Host *host;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting); DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
ppa_struct *dev; ppa_struct *dev, *temp;
int ports; int ports;
int modes, ppb, ppb_hi; int modes, ppb, ppb_hi;
int err = -ENOMEM; int err = -ENOMEM;
struct pardev_cb ppa_cb;
dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL); dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL);
if (!dev) if (!dev)
@ -1002,8 +1028,15 @@ static int __ppa_attach(struct parport *pb)
dev->mode = PPA_AUTODETECT; dev->mode = PPA_AUTODETECT;
dev->recon_tmo = PPA_RECON_TMO; dev->recon_tmo = PPA_RECON_TMO;
init_waitqueue_head(&waiting); init_waitqueue_head(&waiting);
dev->dev = parport_register_device(pb, "ppa", NULL, ppa_wakeup, temp = find_parent();
NULL, 0, dev); 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) if (!dev->dev)
goto out; goto out;
@ -1110,9 +1143,10 @@ static void ppa_detach(struct parport *pb)
} }
static struct parport_driver ppa_driver = { static struct parport_driver ppa_driver = {
.name = "ppa", .name = "ppa",
.attach = ppa_attach, .match_port = ppa_attach,
.detach = ppa_detach, .detach = ppa_detach,
.devmodel = true,
}; };
static int __init ppa_driver_init(void) static int __init ppa_driver_init(void)