Category: Coccinelle

staging: rdma: hfi1: Use setup_timer

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> The function setup_timer combines the initialization of a timer with the initialization of the timer’s function and data fields. The multiline code for timer initialization is now replaced with function setup_timer. This was done with Coccinelle. @@ expression e1, e2, e3; type T; @@ – init_timer(&e1); … ( – e1.function = …

Continue reading

staging: rtl8712: Remove exceptional & on function name

Author: Amitoj Kaur Chawla <amitoj1606@gmail.com> Remove exceptional ‘&’ operator in front of a function name. The Coccinelle semantic patch that is used to make this change is as follows: // @r@ identifier f; @@ f(…) { … } @@ identifier r.f; @@ – &f + f @m@ type T; identifier f; @@ T f(…); @@ …

Continue reading

staging: comedi: Use macro DIV_ROUND_CLOSEST

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Occurences of the computation (x +d/2)/d can be replaced with the macro DIV_ROUND_CLOSEST. This was detected by the following Coccinelle script. @@ expression e1,e2; @@ ( – ((e1) + e2/2) / (e2) + DIV_ROUND_CLOSEST(e1,e2) | – ((e1) + (e2/2)) / (e2) + DIV_ROUND_CLOSEST(e1,e2) ) Since some lines exceeded the 80 character …

Continue reading

staging: rtl8192u: ieee80211: Use macro DIV_ROUND_UP

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> The macro DIV_ROUND_UP performs the computation (((n) + (d) – 1) /(d)). It clarifies the divisor calculations. This was done using the coccinelle script: @@ expression e1; expression e2; @@ ( – ((e1) + e2 – 1) / (e2) + DIV_ROUND_UP(e1,e2) | – ((e1) + (e2 – 1)) / (e2) + …

Continue reading

staging: rts5208: Prefer using BIT macro

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Replace all instances of bit shifting on 1 with the BIT(x) macro. This was done using Coccinelle. @@ int c; @@ – (1

staging: rts5208: Removed unnecessary return variable

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> This patch removes unnecessary return variables in switch statements. This was done with Coccinelle: @@ local idexpression ret; expression e1,e2; identifier label; @@ switch ( … ) { case label : … – ret = e1; – break; + return e1; … default: … – ret = e2; + return e2; …

Continue reading

staging: most: compress return logic into one line

Author: Eva Rachel Retuya <eraretuya@gmail.com> Eliminate local variable ‘ret’ and modify return statement to contain the value being returned directly instead of assigning it first to ‘ret’ and returning this variable. Coccinelle semantic patch used: @@ expression e, ret; @@ -ret = +return e; -return ret; Signed-off-by: Eva Rachel Retuya Signed-off-by: Greg Kroah-Hartman — drivers/staging/most/hdm-dim2/dim2_sysfs.c …

Continue reading

staging: rtl8712: Remove unnecessary cast on void pointer

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> The following Coccinelle script was used to detect this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[…] | ((T*)x)->f | – (T*) e ) Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Greg Kroah-Hartman — drivers/staging/rtl8712/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)   …

Continue reading

staging: rtl8712: Remove cast on void pointer

Author: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> The following Coccinelle script was used to detect this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[…] | ((T *)x)->f | – (T *) e ) Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Greg Kroah-Hartman — drivers/staging/rtl8712/rtl8712_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 …

Continue reading

Staging: wilc1000: Remove and rename struct typedefs from .c files

Author: Bhumika Goyal <bhumirks@gmail.com> Using typedef for a structure type is not suggested in Linux kernel coding style guidelines. So remove typedefs from structures wilc_sdio_t, wilc_spi_t and wilc_mac_cfg_t. Also remove ‘_t’ suffix from the struct names by hand. The following semantic patch detects cases: @tn1@ type td; @@ typedef struct { … } td; @script:python …

Continue reading