最近在写代码的时候,需要更改SDK中的函数mxc_iomux_v3_setup_pad,在linux kernel中多次用到了这个函数,且SDK中frescale imx的姊妹平台很多,很多没有用到的c文件都用到了这个函数。在改之前为了评估工作量,看看总共有多少有效的地方引用了该函数,就写了一个小的shell脚本来实现这个功能。
脚本内容:
tools_to_find_func.sh
#!/bin/bash
if [ $# != 1 ]
then
echo "usage: cmd flag(func)"
exit 0
fi
find . -name "*.o" > tmp.file
sed -i "s/.o$/.c/g" tmp.file
grep -rn $1 $(cat tmp.file) 2> /dev/null
rm tmp.file
将写好的脚本加上执行权限:chmod +x tools_to_find_func.sh,放到/usr/sbin下面。
sudo cp tools_to_find_func.sh /usr/sbin/
在自己的kernel根目录下,将代码编译一遍。然后执行: tools_to_find_func.sh mxc_iomux_v3_setup_pad
结果出来了:
king@kingdom$ tools_to_find_func.sh mxc_iomux_v3_setup_pad
./drivers/imx6_gpio/yw_gpio_test.c:36: mxc_iomux_v3_setup_pad(pad1);
./drivers/imx6_gpio/yw_gpio_test.c:37: mxc_iomux_v3_setup_pad(pad2);
./drivers/imx6_gpio/yw_gpio_test.c:38: mxc_iomux_v3_setup_pad(pad3);
./drivers/misc/pwrgaurd/pwrgaurd.c:106: mxc_iomux_v3_setup_pad(MX6DL_PAD_GPIO_16__GPIO_7_11);
./drivers/misc/pwrgaurd/pwrgaurd.c:177: mxc_iomux_v3_setup_pad(MX6DL_PAD_EIM_D24__UART3_TXD);
./drivers/misc/pwrgaurd/pwrgaurd.c:178: mxc_iomux_v3_setup_pad(MX6DL_PAD_EIM_D25__UART3_RXD);
./drivers/misc/pwrgaurd/pwrgaurd.c:202: mxc_iomux_v3_setup_pad(MX6DL_PAD_EIM_D24__GPIO_3_24); //to prevent flow background by uart3
./drivers/misc/pwrgaurd/pwrgaurd.c:203: mxc_iomux_v3_setup_pad(MX6DL_PAD_EIM_D25__GPIO_3_25);
./drivers/misc/pwrgaurd/pwrgaurd.c:229: mxc_iomux_v3_setup_pad(MX6DL_PAD_SD1_DAT0__GPIO_1_16);
./drivers/misc/pwrgaurd/pwrgaurd.c:230: mxc_iomux_v3_setup_pad(MX6DL_PAD_SD1_DAT1__GPIO_1_17);
./drivers/misc/pwrgaurd/pwrgaurd.c:231: mxc_iomux_v3_setup_pad(MX6DL_PAD_SD1_CMD__GPIO_1_18);
./drivers/misc/pwrgaurd/pwrgaurd.c:232: mxc_iomux_v3_setup_pad(MX6DL_PAD_SD1_DAT2__GPIO_1_19);
./drivers/misc/pwrgaurd/pwrgaurd.c:233: mxc_iomux_v3_setup_pad(MX6DL_PAD_SD1_CLK__GPIO_1_20);
./drivers/misc/pwrgaurd/pwrgaurd.c:234: mxc_iomux_v3_setup_pad(MX6DL_PAD_SD1_DAT3__GPIO_1_21);
./drivers/misc/cam2fb/cam2fb.c:503: mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT17__GPIO_6_3);
./drivers/misc/cam2fb/cam2fb.c:504: //mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT16__UART4_RTS);
./drivers/misc/cam2fb/cam2fb.c:506: mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT16__GPIO_6_2); //rts_down forv1.1
./drivers/misc/cam2fb/cam2fb.c:511: mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT17__GPIO_6_3);
./drivers/misc/cam2fb/cam2fb.c:512: //mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT16__UART4_RTS);
./drivers/misc/cam2fb/cam2fb.c:514: mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT16__GPIO_6_2); //rts_down forv1.1
./drivers/misc/cam2fb/cam2fb.c:519: mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT16__GPIO_6_2);
./drivers/misc/cam2fb/cam2fb.c:520: // mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT17__UART4_RTS);
./arch/arm/mach-mx6/usb_h3.c:179: mxc_iomux_v3_setup_pad(
./arch/arm/mach-mx6/usb_h3.c:182: mxc_iomux_v3_setup_pad(