1. 请不要使用unlikely做判断,除非有确凿的证据说明unlikely能提高效率。编译器和cpu已经知道0是正常的返回值。
NEVER use unlikely unless you can measure the difference without it.
And even then, you better be able to justify it. For something as dumb
as this type of check, you are working against the complier and cpu which
already knows that 0 is the usual response.
2. 函数定义需要这行的话,应该和’(‘对齐
This line should be aligned with the opening ( above.
3. void类型的指针,不许要做转换,可直接复制给任意类型指针变量。
No need to cast a void pointer.
NEVER use unlikely unless you can measure the difference without it.
And even then, you better be able to justify it. For something as dumb
as this type of check, you are working against the complier and cpu which
already knows that 0 is the usual response.
2. 函数定义需要这行的话,应该和’(‘对齐
This line should be aligned with the opening ( above.
static inline int handle_lsr_errors(struct uart_port *port,
unsigned int *flag, unsigned int *lsr)
3. void类型的指针,不许要做转换,可直接复制给任意类型指针变量。
No need to cast a void pointer.
static inline void sprd_rx(int irq, void *dev_id)
{
struct uart_port *port = (struct uart_port *)dev_id;
4. 调用ioremap()函数需要做返回值判断
Return value of ioremap() should be checked for NULL.
up->membase = ioremap(mem->start, resource_size(mem));5. 向已有的文件添加内容,应该按照字母排序地去添加
对于社区中有一些老代码本就不是按照字母排序的方式排列定义,那就保证我们自己的添加是按照字母排序的就好。
6. #include头文件,按照字母排序罗列
7.调用devm_request_irq()函数,需注意irqflags,如下代码片段: irqflags = IRQF_SHARED,如果是这样的情况,就要注意在handle_irq()函数中判断,是否为this device发出的,如果不是,需要在handle_irq()函数中返回IRQ_NONE。
<span style="font-size:18px;">ret = devm_request_irq(port->dev, port->irq, sprd_handle_irq,<span style="background-color: rgb(255, 204, 0); "> IRQF_SHARED</span>, sp->name, port);</span>
<span style="font-size:18px;">devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
<span style="white-space:pre"> </span> unsigned long irqflags, const char *devname, void *dev_id)
{
<span style="white-space:pre"> </span>return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
<span style="white-space:pre"> </span> devname, dev_id);
}
</span>