treewide: fix coccinelle checks
authorRosen Penev <[email protected]>
Sun, 3 Nov 2024 22:11:30 +0000 (14:11 -0800)
committerHauke Mehrtens <[email protected]>
Tue, 2 Dec 2025 22:32:42 +0000 (23:32 +0100)
Unneeded semicolon

WARNING comparing pointer to 0

WARNING: NULL check before some freeing functions is not needed.

WARNING: casting value returned by memory allocation function to (u32 *)

ERROR: allocation function on line 378 returns NULL not ERR_PTR on failure

Signed-off-by: Rosen Penev <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/19932
Signed-off-by: Hauke Mehrtens <[email protected]>
42 files changed:
package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c
package/kernel/lantiq/ltq-adsl-mei/src/ifxmips_mei_interface.h
package/kernel/lantiq/ltq-atm/src/ifxmips_atm_amazon_se.c
package/kernel/lantiq/ltq-atm/src/ifxmips_atm_ar9.c
package/kernel/lantiq/ltq-atm/src/ifxmips_atm_danube.c
package/kernel/lantiq/ltq-atm/src/ifxmips_atm_vr9.c
package/kernel/lantiq/ltq-atm/src/ltq_atm.c
package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c
package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c
package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c
package/kernel/lantiq/ltq-deu/src/ifxmips_des.c
package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h
package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h
package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.h
package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c
package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c
package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c
package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c
package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.c
package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_amazon_se.c
package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_ar9.c
package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_danube.c
package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vr9.c
package/kernel/rtc-rv5c386a/src/rtc.c
target/linux/at91/image/dfboot/src/com.c
target/linux/at91/image/dfboot/src/dataflash.c
target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
target/linux/bcm47xx/image/lzma-loader/src/LzmaDecode.c
target/linux/generic/files/drivers/mtd/nand/mtk_bmt.c
target/linux/generic/files/drivers/mtd/nand/mtk_bmt_nmbm.c
target/linux/generic/files/drivers/net/phy/b53/b53_common.c
target/linux/generic/files/drivers/net/phy/rtl8367b.c
target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c
target/linux/mediatek/files/drivers/net/phy/rtk/rtl8367c/i2c.c
target/linux/mediatek/files/drivers/net/phy/rtk/rtl8367c/rtl8367c_asicdrv_qos.c
target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.c
target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c
target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c
target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
target/linux/realtek/files-6.12/drivers/clk/realtek/clk-rtl83xx.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c

