aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_hpt37x.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-03-24 23:22:49 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:17 -0400
commit887125e3740283be25564bfc6fb5d24974b651ab (patch)
treebd037e1c17a468fabe1834e707b70b4b43513e4a /drivers/ata/pata_hpt37x.c
parent1bd5b715a305f6f13455e89becbd839010dd14b5 (diff)
libata: stop overloading port_info->private_data
port_info->private_data is currently used for two purposes - to record private data about the port_info or to specify host->private_data to use when allocating ata_host. This overloading is confusing and counter-intuitive in that port_info->private_data becomes host->private_data instead of port->private_data. In addition, port_info and host don't correspond to each other 1-to-1. Currently, the first non-NULL port_info->private_data is used. This patch makes port_info->private_data just be what it is - private_data for the port_info where LLD can jot down extra info. libata no longer sets host->private_data to the first non-NULL port_info->private_data, @host_priv argument is added to ata_pci_init_one() instead. LLDs which use ata_pci_init_one() can use this argument to pass in pointer to host private data. LLDs which don't should use init-register model anyway and can initialize host->private_data directly. Adding @host_priv instead of using init-register model for LLDs which use ata_pci_init_one() is suggested by Alan Cox. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Diffstat (limited to 'drivers/ata/pata_hpt37x.c')
-rw-r--r--drivers/ata/pata_hpt37x.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index a43c19753669..fb37e3a161fc 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -831,10 +831,8 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
831 }; 831 };
832 832
833 static const int MHz[4] = { 33, 40, 50, 66 }; 833 static const int MHz[4] = { 33, 40, 50, 66 };
834 const struct ata_port_info *port;
835 void *private_data = NULL; 834 void *private_data = NULL;
836 struct ata_port_info port_info; 835 const struct ata_port_info *ppi[] = { NULL, NULL };
837 const struct ata_port_info *ppi[] = { &port_info, NULL };
838 836
839 u8 irqmask; 837 u8 irqmask;
840 u32 class_rev; 838 u32 class_rev;
@@ -866,17 +864,17 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
866 864
867 switch(class_rev) { 865 switch(class_rev) {
868 case 3: 866 case 3:
869 port = &info_hpt370; 867 ppi[0] = &info_hpt370;
870 chip_table = &hpt370; 868 chip_table = &hpt370;
871 prefer_dpll = 0; 869 prefer_dpll = 0;
872 break; 870 break;
873 case 4: 871 case 4:
874 port = &info_hpt370a; 872 ppi[0] = &info_hpt370a;
875 chip_table = &hpt370a; 873 chip_table = &hpt370a;
876 prefer_dpll = 0; 874 prefer_dpll = 0;
877 break; 875 break;
878 case 5: 876 case 5:
879 port = &info_hpt372; 877 ppi[0] = &info_hpt372;
880 chip_table = &hpt372; 878 chip_table = &hpt372;
881 break; 879 break;
882 default: 880 default:
@@ -889,21 +887,21 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
889 /* 372N if rev >= 2*/ 887 /* 372N if rev >= 2*/
890 if (class_rev >= 2) 888 if (class_rev >= 2)
891 return -ENODEV; 889 return -ENODEV;
892 port = &info_hpt372; 890 ppi[0] = &info_hpt372;
893 chip_table = &hpt372a; 891 chip_table = &hpt372a;
894 break; 892 break;
895 case PCI_DEVICE_ID_TTI_HPT302: 893 case PCI_DEVICE_ID_TTI_HPT302:
896 /* 302N if rev > 1 */ 894 /* 302N if rev > 1 */
897 if (class_rev > 1) 895 if (class_rev > 1)
898 return -ENODEV; 896 return -ENODEV;
899 port = &info_hpt372; 897 ppi[0] = &info_hpt372;
900 /* Check this */ 898 /* Check this */
901 chip_table = &hpt302; 899 chip_table = &hpt302;
902 break; 900 break;
903 case PCI_DEVICE_ID_TTI_HPT371: 901 case PCI_DEVICE_ID_TTI_HPT371:
904 if (class_rev > 1) 902 if (class_rev > 1)
905 return -ENODEV; 903 return -ENODEV;
906 port = &info_hpt372; 904 ppi[0] = &info_hpt372;
907 chip_table = &hpt371; 905 chip_table = &hpt371;
908 /* Single channel device, master is not present 906 /* Single channel device, master is not present
909 but the BIOS (or us for non x86) must mark it 907 but the BIOS (or us for non x86) must mark it
@@ -914,7 +912,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
914 break; 912 break;
915 case PCI_DEVICE_ID_TTI_HPT374: 913 case PCI_DEVICE_ID_TTI_HPT374:
916 chip_table = &hpt374; 914 chip_table = &hpt374;
917 port = &info_hpt374; 915 ppi[0] = &info_hpt374;
918 break; 916 break;
919 default: 917 default:
920 printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device); 918 printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device);
@@ -993,7 +991,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
993 int dpll, adjust; 991 int dpll, adjust;
994 992
995 /* Compute DPLL */ 993 /* Compute DPLL */
996 dpll = (port->udma_mask & 0xC0) ? 3 : 2; 994 dpll = (ppi[0]->udma_mask & 0xC0) ? 3 : 2;
997 995
998 f_low = (MHz[clock_slot] * 48) / MHz[dpll]; 996 f_low = (MHz[clock_slot] * 48) / MHz[dpll];
999 f_high = f_low + 2; 997 f_high = f_low + 2;
@@ -1033,19 +1031,16 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1033 * about lack of UDMA133 support on lower clocks 1031 * about lack of UDMA133 support on lower clocks
1034 */ 1032 */
1035 1033
1036 if (clock_slot < 2 && port == &info_hpt370) 1034 if (clock_slot < 2 && ppi[0] == &info_hpt370)
1037 port = &info_hpt370_33; 1035 ppi[0] = &info_hpt370_33;
1038 if (clock_slot < 2 && port == &info_hpt370a) 1036 if (clock_slot < 2 && ppi[0] == &info_hpt370a)
1039 port = &info_hpt370a_33; 1037 ppi[0] = &info_hpt370a_33;
1040 printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n", 1038 printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n",
1041 chip_table->name, MHz[clock_slot]); 1039 chip_table->name, MHz[clock_slot]);
1042 } 1040 }
1043 1041
1044 /* Now kick off ATA set up */ 1042 /* Now kick off ATA set up */
1045 port_info = *port; 1043 return ata_pci_init_one(dev, ppi, &hpt37x_sht, private_data);
1046 port_info.private_data = private_data;
1047
1048 return ata_pci_init_one(dev, ppi, &hpt37x_sht);
1049} 1044}
1050 1045
1051static const struct pci_device_id hpt37x[] = { 1046static const struct pci_device_id hpt37x[] = {