Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp677279rwn; Thu, 8 Sep 2022 07:21:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR7NN1IDHAxEL6Fj5HFiExYv9BXLxYcb4O5Y26u5u6V7UfD4uEXmGxYZ6VFwQVeQPSOg3AYp X-Received: by 2002:a05:6a00:1309:b0:535:d421:1347 with SMTP id j9-20020a056a00130900b00535d4211347mr9463784pfu.5.1662646870900; Thu, 08 Sep 2022 07:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662646870; cv=none; d=google.com; s=arc-20160816; b=V8YPxjYVAtLAa89ekuDqx6MEqIKO89PCY9upd5IS64UysQyhTofx99WP0fsmWLgjFp BlNaC7l7Jak9vG/h2k7ZpuNbmN4bbQKpH7xBgTe3pV2QOA8bSCkUZhRHtw1RDtmDkeH7 mnqfInFgPfIWbCTnMaTvCp8lrXxlCTD1Aaf+tCKr1tKaQA+4Vmb6JZL2pYXqcfVWBrzc 2cpmxTyULTOf2/C0GgpV+Ddeo0mHIbX0S5WzGyz2tmgK+zDsET32KewSs5A3vGN5GTUs Okj1Ld5rDmDRoCgp7C4gaQmG9xmY7t/NheqGES1O1K3+54pnQ2kxQjK9i+IUmSZVVKK3 YFDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/SRADEoQqUo3mbIOIgtkK+pzbblbjJORu23UgXSUGHk=; b=QvbF7FhuK1WoYZ9rDFDmEpI407PYIM/PLSp/kDds5X1hlo9tG9lLa2PX1go0I5/PMi rdHCE/F2g01DcvX+LiR37njfxyduxCE04p2kJwzzsCakKDrcK+jl54hBC2HBwrl6S+9G oeZM2Fxf2+HiDZUzMRxSVgXHgEyESh7bUMLz3J5Pog/XZNDVCuKdFXRUJcTdULfJQc+T 2VPK286YvlJZ7lCzldSJ3nG5qU5Y6gs39jqgeU0bCmFgyl1rAMCWgjiVyjrL2BUFjjhz mYxlQQFUtsw3egtudaYDfrsuG7ASegr5Pg8s1ftABE5AmEoasRh1aTuVBojvlPr/GTrn K1nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LpijGDeI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h66-20020a636c45000000b00434aeab58e8si8124943pgc.545.2022.09.08.07.20.58; Thu, 08 Sep 2022 07:21:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LpijGDeI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232234AbiIHN5C (ORCPT + 99 others); Thu, 8 Sep 2022 09:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232105AbiIHN4u (ORCPT ); Thu, 8 Sep 2022 09:56:50 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C294EF6B99; Thu, 8 Sep 2022 06:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662645408; x=1694181408; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U0M4rURxAQdIUswdrgfXetFrt5wcmcw5VSJDicfcomI=; b=LpijGDeIx1AsqsPaYHvkW9I/OzaoMFW02i7i72h3cmwPbBZ4sulqLXvp TEXFhUktvHPK4Qv/PkIWHc9QJRkquOM2WTnUM9CnnIK+9DBA3BxF+tRzU tl9buUrfcAel/hJgdYT1KYNX4ktI8+qIkO4DoijN/ZVqZu4ms2WeKq+iI TNx+R5bmE+VyoqRjxKNxwLNXHESXNTRhuPCbyPk5MriztmSuEncIr1BEG YkQnghVCyIKBqfcde++mNJCQMASQZEQNTIuAghpa//Y3ryqXg2BRSWJ+9 uVmzDggfhTWmYRafY0etH98r3rBTx/wjXHIF6En0+09s/PMhuLUsH0bLm A==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="358906738" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="358906738" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 06:56:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="943352125" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 08 Sep 2022 06:56:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 77F7145C; Thu, 8 Sep 2022 16:57:02 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Cc: Thierry Reding Subject: [PATCH v2 3/9] pwm: lpss: Move resource mapping to the glue drivers Date: Thu, 8 Sep 2022 16:56:52 +0300 Message-Id: <20220908135658.64463-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220908135658.64463-1-andriy.shevchenko@linux.intel.com> References: <20220908135658.64463-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move resource mapping to the glue drivers which helps to transform pwm_lpss_probe() to pure library function that may be used by others without need of specific resource management. Signed-off-by: Andy Shevchenko --- drivers/pwm/pwm-lpss-pci.c | 6 +++++- drivers/pwm/pwm-lpss-platform.c | 9 ++++++--- drivers/pwm/pwm-lpss.c | 7 ++----- drivers/pwm/pwm-lpss.h | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c index 9f2c666b95ec..f3367e844e61 100644 --- a/drivers/pwm/pwm-lpss-pci.c +++ b/drivers/pwm/pwm-lpss-pci.c @@ -25,8 +25,12 @@ static int pwm_lpss_probe_pci(struct pci_dev *pdev, if (err < 0) return err; + err = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev)); + if (err) + return err; + info = (struct pwm_lpss_boardinfo *)id->driver_data; - lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info); + lpwm = pwm_lpss_probe(&pdev->dev, pcim_iomap_table(pdev)[0], info); if (IS_ERR(lpwm)) return PTR_ERR(lpwm); diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c index 65154c0abab1..7bbbb7a9b578 100644 --- a/drivers/pwm/pwm-lpss-platform.c +++ b/drivers/pwm/pwm-lpss-platform.c @@ -21,16 +21,19 @@ static int pwm_lpss_probe_platform(struct platform_device *pdev) const struct pwm_lpss_boardinfo *info; const struct acpi_device_id *id; struct pwm_lpss_chip *lpwm; - struct resource *r; + void __iomem *base; id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); if (!id) return -ENODEV; info = (const struct pwm_lpss_boardinfo *)id->driver_data; - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - lpwm = pwm_lpss_probe(&pdev->dev, r, info); + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + lpwm = pwm_lpss_probe(&pdev->dev, base, info); if (IS_ERR(lpwm)) return PTR_ERR(lpwm); diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index 74a296cb1af0..a20915459809 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c @@ -243,7 +243,7 @@ static const struct pwm_ops pwm_lpss_ops = { .owner = THIS_MODULE, }; -struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, +struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base, const struct pwm_lpss_boardinfo *info) { struct pwm_lpss_chip *lpwm; @@ -258,10 +258,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, if (!lpwm) return ERR_PTR(-ENOMEM); - lpwm->regs = devm_ioremap_resource(dev, r); - if (IS_ERR(lpwm->regs)) - return ERR_CAST(lpwm->regs); - + lpwm->regs = base; lpwm->info = info; c = lpwm->info->clk_rate; diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h index 9ea5b145a353..c344921b2cab 100644 --- a/drivers/pwm/pwm-lpss.h +++ b/drivers/pwm/pwm-lpss.h @@ -38,7 +38,7 @@ extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info; extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info; extern const struct pwm_lpss_boardinfo pwm_lpss_tng_info; -struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, +struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base, const struct pwm_lpss_boardinfo *info); #endif /* __PWM_LPSS_H */ -- 2.35.1