index c0fb66c5e33149cad27d94367afa6d9400bdd719..024d45d62c4405026928f2776e97fcfe873fe1f0 100644 (file)
@@ -1286,8 +1286,7 @@ IFX_MEI_RunAdslModem (DSL_DEV_Device_t *pDev)
 //     DSL_DEV_WinHost_Message_t m;
 
        if (mei_arc_swap_buff == NULL) {
-               mei_arc_swap_buff =
-                       (u32 *) kmalloc (MAXSWAPSIZE * 4, GFP_KERNEL);
+               mei_arc_swap_buff = kmalloc (MAXSWAPSIZE * 4, GFP_KERNEL);
                if (mei_arc_swap_buff == NULL) {
                        IFX_MEI_EMSG (">>> malloc fail for codeswap buff!!! <<<\n");
                        return DSL_DEV_MEI_ERR_FAILURE;
index ec4c4429ba31febbd04f0f3c707d6b4358a28303..f77e0d49b5a2ea3fcda59ebb695bb796116d3472 100644 (file)
@@ -418,7 +418,7 @@ typedef struct _arc_img_hdr {
        u32 size;               //      Size of binary image in bytes
        u32 checksum;           //      Checksum for image
        u32 count;              //      Count of swp pages in image
-       ARC_SWP_PAGE_HDR page[1];       //      Should be "count" pages - '1' to make compiler happy
+       ARC_SWP_PAGE_HDR page[];        //      Should be "count" pages - '1' to make compiler happy
 } ARC_IMG_HDR;
 
 typedef struct smmu_mem_info {
index c51f34dda3a0bc5002398112e1fed7b66632ef09..734fe299615619b9e0d158bdfd398494063dcf35 100644 (file)
@@ -224,8 +224,8 @@ static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len,
 {
     volatile u32 *dest;
 
-    if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-        || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+    if (!code_src || ((unsigned long)code_src & 0x03) != 0
+        || !data_src || ((unsigned long)data_src & 0x03) != 0 )
         return -1;
 
     if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
index b1e911915e794691a35b928a0f6212390f0223ea..28ac8f6c7aa66c769364151187c59b88c4cd5cac 100644 (file)
@@ -163,8 +163,8 @@ static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len,
 {
     volatile u32 *dest;
 
-    if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-        || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+    if (!code_src || ((unsigned long)code_src & 0x03) != 0
+        || !data_src || ((unsigned long)data_src & 0x03) != 0 )
         return -1;
 
     if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
index d32e888272f7ef0cdec63533299132bf0c8bf970..57a50e322d352ae42729315c982ca9588bc6f4de 100644 (file)
@@ -110,8 +110,8 @@ static inline int danube_pp32_download_code(u32 *code_src, unsigned int code_dwo
 {
        volatile u32 *dest;
 
-       if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-                       || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+       if (!code_src || ((unsigned long)code_src & 0x03) != 0
+                       || !data_src || ((unsigned long)data_src & 0x03) != 0 )
                return -1;
 
        if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
index c6bb772e4c438d924f73cefbfc6f9a9479222835..ffe079f3df5a46523bbb6044b298479f5f8d8f22 100644 (file)
@@ -96,8 +96,8 @@ static inline int vr9_pp32_download_code(int pp32, u32 *code_src, unsigned int c
        unsigned int clr, set;
        volatile u32 *dest;
 
-       if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-                       || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+       if (!code_src || ((unsigned long)code_src & 0x03) != 0
+                       || !data_src || ((unsigned long)data_src & 0x03) != 0 )
                return -1;
 
        clr = pp32 ? 0xF0 : 0x0F;
index 5a02346e42813d5af89d4e6c97c47845db2e5b3b..d97dadba685dea5b04d7995450f615803b499e63 100644 (file)
@@ -1503,17 +1503,10 @@ static inline void clear_priv_data(void)
                }
        }
 
-       if ( g_atm_priv_data.tx_skb_base != NULL )
-               kfree(g_atm_priv_data.tx_skb_base);
-
-       if ( g_atm_priv_data.tx_desc_base != NULL )
-               kfree(g_atm_priv_data.tx_desc_base);
-
-       if ( g_atm_priv_data.oam_buf_base != NULL )
-               kfree(g_atm_priv_data.oam_buf_base);
-
-       if ( g_atm_priv_data.oam_desc_base != NULL )
-               kfree(g_atm_priv_data.oam_desc_base);
+       kfree(g_atm_priv_data.tx_skb_base);
+       kfree(g_atm_priv_data.tx_desc_base);
+       kfree(g_atm_priv_data.oam_buf_base);
+       kfree(g_atm_priv_data.oam_desc_base);
 
        if ( g_atm_priv_data.aal_desc_base != NULL ) {
                for ( i = 0; i < dma_rx_descriptor_length; i++ ) {
@@ -1522,8 +1515,9 @@ static inline void clear_priv_data(void)
                                dev_kfree_skb_any(skb);
                        }
                }
-               kfree(g_atm_priv_data.aal_desc_base);
        }
+
+       kfree(g_atm_priv_data.aal_desc_base);
 }
 
 static inline void init_rx_tables(void)
index fdd172750dcdcdfd35fffa1418e98f12d2c7a0e4..4139b343dad32cd97e4f52aa6030f37e50a19a5e 100644 (file)
@@ -276,7 +276,7 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
         aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
         aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
         aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
-    };
+    }
 
 
     i = 0;
@@ -1529,7 +1529,7 @@ static int aes_cbcmac_init_tfm(struct crypto_tfm *tfm)
 {
     struct aes_ctx *mctx = crypto_tfm_ctx(tfm);
     mctx->temp = kzalloc(AES_BLOCK_SIZE * AES_CBCMAC_DBN_TEMP_SIZE, GFP_KERNEL);
-    if (IS_ERR(mctx->temp)) return PTR_ERR(mctx->temp);
+    if (!mctx->temp) return -ENOMEM;
 
     return 0;
 }
index e05faa4f3a4c96965b894a7a765593fff4bcd040..cdf9a89a1a58ba91b45cec8a6cb4b2ac8b49d126 100644 (file)
@@ -234,7 +234,7 @@ static int lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
         aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
         aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
         aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
-    };
+    }
 
 
     /* Prepare Rx buf length used in dma psuedo interrupt */
@@ -251,7 +251,7 @@ static int lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
 
     while (aes->controlr.BUS) {
          // wait for AES to be ready
-    };
+    }
 
     deu_priv->outcopy = (u32 *) DEU_DWORD_REORDERING(out_arg, aes_buff_out, BUFFER_OUT, nbytes);
     deu_priv->event_src = AES_ASYNC_EVENT;
