pci-driver.c (cef9bc56e1e944afd11f96de569657117a138c6d) | pci-driver.c (ed283e9f0a2cc0541870828c76c6c6997c51a318) |
---|---|
1/* 2 * drivers/pci/pci-driver.c 3 * 4 * (C) Copyright 2002-2004, 2007 Greg Kroah-Hartman <greg@kroah.com> 5 * (C) Copyright 2007 Novell Inc. 6 * 7 * Released under the GPL v2 only. 8 * --- 174 unchanged lines hidden (view full) --- 183 184 if (retval) 185 return retval; 186 return count; 187} 188static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 189 190static int | 1/* 2 * drivers/pci/pci-driver.c 3 * 4 * (C) Copyright 2002-2004, 2007 Greg Kroah-Hartman <greg@kroah.com> 5 * (C) Copyright 2007 Novell Inc. 6 * 7 * Released under the GPL v2 only. 8 * --- 174 unchanged lines hidden (view full) --- 183 184 if (retval) 185 return retval; 186 return count; 187} 188static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 189 190static int |
191pci_create_newid_file(struct pci_driver *drv) | 191pci_create_newid_files(struct pci_driver *drv) |
192{ 193 int error = 0; | 192{ 193 int error = 0; |
194 if (drv->probe != NULL) | 194 195 if (drv->probe != NULL) { |
195 error = driver_create_file(&drv->driver, &driver_attr_new_id); | 196 error = driver_create_file(&drv->driver, &driver_attr_new_id); |
197 if (error == 0) { 198 error = driver_create_file(&drv->driver, 199 &driver_attr_remove_id); 200 if (error) 201 driver_remove_file(&drv->driver, 202 &driver_attr_new_id); 203 } 204 } |
|
196 return error; 197} 198 | 205 return error; 206} 207 |
199static void pci_remove_newid_file(struct pci_driver *drv) | 208static void pci_remove_newid_files(struct pci_driver *drv) |
200{ | 209{ |
210 driver_remove_file(&drv->driver, &driver_attr_remove_id); |
|
201 driver_remove_file(&drv->driver, &driver_attr_new_id); 202} | 211 driver_remove_file(&drv->driver, &driver_attr_new_id); 212} |
203 204static int 205pci_create_removeid_file(struct pci_driver *drv) 206{ 207 int error = 0; 208 if (drv->probe != NULL) 209 error = driver_create_file(&drv->driver,&driver_attr_remove_id); 210 return error; 211} 212 213static void pci_remove_removeid_file(struct pci_driver *drv) 214{ 215 driver_remove_file(&drv->driver, &driver_attr_remove_id); 216} | |
217#else /* !CONFIG_HOTPLUG */ | 213#else /* !CONFIG_HOTPLUG */ |
218static inline int pci_create_newid_file(struct pci_driver *drv) | 214static inline int pci_create_newid_files(struct pci_driver *drv) |
219{ 220 return 0; 221} | 215{ 216 return 0; 217} |
222static inline void pci_remove_newid_file(struct pci_driver *drv) {} 223static inline int pci_create_removeid_file(struct pci_driver *drv) 224{ 225 return 0; 226} 227static inline void pci_remove_removeid_file(struct pci_driver *drv) {} | 218static inline void pci_remove_newid_files(struct pci_driver *drv) {} |
228#endif 229 230/** 231 * pci_match_id - See if a pci device matches a given pci_id table 232 * @ids: array of PCI device id structures to search in 233 * @dev: the PCI device structure to match against. 234 * 235 * Used by a driver to check whether a PCI device present in the --- 895 unchanged lines hidden (view full) --- 1131 spin_lock_init(&drv->dynids.lock); 1132 INIT_LIST_HEAD(&drv->dynids.list); 1133 1134 /* register with core */ 1135 error = driver_register(&drv->driver); 1136 if (error) 1137 goto out; 1138 | 219#endif 220 221/** 222 * pci_match_id - See if a pci device matches a given pci_id table 223 * @ids: array of PCI device id structures to search in 224 * @dev: the PCI device structure to match against. 225 * 226 * Used by a driver to check whether a PCI device present in the --- 895 unchanged lines hidden (view full) --- 1122 spin_lock_init(&drv->dynids.lock); 1123 INIT_LIST_HEAD(&drv->dynids.list); 1124 1125 /* register with core */ 1126 error = driver_register(&drv->driver); 1127 if (error) 1128 goto out; 1129 |
1139 error = pci_create_newid_file(drv); | 1130 error = pci_create_newid_files(drv); |
1140 if (error) 1141 goto out_newid; | 1131 if (error) 1132 goto out_newid; |
1142 1143 error = pci_create_removeid_file(drv); 1144 if (error) 1145 goto out_removeid; | |
1146out: 1147 return error; 1148 | 1133out: 1134 return error; 1135 |
1149out_removeid: 1150 pci_remove_newid_file(drv); | |
1151out_newid: 1152 driver_unregister(&drv->driver); 1153 goto out; 1154} 1155 1156/** 1157 * pci_unregister_driver - unregister a pci driver 1158 * @drv: the driver structure to unregister 1159 * 1160 * Deletes the driver structure from the list of registered PCI drivers, 1161 * gives it a chance to clean up by calling its remove() function for 1162 * each device it was responsible for, and marks those devices as 1163 * driverless. 1164 */ 1165 1166void 1167pci_unregister_driver(struct pci_driver *drv) 1168{ | 1136out_newid: 1137 driver_unregister(&drv->driver); 1138 goto out; 1139} 1140 1141/** 1142 * pci_unregister_driver - unregister a pci driver 1143 * @drv: the driver structure to unregister 1144 * 1145 * Deletes the driver structure from the list of registered PCI drivers, 1146 * gives it a chance to clean up by calling its remove() function for 1147 * each device it was responsible for, and marks those devices as 1148 * driverless. 1149 */ 1150 1151void 1152pci_unregister_driver(struct pci_driver *drv) 1153{ |
1169 pci_remove_removeid_file(drv); 1170 pci_remove_newid_file(drv); | 1154 pci_remove_newid_files(drv); |
1171 driver_unregister(&drv->driver); 1172 pci_free_dynids(drv); 1173} 1174 1175static struct pci_driver pci_compat_driver = { 1176 .name = "compat" 1177}; 1178 --- 109 unchanged lines hidden --- | 1155 driver_unregister(&drv->driver); 1156 pci_free_dynids(drv); 1157} 1158 1159static struct pci_driver pci_compat_driver = { 1160 .name = "compat" 1161}; 1162 --- 109 unchanged lines hidden --- |