aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/sc1200.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:16 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:16 -0400
commit96776f3b57eb7beb889a4368937cc9d74082a47e (patch)
treeaabc32ed968684f142ad876fd707ed63a35f836a /drivers/ide/pci/sc1200.c
parent1d76d9dc448d5a6fc7b49ba06c634aa6927bcc3d (diff)
sc1200: convert to use ->host_priv
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/sc1200.c')
-rw-r--r--drivers/ide/pci/sc1200.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 8fd9cc2119d6..fa2ce76837d0 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -234,21 +234,11 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
234 * we only save state when going from full power to less 234 * we only save state when going from full power to less
235 */ 235 */
236 if (state.event == PM_EVENT_ON) { 236 if (state.event == PM_EVENT_ON) {
237 struct sc1200_saved_state *ss; 237 struct ide_host *host = pci_get_drvdata(dev);
238 struct sc1200_saved_state *ss = host->host_priv;
238 unsigned int r; 239 unsigned int r;
239 240
240 /* 241 /*
241 * allocate a permanent save area, if not already allocated
242 */
243 ss = (struct sc1200_saved_state *)pci_get_drvdata(dev);
244 if (ss == NULL) {
245 ss = kmalloc(sizeof(*ss), GFP_KERNEL);
246 if (ss == NULL)
247 return -ENOMEM;
248 pci_set_drvdata(dev, ss);
249 }
250
251 /*
252 * save timing registers 242 * save timing registers
253 * (this may be unnecessary if BIOS also does it) 243 * (this may be unnecessary if BIOS also does it)
254 */ 244 */
@@ -263,7 +253,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
263 253
264static int sc1200_resume (struct pci_dev *dev) 254static int sc1200_resume (struct pci_dev *dev)
265{ 255{
266 struct sc1200_saved_state *ss; 256 struct ide_host *host = pci_get_drvdata(dev);
257 struct sc1200_saved_state *ss = host->host_priv;
267 unsigned int r; 258 unsigned int r;
268 int i; 259 int i;
269 260
@@ -271,16 +262,12 @@ static int sc1200_resume (struct pci_dev *dev)
271 if (i) 262 if (i)
272 return i; 263 return i;
273 264
274 ss = (struct sc1200_saved_state *)pci_get_drvdata(dev);
275
276 /* 265 /*
277 * restore timing registers 266 * restore timing registers
278 * (this may be unnecessary if BIOS also does it) 267 * (this may be unnecessary if BIOS also does it)
279 */ 268 */
280 if (ss) { 269 for (r = 0; r < 8; r++)
281 for (r = 0; r < 8; r++) 270 pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
282 pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
283 }
284 271
285 return 0; 272 return 0;
286} 273}
@@ -317,7 +304,19 @@ static const struct ide_port_info sc1200_chipset __devinitdata = {
317 304
318static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) 305static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
319{ 306{
320 return ide_pci_init_one(dev, &sc1200_chipset, NULL); 307 struct sc1200_saved_state *ss = NULL;
308 int rc;
309
310#ifdef CONFIG_PM
311 ss = kmalloc(sizeof(*ss), GFP_KERNEL);
312 if (ss == NULL)
313 return -ENOMEM;
314#endif
315 rc = ide_pci_init_one(dev, &sc1200_chipset, ss);
316 if (rc)
317 kfree(ss);
318
319 return rc;
321} 320}
322 321
323static const struct pci_device_id sc1200_pci_tbl[] = { 322static const struct pci_device_id sc1200_pci_tbl[] = {