@@ -576,10 +576,7 @@ static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq
     u32 remain, inc, nbytes = areq->nbytes;
     u32 chunk_bytes = src->length;
 
-
-    aes_con = (struct aes_container *)kmalloc(sizeof(struct aes_container),
-                                              GFP_KERNEL);
-
+    aes_con = kmalloc(sizeof(struct aes_container), GFP_KERNEL);
     if (!(aes_con)) {
         printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
                __func__, __LINE__);
index 4a1988dd3faa0903466081276d7804d61a100295..e96379f1d4c14d56d9decc2b0e6cae82c13eb6d2 100644 (file)
@@ -254,7 +254,7 @@ static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
         if (mode > 0) {
                 des->IVHR = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
                 des->IVLR = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
-        };
+        }
 
     /* memory alignment issue */
     dword_mem_aligned_in = (u32 *) DEU_DWORD_REORDERING(in_arg, des_buff_in, BUFFER_IN, nbytes);
@@ -268,7 +268,7 @@ static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
     dma->controlr.EN = 1;
 
     while (des->controlr.BUS) {
-    };
+    }
 
     wlen = dma_device_write (dma_device, (u8 *) dword_mem_aligned_in, nbytes, NULL);
     if (wlen != nbytes) {
@@ -287,7 +287,7 @@ static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
     if (mode > 0) {
         *(u32 *) iv_arg = DEU_ENDIAN_SWAP(des->IVHR);
         *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(des->IVLR);
-    };
+    }
 
     CRTCL_SECT_END;
 
@@ -578,9 +578,7 @@ static int lq_queue_mgr(struct des_ctx *ctx, struct ablkcipher_request *areq,
     u32 remain, inc, nbytes = areq->nbytes;
     u32 chunk_bytes = src->length;
 
-    des_con = (struct des_container *)kmalloc(sizeof(struct des_container),
-                                       GFP_KERNEL);
-
+    des_con = kmalloc(sizeof(struct des_container), GFP_KERNEL);
     if (!(des_con)) {
         printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
                 __func__, __LINE__);
index 3e4db763995b4e878fd7fea14348a0a33c73a94c..862419f7f75f92fdcc16bffd3d05abbc5bf58127 100644 (file)
@@ -229,7 +229,7 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
         if (mode > 0) {
                 des->IVHR = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
                 des->IVLR = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
-        };
+        }
 
         nblocks = nbytes / 4;
 
@@ -260,7 +260,7 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
     if (mode > 0) {
         *(u32 *) iv_arg = DEU_ENDIAN_SWAP(des->IVHR);
         *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(des->IVLR);
-    };
+    }
 
     CRTCL_SECT_END;
 }
index 00fbf40f479789133072c7d9474e3dbcf98c05ee..cf9745fc8603b5e161d6b66e1f51e4b8befaf688 100644 (file)
@@ -87,8 +87,8 @@
         volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
         for (i = 0; i < 10; i++)      \
            udelay(DELAY_PERIOD);     \
-        while (dma->controlr.BSY) {}; \
-        while (aes->controlr.BUS) {}; \
+        while (dma->controlr.BSY) {}  \
+        while (aes->controlr.BUS) {}  \
     } while (0)
 
 #define WAIT_DES_DMA_READY()          \
@@ -98,8 +98,8 @@
         volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
         for (i = 0; i < 10; i++)      \
             udelay(DELAY_PERIOD);     \
-        while (dma->controlr.BSY) {}; \
-        while (des->controlr.BUS) {}; \
+        while (dma->controlr.BSY) {}  \
+        while (des->controlr.BUS) {}  \
     } while (0)
 
 #define AES_DMA_MISC_CONFIG()        \
index 9daef9d2d71feece7bcd374535cd4099c19caf02..1a572073f979617c50eeb8ea918f108bef05f742 100644 (file)
@@ -81,8 +81,8 @@
         volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
         for (i = 0; i < 10; i++)      \
             udelay(DELAY_PERIOD);     \
-        while (dma->controlr.BSY) {}; \
-        while (aes->controlr.BUS) {}; \
+        while (dma->controlr.BSY) {}  \
+        while (aes->controlr.BUS) {}  \
     } while (0)
 
 #define WAIT_DES_DMA_READY()          \
@@ -92,8 +92,8 @@
         volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
         for (i = 0; i < 10; i++)      \
             udelay(DELAY_PERIOD);     \
-        while (dma->controlr.BSY) {}; \
-        while (des->controlr.BUS) {}; \
+        while (dma->controlr.BSY) {}  \
+        while (des->controlr.BUS) {}  \
     } while (0)
 
 #define SHA_HASH_INIT                  \
