lots of fixes, fix permissions
[kernel-power] / kernel-power-settings / kernel-config
index b2d0887..31b0853 100755 (executable)
@@ -84,13 +84,22 @@ show|save)
     else
         arg=$1
         test -z "$arg" && arg=/etc/default/kernel-power
-        test `basename $arg` = $arg && arg=/home/user/.kernel/$arg
+        if test `basename $arg` = $arg; then
+           u=/home/user/.kernel
+           arg=$u/$arg
+           if test ! -d $u; then
+               mkdir -p $u
+               chown user.users $u
+           fi
+           touch $arg
+           chown user.users $arg
+       fi
         test $arg = /etc/default/kernel-power && test -L $arg && rm -f $arg
         echo "saving to $arg"
         echo "# kernel configuration file generated by $0" > $arg
         echo "MINFREQ=$minfreq" >> $arg
         echo "MAXFREQ=$maxfreq" >> $arg
-        echo "FREQS=$freqs" >> $arg
+        echo "FREQS=\"$freqs\"" >> $arg
         echo "SMARTREFLEX_VDD1=`cat $pwr/sr_vdd1_autocomp`" >> $arg
         echo "SMARTREFLEX_VDD2=`cat $pwr/sr_vdd2_autocomp`" >> $arg
         echo "IGNORE_NICE_LOAD=`cat $cfd/ignore_nice_load`" >> $arg
@@ -116,7 +125,16 @@ load|loaddef)
     echo "loading $arg"
     source $arg
     if test -n "$VDD1_OPPS_VSEL" -o -n "$DSP_OPPS_RATE"; then
-        echo "warning: old configuration format detected. ignoring"
+        echo "warning: old configuration format detected. please save in the new format."
+       test -n "$MIN_FREQ" && echo $MIN_FREQ > $cfr/scaling_min_freq
+       test -n "$MAX_FREQ" && echo $MAX_FREQ > $cfr/scaling_max_freq
+       test -n "$VDD1_OPPS_VSEL" && echo $VDD1_OPPS_VSEL > $pwr/vdd1_opps_vsel
+       test -n "$DSP_OPPS_RATE" && echo $DSP_OPPS_RATE > $pwr/dsp_opps_rate
+        test -n "$SMARTREFLEX_VDD1" && echo $SMARTREFLEX_VDD1 > $pwr/sr_vdd1_autocomp
+       test -n "$SMARTREFLEX_VDD2" && echo $SMARTREFLEX_VDD2 > $pwr/sr_vdd2_autocomp
+        test -n "$IGNORE_NICE_LOAD" && echo $IGNORE_NICE_LOAD > $cfd/ignore_nice_load
+       test -n "$UP_THRESHOLD" && echo $UP_THRESHOLD > $cfd/up_threshold
+        test -n "$SAMPLING_RATE" && echo $SAMPLING_RATE > $cfd/sampling_rate
         exit 1
     fi
     #echo $allfreq
@@ -168,8 +186,8 @@ load|loaddef)
     done
     #echo vsel $vsel
     #echo rate $rate
-    test -n "$MIN_FREQ" && minfreq=$MIN_FREQ
-    test -n "$MAX_FREQ" && maxfreq=$MAX_FREQ
+    test -n "$MINFREQ" && minfreq=$MINFREQ
+    test -n "$MAXFREQ" && maxfreq=$MAXFREQ
     test "$minfreq" -gt 100000 && minfreq=$((minfreq/1000))
     test "$maxfreq" -gt 100000 && maxfreq=$((maxfreq/1000))
     #echo $minfreq $maxfreq
@@ -184,7 +202,7 @@ load|loaddef)
         esac
     done
     #echo $avoid
-    echo $avoid > $cdf/avoid_frequencies
+    echo $avoid > $cfd/avoid_frequencies
     echo $vsel > $pwr/vdd1_opps_vsel
     echo $rates > $pwr/dsp_opps_rate
     test $maxfreq = 600 && maxfreq=599
@@ -209,6 +227,7 @@ setdefault)
         done
     fi
     def=/etc/default/kernel-power
+    rm -f $def
     case $arg in 
     /usr/share/kernel-power-settings/*) ln -s $arg $def ;;
     *) cp $arg $def ;;