aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-06-28 12:58:28 -0400
committerJeff Garzik <jeff@garzik.org>2006-07-16 11:48:28 -0400
commitd96715c1acb119cef4b2443ba9b3777b730139e6 (patch)
tree232ff826587a342b0dc290c180b843d84446bef0 /drivers/scsi
parent82d6897fefca6206bca7153805b4c5359ce97fc4 (diff)
[PATCH] ata_piix: add host_set private structure
Add host_set private structure piix_host_priv. Currently the only field is ->map which used to be stored directly at host_set->private_data. This change allows more host_set private fields to be added. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ata_piix.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 94b1261a259d..bf41dd3a35d2 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -144,8 +144,13 @@ struct piix_map_db {
144 const int map[][4]; 144 const int map[][4];
145}; 145};
146 146
147struct piix_host_priv {
148 const int *map;
149};
150
147static int piix_init_one (struct pci_dev *pdev, 151static int piix_init_one (struct pci_dev *pdev,
148 const struct pci_device_id *ent); 152 const struct pci_device_id *ent);
153static void piix_host_stop(struct ata_host_set *host_set);
149static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); 154static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
150static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); 155static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
151static void piix_pata_error_handler(struct ata_port *ap); 156static void piix_pata_error_handler(struct ata_port *ap);
@@ -254,7 +259,7 @@ static const struct ata_port_operations piix_pata_ops = {
254 259
255 .port_start = ata_port_start, 260 .port_start = ata_port_start,
256 .port_stop = ata_port_stop, 261 .port_stop = ata_port_stop,
257 .host_stop = ata_host_stop, 262 .host_stop = piix_host_stop,
258}; 263};
259 264
260static const struct ata_port_operations piix_sata_ops = { 265static const struct ata_port_operations piix_sata_ops = {
@@ -284,10 +289,10 @@ static const struct ata_port_operations piix_sata_ops = {
284 289
285 .port_start = ata_port_start, 290 .port_start = ata_port_start,
286 .port_stop = ata_port_stop, 291 .port_stop = ata_port_stop,
287 .host_stop = ata_host_stop, 292 .host_stop = piix_host_stop,
288}; 293};
289 294
290static struct piix_map_db ich5_map_db = { 295static const struct piix_map_db ich5_map_db = {
291 .mask = 0x7, 296 .mask = 0x7,
292 .map = { 297 .map = {
293 /* PM PS SM SS MAP */ 298 /* PM PS SM SS MAP */
@@ -302,7 +307,7 @@ static struct piix_map_db ich5_map_db = {
302 }, 307 },
303}; 308};
304 309
305static struct piix_map_db ich6_map_db = { 310static const struct piix_map_db ich6_map_db = {
306 .mask = 0x3, 311 .mask = 0x3,
307 .map = { 312 .map = {
308 /* PM PS SM SS MAP */ 313 /* PM PS SM SS MAP */
@@ -313,7 +318,7 @@ static struct piix_map_db ich6_map_db = {
313 }, 318 },
314}; 319};
315 320
316static struct piix_map_db ich6m_map_db = { 321static const struct piix_map_db ich6m_map_db = {
317 .mask = 0x3, 322 .mask = 0x3,
318 .map = { 323 .map = {
319 /* PM PS SM SS MAP */ 324 /* PM PS SM SS MAP */
@@ -324,6 +329,14 @@ static struct piix_map_db ich6m_map_db = {
324 }, 329 },
325}; 330};
326 331
332static const struct piix_map_db *piix_map_db_table[] = {
333 [ich5_sata] = &ich5_map_db,
334 [esb_sata] = &ich5_map_db,
335 [ich6_sata] = &ich6_map_db,
336 [ich6_sata_ahci] = &ich6_map_db,
337 [ich6m_sata_ahci] = &ich6m_map_db,
338};
339
327static struct ata_port_info piix_port_info[] = { 340static struct ata_port_info piix_port_info[] = {
328 /* piix4_pata */ 341 /* piix4_pata */
329 { 342 {
@@ -362,7 +375,6 @@ static struct ata_port_info piix_port_info[] = {
362 .mwdma_mask = 0x07, /* mwdma0-2 */ 375 .mwdma_mask = 0x07, /* mwdma0-2 */
363 .udma_mask = 0x7f, /* udma0-6 */ 376 .udma_mask = 0x7f, /* udma0-6 */
364 .port_ops = &piix_sata_ops, 377 .port_ops = &piix_sata_ops,
365 .private_data = &ich5_map_db,
366 }, 378 },
367 379
368 /* i6300esb_sata */ 380 /* i6300esb_sata */
@@ -374,7 +386,6 @@ static struct ata_port_info piix_port_info[] = {
374 .mwdma_mask = 0x07, /* mwdma0-2 */ 386 .mwdma_mask = 0x07, /* mwdma0-2 */
375 .udma_mask = 0x7f, /* udma0-6 */ 387 .udma_mask = 0x7f, /* udma0-6 */
376 .port_ops = &piix_sata_ops, 388 .port_ops = &piix_sata_ops,
377 .private_data = &ich5_map_db,
378 }, 389 },
379 390
380 /* ich6_sata */ 391 /* ich6_sata */
@@ -386,7 +397,6 @@ static struct ata_port_info piix_port_info[] = {
386 .mwdma_mask = 0x07, /* mwdma0-2 */ 397 .mwdma_mask = 0x07, /* mwdma0-2 */
387 .udma_mask = 0x7f, /* udma0-6 */ 398 .udma_mask = 0x7f, /* udma0-6 */
388 .port_ops = &piix_sata_ops, 399 .port_ops = &piix_sata_ops,
389 .private_data = &ich6_map_db,
390 }, 400 },
391 401
392 /* ich6_sata_ahci */ 402 /* ich6_sata_ahci */
@@ -399,7 +409,6 @@ static struct ata_port_info piix_port_info[] = {
399 .mwdma_mask = 0x07, /* mwdma0-2 */ 409 .mwdma_mask = 0x07, /* mwdma0-2 */
400 .udma_mask = 0x7f, /* udma0-6 */ 410 .udma_mask = 0x7f, /* udma0-6 */
401 .port_ops = &piix_sata_ops, 411 .port_ops = &piix_sata_ops,
402 .private_data = &ich6_map_db,
403 }, 412 },
404 413
405 /* ich6m_sata_ahci */ 414 /* ich6m_sata_ahci */
@@ -412,7 +421,6 @@ static struct ata_port_info piix_port_info[] = {
412 .mwdma_mask = 0x07, /* mwdma0-2 */ 421 .mwdma_mask = 0x07, /* mwdma0-2 */
413 .udma_mask = 0x7f, /* udma0-6 */ 422 .udma_mask = 0x7f, /* udma0-6 */
414 .port_ops = &piix_sata_ops, 423 .port_ops = &piix_sata_ops,
415 .private_data = &ich6m_map_db,
416 }, 424 },
417}; 425};
418 426
@@ -508,7 +516,8 @@ static void piix_pata_error_handler(struct ata_port *ap)
508static int piix_sata_prereset(struct ata_port *ap) 516static int piix_sata_prereset(struct ata_port *ap)
509{ 517{
510 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 518 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
511 const unsigned int *map = ap->host_set->private_data; 519 struct piix_host_priv *hpriv = ap->host_set->private_data;
520 const unsigned int *map = hpriv->map;
512 int base = 2 * ap->hard_port_no; 521 int base = 2 * ap->hard_port_no;
513 unsigned int present_mask = 0; 522 unsigned int present_mask = 0;
514 int port, i; 523 int port, i;
@@ -762,9 +771,10 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
762} 771}
763 772
764static void __devinit piix_init_sata_map(struct pci_dev *pdev, 773static void __devinit piix_init_sata_map(struct pci_dev *pdev,
765 struct ata_port_info *pinfo) 774 struct ata_port_info *pinfo,
775 const struct piix_map_db *map_db)
766{ 776{
767 struct piix_map_db *map_db = pinfo[0].private_data; 777 struct piix_host_priv *hpriv = pinfo[0].private_data;
768 const unsigned int *map; 778 const unsigned int *map;
769 int i, invalid_map = 0; 779 int i, invalid_map = 0;
770 u8 map_value; 780 u8 map_value;
@@ -805,8 +815,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
805 dev_printk(KERN_ERR, &pdev->dev, 815 dev_printk(KERN_ERR, &pdev->dev,
806 "invalid MAP value %u\n", map_value); 816 "invalid MAP value %u\n", map_value);
807 817
808 pinfo[0].private_data = (void *)map; 818 hpriv->map = map;
809 pinfo[1].private_data = (void *)map;
810} 819}
811 820
812/** 821/**
@@ -829,6 +838,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
829 static int printed_version; 838 static int printed_version;
830 struct ata_port_info port_info[2]; 839 struct ata_port_info port_info[2];
831 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; 840 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
841 struct piix_host_priv *hpriv;
832 unsigned long host_flags; 842 unsigned long host_flags;
833 843
834 if (!printed_version++) 844 if (!printed_version++)
@@ -839,8 +849,14 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
839 if (!in_module_init) 849 if (!in_module_init)
840 return -ENODEV; 850 return -ENODEV;
841 851
852 hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
853 if (!hpriv)
854 return -ENOMEM;
855
842 port_info[0] = piix_port_info[ent->driver_data]; 856 port_info[0] = piix_port_info[ent->driver_data];
843 port_info[1] = piix_port_info[ent->driver_data]; 857 port_info[1] = piix_port_info[ent->driver_data];
858 port_info[0].private_data = hpriv;
859 port_info[1].private_data = hpriv;
844 860
845 host_flags = port_info[0].host_flags; 861 host_flags = port_info[0].host_flags;
846 862
@@ -856,7 +872,8 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
856 872
857 /* Initialize SATA map */ 873 /* Initialize SATA map */
858 if (host_flags & ATA_FLAG_SATA) 874 if (host_flags & ATA_FLAG_SATA)
859 piix_init_sata_map(pdev, port_info); 875 piix_init_sata_map(pdev, port_info,
876 piix_map_db_table[ent->driver_data]);
860 877
861 /* On ICH5, some BIOSen disable the interrupt using the 878 /* On ICH5, some BIOSen disable the interrupt using the
862 * PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3. 879 * PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3.
@@ -879,6 +896,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
879 return ata_pci_init_one(pdev, ppinfo, 2); 896 return ata_pci_init_one(pdev, ppinfo, 2);
880} 897}
881 898
899static void piix_host_stop(struct ata_host_set *host_set)
900{
901 if (host_set->next == NULL)
902 kfree(host_set->private_data);
903 ata_host_stop(host_set);
904}
905
882static int __init piix_init(void) 906static int __init piix_init(void)
883{ 907{
884 int rc; 908 int rc;