index 1107df96de6fd67b68dfbbc5f10bf7b2e7d7462c..06f0e8b8239fc4c7939fba808fc0bff33403eb1f 100644 (file)
         volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
         for (i = 0; i < 10; i++)      \
             udelay(DELAY_PERIOD);     \
-        while (dma->controlr.BSY) {}; \
-        while (aes->controlr.BUS) {}; \
+        while (dma->controlr.BSY) {}  \
+        while (aes->controlr.BUS) {}  \
     } while (0)
 
 #define WAIT_DES_DMA_READY()          \
         volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
         for (i = 0; i < 10; i++)      \
             udelay(DELAY_PERIOD);     \
-        while (dma->controlr.BSY) {}; \
-        while (des->controlr.BUS) {}; \
+        while (dma->controlr.BSY) {}  \
+        while (des->controlr.BUS) {}  \
     } while (0)
 
 #define AES_DMA_MISC_CONFIG()        \
index 80ff41a7383b372f5d726accb0db73c349ac4f43..dc2a502bd8b6cc96d797df3fec1822a106c1f46e 100644 (file)
@@ -107,7 +107,7 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in)
     for (i = 0; i < 16; i++) {
         hashs->MR = in[i];
 //      printk("in[%d]: %08x\n", i, in[i]);
-    };
+    }
 
     //wait for processing
     while (hashs->controlr.BSY) {
index 51a623b73d9eec5530cc548346d2080f1eb4c413..12088023baa1ba1c315f11a2e494927c4305a704 100644 (file)
@@ -308,7 +308,7 @@ static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final
     {
         for (i = 0; i < 16; i++) {
             hashs->MR = in[i];
-        };
+        }
 
         hashs->controlr.GO = 1;
         asm("sync");
@@ -355,9 +355,9 @@ static int md5_hmac_init_tfm(struct crypto_tfm *tfm)
 {
     struct md5_hmac_ctx *mctx = crypto_tfm_ctx(tfm);
     mctx->temp = kzalloc(4 * MD5_HMAC_DBN_TEMP_SIZE, GFP_KERNEL);
-    if (IS_ERR(mctx->temp)) return PTR_ERR(mctx->temp);
+    if (!mctx->temp) return -ENOMEM;
     mctx->desc = kzalloc(sizeof(struct shash_desc), GFP_KERNEL);
-    if (IS_ERR(mctx->desc)) return PTR_ERR(mctx->desc);
+    if (!mctx->desc) return -ENOMEM;
 
     return 0;
 }
index f67f45531f53342217b7147d5acd8728c417026f..f095d41830f84e151b599b3ac57aab732862c380 100644 (file)
@@ -119,7 +119,7 @@ static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in)
 
     for (i = 0; i < 16; i++) {
         hashs->MR = in[i];
-    };
+    }
 
     //wait for processing
     while (hashs->controlr.BSY) {
index e18fe2b0e8118455e36af2eeb2b3476d5797cd8c..3ab3966e57163398080a57205d901627add2fff2 100644 (file)
@@ -325,7 +325,7 @@ static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_fina
     {
         for (i = 0; i < 16; i++) {
             hashs->MR = in[i];
-        };
+        }
 
         hashs->controlr.GO = 1;
         asm("sync");
@@ -376,9 +376,9 @@ static int sha1_hmac_init_tfm(struct crypto_tfm *tfm)
 {
     struct sha1_hmac_ctx *sctx = crypto_tfm_ctx(tfm);
     sctx->temp = kzalloc(4 * SHA1_HMAC_DBN_TEMP_SIZE, GFP_KERNEL);
-    if (IS_ERR(sctx->temp)) return PTR_ERR(sctx->temp);
+    if (!sctx->temp) return -ENOMEM;
     sctx->desc = kzalloc(sizeof(struct shash_desc), GFP_KERNEL);
-    if (IS_ERR(sctx->desc)) return PTR_ERR(sctx->desc);
+    if (!sctx->desc) return -ENOMEM;
 
     return 0;
 }
index 48bc7b04a9d1a04fcc11fb8a7e7aae38f9f6c12f..527066f54fa56b0088c785c25d37088da2da8e43 100644 (file)
@@ -1360,14 +1360,9 @@ static INLINE void clear_priv_data(void)
         }
     }
 
-    if ( g_ptm_priv_data.rx_desc_base != NULL )
-        kfree(g_ptm_priv_data.rx_desc_base);
-
-    if ( g_ptm_priv_data.tx_desc_base != NULL )
-        kfree(g_ptm_priv_data.tx_desc_base);
-
-    if ( g_ptm_priv_data.tx_skb_base != NULL )
-        kfree(g_ptm_priv_data.tx_skb_base);
+    kfree(g_ptm_priv_data.rx_desc_base);
+    kfree(g_ptm_priv_data.tx_desc_base);
+    kfree(g_ptm_priv_data.tx_skb_base);
 }
 
 static INLINE void init_tables(void)
