diff --git a/.gitignore b/.gitignore index 4105cfbd6f26..4e300f275b01 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,5 @@ all.config # fetched Android config fragments kernel/configs/android-*.cfg +__pycache__/ +*.pyc diff --git a/arch/arm64/boot/dts/dandelion/cust.dtsi b/arch/arm64/boot/dts/dandelion/cust.dtsi new file mode 100644 index 000000000000..8e6036a7bb7b --- /dev/null +++ b/arch/arm64/boot/dts/dandelion/cust.dtsi @@ -0,0 +1,614 @@ +/* + * Generated by MTK SP DrvGen Version: 3.5.160809 for MT6765. + * 2025-11-09 01:52:14 + * Do Not Modify The File. + * Copyright Mediatek Inc. (c) 2016. +*/ + +/************************* + * ADC DTSI File +*************************/ + +&auxadc { + adc_channel@ { + compatible = "mediatek,adc_channel"; + mediatek,temperature0 = <0>; + mediatek,temperature1 = <1>; + mediatek,battery_voltage = <2>; + mediatek,adc_fdd_rf_params_dynamic_custom_ch = <3>; + status = "okay"; + }; +}; + + +/************************* + * CLK_BUF DTSI File +*************************/ + +&pmic_clock_buffer_ctrl { + mediatek,clkbuf-quantity = <7>; + mediatek,clkbuf-config = <2 1 1 2 0 0 0>; + mediatek,clkbuf-driving-current = <1 1 1 1 1 1 1>; + status = "okay"; +}; + + +/************************* + * I2C DTSI File +*************************/ + +&i2c0 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; +}; + +&i2c1 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; +}; + +&i2c2 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; + camera_main_mtk:camera_main@20 { + compatible = "mediatek,camera_main"; + reg = <0x20>; + status = "okay"; + }; + + camera_main_eeprom_mtk:camera_main_eeprom@54 { + compatible = "mediatek,camera_main_eeprom"; + reg = <0x54>; + status = "okay"; + }; + + camera_main_af_mtk:camera_main_af@0c { + compatible = "mediatek,camera_main_af"; + reg = <0x0c>; + status = "okay"; + }; + + camera_main_two_mtk:camera_main_two@30 { + compatible = "mediatek,camera_main_two"; + reg = <0x30>; + status = "okay"; + }; + + ccu_sensor_i2c_2_hw_mtk:ccu_sensor_i2c_2_hw@10 { + compatible = "mediatek,ccu_sensor_i2c_2_hw"; + reg = <0x10>; + status = "okay"; + }; + + camera_main_backup_mtk:camera_main_backup@20 { + compatible = "mediatek,camera_main_backup"; + reg = <0x20>; + status = "okay"; + }; + + camera_main_two_backup_mtk:camera_main_two_backup@30 { + compatible = "mediatek,camera_main_two_backup"; + reg = <0x30>; + status = "okay"; + }; + + camera_main_two_eeprom_mtk:camera_main_two_eeprom@50 { + compatible = "mediatek,camera_main_two_eeprom"; + reg = <0x50>; + status = "okay"; + }; + + camera_main_eeprom_backup_mtk:camera_main_eeprom_backup@58 { + compatible = "mediatek,camera_main_eeprom_backup"; + reg = <0x58>; + status = "okay"; + }; + +}; + +&i2c3 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; + speaker_amp_mtk:speaker_amp@34 { + compatible = "mediatek,speaker_amp"; + reg = <0x34>; + status = "okay"; + }; + + slave_charger_mtk:slave_charger@4b { + compatible = "mediatek,slave_charger"; + reg = <0x4b>; + status = "okay"; + }; + + nfc_mtk:nfc@08 { + compatible = "mediatek,nfc"; + reg = <0x08>; + status = "okay"; + }; + + ext_buck_lp4_mtk:ext_buck_lp4@57 { + compatible = "mediatek,ext_buck_lp4"; + reg = <0x57>; + status = "okay"; + }; + + ext_buck_lp4x_mtk:ext_buck_lp4x@50 { + compatible = "mediatek,ext_buck_lp4x"; + reg = <0x50>; + status = "okay"; + }; + +}; + +&i2c4 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; + camera_main_three_mtk:camera_main_three@3c { + compatible = "mediatek,camera_main_three"; + reg = <0x3c>; + status = "okay"; + }; + + camera_sub_mtk:camera_sub@3f { + compatible = "mediatek,camera_sub"; + reg = <0x3f>; + status = "okay"; + }; + + camera_sub_eeprom_mtk:camera_sub_eeprom@51 { + compatible = "mediatek,camera_sub_eeprom"; + reg = <0x51>; + status = "okay"; + }; + + camera_main_three_backup_mtk:camera_main_three_backup@37 { + compatible = "mediatek,camera_main_three_backup"; + reg = <0x37>; + status = "okay"; + }; + + camera_sub_backup_mtk:camera_sub_backup@3f { + compatible = "mediatek,camera_sub_backup"; + reg = <0x3f>; + status = "okay"; + }; + +}; + +&i2c5 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; + switching_charger_mtk:switching_charger@6b { + compatible = "mediatek,switching_charger"; + reg = <0x6b>; + status = "okay"; + }; + +}; + +&i2c6 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; + ext_buck_vgpu_mtk:ext_buck_vgpu@55 { + compatible = "mediatek,ext_buck_vgpu"; + reg = <0x55>; + status = "okay"; + }; + + i2c_lcd_bias_mtk:i2c_lcd_bias@3e { + compatible = "mediatek,i2c_lcd_bias"; + reg = <0x3e>; + status = "okay"; + }; + +}; + +&i2c7 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; +}; + +&i2c8 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; +}; + +&i2c9 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <400000>; + mediatek,use-open-drain; +}; + + + +/************************* + * GPIO DTSI File +*************************/ + +&gpio_usage_mapping { + GPIO_SIM2_SIO = <&pio 35 0>; + GPIO_SIM2_SRST = <&pio 36 0>; + GPIO_SIM2_SCLK = <&pio 37 0>; + GPIO_SIM1_SCLK = <&pio 38 0>; + GPIO_SIM1_SRST = <&pio 39 0>; + GPIO_SIM1_SIO = <&pio 40 0>; + GPIO_SIM1_HOT_PLUG = <&pio 47 0>; +}; + +&gpio{ + gpio_init_default = <0 0 0 0 1 1 1>, + <1 0 0 0 1 1 1>, + <2 0 0 0 1 1 1>, + <3 0 0 0 1 1 1>, + <4 0 0 0 1 1 0>, + <5 0 0 0 1 1 0>, + <6 0 0 0 1 1 0>, + <7 0 0 0 1 1 0>, + <8 7 0 0 1 1 0>, + <9 0 0 0 0 0 0>, + <10 0 0 0 1 0 0>, + <11 0 0 0 1 1 0>, + <12 0 0 0 1 1 0>, + <13 3 0 0 1 0 0>, + <14 3 1 0 0 0 0>, + <15 3 1 0 0 0 0>, + <16 3 1 0 0 0 0>, + <17 0 1 0 0 0 0>, + <18 0 0 0 1 0 0>, + <19 0 1 0 0 0 0>, + <20 0 0 0 1 0 0>, + <21 1 0 0 1 0 0>, + <22 1 1 0 0 0 0>, + <23 1 1 0 0 0 0>, + <24 1 1 0 0 0 0>, + <25 1 0 0 1 0 0>, + <26 1 1 0 0 0 0>, + <27 1 1 0 0 0 0>, + <28 1 1 0 0 0 0>, + <29 1 1 0 0 0 1>, + <30 1 0 0 1 1 1>, + <31 1 0 0 1 1 1>, + <32 1 0 0 1 1 1>, + <33 1 0 0 1 1 1>, + <34 1 0 0 1 1 1>, + <35 1 0 0 1 1 0>, + <36 1 1 0 0 0 0>, + <37 1 1 0 0 0 0>, + <38 1 1 0 0 0 0>, + <39 1 1 0 0 0 0>, + <40 1 0 0 1 1 0>, + <41 1 0 0 1 1 0>, + <42 0 0 0 1 0 0>, + <43 1 1 0 0 0 0>, + <44 0 0 0 1 0 0>, + <45 0 1 0 0 0 0>, + <46 0 0 0 1 0 0>, + <47 1 0 0 1 1 0>, + <48 1 0 0 1 1 1>, + <49 1 0 0 1 1 1>, + <50 1 0 0 1 1 1>, + <51 1 0 0 1 1 1>, + <52 1 1 0 1 0 0>, + <53 1 1 0 1 0 0>, + <54 0 0 0 0 0 0>, + <55 1 1 0 1 0 0>, + <56 1 1 0 1 0 0>, + <57 1 1 0 1 0 0>, + <58 0 0 0 1 0 0>, + <59 1 0 0 1 0 0>, + <60 1 0 0 1 0 0>, + <61 1 0 0 1 0 0>, + <62 1 0 0 1 0 0>, + <63 1 0 0 1 0 0>, + <64 1 0 0 1 0 0>, + <65 1 0 0 1 0 0>, + <66 1 0 0 1 0 0>, + <67 1 0 0 1 0 0>, + <68 1 0 0 1 0 0>, + <69 1 1 0 1 0 0>, + <70 1 1 0 1 0 0>, + <71 1 1 0 1 0 0>, + <72 1 1 0 1 0 0>, + <73 1 1 0 1 0 0>, + <74 1 1 0 1 0 0>, + <75 1 1 0 1 0 0>, + <76 1 1 0 1 0 0>, + <77 1 1 0 1 0 0>, + <78 0 0 0 0 0 0>, + <79 1 0 0 1 0 0>, + <80 1 0 0 1 0 0>, + <81 1 0 0 1 1 1>, + <82 1 0 0 1 1 1>, + <83 1 0 0 1 1 1>, + <84 1 0 0 1 1 1>, + <85 1 1 0 1 0 0>, + <86 1 1 0 1 0 0>, + <87 0 1 0 0 0 0>, + <88 1 1 0 0 0 0>, + <89 1 0 0 1 0 0>, + <90 0 0 0 1 0 0>, + <91 0 1 0 0 0 0>, + <92 0 0 0 1 0 0>, + <93 1 0 0 1 1 0>, + <94 1 0 0 1 1 0>, + <95 1 0 0 1 1 0>, + <96 1 1 0 0 0 0>, + <97 0 0 0 1 0 0>, + <98 0 0 0 1 0 0>, + <99 1 1 0 0 0 0>, + <100 1 1 0 0 0 0>, + <101 0 1 0 0 0 0>, + <102 0 1 0 0 0 0>, + <103 1 0 0 1 1 1>, + <104 1 0 0 1 1 1>, + <105 1 0 0 1 1 1>, + <106 1 0 0 1 1 1>, + <107 0 0 0 1 0 0>, + <108 1 1 0 0 0 0>, + <109 0 1 0 0 0 0>, + <110 0 0 0 1 0 0>, + <111 0 0 0 1 0 0>, + <112 0 0 0 1 0 0>, + <113 0 0 0 1 0 0>, + <114 0 0 0 1 0 0>, + <115 0 0 0 1 0 0>, + <116 0 0 0 1 0 0>, + <117 0 0 0 1 0 0>, + <118 0 0 0 1 0 0>, + <119 0 0 0 1 0 0>, + <120 0 0 0 1 0 0>, + <121 0 0 0 1 0 0>, + <122 1 0 0 1 1 1>, + <123 1 0 0 1 1 1>, + <124 1 1 0 0 0 1>, + <125 1 0 0 1 1 1>, + <126 1 0 0 1 1 1>, + <127 1 0 0 1 1 1>, + <128 1 0 0 1 1 1>, + <129 1 0 0 1 1 1>, + <130 1 0 0 1 1 1>, + <131 1 0 0 1 0 1>, + <132 1 0 0 1 1 1>, + <133 1 1 1 0 0 1>, + <134 1 0 0 1 0 1>, + <135 1 1 0 0 0 0>, + <136 1 1 0 0 0 0>, + <137 1 1 0 0 0 0>, + <138 1 1 0 0 0 0>, + <139 1 1 0 0 0 0>, + <140 1 0 0 1 0 0>, + <141 1 0 0 1 0 0>, + <142 1 0 0 1 0 0>, + <143 1 0 0 1 0 0>, + <144 1 0 0 1 0 0>, + <145 1 1 1 0 0 0>, + <146 1 0 0 1 0 0>, + <147 1 1 0 0 0 0>, + <148 1 1 0 0 0 0>, + <149 1 1 0 0 0 0>, + <150 0 1 0 0 0 0>, + <151 0 1 0 0 0 0>, + <152 0 0 0 1 0 0>, + <153 0 1 0 0 0 0>, + <154 0 1 0 0 0 0>, + <155 7 1 0 0 0 0>, + <156 7 0 0 1 0 0>, + <157 7 0 0 1 0 0>, + <158 7 0 0 1 0 0>, + <159 0 0 0 1 0 0>, + <160 0 0 0 1 0 0>, + <161 1 0 0 1 1 1>, + <162 1 0 0 1 1 1>, + <163 0 1 0 0 0 0>, + <164 0 1 0 0 0 0>, + <165 0 1 0 0 0 0>, + <166 0 1 0 0 0 0>, + <167 0 1 0 0 0 0>, + <168 0 1 0 0 0 0>, + <169 0 1 1 0 0 0>, + <170 0 1 0 0 0 0>, + <171 0 1 0 0 0 0>, + <172 0 1 0 0 0 0>, + <173 0 1 0 0 0 0>, + <174 0 1 0 0 0 0>, + <175 0 1 0 0 0 0>, + <176 0 1 0 0 0 0>, + <177 0 1 0 0 0 0>, + <178 0 1 1 0 0 0>, + <179 0 0 0 1 0 0>; +}; + + +/************************* + * EINT DTSI File +*************************/ + +#include +#include + +&touch { + interrupt-parent = <&pio>; + interrupts = <0 IRQ_TYPE_EDGE_FALLING 0 0>; + status = "okay"; +}; + +&msdc1_ins { + interrupt-parent = <&pio>; + interrupts = <1 IRQ_TYPE_EDGE_FALLING 1 0>; + status = "okay"; +}; + +&fpsensor_fp_eint { + interrupt-parent = <&pio>; + interrupts = <2 IRQ_TYPE_EDGE_FALLING 2 0>; + status = "okay"; +}; + +&irq_nfc { + interrupt-parent = <&pio>; + interrupts = <10 IRQ_TYPE_LEVEL_HIGH 10 0>; + status = "okay"; +}; + +&chr_stat { + interrupt-parent = <&pio>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW 11 0>; + status = "okay"; +}; + +&dsi_te { + interrupt-parent = <&pio>; + interrupts = <20 IRQ_TYPE_EDGE_RISING 20 0>; + status = "okay"; +}; + +&swtp1 { + interrupt-parent = <&pio>; + interrupts = <54 IRQ_TYPE_LEVEL_HIGH 54 0>; + deb-gpios = <&pio 54 0>; + debounce = <512000>; + status = "okay"; +}; + +&swtp { + interrupt-parent = <&pio>; + interrupts = <78 IRQ_TYPE_LEVEL_HIGH 78 0>; + deb-gpios = <&pio 78 0>; + debounce = <512000>; + status = "okay"; +}; + +&main_pmic { + interrupt-parent = <&pio>; + interrupts = <144 IRQ_TYPE_LEVEL_HIGH 144 1>; + status = "okay"; +}; + +&otg_iddig { + interrupt-parent = <&pio>; + interrupts = <147 IRQ_TYPE_LEVEL_LOW 41 1>; + status = "okay"; +}; + + + +/************************* + * MD1_EINT DTSI File +*************************/ + +&md1_sim1_hot_plug_eint { + compatible = "mediatek,md1_sim1_hot_plug_eint-eint"; + interrupts = <0 8>; + debounce = <0 10000>; + dedicated = <0 0>; + src_pin = <0 1>; + sockettype = <0 0>; + status = "okay"; +}; + + + +/************************* + * PMIC DTSI File +*************************/ + +&mt_pmic_vcama_ldo_reg { + regulator-name = "vcama"; + regulator-default-on = <2>; /* 0:skip, 1: off, 2:on */ + status = "okay"; +}; +&mt_pmic_vsim1_ldo_reg { + regulator-name = "vsim1"; + regulator-default-on = <1>; /* 0:skip, 1: off, 2:on */ + status = "okay"; +}; +&mt_pmic_vsim2_ldo_reg { + regulator-name = "vsim2"; + regulator-default-on = <1>; /* 0:skip, 1: off, 2:on */ + status = "okay"; +}; +&mt_pmic_vcamd_ldo_reg { + regulator-name = "vcamd"; + regulator-default-on = <2>; /* 0:skip, 1: off, 2:on */ + status = "okay"; +}; +&mt_pmic_vcamio_ldo_reg { + regulator-name = "vcamio"; + regulator-default-on = <2>; /* 0:skip, 1: off, 2:on */ + status = "okay"; +}; +&mt_pmic_vldo28_ldo_reg { + regulator-name = "vldo28"; + regulator-default-on = <1>; /* 0:skip, 1: off, 2:on */ + status = "okay"; +}; + +&kd_camera_hw1 { + vcama-supply = <&mt_pmic_vcama_ldo_reg>; + vcama_sub-supply = <&mt_pmic_vcama_ldo_reg>; + vcama_main2-supply = <&mt_pmic_vcama_ldo_reg>; + vcama_main3-supply = <&mt_pmic_vcama_ldo_reg>; + vcamd-supply = <&mt_pmic_vcamd_ldo_reg>; + vcamd_sub-supply = <&mt_pmic_vcamd_ldo_reg>; + vcamio-supply = <&mt_pmic_vcamio_ldo_reg>; + vcamio_sub-supply = <&mt_pmic_vcamio_ldo_reg>; + vcamio_main2-supply = <&mt_pmic_vcamio_ldo_reg>; + vcamio_main3-supply = <&mt_pmic_vcamio_ldo_reg>; + vcamaf-supply = <&mt_pmic_vldo28_ldo_reg>; + status = "okay"; +}; + +&touch { + status = "okay"; +}; + + +/************************* + * POWER DTSI File +*************************/ + + + +/************************* + * KPD DTSI File +*************************/ + +&keypad { + mediatek,kpd-key-debounce = <1024>; + mediatek,kpd-sw-pwrkey = <116>; + mediatek,kpd-hw-pwrkey = <8>; + mediatek,kpd-use-extend-type = <0>; + /*HW Keycode [0~71] -> Linux Keycode*/ + mediatek,kpd-hw-map-num = <72>; + mediatek,kpd-hw-init-map = <115 114 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >; + mediatek,kpd-pwrkey-eint-gpio = <0>; + mediatek,kpd-pwkey-gpio-din = <0>; + mediatek,kpd-hw-dl-key0 = <0>; + mediatek,kpd-hw-dl-key1 = <1>; + mediatek,kpd-hw-dl-key2 = <8>; + mediatek,kpd-hw-recovery-key = <0>; + mediatek,kpd-hw-factory-key = <1>; + status = "okay"; +}; + + diff --git a/arch/arm64/boot/dts/mediatek/dandelion.dtb.merge b/arch/arm64/boot/dts/mediatek/dandelion.dtb.merge new file mode 100644 index 000000000000..a900c18548eb Binary files /dev/null and b/arch/arm64/boot/dts/mediatek/dandelion.dtb.merge differ diff --git a/crypto/xts.c b/crypto/xts.c index 305343f22a02..a62708756d0f 100644 --- a/crypto/xts.c +++ b/crypto/xts.c @@ -329,7 +329,7 @@ static struct crypto_instance *alloc(struct rtattr **tb) return inst; } -static void free(struct crypto_instance *inst) +static void xts_free(struct crypto_instance *inst) { crypto_drop_spawn(crypto_instance_ctx(inst)); kfree(inst); @@ -338,7 +338,7 @@ static void free(struct crypto_instance *inst) static struct crypto_template crypto_tmpl = { .name = "xts", .alloc = alloc, - .free = free, + .free = xts_free, .module = THIS_MODULE, }; diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index b11af3f2c1db..70e097de3a21 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c @@ -401,7 +401,7 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg, regcache_rbtree_set_register(map, rbnode, reg_tmp, value); } else { unsigned int base_reg, top_reg; - unsigned int new_base_reg, new_top_reg; + unsigned int new_base_reg = 0, new_top_reg = 0; unsigned int min, max; unsigned int max_dist; unsigned int dist, best_dist = UINT_MAX; diff --git a/drivers/devfreq/helio-dvfsrc-ipi.c b/drivers/devfreq/helio-dvfsrc-ipi.c index b5143e7f812f..04102ac59bda 100644 --- a/drivers/devfreq/helio-dvfsrc-ipi.c +++ b/drivers/devfreq/helio-dvfsrc-ipi.c @@ -13,7 +13,7 @@ #include -#include +#include "helio-dvfsrc-ipi.h" #if defined(CONFIG_MTK_TINYSYS_SSPM_SUPPORT) static int qos_recv_thread(void *arg) diff --git a/drivers/devfreq/helio-dvfsrc-mt6765.c b/drivers/devfreq/helio-dvfsrc-mt6765.c index 8ec75f8db7dd..37ef0c191b42 100644 --- a/drivers/devfreq/helio-dvfsrc-mt6765.c +++ b/drivers/devfreq/helio-dvfsrc-mt6765.c @@ -21,7 +21,7 @@ #include #include -#include +#include "helio-dvfsrc.h" #include #include #include diff --git a/drivers/devfreq/helio-dvfsrc-opp.c b/drivers/devfreq/helio-dvfsrc-opp.c index 9c74a8d8e07a..42dd0f6086f2 100644 --- a/drivers/devfreq/helio-dvfsrc-opp.c +++ b/drivers/devfreq/helio-dvfsrc-opp.c @@ -11,12 +11,12 @@ * See http://www.gnu.org/licenses/gpl-2.0.html for more details. */ -#include -#include +#include "helio-dvfsrc.h" +#include "helio-dvfsrc-opp.h" #ifdef CONFIG_MTK_QOS_FRAMEWORK -#include +#include "mtk_qos_ipi.h" #else -#include +#include "helio-dvfsrc-ipi.h" #endif static struct opp_profile opp_table[VCORE_DVFS_OPP_NUM]; diff --git a/drivers/devfreq/helio-dvfsrc-opp.h b/drivers/devfreq/helio-dvfsrc-opp.h index 75a8bc0ae94f..ed192ddc8eb4 100644 --- a/drivers/devfreq/helio-dvfsrc-opp.h +++ b/drivers/devfreq/helio-dvfsrc-opp.h @@ -15,15 +15,15 @@ #define __HELIO_DVFSRC_OPP_H #if defined(CONFIG_MACH_MT6765) -#include +#include "helio-dvfsrc-opp-mt6765.h" #elif defined(CONFIG_MACH_MT6761) -#include +#include "helio-dvfsrc-opp-mt6761.h" #elif defined(CONFIG_MACH_MT3967) -#include +#include "helio-dvfsrc-opp-mt3967.h" #elif defined(CONFIG_MACH_MT6779) -#include +#include "helio-dvfsrc-opp-mt6779.h" #else -#include +#include "helio-dvfsrc-opp-mt67xx.h" #endif struct opp_profile { diff --git a/drivers/devfreq/helio-dvfsrc-sysfs.c b/drivers/devfreq/helio-dvfsrc-sysfs.c index 8c1e8b3298a3..45bf3ff8c0d0 100644 --- a/drivers/devfreq/helio-dvfsrc-sysfs.c +++ b/drivers/devfreq/helio-dvfsrc-sysfs.c @@ -16,8 +16,8 @@ #include #include -#include -#include +#include "helio-dvfsrc.h" +#include "helio-dvfsrc-opp.h" __weak void dvfsrc_enable_dvfs_freq_hopping(int gps_on) { diff --git a/drivers/devfreq/helio-dvfsrc.h b/drivers/devfreq/helio-dvfsrc.h index bcd6a7b6b6c8..0811f2427f2e 100644 --- a/drivers/devfreq/helio-dvfsrc.h +++ b/drivers/devfreq/helio-dvfsrc.h @@ -19,13 +19,13 @@ #include #if defined(CONFIG_MACH_MT6765) -#include +#include "helio-dvfsrc-mt6765.h" #elif defined(CONFIG_MACH_MT6761) -#include +#include "helio-dvfsrc-mt6761.h" #elif defined(CONFIG_MACH_MT3967) -#include +#include "helio-dvfsrc-mt3967.h" #elif defined(CONFIG_MACH_MT6779) -#include +#include "helio-dvfsrc-mt6779.h" #elif defined(CONFIG_MACH_MT6763) #else #include diff --git a/drivers/devfreq/mtk_dvfsrc_reg.h b/drivers/devfreq/mtk_dvfsrc_reg.h index 7e2cbe776f89..7f695b95c7d5 100644 --- a/drivers/devfreq/mtk_dvfsrc_reg.h +++ b/drivers/devfreq/mtk_dvfsrc_reg.h @@ -15,15 +15,15 @@ #define __MTK_DVFSRC_REG_H #if defined(CONFIG_MACH_MT6765) -#include +#include "mtk_dvfsrc_reg_mt6765.h" #elif defined(CONFIG_MACH_MT6761) -#include +#include "mtk_dvfsrc_reg_mt6761.h" #elif defined(CONFIG_MACH_MT3967) -#include +#include "mtk_dvfsrc_reg_mt3967.h" #elif defined(CONFIG_MACH_MT6779) -#include +#include "mtk_dvfsrc_reg_mt6779.h" #else -#include +#include "mtk_dvfsrc_reg_mt67xx.h" #endif diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 1205790ed960..39d47b2b1cd3 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -277,7 +277,7 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf, { struct seq_file *m = file->private_data; struct drm_connector *connector = m->private; - char buf[12]; + char buf[12] = {0}; if (len > sizeof(buf) - 1) return -EINVAL; diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index c93dcfedc219..6d68a1d5c723 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3193,7 +3193,7 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid) { const u8 *cea = drm_find_cea_extension(edid); const u8 *db, *hdmi = NULL, *video = NULL; - u8 dbl, hdmi_len, video_len = 0; + u8 dbl, hdmi_len = 0, video_len = 0; int modes = 0; if (cea && cea_revision(cea) >= 3) { diff --git a/dtbimg.cfg b/dtbimg.cfg new file mode 100644 index 000000000000..59fd216bc86e --- /dev/null +++ b/dtbimg.cfg @@ -0,0 +1,2 @@ +/home/runner/work/kernel/kernel/arch/arm64/boot/mtk.dtb + id=0 diff --git a/dtboimg.cfg b/dtboimg.cfg new file mode 100644 index 000000000000..bb3aed1889e9 --- /dev/null +++ b/dtboimg.cfg @@ -0,0 +1,2 @@ +/home/runner/work/kernel/kernel/arch/arm64/boot/dts/mediatek/dandelion.dtb + id=0 diff --git a/lib/debug_locks.c b/lib/debug_locks.c index 124fdf238b3d..e5d952fcd51c 100644 --- a/lib/debug_locks.c +++ b/lib/debug_locks.c @@ -37,7 +37,10 @@ EXPORT_SYMBOL_GPL(debug_locks_silent); */ int debug_locks_off(void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" if (debug_locks && __debug_locks_off()) { +#pragma GCC diagnostic pop if (!debug_locks_silent) { console_verbose(); return 1; diff --git a/lib/kstrtox.c b/lib/kstrtox.c index b8e2080c1a47..6117eceed583 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c @@ -371,7 +371,7 @@ EXPORT_SYMBOL(kstrtobool); int kstrtobool_from_user(const char __user *s, size_t count, bool *res) { /* Longest string needed to differentiate, newline, terminator */ - char buf[4]; + char buf[4] = {0}; count = min(count, sizeof(buf) - 1); if (copy_from_user(buf, s, count)) @@ -385,7 +385,7 @@ EXPORT_SYMBOL(kstrtobool_from_user); int f(const char __user *s, size_t count, unsigned int base, type *res) \ { \ /* sign, base 2 representation, newline, terminator */ \ - char buf[1 + sizeof(type) * 8 + 1 + 1]; \ + char buf[1 + sizeof(type) * 8 + 1 + 1] = {0}; \ \ count = min(count, sizeof(buf) - 1); \ if (copy_from_user(buf, s, count)) \ diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c index a5d313381539..5ed2f6e999d8 100644 --- a/lib/reed_solomon/decode_rs.c +++ b/lib/reed_solomon/decode_rs.c @@ -186,7 +186,10 @@ deg_lambda = i; } /* Find roots of error+erasure locator polynomial by Chien search */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" memcpy(®[1], &lambda[1], nroots * sizeof(reg[0])); +#pragma GCC diagnostic pop count = 0; /* Number of roots of lambda(x) */ for (i = 1, k = iprim - 1; i <= nn; i++, k = rs_modnn(rs, k + iprim)) { q = 1; /* lambda[0] is always 0 */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 91b06873a1fa..b3adb8e43702 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6570,7 +6570,8 @@ void __init mem_init_print_info(const char *str) */ #define adj_init_size(start, end, size, pos, adj) \ do { \ - if (start <= pos && pos < end && size > adj) \ + if ((unsigned long)start <= (unsigned long)pos && \ + (unsigned long)pos < (unsigned long)end && size > adj) \ size -= adj; \ } while (0) diff --git a/mm/swap_state.c b/mm/swap_state.c index 10fec1fc7487..3143f618dce2 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -421,7 +421,10 @@ static unsigned long swapin_nr_pages(unsigned long offset) * random loads, swapping to hard disk or to SSD: please don't ask * what the "+ 2" means, it just happens to work well, that's all. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" pages = atomic_xchg(&swapin_readahead_hits, 0) + 2; +#pragma GCC diagnostic pop if (pages == 2) { /* * We can have no readahead hits to judge by: but must not get diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l index 790fbf6cf2d7..e7eab4d7c5a9 100644 --- a/scripts/dtc/dtc-lexer.l +++ b/scripts/dtc/dtc-lexer.l @@ -38,7 +38,7 @@ LINECOMMENT "//".*\n #include "srcpos.h" #include "dtc-parser.tab.h" -YYLTYPE yylloc; +extern YYLTYPE yylloc; extern bool treesource_error; /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped index ba525c2f9fc2..a2fe8dbc0fd3 100644 --- a/scripts/dtc/dtc-lexer.lex.c_shipped +++ b/scripts/dtc/dtc-lexer.lex.c_shipped @@ -637,7 +637,7 @@ char *yytext; #include "srcpos.h" #include "dtc-parser.tab.h" -YYLTYPE yylloc; +extern YYLTYPE yylloc; extern bool treesource_error; /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b9208871a854..76fe1b5d5194 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -247,7 +247,7 @@ static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, static ssize_t codec_reg_write_file(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - char buf[32]; + char buf[32] = {0}; size_t buf_size; char *start = buf; unsigned long reg, value; diff --git a/tools/dct/DrvGen.py b/tools/dct/DrvGen.py index f6f845a7576d..e296b3768c6b 100755 --- a/tools/dct/DrvGen.py +++ b/tools/dct/DrvGen.py @@ -20,6 +20,9 @@ sys.dont_write_bytecode = True +# Add the directory containing this script to the path +script_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, script_dir) sys.path.append('.') sys.path.append('..') @@ -43,7 +46,7 @@ from utility.util import log def usage(): - print ''' + print(''' usage: DrvGen [dws_path] [file_path] [log_path] [paras]... options and arguments: @@ -52,7 +55,7 @@ def usage(): file_path : where you want to put generated files log_path : where to store the log files paras : parameter for generate wanted file -''' +''') def is_oldDws(path, gen_spec): if not os.path.exists(path): @@ -61,7 +64,7 @@ def is_oldDws(path, gen_spec): try: root = xml.dom.minidom.parse(dws_path) - except Exception, e: + except Exception as e: log(LogLevel.warn, '%s is not xml format, try to use old DCT!' %(dws_path)) if len(gen_spec) == 0: log(LogLevel.warn, 'Please use old DCT UI to gen all files!') @@ -140,37 +143,37 @@ def is_oldDws(path, gen_spec): chipId = ChipObj.get_chipId(dws_path) log(LogLevel.info, 'chip id: %s' %(chipId)) chipObj = None - if cmp(chipId, 'MT6797') == 0: + if chipId == 'MT6797': chipObj = Everest(dws_path, gen_path) - elif cmp(chipId, 'MT6757') == 0: + elif chipId == 'MT6757': chipObj = Olympus(dws_path, gen_path) - elif cmp(chipId, 'MT6757-P25') == 0: + elif chipId == 'MT6757-P25': chipObj = MT6757_P25(dws_path, gen_path) - elif cmp(chipId, 'KIBOPLUS') == 0: + elif chipId == 'KIBOPLUS': chipObj = MT6757_P25(dws_path, gen_path) - elif cmp(chipId, 'MT6570') == 0: + elif chipId == 'MT6570': chipObj = Rushmore(dws_path, gen_path) - elif cmp(chipId, 'MT6799') == 0: + elif chipId == 'MT6799': chipObj = Whitney(dws_path, gen_path) - elif cmp(chipId, 'MT6763') == 0: + elif chipId == 'MT6763': chipObj = MT6763(dws_path, gen_path) - elif cmp(chipId, 'MT6759') == 0: + elif chipId == 'MT6759': chipObj = MT6759(dws_path, gen_path) - elif cmp(chipId, 'MT6750S') == 0: + elif chipId == 'MT6750S': chipObj = MT6750S(dws_path, gen_path) - elif cmp(chipId, 'MT6758') == 0: + elif chipId == 'MT6758': chipObj = MT6758(dws_path, gen_path) - elif cmp(chipId, 'MT6739') == 0: + elif chipId == 'MT6739': chipObj = MT6739(dws_path, gen_path) - elif cmp(chipId, 'MT8695') == 0: + elif chipId == 'MT8695': chipObj = MT8695(dws_path, gen_path) - elif cmp(chipId, 'MT6771') == 0 or \ - cmp(chipId, 'MT6775') == 0 or \ - cmp(chipId, 'MT6765') == 0 or \ - cmp(chipId, 'MT3967') == 0 or \ - cmp(chipId, 'MT6761') == 0: + elif chipId == 'MT6771' or \ + chipId == 'MT6775' or \ + chipId == 'MT6765' or \ + chipId == 'MT3967' or \ + chipId == 'MT6761': chipObj = MT6771(dws_path, gen_path) - elif cmp(chipId, 'MT6779') == 0: + elif chipId == 'MT6779': chipObj = MT6779(dws_path, gen_path) else: chipObj = ChipObj(dws_path, gen_path) diff --git a/tools/dct/obj/AdcObj.py b/tools/dct/obj/AdcObj.py index f9820275d436..c2967ec13103 100755 --- a/tools/dct/obj/AdcObj.py +++ b/tools/dct/obj/AdcObj.py @@ -77,9 +77,9 @@ def fill_dtsiFile(self): value = ModuleObj.get_data(self)[key] if value == "TEMPERATURE": - gen_str += '''\t\tmediatek,%s0 = <%d>;\n''' %(value.lower(), string.atoi(key[3:])) + gen_str += '''\t\tmediatek,%s0 = <%d>;\n''' %(value.lower(), int(key[3:])) else: - gen_str += '''\t\tmediatek,%s = <%d>;\n''' %(value.lower(), string.atoi(key[3:])) + gen_str += '''\t\tmediatek,%s = <%d>;\n''' %(value.lower(), int(key[3:])) gen_str += '''\t\tstatus = \"okay\";\n''' gen_str += '''\t};\n''' diff --git a/tools/dct/obj/ChipObj.py b/tools/dct/obj/ChipObj.py index 9311d10779e5..2d9687030e77 100755 --- a/tools/dct/obj/ChipObj.py +++ b/tools/dct/obj/ChipObj.py @@ -16,31 +16,31 @@ import collections import xml.dom.minidom -from GpioObj import GpioObj -from GpioObj import GpioObj_whitney -from GpioObj import GpioObj_MT6759 -from GpioObj import GpioObj_MT6739 -from GpioObj import GpioObj_MT6771 -from GpioObj import GpioObj_MT6763 -from EintObj import EintObj -from EintObj import EintObj_MT6750S -from EintObj import EintObj_MT6739 -from AdcObj import AdcObj -from ClkObj import ClkObj -from ClkObj import ClkObj_Everest -from ClkObj import ClkObj_Olympus -from ClkObj import ClkObj_Rushmore -from ClkObj import ClkObj_MT6779 -from I2cObj import I2cObj -from I2cObj import I2cObj_MT6759 -from I2cObj import I2cObj_MT6775 -from PmicObj import PmicObj -from PmicObj import PmicObj_MT6758 -from Md1EintObj import Md1EintObj -from Md1EintObj import Md1EintObj_MT6739 -from PowerObj import PowerObj -from KpdObj import KpdObj -from ModuleObj import ModuleObj +from obj.GpioObj import GpioObj +from obj.GpioObj import GpioObj_whitney +from obj.GpioObj import GpioObj_MT6759 +from obj.GpioObj import GpioObj_MT6739 +from obj.GpioObj import GpioObj_MT6771 +from obj.GpioObj import GpioObj_MT6763 +from obj.EintObj import EintObj +from obj.EintObj import EintObj_MT6750S +from obj.EintObj import EintObj_MT6739 +from obj.AdcObj import AdcObj +from obj.ClkObj import ClkObj +from obj.ClkObj import ClkObj_Everest +from obj.ClkObj import ClkObj_Olympus +from obj.ClkObj import ClkObj_Rushmore +from obj.ClkObj import ClkObj_MT6779 +from obj.I2cObj import I2cObj +from obj.I2cObj import I2cObj_MT6759 +from obj.I2cObj import I2cObj_MT6775 +from obj.PmicObj import PmicObj +from obj.PmicObj import PmicObj_MT6758 +from obj.Md1EintObj import Md1EintObj +from obj.Md1EintObj import Md1EintObj_MT6739 +from obj.PowerObj import PowerObj +from obj.KpdObj import KpdObj +from obj.ModuleObj import ModuleObj from utility.util import log from utility.util import LogLevel @@ -168,12 +168,12 @@ def create_obj(self, tag): def gen_spec(self, paras): - # if cmp(paras[0], 'cust_dtsi') == 0: + # if paras[0] == 'cust_dtsi': # self.gen_custDtsi() # return True for para in paras: - if cmp(para, 'cust_dtsi') == 0: + if para == 'cust_dtsi': self.gen_custDtsi() continue @@ -211,7 +211,7 @@ def gen_custDtsi(self): #sorted_list = sorted(self.__objs.keys()) #for tag in sorted_list: for tag in self.__objs.keys(): - if cmp(tag, 'gpio') == 0: + if tag == 'gpio': gpioObj = self.create_obj(tag) gen_str += ModuleObj.writeHeader(gpioObj.get_dtsiFileName()) gen_str += gpioObj.fill_mapping_dtsiFile() diff --git a/tools/dct/obj/ClkObj.py b/tools/dct/obj/ClkObj.py index 445fc7caf1b1..461514fe0cc9 100755 --- a/tools/dct/obj/ClkObj.py +++ b/tools/dct/obj/ClkObj.py @@ -14,11 +14,11 @@ import re import string -import ConfigParser +import configparser as ConfigParser import xml.dom.minidom -from ModuleObj import ModuleObj +from obj.ModuleObj import ModuleObj from data.ClkData import ClkData from data.ClkData import OldClkData from data.ClkData import NewClkData @@ -62,17 +62,17 @@ def read(self, node): return True def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) - count = string.atoi(cp.get('CLK_BUF', 'CLK_BUF_COUNT')) + count = int(cp.get('CLK_BUF', 'CLK_BUF_COUNT')) self.__count = count ops = cp.options('CLK_BUF') for op in ops: if op == 'clk_buf_count': - self.__count = string.atoi(cp.get('CLK_BUF', op)) - ClkData._count = string.atoi(cp.get('CLK_BUF', op)) + self.__count = int(cp.get('CLK_BUF', op)) + ClkData._count = int(cp.get('CLK_BUF', op)) continue value = cp.get('CLK_BUF', op) @@ -80,8 +80,8 @@ def get_cfgInfo(self): data = OldClkData() data.set_curList(var_list[2:]) - data.set_defVarName(string.atoi(var_list[0])) - data.set_defCurrent(string.atoi(var_list[1])) + data.set_defVarName(int(var_list[0])) + data.set_defCurrent(int(var_list[1])) key = op[16:].upper() ModuleObj.set_data(self, key, data) @@ -119,7 +119,7 @@ def fill_hFile(self): for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) - if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: + if value.get_curList()[0] == DEFAULT_AUTOK: idx -= 1 if idx >= 0: @@ -154,7 +154,7 @@ def fill_dtsiFile(self): continue value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) - if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: + if value.get_curList()[0] == DEFAULT_AUTOK: idx -= 1 if idx < 0: gen_str += '''(%d) ''' %(-1) @@ -258,7 +258,7 @@ def fill_dtsiFile(self): value = ModuleObj.get_data(self)[key] if key.find(self.__rf) != -1: idx = value.get_curList().index(value.get_current()) - if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: + if value.get_curList()[0] == DEFAULT_AUTOK: idx -= 1 gen_str += '''%d ''' %(idx) @@ -321,7 +321,7 @@ def fill_hFile(self): continue value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) - if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: + if value.get_curList()[0] == DEFAULT_AUTOK: idx -= 1 if idx >= 0: @@ -337,7 +337,7 @@ def fill_hFile(self): continue value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) - if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: + if value.get_curList()[0] == DEFAULT_AUTOK: idx -= 1 if idx >= 0: @@ -358,10 +358,10 @@ def parse(self, node): ClkObj.parse(self, node) def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) - count = string.atoi(cp.get('CLK_BUF', 'CLK_BUF_COUNT')) + count = int(cp.get('CLK_BUF', 'CLK_BUF_COUNT')) self.__count = count def read(self, node): @@ -416,7 +416,7 @@ def fill_hFile(self): continue value = ModuleObj.get_data(self)[key] idx = value.get_curList().index(value.get_current()) - if cmp(value.get_curList()[0], DEFAULT_AUTOK) == 0: + if value.get_curList()[0] == DEFAULT_AUTOK: idx -= 1 if idx >= 0: @@ -483,7 +483,7 @@ def read(self, node): return True def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) max_count = self.get_max_count(cp) @@ -499,19 +499,19 @@ def get_cfgInfo(self): var_list = value.split(r'/') data = NewClkData() - data.set_defVarName(string.atoi(var_list[0])) + data.set_defVarName(int(var_list[0])) buf_output_list = var_list[1].split(r":") # only -1 means no data if len(buf_output_list) > 1: data.cur_buf_output_list = buf_output_list[1:] - data.set_def_buf_output(string.atoi(buf_output_list[0])) + data.set_def_buf_output(int(buf_output_list[0])) driving_control_list = var_list[2].split(r":") # only -1 means no data if len(driving_control_list) > 1: data.cur_driving_control_list = driving_control_list[1:] - data.set_def_driving_control(string.atoi(driving_control_list[0])) + data.set_def_driving_control(int(driving_control_list[0])) key = op[16:].upper() ModuleObj.set_data(self, key, data) diff --git a/tools/dct/obj/EintObj.py b/tools/dct/obj/EintObj.py index 961e31152cdc..5ce0d4b69142 100755 --- a/tools/dct/obj/EintObj.py +++ b/tools/dct/obj/EintObj.py @@ -16,7 +16,7 @@ import os import string -import ConfigParser +import configparser as ConfigParser import xml.dom.minidom from data.EintData import EintData @@ -43,7 +43,7 @@ def read(self, node): for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: - if cmp(node.nodeName, 'count') == 0: + if node.nodeName == 'count': self.__count = node.childNodes[0].nodeValue continue @@ -84,7 +84,7 @@ def gen_spec(self, para): ModuleObj.gen_spec(self, para) def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) ops = cp.options('GPIO') @@ -94,14 +94,14 @@ def get_cfgInfo(self): value = cp.get('GPIO', op) list = re.split(r' +|\t+', value) - map[string.atoi(re.findall(r'\d+', op)[0])] = string.atoi(list[len(list)-2]) + map[int(re.findall(r'\d+', op)[0])] = int(list[len(list)-2]) mode_map[op] = list[0:len(list)-2] EintData.set_mapTable(map) EintData.set_modeMap(mode_map) if cp.has_option('EINT', 'EINT_MAP_COUNT'): - self.__map_count = string.atoi(cp.get('EINT', 'EINT_MAP_COUNT')) + self.__map_count = int(cp.get('EINT', 'EINT_MAP_COUNT')) if cp.has_option('EINT', 'INTERNAL_EINT'): info = cp.get('EINT', 'INTERNAL_EINT') @@ -132,7 +132,7 @@ def get_cfgInfo(self): self.__gpio_obj.set_eint_map_table(EintData._map_table) #def compare(self, value): - #return string.atoi(value[4:]) + #return int(value[4:]) def fill_hFile(self): gen_str = '' @@ -161,21 +161,21 @@ def fill_hFile(self): polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() - if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: + if polarity == 'High' and sensitive == 'Edge': temp = 'CUST_EINTF_TRIGGER_RISING' - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: + elif polarity == 'Low' and sensitive == 'Edge': temp = 'CUST_EINTF_TRIGGER_FALLING' - elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'High' and sensitive == 'Level': temp = 'CUST_EINTF_TRIGGER_HIGH' - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'Low' and sensitive == 'Level': temp = 'CUST_EINTF_TRIGGER_LOW' gen_str += '''#define CUST_EINT_%s_TYPE\t\t\t%s\n''' %(value.get_varName().upper(), temp) temp = '' - if cmp(value.get_debounceEnable(), 'Disable') == 0: + if value.get_debounceEnable() == 'Disable': temp = 'CUST_EINT_DEBOUNCE_DISABLE' - elif cmp(value.get_debounceEnable(), 'Enable') == 0: + elif value.get_debounceEnable() == 'Enable': temp = 'CUST_EINT_DEBOUNCE_ENABLE' gen_str += '''#define CUST_EINT_%s_DEBOUNCE_EN\t\t%s\n\n''' %(value.get_varName().upper(), temp) @@ -191,7 +191,7 @@ def fill_mappingTable(self): count = 0 if self.__map_count == 0: - for i in range(0, string.atoi(self.__count)): + for i in range(0, int(self.__count)): if EintData.get_gpioNum(i) >= 0: count += 1 count += len(EintData._int_eint) @@ -236,7 +236,7 @@ def fill_mappingTable(self): def get_gpioNum(self, eint_num): for (key, value) in EintData.get_mapTable().items(): - if cmp(eint_num, value) == 0: + if eint_num == value: return key return -1 @@ -245,23 +245,23 @@ def refGpio(self, eint_num, flag): gpio_vec= [] for key in EintData._builtin_map.keys(): - if string.atoi(eint_num) == string.atoi(key): + if int(eint_num) == int(key): temp_map = EintData._builtin_map[key] for key in temp_map.keys(): gpio_vec.append(key) if flag: for item in temp_map.keys(): - item_data = self.__gpio_obj.get_gpioData(string.atoi(item)) + item_data = self.__gpio_obj.get_gpioData(int(item)) - if item_data.get_defMode() == string.atoi(temp_map[item].split(':')[0]): + if item_data.get_defMode() == int(temp_map[item].split(':')[0]): gpio_vec = [] gpio_vec.append(item) return gpio_vec break - gpio_num = EintData.get_gpioNum(string.atoi(eint_num)) + gpio_num = EintData.get_gpioNum(int(eint_num)) if gpio_num >= 0: gpio_vec.append(gpio_num) if flag: @@ -291,17 +291,17 @@ def fill_dtsiFile(self): polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() - if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: + if polarity == 'High' and sensitive == 'Edge': temp = 'IRQ_TYPE_EDGE_RISING' - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: + elif polarity == 'Low' and sensitive == 'Edge': temp = 'IRQ_TYPE_EDGE_FALLING' - elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'High' and sensitive == 'Level': temp = 'IRQ_TYPE_LEVEL_HIGH' - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'Low' and sensitive == 'Level': temp = 'IRQ_TYPE_LEVEL_LOW' gen_str += '''\tinterrupts = <%s %s>;\n''' %(self.refGpio(key[4:], True)[0], temp) - gen_str += '''\tdebounce = <%s %d>;\n''' %(self.refGpio(key[4:], True)[0], string.atoi(value.get_debounceTime()) * 1000) + gen_str += '''\tdebounce = <%s %d>;\n''' %(self.refGpio(key[4:], True)[0], int(value.get_debounceTime()) * 1000) gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' gen_str += '''\n''' @@ -349,19 +349,19 @@ def fill_dtsiFile(self): polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() - if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: + if polarity == 'High' and sensitive == 'Edge': temp = 'IRQ_TYPE_EDGE_RISING' - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: + elif polarity == 'Low' and sensitive == 'Edge': temp = 'IRQ_TYPE_EDGE_FALLING' - elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'High' and sensitive == 'Level': temp = 'IRQ_TYPE_LEVEL_HIGH' - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'Low' and sensitive == 'Level': temp = 'IRQ_TYPE_LEVEL_LOW' gen_str += '''\tinterrupts = <%s %s %s %d>;\n''' % (key[4:], temp, self.refGpio(key[4:], True)[0], self.refGpio_defMode(key[4:], True)) - if cmp(value.get_debounceEnable(), 'Enable') == 0: + if value.get_debounceEnable() == 'Enable': gen_str += '''\tdeb-gpios = <&pio %s 0>;\n''' % (self.refGpio(key[4:], True)[0]) - gen_str += '''\tdebounce = <%d>;\n''' % (string.atoi(value.get_debounceTime()) * 1000) + gen_str += '''\tdebounce = <%d>;\n''' % (int(value.get_debounceTime()) * 1000) gen_str += '''\tstatus = \"okay\";\n''' gen_str += '''};\n''' gen_str += '''\n''' @@ -375,20 +375,20 @@ def refGpio_defMode(self, eint_num, flag): refGpio_defMode = 0 for key in EintData._builtin_map.keys(): - if string.atoi(eint_num) == string.atoi(key): + if int(eint_num) == int(key): temp_map = EintData._builtin_map[key] if flag: for item in temp_map.keys(): - item_data = self.get_gpioObj().get_gpioData(string.atoi(item)) + item_data = self.get_gpioObj().get_gpioData(int(item)) - if item_data.get_defMode() == string.atoi(temp_map[item].split(':')[0]): + if item_data.get_defMode() == int(temp_map[item].split(':')[0]): refGpio_defMode = item_data.get_defMode() return refGpio_defMode break - gpio_num = EintData.get_gpioNum(string.atoi(eint_num)) + gpio_num = EintData.get_gpioNum(int(eint_num)) if gpio_num >= 0: if flag: item_data = self.get_gpioObj().get_gpioData(gpio_num) diff --git a/tools/dct/obj/GpioObj.py b/tools/dct/obj/GpioObj.py index a5765d5fab21..985d0c882006 100755 --- a/tools/dct/obj/GpioObj.py +++ b/tools/dct/obj/GpioObj.py @@ -16,14 +16,14 @@ import os import sys import string -import ConfigParser +import configparser as ConfigParser import xml.dom.minidom from data.GpioData import GpioData from data.EintData import EintData -from ModuleObj import ModuleObj -import ChipObj +from obj.ModuleObj import ModuleObj +import obj.ChipObj as ChipObj from utility.util import compare from utility.util import sorted_key from utility.util import log @@ -41,7 +41,7 @@ def __init__(self): self.__gpio_column_enable = True def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_cmpPath()) # get GPIO_FREQ section @@ -71,7 +71,7 @@ def get_cfgInfo(self): GpioData._modeMap[op] = temp data = GpioData() - data.set_smtNum(string.atoi(list[len(list)-1])) + data.set_smtNum(int(list[len(list)-1])) ModuleObj.set_data(self, op.lower(), data) if cp.has_option('Chip Type', 'GPIO_COLUMN_ENABLE'): @@ -83,8 +83,8 @@ def read(self, node): nodes = node.childNodes for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: - if cmp(node.nodeName, 'count') == 0: - GpioData._count = string.atoi(node.childNodes[0].nodeValue) + if node.nodeName == 'count': + GpioData._count = int(node.childNodes[0].nodeValue) continue eintNode = node.getElementsByTagName('eint_mode') @@ -103,19 +103,19 @@ def read(self, node): iesNode = node.getElementsByTagName('ies') drvCurNode = node.getElementsByTagName('drv_cur') - num = string.atoi(node.nodeName[4:]) + num = int(node.nodeName[4:]) if num >= len(ModuleObj.get_data(self)): break data = ModuleObj.get_data(self)[node.nodeName] if len(eintNode): flag = False - if cmp(eintNode[0].childNodes[0].nodeValue, 'true') == 0: + if eintNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_eintMode(flag) if len(defmNode): - data.set_defMode(string.atoi(defmNode[0].childNodes[0].nodeValue)) + data.set_defMode(int(defmNode[0].childNodes[0].nodeValue)) if len(modsNode) != 0 and len(modsNode[0].childNodes) != 0: str = modsNode[0].childNodes[0].nodeValue @@ -126,13 +126,13 @@ def read(self, node): if len(inpeNode): flag = False - if cmp(inpeNode[0].childNodes[0].nodeValue, 'true') == 0: + if inpeNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_inpullEn(flag) if len(inpsNode): flag = False - if cmp(inpsNode[0].childNodes[0].nodeValue, 'true') == 0: + if inpsNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_inpullSelHigh(flag) @@ -141,19 +141,19 @@ def read(self, node): if len(diriNode) != 0 and len(diriNode[0].childNodes) != 0: flag = False - if cmp(diriNode[0].childNodes[0].nodeValue, 'true') == 0: + if diriNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_inEn(flag) if len(diroNode) != 0 and len(diroNode[0].childNodes) != 0: flag = False - if cmp(diroNode[0].childNodes[0].nodeValue, 'true') == 0: + if diroNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_outEn(flag) if len(outhNode): flag = False - if cmp(outhNode[0].childNodes[0].nodeValue, 'true') == 0: + if outhNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_outHigh(flag) @@ -169,13 +169,13 @@ def read(self, node): if len(smtNode): flag = False - if cmp(smtNode[0].childNodes[0].nodeValue, 'true') == 0: + if smtNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_smtEn(flag) if len(iesNode): flag = False - if cmp(iesNode[0].childNodes[0].nodeValue, 'true') == 0: + if iesNode[0].childNodes[0].nodeValue == 'true': flag = True data.set_iesEn(flag) @@ -416,7 +416,7 @@ def fill_cFile(self): mode_name = mode_name.split('//')[1] if pat.match(mode_name): - if cmp(item, 'eint') == 0 and ((value.get_eintMode() or mode_name.find('MD_EINT') != -1)): + if item == 'eint' and ((value.get_eintMode() or mode_name.find('MD_EINT') != -1)): continue gen_str += '''#define %s%s\t\tGPIO_MODE_0%d\n''' % (varName.upper(), GpioData._specMap[item].upper(), i) @@ -459,7 +459,7 @@ def fill_cFile(self): regExp = '[_A-Z0-9:]*%s[_A-Z0-9:]*' %(item.upper()) pat = re.compile(regExp) if pat.match(mode_name): - if cmp(item, 'eint') == 0 and ((value.get_eintMode() or mode_name.find('MD_EINT') != -1)): + if item == 'eint' and ((value.get_eintMode() or mode_name.find('MD_EINT') != -1)): continue gen_str += '''#define %s%s\t\tGPIO_MODE_0%d\n''' % (varName.upper(), GpioData._specMap[item].upper(), value.get_defMode()) bmatch = True @@ -676,8 +676,8 @@ def __init__(self): GpioObj_MT6759.__init__(self) def get_eint_index(self, gpio_index): - if string.atoi(gpio_index) in GpioData._map_table.keys(): - return GpioData._map_table[string.atoi(gpio_index)] + if int(gpio_index) in GpioData._map_table.keys(): + return GpioData._map_table[int(gpio_index)] return -1 def fill_pinctrl_hFile(self): @@ -727,7 +727,7 @@ def fill_init_default_dtsiFile(self): if "GPIO_INIT_NO_COVER" in value.get_varNames(): continue - num = string.atoi(key[4:]) + num = int(key[4:]) defMode = value.get_defMode() dout = 1 if value.get_outHigh() else 0 pullEn = 1 if value.get_inPullEn() else 0 @@ -749,7 +749,7 @@ def fill_init_default_dtsiFile(self): for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] - num = string.atoi(key[4:]) + num = int(key[4:]) defMode = value.get_defMode() dout = 1 if value.get_outHigh() else 0 pullEn = 1 if value.get_inPullEn() else 0 diff --git a/tools/dct/obj/I2cObj.py b/tools/dct/obj/I2cObj.py index 1d73e27166d5..430b9d06e97b 100755 --- a/tools/dct/obj/I2cObj.py +++ b/tools/dct/obj/I2cObj.py @@ -15,14 +15,14 @@ import re import string import xml.dom.minidom -import ConfigParser +import configparser as ConfigParser -from ModuleObj import ModuleObj +from obj.ModuleObj import ModuleObj #from utility import util from utility.util import sorted_key from data.I2cData import I2cData from data.I2cData import BusData -import ChipObj +import obj.ChipObj as ChipObj class I2cObj(ModuleObj): _busList = [] @@ -33,11 +33,11 @@ def __init__(self): #self.__bBusEnable = True def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) - I2cData._i2c_count = string.atoi(cp.get('I2C', 'I2C_COUNT')) - I2cData._channel_count = string.atoi(cp.get('I2C', 'CHANNEL_COUNT')) + I2cData._i2c_count = int(cp.get('I2C', 'I2C_COUNT')) + I2cData._channel_count = int(cp.get('I2C', 'CHANNEL_COUNT')) if cp.has_option('Chip Type', 'I2C_BUS'): flag = cp.get('Chip Type', 'I2C_BUS') @@ -53,7 +53,7 @@ def read(self, node): nodes = node.childNodes for node in nodes: if node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: - if cmp(node.nodeName, 'count') == 0: + if node.nodeName == 'count': self.__count = node.childNodes[0].nodeValue continue if node.nodeName.find('bus') != -1: @@ -128,19 +128,19 @@ def fill_dtsiFile(self): if self._bBusEnable: - gen_str += '''\tclock-frequency = <%d>;\n''' %(string.atoi(self._busList[i].get_speed()) * 1000) + gen_str += '''\tclock-frequency = <%d>;\n''' %(int(self._busList[i].get_speed()) * 1000) temp_str = '' - if cmp(self._busList[i].get_enable(), 'false') == 0: + if self._busList[i].get_enable() == 'false': temp_str = 'use-open-drain' - elif cmp(self._busList[i].get_enable(), 'true') == 0: + elif self._busList[i].get_enable() == 'true': temp_str = 'use-push-pull' gen_str += '''\tmediatek,%s;\n''' %(temp_str) for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] channel = 'I2C_CHANNEL_%d' %(i) - if cmp(value.get_channel(), channel) == 0 and cmp(value.get_varName(), 'NC') != 0 and value.get_address().strip() != '': + if value.get_channel() == channel and value.get_varName() != 'NC' and value.get_address().strip() != '': gen_str += '''\t%s@%s {\n''' %(value.get_varName().lower(), value.get_address()[2:].lower()) gen_str += '''\t\tcompatible = \"mediatek,%s\";\n''' %(value.get_varName().lower()) gen_str += '''\t\treg = <%s>;\n''' %(value.get_address().lower()) @@ -175,19 +175,19 @@ def fill_dtsiFile(self): if self._bBusEnable: - gen_str += '''\tclock-frequency = <%d>;\n''' %(string.atoi(self._busList[i].get_speed()) * 1000) + gen_str += '''\tclock-frequency = <%d>;\n''' %(int(self._busList[i].get_speed()) * 1000) temp_str = '' - if cmp(self._busList[i].get_enable(), 'false') == 0: + if self._busList[i].get_enable() == 'false': temp_str = 'use-open-drain' - elif cmp(self._busList[i].get_enable(), 'true') == 0: + elif self._busList[i].get_enable() == 'true': temp_str = 'use-push-pull' gen_str += '''\tmediatek,%s;\n''' %(temp_str) for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] channel = 'I2C_CHANNEL_%d' %(i) - if cmp(value.get_channel(), channel) == 0 and cmp(value.get_varName(), 'NC') != 0 and value.get_address().strip() != '': + if value.get_channel() == channel and value.get_varName() != 'NC' and value.get_address().strip() != '': gen_str += '''\t%s_mtk:%s@%s {\n''' %(value.get_varName().lower(), value.get_varName().lower(), value.get_address()[2:].lower()) gen_str += '''\t\tcompatible = \"mediatek,%s\";\n''' %(value.get_varName().lower()) gen_str += '''\t\treg = <%s>;\n''' %(value.get_address().lower()) @@ -213,19 +213,19 @@ def fill_dtsiFile(self): if self._bBusEnable: - gen_str += '''\tclock-frequency = <%d>;\n''' %(string.atoi(self._busList[i].get_speed()) * 1000) + gen_str += '''\tclock-frequency = <%d>;\n''' %(int(self._busList[i].get_speed()) * 1000) temp_str = '' - if cmp(self._busList[i].get_enable(), 'false') == 0: + if self._busList[i].get_enable() == 'false': temp_str = 'use-open-drain' - elif cmp(self._busList[i].get_enable(), 'true') == 0: + elif self._busList[i].get_enable() == 'true': temp_str = 'use-push-pull' gen_str += '''\tmediatek,%s;\n''' %(temp_str) for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] channel = 'I2C_CHANNEL_%d' %(i) - if cmp(value.get_channel(), channel) == 0 and cmp(value.get_varName(), 'NC') != 0 and value.get_address().strip() != '': + if value.get_channel() == channel and value.get_varName() != 'NC' and value.get_address().strip() != '': gen_str += '''\t%s_mtk:%s@%s {\n''' %(value.get_varName().lower(), value.get_varName().lower(), value.get_address()[2:].lower()) if re.match(r'^RT[\d]+$', value.get_varName()): gen_str += '''\t\tcompatible = \"richtek,%s\";\n''' %(value.get_varName().lower()) diff --git a/tools/dct/obj/KpdObj.py b/tools/dct/obj/KpdObj.py index 6dae46f25722..012a9f84e317 100755 --- a/tools/dct/obj/KpdObj.py +++ b/tools/dct/obj/KpdObj.py @@ -14,10 +14,10 @@ import re import string -import ConfigParser +import configparser as ConfigParser import xml.dom.minidom -from ModuleObj import ModuleObj +from obj.ModuleObj import ModuleObj from utility.util import LogLevel from utility.util import log from data.KpdData import KpdData @@ -29,20 +29,20 @@ def __init__(self): def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_cmpPath()) ops = cp.options('Key_definition') for op in ops: - KpdData._keyValueMap[op.upper()] = string.atoi(cp.get('Key_definition', op)) + KpdData._keyValueMap[op.upper()] = int(cp.get('Key_definition', op)) KpdData._keyValueMap['NC'] = 0 cp.read(ModuleObj.get_figPath()) if cp.has_option('KEYPAD_EXTEND_TYPE', 'KEY_ROW'): - KpdData.set_row_ext(string.atoi(cp.get('KEYPAD_EXTEND_TYPE', 'KEY_ROW'))) + KpdData.set_row_ext(int(cp.get('KEYPAD_EXTEND_TYPE', 'KEY_ROW'))) if cp.has_option('KEYPAD_EXTEND_TYPE', 'KEY_COLUMN'): - KpdData.set_col_ext(string.atoi(cp.get('KEYPAD_EXTEND_TYPE', 'KEY_COLUMN'))) + KpdData.set_col_ext(int(cp.get('KEYPAD_EXTEND_TYPE', 'KEY_COLUMN'))) return True @@ -51,11 +51,11 @@ def read(self, node): for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: if node.nodeName == 'row': - row = string.atoi(node.childNodes[0].nodeValue) + row = int(node.childNodes[0].nodeValue) KpdData.set_row(row) if node.nodeName == 'column': - col = string.atoi(node.childNodes[0].nodeValue) + col = int(node.childNodes[0].nodeValue) KpdData.set_col(col) if node.nodeName == 'keyMatrix': @@ -68,7 +68,7 @@ def read(self, node): matrix.append(item) KpdData.set_matrix(matrix) for item in matrix: - if cmp(item, 'NC') != 0: + if item != 'NC': KpdData._usedKeys.append(item) KpdData._usedKeys.append('POWER') @@ -94,7 +94,7 @@ def read(self, node): KpdData._modeKeys['FACTORY'] = keys[2] if node.nodeName == 'pwrKeyEint_gpioNum': - num = string.atoi(node.childNodes[0].nodeValue) + num = int(node.childNodes[0].nodeValue) KpdData.set_gpioNum(num) if node.nodeName == 'pwrKeyUtility': @@ -127,7 +127,7 @@ def read(self, node): KpdData.set_gpioDinHigh(flag) if node.nodeName == 'pressPeriod': - time = string.atoi(node.childNodes[0].nodeValue) + time = int(node.childNodes[0].nodeValue) KpdData.set_pressTime(time) if node.nodeName == 'keyType': @@ -171,7 +171,7 @@ def fill_hFile(self): # do not gen this macro if the home key is null if KpdData.get_homeKey() != '': gen_str += '''#define KPD_PMIC_RSTKEY_MAP\tKEY_%s\n''' %(KpdData.get_homeKey()) - if cmp(KpdData.get_keyType(), 'EXTEND_TYPE') != 0: + if KpdData.get_keyType() != 'EXTEND_TYPE': gen_str += '''#define MTK_PMIC_PWR_KEY\t%d\n''' %(KpdData.get_col() - 1) if KpdData.get_homeKey() != '': gen_str += '''#define MTK_PMIC_RST_KEY\t\t%d\n''' %(2*KpdData.get_col() - 1) @@ -191,11 +191,11 @@ def fill_hFile(self): if KpdData.get_keyType() == 'NORMAL_TYPE': for key in KpdData.get_matrix(): - if cmp(key, 'NC') != 0: + if key != 'NC': gen_str += '''\t[%d] = KEY_%s,\t\\\n''' %(KpdData.get_matrix().index(key), key) else: for key in KpdData.get_matrix_ext(): - if cmp(key, 'NC') != 0: + if key != 'NC': gen_str += '''\t[%d] = KEY_%s,\t\\\n''' %(KpdData.get_matrix_ext().index(key), key) gen_str += '''}\n''' @@ -209,7 +209,7 @@ def fill_hFile(self): gen_str += '''\n''' for key in KpdData.get_downloadKeys(): - if cmp(key, 'NC') != 0: + if key != 'NC': dlIdx = KpdData.get_downloadKeys().index(key) mtxIdx = self.get_matrixIdx(key) gen_str += '''#define KPD_DL_KEY%d\t%d\t/* KEY_%s */\n''' %(dlIdx+1, mtxIdx, key) @@ -220,7 +220,7 @@ def fill_hFile(self): gen_str += '''/***********************************************************/\n''' for (key, value) in KpdData.get_modeKeys().items(): - if cmp(value, 'NC') != 0: + if value != 'NC': idx = self.get_matrixIdx(value) #idx = KpdData.get_matrix().index(value) gen_str += '''#define MT65XX_%s_KEY\t%d\t/* KEY_%s */\n''' %(key, idx, value) @@ -231,16 +231,16 @@ def fill_hFile(self): def get_matrixIdx(self, value): if KpdData.get_keyType() == 'NORMAL_TYPE': - if cmp(value, 'POWER') == 0: + if value == 'POWER': return KpdData.get_col() - 1 - elif cmp(value, KpdData.get_homeKey()) == 0: + elif value == KpdData.get_homeKey(): return 2 * KpdData.get_col() - 1 else: return KpdData.get_matrix().index(value) elif KpdData.get_keyType() == 'EXTEND_TYPE': - if cmp(value, 'POWER') == 0: + if value == 'POWER': return KpdData.get_col_ext() - 1 - elif cmp(value, KpdData.get_homeKey()) == 0: + elif value == KpdData.get_homeKey(): return 2 * KpdData.get_col_ext() - 1 else: return KpdData.get_matrix_ext().index(value) @@ -285,12 +285,12 @@ def fill_dtsiFile(self): gen_str += '''\tmediatek,kpd-pwrkey-eint-gpio = <%d>;\n''' %(KpdData.get_gpioNum()) gen_str += '''\tmediatek,kpd-pwkey-gpio-din = <%d>;\n''' %(int(KpdData.get_gpioDinHigh())) for key in KpdData.get_downloadKeys(): - if cmp(key, 'NC') == 0: + if key == 'NC': continue gen_str += '''\tmediatek,kpd-hw-dl-key%d = <%s>;\n''' %(KpdData.get_downloadKeys().index(key), self.get_matrixIdx(key)) for (key, value) in KpdData.get_modeKeys().items(): - if cmp(value, 'NC') == 0: + if value == 'NC': continue gen_str += '''\tmediatek,kpd-hw-%s-key = <%d>;\n''' %(key.lower(), self.get_matrixIdx(value)) diff --git a/tools/dct/obj/Md1EintObj.py b/tools/dct/obj/Md1EintObj.py index 30044c434278..245dfe68589c 100755 --- a/tools/dct/obj/Md1EintObj.py +++ b/tools/dct/obj/Md1EintObj.py @@ -12,7 +12,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See http://www.gnu.org/licenses/gpl-2.0.html for more details. -import ConfigParser +import configparser as ConfigParser import string import xml.dom.minidom from itertools import dropwhile @@ -20,7 +20,7 @@ from utility import util from utility.util import sorted_key -from ModuleObj import ModuleObj +from obj.ModuleObj import ModuleObj from data.Md1EintData import Md1EintData from utility.util import LogLevel @@ -32,7 +32,7 @@ def __init__(self): def get_cfgInfo(self): # ConfigParser accept ":" and "=", so SRC_PIN will be treated specially - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) if cp.has_option('Chip Type', 'MD1_EINT_SRC_PIN'): @@ -62,7 +62,7 @@ def read(self, node): try: for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: - if cmp(node.nodeName, 'count') == 0: + if node.nodeName == 'count': self.__count = node.childNodes[0].nodeValue continue @@ -131,7 +131,7 @@ def fill_hFile(self): count = 0 for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] - if cmp(value.get_varName(), 'NC') == 0: + if value.get_varName() == 'NC': continue num = key[4:] count += 1 @@ -156,7 +156,7 @@ def fill_dtsiFile(self): gen_str += '''&eintc {\n''' for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] - if cmp(value.get_varName(), 'NC') == 0: + if value.get_varName() == 'NC': continue num = key[4:] gen_str += '''\t%s@%s {\n''' %(value.get_varName(), num) @@ -166,17 +166,17 @@ def fill_dtsiFile(self): polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() - if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: + if polarity == 'High' and sensitive == 'Edge': type = 1 - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: + elif polarity == 'Low' and sensitive == 'Edge': type = 2 - elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'High' and sensitive == 'Level': type = 4 - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'Low' and sensitive == 'Level': type = 8 gen_str += '''\t\tinterrupts = <%s %d>;\n''' %(num, type) - gen_str += '''\t\tdebounce = <%s %d>;\n''' %(num, (string.atoi(value.get_debounceTime()))*1000) + gen_str += '''\t\tdebounce = <%s %d>;\n''' %(num, (int(value.get_debounceTime()))*1000) gen_str += '''\t\tdedicated = <%s %d>;\n''' %(num, int(value.get_dedicatedEn())) if self.__bSrcPinEnable: gen_str += '''\t\tsrc_pin = <%s %s>;\n''' %(num, self.__srcPin[value.get_srcPin()]) @@ -206,7 +206,7 @@ def fill_dtsiFile(self): gen_str = '' for key in sorted_key(ModuleObj.get_data(self).keys()): value = ModuleObj.get_data(self)[key] - if cmp(value.get_varName(), 'NC') == 0: + if value.get_varName() == 'NC': continue num = key[4:] gen_str += '''&%s {\n''' % (value.get_varName().lower()) @@ -216,17 +216,17 @@ def fill_dtsiFile(self): polarity = value.get_polarity() sensitive = value.get_sensitiveLevel() - if cmp(polarity, 'High') == 0 and cmp(sensitive, 'Edge') == 0: + if polarity == 'High' and sensitive == 'Edge': type = 1 - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Edge') == 0: + elif polarity == 'Low' and sensitive == 'Edge': type = 2 - elif cmp(polarity, 'High') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'High' and sensitive == 'Level': type = 4 - elif cmp(polarity, 'Low') == 0 and cmp(sensitive, 'Level') == 0: + elif polarity == 'Low' and sensitive == 'Level': type = 8 gen_str += '''\tinterrupts = <%s %d>;\n''' % (num, type) - gen_str += '''\tdebounce = <%s %d>;\n''' % (num, (string.atoi(value.get_debounceTime())) * 1000) + gen_str += '''\tdebounce = <%s %d>;\n''' % (num, (int(value.get_debounceTime())) * 1000) gen_str += '''\tdedicated = <%s %d>;\n''' % (num, int(value.get_dedicatedEn())) if self.get_srcPinEnable(): gen_str += '''\tsrc_pin = <%s %s>;\n''' % (num, self.get_srcPin()[value.get_srcPin()]) diff --git a/tools/dct/obj/PmicObj.py b/tools/dct/obj/PmicObj.py index 2414c00bd7d5..1030a3a0d999 100755 --- a/tools/dct/obj/PmicObj.py +++ b/tools/dct/obj/PmicObj.py @@ -14,10 +14,10 @@ import sys, os import re -import ConfigParser +import configparser as ConfigParser import xml.dom.minidom -from ModuleObj import ModuleObj +from obj.ModuleObj import ModuleObj from data.PmicData import PmicData from utility.util import log @@ -39,7 +39,7 @@ def __init__(self): def get_cfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_cmpPath()) PmicData._var_list = cp.options('APPLICATION') @@ -70,12 +70,12 @@ def read(self, node): nodes = node.childNodes for node in nodes: if node.nodeType == xml.dom.Node.ELEMENT_NODE: - if cmp(node.nodeName, 'chip') == 0: + if node.nodeName == 'chip': if len(node.childNodes) == 0: break self.__chipName = node.childNodes[0].nodeValue continue - if cmp(node.nodeName, 'count') == 0: + if node.nodeName == 'count': continue ldoNode = node.getElementsByTagName('ldoVar') defNode = node.getElementsByTagName('defEn') @@ -86,9 +86,9 @@ def read(self, node): if len(defNode): number = -1 - if cmp(defNode[0].childNodes[0].nodeValue, 'SKIP') == 0: + if defNode[0].childNodes[0].nodeValue == 'SKIP': number = 0 - elif cmp(defNode[0].childNodes[0].nodeValue, 'OFF') == 0: + elif defNode[0].childNodes[0].nodeValue == 'OFF': number = 1 else: number = 2 diff --git a/tools/dct/obj/PowerObj.py b/tools/dct/obj/PowerObj.py index 6cff9bf5d8f8..0c460ecf1736 100755 --- a/tools/dct/obj/PowerObj.py +++ b/tools/dct/obj/PowerObj.py @@ -15,15 +15,15 @@ import sys,os import re import string -import ConfigParser +import configparser as ConfigParser import xml.dom.minidom -import ChipObj +import obj.ChipObj as ChipObj from data.PowerData import PowerData from utility.util import log from utility.util import LogLevel from utility.util import sorted_key -from ModuleObj import ModuleObj +from obj.ModuleObj import ModuleObj class PowerObj(ModuleObj): def __init__(self): @@ -31,7 +31,7 @@ def __init__(self): self.__list = {} def getCfgInfo(self): - cp = ConfigParser.ConfigParser(allow_no_value=True) + cp = ConfigParser.ConfigParser(allow_no_value=True, strict=False) cp.read(ModuleObj.get_figPath()) self.__list = cp.options('POWER') @@ -75,7 +75,7 @@ def fill_hFile(self): value = ModuleObj.get_data(self)[key] if value.get_varName() == '': continue - idx = string.atoi(key[5:]) + idx = int(key[5:]) name = self.__list[idx] gen_str += '''#define GPIO_%s\t\tGPIO_%s\n''' %(name.upper(), value.get_varName()) diff --git a/tools/dct/utility/util.py b/tools/dct/utility/util.py index 8c0b16e17fb5..3f52908b07ec 100755 --- a/tools/dct/utility/util.py +++ b/tools/dct/utility/util.py @@ -27,16 +27,16 @@ class LogLevel: def log(level, msg): if level == LogLevel.info: - print LEVEL_INFO + msg + print(LEVEL_INFO + msg) elif level == LogLevel.warn: - print LEVEL_WARN + msg + print(LEVEL_WARN + msg) elif level == LogLevel.error: - print LEVEL_ERROR + msg + print(LEVEL_ERROR + msg) def compare(value): lst = re.findall(r'\d+', value) if len(lst) != 0: - return string.atoi(lst[0]) + return int(lst[0]) # if can not find numbers return value