diff options
author | Vasu Dev <vasu.dev@intel.com> | 2009-03-17 14:42:29 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-04-03 10:23:07 -0400 |
commit | a0a25da2a495a889664dc946942b8666665cd1e1 (patch) | |
tree | f3ac1dd6adb76490afa828298e71992ba5045d8f | |
parent | fdd78027fd472351783fb6110a72d991c1a07402 (diff) |
[SCSI] fcoe, libfc: fix double fcoe_softc memory alloc
The foce_softc mem was reserved by libfc_host_alloc as well as
by fcoe_host_alloc.
Removes one liner fcoe_host_alloc completely, instead directly calls
libfc_host_alloc to alloc scsi_host with libfc for just one fcoe_softc
as fcoe private data.
Moves libfc_host_alloc to libfc.h since it is a libfc API, placed
lport_priv API adjacent to libfc_host_alloc since this is related
to scsi_host priv data.
Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 33 | ||||
-rw-r--r-- | include/scsi/libfc.h | 22 |
2 files changed, 19 insertions, 36 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 30161a26387a..d5f009ad0388 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
@@ -70,8 +70,6 @@ static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *); | |||
70 | static int fcoe_hostlist_add(const struct fc_lport *); | 70 | static int fcoe_hostlist_add(const struct fc_lport *); |
71 | static int fcoe_hostlist_remove(const struct fc_lport *); | 71 | static int fcoe_hostlist_remove(const struct fc_lport *); |
72 | 72 | ||
73 | static struct Scsi_Host *fcoe_host_alloc(struct scsi_host_template *, int); | ||
74 | |||
75 | static int fcoe_check_wait_queue(struct fc_lport *); | 73 | static int fcoe_check_wait_queue(struct fc_lport *); |
76 | static void fcoe_recv_flogi(struct fcoe_softc *, struct fc_frame *, u8 *); | 74 | static void fcoe_recv_flogi(struct fcoe_softc *, struct fc_frame *, u8 *); |
77 | static int fcoe_device_notification(struct notifier_block *, ulong, void *); | 75 | static int fcoe_device_notification(struct notifier_block *, ulong, void *); |
@@ -464,8 +462,8 @@ static int fcoe_if_create(struct net_device *netdev) | |||
464 | if (lp) | 462 | if (lp) |
465 | return -EEXIST; | 463 | return -EEXIST; |
466 | 464 | ||
467 | shost = fcoe_host_alloc(&fcoe_shost_template, | 465 | shost = libfc_host_alloc(&fcoe_shost_template, |
468 | sizeof(struct fcoe_softc)); | 466 | sizeof(struct fcoe_softc)); |
469 | if (!shost) { | 467 | if (!shost) { |
470 | FC_DBG("Could not allocate host structure\n"); | 468 | FC_DBG("Could not allocate host structure\n"); |
471 | return -ENOMEM; | 469 | return -ENOMEM; |
@@ -1716,33 +1714,6 @@ void fcoe_clean_pending_queue(struct fc_lport *lp) | |||
1716 | EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue); | 1714 | EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue); |
1717 | 1715 | ||
1718 | /** | 1716 | /** |
1719 | * libfc_host_alloc() - Allocate a Scsi_Host with room for the fc_lport | ||
1720 | * @sht: ptr to the scsi host templ | ||
1721 | * @priv_size: size of private data after fc_lport | ||
1722 | * | ||
1723 | * Returns: ptr to Scsi_Host | ||
1724 | * TODO: to libfc? | ||
1725 | */ | ||
1726 | static inline struct Scsi_Host * | ||
1727 | libfc_host_alloc(struct scsi_host_template *sht, int priv_size) | ||
1728 | { | ||
1729 | return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size); | ||
1730 | } | ||
1731 | |||
1732 | /** | ||
1733 | * fcoe_host_alloc() - Allocate a Scsi_Host with room for the fcoe_softc | ||
1734 | * @sht: ptr to the scsi host templ | ||
1735 | * @priv_size: size of private data after fc_lport | ||
1736 | * | ||
1737 | * Returns: ptr to Scsi_Host | ||
1738 | */ | ||
1739 | struct Scsi_Host *fcoe_host_alloc(struct scsi_host_template *sht, int priv_size) | ||
1740 | { | ||
1741 | return libfc_host_alloc(sht, sizeof(struct fcoe_softc) + priv_size); | ||
1742 | } | ||
1743 | EXPORT_SYMBOL_GPL(fcoe_host_alloc); | ||
1744 | |||
1745 | /** | ||
1746 | * fcoe_reset() - Resets the fcoe | 1717 | * fcoe_reset() - Resets the fcoe |
1747 | * @shost: shost the reset is from | 1718 | * @shost: shost the reset is from |
1748 | * | 1719 | * |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 4e1d394348cf..0303a6a098cc 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -696,11 +696,6 @@ struct fc_lport { | |||
696 | /* | 696 | /* |
697 | * FC_LPORT HELPER FUNCTIONS | 697 | * FC_LPORT HELPER FUNCTIONS |
698 | *****************************/ | 698 | *****************************/ |
699 | static inline void *lport_priv(const struct fc_lport *lp) | ||
700 | { | ||
701 | return (void *)(lp + 1); | ||
702 | } | ||
703 | |||
704 | static inline int fc_lport_test_ready(struct fc_lport *lp) | 699 | static inline int fc_lport_test_ready(struct fc_lport *lp) |
705 | { | 700 | { |
706 | return lp->state == LPORT_ST_READY; | 701 | return lp->state == LPORT_ST_READY; |
@@ -743,6 +738,23 @@ static inline struct fcoe_dev_stats *fc_lport_get_stats(struct fc_lport *lp) | |||
743 | return per_cpu_ptr(lp->dev_stats, smp_processor_id()); | 738 | return per_cpu_ptr(lp->dev_stats, smp_processor_id()); |
744 | } | 739 | } |
745 | 740 | ||
741 | static inline void *lport_priv(const struct fc_lport *lp) | ||
742 | { | ||
743 | return (void *)(lp + 1); | ||
744 | } | ||
745 | |||
746 | /** | ||
747 | * libfc_host_alloc() - Allocate a Scsi_Host with room for the fc_lport | ||
748 | * @sht: ptr to the scsi host templ | ||
749 | * @priv_size: size of private data after fc_lport | ||
750 | * | ||
751 | * Returns: ptr to Scsi_Host | ||
752 | */ | ||
753 | static inline struct Scsi_Host * | ||
754 | libfc_host_alloc(struct scsi_host_template *sht, int priv_size) | ||
755 | { | ||
756 | return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size); | ||
757 | } | ||
746 | 758 | ||
747 | /* | 759 | /* |
748 | * LOCAL PORT LAYER | 760 | * LOCAL PORT LAYER |