index 81ed7f78050877c97a3c740d9893519ac0efa67e..7548c6d357b361814ef92e033f65bba0d3faf7f4 100644 (file)
@@ -223,8 +223,8 @@ static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len,
 {
     volatile u32 *dest;
 
-    if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-        || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+    if (!code_src || ((unsigned long)code_src & 0x03) != 0
+        || !data_src || ((unsigned long)data_src & 0x03) != 0 )
         return -1;
 
     if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
index 2f108286e21955b4ed16b31cc9fa745262a49c08..e83268ee3631451526e5fbe9322d01081016b859 100644 (file)
@@ -246,8 +246,8 @@ static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len,
 {
     volatile u32 *dest;
 
-    if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-        || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+    if (!code_src || ((unsigned long)code_src & 0x03) != 0
+        || !data_src || ((unsigned long)data_src & 0x03) != 0 )
         return -1;
 
     if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
index 47ee4110a3a210db6247708590aeea59fe123158..ef20e9cb45340fb9454a4e48acfe5c8152dea944 100644 (file)
@@ -218,8 +218,8 @@ static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len,
 {
     volatile u32 *dest;
 
-    if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-        || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+    if (!code_src || ((unsigned long)code_src & 0x03) != 0
+        || !data_src || ((unsigned long)data_src & 0x03) != 0 )
         return -1;
 
     if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
index c0d16fe34fe45625b80f0e343b70db48871ec205..10e71cb1d9807409aff8404c5dbf303f80171222 100644 (file)
@@ -207,8 +207,8 @@ static inline int pp32_download_code(int pp32, u32 *code_src, unsigned int code_
     unsigned int clr, set;
     volatile u32 *dest;
 
-    if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
-        || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+    if (!code_src || ((unsigned long)code_src & 0x03) != 0
+        || !data_src || ((unsigned long)data_src & 0x03) != 0 )
         return -1;
 
     clr = pp32 ? 0xF0 : 0x0F;
index 0c00c41f96fc1e9a77d6d178d610b8fd962bf581..8123773e368875fa99a4165e00b3eb43a332d8d6 100644 (file)
@@ -174,13 +174,13 @@ static int i2c_outb(int c)
                if (sclhi() < 0) { /* timed out */
                        sdahi(); /* we don't want to block the net */
                        return -ETIMEDOUT;
-               };
+               }
                scllo();
        }
        sdahi();
        if (sclhi() < 0) {
                return -ETIMEDOUT;
-       };
+       }
        /* read ack: SDA should be pulled down by slave */
        ack = getsda() == 0;    /* ack: sda is pulled low ->success.     */
        scllo();
@@ -204,7 +204,7 @@ static int i2c_inb(int ack)
        for (i = 0; i < 8; i++) {
                if (sclhi() < 0) {
                        return -ETIMEDOUT;
-               };
+               }
                indata *= 2;
                if (getsda())
                        indata |= 0x01;
index 081d86fb6522c4ca11b2fc7fe5cc6ddacaa72674..d44f873cc9cf4aa47f4abc3e5a00df2183e4c890 100644 (file)
@@ -273,7 +273,7 @@ static int number(int num, int base, int size,
     putc(tmp[i]);
 
   while (size-- > 0)
-    putc(' ');;
+    putc(' ');
 
   return 1;
 }
index 62644485a85081beca1f459469c402af86c76854..c95e21a02bc4772f0192d8aaffecd4fe0469f6e4 100644 (file)
@@ -166,7 +166,7 @@ int read_dataflash(unsigned long addr, unsigned long size, char *result)
        AT91PS_DataFlash pFlash = &DataFlashInst;
 
        pFlash = AT91F_DataflashSelect (pFlash, &AddrToRead);
-       if (pFlash == 0)
+       if (!pFlash)
                return -1;
 
        return (AT91F_DataFlashRead(pFlash, AddrToRead, size, result));
index c1670b61a52bfd9b9daba2b83cc70d4da625d96a..9b40706cdd64d1268c306b9d5f52e7b854484428 100644 (file)
@@ -1379,10 +1379,8 @@ static int ar934x_nfc_probe(struct platform_device *pdev)
        }
 
        nfc->irq = platform_get_irq(pdev, 0);
