From patchwork Mon Jan 22 03:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 189892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2378639dyb; Sun, 21 Jan 2024 21:30:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5JOG/xCj35HBsmxeZW+uUrUk8FtDnDl/VlvCOIvkHNK+OLS2yk/NUMvbGb7Qzfp89KXEE X-Received: by 2002:a05:6a20:3b1e:b0:19a:6830:d735 with SMTP id c30-20020a056a203b1e00b0019a6830d735mr978027pzh.31.1705901406459; Sun, 21 Jan 2024 21:30:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705901406; cv=pass; d=google.com; s=arc-20160816; b=kghCeyYYolU3tDksNKE/cAU5pMgLwLFi2YG/gnmfOCePzLRdQZp8o3mdTm51PkfGgI 24BNrpecDau81eyswMriS2/dpPIDdcHxPaltsr9LV23+M9vqhoyso0nWQiFKmQe1sR0a aOq3hbJDO+BD9384fss/ojOY8RcagNFFbxe47YftvZ688gmEidJVpDPkg4Kujk3FZ0cQ CQPZSRa/p84MLUhxB20skvt9qdXQxu71B4ZB+6iNV2/LoItyf3RsCaNWXxJ1uZinh/Yg L7KWy2QRril5Mj+SxSoghnYTcdljzIYPORz8tTc88561qX80/OHcexGIOj2GTfPLwv23 FE5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TV0woCs0fQ8XRcekB66eRhSEHA7QujF8Q8y+Lk5A9+4=; fh=y/RjPbXBoPouJTPaYxwEImQW6x8GRiLpamQFwed/jf0=; b=YWO266wLYpR5Xzg2EuNJQKWu1CsYjdAI18JJIFI1bgRDNCBGcf83m0LW6Olh/xmKEb BLaL0yHIK5Ey4zGEOTbxS+LnYjGT+0RDfzYY37fP8YnzPpK6YZwzqDUpSpfoPAM/EIgo Bp4V0CD7WSVmHG5mJFq5TIqgur3V5emybcoKOGOuM1zfdJzOk6H5IxlZ/vNV47/g5220 5SoNBZBVLYWRrw9QYuaeMoafcUpwy0LN3lQvaA7bt/2TYTsmNJDysIgLwZ0fu4vhCyfu 5mLKxhXOP8KyQmKQS+7zf1JXFL4pbjslfmdcuujtUhWhMRAAogQoAoUthcGQHZFX6gFG vRpA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P2KiHTHh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32289-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32289-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b17-20020a17090aa59100b00290a6f3b319si896757pjq.125.2024.01.21.21.30.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 21:30:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32289-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P2KiHTHh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32289-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32289-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 388FFB21C17 for ; Mon, 22 Jan 2024 03:03:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC0454A39; Mon, 22 Jan 2024 03:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="P2KiHTHh" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 49BA41368; Mon, 22 Jan 2024 03:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892574; cv=none; b=rhYu1gEBJOyfyAYi/Q4UXwxdeyBBi5gO3MRLLGCHcCwvKl6Ej/Zb5LYuBYqCuTM/Cts5kMTFLy9Tva0PsSuPh9r8+tN3xZsqXqgNyRpeG4XRQkiqTrRujuLhedHkK06+YDa33EyhcNd9GGgGiAYy44nG3adGNm8PnkoqMekThlo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892574; c=relaxed/simple; bh=2he2Sh8f6FAIu+UM7iGZ5ZCP6Sfos+wDd/YvS0hJKqQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hz5Atkp+ayzi2y6Nhts4HVTMwmbQ64N3NVl5lSTRU7+zDVDnhMFMwnfB3BIFh56yz1KFofN/mz6iTpQTakEJ8F+3G0PVlAHhQ86qV/NQv7L4AU7ozmcCIFki1JP1bW67xqST9RKa0Sn2tnmDywtk75rVfekSBAE6LE33Ss7qqUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=ecsmtp.iind.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=P2KiHTHh; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ecsmtp.iind.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705892573; x=1737428573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2he2Sh8f6FAIu+UM7iGZ5ZCP6Sfos+wDd/YvS0hJKqQ=; b=P2KiHTHhyOxelkMfo8uGMNT67wp3mZ5PpqnApJoazN9NGFINbjNnC0K8 OiCFH/d43mxyEz8bt43rUV5vwgTY8S9ttm9bPkoqvQsI174BK2WtB8IYE gXNC696Ni6Tc414QZE3fFRjKzsDWFtcz1F39FI7FbSOP2TBrJo+SAHGiW adTHO2Ox8cKs0UoA7MCdEBFtkJIrpGTNPeXSMIidmGbwS0SesMGvGP44J fSsD+n/fKKc0p5/KiYQvwC6FevcrPD/TN5ATMqmnkkQt3jsisA26Fr4TA 83CcobzUjd/BG3I4yG16PN3ry4Orgue554yOr68hcJGgdIvqcNiKwtgTU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="14607317" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="14607317" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 19:02:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="1085517" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by orviesa003.jf.intel.com with ESMTP; 21 Jan 2024 19:02:42 -0800 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 1C517484B; Mon, 22 Jan 2024 08:32:41 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 196331600101; Mon, 22 Jan 2024 08:32:41 +0530 (IST) From: Raag Jadav To: u.kleine-koenig@pengutronix.de, jarkko.nikula@linux.intel.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, lakshmi.sowjanya.d@intel.com Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v1 1/3] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Date: Mon, 22 Jan 2024 08:32:36 +0530 Message-Id: <20240122030238.29437-2-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240122030238.29437-1-raag.jadav@intel.com> References: <20240122030238.29437-1-raag.jadav@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788767273113386080 X-GMAIL-MSGID: 1788767273113386080 Intel Elkhart Lake PSE includes two instances of PWM as a single PCI function with 8 channels each. Add support for the remaining channels. Signed-off-by: Raag Jadav Tested-by: Lakshmi Sowjanya D --- drivers/pwm/pwm-dwc.c | 51 +++++++++++++++++++++++++++++++++++-------- drivers/pwm/pwm-dwc.h | 5 +++++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index 4929354f8cd9..fd64313cb38d 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -25,16 +25,48 @@ #include "pwm-dwc.h" +/* Elkhart Lake */ +static const struct dwc_pwm_info ehl_pwm_info = { + .nr = 2, + .size = 0x1000, +}; + +static int dwc_pwm_init(struct device *dev, const struct dwc_pwm_info *info, void __iomem *base) +{ + /* Default values for single instance devices */ + unsigned int nr = 1, size = 0; + int i, ret; + + /* Fill up values from driver_data, if any */ + if (info) { + nr = info->nr; + size = info->size; + } + + for (i = 0; i < nr; i++) { + struct dwc_pwm *dwc; + + dwc = dwc_pwm_alloc(dev); + if (!dwc) + return -ENOMEM; + + dwc->base = base + (i * size); + + ret = devm_pwmchip_add(dev, &dwc->chip); + if (ret) + return ret; + } + + return 0; +} + static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) { + const struct dwc_pwm_info *info; struct device *dev = &pci->dev; - struct dwc_pwm *dwc; + void __iomem *base; int ret; - dwc = dwc_pwm_alloc(dev); - if (!dwc) - return -ENOMEM; - ret = pcim_enable_device(pci); if (ret) { dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret)); @@ -49,13 +81,14 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) return ret; } - dwc->base = pcim_iomap_table(pci)[0]; - if (!dwc->base) { + base = pcim_iomap_table(pci)[0]; + if (!base) { dev_err(dev, "Base address missing\n"); return -ENOMEM; } - ret = devm_pwmchip_add(dev, &dwc->chip); + info = (const struct dwc_pwm_info *)id->driver_data; + ret = dwc_pwm_init(dev, info, base); if (ret) return ret; @@ -109,7 +142,7 @@ static int dwc_pwm_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume); static const struct pci_device_id dwc_pwm_id_table[] = { - { PCI_VDEVICE(INTEL, 0x4bb7) }, /* Elkhart Lake */ + { PCI_VDEVICE(INTEL, 0x4bb7), (kernel_ulong_t)&ehl_pwm_info }, { } /* Terminating Entry */ }; MODULE_DEVICE_TABLE(pci, dwc_pwm_id_table); diff --git a/drivers/pwm/pwm-dwc.h b/drivers/pwm/pwm-dwc.h index 64795247c54c..c9bbfc77b568 100644 --- a/drivers/pwm/pwm-dwc.h +++ b/drivers/pwm/pwm-dwc.h @@ -33,6 +33,11 @@ MODULE_IMPORT_NS(dwc_pwm); #define DWC_TIM_CTRL_INT_MASK BIT(2) #define DWC_TIM_CTRL_PWM BIT(3) +struct dwc_pwm_info { + unsigned int nr; + unsigned int size; +}; + struct dwc_pwm_ctx { u32 cnt; u32 cnt2; From patchwork Mon Jan 22 03:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 189891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2358773dyb; Sun, 21 Jan 2024 20:14:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IETDb1vfBkrpH86S0NElqIayLnuOtCHqg/iSx7tH31NcA55dnmoQg5yO/sPdB0oFSTJNGzL X-Received: by 2002:a05:6359:494a:b0:176:2f9d:e83 with SMTP id mu10-20020a056359494a00b001762f9d0e83mr2575898rwb.35.1705896874989; Sun, 21 Jan 2024 20:14:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705896874; cv=pass; d=google.com; s=arc-20160816; b=LSNJ8epp2ClkOmNPDqfpbk1Z3NWHHrHjp8Nyz4opD+buRiEmhkGN9lbUElufVz3pZ/ A6BVTWBNStDwM26l5yLF4gKbfzkaEm8JayKVdunfk4hMayqfn7+F8PiJl7oHYxbsqHeQ /8cZDd8YEmowQqw2XLwq06iNh9cU5V6SDGZeRn8nuGlw6PgZLFHU7gzlhJAng98pHQh4 1y2Jq2DhS7kXpBcSggRfiGIBDP+JGv48oNB7O2gkpLKf3qQXHl63Um+k9wOBeT3unJ2j EowuXaWY3/AH0d5OAOlfeMcSyuWAd9IfGD6u9JD97KokbXqPQ05CeLBaTu1KlXBDaClw nInQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xMRbx4FQ9FPFNKS4y33cNbWCtnLHGscbGYm9cp/6uP4=; fh=y/RjPbXBoPouJTPaYxwEImQW6x8GRiLpamQFwed/jf0=; b=XRpwmHIvkIUhtQULcx2dhrdyzT1g5Elvm5o5bDbNGzWqQT7FdF+I++xArstV9WDKyX qD9JOKXVaM0teYeqq4e+4cY4VhBoNXvOOeGBh3uKo2F0fIBHB6icjekwnPCPTVsPSV24 6DnvYd4ZGKoza0m/VWOqwEPq4CqG6bO3takXiWIfxe57oAHCww5V38WEj3sdXROAkTZw 0rKikWtcgVoASyYLZXfVlzsuSDLBmnNrGu2LBijsHkLGTT5gKqfOghrKOoelezxCPPqo Q+ftXhNik9CbH6IWQ/H8zP07pAnNHcFgwOLSQnyCa3llSPirwrUwwUjZyQVMHf0no3Yt yG2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l3n6ufZI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m20-20020a17090a7f9400b0028e7e0ea35asi7535864pjl.109.2024.01.21.20.14.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 20:14:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l3n6ufZI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BAD7BB2290B for ; Mon, 22 Jan 2024 03:03:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B1D75677; Mon, 22 Jan 2024 03:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l3n6ufZI" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 49867139B; Mon, 22 Jan 2024 03:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892575; cv=none; b=SUxoWODzqaCm8StZOLHU7O4f1XKXExj7PzNuUAMOoOUxF/zFoclYY9CrrYCAelsnI8iw05EtUcaPMDcxl2awE4QtefIa5alhykLn//9TSITqxb9emzN4nlEOiR0Rye1feRGa6khnxS+klQ3ac3TJs0SSyKVvWxeZ/+EwMMVdlso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892575; c=relaxed/simple; bh=xXgc14YVJHCCXERS4eQXjRO7DnYkSw+VIjrQ5G10S6o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B6aIGh8y3BRuE9qIQJottR8RuW4y2HfnHiy1qGthxEEI4xUpPOSZ8VY+G9DxmYF+AnmSz+BG5vsGOM1XYH0dwl2UifD22Q/+Tn14depvgmQZkpY3pIONA3uX8HKVvnNsCoDY7TtmeYUG8K5BzW6Dja6z50CLXJyMxlYHuFAL67o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=ecsmtp.iind.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=l3n6ufZI; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ecsmtp.iind.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705892575; x=1737428575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xXgc14YVJHCCXERS4eQXjRO7DnYkSw+VIjrQ5G10S6o=; b=l3n6ufZIdeWo6updMVGtFHJhY8qibh7qlaUyv+wmdOZmsLewhLIwh4AR fMjTXDm5b9gkNdq5zR8qQvG4hVFqnY69BO7x8vM/0PcyjZL9QvrhqcSD8 yBuvqZmodR0cybDY/iwFMR3auM1qs2tHI51CDIAfM6ChqaiqDL0nHEoSu NBIOjR62P4ALaeBpAW/oMAjosp+WcUutGUownejUVub0bnjjnSEQwgRQB d0QeRtyx+nvMKwco2FsTJLnLmfVGdIrbUms9YspfmWYETx492Eme0XxxE UhKKPeJzDx2iCl0Pga06WuCB1xfalJ6XXRjpUrwo57tNUbwSH5lHIo+Ch Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="14607323" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="14607323" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 19:02:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="1085521" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by orviesa003.jf.intel.com with ESMTP; 21 Jan 2024 19:02:42 -0800 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 218854851; Mon, 22 Jan 2024 08:32:41 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 1C4E11600102; Mon, 22 Jan 2024 08:32:41 +0530 (IST) From: Raag Jadav To: u.kleine-koenig@pengutronix.de, jarkko.nikula@linux.intel.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, lakshmi.sowjanya.d@intel.com Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v1 2/3] pwm: dwc: simplify error handling Date: Mon, 22 Jan 2024 08:32:37 +0530 Message-Id: <20240122030238.29437-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240122030238.29437-1-raag.jadav@intel.com> References: <20240122030238.29437-1-raag.jadav@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788762521371741744 X-GMAIL-MSGID: 1788762521371741744 Simplify error handling in ->probe() function using dev_err_probe() helper. Signed-off-by: Raag Jadav --- drivers/pwm/pwm-dwc.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index fd64313cb38d..8f8035b047c1 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -68,24 +68,18 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) int ret; ret = pcim_enable_device(pci); - if (ret) { - dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret)); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret)); pci_set_master(pci); ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); - if (ret) { - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); base = pcim_iomap_table(pci)[0]; - if (!base) { - dev_err(dev, "Base address missing\n"); - return -ENOMEM; - } + if (!base) + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); info = (const struct dwc_pwm_info *)id->driver_data; ret = dwc_pwm_init(dev, info, base); From patchwork Mon Jan 22 03:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 189941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2420631dyb; Sun, 21 Jan 2024 23:51:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOglm0iQmeijDL4BQqb1bjNArFL9FGVaYCxDtspoDinmfv6xuANe4KCQD3yvKnRsKGGnNp X-Received: by 2002:a17:906:66da:b0:a2c:1b17:d267 with SMTP id k26-20020a17090666da00b00a2c1b17d267mr1874077ejp.148.1705909884836; Sun, 21 Jan 2024 23:51:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909884; cv=pass; d=google.com; s=arc-20160816; b=HH/bdTiB2lKHqkK78iwX5Il/s5xA5tGkZrmih93m4M6xsXT6/racxGKINveVjHMHK6 OaT+fz2Z7aXP6kjMyVpe6ltK8rkSRvdVMB2P+q4VKJ/CPJy6N2UUVdDsS2pvD2OyRItc 6Cq7CQP2p6S39Gq/8QOz8kWi6FlC42+x7Crsx8JBOic2sNSfDYXv30ekwZp/M1iwdMrU HVLTt6vuoO5DXUtYS0ffpKv4abX3oe8c9fpJTMpGpGnh3ZLHz9X8rKh151yHJNG4+/5A h/xIxnnhrOqu+ZMfl2b0BDFlllr0UJAJOY76iK26uwBE/qQz5ZkeHebI3/AGElzHQuAS UskQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eS+j/zxO/A13a5c6hDwTbQxnTMwXkUk6OE1+xwjjNdQ=; fh=y/RjPbXBoPouJTPaYxwEImQW6x8GRiLpamQFwed/jf0=; b=oK16D9QO83KCdtypKzopF2g6G3mGcx67A6y3lToeNCODd9tIyQFtVBtmMUcIdgL8hs b6YFFuC3LOQdVsQPUPcQjI42QlIXQvP7lzzTB6nGub0xRpYoRTvagRe1+TSwXf9W+dfs RJi8nHCPeTYEpazoGfimvSbYG1uzLG1Ra3zJElN4f1kp4ugE9PTzK3VdlH/rK0fWV+2i eg5l1wgO/OI+Ce0Rk3iAhTZ7NLWiIQ2SFtt+paUqrU0drKuOQoHrwYYl0lwle818QDIg ilFHIaxHS8TSMH4rY9puYOPsIhqMhzWy8+MWVNSgJZHDOMvs3WbDsliegtrMShq4NXF1 gApA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=laj4Elr3; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32292-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32292-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g23-20020a170906595700b00a305c712805si525644ejr.762.2024.01.21.23.51.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:51:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32292-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=laj4Elr3; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32292-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32292-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7B45F1F232CB for ; Mon, 22 Jan 2024 03:04:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E56716AA7; Mon, 22 Jan 2024 03:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="laj4Elr3" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 D82311C2D; Mon, 22 Jan 2024 03:02:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892577; cv=none; b=Zm5uAnyJHlMrNADtV7x4o5jy7lIHMw68yXfigQ1ywHPotUPsToPRi6bBtsg30GOyESvIO6KVHNQaf8CbUz9u5Nbv8mpU9iehDoU/2ltyBd9YcTdLKDMO9V59gq6DPplU30ZLzivK8njyHRTpKeEqh7TOWS2pU2uauou66zt6gAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892577; c=relaxed/simple; bh=UuttBsPusSkviTtBaHGivf1p+uWZkhK/ocLzEpk1Ga8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jIy3IV8LFWEBBZVQMRZ4TBJ5WJV34zP1fZCz0tSxtNwv4kgBQp1O7fml7e3oFDMV6Elsai/29YMfkWHM9gs2Q7MiUwV0TTJ3z8v6xSAr8K3thcNwwMDzrtUcyUoNteYnoEUVHrtnSsuuyeied1zhcqtOQPv0QLyM/gPCDwH5GGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=ecsmtp.iind.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=laj4Elr3; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ecsmtp.iind.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705892576; x=1737428576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UuttBsPusSkviTtBaHGivf1p+uWZkhK/ocLzEpk1Ga8=; b=laj4Elr3fcK/EpsHwn8MzfDzA/el9TQcL0JyECVpqf0KtfSX0081c6k/ g6Z+8iUL5ER7fPAOqNk8AqqMjGlF3Gz4xbDBbMoZ97mrpMTgXZIchFH1i 1RWqk9CNt+mlec+Dyn1gx1ZbBWwEX7MBTyWg5k09o56CjoNEE7W5GmcBQ K6cVzo0854bcT2/lBI+1WfBRbHtOq1qepcPJACKJdF1GGERVw2y7hlpWl QpAMbusTw7OatowXpQRf7LGq5pMz79URRbLIsPhmTsv9ckGMFz/jDVI1a 0zE+KKmJmNqa+oFa99WLsh5fIQ/YM1zzjMtIQiA8eEvlVMmGtHs3ZJWFf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="14607325" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="14607325" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 19:02:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="1085523" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by orviesa003.jf.intel.com with ESMTP; 21 Jan 2024 19:02:42 -0800 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 21851484E; Mon, 22 Jan 2024 08:32:41 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 1F34B1600100; Mon, 22 Jan 2024 08:32:41 +0530 (IST) From: Raag Jadav To: u.kleine-koenig@pengutronix.de, jarkko.nikula@linux.intel.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, lakshmi.sowjanya.d@intel.com Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v1 3/3] pwm: dwc: use to_pci_dev() helper Date: Mon, 22 Jan 2024 08:32:38 +0530 Message-Id: <20240122030238.29437-4-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240122030238.29437-1-raag.jadav@intel.com> References: <20240122030238.29437-1-raag.jadav@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788776163122093522 X-GMAIL-MSGID: 1788776163122093522 Use to_pci_dev() helper to get pci device reference. Signed-off-by: Raag Jadav --- drivers/pwm/pwm-dwc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index 8f8035b047c1..f5fcea4e69e2 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -100,7 +100,7 @@ static void dwc_pwm_remove(struct pci_dev *pci) static int dwc_pwm_suspend(struct device *dev) { - struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pdev = to_pci_dev(dev); struct dwc_pwm *dwc = pci_get_drvdata(pdev); int i; @@ -120,7 +120,7 @@ static int dwc_pwm_suspend(struct device *dev) static int dwc_pwm_resume(struct device *dev) { - struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pdev = to_pci_dev(dev); struct dwc_pwm *dwc = pci_get_drvdata(pdev); int i;