Patchwork Fix bootswitch of SATA/PATA

login
register
about
Submitter Rudolf Marek
Date 2010-10-06 22:31:57
Message ID <4CACF8DD.6050509@assembler.cz>
Download mbox | patch
Permalink /patch/2059/
State Accepted
Headers show

Comments

Rudolf Marek - 2010-10-06 22:31:57
Hello,

Following patch fixes the boot_switch_sata_ide logic. It can swap primary / 
secondary IDE channel with SATA (in IDE mode).

The bug was that setup was done in wrong device.

Signed-off-by: Rudolf Marek <r.marek@assembler.cz>

Thanks,
Rudolf
Uwe Hermann - 2010-10-10 19:05:12
On Thu, Oct 07, 2010 at 12:31:57AM +0200, Rudolf Marek wrote:
> Hello,
> 
> Following patch fixes the boot_switch_sata_ide logic. It can swap
> primary / secondary IDE channel with SATA (in IDE mode).
> 
> The bug was that setup was done in wrong device.
> 
> Signed-off-by: Rudolf Marek <r.marek@assembler.cz>

Yep, indeed.

Acked-by: Uwe Hermann <uwe@hermann-uwe.de>


> Index: sb700_ide.c
> ===================================================================
> --- sb700_ide.c	(revision 5917)
> +++ sb700_ide.c	(working copy)
> @@ -52,10 +53,13 @@
>  
>  	/* set ide as primary, if you want to boot from IDE, you'd better set it
>  	 * in $vendor/$mainboard/devicetree.cb */
> +	 
> +	
>  	if (conf->boot_switch_sata_ide == 1) {
> -		byte = pci_read_config8(dev, 0xAD);
> +		struct device *sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));

I personally don't like the "struct device *sm_dev" to be defined here,
please consider putting it at the beginning of the function, not in the
middle (yeah, I know, it works, I just don't like it much).


Uwe.
Warren Turkal - 2010-10-11 06:14:15
On Sun, Oct 10, 2010 at 12:05 PM, Uwe Hermann <uwe@hermann-uwe.de> wrote:
*snip*

>> ===================================================================
>> --- sb700_ide.c       (revision 5917)
>> +++ sb700_ide.c       (working copy)
>> @@ -52,10 +53,13 @@
>>
>>       /* set ide as primary, if you want to boot from IDE, you'd better set it
>>        * in $vendor/$mainboard/devicetree.cb */
>> +
>> +
>>       if (conf->boot_switch_sata_ide == 1) {
>> -             byte = pci_read_config8(dev, 0xAD);
>> +             struct device *sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
>
> I personally don't like the "struct device *sm_dev" to be defined here,
> please consider putting it at the beginning of the function, not in the
> middle (yeah, I know, it works, I just don't like it much).

Doesn't declaring the struct there mean that it's only available
within that block's scope? Is there any reason to declare the var
outside that block if that's the only place where the var is used?

Thanks,
wt

Patch

Index: sb700_ide.c
===================================================================
--- sb700_ide.c	(revision 5917)
+++ sb700_ide.c	(working copy)
@@ -52,10 +53,13 @@ 
 
 	/* set ide as primary, if you want to boot from IDE, you'd better set it
 	 * in $vendor/$mainboard/devicetree.cb */
+	 
+	
 	if (conf->boot_switch_sata_ide == 1) {
-		byte = pci_read_config8(dev, 0xAD);
+		struct device *sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
+		byte = pci_read_config8(sm_dev, 0xAD);
 		byte |= 1 << 4;
-		pci_write_config8(dev, 0xAD, byte);
+		pci_write_config8(sm_dev, 0xAD, byte);
 	}
 
 #if CONFIG_PCI_ROM_RUN == 1