-       if (nfc->irq < 0) {
-               dev_err(&pdev->dev, "no IRQ resource specified\n");
+       if (nfc->irq < 0)
                return -EINVAL;
-       }
 
        init_waitqueue_head(&nfc->irq_waitq);
        ret = devm_request_irq(&pdev->dev, nfc->irq, ar934x_nfc_irq_handler,
index 900c7e7b49f47e52736ec474b1b139fbd10de7bb..a4aeda5f1f10426711333e14ef61753a40f3b071 100644 (file)
@@ -185,7 +185,6 @@ int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder
 {
   int mi = 1;
   int i;
-  int symbol = 0;
   #ifdef _LZMA_LOC_OPT
   RC_INIT_VAR
   #endif
@@ -203,7 +202,7 @@ int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder
   #ifdef _LZMA_LOC_OPT
   RC_FLUSH_VAR
   #endif
-  return symbol;
+  return 0;
 }
 
 Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd)
index 063adb50fb6062cbcf95ef6a894e0aefea20834e..66a82dd2d02a5a014faec5f2c341775d71e3c8fa 100644 (file)
@@ -385,8 +385,7 @@ void mtk_bmt_detach(struct mtd_info *mtd)
        if (bmtd.mtd != mtd)
                return;
 
-       if (bmtd.debugfs_dir)
-               debugfs_remove_recursive(bmtd.debugfs_dir);
+       debugfs_remove_recursive(bmtd.debugfs_dir);
        bmtd.debugfs_dir = NULL;
 
        kfree(bmtd.bbt_buf);
index a896e49ec04751ef1a1c8ab61da0dd143fd14fc2..d5827880b2a4854b792978ca4e41b49ea3aa646b 100644 (file)
@@ -810,7 +810,7 @@ static bool nmbm_write_signature(struct nmbm_instance *ni, uint32_t limit,
 
        next_block:
                ba--;
-       };
+       }
 
        return false;
 }
@@ -2069,7 +2069,7 @@ static bool nmbm_find_signature(struct nmbm_instance *ni,
                                return true;
                        }
                }
-       };
+       }
 
        return false;
 }
index ac37ef93b5adb3a4363bdaf5b371997efd13e7ef..320fcbb69469bdb6d91d2cebf6d882b72211af00 100644 (file)
@@ -551,9 +551,11 @@ static int b53_configure_ports_of(struct b53_device *dev)
                                    mode == PHY_INTERFACE_MODE_REVMII) {
                                        b53_read8(dev, B53_CTRL_PAGE,
                                                  B53_PORT_OVERRIDE_CTRL, &po);
-                                       if (!(po & PORT_OVERRIDE_RV_MII_25))
-                                       pr_err("Failed to enable reverse MII mode\n");
-                                       return -EINVAL;
+                                       if (!(po & PORT_OVERRIDE_RV_MII_25)) {
+                                               pr_err("Failed to enable reverse MII mode\n");
+                                               of_node_put(dn);
+                                               return -EINVAL;
+                                       }
                                }
                        } else {
                                po |= GMII_PO_EN;
@@ -845,7 +847,7 @@ static int b53_vlan_set_ports(struct switch_dev *dev, struct switch_val *val)
                if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED))) {
                        vlan->untag |= BIT(port->id);
                        priv->ports[port->id].pvid = val->port_vlan;
-               };
+               }
        }
 
        /* ignore disabled ports */
index 5adcf00f0cac2516bf2108a8c7e1327aa4078117..7bd1d942528608e13b7bf29ab86deacb3f4cb952 100644 (file)
@@ -1594,8 +1594,7 @@ static int  rtl8367b_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, NULL);
        rtl8366_smi_cleanup(smi);
  err_free_smi:
-       if (smi->emu_vlanmc)
-               kfree(smi->emu_vlanmc);
+       kfree(smi->emu_vlanmc);
        kfree(smi);
        return err;
 }
index 4c1edad08178720f3de6db1e9625439295bed561..3c5fa6f5b968480ab98643c76cde8415b075702d 100644 (file)
@@ -549,7 +549,7 @@ static int hc_wlan_data_unpack_lzor_lz77(const u16 tag_id, const u8 *inbuf, size
                        ret = -ENODATA;
                        goto fail;
                }
-       };
+       }
        templen -= (u8 *)needle - tempbuf;
 
        /* Past magic. Look for tag node */
