Re: [PATCH 2/3] drivers/ide/pci/sc1200.c: remove pointless hwif lookup loop

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bartlomiej Zolnierkiewicz
Date: Thursday, October 25, 2007 - 1:01 pm

On Thursday 25 October 2007, Jeff Garzik wrote:

It seems that we can simplify it even further and remove knowledge about
hwifs altogether from suspend/resume methods.


Please take a close look at the line above and the next three lines:

for (r = 0; r < 4; ++r) {
	pci_read_config_dword (hwif->pci_dev, basereg + (r<<2), &ss->regs[r]);
}

It is highly obfuscated but the sc1200_suspend() reads 16 bytes from
the offset 0x40 (for the primary port) and puts them in the corresponding
struct sc1200_saved_state_s buffer, then it reads another 16 bytes from the
offset 0x50 (for the secondary port) and puts it in the another buffer.

In summary sc1200_suspend() reads 32 continuous bytes from offset 0x40
and the exactly reverse operation happens in sc1200_resume().

Given that and the fact that struct sc1200_save_state_s buffers are used
_only_ by sc1200_{suspend,resume}() we may safely convert the code to use
one buffer for both ports (the whole PCI device).  We just need to bump
the size of struct sc1200_saved_state_s (from 4 to 8 double-words) and use
pci_{get,set}_drvdata() instead of hwif->config_data.  Then we can remove
looping over interfaces completely from sc1200_{suspend,resume}()! :)

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 2/3] drivers/ide/pci/sc1200.c: remove pointless ..., Bartlomiej Zolnierki ..., (Thu Oct 25, 1:01 pm)
Re: [PATCH 2/3] drivers/ide/pci/sc1200.c: remove pointless ..., Bartlomiej Zolnierki ..., (Wed Oct 31, 2:53 pm)