[PATCH] staging: ccree: Convert to platform_{get,set}_drvdata()
From: Suniel Mahesh Platform devices are expected to use wrapper functions, platform_{get,set}_drvdata() with platform_device as argument, for getting and setting the driver data. dev_{get,set}_drvdata() are using &plat_dev->dev. For wrapper functions we can directly pass a struct platform_device. dev_set_drvdata() is redundant and therefore removed. The driver core clears the driver data to NULL after device_release or on probe failure. Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on next-20170921. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 6d16220..53b4a8c 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -236,7 +236,7 @@ static int init_cc_resources(struct platform_device *plat_dev) rc = -ENOMEM; goto post_drvdata_err; } - dev_set_drvdata(&plat_dev->dev, new_drvdata); + platform_set_drvdata(plat_dev, new_drvdata); new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); @@ -415,7 +415,6 @@ static int init_cc_resources(struct platform_device *plat_dev) cc_clk_off(new_drvdata); post_drvdata_err: SSI_LOG_ERR("ccree init error occurred!\n"); - dev_set_drvdata(&plat_dev->dev, NULL); return rc; } @@ -429,7 +428,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata) static void cleanup_cc_resources(struct platform_device *plat_dev) { struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev); + (struct ssi_drvdata *)platform_get_drvdata(plat_dev); ssi_aead_free(drvdata); ssi_hash_free(drvdata); @@ -445,7 +444,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #endif fini_cc_regs(drvdata); cc_clk_off(drvdata); - dev_set_drvdata(&plat_dev->dev, NULL); } int cc_clk_on(struct ssi_drvdata *drvdata) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: ccree: Convert to platform_{get,set}_drvdata()
From: Suniel Mahesh Platform devices are expected to use wrapper functions, platform_{get,set}_drvdata() with platform_device as argument, for getting and setting the driver data. dev_{get,set}_drvdata() are using &plat_dev->dev. For wrapper functions we can directly pass a struct platform_device. dev_set_drvdata() is redundant and therefore removed. The driver core clears the driver data to NULL after device_release or on probe failure. Signed-off-by: Suniel Mahesh --- Changes for v2: - Rebased on top of staging-testing. --- Note: - Patch was tested and built(ARCH=arm) on next-20170921. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 6d16220..53b4a8c 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -236,7 +236,7 @@ static int init_cc_resources(struct platform_device *plat_dev) rc = -ENOMEM; goto post_drvdata_err; } - dev_set_drvdata(&plat_dev->dev, new_drvdata); + platform_set_drvdata(plat_dev, new_drvdata); new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); @@ -415,7 +415,6 @@ static int init_cc_resources(struct platform_device *plat_dev) cc_clk_off(new_drvdata); post_drvdata_err: SSI_LOG_ERR("ccree init error occurred!\n"); - dev_set_drvdata(&plat_dev->dev, NULL); return rc; } @@ -429,7 +428,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata) static void cleanup_cc_resources(struct platform_device *plat_dev) { struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev); + (struct ssi_drvdata *)platform_get_drvdata(plat_dev); ssi_aead_free(drvdata); ssi_hash_free(drvdata); @@ -445,7 +444,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #endif fini_cc_regs(drvdata); cc_clk_off(drvdata); - dev_set_drvdata(&plat_dev->dev, NULL); } int cc_clk_on(struct ssi_drvdata *drvdata) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: ccree: else is not generally useful after a break or return
From: Suniel Mahesh Fixes checkpatch warnings: WARNING: else is not generally useful after a break or return Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on next-20170921. No build issues reported. --- drivers/staging/ccree/ssi_request_mgr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index daa5432..25eecbb 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -387,10 +387,9 @@ int send_request( */ wait_for_completion(&ssi_req->seq_compl); return 0; - } else { - /* Operation still in process */ - return -EINPROGRESS; } + /* Operation still in process */ + return -EINPROGRESS; } /*! -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3] staging: ccree: Convert to platform_{get,set}_drvdata()
From: Suniel Mahesh Platform devices are expected to use wrapper functions, platform_{get,set}_drvdata() with platform_device as argument, for getting and setting the driver data. dev_{get,set}_drvdata() are using &plat_dev->dev. For wrapper functions we can directly pass a struct platform_device. dev_set_drvdata() is redundant and therefore removed. The driver core clears the driver data to NULL after device_release or on probe failure. Signed-off-by: Suniel Mahesh --- Changes for v3: - Rebased on top of staging-testing as suggested by Greg KH. - Patch was tested and built(ARCH=arm) on staging-testing. --- Changes for v2: - Rebased on top of staging-testing. --- Note: - No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 795a087..5f03c25 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -215,7 +215,7 @@ static int init_cc_resources(struct platform_device *plat_dev) rc = -ENOMEM; goto post_drvdata_err; } - dev_set_drvdata(dev, new_drvdata); + platform_set_drvdata(plat_dev, new_drvdata); new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); @@ -393,7 +393,6 @@ static int init_cc_resources(struct platform_device *plat_dev) cc_clk_off(new_drvdata); post_drvdata_err: dev_err(dev, "ccree init error occurred!\n"); - dev_set_drvdata(dev, NULL); return rc; } @@ -407,7 +406,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata) static void cleanup_cc_resources(struct platform_device *plat_dev) { struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev); + (struct ssi_drvdata *)platform_get_drvdata(plat_dev); ssi_aead_free(drvdata); ssi_hash_free(drvdata); @@ -423,7 +422,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #endif fini_cc_regs(drvdata); cc_clk_off(drvdata); - dev_set_drvdata(&plat_dev->dev, NULL); } int cc_clk_on(struct ssi_drvdata *drvdata) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: ccree: local variable "dev" not required
From: Suniel Mahesh There is no need to create a local pointer variable "dev" and pass it various API's, instead use plat_dev which is enumerated by platform core on successful probe. Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on staging-testing. - No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 63 +++--- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 5f03c25..eb907ce 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -205,12 +205,11 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; struct ssi_drvdata *new_drvdata; - struct device *dev = &plat_dev->dev; - struct device_node *np = dev->of_node; + struct device_node *np = plat_dev->dev.of_node; u32 signature_val; int rc = 0; - new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL); + new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(*new_drvdata), GFP_KERNEL); if (!new_drvdata) { rc = -ENOMEM; goto post_drvdata_err; @@ -225,16 +224,16 @@ static int init_cc_resources(struct platform_device *plat_dev) /* First CC registers space */ req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); /* Map registers space */ - new_drvdata->cc_base = devm_ioremap_resource(dev, req_mem_cc_regs); + new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, req_mem_cc_regs); if (IS_ERR(new_drvdata->cc_base)) { - dev_err(dev, "Failed to ioremap registers"); + dev_err(&plat_dev->dev, "Failed to ioremap registers"); rc = PTR_ERR(new_drvdata->cc_base); goto post_drvdata_err; } - dev_dbg(dev, "Got MEM resource (%s): %pR\n", req_mem_cc_regs->name, + dev_dbg(&plat_dev->dev, "Got MEM resource (%s): %pR\n", req_mem_cc_regs->name, req_mem_cc_regs); - dev_dbg(dev, "CC registers mapped from %pa to 0x%p\n", + dev_dbg(&plat_dev->dev, "CC registers mapped from %pa to 0x%p\n", &req_mem_cc_regs->start, new_drvdata->cc_base); cc_base = new_drvdata->cc_base; @@ -242,120 +241,120 @@ static int init_cc_resources(struct platform_device *plat_dev) /* Then IRQ */ new_drvdata->irq = platform_get_irq(plat_dev, 0); if (new_drvdata->irq < 0) { - dev_err(dev, "Failed getting IRQ resource\n"); + dev_err(&plat_dev->dev, "Failed getting IRQ resource\n"); rc = new_drvdata->irq; goto post_drvdata_err; } - rc = devm_request_irq(dev, new_drvdata->irq, cc_isr, + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, IRQF_SHARED, "arm_cc7x", new_drvdata); if (rc) { - dev_err(dev, "Could not register to interrupt %d\n", + dev_err(&plat_dev->dev, "Could not register to interrupt %d\n", new_drvdata->irq); goto post_drvdata_err; } - dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq); + dev_dbg(&plat_dev->dev, "Registered to IRQ: %d\n", new_drvdata->irq); rc = cc_clk_on(new_drvdata); if (rc) goto post_drvdata_err; - if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; + if (!plat_dev->dev.dma_mask) + plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask; - if (!dev->coherent_dma_mask) - dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); + if (!plat_dev->dev.coherent_dma_mask) + plat_dev->dev.coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); /* Verify correct mapping */ signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); if (signature_val != DX_DEV_SIGNATURE) { - dev_err(dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", + dev_err(&plat_dev->dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", signature_val, (u32)DX_DEV_SIGNATURE); rc = -EINVAL; goto post_clk_err; } - dev_dbg(dev, "CC SIGNATURE=0x%08X\n", signature_val); + dev_dbg(&plat_dev->dev, "CC SIGNATURE=0x%08X\n", signature_val); /* Display HW versions */ - dev_info(dev, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n", + dev_info(&plat_dev->dev, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n", SSI_DEV_NAME_STR, CC_HAL_READ_REGI
[PATCH] staging: ccree: Fix bool comparison
From: Suniel Mahesh Bool tests don't need comparisons. This fixes the following coccinelle warning: WARNING: Comparison of bool to 0/1 Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on latest linux-next. - No build issues reported, however it was not tested on real hardware. - Please discard this changeset, if this is not helping the code look better. --- drivers/staging/ccree/ssi_request_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 2e0df57..942afe2 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -272,7 +272,7 @@ int send_request( unsigned int max_required_seq_len = (total_seq_len + ((ssi_req->ivgen_dma_addr_len == 0) ? 0 : SSI_IVPOOL_SEQ_LEN) + - ((is_dout == 0) ? 1 : 0)); + (!is_dout ? 1 : 0)); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) rc = ssi_power_mgr_runtime_get(dev); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: ccree: fix boolreturn.cocci warning
From: Suniel Mahesh This fixes the following coccinelle warning: WARNING: return of 0/1 in function 'ssi_is_hw_key' with return type bool. Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on latest linux-next. - No build issues reported, however it was not tested on real hardware. - Please discard this changeset, if this is not helping the code look better. --- drivers/staging/ccree/ssi_cipher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h index c9a83df..f499962 100644 --- a/drivers/staging/ccree/ssi_cipher.h +++ b/drivers/staging/ccree/ssi_cipher.h @@ -75,7 +75,7 @@ struct arm_hw_key_info { static inline bool ssi_is_hw_key(struct crypto_tfm *tfm) { - return 0; + return false; } #endif /* CRYPTO_TFM_REQ_HW_KEY */ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: ccree: Fix bool comparison
From: Suniel Mahesh Comparision operator "equal to" not required on a variable "foo" of type "bool". Bool has only two values, can be used directly or with logical not. This fixes the following coccinelle warning: WARNING: Comparison of bool to 0/1 Signed-off-by: Suniel Mahesh --- Changes for v2: - Changed the commit log to give a more accurate description of the changeset as suggested by Toby C.Harding --- Note: - Patch was built(ARCH=arm) on latest linux-next. - No build issues reported, however it was not tested on real hardware. - Please discard this changeset, if this is not helping the code look better. --- drivers/staging/ccree/ssi_request_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 2e0df57..942afe2 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -272,7 +272,7 @@ int send_request( unsigned int max_required_seq_len = (total_seq_len + ((ssi_req->ivgen_dma_addr_len == 0) ? 0 : SSI_IVPOOL_SEQ_LEN) + - ((is_dout == 0) ? 1 : 0)); + (!is_dout ? 1 : 0)); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) rc = ssi_power_mgr_runtime_get(dev); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: ccree: fix boolreturn.cocci warning
From: Suniel Mahesh Return "false" instead of 0. This fixes the following coccinelle warning: WARNING: return of 0/1 in function 'ssi_is_hw_key' with return type bool. Signed-off-by: Suniel Mahesh --- Changes for v2: - Changed the commit log to give a more accurate description of the changeset as suggested by Toby C.Harding. --- Note: - Patch was built(ARCH=arm) on latest linux-next. - No build issues reported, however it was not tested on real hardware. - Please discard this changeset, if this is not helping the code look better. --- drivers/staging/ccree/ssi_cipher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h index c9a83df..f499962 100644 --- a/drivers/staging/ccree/ssi_cipher.h +++ b/drivers/staging/ccree/ssi_cipher.h @@ -75,7 +75,7 @@ struct arm_hw_key_info { static inline bool ssi_is_hw_key(struct crypto_tfm *tfm) { - return 0; + return false; } #endif /* CRYPTO_TFM_REQ_HW_KEY */ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3] staging: ccree: fix boolreturn.cocci warning
From: Suniel Mahesh This fixes the following coccinelle warning: WARNING: return of 0/1 in function 'ssi_is_hw_key' with return type bool. return "false" instead of 0. Signed-off-by: Suniel Mahesh --- Changes for v3: - Changed the commit log even more to give an accurate description of the changeset as suggested by Toby C.Harding. --- Changes for v2: - Changed the commit log to give a more accurate description of the changeset as suggested by Toby C.Harding. --- Note: - Patch was built(ARCH=arm) on latest linux-next. - No build issues reported, however it was not tested on real hardware. - Please discard this changeset, if this is not helping the code look better. --- drivers/staging/ccree/ssi_cipher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h index c9a83df..f499962 100644 --- a/drivers/staging/ccree/ssi_cipher.h +++ b/drivers/staging/ccree/ssi_cipher.h @@ -75,7 +75,7 @@ struct arm_hw_key_info { static inline bool ssi_is_hw_key(struct crypto_tfm *tfm) { - return 0; + return false; } #endif /* CRYPTO_TFM_REQ_HW_KEY */ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 0/5] staging: rtl8192e: Fix coding style, warnings and checks
From: Suniel Mahesh Fixed coding style issues and improved error handling, return -ENOMEM, if it is out of memory instead of err message. Pointer comparisions with NUll are replaced by logical NOT. Fixed unbalanced braces around else statement and preferred to pass a pointer as an argument to sizeof() instead of struct definition. Rebased on top of next-20170306. Suniel Mahesh (5): staging: rtl8192e: Fix coding style issues staging: rtl8192e: Improve error handling staging: rtl8192e: Rectify pointer comparisions staging: rtl8192e: Fix unbalanced braces around else statement staging: rtl8192e: Pass a pointer as an argument to sizeof() instead of struct drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 274 +++ 1 file changed, 112 insertions(+), 162 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 4/5] staging: rtl8192e: Fix unbalanced braces around else statement
From: Suniel Mahesh Fix unbalanced braces around else statement reported by checkpatch.pl Signed-off-by: Suniel Mahesh --- Changes for v2: - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 028755b..fb711d2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2257,17 +2257,20 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) { if (ipw->u.crypt.set_tx) { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) { ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + } else if (strcmp(ipw->u.crypt.alg, + "TKIP") == 0) { ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) + } else if (strcmp(ipw->u.crypt.alg, + "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) { ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) + } else if (ipw->u.crypt.key_len == 5) { ieee->pairwise_key_type = KEY_TYPE_WEP40; + } } else { ieee->pairwise_key_type = KEY_TYPE_NA; } @@ -2322,9 +2325,9 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) else if (ipw->u.crypt.key_len == 5) ieee->group_key_type = KEY_TYPE_WEP40; - } else + } else { ieee->group_key_type = KEY_TYPE_NA; - + } if (ieee->group_key_type) { rtl92e_set_swcam(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 5/5] staging: rtl8192e: Pass a pointer as an argument to sizeof() instead of struct
From: Suniel Mahesh Prefer vzalloc(sizeof(*priv->pFirmware)...) over vzalloc(sizeof(struct rt_firmware)...) as reported by checkpatch.pl Signed-off-by: Suniel Mahesh --- Changes for v2: - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index fb711d2..a099bce 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -965,7 +965,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->card_type = PCI; - priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); + priv->pFirmware = vzalloc(sizeof(*priv->pFirmware)); if (!priv->pFirmware) return -ENOMEM; skb_queue_head_init(&priv->skb_queue); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/5] staging: rtl8192e: Fix coding style issues
From: Suniel Mahesh Fix coding style issues and comments in rtl_core.c Signed-off-by: Suniel Mahesh --- Changes for v2: - Split larger patch into multiple commits as suggested by Dan Carpenter - This patch fixes coding style issues, comments in rtl_core.c reported by checkpatch.pl - Modified short description to 'Fix coding style issues' from 'Fix coding style issues, improve error handling' - Improve error handling is taken care by the following patch in the series - Removed statements, 'Return -ENOMEM, if it is out of memory', 'Pointer comparison with NULL replaced by logical NOT' from the body of the patch - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 248 +++ 1 file changed, 98 insertions(+), 150 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 4c0caa6..349c49b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1,4 +1,4 @@ -/** +/ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: @@ -17,7 +17,7 @@ * * Contact Information: * wlanfae -**/ + */ #include #include #include @@ -37,7 +37,6 @@ static int channels = 0x3fff; static char *ifname = "wlan%d"; - static const struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size= rtl92e_get_eeprom_size, @@ -100,9 +99,7 @@ static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, static int _rtl92e_down(struct net_device *dev, bool shutdownrf); static void _rtl92e_restart(void *data); -/ - -IO STUFF- -*/ +/* IO STUFF */ u8 rtl92e_readb(struct net_device *dev, int x) { @@ -140,9 +137,7 @@ void rtl92e_writew(struct net_device *dev, int x, u16 y) udelay(20); } -/ - -GENERAL FUNCTION- -*/ +/* GENERAL FUNCTION */ bool rtl92e_set_rf_state(struct net_device *dev, enum rt_rf_power_state StateToSet, RT_RF_CHANGE_SOURCE ChangeSource) @@ -200,7 +195,6 @@ bool rtl92e_set_rf_state(struct net_device *dev, priv->rtllib->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; @@ -223,7 +217,8 @@ bool rtl92e_set_rf_state(struct net_device *dev, else priv->blinked_ingpio = false; rtllib_MgntDisconnect(priv->rtllib, - WLAN_REASON_DISASSOC_STA_HAS_LEFT); + WLAN_REASON_DISASSOC_STA_ + HAS_LEFT); } } if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff) @@ -247,7 +242,6 @@ bool rtl92e_set_rf_state(struct net_device *dev, StateToSet, priv->rtllib->RfOffReason); PHY_SetRFPowerState(dev, StateToSet); if (StateToSet == eRfOn) { - if (bConnectBySSID && priv->blinked_ingpio) { schedule_delayed_work( &ieee->associate_procedure_wq, 0); @@ -346,16 +340,16 @@ static void _rtl92e_update_cap(struct net_device *dev, u16 cap) } } - if (net->mode & (IEEE_G|IEEE_N_24G)) { + if (net->mode & (IEEE_G | IEEE_N_24G)) { u8 slot_time_val; u8 CurSlotTime = priv->slot_time; if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && - (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) { + (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) { if (CurSlotTime != SHORT_SLOT_TIME) { slot_time_val = SHORT_SLOT_TIME; priv->rtllib->SetHwRegHandler(dev, -
[PATCH v2 3/5] staging: rtl8192e: Rectify pointer comparisions
From: Suniel Mahesh Pointer comparison with NULL replaced by logical NOT Signed-off-by: Suniel Mahesh --- Changes for v2: - Rectify pointer comparisions reported by checkpatch.pl in rtl_core.c - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 2e6b03f..028755b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -469,7 +469,7 @@ static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv, u32 size = sizeof(struct rtllib_qos_parameters); int set_qos_param = 0; - if ((priv == NULL) || (network == NULL)) + if (!priv || !network) return 0; if (priv->rtllib->state != RTLLIB_LINKED) @@ -782,7 +782,7 @@ static int _rtl92e_sta_down(struct net_device *dev, bool shutdownrf) if (priv->up == 0) return -1; - if (priv->rtllib->rtllib_ips_leave != NULL) + if (priv->rtllib->rtllib_ips_leave) priv->rtllib->rtllib_ips_leave(dev); if (priv->rtllib->state == RTLLIB_LINKED) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/5] staging: rtl8192e: Improve error handling
From: Suniel Mahesh Return -ENOMEM, if it is out of memory Signed-off-by: Suniel Mahesh --- Changes for v2: - Improve error handling reported by checkpatch.pl in rtl_core.c - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 349c49b..2e6b03f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -967,8 +967,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); if (!priv->pFirmware) - netdev_err(dev, - "rtl8192e: Unable to allocate space for firmware\n"); + return -ENOMEM; skb_queue_head_init(&priv->skb_queue); for (i = 0; i < MAX_QUEUE_SIZE; i++) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 0/8] staging: rtl8192e: Fix coding style, warnings and checks
From: Suniel Mahesh Split earlier patches into multiple commits for easy review as suggested by Dan Carpenter. Modified subject, description and in few patches both for better readability as suggested by Greg KH. Fixed the following issues reported by checkpatch.pl: Block comments should align the * on each line, aligned. Block comments use * on subsequent lines, other characters are replaced by * . line over 80 characters, modified as per coding style. Removed unnecessary 'out of memory' message. Comparison's to NULL could be written '!foo' or 'foo', modified. Fixed unbalanced braces around else statement. Added braces on all arms of the if-else statements to comply with kernel coding style. Replaced sizeof(struct foo) into sizeof(*ptr). Spaces preferred around that 'operator', spacing provided. Logical continuations should be on the previous line, modified accordingly. Unnecessary parentheses around variables, removed. Please use a blank line after function/struct/union/enum declarations, used. Blank lines aren't necessary after an open brace '{' and before a close brace '}', removed. No space is necessary after a cast, removed. Please don't use multiple blank lines, removed. Rebased on top of next-20170310. Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported. Suniel Mahesh (8): staging: rtl8192e: Fix comments as per kernel coding style staging: rtl8192e: Fix coding style staging: rtl8192e: Remove unnecessary 'out of memory' message staging: rtl8192e: Rectify pointer comparisions with NULL staging: rtl8192e: Fix unbalanced braces staging: rtl8192e: Pass a pointer as an argument to sizeof() instead of struct staging: rtl8192e: Fix issues reported by checkpatch.pl staging: rtl8192e: Fix blank lines and space after a cast drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 201 +++ 1 file changed, 84 insertions(+), 117 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/8] staging: rtl8192e: Fix comments as per kernel coding style
From: Suniel Mahesh Fixed the following checkpatch.pl warnings: Block comments should align the * on each line Block comments use * on subsequent lines Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified subject and description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - Split larger patch into multiple commits as suggested by Dan Carpenter - This patch fixes coding style issues, comments in rtl_core.c reported by checkpatch.pl - Modified short description to 'Fix coding style issues' from 'Fix coding style issues, improve error handling' - Improve error handling is taken care by the following patch in the series - Removed statements, 'Return -ENOMEM, if it is out of memory', 'Pointer comparison with NULL replaced by logical NOT' from the body of the patch - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 61 ++-- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 4c0caa6..a648064 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1,4 +1,4 @@ -/** +/* * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: @@ -17,7 +17,7 @@ * * Contact Information: * wlanfae -**/ + */ #include #include #include @@ -75,12 +75,12 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, static irqreturn_t _rtl92e_irq(int irq, void *netdev); static struct pci_driver rtl8192_pci_driver = { - .name = DRV_NAME, /* Driver name */ - .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ - .probe = _rtl92e_pci_probe,/* probe fn */ - .remove = _rtl92e_pci_disconnect, /* remove fn */ - .suspend = rtl92e_suspend, /* PM suspend fn */ - .resume = rtl92e_resume, /* PM resume fn */ + .name = DRV_NAME, + .id_table = rtl8192_pci_id_tbl, + .probe = _rtl92e_pci_probe, + .remove = _rtl92e_pci_disconnect, + .suspend = rtl92e_suspend, + .resume = rtl92e_resume, }; static short _rtl92e_is_tx_queue_empty(struct net_device *dev); @@ -100,10 +100,7 @@ static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, static int _rtl92e_down(struct net_device *dev, bool shutdownrf); static void _rtl92e_restart(void *data); -/ - -IO STUFF- -*/ - +/* IO STUFF */ u8 rtl92e_readb(struct net_device *dev, int x) { return 0xff & readb((u8 __iomem *)dev->mem_start + x); @@ -140,9 +137,7 @@ void rtl92e_writew(struct net_device *dev, int x, u16 y) udelay(20); } -/ - -GENERAL FUNCTION- -*/ +/* GENERAL FUNCTION */ bool rtl92e_set_rf_state(struct net_device *dev, enum rt_rf_power_state StateToSet, RT_RF_CHANGE_SOURCE ChangeSource) @@ -978,7 +973,6 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) if (!priv->pFirmware) netdev_err(dev, "rtl8192e: Unable to allocate space for firmware\n"); - skb_queue_head_init(&priv->skb_queue); for (i = 0; i < MAX_QUEUE_SIZE; i++) @@ -1101,9 +1095,7 @@ static short _rtl92e_init(struct net_device *dev) return 0; } -/*** - ---WATCHDOG STUFF--- -***/ +/* WATCHDOG STUFF */ static short _rtl92e_is_tx_queue_empty(struct net_device *dev) { int i = 0; @@ -1540,9 +1532,7 @@ static void _rtl92e_watchdog_timer_cb(unsigned long data) msecs_to_jiffies(RTLLIB_WATCH_DOG_TIME)); } -/ - NIC TX/RX STUFF--- -*/ +/* NIC TX/RX STUFF */ void rtl92e_rx_enable(struct net_device *dev) { struct r8192_pr
[PATCH v3 3/8] staging: rtl8192e: Remove unnecessary 'out of memory' message
From: Suniel Mahesh Fixed the following checkpatch.pl warning: Possible unnecessary 'out of memory' message Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified subject and description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - Improve error handling reported by checkpatch.pl in rtl_core.c - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index eb2321c..37a03ca 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -971,8 +971,8 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); if (!priv->pFirmware) - netdev_err(dev, - "rtl8192e: Unable to allocate space for firmware\n"); + return; + skb_queue_head_init(&priv->skb_queue); for (i = 0; i < MAX_QUEUE_SIZE; i++) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 5/8] staging: rtl8192e: Fix unbalanced braces
From: Suniel Mahesh Fixed unbalanced braces around else statement Add braces on all arms of the if-else statements to comply with kernel coding style. Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified subject and description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 30 +--- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 0fa4017..c355ee7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2294,17 +2294,20 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) { if (ipw->u.crypt.set_tx) { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) { ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + } else if (strcmp(ipw->u.crypt.alg, + "TKIP") == 0) { ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) + } else if (strcmp(ipw->u.crypt.alg, + "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) { ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) + } else if (ipw->u.crypt.key_len == 5) { ieee->pairwise_key_type = KEY_TYPE_WEP40; + } } else { ieee->pairwise_key_type = KEY_TYPE_NA; } @@ -2346,20 +2349,23 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } else { memcpy((u8 *)key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) { ieee->group_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + } else if (strcmp(ipw->u.crypt.alg, + "TKIP") == 0) { ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (ipw->u.crypt.key_len == 13) + } else if (strcmp(ipw->u.crypt.alg, + "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) { ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) + } else if (ipw->u.crypt.key_len == 5) { ieee->group_key_type = KEY_TYPE_WEP40; - } else + } + } else { ieee->group_key_type = KEY_TYPE_NA; - + } if (ieee->group_key_type) { rtl92e_set_swcam(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 7/8] staging: rtl8192e: Fix issues reported by checkpatch.pl
From: Suniel Mahesh Fixed the following checkpatch.pl checks: spaces preferred around that 'operator', spacing provided Logical continuations should be on the previous line, modified accordingly Unnecessary parentheses around variables, removed Please use a blank line after function/struct/union/enum declarations, used Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - New patch addition to the series - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 46 +++- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 184d6ec..bb156e3 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -341,7 +341,7 @@ static void _rtl92e_update_cap(struct net_device *dev, u16 cap) } } - if (net->mode & (IEEE_G|IEEE_N_24G)) { + if (net->mode & (IEEE_G | IEEE_N_24G)) { u8 slot_time_val; u8 CurSlotTime = priv->slot_time; @@ -675,7 +675,7 @@ static u8 _rtl92e_get_supported_wireless_mode(struct net_device *dev) case RF_8256: case RF_6052: case RF_PSEUDO_11N: - ret = (WIRELESS_MODE_N_24G|WIRELESS_MODE_G | WIRELESS_MODE_B); + ret = (WIRELESS_MODE_N_24G | WIRELESS_MODE_G | WIRELESS_MODE_B); break; case RF_8258: ret = (WIRELESS_MODE_A | WIRELESS_MODE_N_5G); @@ -737,7 +737,7 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) - (&(priv->rtllib->PowerSaveControl)); + (&priv->rtllib->PowerSaveControl); bool init_status = true; priv->bDriverIsGoingToUnload = false; @@ -883,7 +883,7 @@ static void _rtl92e_init_priv_constant(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) - &(priv->rtllib->PowerSaveControl); + &priv->rtllib->PowerSaveControl; pPSC->RegMaxLPSAwakeIntvl = 5; } @@ -1009,9 +1009,9 @@ static void _rtl92e_init_priv_task(struct net_device *dev) (void *)_rtl92e_update_beacon, dev); INIT_WORK_RSL(&priv->qos_activate, (void *)_rtl92e_qos_activate, dev); INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq, - (void *) rtl92e_hw_wakeup_wq, dev); + (void *)rtl92e_hw_wakeup_wq, dev); INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq, - (void *) rtl92e_hw_sleep_wq, dev); + (void *)rtl92e_hw_sleep_wq, dev); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long))_rtl92e_irq_rx_tasklet, (unsigned long)priv); @@ -1029,8 +1029,8 @@ static short _rtl92e_get_channel_map(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); - if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) - && (priv->rf_chip != RF_6052)) { + if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) && + (priv->rf_chip != RF_6052)) { netdev_err(dev, "%s: unknown rf chip, can't set channel map\n", __func__); return -1; @@ -1056,7 +1056,7 @@ static short _rtl92e_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - memset(&(priv->stats), 0, sizeof(struct rt_stats)); + memset(&priv->stats, 0, sizeof(struct rt_stats)); _rtl92e_init_priv_handler(dev); _rtl92e_init_priv_constant(dev); @@ -1071,7 +1071,7 @@ static short _rtl92e_init(struct net_device *dev) setup_timer(&priv->watch_dog_timer, _rtl92e_watchdog_timer_cb, - (unsigned long) dev); + (unsigned long)dev); setup_timer(&priv->gpio_polling_timer, rtl92e_check_rfctrl_gpio_timer, @@ -1126,7 +1126,7 @@ static enum reset_type _rtl92e_tx_check_stuck(struct net_device *dev) switch (priv->rtllib->ps) { case RTLLIB_PS_DISABLED: break; - case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): + case (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST): break; default: break; @@ -1379,7 +1379,7 @@
[PATCH v3 4/8] staging: rtl8192e: Rectify pointer comparisions with NULL
From: Suniel Mahesh This patch simplifies code by replacing explicit NULL comparison with ! or unmark operator Reported by checkpatch.pl for comparison to NULL could be written '!foo' or 'foo' Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - Rectify pointer comparisions reported by checkpatch.pl in rtl_core.c - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 37a03ca..0fa4017 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -472,7 +472,7 @@ static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv, u32 size = sizeof(struct rtllib_qos_parameters); int set_qos_param = 0; - if ((priv == NULL) || (network == NULL)) + if (!priv || !network) return 0; if (priv->rtllib->state != RTLLIB_LINKED) @@ -785,7 +785,7 @@ static int _rtl92e_sta_down(struct net_device *dev, bool shutdownrf) if (priv->up == 0) return -1; - if (priv->rtllib->rtllib_ips_leave != NULL) + if (priv->rtllib->rtllib_ips_leave) priv->rtllib->rtllib_ips_leave(dev); if (priv->rtllib->state == RTLLIB_LINKED) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 8/8] staging: rtl8192e: Fix blank lines and space after a cast
From: Suniel Mahesh Fixed the following checkpatch.pl checks: Blank lines aren't necessary after an open brace '{' and before a close brace '}', removed No space is necessary after a cast, removed Please don't use multiple blank lines, removed Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - New patch addition to the series - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 26 -- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index bb156e3..a587069 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -37,7 +37,6 @@ static int channels = 0x3fff; static char *ifname = "wlan%d"; - static const struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size= rtl92e_get_eeprom_size, @@ -195,7 +194,6 @@ bool rtl92e_set_rf_state(struct net_device *dev, priv->rtllib->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; @@ -242,7 +240,6 @@ bool rtl92e_set_rf_state(struct net_device *dev, StateToSet, priv->rtllib->RfOffReason); PHY_SetRFPowerState(dev, StateToSet); if (StateToSet == eRfOn) { - if (bConnectBySSID && priv->blinked_ingpio) { schedule_delayed_work( &ieee->associate_procedure_wq, 0); @@ -401,8 +398,6 @@ static void _rtl92e_qos_activate(void *data) for (i = 0; i < QOS_QUEUE_NUM; i++) priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); - - success: mutex_unlock(&priv->mutex); } @@ -462,7 +457,6 @@ static int _rtl92e_handle_beacon(struct net_device *dev, schedule_delayed_work(&priv->update_beacon_wq, 0); return 0; - } static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv, @@ -888,7 +882,6 @@ static void _rtl92e_init_priv_constant(struct net_device *dev) pPSC->RegMaxLPSAwakeIntvl = 5; } - static void _rtl92e_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1211,7 +1204,6 @@ static enum reset_type _rtl92e_if_check_reset(struct net_device *dev) } else { return RESET_TYPE_NORESET; } - } static void _rtl92e_if_silent_reset(struct net_device *dev) @@ -1223,7 +1215,6 @@ static void _rtl92e_if_silent_reset(struct net_device *dev) unsigned long flag; if (priv->ResetProgress == RESET_TYPE_NORESET) { - RT_TRACE(COMP_RESET, "=>Reset progress!!\n"); priv->ResetProgress = RESET_TYPE_SILENT; @@ -1417,7 +1408,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) ieee->LinkDetectInfo.NumTxOkInPeriod > 100) bBusyTraffic = true; - if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) { bHigherBusyTraffic = true; @@ -1466,7 +1456,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) else priv->check_roaming_cnt = 0; - if (priv->check_roaming_cnt > 0) { if (ieee->eRFPowerState == eRfOff) netdev_info(dev, "%s(): RF is off\n", __func__); @@ -1497,7 +1486,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) } ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; - } spin_lock_irqsave(&priv->tx_lock, flags); @@ -1549,7 +1537,6 @@ void rtl92e_tx_enable(struct net_device *dev) rtllib_reset_queue(priv->rtllib); } - static void _rtl92e_free_rx_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1951,13 +1938,11 @@ long rtl92e_translate_to_dbm(struct r8192_priv *priv, u8 signal_strength_index) return signal_power; } - void rtl92e_update_rx_statistics(struct r8192_priv *priv, struct rtllib_rx_stats *pprevious_stats) { int weighting = 0; - if (priv->stats.recv_signal_power == 0) priv->stats.recv_signal_power = pprevious_stats->RecvSignalPower; @@ -1981,7 +1966,6 @@ u8 rtl92e_rx_db_to_percent(s8 antpower) return 100;
[PATCH v3 2/8] staging: rtl8192e: Fix coding style
From: Suniel Mahesh Fixed the following checkpatch.pl warning: line over 80 characters Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - New patch addition to the series - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 30 +++- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index a648064..eb2321c 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -218,7 +218,7 @@ bool rtl92e_set_rf_state(struct net_device *dev, else priv->blinked_ingpio = false; rtllib_MgntDisconnect(priv->rtllib, - WLAN_REASON_DISASSOC_STA_HAS_LEFT); + WLAN_REASON_DISASSOC_STA_HAS_LEFT); } } if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff) @@ -1796,7 +1796,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev) for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { priv->rx_ring[rx_queue_idx] = pci_zalloc_consistent(priv->pdev, - sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, + sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, &priv->rx_ring_dma[rx_queue_idx]); if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { @@ -2272,7 +2272,8 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) int ret = -1; struct rtllib_device *ieee = priv->rtllib; u32 key[4]; - const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, + 0xff}; struct iw_point *p = &wrq->u.data; struct ieee_param *ipw = NULL; @@ -2309,14 +2310,15 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } if (ieee->pairwise_key_type) { - if (is_zero_ether_addr(ieee->ap_mac_addr)) + if (is_zero_ether_addr( + ieee->ap_mac_addr)) ieee->iw_mode = IW_MODE_ADHOC; memcpy((u8 *)key, ipw->u.crypt.key, 16); rtl92e_enable_hw_security_config(dev); rtl92e_set_swcam(dev, 4, ipw->u.crypt.idx, - ieee->pairwise_key_type, -(u8 *)ieee->ap_mac_addr, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, 0, key, 0); rtl92e_set_key(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, @@ -2324,17 +2326,17 @@ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 0, key); if (ieee->iw_mode == IW_MODE_ADHOC) { rtl92e_set_swcam(dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->pairwise_key_type, -(u8 *)ieee->ap_mac_addr, -0, key, 0); + ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0);
[PATCH v3 6/8] staging: rtl8192e: Pass a pointer as an argument to sizeof() instead of struct
From: Suniel Mahesh Replaced sizeof(struct foo) into sizeof(*ptr), found by checkpatch.pl Signed-off-by: Suniel Mahesh --- Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index c355ee7..184d6ec 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -969,7 +969,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->card_type = PCI; - priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); + priv->pFirmware = vzalloc(sizeof(*priv->pFirmware)); if (!priv->pFirmware) return; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 3/8] staging: rtl8192e: Remove unnecessary 'out of memory' message
From: Suniel Mahesh Fixed the following checkpatch.pl warning: Possible unnecessary 'out of memory' message If it is out of memory, function should return with an appropriate error code. Since this function is of type void, a return statement is used. Signed-off-by: Suniel Mahesh --- Changes for v4: - Modified description for better readability as pointed out by Dan Carpenter Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified subject and description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - Improve error handling reported by checkpatch.pl in rtl_core.c - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index eb2321c..37a03ca 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -971,8 +971,8 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); if (!priv->pFirmware) - netdev_err(dev, - "rtl8192e: Unable to allocate space for firmware\n"); + return; + skb_queue_head_init(&priv->skb_queue); for (i = 0; i < MAX_QUEUE_SIZE; i++) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 0/6] staging: rtl8192e: Fix coding style, warnings and checks
From: Suniel Mahesh Split earlier patches into multiple commits for easy review as suggested by Dan Carpenter. Modified subject, description and in few patches both for better readability as suggested by Greg KH. Dropped two patches from the earler series, as they were not adding significant value, suggested by Dan Carpenter. Fixed the following issues reported by checkpatch.pl: Block comments should align the * on each line, aligned. Block comments use * on subsequent lines, other characters are replaced by * . Removed unnecessary 'out of memory' message. Comparison's to NULL could be written '!foo' or 'foo', modified. Replaced sizeof(struct foo) into sizeof(*ptr). Spaces preferred around that 'operator', spacing provided. Logical continuations should be on the previous line, modified accordingly. Unnecessary parentheses around variables, removed. Please use a blank line after function/struct/union/enum declarations, used. Blank lines aren't necessary after an open brace '{' and before a close brace '}', removed. No space is necessary after a cast, removed. Please don't use multiple blank lines, removed. Rebased on top of next-20170310. Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported. Suniel Mahesh (6): staging: rtl8192e: Fix comments as per kernel coding style staging: rtl8192e: Remove unnecessary 'out of memory' message staging: rtl8192e: Rectify pointer comparisions with NULL staging: rtl8192e: Pass a pointer as an argument to sizeof() instead of struct staging: rtl8192e: Fix issues reported by checkpatch.pl staging: rtl8192e: Fix blank lines and space after a cast drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 141 ++- 1 file changed, 50 insertions(+), 91 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 6/6] staging: rtl8192e: Fix blank lines and space after a cast
From: Suniel Mahesh Fixed the following checkpatch.pl checks: Blank lines aren't necessary after an open brace '{' and before a close brace '}', removed No space is necessary after a cast, removed Please don't use multiple blank lines, removed Signed-off-by: Suniel Mahesh --- Changes for v4: - Dropped two patches from the series, as they were not adding significant value suggested by Dan Carpenter. staging: rtl8192e: Fix coding style, this was fixing line over 80 characters. staging: rtl8192e: Fix unbalanced braces - Resending the whole series as requested by Greg K-H - Patches were tested and built on next-20170310 and staging-testing Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - New patch addition to the series - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 26 -- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 1d22f18..bc2c732 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -37,7 +37,6 @@ static int channels = 0x3fff; static char *ifname = "wlan%d"; - static const struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size= rtl92e_get_eeprom_size, @@ -195,7 +194,6 @@ bool rtl92e_set_rf_state(struct net_device *dev, priv->rtllib->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; @@ -242,7 +240,6 @@ bool rtl92e_set_rf_state(struct net_device *dev, StateToSet, priv->rtllib->RfOffReason); PHY_SetRFPowerState(dev, StateToSet); if (StateToSet == eRfOn) { - if (bConnectBySSID && priv->blinked_ingpio) { schedule_delayed_work( &ieee->associate_procedure_wq, 0); @@ -401,8 +398,6 @@ static void _rtl92e_qos_activate(void *data) for (i = 0; i < QOS_QUEUE_NUM; i++) priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); - - success: mutex_unlock(&priv->mutex); } @@ -462,7 +457,6 @@ static int _rtl92e_handle_beacon(struct net_device *dev, schedule_delayed_work(&priv->update_beacon_wq, 0); return 0; - } static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv, @@ -888,7 +882,6 @@ static void _rtl92e_init_priv_constant(struct net_device *dev) pPSC->RegMaxLPSAwakeIntvl = 5; } - static void _rtl92e_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1211,7 +1204,6 @@ static enum reset_type _rtl92e_if_check_reset(struct net_device *dev) } else { return RESET_TYPE_NORESET; } - } static void _rtl92e_if_silent_reset(struct net_device *dev) @@ -1223,7 +1215,6 @@ static void _rtl92e_if_silent_reset(struct net_device *dev) unsigned long flag; if (priv->ResetProgress == RESET_TYPE_NORESET) { - RT_TRACE(COMP_RESET, "=>Reset progress!!\n"); priv->ResetProgress = RESET_TYPE_SILENT; @@ -1417,7 +1408,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) ieee->LinkDetectInfo.NumTxOkInPeriod > 100) bBusyTraffic = true; - if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) { bHigherBusyTraffic = true; @@ -1466,7 +1456,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) else priv->check_roaming_cnt = 0; - if (priv->check_roaming_cnt > 0) { if (ieee->eRFPowerState == eRfOff) netdev_info(dev, "%s(): RF is off\n", __func__); @@ -1497,7 +1486,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) } ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; - } spin_lock_irqsave(&priv->tx_lock, flags); @@ -1549,7 +1537,6 @@ void rtl92e_tx_enable(struct net_device *dev) rtllib_reset_queue(priv->rtllib); } - static void _rtl92e_free_rx_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1951,13 +1938,11 @@ long rtl92e_translate_to_dbm(struct r8192_priv *priv, u8 signal_strength_index) return signal_power; } - void rtl92e_update_rx_statistics(struct r8192_priv *pri
[PATCH v4 4/6] staging: rtl8192e: Pass a pointer as an argument to sizeof() instead of struct
From: Suniel Mahesh Replaced sizeof(struct foo) into sizeof(*ptr), found by checkpatch.pl Signed-off-by: Suniel Mahesh --- Changes for v4: - Dropped two patches from the series, as they were not adding significant value suggested by Dan Carpenter. staging: rtl8192e: Fix coding style, this was fixing line over 80 characters. staging: rtl8192e: Fix unbalanced braces - Resending the whole series as requested by Greg K-H - Patches were tested and built on next-20170310 and staging-testing Changes for v3: - Split earlier patches into multiple commits for easy review as suggested by Greg K-H - Modified description for better readability - Rebased on top of next-20170310 - Patches were tested and built on next-20170310 and staging-testing as suggested by Greg K-H, no errors reported Changes for v2: - new patch addition to the series - Rebased on top of next-20170306 --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 4f4cd07..999af05 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -969,7 +969,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->card_type = PCI; - priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); + priv->pFirmware = vzalloc(sizeof(*priv->pFirmware)); if (!priv->pFirmware) return; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: wlan-ng: Amend type mismatch warnings
From: Suniel Mahesh The following type mismatch warnings reported by sparse have been amended: warning: cast to restricted __le16 warning: incorrect type in assignment (different base types) Signed-off-by: Suniel Mahesh --- drivers/staging/wlan-ng/prism2mgmt.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index f4d6e48..358b556 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -185,7 +185,7 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void *msgp) /* set up the txrate to be 2MBPS. Should be fastest basicrate... */ word = HFA384x_RATEBIT_2; - scanreq.tx_rate = cpu_to_le16(word); + scanreq.tx_rate = (__force u16)cpu_to_le16(word); /* set up the channel list */ word = 0; @@ -197,10 +197,10 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void *msgp) /* channel 1 is BIT 0 ... channel 14 is BIT 13 */ word |= (1 << (channel - 1)); } - scanreq.channel_list = cpu_to_le16(word); + scanreq.channel_list = (__force u16)cpu_to_le16(word); /* set up the ssid, if present. */ - scanreq.ssid.len = cpu_to_le16(msg->ssid.data.len); + scanreq.ssid.len = (__force u16)cpu_to_le16(msg->ssid.data.len); memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len); /* Enable the MAC port if it's not already enabled */ @@ -229,7 +229,7 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void *msgp) /* Construct a bogus SSID and assign it to OwnSSID and * DesiredSSID */ - wordbuf[0] = cpu_to_le16(WLAN_SSID_MAXLEN); + wordbuf[0] = (__force u16)cpu_to_le16(WLAN_SSID_MAXLEN); get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN); result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID, wordbuf, @@ -405,8 +405,8 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) /* signal and noise */ req->signal.status = P80211ENUM_msgitem_status_data_ok; req->noise.status = P80211ENUM_msgitem_status_data_ok; - req->signal.data = le16_to_cpu(item->sl); - req->noise.data = le16_to_cpu(item->anl); + req->signal.data = le16_to_cpu((__force __le16)item->sl); + req->noise.data = le16_to_cpu((__force __le16)item->anl); /* BSSID */ req->bssid.status = P80211ENUM_msgitem_status_data_ok; @@ -415,7 +415,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) /* SSID */ req->ssid.status = P80211ENUM_msgitem_status_data_ok; - req->ssid.data.len = le16_to_cpu(item->ssid.len); + req->ssid.data.len = le16_to_cpu((__force __le16)item->ssid.len); req->ssid.data.len = min_t(u16, req->ssid.data.len, WLAN_SSID_MAXLEN); memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len); @@ -463,7 +463,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) /* beacon period */ req->beaconperiod.status = P80211ENUM_msgitem_status_data_ok; - req->beaconperiod.data = le16_to_cpu(item->bcnint); + req->beaconperiod.data = le16_to_cpu((__force __le16)item->bcnint); /* timestamps */ req->timestamp.status = P80211ENUM_msgitem_status_data_ok; @@ -473,14 +473,14 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) /* atim window */ req->ibssatimwindow.status = P80211ENUM_msgitem_status_data_ok; - req->ibssatimwindow.data = le16_to_cpu(item->atim); + req->ibssatimwindow.data = le16_to_cpu((__force __le16)item->atim); /* Channel */ req->dschannel.status = P80211ENUM_msgitem_status_data_ok; - req->dschannel.data = le16_to_cpu(item->chid); + req->dschannel.data = le16_to_cpu((__force __le16)item->chid); /* capinfo bits */ - count = le16_to_cpu(item->capinfo); + count = le16_to_cpu((__force __le16)item->capinfo); req->capinfo.status = P80211ENUM_msgitem_status_data_ok; req->capinfo.data = count; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: wlan-ng: Amend type mismatch warnings
From: Suniel Mahesh le16_to_cpu() accepts argument of type __le16 and cpu_to_le16() returns an argument of type __le16. This patch fixes warnings related to incorrect type in assignment and changes the types in the corresponding header file. The following type mismatch warnings reported by sparse have been amended: warning: cast to restricted __le16 warning: incorrect type in assignment (different base types) Signed-off-by: Suniel Mahesh --- Changes for v2: - Reworked on the patch and modified commit message as per the recommendations from Frans Klaver and Greg K-H. - Patch was tested and built on next-20170609 and staging-testing. --- drivers/staging/wlan-ng/hfa384x.h| 18 +- drivers/staging/wlan-ng/prism2mgmt.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 310e2c4..f99cc04 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -358,7 +358,7 @@ struct hfa384x_bytestr { } __packed; struct hfa384x_bytestr32 { - u16 len; + __le16 len; u8 data[32]; } __packed; @@ -399,8 +399,8 @@ struct hfa384x_caplevel { /*-- Configuration Record: HostScanRequest (data portion only) --*/ struct hfa384x_host_scan_request_data { - u16 channel_list; - u16 tx_rate; + __le16 channel_list; + __le16 tx_rate; struct hfa384x_bytestr32 ssid; } __packed; @@ -682,16 +682,16 @@ struct hfa384x_ch_info_result { /*-- Inquiry Frame, Diagnose: Host Scan Results & Subfields--*/ struct hfa384x_hscan_result_sub { - u16 chid; - u16 anl; - u16 sl; + __le16 chid; + __le16 anl; + __le16 sl; u8 bssid[WLAN_BSSID_LEN]; - u16 bcnint; - u16 capinfo; + __le16 bcnint; + __le16 capinfo; struct hfa384x_bytestr32 ssid; u8 supprates[10]; /* 802.11 info element */ u16 proberesp_rate; - u16 atim; + __le16 atim; } __packed; struct hfa384x_hscan_result { diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index f4d6e48..c4aa9e7 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -213,7 +213,7 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void *msgp) goto exit; } if (word == HFA384x_PORTSTATUS_DISABLED) { - u16 wordbuf[17]; + __le16 wordbuf[17]; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3] staging: wlan-ng: Fix struct definition's and variable type
From: Suniel Mahesh le16_to_cpu() accepts argument of type __le16 and cpu_to_le16() returns an argument of type __le16. This patch fixes: (a) the type of the variable that end's up getting return from cpu_to_le16(). (b) the member types of struct hfa384x_host_scan_request_data, struct hfa384x_bytestr32 and struct hfa384x_hscan_result_sub. The following type mismatch warnings reported by sparse have been fixed: warning: incorrect type in assignment (different base types) warning: cast to restricted __le16 Signed-off-by: Suniel Mahesh --- Changes for v3: - Edited subject and description of the patch to fit with the changes done in the code base, as suggested by Frans Klaver. Changes for v2: - Reworked on the patch and modified commit message as per the recommendations from Frans Klaver and Greg K-H. - Patch was tested and built on next-20170609 and staging-testing. --- drivers/staging/wlan-ng/hfa384x.h| 18 +- drivers/staging/wlan-ng/prism2mgmt.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 310e2c4..f99cc04 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -358,7 +358,7 @@ struct hfa384x_bytestr { } __packed; struct hfa384x_bytestr32 { - u16 len; + __le16 len; u8 data[32]; } __packed; @@ -399,8 +399,8 @@ struct hfa384x_caplevel { /*-- Configuration Record: HostScanRequest (data portion only) --*/ struct hfa384x_host_scan_request_data { - u16 channel_list; - u16 tx_rate; + __le16 channel_list; + __le16 tx_rate; struct hfa384x_bytestr32 ssid; } __packed; @@ -682,16 +682,16 @@ struct hfa384x_ch_info_result { /*-- Inquiry Frame, Diagnose: Host Scan Results & Subfields--*/ struct hfa384x_hscan_result_sub { - u16 chid; - u16 anl; - u16 sl; + __le16 chid; + __le16 anl; + __le16 sl; u8 bssid[WLAN_BSSID_LEN]; - u16 bcnint; - u16 capinfo; + __le16 bcnint; + __le16 capinfo; struct hfa384x_bytestr32 ssid; u8 supprates[10]; /* 802.11 info element */ u16 proberesp_rate; - u16 atim; + __le16 atim; } __packed; struct hfa384x_hscan_result { diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index f4d6e48..c4aa9e7 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -213,7 +213,7 @@ int prism2mgmt_scan(struct wlandevice *wlandev, void *msgp) goto exit; } if (word == HFA384x_PORTSTATUS_DISABLED) { - u16 wordbuf[17]; + __le16 wordbuf[17]; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/3] staging: ccree: Replace kzalloc with devm_kzalloc
From: Suniel Mahesh It is recommended to use managed function devm_kzalloc, which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace kzalloc with devm_kzalloc. (b) drop kfree(), because memory allocated with devm_kzalloc() is automatically freed on driver detach, otherwise it leads to a double free. (c) remove unnecessary blank lines. Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on next-20170714. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 78709b92..f231ecf 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -224,13 +224,15 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), GFP_KERNEL); + struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; int rc = 0; - if (unlikely(!new_drvdata)) { + new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(struct ssi_drvdata), + GFP_KERNEL); + if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; goto init_cc_res_err; @@ -431,10 +433,8 @@ static int init_cc_resources(struct platform_device *plat_dev) resource_size(new_drvdata->res_mem)); new_drvdata->res_mem = NULL; } - kfree(new_drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } - return rc; } @@ -475,8 +475,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) drvdata->cc_base = NULL; drvdata->res_mem = NULL; } - - kfree(drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/3] staging: ccree: Employ devm_* functions, remove redundant code
From: Suniel Mahesh Hi This patch series replaces the current API's which request for device resources in driver probe, with devm_*() functions of the kernel framework as recommended by the kernel community. Doing so simplifies driver cleanup paths and code organization. The current set of API's whch request for device resources are not device managed. The devm_*() functions of the kernel framework are kernel managed resources which the kernel tracks and then automatically releases them when the device goes away. Patch 1/3, replaces kzalloc with devm_kzalloc, kfree's and blank lines are removed accordingly. Patch 2/3, utilizes devm_ioremap_resource for map and unmap of device resources. request_mem_region(), ioremap() and corresponding error handling is replaced with devm_ioremap_resource(). release_mem_region() and iounmap() are dropped. A struct member in struct ssi_drvdata is dropped as it seemed redundant. Log messages adjusted accordingly. Patch 3/3, replaces platform_get_resource(), request_irq() and corresponding error handling with platform_get_irq() and devm_request_irq(). free_irq is not required any more, devm_request_irq() free's it on driver detach. A struct member in struct ssi_drvdata and a bool variable in driver probe are dropped as they seemed redundant. Changed type of a member in struct ssi_drvdata to use it with platform_get_irq(). Log messages adjusted accordingly. Note: Patch was tested and built(ARCH=arm) on next-20170714. No build issues reported, however it was not tested on real hardware. Please drop any patch if they break the flow. As per my analysis these changes should not create a problem. Thanks, Suniel Suniel Mahesh (3): staging: ccree: Replace kzalloc with devm_kzalloc staging: ccree: Convert to devm_ioremap_resource for map, unmap staging: ccree: Use platform_get_irq and devm_request_irq drivers/staging/ccree/ssi_driver.c | 92 +++--- drivers/staging/ccree/ssi_driver.h | 4 +- 2 files changed, 26 insertions(+), 70 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/3] staging: ccree: Convert to devm_ioremap_resource for map, unmap
From: Suniel Mahesh It is recommended to use managed function devm_ioremap_resource(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace request_mem_region(), ioremap() and corresponding error handling with devm_ioremap_resource(). (b) remove struct resource pointer(res_mem) in struct ssi_drvdata as it seems redundant, use struct resource pointer which is defined locally and adjust return value of platform_get_resource() accordingly. (c) release_mem_region() and iounmap() are dropped, since devm_ioremap_ resource() releases and unmaps mem region on driver detach. (d) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on next-20170714. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 59 ++ drivers/staging/ccree/ssi_driver.h | 1 - 2 files changed, 15 insertions(+), 45 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index f231ecf..dca0ce8 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -247,34 +247,21 @@ static int init_cc_resources(struct platform_device *plat_dev) dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ - new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); - if (unlikely(!new_drvdata->res_mem)) { - SSI_LOG_ERR("Failed getting IO memory resource\n"); - rc = -ENODEV; - goto init_cc_res_err; - } - SSI_LOG_DEBUG("Got MEM resource (%s): start=0x%llX end=0x%llX\n", - new_drvdata->res_mem->name, - (unsigned long long)new_drvdata->res_mem->start, - (unsigned long long)new_drvdata->res_mem->end); + req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); /* Map registers space */ - req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); - if (unlikely(!req_mem_cc_regs)) { - SSI_LOG_ERR("Couldn't allocate registers memory region at " -"0x%08X\n", (unsigned int)new_drvdata->res_mem->start); - rc = -EBUSY; - goto init_cc_res_err; - } - cc_base = ioremap(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem)); - if (unlikely(!cc_base)) { - SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n", - (unsigned int)new_drvdata->res_mem->start, (unsigned int)resource_size(new_drvdata->res_mem)); - rc = -ENOMEM; + new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, +req_mem_cc_regs); + if (IS_ERR(new_drvdata->cc_base)) { + rc = PTR_ERR(new_drvdata->cc_base); goto init_cc_res_err; } - SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &new_drvdata->res_mem->start, cc_base); - new_drvdata->cc_base = cc_base; - + SSI_LOG_DEBUG("Got MEM resource (%s): start=0x%llX end=0x%llX\n", + req_mem_cc_regs->name, + (unsigned long long)req_mem_cc_regs->start, + (unsigned long long)req_mem_cc_regs->end); + SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", + &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; /* Then IRQ */ new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); if (unlikely(!new_drvdata->res_irq)) { @@ -421,17 +408,9 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - - if (req_mem_cc_regs) { - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - iounmap(cc_base); - new_drvdata->cc_base = NULL; - } - release_mem_region(new_drvdata->res_mem->start, - resource_size(new_drvdata->res_mem)); - new_drvdata->res_mem = NULL; + if (irq_registered) { + free_irq(new_drvdata->res_irq->start, new_drvdata); + new_drvdata->res_irq = NULL; } dev_set_drvdata(&plat_dev->dev, NULL); } @@ -467,14 +446,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) cc_clk_off(drvdata); free_irq(drvdata->res_irq->start, drvdata); dr
[PATCH 3/3] staging: ccree: Use platform_get_irq and devm_request_irq
From: Suniel Mahesh It is recommended to use managed function devm_request_irq(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace platform_get_resource(), request_irq() and corresponding error handling with platform_get_irq() and devm_request_irq(). (b) remove struct resource pointer(res_irq) in struct ssi_drvdata as it seems redundant. (c) change type of member irq in struct ssi_drvdata from unsigned int to int, as return type of platform_get_irq is int and can be used in error handling. (d) remove irq_registered variable from driver probe as it seems redundant. (e) free_irq is not required any more, devm_request_irq() free's it on driver detach. (f) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh --- Note: - Patch was tested and built(ARCH=arm) on next-20170714. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 29 + drivers/staging/ccree/ssi_driver.h | 3 +-- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index dca0ce8..11b62d0 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,7 +223,6 @@ static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; - bool irq_registered = false; struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; @@ -263,25 +262,22 @@ static int init_cc_resources(struct platform_device *plat_dev) &req_mem_cc_regs->start, new_drvdata->cc_base); cc_base = new_drvdata->cc_base; /* Then IRQ */ - new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); - if (unlikely(!new_drvdata->res_irq)) { + new_drvdata->irq = platform_get_irq(plat_dev, 0); + if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); - rc = -ENODEV; + rc = new_drvdata->irq; goto init_cc_res_err; } - rc = request_irq(new_drvdata->res_irq->start, cc_isr, -IRQF_SHARED, "arm_cc7x", new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("Could not register to interrupt %llu\n", - (unsigned long long)new_drvdata->res_irq->start); + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, + IRQF_SHARED, "arm_cc7x", new_drvdata); + if (rc) { + SSI_LOG_ERR("Could not register to interrupt: %d\n", + new_drvdata->irq); goto init_cc_res_err; } init_completion(&new_drvdata->icache_setup_completion); - irq_registered = true; - SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", - new_drvdata->res_irq->name, - (unsigned long long)new_drvdata->res_irq->start); + SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); new_drvdata->plat_dev = plat_dev; @@ -408,10 +404,6 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } return rc; @@ -441,11 +433,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - fini_cc_regs(drvdata); cc_clk_off(drvdata); - free_irq(drvdata->res_irq->start, drvdata); - drvdata->res_irq = NULL; dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 4b38fe2..6fcd151 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -129,9 +129,8 @@ struct ssi_crypto_req { * @fw_ver:SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_irq; void __iomem *cc_base; - unsigned int irq; + int irq; u32 irq_mask; u32 fw_ver; /* Calibration time of start/stop -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/3] staging: ccree: Convert to devm_ioremap_resource for map, unmap
From: Suniel Mahesh It is recommended to use managed function devm_ioremap_resource(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace request_mem_region(), ioremap() and corresponding error handling with devm_ioremap_resource(). (b) remove struct resource pointer(res_mem) in struct ssi_drvdata as it seems redundant, use struct resource pointer which is defined locally and adjust return value of platform_get_resource() accordingly. (c) release_mem_region() and iounmap() are dropped, since devm_ioremap_ resource() releases and unmaps mem region on driver detach. (d) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh --- Changes for v2: - format specifiers changed in log messages. - Rebased on top of next-20170718. --- Note: - Patch was tested and built(ARCH=arm) on next-20170718. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 60 ++ drivers/staging/ccree/ssi_driver.h | 1 - 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index e918cf4..36b7c92 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -246,35 +246,21 @@ static int init_cc_resources(struct platform_device *plat_dev) dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ - new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); - if (unlikely(!new_drvdata->res_mem)) { - SSI_LOG_ERR("Failed getting IO memory resource\n"); - rc = -ENODEV; - goto init_cc_res_err; - } - SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", - new_drvdata->res_mem->name, - new_drvdata->res_mem->start, - new_drvdata->res_mem->end); + req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); /* Map registers space */ - req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); - if (unlikely(!req_mem_cc_regs)) { - SSI_LOG_ERR("Couldn't allocate registers memory region at " -"0x%08X\n", (unsigned int)new_drvdata->res_mem->start); - rc = -EBUSY; - goto init_cc_res_err; - } - cc_base = ioremap(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem)); - if (unlikely(!cc_base)) { - SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n", - (unsigned int)new_drvdata->res_mem->start, - (unsigned int)resource_size(new_drvdata->res_mem)); - rc = -ENOMEM; + new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, +req_mem_cc_regs); + if (IS_ERR(new_drvdata->cc_base)) { + rc = PTR_ERR(new_drvdata->cc_base); goto init_cc_res_err; } - SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &new_drvdata->res_mem->start, cc_base); - new_drvdata->cc_base = cc_base; - + SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", + req_mem_cc_regs->name, + req_mem_cc_regs->start, + req_mem_cc_regs->end); + SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", + &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; /* Then IRQ */ new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); if (unlikely(!new_drvdata->res_irq)) { @@ -424,17 +410,9 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - - if (req_mem_cc_regs) { - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - iounmap(cc_base); - new_drvdata->cc_base = NULL; - } - release_mem_region(new_drvdata->res_mem->start, - resource_size(new_drvdata->res_mem)); - new_drvdata->res_mem = NULL; + if (irq_registered) { + free_irq(new_drvdata->res_irq->start, new_drvdata); + new_drvdata->res_irq = NULL; } dev_set_drvdata(&plat_dev->dev, NULL); } @@ -470,14 +448,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) cc_clk_off(drv
[PATCH v2 1/3] staging: ccree: Replace kzalloc with devm_kzalloc
From: Suniel Mahesh It is recommended to use managed function devm_kzalloc, which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace kzalloc with devm_kzalloc. (b) drop kfree(), because memory allocated with devm_kzalloc() is automatically freed on driver detach, otherwise it leads to a double free. (c) remove unnecessary blank lines. Signed-off-by: Suniel Mahesh --- Changes for v2: - Changes done as suggested by Greg-KH. - Rebased on top of next-20170718. --- Note: - Patch was tested and built(ARCH=arm) on next-20170718. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index d7b9a63..e918cf4 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,13 +223,15 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), GFP_KERNEL); + struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; int rc = 0; - if (unlikely(!new_drvdata)) { + new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(*new_drvdata), + GFP_KERNEL); + if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; goto init_cc_res_err; @@ -434,10 +436,8 @@ static int init_cc_resources(struct platform_device *plat_dev) resource_size(new_drvdata->res_mem)); new_drvdata->res_mem = NULL; } - kfree(new_drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } - return rc; } @@ -478,8 +478,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) drvdata->cc_base = NULL; drvdata->res_mem = NULL; } - - kfree(drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/3] staging: ccree: Use platform_get_irq and devm_request_irq
From: Suniel Mahesh It is recommended to use managed function devm_request_irq(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace platform_get_resource(), request_irq() and corresponding error handling with platform_get_irq() and devm_request_irq(). (b) remove struct resource pointer(res_irq) in struct ssi_drvdata as it seems redundant. (c) change type of member irq in struct ssi_drvdata from unsigned int to int, as return type of platform_get_irq is int and can be used in error handling. (d) remove irq_registered variable from driver probe as it seems redundant. (e) free_irq is not required any more, devm_request_irq() free's it on driver detach. (f) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh --- Changes for v2: - Rebased on top of next-20170718. --- Note: - Patch was tested and built(ARCH=arm) on next-20170718. No build issues reported, however it was not tested on real hardware. --- drivers/staging/ccree/ssi_driver.c | 30 +- drivers/staging/ccree/ssi_driver.h | 3 +-- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 36b7c92..bac27d4 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -222,7 +222,6 @@ static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; - bool irq_registered = false; struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; @@ -262,26 +261,22 @@ static int init_cc_resources(struct platform_device *plat_dev) &req_mem_cc_regs->start, new_drvdata->cc_base); cc_base = new_drvdata->cc_base; /* Then IRQ */ - new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); - if (unlikely(!new_drvdata->res_irq)) { + new_drvdata->irq = platform_get_irq(plat_dev, 0); + if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); - rc = -ENODEV; + rc = new_drvdata->irq; goto init_cc_res_err; } - rc = request_irq(new_drvdata->res_irq->start, cc_isr, -IRQF_SHARED, "arm_cc7x", new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("Could not register to interrupt %llu\n", - (unsigned long long)new_drvdata->res_irq->start); + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, + IRQF_SHARED, "arm_cc7x", new_drvdata); + if (rc) { + SSI_LOG_ERR("Could not register to interrupt %d\n", + new_drvdata->irq); goto init_cc_res_err; } init_completion(&new_drvdata->icache_setup_completion); - irq_registered = true; - SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", - new_drvdata->res_irq->name, - (unsigned long long)new_drvdata->res_irq->start); - + SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); new_drvdata->plat_dev = plat_dev; rc = cc_clk_on(new_drvdata); @@ -410,10 +405,6 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } return rc; @@ -443,11 +434,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - fini_cc_regs(drvdata); cc_clk_off(drvdata); - free_irq(drvdata->res_irq->start, drvdata); - drvdata->res_irq = NULL; dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 518c0bf..88ef370 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -128,9 +128,8 @@ struct ssi_crypto_req { * @fw_ver:SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_irq; void __iomem *cc_base; - unsigned int irq; + int irq; u32 irq_mask; u32 fw_ver; /* Calibration time of start/stop -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: ccree: Fix unnecessary NULL check before kfree'ing it
From: Suniel Mahesh kfree(NULL) is safe and their is no need for a NULL check. Pointed out by checkpatch. Signed-off-by: Suniel Mahesh --- Note: - Patch was compile tested and built(ARCH=arm) on next-20170719. No build issues reported. --- drivers/staging/ccree/ssi_hash.c | 25 - 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index fba0643..b080aed 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -296,20 +296,14 @@ static int ssi_hash_map_request(struct device *dev, fail1: kfree(state->digest_buff); fail_digest_result_buff: -if (state->digest_result_buff) { -kfree(state->digest_result_buff); -state->digest_result_buff = NULL; -} + kfree(state->digest_result_buff); + state->digest_result_buff = NULL; fail_buff1: -if (state->buff1) { -kfree(state->buff1); -state->buff1 = NULL; -} + kfree(state->buff1); + state->buff1 = NULL; fail_buff0: -if (state->buff0) { -kfree(state->buff0); -state->buff0 = NULL; -} + kfree(state->buff0); + state->buff0 = NULL; fail0: return rc; } @@ -2319,11 +2313,8 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) return 0; fail: - - if (drvdata->hash_handle) { - kfree(drvdata->hash_handle); - drvdata->hash_handle = NULL; - } + kfree(drvdata->hash_handle); + drvdata->hash_handle = NULL; return rc; } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel