Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2301546lqb; Mon, 27 May 2024 15:15:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMonez/jfzWpnBg/GmBDffQqQArtcroh60PockhQA3RfHH68U0AT2X5Fe5fEJnyp38P/lt/gijsomAc9UvgG/+hT6f9llW8QIy1LGZ8Q== X-Google-Smtp-Source: AGHT+IF3WA9MPg+BRUazUapa+/UYQeYCGOgTdiqD2f6/EbDQ2lWyhCB9WkgTjxMJqeJP6+AJof1N X-Received: by 2002:a05:620a:4485:b0:790:9e84:9b75 with SMTP id af79cd13be357-794aa7dac4amr1901028885a.12.1716848134889; Mon, 27 May 2024 15:15:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716848134; cv=pass; d=google.com; s=arc-20160816; b=mvcONJGLlNg46ntGIgvO+v4jaCIzePGxa1PvJIxT5xKGpg69Bppi716rAAuN1wHqWH 27JFlvXLwc5QrxN25KF0OqSsNfPI3wq9wVoq5NfB0FrbQh7UC4QAgyD/xbw7tiPAmeM0 hUS9tkydhcJuwYE5SquduQsHKdXA6+AJYmoYLHgAZIfV4qd+GgHS9P4/5lzVKnK8hkGz X3QStz0GpPFRmBkwUNmdHMQ1DkmaB523gNUZfJJHNcsJ09AbA/rxQG0Br/u/JDPk1Plu RjXvN5ZqpWCT/D234DiYtVN9JLGsplmVJZahdFC218yhrf+8zYovRCElgYf23GuA6uxt 9beQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Mhx0VHnzzMbEOw920oSrnPWneiMuNSd3zSFtO71ho5o=; fh=5ulmZPROPAAjE6CKigcYAdosEOwqGAnUP0EcLtl8YrE=; b=J2znMIcRdHfBuLakbBnQmD/rqdbD5f+2xlXmTv+ZUkYD8NJOHvDI1vGkiBQtVL5Nu8 ZQ4t98c5/U8LTidiXsj9AyEy0xEh0ceSprW1krpf7bG+qdS3Gr3PalGyLLsUCS+nWDPM GsvXsAhWz1ujdJpEcFOvKXgt3ZxfK5TuYXONZk/HMIrnQh1ZY7pqUkzgdnEhcBPLZDDN +Q3kWwNWya35CaskzZy4694TBvLdXOltQa/ODM8ceTdLplz5FwRSt/4TFMUSCw/mC2BI LGchvS4qZF0eabbD4lbFDfBV/zaxBQbjKFm0cvn0ynn1h5Wt9roV4b4qEE+1I9x4TgWf wl/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=frghwIL4; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-191481-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abcabf25si870642685a.10.2024.05.27.15.15.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 15:15:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191481-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=frghwIL4; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-191481-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8FF611C2145C for ; Mon, 27 May 2024 22:15:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D761C169366; Mon, 27 May 2024 22:14:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="frghwIL4" Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4289B168C00 for ; Mon, 27 May 2024 22:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716848096; cv=none; b=S45K3SC88BgWih8ibk6kjiz4YIEwL3EcmotNZPiL+lMA7Xb5q5uCcCrqnqLLUpc76ahn0Ui9s26Iq9oXWAKQUiIWDCIXG7PNKAkl+Uzq7myO4fesARJmGwqH1uGIaloxlTzzBhSFK4NEhLwoikxtqe52rKebrV24g9hyqSyzi48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716848096; c=relaxed/simple; bh=Fwd5tXA0UQLNv4eb1QzUSIOyA2aHWmaleAdJjHcH7xg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dw/FxTbvhYRf+kC1gR4Bx0XfQwKkOUzMhFSFE2yXXdQo0svDNCcGUssqR4JdbnYxpiEG+aK/cfd+M2R02sr9d6jZK0paPYua+MzByyNVpZNrZ36btONaUTBlXvINuuZk5c+8qIeWqOMK0K+3wOmmOj/rddnEwDBcUEGoltaWFOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=frghwIL4; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-792bdf626beso19078885a.1 for ; Mon, 27 May 2024 15:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1716848094; x=1717452894; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Mhx0VHnzzMbEOw920oSrnPWneiMuNSd3zSFtO71ho5o=; b=frghwIL4k4So7kgynmme9gLrBOr6k9VbBm+47wYd9D4/R7Jx78e0k+m4wCqA1C7+kX +eTDHY+Sp0SCVd1S8PB49wy2u+v4mgRFLMWxTdK8SPf3rcpql7btDkvmTOPL2z3QtVtC bLtXt99ACdM628soY4Nn0fbO2mepHDOr6xy7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716848094; x=1717452894; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mhx0VHnzzMbEOw920oSrnPWneiMuNSd3zSFtO71ho5o=; b=Ce+PE/2igJbgBSdFRbb8yfqM5zW98uTaH4lhc2rCYhrMIlyAwJNWiUybcfzJZQUlkn i+9QWjwUr6FJjLAXidk8du6jMSfRNWvHtnkllTjsc5gFq08F78HQmyDmqxzu/a8kjOkx cEks1lU0oS9a+ariciC14NHFKtQMIgseQmIHtDSpeZxzfrAdlcO/gVCbiiBZWhS2MAiO iY7GXdXB7qobbErrt1LyvT+/nCU1NokWP+hLT2tS4rCIw4BaUwsUR0YzTatqjJ2zrch6 QheLlVCOAAHor+Wy7tE9Y9mdmi3GaJOT9YBqGRVY2ChkKKHPacHIF2X/bHJVAb8FQgIk Ovug== X-Forwarded-Encrypted: i=1; AJvYcCUaLLLyCcKTd5++qmbn9g/QMD8/zUo5ggEJ1iuFCZ4sfdO2xQCOAeM8NvJh2T6CK1LLZtCGe1Uv9/CbSSxmMMbP+FZQeBQ2+BPWe0SC X-Gm-Message-State: AOJu0Yw+RgAqIRXq2Zbu1cxe76e+i6BTmq0f3V2KynM07miDC8FkUT/l 4s6MbFdUpxepwB9ZfzzGWi60O9o84PjMtMjvRBxJB9uXSjhF9KKXg4YJA1LbQw== X-Received: by 2002:a05:620a:3906:b0:790:ec77:4c1a with SMTP id af79cd13be357-794a0a568e5mr2414641385a.39.1716848094132; Mon, 27 May 2024 15:14:54 -0700 (PDT) Received: from denia.c.googlers.com (125.135.86.34.bc.googleusercontent.com. [34.86.135.125]) by smtp.gmail.com with ESMTPSA id af79cd13be357-794abca58e6sm329740885a.18.2024.05.27.15.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 15:14:53 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 27 May 2024 22:14:45 +0000 Subject: [PATCH 1/3] media: pci/ivtv: Replace ioremap with devm_ variants Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240527-devm-itv-v1-1-f5829b8e7674@chromium.org> References: <20240527-devm-itv-v1-0-f5829b8e7674@chromium.org> In-Reply-To: <20240527-devm-itv-v1-0-f5829b8e7674@chromium.org> To: Andy Walls , Mauro Carvalho Chehab Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 With Managed Device Resources the error handling is simpler. The following smatch warning is silenced: drivers/media/pci/ivtv/ivtv-driver.c: drivers/media/pci/ivtv/ivtv-driver.c:1296 ivtv_probe() warn: 'itv->dec_mem' from ioremap() not released on lines: 1296. drivers/media/pci/ivtv/ivtv-driver.c: drivers/media/pci/ivtv/ivtv-driver.c:1296 ivtv_probe() warn: 'itv->enc_mem' from ioremap() not released on lines: 1296. Signed-off-by: Ricardo Ribalda --- drivers/media/pci/ivtv/ivtv-driver.c | 51 +++++++++--------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c index ba503d820e48..7599fffb0c9d 100644 --- a/drivers/media/pci/ivtv/ivtv-driver.c +++ b/drivers/media/pci/ivtv/ivtv-driver.c @@ -371,33 +371,6 @@ int ivtv_msleep_timeout(unsigned int msecs, int intr) return 0; } -/* Release ioremapped memory */ -static void ivtv_iounmap(struct ivtv *itv) -{ - if (itv == NULL) - return; - - /* Release registers memory */ - if (itv->reg_mem != NULL) { - IVTV_DEBUG_INFO("releasing reg_mem\n"); - iounmap(itv->reg_mem); - itv->reg_mem = NULL; - } - /* Release io memory */ - if (itv->has_cx23415 && itv->dec_mem != NULL) { - IVTV_DEBUG_INFO("releasing dec_mem\n"); - iounmap(itv->dec_mem); - } - itv->dec_mem = NULL; - - /* Release io memory */ - if (itv->enc_mem != NULL) { - IVTV_DEBUG_INFO("releasing enc_mem\n"); - iounmap(itv->enc_mem); - itv->enc_mem = NULL; - } -} - /* Hauppauge card? get values from tveeprom */ void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv) { @@ -1041,8 +1014,9 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) /* map io memory */ IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n", (u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE); - itv->enc_mem = ioremap(itv->base_addr + IVTV_ENCODER_OFFSET, - IVTV_ENCODER_SIZE); + itv->enc_mem = devm_ioremap(&pdev->dev, + itv->base_addr + IVTV_ENCODER_OFFSET, + IVTV_ENCODER_SIZE); if (!itv->enc_mem) { IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 encoder memory\n"); IVTV_ERR("Each capture card with a CX23415/6 needs 8 MB of vmalloc address space for this window\n"); @@ -1055,8 +1029,9 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) if (itv->has_cx23415) { IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n", (u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); - itv->dec_mem = ioremap(itv->base_addr + IVTV_DECODER_OFFSET, - IVTV_DECODER_SIZE); + itv->dec_mem = devm_ioremap(&pdev->dev, + itv->base_addr + IVTV_DECODER_OFFSET, + IVTV_DECODER_SIZE); if (!itv->dec_mem) { IVTV_ERR("ioremap failed. Can't get a window into CX23415 decoder memory\n"); IVTV_ERR("Each capture card with a CX23415 needs 8 MB of vmalloc address space for this window\n"); @@ -1073,26 +1048,27 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) /* map registers memory */ IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n", (u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); - itv->reg_mem = - ioremap(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); + itv->reg_mem = devm_ioremap(&pdev->dev, + itv->base_addr + IVTV_REG_OFFSET, + IVTV_REG_SIZE); if (!itv->reg_mem) { IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 register space\n"); IVTV_ERR("Each capture card with a CX23415/6 needs 64 kB of vmalloc address space for this window\n"); IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n"); IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n"); retval = -ENOMEM; - goto free_io; + goto free_mem; } retval = ivtv_gpio_init(itv); if (retval) - goto free_io; + goto free_mem; /* active i2c */ IVTV_DEBUG_INFO("activating i2c...\n"); if (init_ivtv_i2c(itv)) { IVTV_ERR("Could not initialize i2c\n"); - goto free_io; + goto free_mem; } if (itv->card->hw_all & IVTV_HW_TVEEPROM) { @@ -1277,8 +1253,6 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) free_i2c: v4l2_ctrl_handler_free(&itv->cxhdl.hdl); exit_ivtv_i2c(itv); -free_io: - ivtv_iounmap(itv); free_mem: release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); @@ -1439,7 +1413,6 @@ static void ivtv_remove(struct pci_dev *pdev) exit_ivtv_i2c(itv); free_irq(itv->pdev->irq, (void *)itv); - ivtv_iounmap(itv); release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); -- 2.45.1.288.g0e0cd299f1-goog