Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1701649pxb; Mon, 8 Mar 2021 04:25:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIk4lK359IYtQzsBuefRY987NDsaSOxSqUXVkJyOhyS0cxvDDuHkzbZ/yUl5CQOtIk/QaP X-Received: by 2002:a17:906:d9d1:: with SMTP id qk17mr14809140ejb.52.1615206325799; Mon, 08 Mar 2021 04:25:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615206325; cv=none; d=google.com; s=arc-20160816; b=Q+s8nfX2qN1B3q5eEHtBNNfxh+9w1+hnc4FnbYmH0tKC8KyHANVnCGtejgwk1TNI86 v3BmdbfJ1Mi07Wkf8F3Excem3aGxhfBjGEXuueyhSLdNDxLx8fOLDzBpEj9PO3yuCvK4 hL6jDfEfI1Iv99HD3O2kuSMrZTMns8QqBnhPkZP4+jZeZM1Ope7c6QNHo4zHxsPcc2AK delKvICY4EWZJ7LBES6+yaKAzzXSrwmD+HM/Ern/aAwZ9szoqVy6jjVk/KnApYsGpCvp T9hZSIRvf6nO1t7gDdNFWBAvfgwTVKnLYb0KoWdn4JBmNvxjflFQNK9sta0ev/q9coSE 4cSA== 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 :ironport-sdr:ironport-sdr; bh=g9vOlI38f4aTjYiJzXG7sJknGaQ09tSjjw8Q3dPt0mk=; b=XJQYif2kcSTNymIwJTccMQugsISuE+PP602X/P6jG+S06M18POGg+J38EZl3yZNjXT agbzqdPN0qRetlq1ze1604g+NPXRZkcEqU30qdh3U1dgvw/7bxSx+NkOy/QAXvWSK0St aBA24I9A6p1/iA1ylR255O3ZUpmiQx4tCv7xO1xefPPVzFZTZAF0b/1doDudUfL+1okM 1cA4lT/PMapGfJyCjFhUH7djWUCiC+g96BG8TXdZCrM6yuKmPD/k+PWKZ//SWgW3aCUu WPw8DDlzIF9fyU5DaN4D4dOprxhixLcCDvf7lB2Py4aabLAl00ufcZgLuq599GIv1y23 nDTA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si6577313edw.446.2021.03.08.04.25.01; Mon, 08 Mar 2021 04:25:25 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbhCHMUz (ORCPT + 99 others); Mon, 8 Mar 2021 07:20:55 -0500 Received: from mga12.intel.com ([192.55.52.136]:52723 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbhCHMUm (ORCPT ); Mon, 8 Mar 2021 07:20:42 -0500 IronPort-SDR: PZ5EcfDbbkwuNTBHD7gK4UCo2DL3cJK7ZWXRXrV/X7eUwgBdbjmS/ay3nGTG8OxLFIhp1zFzZG C5RrnkMceafA== X-IronPort-AV: E=McAfee;i="6000,8403,9916"; a="167288037" X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="167288037" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2021 04:20:41 -0800 IronPort-SDR: fSv4514lS+BwTAYRGvBpsn5EFCTYomMuaTpSj1R21DCWGD1sXJ7lzEfdUIRNcnJcPhrvSMUVRR AMt/kuKR0zNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="588032254" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 08 Mar 2021 04:20:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1E405490; Mon, 8 Mar 2021 14:20:38 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Jean Delvare , Lee Jones , Andy Shevchenko , Tan Jui Nee , Jim Quinlan , Jonathan Yong , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org Cc: Jean Delvare , Peter Tyser , hdegoede@redhat.com, henning.schild@siemens.com Subject: [PATCH v1 4/7] mfd: lpc_ich: Factor out lpc_ich_enable_spi_write() Date: Mon, 8 Mar 2021 14:20:17 +0200 Message-Id: <20210308122020.57071-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122020.57071-1-andriy.shevchenko@linux.intel.com> References: <20210308122020.57071-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factor out duplicate code to lpc_ich_enable_spi_write() helper function. Signed-off-by: Andy Shevchenko --- drivers/mfd/lpc_ich.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c index 3bbb29a7e7a5..3a19ed57260e 100644 --- a/drivers/mfd/lpc_ich.c +++ b/drivers/mfd/lpc_ich.c @@ -1083,12 +1083,21 @@ static int lpc_ich_init_wdt(struct pci_dev *dev) return ret; } +static void lpc_ich_test_spi_write(struct pci_dev *dev, unsigned int devfn, + struct intel_spi_boardinfo *info) +{ + u32 bcr; + + pci_bus_read_config_dword(dev->bus, devfn, BCR, &bcr); + info->writeable = !!(bcr & BCR_WPD); +} + static int lpc_ich_init_spi(struct pci_dev *dev) { struct lpc_ich_priv *priv = pci_get_drvdata(dev); struct resource *res = &intel_spi_res[0]; struct intel_spi_boardinfo *info; - u32 spi_base, rcba, bcr; + u32 spi_base, rcba; info = devm_kzalloc(&dev->dev, sizeof(*info), GFP_KERNEL); if (!info) @@ -1112,8 +1121,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev) res->start = spi_base + SPIBASE_LPT; res->end = res->start + SPIBASE_LPT_SZ - 1; - pci_read_config_dword(dev, BCR, &bcr); - info->writeable = !!(bcr & BCR_WPD); + lpc_ich_test_spi_write(dev, dev->devfn, info); } break; @@ -1134,8 +1142,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev) res->start = spi_base & 0xfffffff0; res->end = res->start + SPIBASE_APL_SZ - 1; - pci_bus_read_config_dword(bus, spi, BCR, &bcr); - info->writeable = !!(bcr & BCR_WPD); + lpc_ich_test_spi_write(dev, spi, info); } pci_bus_write_config_byte(bus, p2sb, 0xe1, 0x1); -- 2.30.1