diff options
author | Tejun Heo <htejun@gmail.com> | 2010-09-21 03:25:48 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2010-09-28 15:14:51 -0400 |
commit | fad16e7a7f67eef8d33f8ad58850db89382b09ce (patch) | |
tree | 09afb3e939cd4cc85e6aec76965c16fcc03c5798 /drivers/ata | |
parent | 050026feae5bd4fe2db4096b63b15abce7c47faa (diff) |
ahci: fix module refcount breakage introduced by libahci split
libata depends on scsi_host_template for module reference counting and
sht's should be owned by each low level driver. During libahci split,
the sht was left with libahci.ko leaving the actual low level drivers
not reference counted. This made ahci and ahci_platform always
unloadable even while they're being actively used.
Fix it by defining AHCI_SHT() macro in ahci.h and defining a sht for
each low level ahci driver.
stable: only applicable to 2.6.35.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Pedro Francisco <pedrogfrancisco@gmail.com>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: stable@kernel.org
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/ahci.c | 4 | ||||
-rw-r--r-- | drivers/ata/ahci.h | 12 | ||||
-rw-r--r-- | drivers/ata/ahci_platform.c | 6 | ||||
-rw-r--r-- | drivers/ata/libahci.c | 16 |
4 files changed, 24 insertions, 14 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index ff1c945fba98..99d0e5a51148 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -90,6 +90,10 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | |||
90 | static int ahci_pci_device_resume(struct pci_dev *pdev); | 90 | static int ahci_pci_device_resume(struct pci_dev *pdev); |
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | static struct scsi_host_template ahci_sht = { | ||
94 | AHCI_SHT("ahci"), | ||
95 | }; | ||
96 | |||
93 | static struct ata_port_operations ahci_vt8251_ops = { | 97 | static struct ata_port_operations ahci_vt8251_ops = { |
94 | .inherits = &ahci_ops, | 98 | .inherits = &ahci_ops, |
95 | .hardreset = ahci_vt8251_hardreset, | 99 | .hardreset = ahci_vt8251_hardreset, |
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 474427b6f99f..e5fdeebf9ef0 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
@@ -298,7 +298,17 @@ struct ahci_host_priv { | |||
298 | 298 | ||
299 | extern int ahci_ignore_sss; | 299 | extern int ahci_ignore_sss; |
300 | 300 | ||
301 | extern struct scsi_host_template ahci_sht; | 301 | extern struct device_attribute *ahci_shost_attrs[]; |
302 | extern struct device_attribute *ahci_sdev_attrs[]; | ||
303 | |||
304 | #define AHCI_SHT(drv_name) \ | ||
305 | ATA_NCQ_SHT(drv_name), \ | ||
306 | .can_queue = AHCI_MAX_CMDS - 1, \ | ||
307 | .sg_tablesize = AHCI_MAX_SG, \ | ||
308 | .dma_boundary = AHCI_DMA_BOUNDARY, \ | ||
309 | .shost_attrs = ahci_shost_attrs, \ | ||
310 | .sdev_attrs = ahci_sdev_attrs | ||
311 | |||
302 | extern struct ata_port_operations ahci_ops; | 312 | extern struct ata_port_operations ahci_ops; |
303 | 313 | ||
304 | void ahci_save_initial_config(struct device *dev, | 314 | void ahci_save_initial_config(struct device *dev, |
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 4e97f33cca44..84b643270e7a 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
@@ -23,6 +23,10 @@ | |||
23 | #include <linux/ahci_platform.h> | 23 | #include <linux/ahci_platform.h> |
24 | #include "ahci.h" | 24 | #include "ahci.h" |
25 | 25 | ||
26 | static struct scsi_host_template ahci_platform_sht = { | ||
27 | AHCI_SHT("ahci_platform"), | ||
28 | }; | ||
29 | |||
26 | static int __init ahci_probe(struct platform_device *pdev) | 30 | static int __init ahci_probe(struct platform_device *pdev) |
27 | { | 31 | { |
28 | struct device *dev = &pdev->dev; | 32 | struct device *dev = &pdev->dev; |
@@ -145,7 +149,7 @@ static int __init ahci_probe(struct platform_device *pdev) | |||
145 | ahci_print_info(host, "platform"); | 149 | ahci_print_info(host, "platform"); |
146 | 150 | ||
147 | rc = ata_host_activate(host, irq, ahci_interrupt, IRQF_SHARED, | 151 | rc = ata_host_activate(host, irq, ahci_interrupt, IRQF_SHARED, |
148 | &ahci_sht); | 152 | &ahci_platform_sht); |
149 | if (rc) | 153 | if (rc) |
150 | goto err0; | 154 | goto err0; |
151 | 155 | ||
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 68dc6785472f..8eea309ea212 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
@@ -121,7 +121,7 @@ static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL); | |||
121 | static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO, | 121 | static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO, |
122 | ahci_read_em_buffer, ahci_store_em_buffer); | 122 | ahci_read_em_buffer, ahci_store_em_buffer); |
123 | 123 | ||
124 | static struct device_attribute *ahci_shost_attrs[] = { | 124 | struct device_attribute *ahci_shost_attrs[] = { |
125 | &dev_attr_link_power_management_policy, | 125 | &dev_attr_link_power_management_policy, |
126 | &dev_attr_em_message_type, | 126 | &dev_attr_em_message_type, |
127 | &dev_attr_em_message, | 127 | &dev_attr_em_message, |
@@ -132,22 +132,14 @@ static struct device_attribute *ahci_shost_attrs[] = { | |||
132 | &dev_attr_em_buffer, | 132 | &dev_attr_em_buffer, |
133 | NULL | 133 | NULL |
134 | }; | 134 | }; |
135 | EXPORT_SYMBOL_GPL(ahci_shost_attrs); | ||
135 | 136 | ||
136 | static struct device_attribute *ahci_sdev_attrs[] = { | 137 | struct device_attribute *ahci_sdev_attrs[] = { |
137 | &dev_attr_sw_activity, | 138 | &dev_attr_sw_activity, |
138 | &dev_attr_unload_heads, | 139 | &dev_attr_unload_heads, |
139 | NULL | 140 | NULL |
140 | }; | 141 | }; |
141 | 142 | EXPORT_SYMBOL_GPL(ahci_sdev_attrs); | |
142 | struct scsi_host_template ahci_sht = { | ||
143 | ATA_NCQ_SHT("ahci"), | ||
144 | .can_queue = AHCI_MAX_CMDS - 1, | ||
145 | .sg_tablesize = AHCI_MAX_SG, | ||
146 | .dma_boundary = AHCI_DMA_BOUNDARY, | ||
147 | .shost_attrs = ahci_shost_attrs, | ||
148 | .sdev_attrs = ahci_sdev_attrs, | ||
149 | }; | ||
150 | EXPORT_SYMBOL_GPL(ahci_sht); | ||
151 | 143 | ||
152 | struct ata_port_operations ahci_ops = { | 144 | struct ata_port_operations ahci_ops = { |
153 | .inherits = &sata_pmp_port_ops, | 145 | .inherits = &sata_pmp_port_ops, |