index 17a5f3785bd4f54c71bb6067f88e10c88d45c470..ac0852ab0cce6463a3cde2744a9dcc97c455341c 100644 (file)
@@ -215,7 +215,7 @@ rtk_api_ret_t rtk_i2c_data_read(rtk_uint8 deviceAddr, rtk_uint32 slaveRegAddr, r
 {
      rtk_uint32 retVal, counter=0;
      rtk_uint8 controlByte_W, controlByte_R;
-     rtk_uint8 slaveRegAddr_L, slaveRegAddr_H = 0x0, temp;
+     rtk_uint8 slaveRegAddr_L, slaveRegAddr_H = 0x0;
      rtk_uint8 regData_L, regData_H;
 
    /* control byte :deviceAddress + W,  deviceAddress + R   */
@@ -226,11 +226,7 @@ rtk_api_ret_t rtk_i2c_data_read(rtk_uint8 deviceAddr, rtk_uint32 slaveRegAddr, r
     slaveRegAddr_H = (rtk_uint8) (slaveRegAddr >>8) ;
 
     if( rtk_i2c_mode == I2C_70B_LSB_16BIT_MODE)
-    {
-        temp = slaveRegAddr_L ;
-        slaveRegAddr_L = slaveRegAddr_H;
-        slaveRegAddr_H = temp;
-    }
+       swap(slaveRegAddr_L, slaveRegAddr_H);
 
 
   /*check bus state: idle*/
@@ -339,7 +335,7 @@ rtk_api_ret_t rtk_i2c_data_write(rtk_uint8 deviceAddr, rtk_uint32 slaveRegAddr,
 {
      rtk_uint32 retVal,counter;
      rtk_uint8 controlByte_W;
-     rtk_uint8 slaveRegAddr_L, slaveRegAddr_H = 0x0, temp;
+     rtk_uint8 slaveRegAddr_L, slaveRegAddr_H = 0x0;
      rtk_uint8 regData_L, regData_H;
 
   /* control byte :deviceAddress + W    */
@@ -352,11 +348,7 @@ rtk_api_ret_t rtk_i2c_data_write(rtk_uint8 deviceAddr, rtk_uint32 slaveRegAddr,
     regData_L   = (rtk_uint8) (regData & 0x00FF);
 
     if( rtk_i2c_mode == I2C_70B_LSB_16BIT_MODE)
-    {
-        temp = slaveRegAddr_L ;
-        slaveRegAddr_L = slaveRegAddr_H;
-        slaveRegAddr_H = temp;
-    }
+        swap(slaveRegAddr_L, slaveRegAddr_H);
 
 
   /*check bus state: idle*/
index 69081049e3360b766274ad9ffa57d62e2146257c..4034f510902f33af9904ff85a095747ab91420c7 100644 (file)
@@ -233,7 +233,7 @@ ret_t rtl8367c_setAsicPriorityDecision(rtk_uint32 index, rtk_uint32 prisrc, rtk_
             break;
         default:
             break;
-    };
+    }
 
     return RT_ERR_OK;
 
@@ -278,7 +278,7 @@ ret_t rtl8367c_getAsicPriorityDecision(rtk_uint32 index, rtk_uint32 prisrc, rtk_
             break;
         default:
             break;
-    };
+    }
 
     return RT_ERR_OK;
 
index 0d77db511bf9751d222bf581149405a2c1bd2958..5b3f21c92f03d4148e318441eddb58bb956feffa 100644 (file)
@@ -1458,7 +1458,7 @@ MODULE_DEVICE_TABLE(of, ralink_esw_match);
 int rt3050_esw_init(struct fe_priv *priv)
 {
        struct device_node *np = priv->switch_np;
-       struct platform_device *pdev = of_find_device_by_node(np);
+       struct platform_device *pdev;
        struct switch_dev *swdev;
        struct rt305x_esw *esw;
        const __be32 *rgmii;
@@ -1470,9 +1470,12 @@ int rt3050_esw_init(struct fe_priv *priv)
        if (!of_device_is_compatible(np, ralink_esw_match->compatible))
                return -EINVAL;
 
+       pdev = of_find_device_by_node(np);
        esw = platform_get_drvdata(pdev);
-       if (!esw)
+       if (!esw) {
+               put_device(&pdev->dev);
                return -EPROBE_DEFER;
+       }
 
        priv->soc->swpriv = esw;
        esw->priv = priv;
@@ -1488,6 +1491,7 @@ int rt3050_esw_init(struct fe_priv *priv)
                dev_err(&pdev->dev, "RGMII mode, not exporting switch device.\n");
                unregister_switch(&esw->swdev);
                platform_set_drvdata(pdev, NULL);
+               put_device(&pdev->dev);
                return -ENODEV;
        }
 
index 750fd94d3ff2b539d642a5b510d2aca8b991f1ec..f45c874eee6554d3d23e246a4dd86cc757453e3a 100644 (file)
@@ -206,18 +206,19 @@ int mtk_gsw_init(struct fe_priv *priv)
        struct device_node *eth_node = priv->dev->of_node;
        struct device_node *phy_node, *mdiobus_node;
        struct device_node *np = priv->switch_np;
-       struct platform_device *pdev = of_find_device_by_node(np);
+       struct platform_device *pdev;
        struct mt7620_gsw *gsw;
        const __be32 *id;
        int ret;
        u8 val;
 
-       if (!pdev)
-               return -ENODEV;
-
        if (!of_device_is_compatible(np, mediatek_gsw_match->compatible))
                return -EINVAL;
 
+       pdev = of_find_device_by_node(np);
+       if (!pdev)
+               return -ENODEV;
+
        gsw = platform_get_drvdata(pdev);
        priv->soc->swpriv = gsw;
 
@@ -249,12 +250,14 @@ int mtk_gsw_init(struct fe_priv *priv)
                ret = devm_request_irq(&pdev->dev, gsw->irq, gsw_interrupt_mt7620, 0,
                                  "gsw", priv);
                if (ret) {
+                       put_device(&pdev->dev);
                        dev_err(&pdev->dev, "Failed to request irq");
                        return ret;
                }
                mtk_switch_w32(gsw, ~PORT_IRQ_ST_CHG, GSW_REG_IMR);
        }
 
+       put_device(&pdev->dev);
        return 0;
 }
 
index 7e896644f8a332c2573d5b7732dbbb6d6588de74..1774de4b0fc18d0c5983b1e2e25c7f10a4130f13 100644 (file)
@@ -268,6 +268,6 @@ void fe_mdio_cleanup(struct fe_priv *priv)
                return;
 
        mdiobus_unregister(priv->mii_bus);
-       of_node_put(priv->mii_bus->dev.of_node);
+       put_device(&priv->mii_bus->dev);
        kfree(priv->mii_bus);
 }
index 8e1e6f5560899e67138cd80cb89065a5bb093e36..8ed4d0e8a4aa9e386d42ea75478e6dc1241c6913 100644 (file)
@@ -1555,10 +1555,8 @@ static int fe_probe(struct platform_device *pdev)
        netdev->base_addr = (unsigned long)fe_base;
 
        netdev->irq = platform_get_irq(pdev, 0);
-       if (netdev->irq < 0) {
-               dev_err(&pdev->dev, "no IRQ resource found\n");
+       if (netdev->irq < 0)
                return -ENXIO;
-       }
 
        priv = netdev_priv(netdev);
        spin_lock_init(&priv->page_lock);
index 290de5ae6ea165ee26753cf9070607416e35b20c..dc5998843094f818942fe134d7407cfea46ce875 100644 (file)
@@ -492,7 +492,7 @@ static int rtcl_ccu_create(struct device_node *np)
                return -ENXIO;
 
        rtcl_ccu = kzalloc(sizeof(*rtcl_ccu), GFP_KERNEL);
-       if (IS_ERR(rtcl_ccu))
+       if (!rtcl_ccu)
                return -ENOMEM;
 
        rtcl_ccu->np = np;
@@ -657,6 +657,7 @@ static int rtcl_init_sram(void)
        rtcl_ccu->sram.pmark = (int *)((void *)sram_pbase + (dram_size - 4));
        rtcl_ccu->sram.vbase = sram_vbase;
 
+       put_device(&pdev->dev);
        return 0;
 
 err_put_device:
index 66889b3214b28527bdd81c9870efdc17cb171e7b..6115c48f301cbc48418b4327f4d0756c8137fd82 100644 (file)
@@ -356,6 +356,7 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
                        sprintf(led_set_str, "led_set%d", led_set);
                        priv->ports[pn].leds_on_this_port = of_property_count_u32_elems(led_node, led_set_str);
                        if (priv->ports[pn].leds_on_this_port > 4) {
+                               of_node_put(dn);
                                dev_err(priv->dev, "led_set %d for port %d configuration is invalid\n", led_set, pn);
                                return -ENODEV;
                        }
index 550a129105d86f3b2533be8066f053a17b464068..59ae4fbb2403e7d80e6feebf02be8da4c49e863b 100644 (file)
@@ -1753,10 +1753,8 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev)
 
        /* Obtain device IRQ number */
        dev->irq = platform_get_irq(pdev, 0);
-       if (dev->irq < 0) {
-               dev_err(&pdev->dev, "cannot obtain network-device IRQ\n");
-               return err;
-       }
+       if (dev->irq < 0)
+               return -ENODEV;
 
        err = devm_request_irq(&pdev->dev, dev->irq, priv->r->net_irq,
                               IRQF_SHARED, dev->name, dev);