bfad_im.c (b504293fe9dc42917a919044f2b672fb361329d0) bfad_im.c (42b426ecb453cf49c3d16cf1d7a5e5d8cab9869d)
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it

--- 504 unchanged lines hidden (view full) ---

513 * Allocate a Scsi_Host for a port.
514 */
515int
516bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
517 struct device *dev)
518{
519 int error = 1;
520
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it

--- 504 unchanged lines hidden (view full) ---

513 * Allocate a Scsi_Host for a port.
514 */
515int
516bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
517 struct device *dev)
518{
519 int error = 1;
520
521 mutex_lock(&bfad_mutex);
521 if (!idr_pre_get(&bfad_im_port_index, GFP_KERNEL)) {
522 if (!idr_pre_get(&bfad_im_port_index, GFP_KERNEL)) {
523 mutex_unlock(&bfad_mutex);
522 printk(KERN_WARNING "idr_pre_get failure\n");
523 goto out;
524 }
525
526 error = idr_get_new(&bfad_im_port_index, im_port,
527 &im_port->idr_id);
528 if (error) {
524 printk(KERN_WARNING "idr_pre_get failure\n");
525 goto out;
526 }
527
528 error = idr_get_new(&bfad_im_port_index, im_port,
529 &im_port->idr_id);
530 if (error) {
531 mutex_unlock(&bfad_mutex);
529 printk(KERN_WARNING "idr_get_new failure\n");
530 goto out;
531 }
532
532 printk(KERN_WARNING "idr_get_new failure\n");
533 goto out;
534 }
535
536 mutex_unlock(&bfad_mutex);
537
533 im_port->shost = bfad_os_scsi_host_alloc(im_port, bfad);
534 if (!im_port->shost) {
535 error = 1;
536 goto out_free_idr;
537 }
538
539 im_port->shost->hostdata[0] = (unsigned long)im_port;
540 im_port->shost->unique_id = im_port->idr_id;

--- 17 unchanged lines hidden (view full) ---

558 /* setup host fixed attribute if the lk supports */
559 bfad_os_fc_host_init(im_port);
560
561 return 0;
562
563out_fc_rel:
564 scsi_host_put(im_port->shost);
565out_free_idr:
538 im_port->shost = bfad_os_scsi_host_alloc(im_port, bfad);
539 if (!im_port->shost) {
540 error = 1;
541 goto out_free_idr;
542 }
543
544 im_port->shost->hostdata[0] = (unsigned long)im_port;
545 im_port->shost->unique_id = im_port->idr_id;

--- 17 unchanged lines hidden (view full) ---

563 /* setup host fixed attribute if the lk supports */
564 bfad_os_fc_host_init(im_port);
565
566 return 0;
567
568out_fc_rel:
569 scsi_host_put(im_port->shost);
570out_free_idr:
571 mutex_lock(&bfad_mutex);
566 idr_remove(&bfad_im_port_index, im_port->idr_id);
572 idr_remove(&bfad_im_port_index, im_port->idr_id);
573 mutex_unlock(&bfad_mutex);
567out:
568 return error;
569}
570
571void
572bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port)
573{
574out:
575 return error;
576}
577
578void
579bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port)
580{
574 unsigned long flags;
575
576 bfa_trc(bfad, bfad->inst_no);
577 bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_HOST_FREE,
578 im_port->shost->host_no);
579
580 fc_remove_host(im_port->shost);
581
582 scsi_remove_host(im_port->shost);
583 scsi_host_put(im_port->shost);
584
581 bfa_trc(bfad, bfad->inst_no);
582 bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_HOST_FREE,
583 im_port->shost->host_no);
584
585 fc_remove_host(im_port->shost);
586
587 scsi_remove_host(im_port->shost);
588 scsi_host_put(im_port->shost);
589
585 spin_lock_irqsave(&bfad->bfad_lock, flags);
590 mutex_lock(&bfad_mutex);
586 idr_remove(&bfad_im_port_index, im_port->idr_id);
591 idr_remove(&bfad_im_port_index, im_port->idr_id);
587 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
592 mutex_unlock(&bfad_mutex);
588}
589
590static void
591bfad_im_port_delete_handler(struct work_struct *work)
592{
593 struct bfad_im_port_s *im_port =
594 container_of(work, struct bfad_im_port_s, port_delete_work);
595

--- 631 unchanged lines hidden ---
593}
594
595static void
596bfad_im_port_delete_handler(struct work_struct *work)
597{
598 struct bfad_im_port_s *im_port =
599 container_of(work, struct bfad_im_port_s, port_delete_work);
600

--- 631 unchanged lines hidden ---