Re: tty contention resulting from tty_open_by_device export
On Fri, Jul 07, 2017 at 09:28:41PM +0100, Okash Khawaja wrote: > Hi, > > The commit 12e84c71b7d4ee (tty: export tty_open_by_driver) exports > tty_open_by_device to allow tty to be opened from inside kernel which > works fine except that it doesn't handle contention with user space or > another kernel-space open of the same tty. For example, opening a tty > from user space while it is kernel opened results in failure and a > kernel log message about mismatch between tty->count and tty's file open > count. > > I suggest we make kernel access to tty exclusive so that if a user > process or kernel opens a kernel opened tty, it gets -EBUSY. Below is > a patch which does this by adding TTY_KOPENED flag to tty->flags. When > this flag is set, tty_open_by_driver returns -EBUSY. Instead of > overlaoding tty_open_by_driver for both kernel and user space, this > patch creates a separate function tty_kopen which closely follows > tty_open_by_driver. > > I am far from an expert on tty and this patch might contain the wrong > approach. But it should convey what I mean. > > Thanks, > Okash > > --- > drivers/staging/speakup/spk_ttyio.c |2 - > drivers/tty/tty_io.c| 56 > ++-- > include/linux/tty.h |7 +--- > 3 files changed, 58 insertions(+), 7 deletions(-) > > --- a/drivers/staging/speakup/spk_ttyio.c > +++ b/drivers/staging/speakup/spk_ttyio.c > @@ -164,7 +164,7 @@ static int spk_ttyio_initialise_ldisc(st > if (ret) > return ret; > > - tty = tty_open_by_driver(dev, NULL, NULL); > + tty = tty_kopen(dev); > if (IS_ERR(tty)) > return PTR_ERR(tty); > > --- a/drivers/tty/tty_io.c > +++ b/drivers/tty/tty_io.c > @@ -1786,6 +1786,53 @@ static struct tty_driver *tty_lookup_dri > } > > /** > + * tty_kopen - open a tty device for kernel > + * @device: dev_t of device to open If nothing else, this api call is much simpler overall, as your use above shows :) > + * > + * Opens tty exclusively for kernel. Performs the driver lookup, > + * makes sure it's not already opened and performs the first-time > + * tty initialization. > + * > + * Returns the locked initialized &tty_struct > + * > + * Claims the global tty_mutex to serialize: > + * - concurrent first-time tty initialization > + * - concurrent tty driver removal w/ lookup > + * - concurrent tty removal from driver table > + */ > +struct tty_struct *tty_kopen(dev_t device) > +{ > +struct tty_struct *tty; > +struct tty_driver *driver = NULL; > +int index = -1; > + > +mutex_lock(&tty_mutex); > +driver = tty_lookup_driver(device, NULL, &index); > +if (IS_ERR(driver)) { > +mutex_unlock(&tty_mutex); > +return ERR_CAST(driver); > +} > + > +/* check whether we're reopening an existing tty */ > +tty = tty_driver_lookup_tty(driver, NULL, index); > +if (IS_ERR(tty)) > +goto out; > + > +if (tty) { > +tty_kref_put(tty); /* drop kref from > tty_driver_lookup_tty() */ Put the comment above the line? > +tty = ERR_PTR(-EBUSY); > +} else { /* Returns with the tty_lock held for now */ I don't understand this comment. > +tty = tty_init_dev(driver, index); > +set_bit(TTY_KOPENED, &tty->flags); > +} > +out: > +mutex_unlock(&tty_mutex); > +tty_driver_kref_put(driver); > +return tty; > +} > +EXPORT_SYMBOL(tty_kopen); EXPORT_SYMBOL_GPL()? :) > + > +/** > * tty_open_by_driver - open a tty device > * @device: dev_t of device to open > * @inode: inode of device file > @@ -1801,7 +1848,7 @@ static struct tty_driver *tty_lookup_dri > * - concurrent tty driver removal w/ lookup > * - concurrent tty removal from driver table > */ > -struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, > +static struct tty_struct *tty_open_by_driver(dev_t device, struct inode > *inode, >struct file *filp) > { > struct tty_struct *tty; > @@ -1824,6 +1871,12 @@ struct tty_struct *tty_open_by_driver(de > } > > if (tty) { > + if (test_bit(TTY_KOPENED, &tty->flags)) { > + tty_kref_put(tty); > + mutex_unlock(&tty_mutex); > + tty = ERR_PTR(-EBUSY); > + goto out; > + } > mutex_unlock(&tty_mutex); > retval = tty_lock_interruptible(tty); > tty_kref_put(tty); /* drop kref from tty_driver_lookup_tty() */ > @@ -1846,7 +1899,6 @@ out: > tty_driver_kref_put(driver); > return tty; > } > -EXPORT_SYMBOL_GPL(tty_open_by_driver); > > /** > * tty_open- open a tty device > --- a/include/linux/tty.h > +++ b/include/linux/tty.
Re: tty contention resulting from tty_open_by_device export
On Sat, Jul 08, 2017 at 10:38:03AM +0200, Greg Kroah-Hartman wrote: > > + > > +if (tty) { > > +tty_kref_put(tty); /* drop kref from > > tty_driver_lookup_tty() */ > > Put the comment above the line? > Sure > > +tty = ERR_PTR(-EBUSY); > > +} else { /* Returns with the tty_lock held for now */ > > I don't understand this comment. > This is same comment in tty_open_by_driver. Basically, tty_init_dev returns tty locked so that it doesn't dissapear from underneath the caller. I am not sure about the "for now" part of the comment. I'll remove it. > > +tty = tty_init_dev(driver, index); > > +set_bit(TTY_KOPENED, &tty->flags); > > +} > > +out: > > +mutex_unlock(&tty_mutex); > > +tty_driver_kref_put(driver); > > +return tty; > > +} > > +EXPORT_SYMBOL(tty_kopen); > > EXPORT_SYMBOL_GPL()? :) > Of course, will update > > /** > > * tty_open- open a tty device > > --- a/include/linux/tty.h > > +++ b/include/linux/tty.h > > @@ -362,6 +362,7 @@ struct tty_file_private { > > #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to > > driver */ > > #define TTY_HUPPED 18 /* Post driver->hangup() */ > > #define TTY_LDISC_HALTED 22 /* Line discipline is halted */ > > +#define TTY_KOPENED 23 /* TTY exclusively opened by > > kernel */ > > Minor nit, please use tabs here. > Will do > Overall, the idea looks sane to me. Keeping userspace from opening a > tty that the kernel has opened internally makes sense, hopefully > userspace doesn't get too confused when that happens. I don't think we > normally return -EBUSY from an open call, have you seen what happens > with apps when you do this (like minicom?) > Yes, returning -EBUSY is a change in the interface. I will test against applications like minicom before resubmitting this. Thanks, Okash ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree()
On Fri, 2017-07-07 at 20:41 -0400, Amitoj Kaur Chawla wrote: [...] > --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool > zero_mem) > */ > void atomisp_kernel_free(void *ptr) > { > - /* Verify if buffer was allocated by vmalloc() or kmalloc() > */ > - if (is_vmalloc_addr(ptr)) > - vfree(ptr); > - else > - kfree(ptr); > + kvfree(ptr); > } > > /* Why not get rid of the trivial wrapper function completely? MfG, Bernd -- Bernd Petrovitsch Email : be...@petrovitsch.priv.at LUGA : http://www.luga.at ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy
Hi Hari, On Fri, Jul 07, 2017 at 08:15:21PM +0530, Hari Prasath wrote: > kstrdup kernel primitive can be used to replace kmalloc followed by > string copy. This was reported by coccinelle tool > > Signed-off-by: Hari Prasath > --- > .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 10 > +++--- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git > a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c > b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c > index 34cc56f..68db87b 100644 > --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c > +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c > @@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct > ia_css_fw_info *bi, struct ia > ) > { > char *namebuffer; > - int namelength = (int)strlen(name); > - > - namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL); > - if (namebuffer == NULL) > - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; > - > - memcpy(namebuffer, name, namelength + 1); > > + namebuffer = kstrdup(name, GFP_KERNEL); > + if (!namebuffer) > + return -ENOMEM; The patch also changes the return value in error cases. I believe the caller(s) expect to get errors in the IA_CCS_ERR_* range. > bd->name = fw_minibuffer[index].name = namebuffer; > } else { > bd->name = name; -- Regards, Sakari Ailus e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Coding style fixes for /drivers/staging/ccree/. This is for the eudyptula challenge.
Signed-off-by: Tyler Olivieri --- drivers/staging/ccree/ssi_buffer_mgr.c | 14 ++ drivers/staging/ccree/ssi_cipher.c | 6 ++- drivers/staging/ccree/ssi_driver.c | 5 +- drivers/staging/ccree/ssi_fips.c | 2 - drivers/staging/ccree/ssi_fips_ll.c| 85 +++--- drivers/staging/ccree/ssi_hash.c | 33 +++-- drivers/staging/ccree/ssi_sysfs.c | 3 +- 7 files changed, 57 insertions(+), 91 deletions(-) diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index b35871e..cbf672b 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -150,7 +150,7 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli( u32 **mlli_entry_pp) { u32 *mlli_entry_p = *mlli_entry_pp; - u32 new_nents;; + u32 new_nents; /* Verify there is no memory overflow*/ new_nents = (*curr_nents + buff_size / CC_MAX_MLLI_ENTRY_SIZE + 1); @@ -696,8 +696,7 @@ void ssi_buffer_mgr_unmap_aead_request( } if (drvdata->coherent && (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) && - likely(req->src == req->dst)) - { + likely(req->src == req->dst)) { u32 size_to_skip = req->assoclen; if (areq_ctx->is_gcm4543) @@ -1134,8 +1133,7 @@ static inline int ssi_buffer_mgr_aead_chain_data( sg_index += areq_ctx->srcSgl->length; src_mapped_nents--; } - if (unlikely(src_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) - { + if (unlikely(src_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) { SSI_LOG_ERR("Too many fragments. current %d max %d\n", src_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); return -ENOMEM; @@ -1177,8 +1175,7 @@ static inline int ssi_buffer_mgr_aead_chain_data( sg_index += areq_ctx->dstSgl->length; dst_mapped_nents--; } - if (unlikely(dst_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) - { + if (unlikely(dst_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) { SSI_LOG_ERR("Too many fragments. current %d max %d\n", dst_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); return -ENOMEM; @@ -1274,8 +1271,7 @@ int ssi_buffer_mgr_map_aead_request( if (drvdata->coherent && (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) && - likely(req->src == req->dst)) - { + likely(req->src == req->dst)) { u32 size_to_skip = req->assoclen; if (is_gcm4543) diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index cd2eafc..4ef0c9b 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -68,7 +68,8 @@ struct ssi_ablkcipher_ctx { static void ssi_ablkcipher_complete(struct device *dev, void *ssi_req, void __iomem *cc_base); -static int validate_keys_sizes(struct ssi_ablkcipher_ctx *ctx_p, u32 size) { +static int validate_keys_sizes(struct ssi_ablkcipher_ctx *ctx_p, u32 size) +{ switch (ctx_p->flow_mode) { case S_DIN_to_AES: switch (size) { @@ -108,7 +109,8 @@ static int validate_keys_sizes(struct ssi_ablkcipher_ctx *ctx_p, u32 size) { return -EINVAL; } -static int validate_data_size(struct ssi_ablkcipher_ctx *ctx_p, unsigned int size) { +static int validate_data_size(struct ssi_ablkcipher_ctx *ctx_p, unsigned int size) +{ switch (ctx_p->flow_mode) { case S_DIN_to_AES: switch (ctx_p->cipher_mode) { diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 78709b92..d396474 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -301,13 +301,10 @@ static int init_cc_resources(struct platform_device *plat_dev) goto init_cc_res_err; if (!new_drvdata->plat_dev->dev.dma_mask) - { new_drvdata->plat_dev->dev.dma_mask = &new_drvdata->plat_dev->dev.coherent_dma_mask; - } + if (!new_drvdata->plat_dev->dev.coherent_dma_mask) - { new_drvdata->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)); diff --git a/drivers/staging/ccree/ssi_fips.c b/drivers/staging/ccree/ssi_fips.c index fdc40f3..523057c 100644 --- a/drivers/staging/ccree/ssi_fips.c +++ b/drivers/staging/ccree/ssi_fips.c @@ -39,7 +39,6 @@ int ssi_fips_get_state(enum cc_fips_state_t *p_state) return rc; } - EXPORT_SYMBOL(ssi_fips_get_state); /* @@ -57,5 +56,4 @@ int ssi_fips_get_error(enum cc_fips_error *p_err) return rc; } - EXPORT_SYMBOL(ssi_fips_
Re: [PATCH] Coding style fixes for /drivers/staging/ccree/. This is for the eudyptula challenge.
On Sat, Jul 8, 2017 at 1:55 PM, SnazyMan wrote: > [PATCH] Coding style fixes for /drivers/staging/ccree/. This is for the > eudyptula challenge. That's way too generic. Also, these patches are for the kernel, not Little Penguin :D. It really isn't that important to the kernel that you submit this as part of the eudyptula challenge. Other than that, you should be doing one thing per patch. Whatever you do in a patch, you need to properly describe it too. Decent subject lines would be [PATCH] staging: ccree: fix placement of curly braces [PATCH] staging: ccree: remove redundant semicolons Then in the body you can state that it fixes some checkpatch noise, or that some documentation describes that we prefer a certain style for certain cases. Oh, and in your new patches, either fix your name in your mail client, or start your mail body with: From: Tyler Olivieri SnazyMan will not be accepted as your name. Good luck, Frans ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8723bs: Place constant at the right.
Move constant to the right of a relational operator. This coding style is more common for the kernel code. Problem found by checkpatch. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 3c5cb78..01f78d1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -55,7 +55,7 @@ void rtw_btcoex_ConnectNotify(struct adapter *padapter, u8 action) void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus) { - if ((RT_MEDIA_CONNECT == mediaStatus) + if ((mediaStatus == RT_MEDIA_CONNECT) && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) { rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL); } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: atomisp: gc0310: constify acpi_device_id.
On Fri, Jul 07, 2017 at 11:47:43AM +0100, Alan Cox wrote: > On Thu, 2017-07-06 at 21:50 +0530, Arvind Yadav wrote: > > acpi_device_id are not supposed to change at runtime. All functions > > working with acpi_device_id provided by work with > > const acpi_device_id. So mark the non-const structs as const. > > > > File size before: > > text data bss dec hex > > filename > > 10297 1888 0 12185 2f99 > > drivers/staging/media/atomisp/i2c/gc0310.o > > > > File size After adding 'const': > > text data bss dec hex > > filename > > 10361 1824 0 12185 2f99 > > drivers/staging/media/atomisp/i2c/gc0310.o > > > > Signed-off-by: Arvind Yadav > > --- > > drivers/staging/media/atomisp/i2c/gc0310.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/media/atomisp/i2c/gc0310.c > > b/drivers/staging/media/atomisp/i2c/gc0310.c > > index 1ec616a..c8162bb 100644 > > --- a/drivers/staging/media/atomisp/i2c/gc0310.c > > +++ b/drivers/staging/media/atomisp/i2c/gc0310.c > > @@ -1453,7 +1453,7 @@ static int gc0310_probe(struct i2c_client > > *client, > > return ret; > > } > > > > -static struct acpi_device_id gc0310_acpi_match[] = { > > +static const struct acpi_device_id gc0310_acpi_match[] = { > > {"XXGC0310"}, > > {}, > > }; > > (All four) > > Acked-by: Alan Cox There's four more... I've applied all to my atomisp branch. Arvind: please send the patches as a single set next time. -- Regards, Sakari Ailus e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192u: Use __func__ instead of function name in strings
Replace hard-coded function names in strings with '"%s...", __func__' in the r8190_rtl8256.c file. Issue found by checkpatch.pl. Signed-off-by: Chris Coffey --- Patch generated on staging tree, staging-testing branch. drivers/staging/rtl8192u/r8190_rtl8256.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index e54f6fad2e..a095c359df 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -53,7 +53,7 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth) (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "%s: unknown hardware version\n", __func__); } break; case HT_CHANNEL_WIDTH_20_40: @@ -68,11 +68,11 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth) else rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "%s: unknown hardware version\n", __func__); } break; default: - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n", Bandwidth); + RT_TRACE(COMP_ERR, "%s: unknown Bandwidth: %#X\n", __func__, Bandwidth); break; } @@ -152,7 +152,7 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) * TODO: this function should be removed on ASIC , Emily 2007.2.2 */ if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath)) { - RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); + RT_TRACE(COMP_ERR, "%s: Check Radio[%d] Fail!!\n", __func__, eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -207,7 +207,7 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) } if (ret) { - RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath); + RT_TRACE(COMP_ERR, "%s: Radio[%d] Fail!!", __func__, eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: wilc1000: add parameter name to function definition
Add missing parameter name to fix the following checkpatch.pl warning: WARNING: function definition argument 'struct device *' should also have an identifier name Signed-off-by: Dmitriy Cherkasov --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index c89bf43..7a36561 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -227,8 +227,8 @@ struct WILC_WFI_mon_priv { void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); void wilc_mac_indicate(struct wilc *wilc, int flag); void wilc_netdev_cleanup(struct wilc *wilc); -int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type, int gpio, -const struct wilc_hif_func *ops); +int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, +int gpio, const struct wilc_hif_func *ops); void wilc1000_wlan_deinit(struct net_device *dev); void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); int wilc_wlan_get_firmware(struct net_device *dev); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree()
On Sat, Jul 8, 2017 at 4:58 AM, Bernd Petrovitsch wrote: > On Fri, 2017-07-07 at 20:41 -0400, Amitoj Kaur Chawla wrote: > [...] >> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c >> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c >> @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool >> zero_mem) >> */ >> void atomisp_kernel_free(void *ptr) >> { >> - /* Verify if buffer was allocated by vmalloc() or kmalloc() >> */ >> - if (is_vmalloc_addr(ptr)) >> - vfree(ptr); >> - else >> - kfree(ptr); >> + kvfree(ptr); >> } >> >> /* > > Why not get rid of the trivial wrapper function completely? > Oh yes, i'll send a v2. Amitoj ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/2] staging: ccree: remove unnecessary cast on kmalloc
The assignment operator implicitly converts a void pointer to the type of the pointer it is assigned to. This issue was detected using Coccinelle and the following semantic patch: @@ expression * e; expression arg1, arg2; type T; @@ - e=(T*) + e= kmalloc(arg1, arg2); Signed-off-by: Gustavo A. R. Silva --- drivers/staging/ccree/ssi_buffer_mgr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index b35871e..18a8694 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -1725,8 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata) struct buff_mgr_handle *buff_mgr_handle; struct device *dev = &drvdata->plat_dev->dev; - buff_mgr_handle = (struct buff_mgr_handle *) - kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL); + buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL); if (!buff_mgr_handle) return -ENOMEM; -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/2] staging: ccree: use sizeof(*var) in kmalloc
Fix the following checkpatch warning: CHECK: Prefer kmalloc(sizeof(*buff_mgr_handle)...) over kmalloc(sizeof(struct buff_mgr_handle)...) Signed-off-by: Gustavo A. R. Silva --- drivers/staging/ccree/ssi_buffer_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 18a8694..9caff9b 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -1725,7 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata) struct buff_mgr_handle *buff_mgr_handle; struct device *dev = &drvdata->plat_dev->dev; - buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL); + buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL); if (!buff_mgr_handle) return -ENOMEM; -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel