Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3025158pxk; Mon, 21 Sep 2020 03:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXkaKVkEV41I84kVXnkLuctsyd6YdbbU7RB20BfFGdMu9EGJpq2PK1F1Dh3Zg7qqNk2IVj X-Received: by 2002:a17:906:48d6:: with SMTP id d22mr49872521ejt.462.1600683910032; Mon, 21 Sep 2020 03:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600683910; cv=none; d=google.com; s=arc-20160816; b=b/ByB7nP0Ymyg7pbkUcCGlw+tHubCsZDaCA9qGU2sOjXs2D1CHxLxccMdRJAvTF75r acB6TSdusG+pnfx8Tg1AjAPHRmYG+GBQntwe3YW/hkX0hO/DFFh52evaLhZosBTE1TvA GUc/8ep49YKYvDTZCmZ3T/9tOAYclVE50H0EAn4uCqHxbFjeFhnjIv9SKzwozi6MfeKI TK/ERHIvY/5X4XvbSjgWe06/7SfOYlVjcaNCewUAsvWJ6asvpIXxw2/77vyoPFXWSmXh W4RGsNHqWGUPCYdV43cX3kt4H6Tj3SywCp6NBFKnOE67R8P8fhilS6u3brTolQOOWGC2 2StA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=1urHh7daH3LoOqNIcatz+V8D8QIxpgJB7hMXIZZ34x8=; b=xOnbfxbVMqt+u8nOonqKraZHPRDcEu5WoanVevJa08X6v3WGyNPtJHNm0HvGI07IWu X7awdFvDon7pM2MoPzrPocm58vM91YY1h4zxjiCvFAkxiIBopmCRJ+4BHluAPKe5lpTi elzcUkAlxUZ9FauvKtuXu71LBDInlR3EpykdEwgPcMepq7jzAJ3PIw3KmEKWDyVXKO6V xnz6zk6wpUnI+M4kG+OuCtjxkuHBvzftWBiTKHW6O6nOzSXbrL3ctgFGeqid2V8frHCs yymhJqXQnteIleBJCg4w8zR+dsFT1lnOwKY7SwZTwj5oHdPTDW7EY6Pm8hKamWYcFIZJ z5nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=YjR+2ZxA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce12si7663980ejb.719.2020.09.21.03.24.46; Mon, 21 Sep 2020 03:25:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=YjR+2ZxA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbgIUKWk (ORCPT + 99 others); Mon, 21 Sep 2020 06:22:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbgIUKVC (ORCPT ); Mon, 21 Sep 2020 06:21:02 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A0AEC0613D0 for ; Mon, 21 Sep 2020 03:21:02 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id t10so12133933wrv.1 for ; Mon, 21 Sep 2020 03:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1urHh7daH3LoOqNIcatz+V8D8QIxpgJB7hMXIZZ34x8=; b=YjR+2ZxADZaysP7sw04FPhYP3YPw21PgBstXPTe3UwIIsIvxSdaRgWBLUKrGCbw56r KSmiVKdsOVv0Z9mDW82UCgPiG8NptXiVwiymXb+AEp7VChMnFw8+uo2GanEjEhXIZSu9 AVdIcAPCng8oQxUttO4d0ogtZ32GGoyueYSG11AHhkpx94Ij4JrMlGEjxHwJu/G0POdK DGHzJ8X8OyWo3mgdsN/donCalFVhbAISMXlqC3dS0+ZNTyRMhi8mR6rJGTkcsFPaEBUo lUpa50VSd70ObhfzKgtAUjCX1Pqcj8jBfKzQQDx34YlFyJwYzKEbN6E6CiVN5yi7NBer 9xkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1urHh7daH3LoOqNIcatz+V8D8QIxpgJB7hMXIZZ34x8=; b=PUBdQhKdTH2SqMEA67ej9GRROJJD5DIv9igCo/ZY2xOuhtE8UV9UKE5CIxi9dcQAze d+ReAAJw0Fo49plzPk5/U4Dv0ZVZqFugXF0MGE+paDWzljWDL8LJjFLLlTRHQ94P5n88 JdMYK6gAlwna9xkm2tbK36nc0xVYSE/6bELjAmVKslrn24Bj5FK6mCQtBc4rqFGH95C/ IhcG1OBnxORSiIZ0LZjDys0lwxXjFjdkLX8K1tMFn1LNZ3T9aVwd+u3x4g7p8NGW8qkI TH1/qHPcMVSmAyPRxerjCCQG5ValEnJlF6GFUGRsQPcTiEPeSR8Ig6aeEFKcJzLPs3yP Hi3w== X-Gm-Message-State: AOAM5323uOadDcW+ayFXvbxOk85n8gnkLlDxPJa057BLAOdO8ACkjz97 i6ALEqS5HfYkP+YRM9lzZBtF4Q== X-Received: by 2002:adf:f984:: with SMTP id f4mr51635137wrr.102.1600683660854; Mon, 21 Sep 2020 03:21:00 -0700 (PDT) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id l17sm18804629wme.11.2020.09.21.03.21.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2020 03:21:00 -0700 (PDT) From: Corentin Labbe To: gregkh@linuxfoundation.org, laurent.pinchart@skynet.be, mchehab@kernel.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Corentin Labbe Subject: [PATCH RFT/RFC 30/49] staging: media: zoran: use devm for videocodec_master alloc Date: Mon, 21 Sep 2020 10:20:05 +0000 Message-Id: <1600683624-5863-31-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600683624-5863-1-git-send-email-clabbe@baylibre.com> References: <1600683624-5863-1-git-send-email-clabbe@baylibre.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's use devm allocations for videocodec, this simplify code. Signed-off-by: Corentin Labbe --- drivers/staging/media/zoran/zoran_card.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c index 62e63804ae14..756b9a339f7e 100644 --- a/drivers/staging/media/zoran/zoran_card.c +++ b/drivers/staging/media/zoran/zoran_card.c @@ -989,18 +989,10 @@ static void zoran_remove(struct pci_dev *pdev) goto exit_free; /* unregister videocodec bus */ - if (zr->codec) { - struct videocodec_master *master = zr->codec->master_data; - + if (zr->codec) videocodec_detach(zr->codec); - kfree(master); - } - if (zr->vfe) { - struct videocodec_master *master = zr->vfe->master_data; - + if (zr->vfe) videocodec_detach(zr->vfe); - kfree(master); - } /* unregister i2c bus */ zoran_unregister_i2c(zr); @@ -1028,7 +1020,7 @@ static struct videocodec_master *zoran_setup_videocodec(struct zoran *zr, int ty { struct videocodec_master *m = NULL; - m = kmalloc(sizeof(*m), GFP_KERNEL); + m = devm_kmalloc(&zr->pci_dev->dev, sizeof(*m), GFP_KERNEL); if (!m) return m; @@ -1234,7 +1226,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) zr->codec = videocodec_attach(master_codec); if (!zr->codec) { pci_err(pdev, "%s - no codec found\n", __func__); - goto zr_free_codec; + goto zr_unreg_i2c; } if (zr->codec->type != zr->card.video_codec) { pci_err(pdev, "%s - wrong codec\n", __func__); @@ -1248,7 +1240,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) zr->vfe = videocodec_attach(master_vfe); if (!zr->vfe) { pci_err(pdev, "%s - no VFE found\n", __func__); - goto zr_free_vfe; + goto zr_detach_codec; } if (zr->vfe->type != zr->card.video_vfe) { pci_err(pdev, "%s = wrong VFE\n", __func__); @@ -1269,12 +1261,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) zr_detach_vfe: videocodec_detach(zr->vfe); -zr_free_vfe: - kfree(master_vfe); zr_detach_codec: videocodec_detach(zr->codec); -zr_free_codec: - kfree(master_codec); zr_unreg_i2c: zoran_unregister_i2c(zr); zr_free_irq: -- 2.26.2