From nobody Mon Feb 9 12:02:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4954731D379 for ; Mon, 29 Dec 2025 14:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767018239; cv=none; b=kV3A76CPnRW2Q9ZMj14EYnALmSiqXGDlO4RT8Luz9FrcQFwFIdd1w1ot/Icq4WP5fE5JQJfp6/EuZTNNtlkUb6ttdDfWjlF4I1qenYFwf6eIFp8JIyULNp0OVHc07k9RV5pmB1TLC6MoFmPA5xPMO9QygcVrR3piFjFUG9K6ebU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767018239; c=relaxed/simple; bh=EAFW2gZaTHS5eyzW1JYSLjiq7dLD2WjFxmvfBwBSPMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Og0em3e8YpoAQJJqzfLfC8QZcnGU3QQ998hYFsPNhkmEmu5iRXbYCVRY8HSB2VxVQz8lExpbU4b/PZ+zZKdvTG7svj5ss6KcwMwjFdySo5CG/e/PrO/HR70G1oOwys+Y/Zh4EfpQNnvMC11J1OQwH2Bs6AGw8oSme4iTLivS/uI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NoJyoXPy; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NoJyoXPy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1767018237; x=1798554237; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EAFW2gZaTHS5eyzW1JYSLjiq7dLD2WjFxmvfBwBSPMk=; b=NoJyoXPyb1yNjX6OVel9LrOmXx5xE0G0Hj8pkyBiY/WPXOuMHpFFBS+0 dc+tHYkwVSmUSpwTQFtIMm/zVDocmYzntlCg2/ErujyB7FaCNROLMX8UC GYnhvYTe7GG24WUh6jWDnWW6gMfu54cSa08IMowVoo49frcqgA4PvBn/9 aXEeRfS4wbt6E7sT7N6Tu5RGLHHGNc77/mWHKC0X26Tfnv2ZhVtMLHIpF v4+/OtlOVik1L5/iiBbq9vCStkdCgFu+vAxKvEX+4wCjHOuJnRTDO2ubQ 35PcSxcwV/v3eL8ZnhXsydLmMICZny+Jy9MNnwObgCFNTIpSv5HvoyHYY w==; X-CSE-ConnectionGUID: AtFrbV9AQ2aqP9qJBxxRGQ== X-CSE-MsgGUID: IMA/+SKwRQehvNAlVQ29rg== X-IronPort-AV: E=McAfee;i="6800,10657,11656"; a="79742751" X-IronPort-AV: E=Sophos;i="6.21,186,1763452800"; d="scan'208";a="79742751" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2025 06:23:53 -0800 X-CSE-ConnectionGUID: dD8g8tKTRE+lrbveAOSmIg== X-CSE-MsgGUID: qBA/W0/iR+Wy7UiX83W30A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,186,1763452800"; d="scan'208";a="205829429" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa004.fm.intel.com with ESMTP; 29 Dec 2025 06:23:52 -0800 Received: by black.igk.intel.com (Postfix, from userid 1003) id 1E41693; Mon, 29 Dec 2025 15:23:51 +0100 (CET) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven Subject: [PATCH v1 1/7] auxdisplay: arm-charlcd: convert to use device managed APIs Date: Mon, 29 Dec 2025 14:52:34 +0100 Message-ID: <20251229142349.1251843-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251229142349.1251843-1-andriy.shevchenko@linux.intel.com> References: <20251229142349.1251843-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The current probe function of the driver is implemented by using plain old APIs. As Geert noted, one of the error paths has a mistake that may lead to a wrong call. Instead of targeting that particular issue, convert the driver to use device managed APIs altogether. It's not needed per se (driver can never be removed once loaded), but it simplifies coding and error handling. Reported-by: Geert Uytterhoeven Closes: https://lore.kernel.org/r/CAMuHMdVquNEoxRQkcBEH0nC+CDuib6o0H6m3CBk3= ZN2267LpQw@mail.gmail.com Signed-off-by: Andy Shevchenko --- drivers/auxdisplay/arm-charlcd.c | 49 ++++++-------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-char= lcd.c index 4e22882f57c9..0dab69938352 100644 --- a/drivers/auxdisplay/arm-charlcd.c +++ b/drivers/auxdisplay/arm-charlcd.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include =20 @@ -56,8 +55,6 @@ /** * struct charlcd - Private data structure * @dev: a pointer back to containing device - * @phybase: the offset to the controller in physical memory - * @physize: the size of the physical page * @virtbase: the offset to the controller in virtual memory * @irq: reserved interrupt number * @complete: completion structure for the last LCD command @@ -65,8 +62,6 @@ */ struct charlcd { struct device *dev; - u32 phybase; - u32 physize; void __iomem *virtbase; int irq; struct completion complete; @@ -266,44 +261,27 @@ static void charlcd_init_work(struct work_struct *wor= k) =20 static int __init charlcd_probe(struct platform_device *pdev) { + struct device *dev =3D &pdev->dev; int ret; struct charlcd *lcd; struct resource *res; =20 - lcd =3D kzalloc(sizeof(*lcd), GFP_KERNEL); + lcd =3D devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL); if (!lcd) return -ENOMEM; =20 lcd->dev =3D &pdev->dev; =20 - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret =3D -ENOENT; - goto out_no_resource; - } - lcd->phybase =3D res->start; - lcd->physize =3D resource_size(res); - - if (request_mem_region(lcd->phybase, lcd->physize, - DRIVERNAME) =3D=3D NULL) { - ret =3D -EBUSY; - goto out_no_memregion; - } - - lcd->virtbase =3D ioremap(lcd->phybase, lcd->physize); - if (!lcd->virtbase) { - ret =3D -ENOMEM; - goto out_no_memregion; - } + lcd->virtbase =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(lcd->virtbase)) + return PTR_ERR(lcd->virtbase); =20 lcd->irq =3D platform_get_irq(pdev, 0); /* If no IRQ is supplied, we'll survive without it */ if (lcd->irq >=3D 0) { - if (request_irq(lcd->irq, charlcd_interrupt, 0, - DRIVERNAME, lcd)) { - ret =3D -EIO; - goto out_no_irq; - } + ret =3D devm_request_irq(dev, lcd->irq, charlcd_interrupt, 0, DRIVERNAME= , lcd); + if (ret) + return ret; } =20 platform_set_drvdata(pdev, lcd); @@ -315,18 +293,9 @@ static int __init charlcd_probe(struct platform_device= *pdev) INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work); schedule_delayed_work(&lcd->init_work, 0); =20 - dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n", - lcd->phybase); + dev_info(dev, "initialized ARM character LCD at %pa\n", &res->start); =20 return 0; - -out_no_irq: - iounmap(lcd->virtbase); -out_no_memregion: - release_mem_region(lcd->phybase, lcd->physize); -out_no_resource: - kfree(lcd); - return ret; } =20 static int charlcd_suspend(struct device *dev) --=20 2.50.1