Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1933203lqm; Fri, 3 May 2024 10:20:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpZMVUcmQ8mBZq7HiK2E6Eu7h5vzHLsiYsIxQvUNibYxQscn1k0VrFRfAfUqj8PcMFa2Nk/JhY3OJ39dAFYaD6YJ3T8riHHMr9lzjqUQ== X-Google-Smtp-Source: AGHT+IHl7Ro/WMBqYjHFfTYzCWNxb1HN36N2Jj55v3WI/anWdpBJie6KTG4CIzxYFnpC8sgT6r/O X-Received: by 2002:a50:bac5:0:b0:570:369:3e06 with SMTP id x63-20020a50bac5000000b0057003693e06mr2045609ede.19.1714756857154; Fri, 03 May 2024 10:20:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714756857; cv=pass; d=google.com; s=arc-20160816; b=cOhR96zhEGkjbnAU1EM5azumYq8CQmCv3BgDdh450Iwd/HFiFQhPy+1UjptHB8Zcsa oY5CmXPEa9B8q7U299LghxHRQzBcKDB2yF0o9si9UnSkcNfNxkGQVbQ+YWv95DVb2SsP TeN25XMZZWq1yBVCzgIJpEIj+NZ0ceRWw8tgEL6bNUCA69LvPHj5d5SERBlsbQcq4hgg EQLh9k4Ned80n+qNVi6y8s8EvMypFfhFgxUnszcfIejIQofj/IXmAKMmCqxmqC6CrlGU g1GNnxzsWhsUW9oUEAG7K0T88SxkOhftHefcm/KLkwp/tJMAp5GL6knunkqlvFp5ESb3 khKQ== 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=Zx53yg/PfBZG5qMcnnXX69nZbQT0RkjmMESVNfJeYG8=; fh=iJf5csy0r5ybD7NaLRHWR20RoYCcjF+JTLc5MGZ+RdE=; b=Xn0/ZbEA9rS2C7B5jCv1PShVRBoKkRU51lHjRwLvN6d4JgzGZ9z5TjVGEemc+9PDje qLa8NIeVx8ntIAQcSYF3JyGp0cJOHrwcLclnoot/JDKqV6ALMWGUYM6l2+r3mZhLdXg2 6pVPPHKnBbNF+/qNTIxaS4P3JHv5TkH4UU/jdXUVDszryDeUgqnelhnAHy4fQzbt8hIG rcE+WVwvKLDU7emqx3uno+skftOzQOrbIMpJrjYmez5A1vizs6jEBvaPorvREySk+Qx9 ZqTs4YIrfrOCjzjCQYkCrQdUGAjRhSsfXDYD3GgPV6wJ83NIzsNpjbniBT+PYmFSi5Vp WICg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GYLqjtvl; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-167962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167962-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l19-20020a056402125300b005729fca3cf0si1623817edw.628.2024.05.03.10.20.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:20:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167962-linux.lists.archive=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=GYLqjtvl; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-167962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167962-linux.lists.archive=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 CFDBD1F23CF2 for ; Fri, 3 May 2024 17:20:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72129158A31; Fri, 3 May 2024 17:19:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GYLqjtvl" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 0075D1586C0; Fri, 3 May 2024 17:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714756786; cv=none; b=PcaSp7k3fyVk2QND3kSp6BEWlL9VFJ+MY0O5cSf8kGSOLveg9kb2tmYYzyQ0dGZG3TFll7M3iNZbqc+H72yNhkU6QAbb3qrw0wO6TqwR3CLvtozPKjVMiomhOvxXs6O6GG49CnWUli/L4sjrW/Yk2H2/TT0l/6yAkJzMXDsbpog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714756786; c=relaxed/simple; bh=Hcgz7372JSWmrvRQywcGylEztD7txJvhGznmILq6zB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pebHZ868J6iFkloq/RcKeGizvDP3Qj9V1KnwOlpiDdCSSZm6pAniXQTp92AvG08wNZ83OvZCdHrIgOF2IfiF5zoEMtPBtFRqQ4LvI8dZYuQ6NZHesJ345Mo+jTdCRKnu7t0//RVG9NVMgmDhoyuWQM7JFFVn2eHwrxjo8+LNI0w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GYLqjtvl; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714756785; x=1746292785; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hcgz7372JSWmrvRQywcGylEztD7txJvhGznmILq6zB4=; b=GYLqjtvldvH6QwwH8Lns9yQsk6jGcCfDUSYKI3QmtNYt0J4cUgIU3vDk nXDNF6tO3rX/8BzQY8voa9u4COCzT9kLOLp1PpBArZ/x3mEp/IhQbb1mc 0A1ahILEjSxErTMoVTMgwK4FWLNmk9twdOxGavxGIqSCIAjc1Ly5do64C FYuGNtgQq1St6XEGq7hDvJJ69/IaU3VZdac3O0nX+wfVLipBtrMDz6U/m edu/3nU3KwXAp8bKQUEimU/h7hf/trGaP1P4v82jkdtYidq2nDzakr3IZ NmcT9nYkUNs/4GpBcUqTsM/eiXsML3VMTI/rdyrSCK36e53kkbXkjBBuA A==; X-CSE-ConnectionGUID: Jf2h6PuARM63v7pZZsM6IQ== X-CSE-MsgGUID: PI7NB5/4RSalkxl5A3hn5w== X-IronPort-AV: E=McAfee;i="6600,9927,11063"; a="11107808" X-IronPort-AV: E=Sophos;i="6.07,251,1708416000"; d="scan'208";a="11107808" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 May 2024 10:19:44 -0700 X-CSE-ConnectionGUID: 0S5fgwx+RuGGjX3mv209/g== X-CSE-MsgGUID: vq5wy9W0SKq6Swtvz3e3Hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,251,1708416000"; d="scan'208";a="58415424" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa002.jf.intel.com with ESMTP; 03 May 2024 10:19:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 606F91C7; Fri, 3 May 2024 20:19:38 +0300 (EEST) From: Andy Shevchenko To: Parker Newman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v2 06/13] serial: 8250_exar: Extract cti_board_init_osc_freq() helper Date: Fri, 3 May 2024 20:15:58 +0300 Message-ID: <20240503171917.2921250-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240503171917.2921250-1-andriy.shevchenko@linux.intel.com> References: <20240503171917.2921250-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: 8bit Extract cti_board_init_osc_freq() helper to avoid code duplication. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_exar.c | 48 ++++++++++++----------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index ac373cde7e39..956323e2de4a 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -695,7 +695,6 @@ static int cti_read_osc_freq(struct exar8250 *priv, u8 eeprom_offset) { u16 lower_word; u16 upper_word; - int osc_freq; lower_word = exar_ee_read(priv, eeprom_offset); // Check if EEPROM word was blank @@ -706,10 +705,8 @@ static int cti_read_osc_freq(struct exar8250 *priv, u8 eeprom_offset) if (upper_word == 0xFFFF) return -EIO; - osc_freq = FIELD_PREP(CTI_EE_MASK_OSC_FREQ_LOWER, lower_word) | - FIELD_PREP(CTI_EE_MASK_OSC_FREQ_UPPER, upper_word); - - return osc_freq; + return FIELD_PREP(CTI_EE_MASK_OSC_FREQ_LOWER, lower_word) | + FIELD_PREP(CTI_EE_MASK_OSC_FREQ_UPPER, upper_word); } /** @@ -890,6 +887,19 @@ static int cti_rs485_config_mpio_tristate(struct uart_port *port, return cti_tristate_disable(priv, port->port_id); } +static void cti_board_init_osc_freq(struct exar8250 *priv, struct pci_dev *pcidev, u8 eeprom_offset) +{ + int osc_freq; + + osc_freq = cti_read_osc_freq(priv, eeprom_offset); + if (osc_freq <= 0) { + dev_warn(&pcidev->dev, "failed to read OSC freq from EEPROM, using default\n"); + osc_freq = CTI_DEFAULT_PCI_OSC_FREQ; + } + + priv->osc_freq = osc_freq; +} + static int cti_port_setup_common(struct exar8250 *priv, struct pci_dev *pcidev, int idx, unsigned int offset, @@ -1095,19 +1105,9 @@ static int cti_board_init_xr17v35x(struct exar8250 *priv, return 0; } -static int cti_board_init_xr17v25x(struct exar8250 *priv, - struct pci_dev *pcidev) +static int cti_board_init_xr17v25x(struct exar8250 *priv, struct pci_dev *pcidev) { - int osc_freq; - - osc_freq = cti_read_osc_freq(priv, CTI_EE_OFF_XR17V25X_OSC_FREQ); - if (osc_freq < 0) { - dev_warn(&pcidev->dev, - "failed to read osc freq from EEPROM, using default\n"); - osc_freq = CTI_DEFAULT_PCI_OSC_FREQ; - } - - priv->osc_freq = osc_freq; + cti_board_init_osc_freq(priv, pcidev, CTI_EE_OFF_XR17V25X_OSC_FREQ); /* enable interrupts on cards that need the "PLX fix" */ switch (pcidev->subsystem_device) { @@ -1123,19 +1123,9 @@ static int cti_board_init_xr17v25x(struct exar8250 *priv, return 0; } -static int cti_board_init_xr17c15x(struct exar8250 *priv, - struct pci_dev *pcidev) +static int cti_board_init_xr17c15x(struct exar8250 *priv, struct pci_dev *pcidev) { - int osc_freq; - - osc_freq = cti_read_osc_freq(priv, CTI_EE_OFF_XR17C15X_OSC_FREQ); - if (osc_freq <= 0) { - dev_warn(&pcidev->dev, - "failed to read osc freq from EEPROM, using default\n"); - osc_freq = CTI_DEFAULT_PCI_OSC_FREQ; - } - - priv->osc_freq = osc_freq; + cti_board_init_osc_freq(priv, pcidev, CTI_EE_OFF_XR17C15X_OSC_FREQ); /* enable interrupts on cards that need the "PLX fix" */ switch (pcidev->subsystem_device) { -- 2.43.0.rc1.1336.g36b5255a03ac