lkml.org 
[lkml]   [2020]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH RFT/RFC 24/49] staging: media: zoran: Use DMA coherent for stat_com
On Mon, Sep 21, 2020 at 10:19:59AM +0000, Corentin Labbe wrote:
> Instead of using a fragile virt_to_bus, let's use proper DMA coherent
> for the stat_com entry.
>
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
> drivers/staging/media/zoran/zoran.h | 2 ++
> drivers/staging/media/zoran/zoran_card.c | 20 +++++++++++++-------
> drivers/staging/media/zoran/zoran_device.c | 3 +--
> 3 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h
> index aa2a8f688a01..8f3faa4eb60f 100644
> --- a/drivers/staging/media/zoran/zoran.h
> +++ b/drivers/staging/media/zoran/zoran.h
> @@ -351,6 +351,8 @@ struct zoran {
> unsigned long frame_num;
>
> wait_queue_head_t test_q;
> +
> + dma_addr_t p_sc;
> };
>
> static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
> diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
> index 3a7895be3341..a8d23bf126c3 100644
> --- a/drivers/staging/media/zoran/zoran_card.c
> +++ b/drivers/staging/media/zoran/zoran_card.c
> @@ -931,11 +931,15 @@ static int zr36057_init(struct zoran *zr)
> zoran_open_init_params(zr);
>
> /* allocate memory *before* doing anything to the hardware in case allocation fails */
> - zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
> zr->video_dev = video_device_alloc();
> - if (!zr->stat_com || !zr->video_dev) {
> + if (!zr->video_dev) {
> err = -ENOMEM;
> - goto exit_free;
> + goto exit;
> + }
> + zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), &zr->p_sc, GFP_KERNEL);

Again, don't write junk coe like this. Stick to the 80 lines unless
you have a very good reason.

\
 
 \ /
  Last update: 2020-09-22 07:15    [W:0.177 / U:18.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site