--- ./rewrite_eeprom_v1_9 2009-03-10 17:23:36.000000000 -0300 +++ ./rewrite_eeprom_v2_0 2009-03-11 14:13:18.000000000 -0300 @@ -129,22 +129,17 @@ $script_prevent .= "if [ ! \"\$UID\" = \"0\" ]; then\n\techo \"You must run this script as root\";\n\texit;\nfi\n\n"; $script_prevent .= "i2cset &> /dev/null\n"; - $script_prevent .= "if [ \$\? != \"1\" ]; then\n"; + $script_prevent .= "if [ ! \"\$\?\" = \"1\" ]; then\n"; $script_prevent .= "\techo \"Please install i2c-tools package before continue.\";\n"; $script_prevent .= "\texit;\n"; $script_prevent .= "fi\n\n"; $script_prevent .= "modprobe i2c-dev\n"; - $script_prevent .= "if [ \$\? != \"0\" ]; then\n"; + $script_prevent .= "if [ ! \"\$\?\" = \"0\" ]; then\n"; $script_prevent .= "\techo \"Can't load i2c-dev module.\";\n"; $script_prevent .= "\texit;\n"; $script_prevent .= "fi\n\n"; - $script_prevent .= "if [ \$\? != \"0\" ]; then\n"; - $script_prevent .= "\techo \"Can't locate eeprom in $argv.\";\n"; - $script_prevent .= "\texit;\n"; - $script_prevent .= "fi\n\n"; - $script_prevent .= "clear;\n"; $script_prevent .= "echo \""; $script_prevent .= "\n\033[1;31m# # # ###### # # ### # # #####\n"; @@ -163,13 +158,13 @@ $script_prevent .= "Are you \033[1;31mABSOLUTELY SURE\033[0m to continue? (yes or not)\";\n\n"; $script_prevent .= "read confirmation;\n"; - $script_prevent .= "if \[ \"\$confirmation\" != \"yes\" \]; then\n"; + $script_prevent .= "if \[ ! \"\$confirmation\" = \"yes\" \]; then\n"; $script_prevent .= "\techo \"process aborted\";\n"; $script_prevent .= "\texit;\n"; $script_prevent .= "fi\n\n"; $script_prevent .= "lsmod | egrep -e \"$modules\" &> /dev/null\n"; - $script_prevent .= "if [ \$\? != \"0\" ]; then\n"; + $script_prevent .= "if [ ! \"\$\?\" = \"0\" ]; then\n"; $script_prevent .= "\techo \"Aborting script.. None of the supported driver $modules_str are loaded. Did you forget to connect the device?\";\n"; $script_prevent .= "\texit;"; $script_prevent .= "\nfi\n\n"; @@ -191,7 +186,7 @@ my $lines = 0; my $output = "#!/bin/bash\n"; - system("i2cdetect -l | egrep -e \"$modules\" | cut -b 5 > $file_bus 2> /dev/null"); + system("\ni2cdetect -l | egrep -e \"$modules\" 2> /dev/null | cut -b 5 > $file_bus\n"); # Checking number if lines open(FILE, $file_bus) or die "Can't open `$file_bus': $!"; @@ -202,7 +197,7 @@ switch ($lines) { case 0 { - $output .= "echo \"Could not detect i2c bus from any device! Did you connect the device?\";\n"; + $output .= "echo \"Could not detect i2c bus from any device, run again $0. Did you forget to connect the device?\";\n"; $output .= "echo \"Modules supported: $modules_str\";\n"; $output .= "exit;"; print $output; @@ -212,7 +207,7 @@ &build_script; } else { - $output .= "humm, I got too many bus, please connect or plug just a hardware peer time!\n"; + $output .= "humm, I got too many busses, please connect or plug just a hardware peer time!\n"; $output .= "Read a note inside the script!\n"; $output .= "exit;"; print $output; @@ -238,15 +233,15 @@ } if($addrinfo eq "--") { - print "\necho \"**** Failed to recognize bus address! Run again rewrite_eeprom tool with the right dump file, aborted!\";\n"; + print "\necho \"**** Failed to recognize bus address!\n**** Please connect your device *with eeprom* and try to run $0 tool again, aborted!\";\n"; print "exit;"; } # Double check - $bkp_eeprom = "i2cdetect -y $businfo > $file_i2c_tmp 2> /dev/null;\n"; + $bkp_eeprom = "\n\ni2cdetect -y $businfo > $file_i2c_tmp 2> /dev/null;\n"; $bkp_eeprom .= "BUSCHECK=\`awk \'NR==7\' $file_i2c_tmp | cut -d \' \' -f 2\`;\n"; $bkp_eeprom .= "rm -f $file_i2c_tmp;\n"; - $bkp_eeprom .= "if [ \$BUSCHECK == \"--\" ]; then\n"; + $bkp_eeprom .= "if [ \"\$BUSCHECK\" == \"--\" ]; then\n"; $bkp_eeprom .= "\t echo \"Aborting script.. I cannot make backup of your current eeprom.. It's not safe to continue!\";\n"; $bkp_eeprom .= "\t exit;\n"; $bkp_eeprom .= "fi\n\n"; @@ -255,11 +250,15 @@ $bkp_eeprom .= "\nDATE=\`/bin/date +%Y%m%d_%I%M%S\`\n"; $bkp_eeprom .= "echo \"\nMaking backup of current eeprom - dir [$eeprom_backup_dir/eeprom-\$DATE]\";\n"; $bkp_eeprom .= "mkdir -p $eeprom_backup_dir\n"; - $bkp_eeprom .= "i2cdump -y $businfo 0x$addrinfo > $eeprom_backup_dir/eeprom-\$DATE 2> /dev/null\n"; - $bkp_eeprom .= "if [ \$\? != \"0\" ]; then\n"; + $bkp_eeprom .= "\necho \"\n--EEPROM DUMP START HERE--\n\" > $eeprom_backup_dir/eeprom-\$DATE\n"; + $bkp_eeprom .= "i2cdump -y $businfo 0x$addrinfo >> $eeprom_backup_dir/eeprom-\$DATE 2> /dev/null\n"; + $bkp_eeprom .= "if [ ! \"\$\?\" = \"0\" ]; then\n"; $bkp_eeprom .= "\t echo \"Aborting script.. I cannot make backup of your current eeprom.. It's not safe to continue!\";\n"; $bkp_eeprom .= "\t exit;"; $bkp_eeprom .= "\nfi\n"; + $bkp_eeprom .= "\necho \"\n--DMESG START HERE--\n\" >> $eeprom_backup_dir/eeprom-\$DATE\n"; + $bkp_eeprom .= "\ndmesg >> $eeprom_backup_dir/eeprom-\$DATE\n"; + print $bkp_eeprom; close FILE; @@ -285,7 +284,7 @@ close INPUT; if ($NR_EEPROM_REGS == 0) { - print "\necho \"**** Failed to recognize any dump in: $argv! Run again rewrite_eeprom tool with the right dump file, aborted..\";\n"; + print "\necho \"**** Failed to recognize any dump in: $argv! Make sure that you have the right dump file before run again $0 tool, aborted!\";\n"; print "exit;"; } @@ -316,7 +315,7 @@ print "\t If you have *any doubt*, \033[1;31mBEFORE run it\033[0m contact people from: linux-media\@vger.kernel.org\n"; print "\nUsage:\n"; - print "\tshell>./rewrite_eeprom ./dmesg-dump-eeprom > eeprom_script.sh\n"; + print "\tshell>perl $0 ./dmesg-dump-eeprom > eeprom_script.sh\n"; print "\tshell>sh ./eeprom_script.sh\n\n"; exit(); }